@ -4,9 +4,12 @@ import au.com.royalpay.payment.manage.activities.monsettledelay.core.ActMonDelay
import au.com.royalpay.payment.manage.mappers.act.ActAppMapper ;
import au.com.royalpay.payment.manage.mappers.act.ActAppMapper ;
import au.com.royalpay.payment.manage.mappers.act.ActMonDelaySettleMapper ;
import au.com.royalpay.payment.manage.mappers.act.ActMonDelaySettleMapper ;
import au.com.royalpay.payment.manage.mappers.act.ActMonDelaySettleRedPackMapper ;
import au.com.royalpay.payment.manage.mappers.act.ActMonDelaySettleRedPackMapper ;
import au.com.royalpay.payment.manage.mappers.log.ClientsOperationLogMapper ;
import au.com.royalpay.payment.manage.mappers.system.ClientAccountMapper ;
import au.com.royalpay.payment.manage.mappers.system.ClientAccountMapper ;
import au.com.royalpay.payment.manage.merchants.core.ClientManager ;
import au.com.royalpay.payment.tools.device.DeviceSupport ;
import au.com.royalpay.payment.tools.device.DeviceSupport ;
import au.com.royalpay.payment.tools.env.PlatformEnvironment ;
import au.com.royalpay.payment.tools.env.PlatformEnvironment ;
import au.com.royalpay.payment.tools.env.RequestEnvironment ;
import au.com.royalpay.payment.tools.exceptions.BadRequestException ;
import au.com.royalpay.payment.tools.exceptions.BadRequestException ;
import au.com.royalpay.payment.tools.exceptions.ForbiddenException ;
import au.com.royalpay.payment.tools.exceptions.ForbiddenException ;
import au.com.royalpay.payment.tools.permission.enums.PartnerRole ;
import au.com.royalpay.payment.tools.permission.enums.PartnerRole ;
@ -17,7 +20,9 @@ import com.github.miemiedev.mybatis.paginator.domain.Order;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds ;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds ;
import com.github.miemiedev.mybatis.paginator.domain.PageList ;
import com.github.miemiedev.mybatis.paginator.domain.PageList ;
import org.springframework.context.MessageSource ;
import org.springframework.stereotype.Service ;
import org.springframework.stereotype.Service ;
import org.springframework.transaction.annotation.Transactional ;
import org.springframework.util.Assert ;
import org.springframework.util.Assert ;
import java.math.BigDecimal ;
import java.math.BigDecimal ;
@ -40,12 +45,15 @@ public class ActMonDelaySettleServiceImp implements ActMonDelaySettleService {
private ClientAccountMapper clientAccountMapper ;
private ClientAccountMapper clientAccountMapper ;
@Resource
@Resource
private ActAppMapper actAppMapper ;
private ActAppMapper actAppMapper ;
@Resource
private ClientsOperationLogMapper clientsOperationLogMapper ;
@Resource
private ClientManager clientManager ;
@Resource
private MessageSource messageSource ;
@Override
@Override
public JSONObject getActNotice ( JSONObject device ) {
public JSONObject getActNotice ( JSONObject device ) {
String clientType = device . getString ( "client_type" ) ;
deviceSupport . findRegister ( clientType ) ;
int client_id = device . getIntValue ( "client_id" ) ;
int client_id = device . getIntValue ( "client_id" ) ;
BigDecimal total_redpack = actMonDelaySettleRedPackMapper . getTotalRedPack ( client_id ) ;
BigDecimal total_redpack = actMonDelaySettleRedPackMapper . getTotalRedPack ( client_id ) ;
JSONObject res = new JSONObject ( ) ;
JSONObject res = new JSONObject ( ) ;
@ -62,15 +70,14 @@ public class ActMonDelaySettleServiceImp implements ActMonDelaySettleService {
if ( ! act . getBoolean ( "is_valid" ) ) {
if ( ! act . getBoolean ( "is_valid" ) ) {
throw new BadRequestException ( "Activity is not valid" ) ;
throw new BadRequestException ( "Activity is not valid" ) ;
}
}
String clientType = device . getString ( "client_type" ) ;
deviceSupport . findRegister ( clientType ) ;
int client_id = device . getIntValue ( "client_id" ) ;
int client_id = device . getIntValue ( "client_id" ) ;
List < JSONObject > clientLogs = actMonDelaySettleMapper . clientLog ( client_id ) ;
List < JSONObject > clientLogs = actMonDelaySettleMapper . clientLog ( client_id ) ;
JSONObject res = new JSONObject ( ) ;
JSONObject res = new JSONObject ( ) ;
res . put ( "operation_pause" , false ) ;
res . put ( "operation_pause" , false ) ;
Boolean apply = false ;
Boolean apply = true ;
if ( ! clientLogs . isEmpty ( ) ) {
if ( clientLogs . isEmpty ( ) ) {
apply = true ;
apply = false ;
res . put ( "cancel_waring" , messageSource . getMessage ( "sys.mondelay.cancel.waring" , null , RequestEnvironment . getLocale ( ) ) ) ;
}
}
if ( new Date ( ) . compareTo ( act . getDate ( "active_date" ) ) < 0 ) {
if ( new Date ( ) . compareTo ( act . getDate ( "active_date" ) ) < 0 ) {
res . put ( "active" , false ) ;
res . put ( "active" , false ) ;
@ -92,10 +99,12 @@ public class ActMonDelaySettleServiceImp implements ActMonDelaySettleService {
res . put ( "apply" , apply ) ;
res . put ( "apply" , apply ) ;
res . put ( "total_redpack" , total_redpack ) ;
res . put ( "total_redpack" , total_redpack ) ;
res . put ( "list" , list ) ;
res . put ( "list" , list ) ;
return res ;
return res ;
}
}
@Override
@Override
@Transactional
public void actApply ( JSONObject device ) {
public void actApply ( JSONObject device ) {
LocalDateTime dt = LocalDateTime . now ( ) ;
LocalDateTime dt = LocalDateTime . now ( ) ;
if ( dt . getDayOfWeek ( ) = = DayOfWeek . MONDAY & & dt . getHour ( ) < 18 ) {
if ( dt . getDayOfWeek ( ) = = DayOfWeek . MONDAY & & dt . getHour ( ) < 18 ) {
@ -112,8 +121,6 @@ public class ActMonDelaySettleServiceImp implements ActMonDelaySettleService {
if ( new Date ( ) . compareTo ( act . getDate ( "expire_date" ) ) > 0 ) {
if ( new Date ( ) . compareTo ( act . getDate ( "expire_date" ) ) > 0 ) {
throw new BadRequestException ( "The activity has expired" ) ;
throw new BadRequestException ( "The activity has expired" ) ;
}
}
String clientType = device . getString ( "client_type" ) ;
deviceSupport . findRegister ( clientType ) ;
int client_id = device . getIntValue ( "client_id" ) ;
int client_id = device . getIntValue ( "client_id" ) ;
List < JSONObject > clientLogs = actMonDelaySettleMapper . clientLog ( client_id ) ;
List < JSONObject > clientLogs = actMonDelaySettleMapper . clientLog ( client_id ) ;
if ( ! clientLogs . isEmpty ( ) ) {
if ( ! clientLogs . isEmpty ( ) ) {
@ -129,16 +136,19 @@ public class ActMonDelaySettleServiceImp implements ActMonDelaySettleService {
device . put ( "rate" , params . getBigDecimal ( "rate" ) = = null ? new BigDecimal ( 0.15 ) : params . getBigDecimal ( "rate" ) ) ;
device . put ( "rate" , params . getBigDecimal ( "rate" ) = = null ? new BigDecimal ( 0.15 ) : params . getBigDecimal ( "rate" ) ) ;
device . put ( "expire_time" , act . getDate ( "expire_date" ) ) ;
device . put ( "expire_time" , act . getDate ( "expire_date" ) ) ;
actMonDelaySettleMapper . save ( device ) ;
actMonDelaySettleMapper . save ( device ) ;
clientManager . changeManualSettle ( client_id , true , device . getString ( "account_id" ) , 1 , "参加活动打开手动清算" ) ;
}
}
@Override
@Override
@Transactional
public void cancelAct ( JSONObject device ) {
public void cancelAct ( JSONObject device ) {
LocalDateTime dt = LocalDateTime . now ( ) ;
LocalDateTime dt = LocalDateTime . now ( ) ;
if ( dt . getDayOfWeek ( ) = = DayOfWeek . MONDAY & & dt . getHour ( ) < 18 ) {
if ( dt . getDayOfWeek ( ) = = DayOfWeek . MONDAY & & dt . getHour ( ) < 18 ) {
throw new BadRequestException ( "每周一0点至18点为收益计算时间,暂停退出活动操作" ) ;
throw new BadRequestException ( "每周一0点至18点为收益计算时间,暂停退出活动操作" ) ;
}
}
String clientType = device . getString ( "client_type" ) ;
deviceSupport . findRegister ( clientType ) ;
int client_id = device . getIntValue ( "client_id" ) ;
int client_id = device . getIntValue ( "client_id" ) ;
List < JSONObject > clientLogs = actMonDelaySettleMapper . clientLog ( client_id ) ;
List < JSONObject > clientLogs = actMonDelaySettleMapper . clientLog ( client_id ) ;
if ( clientLogs . isEmpty ( ) ) {
if ( clientLogs . isEmpty ( ) ) {
@ -148,6 +158,8 @@ public class ActMonDelaySettleServiceImp implements ActMonDelaySettleService {
clientLog . put ( "is_valid" , 0 ) ;
clientLog . put ( "is_valid" , 0 ) ;
clientLog . put ( "expire_time" , new Date ( ) ) ;
clientLog . put ( "expire_time" , new Date ( ) ) ;
actMonDelaySettleMapper . update ( clientLog ) ;
actMonDelaySettleMapper . update ( clientLog ) ;
clientManager . changeManualSettle ( client_id , false , device . getString ( "account_id" ) , 1 , "退出活动关闭手动清算" ) ;
}
}
}
}