1
0
Переглянути джерело

活动相关bug修复,订单详情新增积分抵扣数量、积分抵扣金额

lhm 3 роки тому
батько
коміт
33e32a4eb6

+ 8 - 0
kmall-admin/src/main/java/com/kmall/admin/dao/mk/MkActivitiesScoreDao.java

@@ -23,4 +23,12 @@ public interface MkActivitiesScoreDao extends BaseDao<MkActivitiesScoreEntity> {
                                                                             @Param("nowTime") Date nowTime);
 
     List<MkActivitiesScoreEntity> queryDetailByTime(@Param("date") Date date);
+
+    /**
+     * 查询积分抵扣活动信息
+     *
+     * @param mkaIdList 活动id集合
+     * @return 活动
+     */
+    List<MkActivitiesScoreEntity> queryActivityInfoByMkaIdList(List<Long> mkaIdList);
 }

+ 13 - 0
kmall-admin/src/main/java/com/kmall/admin/dto/GoodsDetailsDto.java

@@ -90,6 +90,11 @@ public class GoodsDetailsDto {
     private Integer deductionScore;
 
     /**
+     * 积分抵扣金额
+     */
+    private BigDecimal deductionPrice;
+
+    /**
      * 仓库编码
      */
     private String warehouseSn;
@@ -372,4 +377,12 @@ public class GoodsDetailsDto {
     public void setInventoryType(String inventoryType) {
         this.inventoryType = inventoryType;
     }
+
+    public BigDecimal getDeductionPrice() {
+        return deductionPrice;
+    }
+
+    public void setDeductionPrice(BigDecimal deductionPrice) {
+        this.deductionPrice = deductionPrice;
+    }
 }

+ 20 - 0
kmall-admin/src/main/java/com/kmall/admin/entity/GoodsEntity.java

@@ -404,6 +404,10 @@ public class GoodsEntity implements Serializable {
      */
     private Integer exitRegionNumber;
 
+    private Integer deductionScore;
+
+    private BigDecimal deductionPrice;
+
     public BigDecimal getRetailPrice() {
         return retailPrice;
     }
@@ -1345,6 +1349,22 @@ public class GoodsEntity implements Serializable {
         this.unitCodeName = unitCodeName;
     }
 
+    public Integer getDeductionScore() {
+        return deductionScore;
+    }
+
+    public void setDeductionScore(Integer deductionScore) {
+        this.deductionScore = deductionScore;
+    }
+
+    public BigDecimal getDeductionPrice() {
+        return deductionPrice;
+    }
+
+    public void setDeductionPrice(BigDecimal deductionPrice) {
+        this.deductionPrice = deductionPrice;
+    }
+
     /**
      * 重写hashCode方法,用作排序
      */

+ 11 - 0
kmall-admin/src/main/java/com/kmall/admin/haikong/vo/QueryGoodsVO.java

@@ -158,6 +158,8 @@ public class QueryGoodsVO {
 
     private Integer deductionScore;
 
+    private BigDecimal deductionPrice;
+
 
     public String getProdBarcode() {
         return prodBarcode;
@@ -399,6 +401,14 @@ public class QueryGoodsVO {
         this.deductionScore = deductionScore;
     }
 
+    public BigDecimal getDeductionPrice() {
+        return deductionPrice;
+    }
+
+    public void setDeductionPrice(BigDecimal deductionPrice) {
+        this.deductionPrice = deductionPrice;
+    }
+
     @Override
     public String toString() {
         return "QueryGoodsVO{" +
@@ -432,6 +442,7 @@ public class QueryGoodsVO {
                 ", activity='" + activity + '\'' +
                 ", productId='" + productId + '\'' +
                 ", deductionScore=" + deductionScore +
+                ", deductionPrice=" + deductionPrice +
                 '}';
     }
 

+ 96 - 68
kmall-admin/src/main/java/com/kmall/admin/service/impl/OrderServiceImpl.java

@@ -2108,6 +2108,7 @@ public class OrderServiceImpl implements OrderService {
     @Override
     @Transactional(rollbackFor = Exception.class)
     public synchronized Map offlineRetailSubmit(Map param, SysUserEntity user) {
+        long start = System.currentTimeMillis();
         // 解析订单数据 List
         List<LinkedHashMap> goodsList = (List<LinkedHashMap>) param.get("goodsList");
         // 解析用户信息 LinkedHashMap
@@ -2161,6 +2162,12 @@ public class OrderServiceImpl implements OrderService {
                 queryGoodsVo.setTotalPrice(new BigDecimal(String.valueOf(map.get("actualPaymentAmount"))));
                 queryGoodsVo.setActivity((String) map.get("activity"));
                 queryGoodsVo.setDeductionScore((Integer) map.get("deductionScore"));
+                Object deductionPriceObj = map.get("deductionPrice");
+                BigDecimal deductionPrice = BigDecimal.ZERO;
+                if (Objects.nonNull(deductionPriceObj)) {
+                    deductionPrice = new BigDecimal(deductionPriceObj.toString());
+                }
+                queryGoodsVo.setDeductionPrice(deductionPrice);
                 queryGoodsVOList.add(queryGoodsVo);
             });
             // 将在循环中查询数据库改为一次性查询
@@ -2355,14 +2362,15 @@ public class OrderServiceImpl implements OrderService {
                     goodsEntity.setListPicUrl(goodsDto.getListPicUrl());
                     GoodsEntity goodsEntity1 = goodsEntityMap.get(sku);
                     if (Objects.nonNull(goodsEntity1)) {
-                        goodsEntity.setNetWeight(goodsEntity1.getNetWeight());
                         goodsEntity.setWarehouseSn(goodsEntity1.getWarehouseSn());
                         goodsEntity.setConsignorSn(goodsEntity1.getConsignorSn());
                         goodsEntity.setWarehousSysGoodId(goodsEntity1.getWarehousSysGoodId());
                         goodsEntity.setInventoryType(goodsEntity1.getInventoryType());
                         goodsEntity.setDefectiveProductsGrade(goodsEntity1.getDefectiveProductsGrade());
-                        weight = weight.add(goodsEntity1.getNetWeight().multiply(new BigDecimal(goodsEntity.getSellVolume())));
+                        goodsEntity.setCategoryId(goodsEntity1.getCategoryId());
                     }
+                    goodsEntity.setDeductionScore(goodsDto.getDeductionScore());
+                    goodsEntity.setDeductionPrice(goodsDto.getDeductionPrice());
                     goodsEntities.add(goodsEntity);
                 } else {
                     // sku不存在
@@ -2437,7 +2445,6 @@ public class OrderServiceImpl implements OrderService {
             order.setMerchOrderSn(merchOrderSn);
             order.setCoupon_name(couponSn); // 借用这个字段来记录是否使用优惠券
             order.setIdCard(userEntity.getIdNo());
-            order.setWeight(weight);
             //插入订单信息和订单商品
             orderDao.saveOrderVo(order);
 
@@ -2731,6 +2738,9 @@ public class OrderServiceImpl implements OrderService {
             // 推单
             sendOrderInfoToVmcShop(order, orderGoodsVoList);
 
+            LOGGER.info("----------------------------------------------------------------------------");
+            LOGGER.info("下单耗时:{}ms", (System.currentTimeMillis()) - start);
+            LOGGER.info("----------------------------------------------------------------------------");
             return resultObj;
         } catch (Exception e) {
             e.printStackTrace();
@@ -2872,7 +2882,7 @@ public class OrderServiceImpl implements OrderService {
     }
 
     /**
-     * 组装推送订单数据:跨境数据
+     * 组装推送订单数据:订单数据
      * @param order 订单数据
      * @return  订单数据
      */
@@ -2890,12 +2900,6 @@ public class OrderServiceImpl implements OrderService {
         orderInfoDTO.setConsigneeTel("0756-8800000");
         orderInfoDTO.setConsigneeEmail("hk@greedc.com");
         orderInfoDTO.setConsigneeMobile(order.getMobile());
-        BigDecimal weight = order.getWeight();
-        if (Objects.nonNull(weight)) {
-            orderInfoDTO.setWeight(weight.toString());
-        } else {
-            orderInfoDTO.setWeight("0");
-        }
         orderInfoDTO.setQuantity(order.getNumber());
         orderInfoDTO.setOrderTotal(order.getActual_price());
         orderInfoDTO.setPlatform("store");
@@ -3170,6 +3174,7 @@ public class OrderServiceImpl implements OrderService {
             LOGGER.info("请求会员系统同步消费订单接口!请求体:{}", body);
             // 发送请求
             String memberOrderSyncResponseJson = haiKongMemberTemplate.memberOrderSync(body);
+            LOGGER.info("请求会员系统同步消费订单接口!响应:{}", memberOrderSyncResponseJson);
             Response<Long> response = JacksonUtil.fromListJson(memberOrderSyncResponseJson, new TypeReference<Response<Long>>() {});
             if (Objects.nonNull(response) && response.getSuccess()) {
                 haiKongMemberOrderSyncResendEntity.setMemberSysOrderId(response.getData());
@@ -3178,7 +3183,7 @@ public class OrderServiceImpl implements OrderService {
                 haiKongMemberOrderSyncResendEntity.setResendStatus(HaiKongMemberOrderResendStatusEnum.WAIT_RESEND.getStatus());
             }
             haiKongMemberOrderSyncResendService.save(haiKongMemberOrderSyncResendEntity);
-            LOGGER.info("请求会员系统同步消费订单接口成功!响应数据:{}", memberOrderSyncResponseJson);
+            LOGGER.info("请求会员系统同步消费订单接口成功!");
         } catch (Exception e) {
             LOGGER.error("请求会员系统同步消费订单接口出现异常!准备新增发送失败记录,等待重发!异常信息:", e);
             // 没有请求成功,写表,重发
@@ -3221,6 +3226,7 @@ public class OrderServiceImpl implements OrderService {
             String body = JacksonUtil.toJson(memberScoreChangeDTO);
             LOGGER.info("请求会员系统积分变动接口!请求体:{}", body);
             String changeMemberScoreResponseJson = haiKongMemberTemplate.changeMemberScore(body);
+            LOGGER.info("请求会员系统积分变动接口!响应数据:{}", changeMemberScoreResponseJson);
             Response<MemberScoreChangeResponseDTO> response = JacksonUtil.fromListJson(changeMemberScoreResponseJson, new TypeReference<Response<MemberScoreChangeResponseDTO>>() {});
             if (Objects.nonNull(response) && response.getSuccess()) {
                 MemberScoreChangeResponseDTO responseData = response.getData();
@@ -3230,7 +3236,7 @@ public class OrderServiceImpl implements OrderService {
                 haiKongMemberScoreChangeRecordEntity.setResendStatus(HaiKongMemberOrderResendStatusEnum.WAIT_RESEND.getStatus());
             }
             haiKongMemberScoreChangeRecordService.save(haiKongMemberScoreChangeRecordEntity);
-            LOGGER.info("请求会员系统积分变动接口成功!响应数据:{}", changeMemberScoreResponseJson);
+            LOGGER.info("请求会员系统积分变动接口成功!");
         } catch (Exception e) {
             LOGGER.error("请求会员系统积分变动接口出现异常!准备新增发送失败记录,等待重发!异常信息:", e);
             // 失败重发
@@ -4260,6 +4266,7 @@ public class OrderServiceImpl implements OrderService {
                             goodsDetailsDto.setGoodstaxes(String.valueOf(tax.multiply(new BigDecimal(goodsDetailsDto.getSellVolume()))));
                             goodsDetailsDto.setActivity(Constants.ActivityTopicEnum.LSCX.getTopicName());
                             goodsDetailsDto.setDiscountedPrice(retailPrice.subtract(activityPrice));
+                            goodsDetailsDto.setDeductionPrice(retailPrice.subtract(activityPrice));
                             activityFlag.set(false);
                             promotionActivityFlag.set(true);
                         }
@@ -4509,7 +4516,7 @@ public class OrderServiceImpl implements OrderService {
                 Integer score = memberInfoDTO.getScore();
                 if (Objects.nonNull(score) && score > 0) {
                     // 有积分
-                    afterDiscountPrice = calculatePreferentialPrice(orderTotalPrice, score, memberCode, activityFlag, calculateOrderDiscountPriceResponseVO, goodsDetailsDtos, promotionSkuList);
+                    afterDiscountPrice = calculatePreferentialPrice(orderTotalPrice, score, memberCode, storeId, calculateOrderDiscountPriceResponseVO, goodsDetailsDtos, promotionSkuList, mkActivitiesEntityList);
                     LOGGER.info("会员【{}】,当前积分:{},积分抵扣后的订单金额:{},积分抵扣前的订单金额:{}", memberCode, score, afterDiscountPrice, orderTotalPrice);
                     calculateOrderDiscountPriceResponseVO.setOrderTotalPrice(afterDiscountPrice);
                     calculateOrderDiscountPriceResponseVO.setGoodsDetailsDtos(goodsDetailsDtos);
@@ -4551,30 +4558,43 @@ public class OrderServiceImpl implements OrderService {
     private BigDecimal calculatePreferentialPrice(BigDecimal orderTotalPrice,
                                                   Integer score,
                                                   String memberCode,
-                                                  AtomicBoolean activityFlag,
+                                                  String storeId,
                                                   CalculateOrderDiscountPriceResponseVO calculateOrderDiscountPriceResponseVO,
                                                   List<GoodsDetailsDto> goodsDetailsDtos,
-                                                  List<String> promotionSkuList) {
+                                                  List<String> promotionSkuList,
+                                                  List<MkActivitiesEntity> mkActivitiesEntityList) {
         // 1. 判断是否有积分,是否需要计算积分抵扣后的价格
         AtomicBoolean isCalculateScorePrice = new AtomicBoolean(false);
         if (Objects.nonNull(score) && score > 0) {
             isCalculateScorePrice.set(true);
         }
-        // 参与了积分抵扣的sku集合
-        Date date = new Date();
-        List<MkActivitiesScoreEntity> mkActivitiesScoreEntities = mkActivitiesScoreService.queryDetailByTime(date);
-        if (CollectionUtils.isEmpty(mkActivitiesScoreEntities)) {
-            LOGGER.error("当前时间【{}】无积分抵扣活动!", date);
+        // 参与了积分抵扣的活动id
+        List<Long> mkaIdList = mkActivitiesEntityList.stream().filter(mkActivitiesEntity -> Constants.ActivityTopicEnum.JFDK.getTopicCode().equals(mkActivitiesEntity.getMkaTopic()))
+                .map(MkActivitiesEntity::getMkaId)
+                .collect(Collectors.toList());
+        if (CollectionUtils.isEmpty(mkaIdList)) {
+            LOGGER.error("当前时间【{}】无积分抵扣活动!", new Date());
             return orderTotalPrice;
         }
+
+        List<MkActivitiesScoreEntity> mkActivitiesScoreEntities = mkActivitiesScoreService.queryActivityInfoByMkaIdList(mkaIdList);
+
+        // 参与了积分抵扣的sku集合
         List<String> scoreDeductionSkuList = mkActivitiesScoreEntities.stream()
                 .filter(m -> Constants.RejectStatus.ALLOW.getCode().equals(m.getReject()))
                 .map(MkActivitiesScoreEntity::getSku)
                 .collect(Collectors.toList());
-        // 转换成map,保存参与了积分抵扣活动的sku,积分计算比例的数据,key===>sku,value===>比例
+        // 转换成map,保存参与了积分抵扣活动的sku,积分计算比例的数据,key===>sku,value===>最大抵扣比例
         Map<String, BigDecimal> skuScoreLimitMap = mkActivitiesScoreEntities.stream()
                 .filter(m -> Constants.RejectStatus.ALLOW.getCode().equals(m.getReject()))
-                .collect(Collectors.toMap(MkActivitiesScoreEntity::getSku, MkActivitiesScoreEntity::getScoreLimit, (k1, k2) -> k2));
+                .collect(Collectors.toMap(MkActivitiesScoreEntity::getSku, mkActivitiesScoreEntity -> {
+                    BigDecimal scoreLimit = mkActivitiesScoreEntity.getScoreLimit();
+                    if (Objects.isNull(scoreLimit)) {
+                        LOGGER.error("商品:【{}】,未设置最大抵扣比例!请设置后在计算优惠价!", mkActivitiesScoreEntity.getSku());
+                        throw new ServiceException(String.format("商品:【%s】,未设置最大抵扣比例!请设置后在计算优惠价!", mkActivitiesScoreEntity.getSku()));
+                    }
+                    return scoreLimit;
+                }, (k1, k2) -> k2));
         // 当前订单中参与了积分抵扣活动的sku总支付金额
         BigDecimal skuTotalPrice = BigDecimal.ZERO;
         for (GoodsDetailsDto goodsDetailsDto : goodsDetailsDtos) {
@@ -4590,31 +4610,25 @@ public class OrderServiceImpl implements OrderService {
         if (isCalculateScorePrice.get()) {
             Integer scoreLimit = haiKongProperties.getMemberScoreLimit();
             if (score < scoreLimit) {
-                LOGGER.warn("用户【{}】的积分数量为:{},最低需要30积分才能抵扣!", memberCode, score);
+                LOGGER.error("用户【{}】的积分数量为:{},最低需要{}积分才能抵扣!", memberCode, score, scoreLimit);
                 calculateOrderDiscountPriceResponseVO.setAfterScore(score);
-                return orderTotalPrice;
+                throw new ServiceException(String.format("用户【%s】的积分数量为:%s,最低需要%s积分才能抵扣!", memberCode, score, scoreLimit));
             } else {
                 // 积分取整
                 int scoreInteger = score % scoreLimit == 0 ? score : score - (score % scoreLimit);
-                // 积分的50%
-                int scoreIntegerHalf = scoreInteger * scoreLimit / 100;
-                // 3-2. 计算出积分能抵扣的价格
-                int scoreMayDeductionPrice = (int) (score / scoreLimit);
-                BigDecimal scoreMayDeductionPriceDecimal = new BigDecimal(scoreMayDeductionPrice);
                 // 过滤掉参与过限时特价并且与积分抵扣互斥的sku,以及未参加积分抵扣活动的sku
                 goodsDetailsDtos = goodsDetailsDtos.stream().filter(goodsDetailsDto -> {
                     if (!promotionSkuList.contains(goodsDetailsDto.getSku()) && scoreDeductionSkuList.contains(goodsDetailsDto.getSku())) {
                         return true;
                     }
                     // 满赠商品不参与积分分摊计算
-                    if (!Constants.ActivityTopicEnum.MZ.getTopicName().equals(goodsDetailsDto.getActivity())) {
-                        return true;
-                    }
-                    return false;
+                    return !Constants.ActivityTopicEnum.MZ.getTopicName().equals(goodsDetailsDto.getActivity());
                 }).collect(Collectors.toList());
                 // 总分摊积分
                 BigDecimal shareScore = BigDecimal.ZERO;
+                // 取整后的积分数量
                 BigDecimal scoreIntegerDecimal = BigDecimal.valueOf(scoreInteger);
+                // 订单详情积分抵扣总金额
                 BigDecimal goodsDetailScoreDeductionPrice = BigDecimal.ZERO;
                 int size = goodsDetailsDtos.size();
                 for (int i = 0; i < size; i++) {
@@ -4623,62 +4637,75 @@ public class OrderServiceImpl implements OrderService {
                     int index = size - 1;
                     goodsDetailsDto.setActivity(org.springframework.util.StringUtils.isEmpty(goodsDetailsDto.getActivity()) ? "积分抵扣" : goodsDetailsDto.getActivity() + ",积分抵扣");
                     String sku = goodsDetailsDto.getGoodsSn();
+                    // 系统设置的最大抵扣比例(最多能抵扣订单金额的比例),导入积分抵扣活动时设置
                     BigDecimal scoreLimitDecimal = skuScoreLimitMap.get(sku);
                     String prodBarcode = goodsDetailsDto.getProdBarcode();
-                    BigDecimal retailPrice = goodsDetailsDto.getRetailPrice();
+                    // 此字段 = 零售价 - 其他活动优惠金额
                     BigDecimal actualPaymentAmount = goodsDetailsDto.getActualPaymentAmount();
+                    // 当前商品最大支持抵扣的金额
+                    BigDecimal currentSkuMaxDeductionPrice = actualPaymentAmount.multiply(BigDecimal.valueOf(goodsDetailsDto.getSellVolume()))
+                                                                                .multiply(scoreLimitDecimal);
+                    // 其他活动优惠金额
+                    BigDecimal otherDiscountedPrice = Objects.isNull(goodsDetailsDto.getDiscountedPrice()) ? BigDecimal.ZERO : goodsDetailsDto.getDiscountedPrice();
+
+                    // 当前商品分摊积分数量,当前商品分摊积分 = 当前商品支付价 / 订单中所有参与积分抵扣商品支付价的和 * 积分取整
+                    BigDecimal shareScoreItem = BigDecimal.ZERO;
+                    // 当前商品分摊积分抵扣金额,保留两位小数,四舍五入
+                    BigDecimal discountedPrice = BigDecimal.ZERO;
                     // 计算抵扣,当商品不是最后一个商品
                     if (i < index) {
-                        // 商品总价
-                        // 分摊积分
-                        BigDecimal shareScoreItem = retailPrice.divide(skuTotalPrice, 2, BigDecimal.ROUND_HALF_UP).multiply(scoreIntegerDecimal);
-                        shareScore = shareScore.add(shareScoreItem);
-                        // 保留两位小数,四舍五入
-                        BigDecimal discountedPrice = shareScore.divide(BigDecimal.valueOf(scoreLimit), 2, BigDecimal.ROUND_HALF_UP);
-                        goodsDetailScoreDeductionPrice = goodsDetailScoreDeductionPrice.add(discountedPrice);
-                        goodsDetailsDto.setDiscountedPrice(discountedPrice);
-                        goodsDetailsDto.setDeductionScore(shareScoreItem.intValue());
-                        goodsDetailsDto.setActualPaymentAmount(actualPaymentAmount.subtract(discountedPrice));
+                        shareScoreItem = actualPaymentAmount.divide(skuTotalPrice, 2, BigDecimal.ROUND_HALF_UP).multiply(scoreIntegerDecimal);
+                        discountedPrice = shareScoreItem.divide(BigDecimal.valueOf(scoreLimit), 2, BigDecimal.ROUND_HALF_UP);
                     }
                     // 订单商品详情最后一个商品并且详情不止一个商品
                     if (i == index && size > 1) {// 商品总价
-                        // 分摊积分
-                        BigDecimal shareScoreItem = scoreIntegerDecimal.subtract(shareScore);
-                        BigDecimal discountedPrice = shareScoreItem.divide(BigDecimal.valueOf(scoreLimit), 2, BigDecimal.ROUND_HALF_UP);
-                        goodsDetailScoreDeductionPrice = goodsDetailScoreDeductionPrice.add(discountedPrice);
-                        goodsDetailsDto.setDiscountedPrice(discountedPrice);
-                        goodsDetailsDto.setDeductionScore(shareScoreItem.intValue());
-                        goodsDetailsDto.setActualPaymentAmount(actualPaymentAmount.subtract(discountedPrice));
+                        // 最后一个商品分摊积分 = 积分总数 - 已分摊积分
+                        shareScoreItem = scoreIntegerDecimal.subtract(shareScore);
+                        discountedPrice = shareScoreItem.divide(BigDecimal.valueOf(scoreLimit), 2, BigDecimal.ROUND_HALF_UP);
                     }
                     // 订单商品详情只有一个商品的情况下
                     if (size == 1) {
+                        // 总计分为所有积分取整
                         shareScore = scoreIntegerDecimal;
-                        // 3-1. 计算总价的50%,百分比可以进行设置,算出整数(向下取整)
-                        BigDecimal halfPrice = orderTotalPrice.multiply(new BigDecimal("0.5")).setScale(0, BigDecimal.ROUND_FLOOR);
                         // 3-3. 计算积分抵扣后的价格
-                        BigDecimal discountedPrice = scoreMayDeductionPriceDecimal;
-                        if (halfPrice.compareTo(discountedPrice) <= 0) {
-                            // 积分能抵扣的金额大于订单总额的50%,按50%抵扣
-                            discountedPrice = halfPrice;
-                        }
-                        goodsDetailScoreDeductionPrice = goodsDetailScoreDeductionPrice.add(discountedPrice);
-                        goodsDetailsDto.setDiscountedPrice(discountedPrice);
-                        goodsDetailsDto.setDeductionScore(shareScore.intValue());
-                        goodsDetailsDto.setActualPaymentAmount(actualPaymentAmount.subtract(discountedPrice));
+                        discountedPrice = shareScore.divide(BigDecimal.valueOf(scoreLimit), 2, BigDecimal.ROUND_HALF_UP);
                     }
+                    // 当前计算出来的积分抵扣金额如果比最大的还要大,则积分抵扣金额为最大抵扣金额,并且积分需要重新计算
+                    if (discountedPrice.compareTo(currentSkuMaxDeductionPrice) > 0) {
+                        discountedPrice = currentSkuMaxDeductionPrice;
+                        shareScoreItem = discountedPrice.multiply(BigDecimal.valueOf(scoreLimit)).setScale(0, BigDecimal.ROUND_FLOOR);
+                    }
+                    // 总分摊积分
+                    shareScore = shareScore.add(shareScoreItem);
+                    // 订单总积分抵扣金额,减去其他优惠金额
+                    goodsDetailScoreDeductionPrice = goodsDetailScoreDeductionPrice.add(discountedPrice);
+                    // 设置积分的优惠金额
+                    goodsDetailsDto.setDeductionPrice(discountedPrice);
+                    // 设置实际支付价
+                    goodsDetailsDto.setActualPaymentAmount(actualPaymentAmount.subtract(discountedPrice));
+                    // 设置抵扣积分数量
+                    goodsDetailsDto.setDeductionScore(shareScoreItem.intValue());
+                    if (Objects.nonNull(otherDiscountedPrice)) {
+                        discountedPrice = discountedPrice.add(otherDiscountedPrice);
+                    }
+                    // 设置总优惠金额
+                    goodsDetailsDto.setDiscountedPrice(discountedPrice);
                     LOGGER.info("--------------------------------------------------------");
                     LOGGER.info("【计算优惠价】sku:【{}】,条码:【{}】积分抵扣{}元,抵扣积分{}分", sku, prodBarcode, goodsDetailsDto.getDiscountedPrice(), shareScore.intValue());
                     LOGGER.info("--------------------------------------------------------");
                 }
-                scoreMayDeductionPriceDecimal = goodsDetailScoreDeductionPrice;
-
-                orderTotalPrice = calculateOrderDiscountPriceResponseVO.getOrderTotalPrice().subtract(scoreMayDeductionPriceDecimal);
+                orderTotalPrice = calculateOrderDiscountPriceResponseVO.getOrderTotalPrice().subtract(goodsDetailScoreDeductionPrice);
                 int afterScore = score - shareScore.intValue();
+                // 抵扣后的积分数量
                 calculateOrderDiscountPriceResponseVO.setAfterScore(afterScore);
+                // 最大抵扣比例
                 calculateOrderDiscountPriceResponseVO.setScoreLimit(scoreLimit);
+                // 抵扣的积分数量
                 calculateOrderDiscountPriceResponseVO.setDeductionScore(score - afterScore);
+                // 订单总价
                 calculateOrderDiscountPriceResponseVO.setOrderTotalPrice(orderTotalPrice);
-                calculateOrderDiscountPriceResponseVO.setScoreDeductionPrice(scoreMayDeductionPriceDecimal);
+                // 积分抵扣的总金额
+                calculateOrderDiscountPriceResponseVO.setScoreDeductionPrice(goodsDetailScoreDeductionPrice);
                 LOGGER.info("会员【{}】,当前积分:{},抵扣订单金额后剩余积分:{}", memberCode, score, afterScore);
             }
         } else {
@@ -4916,7 +4943,7 @@ public class OrderServiceImpl implements OrderService {
         orderInfo.setPostscript("无");
         orderInfo.setAdd_time(new Date());
         orderInfo.setGoods_price(actualPrice.subtract(totalTax));
-        orderInfo.setOrder_price(orderTotalPrice);
+        orderInfo.setOrder_price(actualPrice);
         orderInfo.setActual_price(actualPrice); // 实际支付金额
         orderInfo.setOrder_type("1");
         orderInfo.setOrder_status(0);
@@ -4969,6 +4996,8 @@ public class OrderServiceImpl implements OrderService {
 
         orderGoodsVo.setDiscountedPrice(goodsDto.getDiscountedPrice());
         orderGoodsVo.setActualPaymentAmount(goodsDto.getActualPaymentAmount());
+        orderGoodsVo.setDeductionScore(goodsDto.getDeductionScore());
+        orderGoodsVo.setDeductionPrice(goodsDto.getDeductionPrice());
 
         orderGoodsVo.setNumber(goodsDto.getSellVolume());
 //        orderGoodsVo.setGoods_specification_name_value(goodsDto.get);
@@ -4981,7 +5010,6 @@ public class OrderServiceImpl implements OrderService {
         orderGoodsVo.setGoodsRate(goodsDto.getGoodsRate());
         orderGoodsVo.setSku(goodsDto.getSku());
 
-        orderGoodsVo.setNetWeight(goodsDto.getNetWeight());
         orderGoodsVo.setWarehouseSn(goodsDto.getWarehouseSn());
         orderGoodsVo.setConsignorSn(goodsDto.getConsignorSn());
         orderGoodsVo.setWarehouseSysGoodId(goodsDto.getWarehousSysGoodId());

+ 11 - 0
kmall-admin/src/main/java/com/kmall/admin/service/impl/mk/MkActivitiesScoreServiceImpl.java

@@ -159,4 +159,15 @@ public class MkActivitiesScoreServiceImpl implements MkActivitiesScoreService {
     public List<MkActivitiesScoreEntity> queryDetailByTime(Date date) {
         return mkActivitiesScoreDao.queryDetailByTime(date);
     }
+
+    /**
+     * 查询积分抵扣活动信息
+     *
+     * @param mkaIdList 活动id集合
+     * @return 活动
+     */
+    @Override
+    public List<MkActivitiesScoreEntity> queryActivityInfoByMkaIdList(List<Long> mkaIdList) {
+        return mkActivitiesScoreDao.queryActivityInfoByMkaIdList(mkaIdList);
+    }
 }

+ 7 - 0
kmall-admin/src/main/java/com/kmall/admin/service/mk/MkActivitiesScoreService.java

@@ -103,4 +103,11 @@ public interface MkActivitiesScoreService {
      * @return      sku
      */
     List<MkActivitiesScoreEntity> queryDetailByTime(Date date);
+
+    /**
+     * 查询积分抵扣活动信息
+     * @param mkaIdList 活动id集合
+     * @return          活动
+     */
+    List<MkActivitiesScoreEntity> queryActivityInfoByMkaIdList(List<Long> mkaIdList);
 }

+ 2 - 0
kmall-admin/src/main/resources/mybatis/mapper/OrderGoodsDao.xml

@@ -216,6 +216,7 @@
             `settle_price`,
             `sku`,
             `deduction_score`,
+            `deduction_price`,
             `order_biz_type`,
             `activity`,
             `creater_sn`,
@@ -247,6 +248,7 @@
                 #{item.settlePrice},
                 #{item.sku,jdbcType=VARCHAR},
                 #{item.deductionScore},
+                #{item.deductionPrice},
                 #{item.orderBizType,jdbcType=VARCHAR},
                 #{item.activity},
                 #{item.createrSn,jdbcType=VARCHAR},

+ 10 - 0
kmall-admin/src/main/resources/mybatis/mapper/mk/MkActivitiesScoreDao.xml

@@ -113,6 +113,16 @@
 		where deadline &gt; #{date}
 	</select>
 
+    <select id="queryActivityInfoByMkaIdList" resultType="com.kmall.admin.entity.mk.MkActivitiesScoreEntity">
+		select
+    		*
+		from mk_activities_score
+		where mka_id in
+		<foreach collection="list" item="item" open="(" separator="," close=")">
+			#{item}
+		</foreach>
+	</select>
+
     <insert id="save" parameterType="com.kmall.admin.entity.mk.MkActivitiesScoreEntity" useGeneratedKeys="true" keyProperty="id">
 		insert into mk_activities_score(
 			`prod_barcode`,

+ 21 - 4
kmall-admin/src/main/webapp/js/sale/sale.js

@@ -1956,7 +1956,24 @@ function toPayOrder(payCode){
     addrUser = cmbProvince+cmbCity+cmbArea+addrUser;
     // console.log('单选按钮值:'+status);
     // console.log('城市三级联动的值:'+cmbProvince+'|'+cmbCity+'|'+cmbArea+'|'+addrUser);
-    console.log(vm.machineCode);
+    let scoreDeductionPrice = vm.scoreDeductionPrice;
+    if (scoreDeductionPrice == null) {
+        scoreDeductionPrice = "0";
+    } else {
+        scoreDeductionPrice = scoreDeductionPrice.toString();
+    }
+    let deductionScore = vm.deductionScore;
+    if (deductionScore == null) {
+        deductionScore = "0";
+    } else {
+        deductionScore = new BigNumber(deductionScore).toString()
+    }
+    let actualPrice = vm.actualPrice;
+    if (actualPrice == null) {
+        actualPrice = "0";
+    } else {
+        actualPrice = new BigNumber(actualPrice).toString()
+    }
     var param = {'userInfo':vm.userInfo,
                  'payCode':vm.parCode,
                  'goodsList':vm.goodsList,
@@ -1964,9 +1981,9 @@ function toPayOrder(payCode){
                  'machineCode':vm.machineCode,
                  'memberCode': vm.memberCode,
                  'memberPhone': vm.memberPhone,
-                 'deductionScore': new BigNumber(vm.deductionScore).toString(),
-                 'actualPrice': new BigNumber(vm.actualPrice).toString(),
-                 'scoreDeductionPrice': vm.scoreDeductionPrice.toString(),
+                 'deductionScore': deductionScore,
+                 'actualPrice': actualPrice,
+                 'scoreDeductionPrice': scoreDeductionPrice,
                  'scoreLimit': vm.scoreLimit,
                  'beforeScore': vm.beforeScore,
                  'afterScore': vm.afterScore,

+ 13 - 0
kmall-api/src/main/java/com/kmall/api/entity/OrderGoodsVo.java

@@ -80,6 +80,11 @@ public class OrderGoodsVo implements Serializable {
     private Integer deductionScore;
 
     /**
+     * 积分抵扣金额
+     */
+    private BigDecimal deductionPrice;
+
+    /**
      * 订单编号
      */
     private String orderSn;
@@ -431,4 +436,12 @@ public class OrderGoodsVo implements Serializable {
     public void setDefectiveProductsGrade(String defectiveProductsGrade) {
         this.defectiveProductsGrade = defectiveProductsGrade;
     }
+
+    public BigDecimal getDeductionPrice() {
+        return deductionPrice;
+    }
+
+    public void setDeductionPrice(BigDecimal deductionPrice) {
+        this.deductionPrice = deductionPrice;
+    }
 }