Merge remote-tracking branch 'origin/dev' into dev

master
袁野 1 year ago
commit e55aeb291d
  1. 4
      service/src/main/java/com/hfkj/dao/BsTradeOrderMapperExt.java
  2. 4
      service/src/main/java/com/hfkj/dao/BsTransferAccountsMapperExt.java
  3. 3
      service/src/main/java/com/hfkj/service/impl/BsTradeOrderRefundServiceImpl.java
  4. 174
      service/src/main/java/com/hfkj/service/impl/BsTradeOrderServiceImpl.java
  5. 2
      service/src/main/java/com/hfkj/service/rebate/impl/BsRebateActivityAccountServiceImpl.java
  6. 2
      service/src/main/java/com/hfkj/service/rebate/impl/BsRebateActivityServiceImpl.java

@ -32,4 +32,8 @@ public interface BsTradeOrderMapperExt {
"</script>") "</script>")
Map<String,Object> countTradeOrderPrice(@Param("param") Map<String, Object> param); Map<String,Object> countTradeOrderPrice(@Param("param") Map<String, Object> param);
@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);
} }

@ -14,10 +14,10 @@ public interface BsTransferAccountsMapperExt {
@Select(" SELECT mer_no merNo," + @Select(" SELECT mer_no merNo," +
" sum(rebate_activity_actual_price) totalPrice " + " sum(rebate_activity_actual_price) totalPrice " +
" FROM bs_trade_order where rebate_activity_part = 1 " + " FROM bs_trade_order where rebate_activity_part = 1 " +
" <![CDATA[ and pay_time >= #{startTimeS} ]]>" + " <![CDATA[ and pay_time >= #{startTime} ]]>" +
" <![CDATA[ and pay_time <= #{endTime} ]]>" + " <![CDATA[ and pay_time <= #{endTime} ]]>" +
" and `status` = 3" + " and `status` = 3" +
" GROUP BY mer_no") " GROUP BY mer_no")
List<Map<String,Object>> queryTradeRebate(@Param("startTimeS") String startTime, @Param("endTime") String endTime); List<Map<String,Object>> queryTradeRebate(@Param("startTime") String startTime, @Param("endTime") String endTime);
} }

