消费返现
充值触发条件成为会员 霸王餐触发条件成为会员
This commit is contained in:
@@ -194,16 +194,18 @@ public class MkConsumeCashbackServiceImpl extends ServiceImpl<MkConsumeCashbackM
|
||||
.setMainShopId(record.getMainShopId())
|
||||
.setShopId(shopId)
|
||||
.setAmount(BigDecimal.ZERO)
|
||||
.setCashbackAmount(record.getAmount().negate())
|
||||
.setCashbackAmount(record.getCashbackAmount().negate())
|
||||
.setUserId(userId)
|
||||
.setShopUserId(record.getShopUserId());
|
||||
consumeCashbackRecordService.save(mkConsumeCashbackRecord);
|
||||
shopUserService.updateMoney(new ShopUserMoneyEditDTO().setId(record.getShopUserId()).setType(0)
|
||||
shopUserService.updateMoney(new ShopUserMoneyEditDTO()
|
||||
.setId(record.getShopUserId())
|
||||
.setType(0)
|
||||
.setRelationId(mkConsumeCashbackRecord.getId())
|
||||
.setMoney(record.getAmount())
|
||||
.setMoney(record.getCashbackAmount())
|
||||
.setBizEnum(ShopUserFlowBizEnum.CASHBACK)
|
||||
.setRemark(StrUtil.format("订单退款,扣除返现: {}", record.getAmount())));
|
||||
log.info("订单退款扣除返现 订单ID:{}, 店铺用户id: {}, 扣除返现: {}", orderId, record.getShopUserId(), record.getAmount());
|
||||
.setRemark(StrUtil.format("订单退款,扣除返现: {}", record.getCashbackAmount())));
|
||||
log.info("订单退款扣除返现 订单ID:{}, 店铺用户id: {}, 扣除返现: {}", orderId, record.getShopUserId(), record.getCashbackAmount());
|
||||
|
||||
AcUserMsg msg = new AcUserMsg()
|
||||
.setUserId(userId)
|
||||
@@ -212,7 +214,7 @@ public class MkConsumeCashbackServiceImpl extends ServiceImpl<MkConsumeCashbackM
|
||||
.setSourceType("order")
|
||||
.setType("cash")
|
||||
.setTitle("订单退款,消费返现扣除")
|
||||
.setContent(StrUtil.format("返现扣除提醒: 订单退款扣除的{}元返现。订单编号:{}", record.getAmount(), orderNo));
|
||||
.setContent(StrUtil.format("返现扣除提醒: 订单退款扣除的{}元返现。订单编号:{}", record.getCashbackAmount(), orderNo));
|
||||
acUserMsgService.addUserMsg(msg);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.czg.market.enums.PointsConstant;
|
||||
import com.czg.market.service.*;
|
||||
import com.czg.market.vo.*;
|
||||
import com.czg.utils.AssertUtil;
|
||||
import com.czg.utils.FunUtils;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.czg.market.entity.MkShopRecharge;
|
||||
@@ -45,6 +46,8 @@ public class MkShopRechargeServiceImpl extends ServiceImpl<MkShopRechargeMapper,
|
||||
@Resource
|
||||
private MkShopRechargeDetailService shopRechargeDetailService;
|
||||
@Resource
|
||||
private TbMemberConfigService memberConfigService;
|
||||
@Resource
|
||||
private ShopCouponService shopCouponService;
|
||||
@DubboReference
|
||||
private ShopUserService shopUserService;
|
||||
@@ -159,7 +162,8 @@ public class MkShopRechargeServiceImpl extends ServiceImpl<MkShopRechargeMapper,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recharge(Long shopId, Long shopUserId, Long rechargeDetailId, BigDecimal amount, Long paymentId, String payType, ShopUserFlowBizEnum bizEnum) {
|
||||
public void recharge(Long shopId, Long shopUserId, Long rechargeDetailId, BigDecimal amount, Long paymentId,
|
||||
String payType, ShopUserFlowBizEnum bizEnum, boolean isNoJoin) {
|
||||
log.info("充值回调, 用户id: {}, 金额: {}, rechargeDetailId: {}", shopUserId, amount, rechargeDetailId);
|
||||
ShopUser shopUser = shopUserService.getById(shopUserId);
|
||||
ShopUserMoneyEditDTO shopUserMoneyEditDTO = new ShopUserMoneyEditDTO()
|
||||
@@ -168,7 +172,6 @@ public class MkShopRechargeServiceImpl extends ServiceImpl<MkShopRechargeMapper,
|
||||
.setBizEnum(bizEnum)
|
||||
.setRelationId(paymentId);
|
||||
|
||||
|
||||
// 标准充值
|
||||
if (rechargeDetailId != null) {
|
||||
MkShopRechargeDetail rechargeDetail = shopRechargeDetailService.getById(rechargeDetailId);
|
||||
@@ -195,10 +198,10 @@ public class MkShopRechargeServiceImpl extends ServiceImpl<MkShopRechargeMapper,
|
||||
return;
|
||||
}
|
||||
// try {
|
||||
shopCouponRecordService.grant(shopId, new MkRewardCouponDTO().setCouponId(item.getId())
|
||||
.setNum(item.getNum())
|
||||
.setUserId(shopUser.getUserId())
|
||||
.setShopId(shopId), "充值赠券");
|
||||
shopCouponRecordService.grant(shopId, new MkRewardCouponDTO().setCouponId(item.getId())
|
||||
.setNum(item.getNum())
|
||||
.setUserId(shopUser.getUserId())
|
||||
.setShopId(shopId), "充值赠券");
|
||||
// } catch (Exception e) {
|
||||
// log.warn("发放优惠券失败", e);
|
||||
// }
|
||||
@@ -209,7 +212,9 @@ public class MkShopRechargeServiceImpl extends ServiceImpl<MkShopRechargeMapper,
|
||||
shopUserMoneyEditDTO.setMoney(amount);
|
||||
}
|
||||
shopUserService.updateMoney(shopUserMoneyEditDTO);
|
||||
|
||||
if (isNoJoin) {
|
||||
FunUtils.transactionSafeRun(() -> memberConfigService.joinMemberByCondition(shopId, shopUser.getUserId(), shopUser));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -11,7 +11,6 @@ import com.czg.account.entity.ShopUser;
|
||||
import com.czg.account.service.ShopConfigService;
|
||||
import com.czg.account.service.ShopInfoService;
|
||||
import com.czg.account.service.ShopUserService;
|
||||
import com.czg.account.service.UserInfoService;
|
||||
import com.czg.constant.TableValueConstant;
|
||||
import com.czg.constants.PayTypeConstants;
|
||||
import com.czg.exception.CzgException;
|
||||
@@ -60,8 +59,6 @@ public class TbMemberConfigServiceImpl extends ServiceImpl<TbMemberConfigMapper,
|
||||
@Resource
|
||||
private MemberLevelConfigService levelConfigService;
|
||||
@DubboReference
|
||||
private UserInfoService userInfoService;
|
||||
@DubboReference
|
||||
private ShopUserService shopUserService;
|
||||
@Resource
|
||||
private OrderInfoService orderInfoService;
|
||||
@@ -345,13 +342,11 @@ public class TbMemberConfigServiceImpl extends ServiceImpl<TbMemberConfigMapper,
|
||||
}
|
||||
|
||||
if (levelVO.getCycleRewardCouponList() != null && !levelVO.getCycleRewardCouponList().isEmpty()) {
|
||||
levelVO.getCycleRewardCouponList().forEach(item -> {
|
||||
shopCouponRecordService.grant(shopUser.getMainShopId(), new MkRewardCouponDTO().setCouponId(item.getCoupon().getId())
|
||||
.setNum(item.getNum())
|
||||
.setUserId(shopUser.getUserId())
|
||||
.setShopId(shopUser.getMainShopId()), "购买会员赠券");
|
||||
|
||||
});
|
||||
levelVO.getCycleRewardCouponList().forEach(item ->
|
||||
shopCouponRecordService.grant(shopUser.getMainShopId(), new MkRewardCouponDTO().setCouponId(item.getCoupon().getId())
|
||||
.setNum(item.getNum())
|
||||
.setUserId(shopUser.getUserId())
|
||||
.setShopId(shopUser.getMainShopId()), "购买会员赠券"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -425,13 +420,14 @@ public class TbMemberConfigServiceImpl extends ServiceImpl<TbMemberConfigMapper,
|
||||
orderInfoService.getOneAs(query().select("IFNULL(sum(pay_amount), 0) as total_amount").eq(OrderInfo::getShopId, shopId).eq(OrderInfo::getUserId, shopUser.getUserId())
|
||||
.eq(OrderInfo::getStatus, OrderStatusEnums.DONE.getCode()), BigDecimal.class)
|
||||
.compareTo(new BigDecimal(item.getValue())) >= 0;
|
||||
case "RECHARGE_AMOUNT" -> paymentService.getOneAs(query().select("IFNULL(sum(amount), 0) as total_amount")
|
||||
.eq(OrderPayment::getShopId, shopId)
|
||||
.eq(OrderPayment::getSourceType, PayTypeConstants.SourceType.MEMBER_IN)
|
||||
.eq(OrderPayment::getPayType, PayTypeConstants.PayType.PAY)
|
||||
.eq(OrderPayment::getSourceId, shopUser.getId())
|
||||
.eq(OrderPayment::getPayStatus, PayTypeConstants.PayStatus.SUCCESS), BigDecimal.class)
|
||||
.compareTo(new BigDecimal(item.getValue())) >= 0;
|
||||
case "RECHARGE_AMOUNT" ->
|
||||
paymentService.getOneAs(query().select("IFNULL(sum(amount), 0) as total_amount")
|
||||
.eq(OrderPayment::getShopId, shopId)
|
||||
.eq(OrderPayment::getSourceType, PayTypeConstants.SourceType.MEMBER_IN)
|
||||
.eq(OrderPayment::getPayType, PayTypeConstants.PayType.PAY)
|
||||
.eq(OrderPayment::getSourceId, shopUser.getId())
|
||||
.eq(OrderPayment::getPayStatus, PayTypeConstants.PayStatus.SUCCESS), BigDecimal.class)
|
||||
.compareTo(new BigDecimal(item.getValue())) >= 0;
|
||||
default -> throw new CzgException("会员开通条件类型错误");
|
||||
};
|
||||
if (!canOpen) {
|
||||
|
||||
Reference in New Issue
Block a user