ソースを参照

Merge remote-tracking branch 'origin/bjcz_his_scrm' into bjcz_his_scrm

yjwang 1 ヶ月 前
コミット
aeff41dbd4

+ 1 - 1
fs-service/src/main/java/com/fs/hisStore/dto/FsStoreOrderComputeDTO.java

@@ -30,4 +30,4 @@ public class FsStoreOrderComputeDTO implements Serializable
     private BigDecimal deductionPrice;
 
 
-}
+}

+ 1 - 1
fs-service/src/main/java/com/fs/hisStore/mapper/FsStoreCouponIssueScrmMapper.java

@@ -92,7 +92,7 @@ public interface FsStoreCouponIssueScrmMapper
             "and find_in_set(#{maps.cateId},c.package_cate_ids) " +
             "</if>" +
             "<if test = 'maps.couponType != null     '> " +
-            "and i.coupon_type =#{maps.couponType} " +
+            "and i.coupon_type =0 " +
             "</if>" +
             "<if test = 'maps.couponPrice != null     '> " +
             "and c.coupon_price =  #{maps.couponPrice} " +

+ 20 - 4
fs-service/src/main/java/com/fs/hisStore/mapper/FsStoreCouponUserScrmMapper.java

@@ -69,7 +69,7 @@ public interface FsStoreCouponUserScrmMapper
     int updateFsCouponByExpire();
     @Select({"<script> " +
             "select cu.* from fs_store_coupon_user_scrm cu inner join fs_store_coupon_scrm c on c.coupon_id=cu.coupon_id  LEFT JOIN fs_store_coupon_issue_scrm i ON i.coupon_id = cu.coupon_id  " +
-            "where cu.status=0 and cu.is_del=0 " +
+            "where cu.status=0 and cu.is_del=0 and  c.type!=3  and cu.limit_time &gt; now()" +
             "<if test = 'maps.userId != null     '> " +
             "and cu.user_id =#{maps.userId} " +
             "</if>" +
@@ -80,7 +80,7 @@ public interface FsStoreCouponUserScrmMapper
             "and cu.use_min_price &lt; #{maps.useMinPrice} " +
             "</if>" +
             "<if test = 'maps.couponType != null     '> " +
-            "and i.coupon_type = 3 " +
+            "and i.coupon_type = #{maps.couponType} " +
             "</if>" +
             "</script>"})
     List<FsStoreCouponUserScrm> selectFsStoreCouponUserListByEnable(@Param("maps")FsCouponUserEnableParam param);
@@ -121,5 +121,21 @@ public interface FsStoreCouponUserScrmMapper
     List<FsStoreCouponUserVO> selectFsStoreCouponUserListVOForCash(@Param("maps")FsStoreCouponUserScrm fsStoreCouponUser);
 
 
-
-}
+    @Select({"<script> " +
+            "select cu.* from fs_store_coupon_user_scrm cu inner join fs_store_coupon_scrm c on c.coupon_id=cu.coupon_id  LEFT JOIN fs_store_coupon_issue_scrm i ON i.coupon_id = cu.coupon_id  " +
+            "where cu.status=0 and cu.is_del=0 and  c.type=3  " +
+            "<if test = 'maps.userId != null     '> " +
+            "and cu.user_id =#{maps.userId} " +
+            "</if>" +
+            "<if test = 'maps.packageCateId != null     '> " +
+            "and (find_in_set( #{maps.packageCateId},c.package_cate_ids) or c.package_cate_ids=0) " +
+            "</if>" +
+            "<if test = 'maps.useMinPrice != null     '> " +
+            "and cu.use_min_price &lt; #{maps.useMinPrice} " +
+            "</if>" +
+            "<if test = 'maps.couponType != null     '> " +
+            "and i.coupon_type = #{maps.couponType} " +
+            "</if>" +
+            "</script>"})
+    List<FsStoreCouponUserScrm> selectFsStoreCouponUserListByEnableForCash(@Param("maps") FsCouponUserEnableParam param);
+}

+ 2 - 1
fs-service/src/main/java/com/fs/hisStore/service/IFsStoreCouponUserScrmService.java

@@ -70,4 +70,5 @@ public interface IFsStoreCouponUserScrmService
 
     List<FsStoreCouponUserVO> selectFsStoreCouponUserListVOForCash(FsStoreCouponUserScrm fsStoreCouponUser);
 
-}
+    List<FsStoreCouponUserScrm> selectFsStoreCouponUserListByEnableForCash(FsCouponUserEnableParam param);
+}

+ 6 - 1
fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreCouponUserScrmServiceImpl.java

@@ -116,4 +116,9 @@ public class FsStoreCouponUserScrmServiceImpl implements IFsStoreCouponUserScrmS
     public List<FsStoreCouponUserVO> selectFsStoreCouponUserListVOForCash(FsStoreCouponUserScrm fsStoreCouponUser) {
         return fsStoreCouponUserMapper.selectFsStoreCouponUserListVOForCash(fsStoreCouponUser);
     }
-}
+
+    @Override
+    public List<FsStoreCouponUserScrm> selectFsStoreCouponUserListByEnableForCash(FsCouponUserEnableParam param) {
+        return fsStoreCouponUserMapper.selectFsStoreCouponUserListByEnableForCash(param);
+    }
+}

