|
|
@@ -53,6 +53,7 @@ import com.cyksj.mapper.corp.CorpUserMapper;
|
|
|
import com.cyksj.mapper.corp.CorpUserTagMapper;
|
|
|
import com.cyksj.mapper.fission.UserMirrorFissionInvertRecordMapper;
|
|
|
import com.cyksj.mapper.fission.UserMirrorFissionReceiveRecordMapper;
|
|
|
+import com.cyksj.mapper.manage.cms.SysLogMapper;
|
|
|
import com.cyksj.mapper.manage.coupon.CouponDistributePopularizeMapper;
|
|
|
import com.cyksj.mapper.manage.coupon.CouponMapper;
|
|
|
import com.cyksj.mapper.manage.coupon.CouponSkuMapper;
|
|
|
@@ -409,6 +410,8 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
|
|
|
private final ClaudeCodeDeductOrderRelateMapper claudeCodeDeductOrderRelateMapper;
|
|
|
|
|
|
+ private final SysLogMapper sysLogMapper;
|
|
|
+
|
|
|
private final List<String> noChekGoodsTemp = List.of("Apple One", "Youtube", "Spotify");
|
|
|
|
|
|
@Transactional(rollbackFor = Throwable.class)
|
|
|
@@ -694,7 +697,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
}
|
|
|
if (sku != null) {
|
|
|
//扣除使用优惠券、余额的订单金额
|
|
|
- deductOrderMoney(orderDon, couponUser, payRequest.getBalance(), user, sku.getPrice(), goodsDon, payRequest.getGcCash(), payRequest.getGcpIds(), payRequest.getIsAcReduce(), subsidyId, sku, payRequest.getGalaxyCoin());
|
|
|
+ deductOrderMoney(orderDon, couponUser, payRequest.getBalance(), user, sku.getPrice(), goodsDon, payRequest.getGcCash(), payRequest.getGcpIds(), payRequest.getIsAcReduce(), subsidyId, sku, payRequest.getGalaxyCoin(), null);
|
|
|
}
|
|
|
|
|
|
if (isSpecificPrice && (orderDon.getMoney().compareTo(BigDecimal.ZERO) == 0 || orderDon.getMoney().compareTo(specificPrice) != 0)) {
|
|
|
@@ -1267,6 +1270,20 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
if (tripGoodsDonSkuView.getIsMirror() != sku.getIsMirror()) {
|
|
|
throw BusinessRuntimeException.getInstance("续费规格错误");
|
|
|
}
|
|
|
+ //天卡不支持续费其他规格
|
|
|
+ if (sku.getGoodsId() == Constant.NETFLIX_GID) {
|
|
|
+ if (tripGoodsDonSkuView.getDays() != null && tripGoodsDonSkuView.getSkuId().intValue() != sku.getId().intValue()) {
|
|
|
+ throw BusinessRuntimeException.getInstance("该规格不支持续费");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //cluade code
|
|
|
+ if (goodsDon.getId() == Constant.CLAUDE_CODE_GOODS_ID) {
|
|
|
+ //天卡规格不可续费
|
|
|
+ if (renewSkuId.intValue() == Constant.DISTRIBUTE_CLAUDE_CODE_TRIAL_SKU_ID.intValue()) {
|
|
|
+ throw BusinessRuntimeException.getInstance("不可续费该规格");
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
if (GroupsTrips.Status.waiting.equals(groupsTrips.getStatus())) {
|
|
|
if (!noChekGoodsTemp.contains(goodsDon.getTitle())) {
|
|
|
@@ -1315,7 +1332,17 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
orderDon.setOrderNo(donNo);
|
|
|
orderDon.setOpenId(payOpenId);
|
|
|
orderDon.setYhsId(yhsId);
|
|
|
- orderDon.setMoney(sku.getPrice().multiply(BigDecimal.valueOf(payRequest.getNum())));
|
|
|
+ BigDecimal skuPrice = sku.getPrice();
|
|
|
+ BigDecimal renewPrice = null;
|
|
|
+ //使用续费价格
|
|
|
+ if (payRequest.getIsRenewPrice()) {
|
|
|
+ renewPrice = sku.getRenewPrice();
|
|
|
+ //续费价格存在 续费时直接使用
|
|
|
+ if (renewPrice != null && renewPrice.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ skuPrice = renewPrice;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ orderDon.setMoney(skuPrice.multiply(BigDecimal.valueOf(payRequest.getNum())));
|
|
|
orderDon.setSkuId(renewSkuId);
|
|
|
orderDon.setRelationId(relation.getId());
|
|
|
//续费订单
|
|
|
@@ -1352,7 +1379,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
orderDon.setMoney(sku.getPrice().multiply(discount));
|
|
|
}
|
|
|
//扣除使用优惠券、余额的订单金额
|
|
|
- deductOrderMoney(orderDon, couponUser, payRequest.getBalance(), user, sku.getPrice(), goodsDon, payRequest.getGcCash(), payRequest.getGcpIds(), false, null, sku, payRequest.getGalaxyCoin());
|
|
|
+ deductOrderMoney(orderDon, couponUser, payRequest.getBalance(), user, sku.getPrice(), goodsDon, payRequest.getGcCash(), payRequest.getGcpIds(), false, null, sku, payRequest.getGalaxyCoin(), renewPrice);
|
|
|
this.saveOrUpdate(orderDon);
|
|
|
|
|
|
Long orderId = orderDon.getId();
|
|
|
@@ -2682,168 +2709,170 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
/**
|
|
|
* 使用优惠营销 订单金额抵扣
|
|
|
*/
|
|
|
- public void deductOrderMoney(OrderDon orderDon, CouponUser couponUser, BigDecimal balance, User user, BigDecimal skuMoney, GoodsDon goodsDon, BigDecimal gcCash, List<Long> gcpIds, Boolean isAcReduce, Long subsidyId, GoodsDonSku sku, BigDecimal galaxyCoin) throws Exception {
|
|
|
- Integer goodsType = goodsDon.getType();
|
|
|
- if (gcCash != null && gcCash.compareTo(BigDecimal.ZERO) > 0 && couponUser != null && (balance != null && balance.compareTo(BigDecimal.ZERO) > 0)) {
|
|
|
- throw BusinessRuntimeException.getInstance("现金卡不能与其他优惠叠加使用");
|
|
|
- }
|
|
|
- BigDecimal first_money = orderDon.getMoney();
|
|
|
- //礼品卡现金支付 不参与其他优惠
|
|
|
- if (subsidyId == null && gcCash != null && gcCash.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
- List<Long> userIdList = userBindRelationService.getRelationUserIdList(user.getId(), user);
|
|
|
- if (CollUtil.isEmpty(gcpIds)) {
|
|
|
- throw BusinessRuntimeException.getInstance("礼品卡现金支付参数异常");
|
|
|
- }
|
|
|
- BigDecimal money = orderDon.getMoney();
|
|
|
- if (gcCash.compareTo(money) > 0) {
|
|
|
- gcCash = money;
|
|
|
- }
|
|
|
- List<GiftCardUserRecord> availableGiftCards = giftCardUserRecordService.list(Wrappers.lambdaQuery(GiftCardUserRecord.class)
|
|
|
- .in(GiftCardUserRecord::getToUserId, userIdList)
|
|
|
- .in(GiftCardUserRecord::getId, gcpIds)
|
|
|
- .eq(GiftCardUserRecord::getIsPay, true)
|
|
|
- .eq(GiftCardUserRecord::getGcType, 1)
|
|
|
- .gt(GiftCardUserRecord::getRemainCash, 0));
|
|
|
- if (availableGiftCards.size() != gcpIds.size()) {
|
|
|
- throw BusinessRuntimeException.getInstance("礼品卡使用异常,请刷新页面重试");
|
|
|
- }
|
|
|
- //需要扣除的礼品卡现金
|
|
|
- BigDecimal deductCash = gcCash;
|
|
|
- List<GiftCardOrderUseRecord> gcUseRecords = new ArrayList<>();
|
|
|
- for (GiftCardUserRecord giftCard : availableGiftCards) {
|
|
|
- if (deductCash.compareTo(BigDecimal.ZERO) <= 0) {
|
|
|
- break;
|
|
|
- }
|
|
|
- BigDecimal remainCash = giftCard.getRemainCash();
|
|
|
- //扣完
|
|
|
- if (remainCash.compareTo(deductCash) == 0) {
|
|
|
- deductGiftCardCash(user.getId(), giftCard.getId(), deductCash, remainCash, gcUseRecords, true);
|
|
|
- deductCash = BigDecimal.ZERO;
|
|
|
- } else if (remainCash.compareTo(deductCash) < 0) {
|
|
|
- deductGiftCardCash(user.getId(), giftCard.getId(), remainCash, remainCash, gcUseRecords, true);
|
|
|
- deductCash = deductCash.subtract(remainCash);
|
|
|
- } else if (remainCash.compareTo(deductCash) > 0) {
|
|
|
- deductGiftCardCash(user.getId(), giftCard.getId(), deductCash, remainCash, gcUseRecords, false);
|
|
|
- deductCash = BigDecimal.ZERO;
|
|
|
- }
|
|
|
- }
|
|
|
- orderDon.setMoney(orderDon.getMoney().subtract(gcCash));
|
|
|
- orderDon.setGcCash(gcCash);
|
|
|
- if (!gcUseRecords.isEmpty()) {
|
|
|
- orderDon.setGcUseRecords(gcUseRecords);
|
|
|
- }
|
|
|
- return;
|
|
|
- }
|
|
|
- //针对设备 满减活动优惠 不支持使用优惠券等优惠
|
|
|
- if (isAcReduce != null && isAcReduce && orderDon.getGoodsId() == 15) {
|
|
|
- epOrderDonActivityReduce(orderDon);
|
|
|
- //存在余额
|
|
|
- deductBalancePayOrderMoney(orderDon, balance, user);
|
|
|
- return;
|
|
|
- }
|
|
|
- //存在优惠券
|
|
|
- if (couponUser != null && subsidyId == null) {
|
|
|
- Long couponId = couponUser.getCouponId();
|
|
|
- Coupon coupon = couponMapper.getCouponById(couponId);
|
|
|
- BigDecimal couponMoney = null;
|
|
|
- BigDecimal payMoney = orderDon.getMoney();
|
|
|
- BigDecimal needDeductMoney = payMoney;
|
|
|
- if (orderDon.getOriMoney() == null) {
|
|
|
- orderDon.setOriMoney(payMoney);
|
|
|
- }
|
|
|
- if (orderDon.getIsDp() != null && orderDon.getIsDp()) {
|
|
|
- needDeductMoney = needDeductMoney.subtract(orderDon.getDpMoney());
|
|
|
- }
|
|
|
- if (coupon.getType() == Coupon.Type.discount) {
|
|
|
- couponMoney = needDeductMoney.multiply(BigDecimal.valueOf(1).subtract(coupon.getDiscount()));
|
|
|
- //需支付金额
|
|
|
- orderDon.setMoney(payMoney.subtract(couponMoney));
|
|
|
-
|
|
|
- orderDon.setOriMoney(orderDon.getOriMoney().multiply(coupon.getDiscount()));
|
|
|
- //记录折扣 用于分销
|
|
|
- couponUser.setDiscount(coupon.getDiscount());
|
|
|
- couponUserMapper.updateById(couponUser);
|
|
|
- } else if (coupon.getType() == Coupon.Type.reduce) {
|
|
|
- if (goodsType == 2) {
|
|
|
- if (skuMoney.compareTo(coupon.getReduceCondition()) < 0) {
|
|
|
- throw BusinessRuntimeException.getInstance(String.format("满%s可用", coupon.getReduceCondition().divide(BigDecimal.valueOf(100))));
|
|
|
+ public void deductOrderMoney(OrderDon orderDon, CouponUser couponUser, BigDecimal balance, User user, BigDecimal skuMoney, GoodsDon goodsDon, BigDecimal gcCash, List<Long> gcpIds, Boolean isAcReduce, Long subsidyId, GoodsDonSku sku, BigDecimal galaxyCoin, BigDecimal renewPrice) throws Exception {
|
|
|
+ //续费规格价格 不允许其他优惠
|
|
|
+ if (renewPrice == null || renewPrice.compareTo(BigDecimal.ZERO) <= 0) {
|
|
|
+ Integer goodsType = goodsDon.getType();
|
|
|
+ if (gcCash != null && gcCash.compareTo(BigDecimal.ZERO) > 0 && couponUser != null && (balance != null && balance.compareTo(BigDecimal.ZERO) > 0)) {
|
|
|
+ throw BusinessRuntimeException.getInstance("现金卡不能与其他优惠叠加使用");
|
|
|
+ }
|
|
|
+ BigDecimal first_money = orderDon.getMoney();
|
|
|
+ //礼品卡现金支付 不参与其他优惠
|
|
|
+ if (subsidyId == null && gcCash != null && gcCash.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ List<Long> userIdList = userBindRelationService.getRelationUserIdList(user.getId(), user);
|
|
|
+ if (CollUtil.isEmpty(gcpIds)) {
|
|
|
+ throw BusinessRuntimeException.getInstance("礼品卡现金支付参数异常");
|
|
|
+ }
|
|
|
+ BigDecimal money = orderDon.getMoney();
|
|
|
+ if (gcCash.compareTo(money) > 0) {
|
|
|
+ gcCash = money;
|
|
|
+ }
|
|
|
+ List<GiftCardUserRecord> availableGiftCards = giftCardUserRecordService.list(Wrappers.lambdaQuery(GiftCardUserRecord.class)
|
|
|
+ .in(GiftCardUserRecord::getToUserId, userIdList)
|
|
|
+ .in(GiftCardUserRecord::getId, gcpIds)
|
|
|
+ .eq(GiftCardUserRecord::getIsPay, true)
|
|
|
+ .eq(GiftCardUserRecord::getGcType, 1)
|
|
|
+ .gt(GiftCardUserRecord::getRemainCash, 0));
|
|
|
+ if (availableGiftCards.size() != gcpIds.size()) {
|
|
|
+ throw BusinessRuntimeException.getInstance("礼品卡使用异常,请刷新页面重试");
|
|
|
+ }
|
|
|
+ //需要扣除的礼品卡现金
|
|
|
+ BigDecimal deductCash = gcCash;
|
|
|
+ List<GiftCardOrderUseRecord> gcUseRecords = new ArrayList<>();
|
|
|
+ for (GiftCardUserRecord giftCard : availableGiftCards) {
|
|
|
+ if (deductCash.compareTo(BigDecimal.ZERO) <= 0) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ BigDecimal remainCash = giftCard.getRemainCash();
|
|
|
+ //扣完
|
|
|
+ if (remainCash.compareTo(deductCash) == 0) {
|
|
|
+ deductGiftCardCash(user.getId(), giftCard.getId(), deductCash, remainCash, gcUseRecords, true);
|
|
|
+ deductCash = BigDecimal.ZERO;
|
|
|
+ } else if (remainCash.compareTo(deductCash) < 0) {
|
|
|
+ deductGiftCardCash(user.getId(), giftCard.getId(), remainCash, remainCash, gcUseRecords, true);
|
|
|
+ deductCash = deductCash.subtract(remainCash);
|
|
|
+ } else if (remainCash.compareTo(deductCash) > 0) {
|
|
|
+ deductGiftCardCash(user.getId(), giftCard.getId(), deductCash, remainCash, gcUseRecords, false);
|
|
|
+ deductCash = BigDecimal.ZERO;
|
|
|
}
|
|
|
}
|
|
|
- BigDecimal subtractMoney = payMoney.subtract(coupon.getReduceMoney());
|
|
|
- orderDon.setMoney(subtractMoney);
|
|
|
- couponMoney = coupon.getReduceMoney();
|
|
|
-
|
|
|
- orderDon.setOriMoney(orderDon.getOriMoney().subtract(coupon.getReduceMoney()));
|
|
|
+ orderDon.setMoney(orderDon.getMoney().subtract(gcCash));
|
|
|
+ orderDon.setGcCash(gcCash);
|
|
|
+ if (!gcUseRecords.isEmpty()) {
|
|
|
+ orderDon.setGcUseRecords(gcUseRecords);
|
|
|
+ }
|
|
|
+ return;
|
|
|
}
|
|
|
- if (couponMoney != null && couponMoney.compareTo(first_money) >= 0) {
|
|
|
- throw BusinessRuntimeException.getInstance("支付金额不能小于优惠金额");
|
|
|
+ //针对设备 满减活动优惠 不支持使用优惠券等优惠
|
|
|
+ if (isAcReduce != null && isAcReduce && orderDon.getGoodsId() == 15) {
|
|
|
+ epOrderDonActivityReduce(orderDon);
|
|
|
+ //存在余额
|
|
|
+ deductBalancePayOrderMoney(orderDon, balance, user);
|
|
|
+ return;
|
|
|
}
|
|
|
- orderDon.setCouponMoney(couponMoney);
|
|
|
- orderDon.setCouponUserId(couponUser.getId());
|
|
|
- orderDon.setCouponId(couponUser.getCouponId());
|
|
|
- }
|
|
|
- //特殊渠道推广优惠. 360
|
|
|
- if (subsidyId == null && orderDon.getPopularizeId() != null && orderDon.getPopularizeId() != 0L) {
|
|
|
- String name = channelPopularizeMapper.selectChannelByPid(orderDon.getPopularizeId());
|
|
|
- if (StrUtil.isNotBlank(name)) {
|
|
|
- //使用了优惠券 不再使用360渠道 折扣
|
|
|
- if (couponUser == null && goodsType == 1) {
|
|
|
- if (name.contains(Constant.NO_SIGN_CHANNEL_NAMES.get(0)) || name.contains(Constant.NO_SIGN_CHANNEL_NAMES.get(1))) {
|
|
|
- String key;
|
|
|
- if (name.contains(Constant.NO_SIGN_CHANNEL_NAMES.get(0))) {
|
|
|
- //百度渠道 专门优惠链接
|
|
|
- key = Constant.CHANNEL_BAIDU_DISCOUNT_KEY;
|
|
|
- } else {
|
|
|
- //抖音
|
|
|
- key = Constant.CHANNEL_DY_DISCOUNT_KEY;
|
|
|
+ //存在优惠券
|
|
|
+ if (couponUser != null && subsidyId == null) {
|
|
|
+ Long couponId = couponUser.getCouponId();
|
|
|
+ Coupon coupon = couponMapper.getCouponById(couponId);
|
|
|
+ BigDecimal couponMoney = null;
|
|
|
+ BigDecimal payMoney = orderDon.getMoney();
|
|
|
+ BigDecimal needDeductMoney = payMoney;
|
|
|
+ if (orderDon.getOriMoney() == null) {
|
|
|
+ orderDon.setOriMoney(payMoney);
|
|
|
+ }
|
|
|
+ if (orderDon.getIsDp() != null && orderDon.getIsDp()) {
|
|
|
+ needDeductMoney = needDeductMoney.subtract(orderDon.getDpMoney());
|
|
|
+ }
|
|
|
+ if (coupon.getType() == Coupon.Type.discount) {
|
|
|
+ couponMoney = needDeductMoney.multiply(BigDecimal.valueOf(1).subtract(coupon.getDiscount()));
|
|
|
+ //需支付金额
|
|
|
+ orderDon.setMoney(payMoney.subtract(couponMoney));
|
|
|
+
|
|
|
+ orderDon.setOriMoney(orderDon.getOriMoney().multiply(coupon.getDiscount()));
|
|
|
+ //记录折扣 用于分销
|
|
|
+ couponUser.setDiscount(coupon.getDiscount());
|
|
|
+ couponUserMapper.updateById(couponUser);
|
|
|
+ } else if (coupon.getType() == Coupon.Type.reduce) {
|
|
|
+ if (goodsType == 2) {
|
|
|
+ if (skuMoney.compareTo(coupon.getReduceCondition()) < 0) {
|
|
|
+ throw BusinessRuntimeException.getInstance(String.format("满%s可用", coupon.getReduceCondition().divide(BigDecimal.valueOf(100))));
|
|
|
}
|
|
|
- SysConfig channelNoSignConfig = sysConfigService.getOne(Wrappers.lambdaQuery(SysConfig.class)
|
|
|
- .eq(SysConfig::getSysKey, key).last("limit 1"));
|
|
|
- if (channelNoSignConfig != null) {
|
|
|
- String sysValue = channelNoSignConfig.getSysValue();
|
|
|
- if (StrUtil.isNotBlank(sysValue)) {
|
|
|
- try {
|
|
|
- ChannelBaiDuDiscountDto baiDuDiscountDto = Jsons.parseObject(sysValue, ChannelBaiDuDiscountDto.class);
|
|
|
- List<Long> baiduPopularizeIds = baiDuDiscountDto.getPopularizeIds();
|
|
|
- BigDecimal discount = baiDuDiscountDto.getDiscount();
|
|
|
- if (CollUtil.isNotEmpty(baiduPopularizeIds) && discount != null && discount.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
- if (baiduPopularizeIds.contains(orderDon.getPopularizeId())) {
|
|
|
- BigDecimal discountMoney = orderDon.getMoney().multiply(discount);
|
|
|
- orderDon.setMoney(discountMoney);
|
|
|
+ }
|
|
|
+ BigDecimal subtractMoney = payMoney.subtract(coupon.getReduceMoney());
|
|
|
+ orderDon.setMoney(subtractMoney);
|
|
|
+ couponMoney = coupon.getReduceMoney();
|
|
|
+
|
|
|
+ orderDon.setOriMoney(orderDon.getOriMoney().subtract(coupon.getReduceMoney()));
|
|
|
+ }
|
|
|
+ if (couponMoney != null && couponMoney.compareTo(first_money) >= 0) {
|
|
|
+ throw BusinessRuntimeException.getInstance("支付金额不能小于优惠金额");
|
|
|
+ }
|
|
|
+ orderDon.setCouponMoney(couponMoney);
|
|
|
+ orderDon.setCouponUserId(couponUser.getId());
|
|
|
+ orderDon.setCouponId(couponUser.getCouponId());
|
|
|
+ }
|
|
|
+ //特殊渠道推广优惠. 360
|
|
|
+ if (subsidyId == null && orderDon.getPopularizeId() != null && orderDon.getPopularizeId() != 0L) {
|
|
|
+ String name = channelPopularizeMapper.selectChannelByPid(orderDon.getPopularizeId());
|
|
|
+ if (StrUtil.isNotBlank(name)) {
|
|
|
+ //使用了优惠券 不再使用360渠道 折扣
|
|
|
+ if (couponUser == null && goodsType == 1) {
|
|
|
+ if (name.contains(Constant.NO_SIGN_CHANNEL_NAMES.get(0)) || name.contains(Constant.NO_SIGN_CHANNEL_NAMES.get(1))) {
|
|
|
+ String key;
|
|
|
+ if (name.contains(Constant.NO_SIGN_CHANNEL_NAMES.get(0))) {
|
|
|
+ //百度渠道 专门优惠链接
|
|
|
+ key = Constant.CHANNEL_BAIDU_DISCOUNT_KEY;
|
|
|
+ } else {
|
|
|
+ //抖音
|
|
|
+ key = Constant.CHANNEL_DY_DISCOUNT_KEY;
|
|
|
+ }
|
|
|
+ SysConfig channelNoSignConfig = sysConfigService.getOne(Wrappers.lambdaQuery(SysConfig.class)
|
|
|
+ .eq(SysConfig::getSysKey, key).last("limit 1"));
|
|
|
+ if (channelNoSignConfig != null) {
|
|
|
+ String sysValue = channelNoSignConfig.getSysValue();
|
|
|
+ if (StrUtil.isNotBlank(sysValue)) {
|
|
|
+ try {
|
|
|
+ ChannelBaiDuDiscountDto baiDuDiscountDto = Jsons.parseObject(sysValue, ChannelBaiDuDiscountDto.class);
|
|
|
+ List<Long> baiduPopularizeIds = baiDuDiscountDto.getPopularizeIds();
|
|
|
+ BigDecimal discount = baiDuDiscountDto.getDiscount();
|
|
|
+ if (CollUtil.isNotEmpty(baiduPopularizeIds) && discount != null && discount.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ if (baiduPopularizeIds.contains(orderDon.getPopularizeId())) {
|
|
|
+ BigDecimal discountMoney = orderDon.getMoney().multiply(discount);
|
|
|
+ orderDon.setMoney(discountMoney);
|
|
|
+ }
|
|
|
}
|
|
|
+ } catch (Exception e) {
|
|
|
}
|
|
|
- } catch (Exception e) {
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- } else {
|
|
|
- SysConfig discountPopularizeConfig = sysConfigService.getOne(Wrappers.lambdaQuery(SysConfig.class)
|
|
|
- .eq(SysConfig::getSysKey, Constant.DISCOUNT_POPULARIZE_KEY).last("limit 1"));
|
|
|
- if (discountPopularizeConfig != null) {
|
|
|
- String sysValue = discountPopularizeConfig.getSysValue();
|
|
|
- if (StrUtil.isNotBlank(sysValue)) {
|
|
|
- if (user == null) {
|
|
|
- throw BusinessRuntimeException.getGatewayApiCode(GatewayApiCode.CMS_TOKEN_VALID);
|
|
|
- }
|
|
|
- DiscountPopularizeDto discountPopularizeDto = Jsons.parseObject(sysValue, DiscountPopularizeDto.class);
|
|
|
- List<Long> popularizeIds = discountPopularizeDto.getPopularizeIds();
|
|
|
- if (CollUtil.isNotEmpty(popularizeIds) && popularizeIds.contains(orderDon.getPopularizeId())) {
|
|
|
- List<Long> userIdList = userBindRelationService.getRelationUserIdList(user.getId(), user);
|
|
|
- Integer count = orderDonUserDiscountPopularizeRecordMapper.selectUserPopularzieDiscountRecordByUidAndPid(userIdList, orderDon.getPopularizeId());
|
|
|
- if (count == 0) {
|
|
|
- log.info("用户:{}首次使用折扣特殊链接:{} 折扣:{},修改支付金额", user.getId(), orderDon.getPopularizeId(), discountPopularizeDto.getDiscount());
|
|
|
- BigDecimal discountMoney = orderDon.getMoney().multiply(discountPopularizeDto.getDiscount());
|
|
|
- orderDon.setMoney(discountMoney);
|
|
|
-
|
|
|
- //记录用户使用折扣链接
|
|
|
- orderDon.setDiscountPopularizeRecord(createPopularizeDiscountRecord(orderDon, discountPopularizeDto.getDiscount()));
|
|
|
+ } else {
|
|
|
+ SysConfig discountPopularizeConfig = sysConfigService.getOne(Wrappers.lambdaQuery(SysConfig.class)
|
|
|
+ .eq(SysConfig::getSysKey, Constant.DISCOUNT_POPULARIZE_KEY).last("limit 1"));
|
|
|
+ if (discountPopularizeConfig != null) {
|
|
|
+ String sysValue = discountPopularizeConfig.getSysValue();
|
|
|
+ if (StrUtil.isNotBlank(sysValue)) {
|
|
|
+ if (user == null) {
|
|
|
+ throw BusinessRuntimeException.getGatewayApiCode(GatewayApiCode.CMS_TOKEN_VALID);
|
|
|
+ }
|
|
|
+ DiscountPopularizeDto discountPopularizeDto = Jsons.parseObject(sysValue, DiscountPopularizeDto.class);
|
|
|
+ List<Long> popularizeIds = discountPopularizeDto.getPopularizeIds();
|
|
|
+ if (CollUtil.isNotEmpty(popularizeIds) && popularizeIds.contains(orderDon.getPopularizeId())) {
|
|
|
+ List<Long> userIdList = userBindRelationService.getRelationUserIdList(user.getId(), user);
|
|
|
+ Integer count = orderDonUserDiscountPopularizeRecordMapper.selectUserPopularzieDiscountRecordByUidAndPid(userIdList, orderDon.getPopularizeId());
|
|
|
+ if (count == 0) {
|
|
|
+ log.info("用户:{}首次使用折扣特殊链接:{} 折扣:{},修改支付金额", user.getId(), orderDon.getPopularizeId(), discountPopularizeDto.getDiscount());
|
|
|
+ BigDecimal discountMoney = orderDon.getMoney().multiply(discountPopularizeDto.getDiscount());
|
|
|
+ orderDon.setMoney(discountMoney);
|
|
|
+
|
|
|
+ //记录用户使用折扣链接
|
|
|
+ orderDon.setDiscountPopularizeRecord(createPopularizeDiscountRecord(orderDon, discountPopularizeDto.getDiscount()));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- } else {
|
|
|
- //360
|
|
|
+ } else {
|
|
|
+ //360
|
|
|
// if (Constant.CHANNEL_NAME_360.equals(name)) {
|
|
|
// SysConfig sysConfig = sysConfigService.getBaseMapper().selectOne(Wrappers.lambdaQuery(SysConfig.class).eq(SysConfig::getSysKey, Constant.CHANNEL_360_DISCOUNT));
|
|
|
// if (sysConfig != null) {
|
|
|
@@ -2851,6 +2880,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
// orderDon.setMoney(discountMoney);
|
|
|
// }
|
|
|
// }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -3333,39 +3363,59 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
if (orderDon.getGoodsId() == Constant.CLAUDE_CODE_GOODS_ID) {
|
|
|
try {
|
|
|
ClaudeCodeDeductOrderRelate claudeCodeDeductOrderRelate = claudeCodeDeductOrderRelateMapper.selectOne(Wrappers.lambdaQuery(ClaudeCodeDeductOrderRelate.class).eq(ClaudeCodeDeductOrderRelate::getOrderId, orderDon.getId()));
|
|
|
- Long relationId = claudeCodeDeductOrderRelate.getRelationId();
|
|
|
- //清除旧的cc车票
|
|
|
- GroupsRelation oldRelation = groupsRelationMapper.selectById(relationId);
|
|
|
- Long relationUserId = oldRelation.getUserId();
|
|
|
- groupRelationClearService.clearTicket(oldRelation, UserTicketClearedRecord.Source.cc_deduct);
|
|
|
- //生成新规格车票
|
|
|
- Long skuId = orderDon.getSkuId();
|
|
|
- Long newRelationId = groupRelationFrontService.getTicket(relationUserId, skuId, Boolean.FALSE);
|
|
|
- GroupsRelation newRelation = groupsRelationMapper.selectById(newRelationId);
|
|
|
- ClaudeCodeUser claudeCodeUser = claudeCodeUserMapper.selectOne(Wrappers.lambdaQuery(ClaudeCodeUser.class).eq(ClaudeCodeUser::getRelationId, relationId).last("limit 1"));
|
|
|
- //同步用户cc的 车票id
|
|
|
- if (claudeCodeUser != null) {
|
|
|
- claudeCodeUser.setRelationId(newRelationId);
|
|
|
- claudeCodeUser.setRenewSkuId(null);
|
|
|
- claudeCodeUser.setRenewOrderId(null);
|
|
|
- claudeCodeUser.setRenewExpiryTime(null);
|
|
|
- claudeCodeUserMapper.updateById(claudeCodeUser);
|
|
|
- //同步套餐
|
|
|
- claudeCodeService.updateClaudeCodeUserPackageInfo(claudeCodeUser, newRelation.getExpiryTime(), sku);
|
|
|
- }
|
|
|
- claudeCodeDeductOrderRelate.setNewRelationId(newRelationId);
|
|
|
- claudeCodeDeductOrderRelateMapper.updateById(claudeCodeDeductOrderRelate);
|
|
|
- if (claudeCodeDeductOrderRelate.getExtendsDays() != null && claudeCodeDeductOrderRelate.getExtendsDays() > 0) {
|
|
|
- newRelation.setExpiryTime(DateUtil.offsetDay(newRelation.getExpiryTime(), claudeCodeDeductOrderRelate.getExtendsDays()));
|
|
|
- groupsRelationMapper.updateById(newRelation);
|
|
|
- }
|
|
|
- //将订单车票id同步成新规格车票id
|
|
|
- orderDon.setRelationId(newRelationId);
|
|
|
- orderDonMapper.updateById(orderDon);
|
|
|
+ if (claudeCodeDeductOrderRelate != null) {
|
|
|
+ Long relationId = claudeCodeDeductOrderRelate.getRelationId();
|
|
|
+ //清除旧的cc车票
|
|
|
+ GroupsRelation oldRelation = groupsRelationMapper.selectById(relationId);
|
|
|
+ Long relationUserId = oldRelation.getUserId();
|
|
|
+ groupRelationClearService.clearTicket(oldRelation, UserTicketClearedRecord.Source.cc_deduct);
|
|
|
+ //生成新规格车票
|
|
|
+ Long skuId = orderDon.getSkuId();
|
|
|
+ Long newRelationId = groupRelationFrontService.getTicket(relationUserId, skuId, Boolean.FALSE);
|
|
|
+ GroupsRelation newRelation = groupsRelationMapper.selectById(newRelationId);
|
|
|
+ ClaudeCodeUser claudeCodeUser = claudeCodeUserMapper.selectOne(Wrappers.lambdaQuery(ClaudeCodeUser.class).eq(ClaudeCodeUser::getRelationId, relationId).last("limit 1"));
|
|
|
+ //同步用户cc的 车票id
|
|
|
+ if (claudeCodeUser != null) {
|
|
|
+ claudeCodeUser.setRelationId(newRelationId);
|
|
|
+ claudeCodeUser.setRenewSkuId(null);
|
|
|
+ claudeCodeUser.setRenewOrderId(null);
|
|
|
+ claudeCodeUser.setRenewExpiryTime(null);
|
|
|
+ claudeCodeUserMapper.updateById(claudeCodeUser);
|
|
|
+ //同步套餐
|
|
|
+ claudeCodeService.updateClaudeCodeUserPackageInfo(claudeCodeUser, newRelation.getExpiryTime(), sku);
|
|
|
+ }
|
|
|
+ claudeCodeDeductOrderRelate.setNewRelationId(newRelationId);
|
|
|
+ claudeCodeDeductOrderRelateMapper.updateById(claudeCodeDeductOrderRelate);
|
|
|
+ if (claudeCodeDeductOrderRelate.getExtendsDays() != null && claudeCodeDeductOrderRelate.getExtendsDays() > 0) {
|
|
|
+ newRelation.setExpiryTime(DateUtil.offsetDay(newRelation.getExpiryTime(), claudeCodeDeductOrderRelate.getExtendsDays()));
|
|
|
+ groupsRelationMapper.updateById(newRelation);
|
|
|
+ }
|
|
|
+ //将订单车票id同步成新规格车票id
|
|
|
+ orderDon.setRelationId(newRelationId);
|
|
|
+ orderDonMapper.updateById(orderDon);
|
|
|
+ }
|
|
|
} catch (Exception e) {
|
|
|
log.error("订单回调,cc抵扣升级报错:{}", StringUtil.getErrorText(e));
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ if (orderDon.getOrderType() == 1 && sku.getIsDown()) {
|
|
|
+ try {
|
|
|
+ GroupsRelation relation = groupsRelationMapper.selectById(orderDon.getRelationId());
|
|
|
+ Long groupsId = relation.getGroupsId();
|
|
|
+ GroupsTrips groupsTrips = groupsMapper.selectById(groupsId);
|
|
|
+ if (groupsTrips.getStatus() == GroupsTrips.Status.validity) {
|
|
|
+ Integer selectCount = groupsRelationMapper.selectCount(Wrappers.lambdaQuery(GroupsRelation.class).eq(GroupsRelation::getGroupsId, groupsId).eq(GroupsRelation::getStatus, GroupsTrips.Status.validity));
|
|
|
+ if (selectCount == sku.getNum()) {
|
|
|
+ groupsTrips.setStatus(GroupsTrips.Status.down);
|
|
|
+ groupsMapper.updateById(groupsTrips);
|
|
|
+ recordSysOpLog(groupsTrips.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private void handleUserMirrorSHopOrderDon(OrderDon orderDon) throws Exception {
|
|
|
@@ -4665,9 +4715,9 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
GroupsTrips groupsTrips = getGroupsTrips(groupsRelation);
|
|
|
GoodsDonSku goodsDonSku = goodsDonSkuMapper.selectById(groupsTrips.getSkuId());
|
|
|
GoodsDon goodsDon = goodsDonMapper.selectById(goodsDonSku.getGoodsId());
|
|
|
- if (!goodsDonSku.getIsMirror()) {
|
|
|
- throw BusinessRuntimeException.getInstance("系统异常");
|
|
|
- }
|
|
|
+// if (!goodsDonSku.getIsMirror()) {
|
|
|
+// throw BusinessRuntimeException.getInstance("系统异常");
|
|
|
+// }
|
|
|
Long renewSkuId = payRequest.getSkuId();
|
|
|
GoodsDonSku renewSku = goodsDonSkuMapper.selectById(renewSkuId);
|
|
|
//校验同规格
|
|
|
@@ -5611,4 +5661,17 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
claudeCodeDeductOrderRelate.setExtendsDays(extendsDays);
|
|
|
claudeCodeDeductOrderRelateMapper.insert(claudeCodeDeductOrderRelate);
|
|
|
}
|
|
|
+
|
|
|
+ private void recordSysOpLog(Long groupsId) {
|
|
|
+ try {
|
|
|
+ //添加操作记录
|
|
|
+ SysLog sysLog = new SysLog();
|
|
|
+ sysLog.setModule("过期账号/上下架过期车队");
|
|
|
+ sysLog.setOperateParams(groupsId.toString());
|
|
|
+ sysLog.setOperator("坐满系统下架");
|
|
|
+ sysLogMapper.insert(sysLog);
|
|
|
+ } catch (Exception e) {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|