Browse Source

fixed 支付卡用卡券选取

fushengqian 1 year ago
parent
commit
35c681b7ed

+ 4 - 3
fuint-application/src/main/java/com/fuint/common/service/UserCouponService.java

@@ -61,11 +61,12 @@ public interface UserCouponService extends IService<MtUserCoupon> {
     /**
      * 获取会员可支付用的卡券
      *
-     * @param userId
-     * @param type
+     * @param userId 会员ID
+     * @param storeId 使用门店
+     * @param useFor 用途
      * @return
      * */
-    List<CouponDto> getPayAbleCouponList(Integer userId, String type) throws BusinessCheckException;
+    List<CouponDto> getPayAbleCouponList(Integer userId, Integer storeId, String useFor) throws BusinessCheckException;
 
     /**
      * 获取会员卡券详情

+ 9 - 1
fuint-application/src/main/java/com/fuint/common/service/impl/UserCouponServiceImpl.java

@@ -527,11 +527,12 @@ public class UserCouponServiceImpl extends ServiceImpl<MtUserCouponMapper, MtUse
      * 获取会员可支付使用的卡券
      *
      * @param userId 会员ID
+     * @param storeId 使用门店
      * @param useFor 用途
      * @return
      * */
     @Override
-    public List<CouponDto> getPayAbleCouponList(Integer userId, String useFor) throws BusinessCheckException {
+    public List<CouponDto> getPayAbleCouponList(Integer userId, Integer storeId, String useFor) throws BusinessCheckException {
         List<String> statusList = Arrays.asList(UserCouponStatusEnum.UNUSED.getKey());
         List<MtUserCoupon> userCouponList = mtUserCouponMapper.getUserCouponList(userId, statusList);
         List<CouponDto> dataList = new ArrayList<>();
@@ -539,6 +540,13 @@ public class UserCouponServiceImpl extends ServiceImpl<MtUserCouponMapper, MtUse
         if (userCouponList.size() > 0) {
             for (MtUserCoupon userCoupon : userCouponList) {
                  MtCoupon couponInfo = couponService.queryCouponById(userCoupon.getCouponId());
+                 // 适用门店
+                 if (storeId != null && storeId > 0 && StringUtil.isNotEmpty(couponInfo.getStoreIds())) {
+                     String[] storeIds = couponInfo.getStoreIds().split(",");
+                     if (!Arrays.asList(storeIds).contains(storeId.toString())) {
+                         continue;
+                     }
+                 }
                  // 只取专用卡券
                  if (StringUtil.isNotEmpty(useFor) && !couponInfo.getUseFor().equals(useFor)) {
                      continue;

+ 2 - 1
fuint-application/src/main/java/com/fuint/module/clientApi/controller/ClientPayController.java

@@ -97,6 +97,7 @@ public class ClientPayController extends BaseController {
     @CrossOrigin
     public ResponseObject prePay(HttpServletRequest request) throws BusinessCheckException {
         String token = request.getHeader("Access-Token");
+        Integer storeId = request.getHeader("storeId") == null ? 0 : Integer.parseInt(request.getHeader("storeId"));
         String useFor = request.getParameter("type") == null ? "" : request.getParameter("type");
         String merchantNo = request.getHeader("merchantNo");
         UserInfo userInfo = TokenUtil.getUserInfoByToken(token);
@@ -120,7 +121,7 @@ public class ClientPayController extends BaseController {
         // 可用卡券
         CouponDto canUseCouponInfo = null;
         if (mtUser != null) {
-            List<CouponDto> couponList = userCouponService.getPayAbleCouponList(mtUser.getId(), useFor);
+            List<CouponDto> couponList = userCouponService.getPayAbleCouponList(mtUser.getId(), storeId, useFor);
             if (couponList.size() > 0) {
                 canUseCouponInfo = couponList.get(0);
             }