@ -74,6 +74,9 @@ public class BsTradeOrderRefundServiceImpl implements BsTradeOrderRefundService
if (tradeOrder == null) { if (tradeOrder == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的交易订单"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的交易订单");
} }
if (tradeOrder.getRebateActivityPart().equals(true)) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法退款,交易订单已参加优惠活动");
}
if (StringUtils.isNotBlank(tradeOrder.getUserPhone())) { if (StringUtils.isNotBlank(tradeOrder.getUserPhone())) {
if (HsgIntegralService.recycleIntegral(tradeOrder.getId().toString(),tradeOrder.getOutTradeNo()).equals(false)) { if (HsgIntegralService.recycleIntegral(tradeOrder.getId().toString(),tradeOrder.getOutTradeNo()).equals(false)) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "用户积分不足,暂时无法退款"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "用户积分不足,暂时无法退款");

@ -224,60 +224,134 @@ public class BsTradeOrderServiceImpl implements BsTradeOrderService {
editOrder(tradeOrder); editOrder(tradeOrder);
// 商户活动金活动 if (StringUtils.isNotBlank(userPhone)) {
BsRebateActivity rebateActivity = rebateActivityService.getMerCurrentActivity(mer.getMerNo()); // 查询商户的活动金 优惠活动
if (rebateActivity != null && rebateActivity.getEndTime().compareTo(new Date()) >= 0) { BsRebateActivity rebateActivity = rebateActivityService.getMerCurrentActivity(mer.getMerNo());
if (rebateActivity.getActivityType().equals(RebateActivityTypeEnum.type1.getNumber())) { if (rebateActivity != null && rebateActivity.getEndTime().compareTo(new Date()) >= 0) {
if (rebateActivity.getPreferentialType().equals(RebateActivityPreferentialTypeEnum.type1.getNumber())) { // 优惠活动限制
// 达到满减门槛 if (rebateActivity.getRestrictPartakeType().equals(RebateActivityPartakeTypeEnum.type1.getNumber())) {
if (tradeOrder.getTradeAmount().compareTo(rebateActivity.getCondition()) >= 0) { // 查询用户交易次数
tradeOrder.setRebateActivityPart(true); Calendar timeS = Calendar.getInstance();
tradeOrder.setRebateActivityId(rebateActivity.getId()); timeS.setTime(new Date());
tradeOrder.setRebateActivityNo(rebateActivity.getActivityNo()); timeS.set(Calendar.HOUR_OF_DAY, 00);
tradeOrder.setRebateActivityType(rebateActivity.getActivityType()); timeS.set(Calendar.MINUTE, 00);
tradeOrder.setRebateActivityPreferentialType(rebateActivity.getPreferentialType()); timeS.set(Calendar.SECOND, 00);
tradeOrder.setRebateActivityPrice(rebateActivity.getPrice());
tradeOrder.setRebateActivityActualPrice(rebateActivity.getPrice()); Calendar timeE = Calendar.getInstance();
tradeOrder.setTradeActualAmount(tradeOrder.getTradeActualAmount().subtract(tradeOrder.getRebateActivityActualPrice())); timeE.setTime(new Date());
timeE.set(Calendar.HOUR_OF_DAY, 23);
timeE.set(Calendar.MINUTE, 59);
timeE.set(Calendar.SECOND, 59);
Integer userTrade = tradeOrderMapper.countUserTrade(
userPhone,
DateUtil.format(timeS.getTime(), "yyyy-MM-dd HH:mm:ss"),
DateUtil.format(timeE.getTime(), "yyyy-MM-dd HH:mm:ss"));
if (userTrade < rebateActivity.getRestrictPartakeNum()) {
if (rebateActivity.getActivityType().equals(RebateActivityTypeEnum.type1.getNumber())) {
if (rebateActivity.getPreferentialType().equals(RebateActivityPreferentialTypeEnum.type1.getNumber())) {
// 达到满减门槛
if (tradeOrder.getTradeAmount().compareTo(rebateActivity.getCondition()) >= 0) {
tradeOrder.setRebateActivityPart(true);
tradeOrder.setRebateActivityId(rebateActivity.getId());
tradeOrder.setRebateActivityNo(rebateActivity.getActivityNo());
tradeOrder.setRebateActivityType(rebateActivity.getActivityType());
tradeOrder.setRebateActivityPreferentialType(rebateActivity.getPreferentialType());
tradeOrder.setRebateActivityPrice(rebateActivity.getPrice());
tradeOrder.setRebateActivityActualPrice(rebateActivity.getPrice());
tradeOrder.setTradeActualAmount(tradeOrder.getTradeActualAmount().subtract(tradeOrder.getRebateActivityActualPrice()));
}
} else if (rebateActivity.getPreferentialType().equals(RebateActivityPreferentialTypeEnum.type2.getNumber())) {
tradeOrder.setRebateActivityPart(true);
tradeOrder.setRebateActivityId(rebateActivity.getId());
tradeOrder.setRebateActivityNo(rebateActivity.getActivityNo());
tradeOrder.setRebateActivityType(rebateActivity.getActivityType());
tradeOrder.setRebateActivityPreferentialType(rebateActivity.getPreferentialType());
tradeOrder.setRebateActivityPrice(rebateActivity.getPrice());
tradeOrder.setRebateActivityActualPrice(rebateActivity.getPrice());
tradeOrder.setTradeActualAmount(tradeOrder.getTradeActualAmount().subtract(tradeOrder.getRebateActivityActualPrice()));
} else if (rebateActivity.getPreferentialType().equals(RebateActivityPreferentialTypeEnum.type3.getNumber())) {
tradeOrder.setRebateActivityPart(true);
tradeOrder.setRebateActivityId(rebateActivity.getId());
tradeOrder.setRebateActivityNo(rebateActivity.getActivityNo());
tradeOrder.setRebateActivityType(rebateActivity.getActivityType());
tradeOrder.setRebateActivityPreferentialType(rebateActivity.getPreferentialType());
tradeOrder.setRebateActivityPrice(rebateActivity.getPrice());
// 优惠折扣
BigDecimal priceRate = tradeOrder.getRebateActivityPrice().divide(new BigDecimal("10")).setScale(2, BigDecimal.ROUND_DOWN);
tradeOrder.setRebateActivityActualPrice(tradeOrder.getTradeActualAmount().subtract(tradeOrder.getTradeActualAmount().multiply(priceRate).setScale(2, BigDecimal.ROUND_HALF_UP)));
tradeOrder.setTradeActualAmount(tradeOrder.getTradeActualAmount().subtract(tradeOrder.getRebateActivityActualPrice()));
}
}
}
} else {
if (rebateActivity.getActivityType().equals(RebateActivityTypeEnum.type1.getNumber())) {
if (rebateActivity.getPreferentialType().equals(RebateActivityPreferentialTypeEnum.type1.getNumber())) {
// 达到满减门槛
if (tradeOrder.getTradeAmount().compareTo(rebateActivity.getCondition()) >= 0) {
tradeOrder.setRebateActivityPart(true);
tradeOrder.setRebateActivityId(rebateActivity.getId());
tradeOrder.setRebateActivityNo(rebateActivity.getActivityNo());
tradeOrder.setRebateActivityType(rebateActivity.getActivityType());
tradeOrder.setRebateActivityPreferentialType(rebateActivity.getPreferentialType());
tradeOrder.setRebateActivityPrice(rebateActivity.getPrice());
tradeOrder.setRebateActivityActualPrice(rebateActivity.getPrice());
tradeOrder.setTradeActualAmount(tradeOrder.getTradeActualAmount().subtract(tradeOrder.getRebateActivityActualPrice()));
}
} else if (rebateActivity.getPreferentialType().equals(RebateActivityPreferentialTypeEnum.type2.getNumber())) {
tradeOrder.setRebateActivityPart(true);
tradeOrder.setRebateActivityId(rebateActivity.getId());
tradeOrder.setRebateActivityNo(rebateActivity.getActivityNo());
tradeOrder.setRebateActivityType(rebateActivity.getActivityType());
tradeOrder.setRebateActivityPreferentialType(rebateActivity.getPreferentialType());
tradeOrder.setRebateActivityPrice(rebateActivity.getPrice());
tradeOrder.setRebateActivityActualPrice(rebateActivity.getPrice());
tradeOrder.setTradeActualAmount(tradeOrder.getTradeActualAmount().subtract(tradeOrder.getRebateActivityActualPrice()));
} else if (rebateActivity.getPreferentialType().equals(RebateActivityPreferentialTypeEnum.type3.getNumber())) {
tradeOrder.setRebateActivityPart(true);
tradeOrder.setRebateActivityId(rebateActivity.getId());
tradeOrder.setRebateActivityNo(rebateActivity.getActivityNo());
tradeOrder.setRebateActivityType(rebateActivity.getActivityType());
tradeOrder.setRebateActivityPreferentialType(rebateActivity.getPreferentialType());
tradeOrder.setRebateActivityPrice(rebateActivity.getPrice());
// 优惠折扣
BigDecimal priceRate = tradeOrder.getRebateActivityPrice().divide(new BigDecimal("10")).setScale(2, BigDecimal.ROUND_DOWN);
tradeOrder.setRebateActivityActualPrice(tradeOrder.getTradeActualAmount().subtract(tradeOrder.getTradeActualAmount().multiply(priceRate).setScale(2, BigDecimal.ROUND_HALF_UP)));
tradeOrder.setTradeActualAmount(tradeOrder.getTradeActualAmount().subtract(tradeOrder.getRebateActivityActualPrice()));
}
}
}
if (tradeOrder.getRebateActivityPart().equals(true)) {
RebateActivityAccountTradeObject accountTradeObject = new RebateActivityAccountTradeObject();
accountTradeObject.setTradeObjectType(RebateActivityAccountObjectTypeEnum.type3);
accountTradeObject.setTradeObjectId(tradeOrder.getId());
accountTradeObject.setTradeObjectContent("创建交易" + tradeOrder.getOutTradeNo());
Boolean activityAccount = rebateActivityAccountService.accountTrade(
tradeOrder.getRebateActivityNo(),
RebateActivityAccountTradeTypeEnum.type2,
tradeOrder.getRebateActivityActualPrice(),
accountTradeObject);
if (activityAccount.equals(true)) {
editOrder(tradeOrder);
} else {
tradeOrder.setRebateActivityPart(false);
tradeOrder.setRebateActivityId(null);
tradeOrder.setRebateActivityNo(null);
tradeOrder.setRebateActivityType(null);
tradeOrder.setRebateActivityPreferentialType(null);
tradeOrder.setRebateActivityPrice(null);
tradeOrder.setRebateActivityActualPrice(null);
tradeOrder.setTradeActualAmount(null);
} }
} else if (rebateActivity.getPreferentialType().equals(RebateActivityPreferentialTypeEnum.type2.getNumber())) {
tradeOrder.setRebateActivityPart(true);
tradeOrder.setRebateActivityId(rebateActivity.getId());
tradeOrder.setRebateActivityNo(rebateActivity.getActivityNo());
tradeOrder.setRebateActivityType(rebateActivity.getActivityType());
tradeOrder.setRebateActivityPreferentialType(rebateActivity.getPreferentialType());
tradeOrder.setRebateActivityPrice(rebateActivity.getPrice());
tradeOrder.setRebateActivityActualPrice(rebateActivity.getPrice());
tradeOrder.setTradeActualAmount(tradeOrder.getTradeActualAmount().subtract(tradeOrder.getRebateActivityActualPrice()));
} else if (rebateActivity.getPreferentialType().equals(RebateActivityPreferentialTypeEnum.type3.getNumber())) {
tradeOrder.setRebateActivityPart(true);
tradeOrder.setRebateActivityId(rebateActivity.getId());
tradeOrder.setRebateActivityNo(rebateActivity.getActivityNo());
tradeOrder.setRebateActivityType(rebateActivity.getActivityType());
tradeOrder.setRebateActivityPreferentialType(rebateActivity.getPreferentialType());
tradeOrder.setRebateActivityPrice(rebateActivity.getPrice());
// 优惠折扣
BigDecimal priceRate = tradeOrder.getRebateActivityPrice().divide(new BigDecimal("10")).setScale(2, BigDecimal.ROUND_DOWN);
tradeOrder.setRebateActivityActualPrice(tradeOrder.getTradeActualAmount().subtract(tradeOrder.getTradeActualAmount().multiply(priceRate).setScale(2, BigDecimal.ROUND_HALF_UP)));
tradeOrder.setTradeActualAmount(tradeOrder.getTradeActualAmount().subtract(tradeOrder.getRebateActivityActualPrice()));
} }
editOrder(tradeOrder);
}
if (tradeOrder.getRebateActivityPart().equals(true)) {
RebateActivityAccountTradeObject accountTradeObject = new RebateActivityAccountTradeObject();
accountTradeObject.setTradeObjectType(RebateActivityAccountObjectTypeEnum.type3);
accountTradeObject.setTradeObjectId(tradeOrder.getId());
accountTradeObject.setTradeObjectContent("创建交易" + tradeOrder.getOutTradeNo());
rebateActivityAccountService.accountTrade(
tradeOrder.getRebateActivityNo(),
RebateActivityAccountTradeTypeEnum.type2,
tradeOrder.getRebateActivityActualPrice(),
accountTradeObject
);
} }
} }
Map<String, Object> returnParam = new HashMap<>(); Map<String, Object> returnParam = new HashMap<>();

@ -221,7 +221,7 @@ public class BsRebateActivityAccountServiceImpl implements BsRebateActivityAccou
} else if (tradeType.getNumber().equals(RebateActivityAccountTradeTypeEnum.type2.getNumber())) { } else if (tradeType.getNumber().equals(RebateActivityAccountTradeTypeEnum.type2.getNumber())) {
// 扣款金额是否大于账户余额 // 扣款金额是否大于账户余额
if (tradeAmount.compareTo(account.getAmount()) >= 0) { if (tradeAmount.compareTo(account.getAmount()) > 0) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "账户余额不足"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "账户余额不足");
} }
account.setAmount(account.getAmount().subtract(tradeAmount)); account.setAmount(account.getAmount().subtract(tradeAmount));

@ -97,7 +97,7 @@ public class BsRebateActivityServiceImpl implements BsRebateActivityService {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "活动状态错误"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "活动状态错误");
} }
activity.setStatus(RebateActivityStatusEnum.status3.getNumber()); activity.setStatus(RebateActivityStatusEnum.status3.getNumber());
activity.setRestrictPartakeType(rebateActivityEndTypeEnum.getNumber()); activity.setRealityEndType(rebateActivityEndTypeEnum.getNumber());
if (RebateActivityEndTypeEnum.type1.getNumber().equals(rebateActivityEndTypeEnum.getNumber())) { if (RebateActivityEndTypeEnum.type1.getNumber().equals(rebateActivityEndTypeEnum.getNumber())) {
activity.setRealityEndTime(activity.getEndTime()); activity.setRealityEndTime(activity.getEndTime());

Loading…
Cancel
Save