消费返现触发问题
This commit is contained in:
parent
0afcba22df
commit
a1886bd26c
|
|
@ -1,6 +1,7 @@
|
|||
package com.czg.service.market.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.czg.account.dto.shopuser.ShopUserMoneyEditDTO;
|
||||
|
|
@ -95,19 +96,22 @@ public class MkConsumeCashbackServiceImpl extends ServiceImpl<MkConsumeCashbackM
|
|||
@Transactional(rollbackFor = Exception.class)
|
||||
public void cashback(Long shopId, Long userId, BigDecimal amount, Long orderId, String orderNo) {
|
||||
AssertUtil.isTrue(amount == null || amount.compareTo(BigDecimal.ZERO) == 0, "金额必须大于0");
|
||||
log.info("消费返现1, shopId: {}, userId: {}, amount: {}, orderId: {}, orderNo: {}", shopId, userId, amount, orderId, orderNo);
|
||||
Long mainShopId = shopInfoService.getMainIdByShopId(shopId);
|
||||
MkConsumeCashbackVO config = detail(mainShopId);
|
||||
if (config.getIsEnable() == 0) {
|
||||
log.info("消费返现未开启, {}", shopId);
|
||||
return;
|
||||
}
|
||||
log.info("消费返现2, orderId: {}, orderNo: {}, config: {}", orderId, orderNo,config);
|
||||
ShopUser shopUser = shopUserService.getOne(new QueryWrapper().eq(ShopUser::getMainShopId, mainShopId).eq(ShopUser::getUserId, userId));
|
||||
List<MkConsumeCashbackStep> cashbackStepList = config.getCashbackStepList();
|
||||
if (cashbackStepList != null && !cashbackStepList.isEmpty()) {
|
||||
log.info("消费返现2, orderId: {}, cashbackStepList:{}", orderId, cashbackStepList);
|
||||
if (CollUtil.isNotEmpty(cashbackStepList)) {
|
||||
|
||||
config.setCashbackStepList(cashbackStepList.stream().sorted(Comparator.comparing(MkConsumeCashbackStep::getAmount)).collect(Collectors.toList()));
|
||||
for (MkConsumeCashbackStep cashbackStep : cashbackStepList) {
|
||||
|
||||
log.info("消费返现3, cashbackStep: {}, userId: {}, amount: {}, orderId: {}", cashbackStep, userId, amount, orderId);
|
||||
if (cashbackStep.getAmount().compareTo(amount) <= 0 ) {
|
||||
BigDecimal cashbackAmount;
|
||||
// 固定金额
|
||||
|
|
|
|||
|
|
@ -399,7 +399,7 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|||
}
|
||||
|
||||
//优惠券部分 目前规则 每个券只能用一张
|
||||
if (CollUtil.isNotEmpty(param.getCouponList()) && (!param.isFreeDine() || param.isWithCoupon())){
|
||||
if (CollUtil.isNotEmpty(param.getCouponList()) && (!param.isFreeDine() || param.isWithCoupon())) {
|
||||
QueryWrapper couponRecordQuery = new QueryWrapper();
|
||||
couponRecordQuery.in(MkShopCouponRecord::getId, param.getCouponList());
|
||||
couponRecordQuery.le(MkShopCouponRecord::getUseStartTime, LocalDateTime.now());
|
||||
|
|
@ -1087,12 +1087,14 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|||
log.error("订单{}消费赠券失败", orderInfo.getId(), e);
|
||||
}
|
||||
}
|
||||
log.info("消费返现 start, orderId: {}, payType1: {} ,payType2: {}", orderInfo.getId(), orderInfo.getPayType(), payType);
|
||||
String[] payTypes = {PayEnums.VIP_PAY.getValue(), PayEnums.CREDIT_PAY.getValue()};
|
||||
if ((orderInfo.getPayType() != null && !ArrayUtil.contains(payTypes, orderInfo.getPayType()))
|
||||
|| (payType != null && !ArrayUtil.contains(payTypes, payType))) {
|
||||
//下单赠送积分
|
||||
pointsService.consumeAwardPoints(shopUser.getId(), orderInfo);
|
||||
if(!orderInfo.getPayType().equals(PayEnums.CASH_PAY.getValue())){
|
||||
//消费返现
|
||||
if (!orderInfo.getPayType().equals(PayEnums.CASH_PAY.getValue())) {
|
||||
consumeCashbackService.cashback(orderInfo.getShopId(), shopUser.getUserId(), orderInfo.getPayAmount(), orderInfo.getId(), orderInfo.getOrderNo());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue