Explorar el Código

税费显示问题

lhm hace 3 años
padre
commit
ac8016a248

+ 14 - 9
kmall-admin/src/main/java/com/kmall/admin/controller/OrderController.java

@@ -1147,6 +1147,11 @@ public class OrderController {
         List<OrderGoodsEntity> goodsList = orderGoodsService.queryList(map);
 
         BigDecimal tax = new BigDecimal(0);
+        for (OrderGoodsEntity orderGoodsEntity : goodsList) {
+            tax = tax.add(orderGoodsEntity.getTaxPrice());
+        }
+
+        /*BigDecimal tax = new BigDecimal(0);
         for(OrderGoodsEntity orderGoodsEntity : goodsList){
             BigDecimal retailPrice = orderGoodsEntity.getRetailPrice();
             BigDecimal goodsRate = orderGoodsEntity.getGoodsRate();
@@ -1158,17 +1163,17 @@ public class OrderController {
             orderGoodsEntity.setTax(goodsTax);
             tax = tax.add(goodsTax).setScale(2,RoundingMode.HALF_UP);
 //            BigDecimal goodsTax = retailPrice.divide(new BigDecimal(1).add(goodsRate),2,RoundingMode.HALF_DOWN).multiply(goodsRate).multiply(new BigDecimal(number)).setScale(0,RoundingMode.HALF_DOWN);
-        }
+        }*/
         String response = null;
 
-        try {
-            // 查询失败原因
-            String url = OmsMerchPropertiesBuilder.instance().getWxOrderResendUrl() + "/"+orderSn;
-            // 同步访问,返回结果字符串
-            response = OkHttpUtils.post(map, url, "SSL");
-        } catch (Exception e) {
-            logger.error("查询失败。"+e.getMessage());
-        }
+//        try {
+//            // 查询失败原因
+//            String url = OmsMerchPropertiesBuilder.instance().getWxOrderResendUrl() + "/"+orderSn;
+//            // 同步访问,返回结果字符串
+//            response = OkHttpUtils.post(map, url, "SSL");
+//        } catch (Exception e) {
+//            logger.error("查询失败。"+e.getMessage());
+//        }
 
         Map<String,Object> result = new HashMap<>();
         result.put("orderProcessRecordEntity",orderProcessRecordEntity);

+ 19 - 17
kmall-admin/src/main/java/com/kmall/admin/service/impl/OrderServiceImpl.java

@@ -4692,22 +4692,24 @@ public class OrderServiceImpl implements OrderService {
                     // 满赠商品不参与积分分摊计算
                     return !Constants.ActivityTopicEnum.MZ.getTopicName().equals(goodsDetailsDto.getActivity());
                 }).collect(Collectors.toList());
+                // 系统设置的最大抵扣比例(最多能抵扣订单金额的比例),在系统管理的系统参数中设置,KEY为 HAIKONG_MEMBER_MAX_SCORE_RATIO
+                String scoreRatioStr = sysConfigDao.queryByKey(Constants.HAIKONG_MEMBER_MAX_SCORE_RATIO);
+                if (org.springframework.util.StringUtils.isEmpty(scoreRatioStr)) {
+                    LOGGER.error("计算优惠价格时,未设置订单的最大积分抵扣比例!");
+                    throw new ServiceException(String.format("请先设置订单的最大积分抵扣比例,设置方式:【系统管理】-->【系统参数】,参数名为:【%s】", Constants.HAIKONG_MEMBER_MAX_SCORE_RATIO));
+                }
+                BigDecimal scoreRatio = new BigDecimal(scoreRatioStr);
                 // 总分摊积分
                 BigDecimal shareScore = BigDecimal.ZERO;
                 // 取整后的积分数量
                 BigDecimal scoreIntegerDecimal = BigDecimal.valueOf(scoreInteger);
                 // 计算积分能抵扣的金额
-                BigDecimal scoreCanDeductionPrice = scoreIntegerDecimal.divide(BigDecimal.valueOf(scoreLimit), 2, BigDecimal.ROUND_HALF_UP);
+                BigDecimal scoreCanDeductionPrice = orderTotalPrice.multiply(new BigDecimal(scoreRatioStr)).setScale(0, BigDecimal.ROUND_FLOOR);
+                // 计算最大可抵扣积分
+                BigDecimal maxDeductionScore = scoreCanDeductionPrice.multiply(BigDecimal.valueOf(scoreLimit));
                 // 订单详情积分抵扣总金额
                 BigDecimal goodsDetailScoreDeductionPrice = BigDecimal.ZERO;
                 int size = goodsDetailsDtos.size();
