diff --git a/schedule/src/main/java/com/hfkj/schedule/TransferSchedule.java b/schedule/src/main/java/com/hfkj/schedule/TransferSchedule.java index f8ecfbc..e83ceff 100644 --- a/schedule/src/main/java/com/hfkj/schedule/TransferSchedule.java +++ b/schedule/src/main/java/com/hfkj/schedule/TransferSchedule.java @@ -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> list = tradeOrderService.countMerUserDiscountPrice(startTime.getTime(), endTime.getTime()); + for (Map 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("转账失败"); + } + } + } + /** * 活动金优惠 - 转账商户 */ diff --git a/service/src/main/java/com/hfkj/dao/BsTradeOrderMapperExt.java b/service/src/main/java/com/hfkj/dao/BsTradeOrderMapperExt.java index 2f75066..fb69cb3 100644 --- a/service/src/main/java/com/hfkj/dao/BsTradeOrderMapperExt.java +++ b/service/src/main/java/com/hfkj/dao/BsTradeOrderMapperExt.java @@ -35,5 +35,16 @@ public interface BsTradeOrderMapperExt { @Select("SELECT count(1) FROM `bs_trade_order` where user_phone = #{userPhone} and `status` = 3 and rebate_activity_part = 1 and pay_time BETWEEN #{timeS} and #{timeE} ") Integer countUserTrade(@Param("userPhone") String userPhone, @Param("timeS") String timeS, @Param("timeE") String timeE); - + + @Select("") + List> countMerUserDiscountPrice(@Param("startTime") String startTime, @Param("endTime") String endTime); } diff --git a/service/src/main/java/com/hfkj/service/BsTradeOrderService.java b/service/src/main/java/com/hfkj/service/BsTradeOrderService.java index 67ec912..aedc23f 100644 --- a/service/src/main/java/com/hfkj/service/BsTradeOrderService.java +++ b/service/src/main/java/com/hfkj/service/BsTradeOrderService.java @@ -9,6 +9,7 @@ import com.hfkj.sysenum.TradeOrderPayModeEnum; import javax.servlet.http.HttpServletRequest; import java.math.BigDecimal; +import java.util.Date; import java.util.List; import java.util.Map; @@ -80,4 +81,11 @@ public interface BsTradeOrderService { */ Map countTradeOrderPrice(Map param); + /** + * 获取商户用户优惠券优惠金额 + * @param startTime + * @param endTime + * @return + */ + List> countMerUserDiscountPrice(Date startTime, Date endTime); } diff --git a/service/src/main/java/com/hfkj/service/impl/BsTradeOrderServiceImpl.java b/service/src/main/java/com/hfkj/service/impl/BsTradeOrderServiceImpl.java index b30750c..cfbfcd8 100644 --- a/service/src/main/java/com/hfkj/service/impl/BsTradeOrderServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/impl/BsTradeOrderServiceImpl.java @@ -649,4 +649,12 @@ public class BsTradeOrderServiceImpl implements BsTradeOrderService { return tradeOrderMapper.countTradeOrderPrice(paramMap); } + @Override + public List> countMerUserDiscountPrice(Date startTime, Date endTime) { + return tradeOrderMapper.countMerUserDiscountPrice( + DateUtil.format(startTime, DateUtil.Y_M_D_HMS), + DateUtil.format(endTime, DateUtil.Y_M_D_HMS) + ); + } + }