Преглед изворни кода

红德堂-运费模板,积分商品订单运费计算,奖励商品订单运费计算

Long пре 1 недеља
родитељ
комит
33a9bae712
26 измењених фајлова са 564 додато и 98 уклоњено
  1. 13 0
      fs-admin/src/main/java/com/fs/hisStore/controller/FsShippingTemplatesScrmController.java
  2. 3 0
      fs-service/src/main/java/com/fs/his/domain/FsIntegralGoods.java
  3. 3 0
      fs-service/src/main/java/com/fs/his/domain/FsIntegralOrder.java
  4. 5 0
      fs-service/src/main/java/com/fs/his/dto/ComputeIntegralOrderMoneyDTO.java
  5. 6 0
      fs-service/src/main/java/com/fs/his/mapper/FsCityMapper.java
  6. 7 4
      fs-service/src/main/java/com/fs/his/param/FsIntegralOrderComputeParam.java
  7. 14 0
      fs-service/src/main/java/com/fs/his/param/FsRewardOrderComputeParam.java
  8. 230 91
      fs-service/src/main/java/com/fs/his/service/impl/FsIntegralOrderServiceImpl.java
  9. 13 0
      fs-service/src/main/java/com/fs/his/vo/FsIntegralOrderPVO.java
  10. 6 0
      fs-service/src/main/java/com/fs/hisStore/mapper/FsShippingTemplatesFreeScrmMapper.java
  11. 5 0
      fs-service/src/main/java/com/fs/hisStore/mapper/FsShippingTemplatesRegionScrmMapper.java
  12. 6 0
      fs-service/src/main/java/com/fs/hisStore/mapper/FsShippingTemplatesScrmMapper.java
  13. 5 0
      fs-service/src/main/java/com/fs/hisStore/service/IFsShippingTemplatesScrmService.java
  14. 13 0
      fs-service/src/main/java/com/fs/hisStore/service/impl/FsShippingTemplatesScrmServiceImpl.java
  15. 5 0
      fs-service/src/main/java/com/fs/reward/domain/FsRewardGoods.java
  16. 5 0
      fs-service/src/main/java/com/fs/reward/domain/FsRewardGoodsOrder.java
  17. 3 0
      fs-service/src/main/java/com/fs/reward/param/FsRewardGoodsAddParam.java
  18. 6 0
      fs-service/src/main/java/com/fs/reward/service/IFsRewardGoodsOrderService.java
  19. 165 0
      fs-service/src/main/java/com/fs/reward/service/impl/FsRewardGoodsOrderServiceImpl.java
  20. 5 0
      fs-service/src/main/java/com/fs/reward/vo/FsRewardGoodsOrderVO.java
  21. 5 0
      fs-service/src/main/java/com/fs/reward/vo/FsRewardGoodsVO.java
  22. 5 1
      fs-service/src/main/resources/mapper/his/FsIntegralGoodsMapper.xml
  23. 9 0
      fs-service/src/main/resources/mapper/his/FsIntegralOrderMapper.xml
  24. 10 1
      fs-service/src/main/resources/mapper/hisStore/FsShippingTemplatesRegionScrmMapper.xml
  25. 8 1
      fs-service/src/main/resources/mapper/hisStore/FsShippingTemplatesScrmMapper.xml
  26. 9 0
      fs-user-app/src/main/java/com/fs/app/controller/RewardGoodsController.java

+ 13 - 0
fs-admin/src/main/java/com/fs/hisStore/controller/FsShippingTemplatesScrmController.java

@@ -42,6 +42,14 @@ public class FsShippingTemplatesScrmController extends BaseController
         return getDataTable(list);
     }
 
+    @GetMapping("/componentList")
+    public TableDataInfo componentList(FsShippingTemplatesScrm fsShippingTemplates) {
+        startPage();
+        fsShippingTemplates.setIsDel(0);
+        List<FsShippingTemplatesScrm> list = fsShippingTemplatesService.selectFsShippingTemplatesList(fsShippingTemplates);
+        return getDataTable(list);
+    }
+
     /**
      * 导出运费模板列表
      */
@@ -103,4 +111,9 @@ public class FsShippingTemplatesScrmController extends BaseController
         List<FsShippingTemplatesScrm> list = fsShippingTemplatesService.selectFsShippingTemplatesList(fsShippingTemplates);
         return R.ok().put("data",list);
     }
+
+    @GetMapping(value = "/getByIds")
+    public AjaxResult getByIds(@RequestParam List<Long> ids) {
+        return AjaxResult.success(fsShippingTemplatesService.selectByIds(ids));
+    }
 }

+ 3 - 0
fs-service/src/main/java/com/fs/his/domain/FsIntegralGoods.java

@@ -66,6 +66,9 @@ public class FsIntegralGoods extends BaseEntity
     @Excel(name = "产品编码")
     private String barCode;
 
+    /** 运费模板ID **/
+    private Long tempId;
+
     /**
      * 非数据库字段 仅用于订单信息存储购买数量
      */

+ 3 - 0
fs-service/src/main/java/com/fs/his/domain/FsIntegralOrder.java

@@ -79,6 +79,9 @@ public class FsIntegralOrder
     @Excel(name = "支付金额")
     private BigDecimal payMoney;
 
+    /** 运费 **/
+    private BigDecimal deliveryMoney;
+
     /** 用户优惠券 **/
     private Long userCouponId;
 

+ 5 - 0
fs-service/src/main/java/com/fs/his/dto/ComputeIntegralOrderMoneyDTO.java

@@ -36,4 +36,9 @@ public class ComputeIntegralOrderMoneyDTO {
      * 优惠金额
      */
     private BigDecimal discountCash = BigDecimal.ZERO;
+
+    /**
+     * 运费
+     */
+    private BigDecimal deliveryMoney = BigDecimal.ZERO;
 }

+ 6 - 0
fs-service/src/main/java/com/fs/his/mapper/FsCityMapper.java

@@ -4,6 +4,7 @@ import java.util.List;
 import com.fs.his.domain.FsCity;
 import com.fs.his.vo.CitysAreaVO;
 import com.github.binarywang.wxpay.bean.result.WxPayRefundV3Result;
+import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
 
 /**
@@ -73,4 +74,9 @@ public interface FsCityMapper
     @Select("SELECT city_id,city_name FROM fs_city where parent_id=0 ")
     List<CitysAreaVO> getCitysArea();
 
+    /**
+     * 根据城市名称和上级编码查询城市
+     */
+    @Select("select * from fs_city where city_name = #{cityName} and parent_id = #{parentId}")
+    FsCity selectByNameAndParentId(@Param("cityName") String cityName, @Param("parentId") String parentId);
 }

