提交代码

master
胡锐 12 months ago
parent e9d7af7b3c
commit 2fa5eb3057
  1. 44
      schedule/src/main/java/com/hfkj/schedule/TransferSchedule.java
  2. 11
      service/src/main/java/com/hfkj/dao/BsTradeOrderMapperExt.java
  3. 8
      service/src/main/java/com/hfkj/service/BsTradeOrderService.java
  4. 8
      service/src/main/java/com/hfkj/service/impl/BsTradeOrderServiceImpl.java

@ -5,6 +5,7 @@ import com.hfkj.channel.tianque.service.TianQueFundManageService;
import com.hfkj.common.utils.DateUtil; import com.hfkj.common.utils.DateUtil;
import com.hfkj.entity.*; import com.hfkj.entity.*;
import com.hfkj.service.BsMerService; import com.hfkj.service.BsMerService;
import com.hfkj.service.BsTradeOrderService;
import com.hfkj.service.BsTransferAccountsService; import com.hfkj.service.BsTransferAccountsService;
import com.hfkj.service.rebate.BsRebateTransferCycleService; import com.hfkj.service.rebate.BsRebateTransferCycleService;
import com.hfkj.sysenum.TransferAccountsStatus; import com.hfkj.sysenum.TransferAccountsStatus;
@ -39,6 +40,9 @@ public class TransferSchedule {
@Resource @Resource
private TianQueFundManageService tianQueFundManageService; private TianQueFundManageService tianQueFundManageService;
@Resource
private BsTradeOrderService tradeOrderService;
@Resource @Resource
private BsMerService merService; 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("转账失败");
}
}
}
/** /**
* 活动金优惠 - 转账商户 * 活动金优惠 - 转账商户
*/ */

@ -36,4 +36,15 @@ 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} ") @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); Integer countUserTrade(@Param("userPhone") String userPhone, @Param("timeS") String timeS, @Param("timeE") String timeE);
@Select("<script>" +
" select " +
" mer_no merNo," +
" sum(user_discount_actual_price) totalPrice" +
" from bs_trade_order " +
" where `status` = 3 and user_discount_actual_price is not null " +
" <![CDATA[ and pay_time >= #{startTime} ]]>" +
" <![CDATA[ and pay_time <= #{endTime} ]]>" +
" GROUP BY mer_no " +
" </script>")
List<Map<String,Object>> countMerUserDiscountPrice(@Param("startTime") String startTime, @Param("endTime") String endTime);
} }

@ -9,6 +9,7 @@ import com.hfkj.sysenum.TradeOrderPayModeEnum;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -80,4 +81,11 @@ public interface BsTradeOrderService {
*/ */
Map<String,Object> countTradeOrderPrice(Map<String, Object> param); Map<String,Object> countTradeOrderPrice(Map<String, Object> param);
/**
* 获取商户用户优惠券优惠金额
* @param startTime
* @param endTime
* @return
*/
List<Map<String,Object>> countMerUserDiscountPrice(Date startTime, Date endTime);
} }

@ -649,4 +649,12 @@ public class BsTradeOrderServiceImpl implements BsTradeOrderService {
return tradeOrderMapper.countTradeOrderPrice(paramMap); return tradeOrderMapper.countTradeOrderPrice(paramMap);
} }
@Override
public List<Map<String, Object>> countMerUserDiscountPrice(Date startTime, Date endTime) {
return tradeOrderMapper.countMerUserDiscountPrice(
DateUtil.format(startTime, DateUtil.Y_M_D_HMS),
DateUtil.format(endTime, DateUtil.Y_M_D_HMS)
);
}
} }

Loading…
Cancel
Save