|
@@ -25,6 +25,7 @@ import com.cyksj.mapper.manage.coupon.CouponSkuMapper;
|
|
|
import com.cyksj.mapper.manage.coupon.CouponUserMapper;
|
|
import com.cyksj.mapper.manage.coupon.CouponUserMapper;
|
|
|
import com.cyksj.mapper.manage.distribute.UserDistributeMapper;
|
|
import com.cyksj.mapper.manage.distribute.UserDistributeMapper;
|
|
|
import com.cyksj.mapper.manage.distribute.UserDistributeSharedMapper;
|
|
import com.cyksj.mapper.manage.distribute.UserDistributeSharedMapper;
|
|
|
|
|
+import com.cyksj.mapper.renew.RenewUpgradePackageMapper;
|
|
|
import com.cyksj.model.dto.CouponPopularizeDto;
|
|
import com.cyksj.model.dto.CouponPopularizeDto;
|
|
|
import com.cyksj.model.entity.*;
|
|
import com.cyksj.model.entity.*;
|
|
|
import com.cyksj.model.request.ClaudeCodeApiKeysReq;
|
|
import com.cyksj.model.request.ClaudeCodeApiKeysReq;
|
|
@@ -113,6 +114,8 @@ public class CodexServiceImpl implements CodexService {
|
|
|
|
|
|
|
|
private final OrderDonGalaxyCoinRecordMapper orderDonGalaxyCoinRecordMapper;
|
|
private final OrderDonGalaxyCoinRecordMapper orderDonGalaxyCoinRecordMapper;
|
|
|
|
|
|
|
|
|
|
+ private final RenewUpgradePackageMapper renewUpgradePackageMapper;
|
|
|
|
|
+
|
|
|
private static final Sequence SEQUENCE = new Sequence(0);
|
|
private static final Sequence SEQUENCE = new Sequence(0);
|
|
|
|
|
|
|
|
private final ClaudeCodexApiService claudeCodexApiService;
|
|
private final ClaudeCodexApiService claudeCodexApiService;
|
|
@@ -479,12 +482,25 @@ public class CodexServiceImpl implements CodexService {
|
|
|
BigDecimal deductMoneyFromTicket = getDeductMoneyFromTicket(relationId, userIdList, relationSkuId, now, relationStartTime, relationExpiryTime);
|
|
BigDecimal deductMoneyFromTicket = getDeductMoneyFromTicket(relationId, userIdList, relationSkuId, now, relationStartTime, relationExpiryTime);
|
|
|
deductMoney = deductMoney.add(deductMoneyFromTicket);
|
|
deductMoney = deductMoney.add(deductMoneyFromTicket);
|
|
|
}
|
|
}
|
|
|
|
|
+ Long presentSkuId = renewSkuId != null && renewSkuId > 0 ? renewSkuId : relationSkuId;
|
|
|
|
|
+ RenewUpgradePackage renewUpgradePackage = renewUpgradePackageMapper.selectOne(Wrappers.lambdaQuery(RenewUpgradePackage.class)
|
|
|
|
|
+ .eq(RenewUpgradePackage::getGoodsId, Constant.CODEX_GOODS_ID)
|
|
|
|
|
+ .eq(RenewUpgradePackage::getSkuId, presentSkuId)
|
|
|
|
|
+ .apply("JSON_CONTAINS(upgrade_sku_ids,'\"" + upgradeSku.getId() + "\"')")
|
|
|
|
|
+ .eq(RenewUpgradePackage::getStatus, 1)
|
|
|
|
|
+ .eq(RenewUpgradePackage::getDeleted, 1)
|
|
|
|
|
+ .orderByAsc(RenewUpgradePackage::getDiscount)
|
|
|
|
|
+ .last("limit 1"));
|
|
|
|
|
+ BigDecimal skuPrice = upgradeSku.getPrice();
|
|
|
|
|
+ if (renewUpgradePackage != null && renewUpgradePackage.getDiscount() != null) {
|
|
|
|
|
+ skuPrice = skuPrice.multiply(renewUpgradePackage.getDiscount());
|
|
|
|
|
+ }
|
|
|
//超出可抵扣的金额 直接返回
|
|
//超出可抵扣的金额 直接返回
|
|
|
- if (deductMoney.compareTo(upgradeSku.getPrice()) >= 0) {
|
|
|
|
|
- BigDecimal overMoney = deductMoney.subtract(upgradeSku.getPrice());
|
|
|
|
|
|
|
+ if (deductMoney.compareTo(skuPrice) >= 0) {
|
|
|
|
|
+ BigDecimal overMoney = deductMoney.subtract(skuPrice);
|
|
|
//超过抵扣金额可换延长会员多少天
|
|
//超过抵扣金额可换延长会员多少天
|
|
|
//每天单价
|
|
//每天单价
|
|
|
- BigDecimal daySingle = upgradeSku.getPrice().divide(BigDecimal.valueOf(upgradeSku.getMonths())).divide(BigDecimal.valueOf(30), 0, RoundingMode.DOWN);
|
|
|
|
|
|
|
+ BigDecimal daySingle = skuPrice.divide(BigDecimal.valueOf(upgradeSku.getMonths())).divide(BigDecimal.valueOf(30), 0, RoundingMode.DOWN);
|
|
|
//超出部分可换取多少天 低于每天单价为0天
|
|
//超出部分可换取多少天 低于每天单价为0天
|
|
|
BigDecimal extendsDays = overMoney.divide(daySingle, 0, RoundingMode.UP);
|
|
BigDecimal extendsDays = overMoney.divide(daySingle, 0, RoundingMode.UP);
|
|
|
codexDeductResp.setExtendsDays(extendsDays.intValue());
|
|
codexDeductResp.setExtendsDays(extendsDays.intValue());
|
|
@@ -861,7 +877,7 @@ public class CodexServiceImpl implements CodexService {
|
|
|
thisOrderExpiryTime = DateUtil.offsetMonth(orderDon.getCreatedTime(), sku.getMonths());
|
|
thisOrderExpiryTime = DateUtil.offsetMonth(orderDon.getCreatedTime(), sku.getMonths());
|
|
|
}
|
|
}
|
|
|
//当天购买的按规格原价抵扣
|
|
//当天购买的按规格原价抵扣
|
|
|
- if (now.toDateStr().equals(DateUtil.format(relationStartTime, "yyyy-MM-dd")) && (DateUtil.betweenDay(thisOrderExpiryTime, relationExpiryTime, true) == 0)) {
|
|
|
|
|
|
|
+ if (now.toDateStr().equals(DateUtil.format(orderDon.getCreatedTime(), "yyyy-MM-dd")) && (DateUtil.betweenDay(thisOrderExpiryTime, relationExpiryTime, true) == 0)) {
|
|
|
if (codexDeductRecord != null) {
|
|
if (codexDeductRecord != null) {
|
|
|
thisOrderMoney = thisOrderMoney.add(Optional.ofNullable(codexDeductRecord.getDeductMoney()).orElse(BigDecimal.ZERO));
|
|
thisOrderMoney = thisOrderMoney.add(Optional.ofNullable(codexDeductRecord.getDeductMoney()).orElse(BigDecimal.ZERO));
|
|
|
}
|
|
}
|