+ 7 - 4
fs-service/src/main/java/com/fs/his/param/FsIntegralOrderComputeParam.java

@@ -2,15 +2,18 @@ package com.fs.his.param;
 
 import lombok.Data;
 
-import javax.validation.constraints.NotNull;
+import java.util.List;
 
 @Data
 public class FsIntegralOrderComputeParam {
 
-    @NotNull(message = "订单ID不能为空")
-    private Long orderId;
-
     private Long userId;
 
     private Long userCouponId;
+
+    private Long  userAddressId;
+
+    private Long goodsId;
+
+    private List<Long> cartIds;
 }

+ 14 - 0
fs-service/src/main/java/com/fs/his/param/FsRewardOrderComputeParam.java

@@ -0,0 +1,14 @@
+package com.fs.his.param;
+
+import lombok.Data;
+
+
+@Data
+public class FsRewardOrderComputeParam {
+
+    private Long userId;
+
+    private Long  userAddressId;
+
+    private Long goodsId;
+}

+ 230 - 91
fs-service/src/main/java/com/fs/his/service/impl/FsIntegralOrderServiceImpl.java

@@ -23,7 +23,6 @@ import com.fs.company.mapper.CompanyUserMapper;
 import com.fs.company.service.ICompanyUserService;
 import com.fs.company.util.WechatApi;
 import com.fs.core.utils.OrderCodeUtils;
-import com.fs.course.domain.FsCourseCheckinPrize;
 import com.fs.course.domain.FsCourseCheckinReceive;
 import com.fs.course.mapper.FsCourseCheckinPrizeMapper;
 import com.fs.course.mapper.FsCourseCheckinReceiveMapper;
@@ -40,7 +39,6 @@ import com.fs.his.config.FsSysConfig;
 import com.fs.his.domain.*;
 import com.fs.his.dto.ErpRemarkDTO;
 import com.fs.his.enums.BusinessTypeEnum;
-import com.fs.his.enums.FsInquiryOrderStatusEnum;
 import com.fs.his.enums.FsUserIntegralLogTypeEnum;
 import com.fs.his.enums.PaymentMethodEnum;
 import com.fs.his.mapper.*;
@@ -52,6 +50,13 @@ import com.fs.his.vo.FsIntegralOrderListUVO;
 import com.fs.his.vo.FsIntegralOrderListVO;
 import com.fs.his.vo.FsIntegralOrderPVO;
 import com.fs.his.vo.FsStoreProductDeliverExcelVO;
+import com.fs.hisStore.domain.FsShippingTemplatesFreeScrm;
+import com.fs.hisStore.domain.FsShippingTemplatesRegionScrm;
+import com.fs.hisStore.domain.FsShippingTemplatesScrm;
+import com.fs.hisStore.enums.ShippingTempEnum;
+import com.fs.hisStore.mapper.FsShippingTemplatesFreeScrmMapper;
+import com.fs.hisStore.mapper.FsShippingTemplatesRegionScrmMapper;
+import com.fs.hisStore.mapper.FsShippingTemplatesScrmMapper;
 import com.fs.huifuPay.domain.HuiFuRefundResult;
 import com.fs.huifuPay.sdk.opps.core.request.V2TradePaymentScanpayRefundRequest;
 import com.fs.huifuPay.service.HuiFuService;
@@ -62,8 +67,6 @@ import com.fs.ybPay.domain.OrderResult;
 import com.fs.ybPay.dto.OrderQueryDTO;
 import com.fs.ybPay.service.IPayService;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.collections.CollectionUtils;
-import org.redisson.api.RObjectAsync;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.BeanUtils;
@@ -77,6 +80,7 @@ import org.springframework.transaction.interceptor.TransactionAspectSupport;
 
 import javax.annotation.PostConstruct;
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.sql.Timestamp;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
@@ -84,6 +88,7 @@ import java.time.LocalDateTime;
 import java.time.ZoneId;
 import java.util.*;
 import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
 
 import static com.fs.his.utils.PhoneUtil.decryptPhone;
 
