@ -5,6 +5,7 @@ import com.hfkj.channel.tianque.service.TianQueFundManageService;
import com.hfkj.common.utils.DateUtil ;
import com.hfkj.entity.* ;
import com.hfkj.service.BsMerService ;
import com.hfkj.service.BsTradeOrderService ;
import com.hfkj.service.BsTransferAccountsService ;
import com.hfkj.service.rebate.BsRebateTransferCycleService ;
import com.hfkj.sysenum.TransferAccountsStatus ;
@ -39,6 +40,9 @@ public class TransferSchedule {
@Resource
private TianQueFundManageService tianQueFundManageService ;
@Resource
private BsTradeOrderService tradeOrderService ;
@Resource
private BsMerService merService ;
@ -75,6 +79,46 @@ public class TransferSchedule {
}
}
/ * *
* 用户优惠券 - 转账商户
* /
@Scheduled ( cron = "0 0 1 * * ?" ) // 每日凌晨1点执行
public void tradeUserDiscount ( ) {
Calendar startTime = Calendar . getInstance ( ) ;
startTime . setTime ( new Date ( ) ) ;
startTime . add ( Calendar . DAY_OF_MONTH , - 1 ) ;
startTime . set ( Calendar . HOUR_OF_DAY , 00 ) ;
startTime . set ( Calendar . MINUTE , 00 ) ;
startTime . set ( Calendar . SECOND , 00 ) ;
Calendar endTime = Calendar . getInstance ( ) ;
endTime . add ( Calendar . DAY_OF_MONTH , - 1 ) ;
endTime . setTime ( new Date ( ) ) ;
endTime . set ( Calendar . HOUR_OF_DAY , 00 ) ;
endTime . set ( Calendar . MINUTE , 00 ) ;
endTime . set ( Calendar . SECOND , 00 ) ;
List < Map < String , Object > > list = tradeOrderService . countMerUserDiscountPrice ( startTime . getTime ( ) , endTime . getTime ( ) ) ;
for ( Map < String , Object > param : list ) {
try {
BsMer mer = merService . getMer ( MapUtils . getString ( param , "merNo" ) ) ;
if ( mer ! = null ) {
BsTransferAccounts transferAccounts = new BsTransferAccounts ( ) ;
transferAccounts . setMerId ( mer . getId ( ) ) ;
transferAccounts . setMerNo ( mer . getMerNo ( ) ) ;
transferAccounts . setMerName ( mer . getMerName ( ) ) ;
transferAccounts . setMerAbbreviate ( mer . getMerAbbreviate ( ) ) ;
transferAccounts . setOrderNo ( "1000" + System . currentTimeMillis ( ) + "" ) ;
transferAccounts . setAmount ( new BigDecimal ( MapUtils . getString ( param , "totalPrice" ) ) ) ;
transferAccounts . setContent ( DateUtil . date2String ( startTime . getTime ( ) , "yyyy-MM-dd" ) + "客户优惠券结算" ) ;
transferAccountsService . transfer ( transferAccounts ) ;
}
} catch ( Exception e ) {
System . out . println ( "转账失败" ) ;
}
}
}
/ * *
* 活动金优惠 - 转账商户
* /