+ 9 - 5
fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreOrderScrmServiceImpl.java

@@ -565,14 +565,16 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
                 if (integralMax.intValue() > 0 && Double.compare(userIntegral, integralMax) >= 0) {
                     userIntegral = integralMax;
                 }
-                deductionPrice = BigDecimal.valueOf(NumberUtil.mul(userIntegral, integralRatio));
-                if (deductionPrice.compareTo(payPrice) < 0) {
-                    payPrice = NumberUtil.sub(payPrice, deductionPrice);
+                BigDecimal integralDeduction = BigDecimal.valueOf(NumberUtil.mul(userIntegral, integralRatio));
+                if (integralDeduction.compareTo(payPrice) < 0) {
+                    payPrice = NumberUtil.sub(payPrice, integralDeduction);
+                    deductionPrice = deductionPrice.add(integralDeduction);
                     usedIntegral = userIntegral;
                 } else {
-                    deductionPrice = payPrice;
+                    integralDeduction = payPrice;
                     payPrice = BigDecimal.ZERO;
-                    usedIntegral = NumberUtil.round(NumberUtil.div(deductionPrice,
+                    deductionPrice = deductionPrice.add(integralDeduction);
+                    usedIntegral = NumberUtil.round(NumberUtil.div(integralDeduction,
                             BigDecimal.valueOf(integralRatio)), 2).doubleValue();
                 }
             }
@@ -587,6 +589,7 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
             if (couponUser != null && couponUser.getStatus() == 0) {
                 if (couponUser.getUseMinPrice().compareTo(priceGroup.getTotalPrice()) == -1) {
                     payPrice = payPrice.subtract(couponUser.getCouponPrice());
+                    deductionPrice = deductionPrice.add(couponUser.getCouponPrice());
                 }
             }
         }
@@ -597,6 +600,7 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
             if (deductionCouponUser != null && deductionCouponUser.getStatus() == 0) {
                 if (deductionCouponUser.getUseMinPrice().compareTo(priceGroup.getTotalPrice()) == -1) {
                     payPrice = payPrice.subtract(deductionCouponUser.getCouponPrice());
+                    deductionPrice = deductionPrice.add(deductionCouponUser.getCouponPrice());
                 }
             }
         }

+ 6 - 1
fs-user-app/src/main/java/com/fs/app/controller/store/CouponScrmController.java

@@ -148,7 +148,12 @@ public class CouponScrmController extends AppBaseController {
     public R getMyEnableCouponList(FsCouponUserEnableParam param, HttpServletRequest request){
         try {
             param.setUserId(Long.parseLong(getUserId()));
-            List<FsStoreCouponUserScrm> list=fsStoreCouponUserService.selectFsStoreCouponUserListByEnable(param);
+            List<FsStoreCouponUserScrm> list;
+            if (param.getCouponType() != null && param.getCouponType() == 3) {
+                list = fsStoreCouponUserService.selectFsStoreCouponUserListByEnableForCash(param);
+            } else {
+                list = fsStoreCouponUserService.selectFsStoreCouponUserListByEnable(param);
+            }
             list=list.stream().filter(s->(s.getCouponPrice().compareTo(param.getUseMinPrice())==-1 )).collect(Collectors.toList());
             list=list.stream().filter(s->(s.getUseMinPrice().compareTo(param.getUseMinPrice())==-1 )).collect(Collectors.toList());
             return R.ok().put("data",list);

+ 19 - 1
fs-user-app/src/main/java/com/fs/app/controller/store/StoreOrderScrmController.java

@@ -28,6 +28,7 @@ import com.fs.hisStore.mapper.FsStorePaymentScrmMapper;
 import com.fs.hisStore.param.*;
 import com.fs.hisStore.service.*;
 import com.fs.hisStore.vo.FsMyStoreOrderListQueryVO;
+import com.fs.hisStore.vo.FsStoreCartQueryVO;
 import com.fs.hisStore.vo.FsStoreOrderItemVO;
 import com.fs.huifuPay.domain.HuiFuCreateOrder;
 import com.fs.huifuPay.domain.HuifuCreateOrderResult;
@@ -274,7 +275,24 @@ public class StoreOrderScrmController extends AppBaseController {
     @ApiOperation("确认订单")
     @PostMapping("/confirm")
     public R confirm(@Validated @RequestBody FsStoreConfirmOrderParam param, HttpServletRequest request){
-        return orderService.confirmOrder(Long.parseLong(getUserId()),param);
+        R result = orderService.confirmOrder(Long.parseLong(getUserId()),param);
+        // 计算商品原价总价
+        BigDecimal totalPrice = BigDecimal.ZERO;
+        String orderKey = (String) result.get("orderKey");
+        if (orderKey != null) {
+            List<FsStoreCartQueryVO> carts = redisCache.getCacheObject("orderCarts:" + orderKey);
+            if (carts != null) {
+                for (FsStoreCartQueryVO cart : carts) {
+                    BigDecimal price = cart.getPrice();
+                    Integer cartNum = cart.getCartNum();
+                    if (price != null && cartNum != null) {
+                        totalPrice = totalPrice.add(price.multiply(new BigDecimal(cartNum)));
+                    }
+                }
+            }
+        }
+        result.put("totalPrice", totalPrice);
+        return result;
     }
     @Login
     @ApiOperation("计算订单金额")