@@ -188,6 +193,14 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService {
     private FsUserCouponMapper fsUserCouponMapper;
     @Autowired
     private FsCouponMapper fsCouponMapper;
+    @Autowired
+    private FsCityMapper fsCityMapper;
+    @Autowired
+    private FsShippingTemplatesScrmMapper fsShippingTemplatesScrmMapper;
+    @Autowired
+    private FsShippingTemplatesFreeScrmMapper fsShippingTemplatesFreeScrmMapper;
+    @Autowired
+    private FsShippingTemplatesRegionScrmMapper fsShippingTemplatesRegionScrmMapper;
 
     //ERP 类型到服务的映射
     private Map<Integer, IErpOrderService> erpServiceMap;
@@ -332,38 +345,7 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService {
 
         // 计算优惠券
         if (param.getUserCouponId() != null) {
-
-            // 查询用户优惠券,判断是否有效,是否未使用
-            FsUserCoupon fsUserCoupon = fsUserCouponMapper.selectFsUserCouponById(param.getUserCouponId());
-            if (fsUserCoupon == null || !Objects.equals(fsUserCoupon.getUserId(), param.getUserId())) {
-                return R.error("无效的优惠券");
-            }
-            if (fsUserCoupon.getBusinessType() != 4) {
-                return  R.error("优惠券类型不匹配,无法使用");
-            }
-
-            if (fsUserCoupon.getStatus() == 1) {
-                return R.error("优惠券已使用");
-            }
-
-            if (fsUserCoupon.getStatus() == 2 || fsUserCoupon.getLimitTime().before(new Date())) {
-                return  R.error("优惠券已过期");
-            }
-
-            // 查看优惠券具体类型
-            FsCoupon fsCoupon = fsCouponMapper.selectFsCouponByCouponId(fsUserCoupon.getCouponId());
-            if (fsCoupon == null) {
-                return R.error("无效的优惠券");
-            }
-
-            if (fsCoupon.getCouponType() != 7) {
-                return R.error("无效的优惠券");
-            }
-
-            moneyDTO.setDiscountIntegral(moneyDTO.getIntegral());
-            moneyDTO.setIntegral(BigDecimal.ZERO);
-            moneyDTO.setDiscountCash(moneyDTO.getCash());
-            moneyDTO.setCash(BigDecimal.ZERO);
+            applyCoupon(param.getUserCouponId(), user.getUserId(), integralGoods, moneyDTO);
         }
 
         if (moneyDTO.getIntegral().intValue() > 0 && user.getIntegral() < moneyDTO.getIntegral().intValue()) {
@@ -383,6 +365,43 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService {
         return createOrder(user, address, moneyDTO, goodsItem, param.getCompanyUserId(), param.getUserCouponId());
     }
 
+    /**
+     * 计算优惠
+     */
+    private void applyCoupon(Long userCouponId, Long userId, FsIntegralGoods integralGoods, ComputeIntegralOrderMoneyDTO moneyDTO) {
+        // 查询用户优惠券,判断是否有效,是否未使用
+        FsUserCoupon fsUserCoupon = fsUserCouponMapper.selectFsUserCouponById(userCouponId);
+        if (fsUserCoupon == null || !Objects.equals(fsUserCoupon.getUserId(), userId)) {
+            throw new CustomException("无效的优惠券");
+        }
+        if (fsUserCoupon.getBusinessType() != 4) {
+            throw new CustomException("优惠券类型不匹配,无法使用");
+        }
+
+        if (fsUserCoupon.getStatus() == 1) {
+            throw new CustomException("优惠券已使用");
+        }
+
+        if (fsUserCoupon.getStatus() == 2 || fsUserCoupon.getLimitTime().before(new Date())) {
+            throw new CustomException("优惠券已过期");
+        }
+
+        // 查看优惠券具体类型
+        FsCoupon fsCoupon = fsCouponMapper.selectFsCouponByCouponId(fsUserCoupon.getCouponId());
+        if (fsCoupon == null) {
+            throw new CustomException("无效的优惠券");
+        }
+
+        if (fsCoupon.getCouponType() != 7 || !fsCoupon.getFreeGoodsId().equals(integralGoods.getGoodsId())) {
+            throw new CustomException("无效的优惠券");
+        }
+
+        moneyDTO.setDiscountIntegral(moneyDTO.getIntegral());
+        moneyDTO.setIntegral(BigDecimal.ZERO);
+        moneyDTO.setDiscountCash(moneyDTO.getCash());
+        moneyDTO.setCash(BigDecimal.ZERO);
+    }
+
     /**
      * 创建订单
      */
@@ -398,6 +417,9 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService {
             throw new CustomException("订单生成失败,请重试");
         }
 
+        // 运费计算
+        calcDeliveryMoney(moneyDTO, address, goodsItem);
+
         // 现金
         if (moneyDTO.getCash().compareTo(BigDecimal.ZERO) > 0) {
             // 现金+积分
@@ -423,6 +445,7 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService {
         order.setTotalMoney(moneyDTO.getTotalCash());
         order.setPayMoney(moneyDTO.getCash());
         order.setDiscountMoney(moneyDTO.getDiscountCash());
+        order.setDeliveryMoney(moneyDTO.getDeliveryMoney());
         order.setUserCouponId(userCouponId);
         order.setItemJson(JSONUtil.toJsonStr(goodsItem));
         order.setUserName(address.getRealName());
@@ -510,6 +533,118 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService {
         }
     }
 
+    /**
+     * 计算运费
+     */
+    private void calcDeliveryMoney(ComputeIntegralOrderMoneyDTO moneyDTO, FsUserAddress address, List<FsIntegralGoods> goodsItem) {
+        // 解析省市信息
+        FsCity province = fsCityMapper.selectByNameAndParentId(address.getProvince(), "0");
+        if (province == null) return;
+
+        FsCity city = fsCityMapper.selectByNameAndParentId(address.getCity(), province.getCityId());
+        if (city == null) return;
+
+        // 按运费模板分组(过滤无模板商品)
+        Map<Long, List<FsIntegralGoods>> templateGroupMap = goodsItem.stream()
+                .filter(goods -> goods.getTempId() != null)
+                .collect(Collectors.groupingBy(FsIntegralGoods::getTempId));
+
+        BigDecimal totalDeliveryMoney = BigDecimal.ZERO;
+
+        for (Map.Entry<Long, List<FsIntegralGoods>> entry : templateGroupMap.entrySet()) {
+            BigDecimal fee = calcTemplateFee(entry.getKey(), entry.getValue(), province, city);
+            totalDeliveryMoney = totalDeliveryMoney.add(fee);
+        }
+
+        // 更新 DTO
+        moneyDTO.setDeliveryMoney(totalDeliveryMoney);
+        moneyDTO.setCash(moneyDTO.getCash().add(totalDeliveryMoney));
+        moneyDTO.setTotalCash(moneyDTO.getTotalCash().add(totalDeliveryMoney));
+    }
+
+    /**
+     * 计算单个运费模板的运费
+     */
+    private BigDecimal calcTemplateFee(Long tempId, List<FsIntegralGoods> goodsList, FsCity province, FsCity city) {
+        FsShippingTemplatesScrm template = fsShippingTemplatesScrmMapper.selectFsShippingTemplatesById(tempId);
+
+        // 仅处理按件计费模板
+        if (template == null || !ShippingTempEnum.TYPE_1.getValue().equals(template.getType())) {
+            return BigDecimal.ZERO;
+        }
+
+        // 汇总商品总件数与总金额
+        int totalNum = 0;
+        BigDecimal totalPrice = BigDecimal.ZERO;
+        for (FsIntegralGoods goods : goodsList) {
+            int num = goods.getNum() != null ? goods.getNum() : 0;
+            if (num <= 0) continue;
+            totalNum += num;
+            if (goods.getCash() != null) {
+                totalPrice = totalPrice.add(goods.getCash().multiply(BigDecimal.valueOf(num)));
+            }
+        }
+
+        if (totalNum <= 0) return BigDecimal.ZERO;
+
+        // 检查指定包邮
+        if (isFreeShipping(template, province, city, totalNum, totalPrice)) {
+            return BigDecimal.ZERO;
+        }
+
+        // 查询运费区域配置(优先精确匹配,降级全国)
+        FsShippingTemplatesRegionScrm region = fsShippingTemplatesRegionScrmMapper.selectByTempIdAndProvinceIdAndCityId(template.getId(), province.getCityId(), city.getCityId());
+        if (region == null) {
+            region = fsShippingTemplatesRegionScrmMapper.selectByTempIdAndProvinceIdAndCityId(template.getId(), "0", null);
+        }
+
+        return region != null ? calcShippingFee(region, totalNum) : BigDecimal.ZERO;
+    }
+
+    /**
+     * 判断是否满足包邮条件
+     */
+    private boolean isFreeShipping(FsShippingTemplatesScrm template, FsCity province, FsCity city, int totalNum, BigDecimal totalPrice) {
+        if (template.getAppoint() == null || template.getAppoint() != 1) {
+            return false;
+        }
+
+        FsShippingTemplatesFreeScrm freeRule = fsShippingTemplatesFreeScrmMapper
+                .selectByTempIdAndProvinceIdAndCityId(template.getId(), province.getCityId(), city.getCityId());
+        if (freeRule == null) return false;
+
+        // 件数满足包邮(0 表示不限件数)
+        boolean freeByNum = freeRule.getNumber() == null
+                || freeRule.getNumber().intValue() == 0
+                || totalNum >= freeRule.getNumber().intValue();
+
+        // 金额满足包邮(0 表示不限金额)
+        boolean freeByPrice = freeRule.getPrice() != null
+                && freeRule.getPrice().compareTo(BigDecimal.ZERO) > 0
+                && totalPrice.compareTo(freeRule.getPrice()) >= 0;
+
+        return freeByNum || freeByPrice;  // 满足任一条件即可包邮
+    }
+
+    /**
+     * 根据区域配置计算运费(按件计费)
+     */
+    private BigDecimal calcShippingFee(FsShippingTemplatesRegionScrm region, int totalNum) {
+        BigDecimal firstCount = region.getFirst();
+        BigDecimal firstPrice = region.getFirstPrice();
+        BigDecimal continueCount = region.getContinues();
+        BigDecimal continuePrice = region.getContinuePrice();
+
+        if (totalNum <= firstCount.intValue() || continueCount.compareTo(BigDecimal.ZERO) == 0) {
+            return firstPrice;
+        }
+
+        // 超出首件部分,向上取整计算续件费用
+        BigDecimal extra = BigDecimal.valueOf(totalNum).subtract(firstCount);
+        BigDecimal continueUnits = extra.divide(continueCount, 0, RoundingMode.CEILING);
+        return firstPrice.add(continueUnits.multiply(continuePrice));
+    }
+
     /**
      * 创建购物车订单
      *
@@ -1393,79 +1528,83 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService {
      */
     @Override
     public R computeOrder(FsIntegralOrderComputeParam param) {
-
-        // 查询积分订单,判断订单是否存在,状态是否未支付
-        FsIntegralOrder order = fsIntegralOrderMapper.selectFsIntegralOrderByOrderId(param.getOrderId());
-        if (order == null) {
-            return R.error("订单不存在!");
-        }
-
-        if (order.getIsPay() != 0 || order.getStatus() != 4) {
-            return R.error("订单状态不正确");
-        }
-
         // 查询用户,判断用户是否存在
         FsUser fsUser = fsUserMapper.selectFsUserById(param.getUserId());
         if (fsUser == null || fsUser.getIsDel() == 1) {
             return R.error("用户不存在");
         }
 
-        // 返回扣减后的支付金额
-        return R.ok().put("data", computeOrderMoney(param.getUserId(), new BigDecimal(order.getTotalIntegral()), order.getTotalMoney(), param.getUserCouponId(), order.getItemJson()));
-    }
+        if (param.getGoodsId() == null && (param.getCartIds() == null || param.getCartIds().isEmpty())) {
+            return R.error("商品不能为空");
+        }
 
-    /**
-     * 计算优惠后的价格
-     */
-    private ComputeIntegralOrderMoneyDTO computeOrderMoney(Long userId, BigDecimal orderIntegral, BigDecimal orderMoney, Long userCouponId, String goodsJson) {
         ComputeIntegralOrderMoneyDTO moneyDTO = new ComputeIntegralOrderMoneyDTO();
-        moneyDTO.setIntegral(orderIntegral);
-        moneyDTO.setCash(orderMoney);
+        List<FsIntegralGoods> goodsItem = new ArrayList<>();
 
-        // 不使用优惠券
-        if (null == userCouponId) {
-            return moneyDTO;
-        }
+        // 判断是购物车还是单商品
+        if (param.getGoodsId() != null) {
+            FsIntegralGoods fsIntegralGoods = fsIntegralGoodsMapper.selectFsIntegralGoodsByGoodsId(param.getGoodsId());
+            if (fsIntegralGoods == null) {
+                return R.error("积分商品不存在");
+            }
 
-        // 查询用户优惠券,判断是否有效,是否未使用
-        FsUserCoupon fsUserCoupon = fsUserCouponMapper.selectFsUserCouponById(userCouponId);
-        if (fsUserCoupon == null || !Objects.equals(fsUserCoupon.getUserId(), userId)) {
-            return moneyDTO;
-        }
+            if (fsIntegralGoods.getStatus() == 0) {
+                return R.error("积分商品已下架");
+            }
 
-        if (fsUserCoupon.getBusinessType() != 4) {
-            return moneyDTO;
-        }
+            fsIntegralGoods.setNum(1);
+            goodsItem.add(fsIntegralGoods);
 
-        if (fsUserCoupon.getStatus() == 1) {
-            return moneyDTO;
-        }
+            moneyDTO.setTotalCash(fsIntegralGoods.getCash());
+            moneyDTO.setCash(fsIntegralGoods.getCash());
+            moneyDTO.setTotalIntegral(new BigDecimal(fsIntegralGoods.getIntegral()));
+            moneyDTO.setIntegral(new BigDecimal(fsIntegralGoods.getIntegral()));
 
-        if (fsUserCoupon.getStatus() == 2 || fsUserCoupon.getLimitTime().before(new Date())) {
-            return moneyDTO;
-        }
+            // 优惠金额计算
+            if (param.getUserCouponId() != null) {
+                applyCoupon(param.getUserCouponId(), fsUser.getUserId(), fsIntegralGoods, moneyDTO);
+            }
+        } else {
+            Wrapper<FsIntegralCart> wrapper = Wrappers.<FsIntegralCart>lambdaQuery().eq(FsIntegralCart::getUserId, fsUser.getUserId())
+                    .in(FsIntegralCart::getId, param.getCartIds());
+            List<FsIntegralCart> carts = cartService.list(wrapper);
+            if (carts.isEmpty()) {
+                return R.error("购物车商品不存在");
+            }
 
-        // 查看优惠券具体类型
-        FsCoupon fsCoupon = fsCouponMapper.selectFsCouponByCouponId(fsUserCoupon.getCouponId());
-        if (fsCoupon == null) {
-            return moneyDTO;
+            for (FsIntegralCart cart : carts) {
+                FsIntegralGoods integralGoods = fsIntegralGoodsMapper.selectFsIntegralGoodsByGoodsId(cart.getGoodsId());
+                if (Objects.isNull(integralGoods)) {
+                    throw new CustomException("商品不存在");
+                }
+
+                // 计算所需积分和现金
+                BigDecimal totalIntegral = new BigDecimal(integralGoods.getIntegral()).multiply(new BigDecimal(cart.getCartNum()));
+                BigDecimal totalCash = integralGoods.getCash().multiply(new BigDecimal(cart.getCartNum()));
+
+                moneyDTO.setTotalIntegral(moneyDTO.getTotalIntegral().add(totalIntegral));
+                moneyDTO.setTotalCash(moneyDTO.getTotalCash().add(totalCash));
+
+                integralGoods.setNum(cart.getCartNum());
+                goodsItem.add(integralGoods);
+            }
+
+            moneyDTO.setIntegral(moneyDTO.getTotalIntegral());
+            moneyDTO.setCash(moneyDTO.getTotalCash());
         }
 
-        // 积分商品免单券
-        if (fsCoupon.getCouponType() == 7) {
-            // 查找指定减免积分商品并减免价格
-            List<FsIntegralGoods> goodsItem = JSONUtil.toBean(goodsJson, new TypeReference<List<FsIntegralGoods>>(){}, true);
-            goodsItem.stream().filter(g -> g.getGoodsId().equals(fsCoupon.getFreeGoodsId())).findFirst().ifPresent(g -> {
-                BigDecimal integral = orderIntegral.subtract(new BigDecimal(g.getIntegral()));
-                BigDecimal cash = orderMoney.subtract(g.getCash());
-                moneyDTO.setIntegral(integral);
-                moneyDTO.setDiscountIntegral(new BigDecimal(g.getIntegral()));
-                moneyDTO.setCash(cash);
-                moneyDTO.setDiscountCash(g.getCash());
-            });
+        // 运费计算
+        if (param.getUserAddressId() != null) {
+            FsUserAddress fsUserAddress = fsUserAddressMapper.selectFsUserAddressByAddressId(param.getUserAddressId());
+            if (fsUserAddress == null || fsUserAddress.getIsDel() == 1 || fsUserAddress.getIsConfirm() == 0
+                    || !fsUser.getUserId().equals(fsUserAddress.getUserId())) {
+                return R.error("收货地址不存在");
+            }
+            calcDeliveryMoney(moneyDTO, fsUserAddress, goodsItem);
         }
 
-        return moneyDTO;
+        // 返回扣减后的支付金额
+        return R.ok().put("data", moneyDTO);
     }
 
 }

+ 13 - 0
fs-service/src/main/java/com/fs/his/vo/FsIntegralOrderPVO.java

@@ -5,6 +5,7 @@ import com.fs.common.annotation.Excel;
 import com.fs.common.core.domain.BaseEntity;
 import lombok.Data;
 
+import java.math.BigDecimal;
 import java.util.Date;
 
 /**
@@ -76,4 +77,16 @@ public class FsIntegralOrderPVO extends BaseEntity
     private String phone;
 
     private String loginAccount;
+
+    /** 支付金额 **/
+    private BigDecimal payMoney;
+
+    /** 优惠金额 **/
+    private BigDecimal discountMoney;
+
+    /** 优惠积分 **/
+    private String discountIntegral;
+
+    /** 运费 **/
+    private BigDecimal deliveryMoney;
 }

+ 6 - 0
fs-service/src/main/java/com/fs/hisStore/mapper/FsShippingTemplatesFreeScrmMapper.java

@@ -86,4 +86,10 @@ public interface FsShippingTemplatesFreeScrmMapper
             "</if>" +
             "</script>"})
     int selectCountByTemplateDTO(@Param("maps") TemplateDTO mapValue);
+
+    /**
+     * 查询模板免邮配置
+     */
+    @Select("select * from fs_shipping_templates_free where temp_id = #{tempId} and province_id = #{provinceId} and city_id = #{cityId} limit 1")
+    FsShippingTemplatesFreeScrm selectByTempIdAndProvinceIdAndCityId(@Param("tempId") Long tempId, @Param("provinceId") String provinceId, @Param("cityId") String cityId);
 }

+ 5 - 0
fs-service/src/main/java/com/fs/hisStore/mapper/FsShippingTemplatesRegionScrmMapper.java

@@ -66,4 +66,9 @@ public interface FsShippingTemplatesRegionScrmMapper
     int deleteFsShippingTemplatesRegionByTempId(Long tempId);
     @Select("select * from fs_shipping_templates_region where find_in_set(temp_id,#{tempIds}) and find_in_set(city_id,#{cityIds})")
     List<FsShippingTemplatesRegionScrm> selectFsShippingTemplatesRegionListByTempIdsAndCityIds(@Param("tempIds") String tempIds, @Param("cityIds") String cityIds);
+
+    /**
+     * 查询模板运费配置
+     */
+    FsShippingTemplatesRegionScrm selectByTempIdAndProvinceIdAndCityId(@Param("tempId") Long tempId, @Param("provinceId") String provinceId, @Param("cityId") String cityId);
 }