-                // 系统设置的最大抵扣比例(最多能抵扣订单金额的比例),在系统管理的系统参数中设置,KEY为 HAIKONG_MEMBER_MAX_SCORE_RATIO
-                String scoreRatioStr = sysConfigDao.queryByKey(Constants.HAIKONG_MEMBER_MAX_SCORE_RATIO);
-                if (org.springframework.util.StringUtils.isEmpty(scoreRatioStr)) {
-                    LOGGER.error("计算优惠价格时,未设置订单的最大积分抵扣比例!");
-                    throw new ServiceException(String.format("请先设置订单的最大积分抵扣比例,设置方式:【系统管理】-->【系统参数】,参数名为:【%s】", Constants.HAIKONG_MEMBER_MAX_SCORE_RATIO));
-                }
-                BigDecimal scoreRatio = new BigDecimal(scoreRatioStr);
                 for (int i = 0; i < size; i++) {
                     GoodsDetailsDto goodsDetailsDto = goodsDetailsDtos.get(i);
                     // 抵扣积分分摊
@@ -4720,7 +4722,7 @@ public class OrderServiceImpl implements OrderService {
                     BigDecimal actualPaymentAmount = goodsDetailsDto.getActualPaymentAmount();
                     // 当前商品最大支持抵扣的金额
                     BigDecimal currentSkuMaxDeductionPrice = actualPaymentAmount.multiply(BigDecimal.valueOf(goodsDetailsDto.getSellVolume()))
-                                                                                .multiply(scoreRatio);
+                                                                                .multiply(scoreRatio).setScale(0, BigDecimal.ROUND_FLOOR);
                     // 其他活动优惠金额
                     BigDecimal otherDiscountedPrice = Objects.isNull(goodsDetailsDto.getDiscountedPrice()) ? BigDecimal.ZERO : goodsDetailsDto.getDiscountedPrice();
 
@@ -4734,7 +4736,7 @@ public class OrderServiceImpl implements OrderService {
                         discountedPrice = shareScoreItem.divide(BigDecimal.valueOf(scoreLimit), 2, BigDecimal.ROUND_HALF_UP);
                     }
                     // 订单商品详情最后一个商品并且详情不止一个商品
-                    if (i == index && size > 1) {// 商品总价
+                    if (i == index && size > 1) {
                         // 最后一个商品分摊积分 = 积分总数 - 已分摊积分
                         shareScoreItem = scoreIntegerDecimal.subtract(shareScore);
 //                        discountedPrice = shareScoreItem.divide(BigDecimal.valueOf(scoreLimit), 2, BigDecimal.ROUND_HALF_UP);
@@ -4744,9 +4746,9 @@ public class OrderServiceImpl implements OrderService {
                     // 订单商品详情只有一个商品的情况下
                     if (size == 1) {
                         // 总计分为所有积分取整
-                        shareScore = scoreIntegerDecimal;
+                        shareScoreItem = scoreIntegerDecimal;
                         // 3-3. 计算积分抵扣后的价格
-                        discountedPrice = shareScore.divide(BigDecimal.valueOf(scoreLimit), 2, BigDecimal.ROUND_HALF_UP);
+                        discountedPrice = shareScoreItem.divide(BigDecimal.valueOf(scoreLimit), 2, BigDecimal.ROUND_HALF_UP);
                     }
                     // 当前计算出来的积分抵扣金额如果比最大的还要大,则积分抵扣金额为最大抵扣金额,并且积分需要重新计算
                     if (discountedPrice.compareTo(currentSkuMaxDeductionPrice) > 0) {
@@ -5094,7 +5096,7 @@ public class OrderServiceImpl implements OrderService {
         orderGoodsVo.setInventoryType(goodsDto.getInventoryType());
         orderGoodsVo.setDefectiveProductsGrade(goodsDto.getDefectiveProductsGrade());
 
-        BigDecimal number = new BigDecimal(Long.valueOf(goodsDto.getSellVolume()));
+        /*BigDecimal number = new BigDecimal(Long.valueOf(goodsDto.getSellVolume()));
         BigDecimal goodsTotal = goodsDto.getRetailPrice().multiply(number);//单商品总价
         BigDecimal rate = goodsTotal.divide(orderInfo.getGoods_price(), 2, BigDecimal.ROUND_HALF_UP);//当前商品总价/订单总价(不含运费、不含优惠券)
         BigDecimal freightPrice = BigDecimal.valueOf(orderInfo.getFreight_price());
@@ -5122,13 +5124,13 @@ public class OrderServiceImpl implements OrderService {
             orderGoodsVo.setSettlePrice(goodsTotal);//商品结算平摊价格
         } else {
             orderGoodsVo.setSettlePrice(settlePrice);//商品结算平摊价格
-        }
+        }*/
 
         // 计算税费
-        GoodsEntity goodsEntity = goodsService.queryObject(goodsDto.getId().intValue());
+        /*GoodsEntity goodsEntity = goodsService.queryObject(goodsDto.getId().intValue());
         BigDecimal goodsTax = CalculateTax.calculateFinalTax(goodsEntity, goodsDto.getStoreRetailPrice(), goodsService).setScale(3, RoundingMode.HALF_UP);
-        goodsTax = goodsTax.multiply(number).setScale(2, RoundingMode.HALF_UP);
-        orderGoodsVo.setTaxPrice(goodsTax);
+        goodsTax = goodsTax.multiply(number).setScale(2, RoundingMode.HALF_UP);*/
+        orderGoodsVo.setTaxPrice(goodsDto.getGoodsTaxes());
 
         return orderGoodsVo;
     }

+ 2 - 2
kmall-admin/src/main/webapp/WEB-INF/page/sale/sale.html

@@ -178,7 +178,7 @@
                                 <th style="width: 300px;padding: 7px">跨境商品名称</th>
                                 <th style="padding: 7px">单价</th>
                                 <th style="padding: 7px">优惠金额</th>
-                                <th style="padding: 7px">税费</th>
+                                <th style="padding: 7px">预估税费</th>
                                 <th style="padding: 7px">实际支付价</th>
                                 <th style="padding: 7px">数量</th>
                                 <th style="padding: 7px">参与活动</th>
@@ -448,7 +448,7 @@
 <!--                                    <td>{{item.discountedPrice}}</td>-->
                                     <td>{{item.number}}</td>
                                     <td>{{item.actualPaymentAmount}}</td>
-                                    <td >{{item.tax}}</td>
+                                    <td >{{item.taxPrice}}</td>
                                     <td >{{item.activity}}</td>
                                 </tr>
                             </table>