zoujiajian 1 ano atrás
pai
commit
3b6f6e4bd8

+ 8 - 4
netflix-service/src/main/java/com/cyksj/service/order/impl/OrderDonServiceImpl.java

@@ -2691,10 +2691,10 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 		//存在余额
 		deductBalancePayOrderMoney(orderDon, balance, user);
 		//存在银河币
-		deductGalaxyCoinPayOrderMoney(orderDon, sku, galaxyCoin, user);
+		deductGalaxyCoinPayOrderMoney(orderDon, sku.getPrice(), galaxyCoin, user);
 	}
 
-	public void deductGalaxyCoinPayOrderMoney(OrderDon orderDon, GoodsDonSku sku, BigDecimal toUseGalaxyCoin, User user) {
+	public void deductGalaxyCoinPayOrderMoney(OrderDon orderDon, BigDecimal renewSkuDiscountPrice, BigDecimal toUseGalaxyCoin, User user) {
 		//存在银河币
 		if (toUseGalaxyCoin != null && toUseGalaxyCoin.compareTo(BigDecimal.ZERO) > 0) {
 			BigDecimal userGalaxyCoin = user.getGalaxyCoin();
@@ -2724,7 +2724,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 				//此次使用抵扣金额
 				BigDecimal thisDeductMoney = toUseGalaxyCoin.multiply(deductMoneyEachCoin);
 				//该笔平台最高可抵扣金额
-				BigDecimal maxDeductMoney = sku.getPrice().multiply(galaxyCoinPayConfigDto.getMaxRate());
+				BigDecimal maxDeductMoney = renewSkuDiscountPrice.multiply(galaxyCoinPayConfigDto.getMaxRate());
 				if (thisDeductMoney.compareTo(maxDeductMoney) > 0) {
 					thisDeductMoney = maxDeductMoney;
 				}
@@ -4393,7 +4393,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 		//存在余额
 		deductBalancePayOrderMoney(orderDon, payRequest.getBalance(), user);
 		//存在银河币
-		deductGalaxyCoinPayOrderMoney(orderDon, renewSku, payRequest.getGalaxyCoin(), user);
+		deductGalaxyCoinPayOrderMoney(orderDon, discountPrice, payRequest.getGalaxyCoin(), user);
 
 		orderDonMapper.insert(orderDon);
 		//记录续费升级的规格
@@ -4498,6 +4498,8 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 			//续费订单
 			orderDon.setOrderType(2);
 		}
+		//订单实际支付金额
+		BigDecimal orderDonMoney = orderDon.getMoney();
 		if (orderDon.getMoney().compareTo(BigDecimal.ZERO) < 0) {
 			throw BusinessRuntimeException.getInstance("订单金额错误");
 		}
@@ -4532,6 +4534,8 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 		orderDon.setPayDesc(goodsDon.getPayDesc());
 		//设置订单支付商品信息
 		setOrderDonPayTile(null, null, null, orderDon, goodsDon, sku, null);
+		//存在银河币
+		deductGalaxyCoinPayOrderMoney(orderDon, orderDonMoney, orderPayRequest.getGalaxyCoin(), user);
 		this.saveOrUpdate(orderDon);
 		if (orderDon.getStatus() == OrderDon.Status.noPayment) {
 			jobManager.addJob(EXPIRY_TIME, () -> {

+ 15 - 14
netflix-web/src/main/java/com/cyksj/web/controller/group/GroupRelationController.java

@@ -1326,30 +1326,31 @@ public class GroupRelationController {
         BigDecimal payMoney = galaxyCoinPayConfigDto.getMoney();
         for (GalaxyCoinRenewTicketsView galaxyCoinRenewTicketsView : search.getDataList()) {
             Long skuId = galaxyCoinRenewTicketsView.getSkuId();
-            GoodsDonSku maxPriceSku = null;
+            BigDecimal maxSkuPrice = BigDecimal.ZERO;
             if (galaxyCoinRenewTicketsView.getIsMirror() != null && galaxyCoinRenewTicketsView.getIsMirror()) {
                 List<RenewUpgradePackageFrontView> renewUpgradePackageFrontViews = beanSearcher.searchAll(RenewUpgradePackageFrontView.class, MapUtils.builder().field(RenewUpgradePackageFrontView::getSkuId, skuId).build());
-                List<Long> upgradeSkuIds = new ArrayList<>();
-                renewUpgradePackageFrontViews.forEach(renew -> {
+                for (RenewUpgradePackageFrontView renew : renewUpgradePackageFrontViews) {
                     try {
-                        upgradeSkuIds.addAll(Jsons.parseList(renew.getUpgradeSkuIds(), Long.class));
+                        List<Long> upgradeSkuIds = Jsons.parseList(renew.getUpgradeSkuIds(), Long.class);
+                        GoodsDonSku maxPriceSku = goodsDonSkuMapper.selectOne(Wrappers.lambdaQuery(GoodsDonSku.class)
+                                .eq(GoodsDonSku::getStatus, Boolean.TRUE)
+                                .in(GoodsDonSku::getId, upgradeSkuIds)
+                                .orderByDesc(GoodsDonSku::getPrice)
+                                .last("limit 1"));
+                        BigDecimal discountMoney = maxPriceSku.getPrice().multiply(renew.getDiscount());
+                        if (discountMoney.compareTo(maxSkuPrice) > 0) {
+                            maxSkuPrice = discountMoney;
+                        }
                     } catch (Exception e) {
                     }
-                });
-                if (CollUtil.isNotEmpty(upgradeSkuIds)) {
-                    maxPriceSku = goodsDonSkuMapper.selectOne(Wrappers.lambdaQuery(GoodsDonSku.class)
-                            .eq(GoodsDonSku::getStatus, Boolean.TRUE)
-                            .in(GoodsDonSku::getId, upgradeSkuIds)
-                            .orderByDesc(GoodsDonSku::getPrice)
-                            .last("limit 1"));
                 }
 
             }
-            if (maxPriceSku == null) {
-                maxPriceSku = goodsDonSkuMapper.selectById(skuId);
+            if (maxSkuPrice.compareTo(BigDecimal.ZERO) == 0) {
+                maxSkuPrice = goodsDonSkuMapper.selectById(skuId).getPrice();
             }
             //此次最大可抵扣银河币数量
-            BigDecimal maxDeductGalaxyCoin = maxPriceSku.getPrice().multiply(maxRate).divide(payMoney).multiply(payGalaxyCoin);
+            BigDecimal maxDeductGalaxyCoin = maxSkuPrice.multiply(maxRate).divide(payMoney).multiply(payGalaxyCoin);
             galaxyCoinRenewTicketsView.setMaxGalaxyCoinDeduct(userGalaxyCoin.compareTo(maxDeductGalaxyCoin) > 0 ? maxDeductGalaxyCoin : userGalaxyCoin);
             if (galaxyCoinRenewTicketsView.getExpiryTime() != null && galaxyCoinRenewTicketsView.getGoodsType() == 1) {
                 String remainDays = DateUtil.formatBetween(now, galaxyCoinRenewTicketsView.getExpiryTime(), BetweenFormater.Level.DAY);