+ 6 - 0
fs-service/src/main/java/com/fs/hisStore/mapper/FsShippingTemplatesScrmMapper.java

@@ -2,6 +2,7 @@ package com.fs.hisStore.mapper;
 
 import java.util.List;
 import com.fs.hisStore.domain.FsShippingTemplatesScrm;
+import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
 
 /**
@@ -61,4 +62,9 @@ public interface FsShippingTemplatesScrmMapper
     public int deleteFsShippingTemplatesByIds(Long[] id);
     @Select("select * from fs_shipping_templates where find_in_set(id,#{ids})")
     List<FsShippingTemplatesScrm> selectFsShippingTemplatesByIds(String ids);
+
+    /**
+     * 根据id集合查询模板列表
+     */
+    List<FsShippingTemplatesScrm> selectByIds(@Param("ids") List<Long> ids);
 }

+ 5 - 0
fs-service/src/main/java/com/fs/hisStore/service/IFsShippingTemplatesScrmService.java

@@ -65,4 +65,9 @@ public interface IFsShippingTemplatesScrmService
     R addOrEdit(FsShippingTemplatesAddEditParam fsShippingTemplates);
 
     List<FsShippingTemplatesScrm> selectFsShippingTemplatesByIds(String ids);
+
+    /**
+     * 根据id集合查询模板列表
+     */
+    List<FsShippingTemplatesScrm> selectByIds(List<Long> ids);
 }

