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