+ 13 - 0
fs-service/src/main/java/com/fs/hisStore/service/impl/FsShippingTemplatesScrmServiceImpl.java

@@ -1,7 +1,9 @@
 package com.fs.hisStore.service.impl;
 
 import java.math.BigDecimal;
+import java.util.ArrayList;
 import java.util.List;
+import java.util.Objects;
 
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.util.IdUtil;
@@ -224,4 +226,15 @@ public class FsShippingTemplatesScrmServiceImpl implements IFsShippingTemplatesS
             }
         }
     }
+
+    /**
+     * 根据id集合查询模板列表
+     */
+    @Override
+    public List<FsShippingTemplatesScrm> selectByIds(List<Long> ids) {
+        if (Objects.isNull(ids) || ids.isEmpty()) {
+            return new ArrayList<>();
+        }
+        return fsShippingTemplatesMapper.selectByIds(ids);
+    }
 }

+ 5 - 0
fs-service/src/main/java/com/fs/reward/domain/FsRewardGoods.java

@@ -107,4 +107,9 @@ public class FsRewardGoods {
      * 修改人
      */
     private String updateBy;
+
+    /**
+     * 运费模板
+     */
+    private Long tempId;
 }

+ 5 - 0
fs-service/src/main/java/com/fs/reward/domain/FsRewardGoodsOrder.java

@@ -63,6 +63,11 @@ public class FsRewardGoodsOrder {
      */
     private BigDecimal payMoney;
 
+    /**
+     * 运费
+     */
+    private BigDecimal deliveryMoney;
+
     /**
      * 支付类型
      */

+ 3 - 0
fs-service/src/main/java/com/fs/reward/param/FsRewardGoodsAddParam.java

@@ -65,4 +65,7 @@ public class FsRewardGoodsAddParam {
 
     @ApiModelProperty("创建人")
     private String createBy;
+
+    @ApiModelProperty("运费模板")
+    private Long tempId;
 }

+ 6 - 0
fs-service/src/main/java/com/fs/reward/service/IFsRewardGoodsOrderService.java

@@ -3,6 +3,7 @@ package com.fs.reward.service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.fs.common.core.domain.R;
 import com.fs.his.domain.FsStorePayment;
+import com.fs.his.param.FsRewardOrderComputeParam;
 import com.fs.reward.domain.FsRewardGoodsOrder;
 import com.fs.reward.param.FsAppRewardGoodsOrderAddParam;
 import com.fs.reward.param.FsRewardGoodsOrderAddParam;
@@ -64,4 +65,9 @@ public interface IFsRewardGoodsOrderService extends IService<FsRewardGoodsOrder>
      * 取消订单
      */
     int cancelOrder(Long orderId);
+
+    /**
+     * 计算订单金额
+     */
+    R computeOrder(FsRewardOrderComputeParam param);
 }

+ 165 - 0
fs-service/src/main/java/com/fs/reward/service/impl/FsRewardGoodsOrderServiceImpl.java

@@ -18,17 +18,27 @@ import com.fs.erp.dto.ErpOrderQueryResponse;
 import com.fs.erp.dto.ErpRefundUpdateRequest;
 import com.fs.erp.service.IErpOrderService;
 import com.fs.his.domain.*;
+import com.fs.his.dto.ComputeIntegralOrderMoneyDTO;
 import com.fs.his.dto.ErpRemarkDTO;
 import com.fs.his.enums.BusinessTypeEnum;
 import com.fs.his.enums.PaymentMethodEnum;
 import com.fs.his.enums.ShipperCodeEnum;
+import com.fs.his.mapper.FsCityMapper;
 import com.fs.his.mapper.FsStoreMapper;
 import com.fs.his.mapper.FsUserAddressMapper;
 import com.fs.his.mapper.FsUserMapper;
+import com.fs.his.param.FsRewardOrderComputeParam;
 import com.fs.his.param.PayOrderParam;
 import com.fs.his.service.IFsExpressService;
 import com.fs.his.service.IFsStorePaymentService;
 import com.fs.his.service.IFsUserAddressService;
+import com.fs.hisStore.domain.FsShippingTemplatesFreeScrm;
+import com.fs.hisStore.domain.FsShippingTemplatesRegionScrm;
+import com.fs.hisStore.domain.FsShippingTemplatesScrm;
+import com.fs.hisStore.enums.ShippingTempEnum;
+import com.fs.hisStore.mapper.FsShippingTemplatesFreeScrmMapper;
+import com.fs.hisStore.mapper.FsShippingTemplatesRegionScrmMapper;
+import com.fs.hisStore.mapper.FsShippingTemplatesScrmMapper;
 import com.fs.huifuPay.domain.HuiFuRefundResult;
 import com.fs.huifuPay.sdk.opps.core.request.V2TradePaymentScanpayRefundRequest;
 import com.fs.huifuPay.service.HuiFuService;
@@ -62,6 +72,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.sql.Timestamp;
 import java.text.SimpleDateFormat;
 import java.time.LocalDateTime;
@@ -104,6 +115,14 @@ public class FsRewardGoodsOrderServiceImpl extends ServiceImpl<FsRewardGoodsOrde
     private FsWxExpressTaskMapper fsWxExpressTaskMapper;
     @Autowired
     private FsStoreMapper storeMapper;
+    @Autowired
+    private FsCityMapper fsCityMapper;
+    @Autowired
+    private FsShippingTemplatesScrmMapper fsShippingTemplatesScrmMapper;
+    @Autowired
+    private FsShippingTemplatesFreeScrmMapper fsShippingTemplatesFreeScrmMapper;
+    @Autowired
+    private FsShippingTemplatesRegionScrmMapper fsShippingTemplatesRegionScrmMapper;
 
     /**
      * 查询奖励商品订单列表
@@ -155,6 +174,17 @@ public class FsRewardGoodsOrderServiceImpl extends ServiceImpl<FsRewardGoodsOrde
             throw new CustomException("收货地址不存在!");
         }
 
+        // 计算运费
+        FsRewardGoods fsRewardGoods = fsRewardGoodsMapper.selectById(order.getGoodsId());
+        ComputeIntegralOrderMoneyDTO moneyDTO = new ComputeIntegralOrderMoneyDTO();
+        moneyDTO.setCash(order.getPayMoney());
+        moneyDTO.setTotalCash(order.getOrderMoney());
+        calcDeliveryMoney(moneyDTO, fsUserAddress, fsRewardGoods);
+
+        order.setDeliveryMoney(moneyDTO.getDeliveryMoney());
+        order.setPayMoney(moneyDTO.getCash());
+        order.setOrderMoney(moneyDTO.getTotalCash());
+
         order.setUserName(fsUserAddress.getRealName().trim());
         order.setMobile(fsUserAddress.getPhone().trim());
         order.setAddress(fsUserAddress.getProvince() + " " + fsUserAddress.getCity() + " " + fsUserAddress.getDistrict() + " " + fsUserAddress.getDetail());
@@ -741,4 +771,139 @@ public class FsRewardGoodsOrderServiceImpl extends ServiceImpl<FsRewardGoodsOrde
         paymentMap.setRefundMoney(payment.getPayMoney());
         storePaymentService.updateFsStorePayment(paymentMap);
     }
+
+    /**
+     * 计算订单金额
+     */
+    @Override
+    public R computeOrder(FsRewardOrderComputeParam param) {
+        // 查询用户,判断用户是否存在
+        FsUser fsUser = fsUserMapper.selectFsUserById(param.getUserId());
+        if (fsUser == null || fsUser.getIsDel() == 1) {
+            return R.error("用户不存在");
+        }
+
+        if (param.getGoodsId() == null) {
+            return R.error("商品不能为空");
+        }
+
+        FsRewardGoods fsRewardGoods = fsRewardGoodsMapper.selectById(param.getGoodsId());
+        if (fsRewardGoods == null || fsRewardGoods.getIsDel() == 1) {
+            return R.error("商品不存在");
+        }
+
+        if (fsRewardGoods.getStatus() == 0) {
+            return R.error("商品已下架");
+        }
+
+        ComputeIntegralOrderMoneyDTO moneyDTO = new ComputeIntegralOrderMoneyDTO();
+        moneyDTO.setCash(fsRewardGoods.getPrice());
+        moneyDTO.setTotalCash(fsRewardGoods.getPrice());
+
+        FsUserAddress fsUserAddress = fsUserAddressService.selectFsUserAddressByAddressId(param.getUserAddressId());
+        if (fsUserAddress == null || fsUserAddress.getIsDel() == 1 || fsUserAddress.getIsConfirm() == 0
+                || !fsUser.getUserId().equals(fsUserAddress.getUserId())) {
+            return R.error("收货地址不存在");
+        }
+
+        // 计算运费
+        calcDeliveryMoney(moneyDTO, fsUserAddress, fsRewardGoods);
+
+        return R.ok().put("data", moneyDTO);
+    }
+
+    /**
+     * 计算运费
+     */
+    private void calcDeliveryMoney(ComputeIntegralOrderMoneyDTO moneyDTO, FsUserAddress address, FsRewardGoods fsRewardGoods) {
+        // 解析省市信息
+        FsCity province = fsCityMapper.selectByNameAndParentId(address.getProvince(), "0");
+        if (province == null) return;
+
+        FsCity city = fsCityMapper.selectByNameAndParentId(address.getCity(), province.getCityId());
+        if (city == null) return;
+
+        BigDecimal totalDeliveryMoney = BigDecimal.ZERO;
+        if (fsRewardGoods.getTempId() != null) {
+            totalDeliveryMoney = calcTemplateFee(fsRewardGoods, province, city);
+        }
+
+        // 更新 DTO
+        moneyDTO.setDeliveryMoney(totalDeliveryMoney);
+        moneyDTO.setCash(moneyDTO.getCash().add(totalDeliveryMoney));
+        moneyDTO.setTotalCash(moneyDTO.getTotalCash().add(totalDeliveryMoney));
+    }
+
+    /**
+     * 计算单个运费模板的运费
+     */
+    private BigDecimal calcTemplateFee(FsRewardGoods rewardGoods, FsCity province, FsCity city) {
+        FsShippingTemplatesScrm template = fsShippingTemplatesScrmMapper.selectFsShippingTemplatesById(rewardGoods.getTempId());
+
+        // 仅处理按件计费模板
+        if (template == null || !ShippingTempEnum.TYPE_1.getValue().equals(template.getType())) {
+            return BigDecimal.ZERO;
+        }
+
+        // 汇总商品总件数与总金额
+        int totalNum = 1;
+        BigDecimal totalPrice = rewardGoods.getPrice();
+
+        // 检查指定包邮
+        if (isFreeShipping(template, province, city, totalNum, totalPrice)) {
+            return BigDecimal.ZERO;
+        }
+
+        // 查询运费区域配置(优先精确匹配,降级全国)
+        FsShippingTemplatesRegionScrm region = fsShippingTemplatesRegionScrmMapper.selectByTempIdAndProvinceIdAndCityId(template.getId(), province.getCityId(), city.getCityId());
+        if (region == null) {
+            region = fsShippingTemplatesRegionScrmMapper.selectByTempIdAndProvinceIdAndCityId(template.getId(), "0", null);
+        }
+
+        return region != null ? calcShippingFee(region, totalNum) : BigDecimal.ZERO;
+    }
+
+    /**
+     * 判断是否满足包邮条件
+     */
+    private boolean isFreeShipping(FsShippingTemplatesScrm template, FsCity province, FsCity city, int totalNum, BigDecimal totalPrice) {
+        if (template.getAppoint() == null || template.getAppoint() != 1) {
+            return false;
+        }
+
+        FsShippingTemplatesFreeScrm freeRule = fsShippingTemplatesFreeScrmMapper
+                .selectByTempIdAndProvinceIdAndCityId(template.getId(), province.getCityId(), city.getCityId());
+        if (freeRule == null) return false;
+
+        // 件数满足包邮(0 表示不限件数)
+        boolean freeByNum = freeRule.getNumber() == null
+                || freeRule.getNumber().intValue() == 0
+                || totalNum >= freeRule.getNumber().intValue();
+
+        // 金额满足包邮(0 表示不限金额)
+        boolean freeByPrice = freeRule.getPrice() != null
+                && freeRule.getPrice().compareTo(BigDecimal.ZERO) > 0
+                && totalPrice.compareTo(freeRule.getPrice()) >= 0;
+
+        return freeByNum || freeByPrice;  // 满足任一条件即可包邮
+    }
+
+    /**
+     * 根据区域配置计算运费(按件计费)
+     */
+    private BigDecimal calcShippingFee(FsShippingTemplatesRegionScrm region, int totalNum) {
+        BigDecimal firstCount = region.getFirst();
+        BigDecimal firstPrice = region.getFirstPrice();
+        BigDecimal continueCount = region.getContinues();
+        BigDecimal continuePrice = region.getContinuePrice();
+
+        if (totalNum <= firstCount.intValue() || continueCount.compareTo(BigDecimal.ZERO) == 0) {
+            return firstPrice;
+        }
+
+        // 超出首件部分,向上取整计算续件费用
+        BigDecimal extra = BigDecimal.valueOf(totalNum).subtract(firstCount);
+        BigDecimal continueUnits = extra.divide(continueCount, 0, RoundingMode.CEILING);
+        return firstPrice.add(continueUnits.multiply(continuePrice));
+    }
 }

+ 5 - 0
fs-service/src/main/java/com/fs/reward/vo/FsRewardGoodsOrderVO.java

@@ -69,6 +69,11 @@ public class FsRewardGoodsOrderVO {
      */
     private BigDecimal payMoney;
 
+    /**
+     * 运费
+     */
+    private BigDecimal deliveryMoney;
+
     /**
      * 支付类型
      */

+ 5 - 0
fs-service/src/main/java/com/fs/reward/vo/FsRewardGoodsVO.java

@@ -110,4 +110,9 @@ public class FsRewardGoodsVO {
      * 修改人
      */
     private String updateBy;
+
+    /**
+     * 运费模板
+     */
+    private Long tempId;
 }

+ 5 - 1
fs-service/src/main/resources/mapper/his/FsIntegralGoodsMapper.xml

@@ -19,10 +19,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="descs"    column="descs"    />
         <result property="createTime"    column="create_time"    />
         <result property="barCode"    column="bar_code"    />
+        <result property="tempId"    column="temp_id"    />
     </resultMap>
 
     <sql id="selectFsIntegralGoodsVo">
-        select goods_id, img_url, images,bar_code, goods_name, ot_price, goods_type, status, integral, cash, sort, stock, descs, create_time from fs_integral_goods
+        select * from fs_integral_goods
     </sql>
 
     <select id="selectFsIntegralGoodsList" parameterType="FsIntegralGoods" resultMap="FsIntegralGoodsResult">
@@ -59,6 +60,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="descs != null">descs,</if>
             <if test="createTime != null">create_time,</if>
             <if test="barCode != null">bar_code,</if>
+            <if test="tempId != null">temp_id,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="goodsId != null">#{goodsId},</if>
@@ -75,6 +77,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="descs != null">#{descs},</if>
             <if test="createTime != null">#{createTime},</if>
             <if test="barCode != null">#{barCode},</if>
+            <if test="tempId != null">#{tempId},</if>
          </trim>
     </insert>
 
@@ -94,6 +97,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="descs != null">descs = #{descs},</if>
             <if test="createTime != null">create_time = #{createTime},</if>
             <if test="barCode != null">bar_code = #{barCode},</if>
+            <if test="tempId != null">temp_id = #{tempId},</if>
         </trim>
         where goods_id = #{goodsId}
     </update>

+ 9 - 0
fs-service/src/main/resources/mapper/his/FsIntegralOrderMapper.xml

@@ -18,6 +18,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="totalMoney"    column="total_money"    />
         <result property="discountMoney"    column="discount_money"    />
         <result property="payMoney"    column="pay_money"    />
+        <result property="deliveryMoney"    column="delivery_money"    />
         <result property="userCouponId"    column="user_coupon_id"    />
         <result property="isPay"    column="is_pay"    />
         <result property="payTime"    column="pay_time"    />
@@ -87,6 +88,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="totalMoney != null">total_money,</if>
             <if test="discountMoney != null">discount_money,</if>
             <if test="payMoney != null">pay_money,</if>
+            <if test="deliveryMoney != null">delivery_money,</if>
             <if test="userCouponId != null">user_coupon_id,</if>
             <if test="isPay != null">is_pay,</if>
             <if test="payTime != null">pay_time,</if>
@@ -112,7 +114,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="userAddress != null">#{userAddress},</if>
             <if test="itemJson != null">#{itemJson},</if>
             <if test="integral != null">#{integral},</if>
+            <if test="totalIntegral != null">#{totalIntegral},</if>
+            <if test="discountIntegral != null">#{discountIntegral},</if>
+            <if test="totalMoney != null">#{totalMoney},</if>
+            <if test="discountMoney != null">#{discountMoney},</if>
             <if test="payMoney != null">#{payMoney},</if>
+            <if test="deliveryMoney != null">#{deliveryMoney},</if>
+            <if test="userCouponId != null">#{userCouponId},</if>
             <if test="isPay != null">#{isPay},</if>
             <if test="payTime != null">#{payTime},</if>
             <if test="payType != null">#{payType},</if>
@@ -145,6 +153,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="totalMoney != null">total_money = #{totalMoney},</if>
             <if test="discountMoney != null">discount_money = #{discountMoney},</if>
             <if test="payMoney != null">pay_money = #{payMoney},</if>
+            <if test="deliveryMoney != null">delivery_money = #{deliveryMoney},</if>
             <if test="userCouponId != null">user_coupon_id = #{userCouponId},</if>
             <if test="isPay != null">is_pay = #{isPay},</if>
             <if test="payTime != null">pay_time = #{payTime},</if>

+ 10 - 1
fs-service/src/main/resources/mapper/hisStore/FsShippingTemplatesRegionScrmMapper.xml

@@ -38,7 +38,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <include refid="selectFsShippingTemplatesRegionVo"/>
         where id = #{id}
     </select>
-        
+
+    <select id="selectByTempIdAndProvinceIdAndCityId" resultType="com.fs.hisStore.domain.FsShippingTemplatesRegionScrm">
+        select * from fs_shipping_templates_region
+        where temp_id = #{tempId} and province_id = #{provinceId}
+        <if test="cityId != null">
+            and city_id = #{cityId}
+        </if>
+        limit 1
+    </select>
+
     <insert id="insertFsShippingTemplatesRegion" parameterType="FsShippingTemplatesRegionScrm" useGeneratedKeys="true" keyProperty="id">
         insert into fs_shipping_templates_region
         <trim prefix="(" suffix=")" suffixOverrides=",">

+ 8 - 1
fs-service/src/main/resources/mapper/hisStore/FsShippingTemplatesScrmMapper.xml

@@ -38,7 +38,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <include refid="selectFsShippingTemplatesVo"/>
         where id = #{id}
     </select>
-        
+
+    <select id="selectByIds" resultType="com.fs.hisStore.domain.FsShippingTemplatesScrm">
+        select * from fs_shipping_templates where id in
+        <foreach item="tempId" collection="ids" open="(" separator="," close=")">
+            #{tempId}
+        </foreach>
+    </select>
+
     <insert id="insertFsShippingTemplates" parameterType="FsShippingTemplatesScrm" useGeneratedKeys="true" keyProperty="id">
         insert into fs_shipping_templates
         <trim prefix="(" suffix=")" suffixOverrides=",">

+ 9 - 0
fs-user-app/src/main/java/com/fs/app/controller/RewardGoodsController.java

@@ -7,6 +7,7 @@ import com.fs.common.core.domain.R;
 import com.fs.common.utils.StringUtils;
 import com.fs.his.dto.ExpressInfoDTO;
 import com.fs.his.enums.ShipperCodeEnum;
+import com.fs.his.param.FsRewardOrderComputeParam;
 import com.fs.his.service.IFsExpressService;
 import com.fs.reward.domain.FsRewardGoodsOrder;
 import com.fs.reward.param.FsRewardGoodsOrderPayParam;
@@ -45,6 +46,14 @@ public class RewardGoodsController extends AppBaseController {
         return R.ok().put("data", rewardGoodsService.selectFsRewardGoodsVOById(goodsId));
     }
 
+    @Login
+    @ApiOperation("计算订单")
+    @PostMapping("/compute")
+    public R compute(@Validated @RequestBody FsRewardOrderComputeParam param){
+        param.setUserId(Long.parseLong(getUserId()));
+        return rewardGoodsOrderService.computeOrder(param);
+    }
+
     @RepeatSubmit
     @Login
     @ApiOperation("通用支付接口")