Parcourir la source

fixed 商家发券逻辑优化

fushengqian il y a 6 mois
Parent
commit
dda04b723d

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

@@ -123,10 +123,10 @@ public interface CouponService extends IService<MtCoupon> {
     void deleteUserCoupon(Integer id, String operator) throws BusinessCheckException;
 
     /**
-     * 根据券ID 撤销个人卡券消费流水
+     * 根据券ID撤销个人卡券消费流水
      *
-     * @param id       消费流水ID
-     * @param userCouponId       用户卡券ID
+     * @param id 消费流水ID
+     * @param userCouponId 用户卡券ID
      * @param operator 操作人
      * @throws BusinessCheckException
      * @return

+ 1 - 2
fuint-application/src/main/java/com/fuint/common/service/impl/CouponServiceImpl.java

@@ -444,7 +444,7 @@ public class CouponServiceImpl extends ServiceImpl<MtCouponMapper, MtCoupon> imp
      * */
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public ResponseObject findCouponList(CouponListParam couponListParam) {
+    public ResponseObject findCouponList(CouponListParam couponListParam) throws BusinessCheckException {
         Integer pageNumber = couponListParam.getPage() == null ? Constants.PAGE_NUMBER : couponListParam.getPage();
         Integer pageSize = couponListParam.getPageSize() == null ? Constants.PAGE_SIZE : couponListParam.getPageSize();
         String status = couponListParam.getStatus() == null ? StatusEnum.ENABLED.getKey() : couponListParam.getStatus();
@@ -483,7 +483,6 @@ public class CouponServiceImpl extends ServiceImpl<MtCouponMapper, MtCoupon> imp
         if (storeId != null && storeId > 0) {
             lambdaQueryWrapper.eq(MtCoupon::getStoreId, storeId);
         }
-
         lambdaQueryWrapper.orderByDesc(MtCoupon::getId);
         List<MtCoupon> dataList = mtCouponMapper.selectList(lambdaQueryWrapper);
 

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

@@ -112,7 +112,7 @@ public class ClientConfirmController extends BaseController {
                         }
                     }
                     if (!isSameStore) {
-                        return getFailureResult(1003, "抱歉,该卡券存在店铺使用范围限制,您所在店铺无法核销!");
+                        return getFailureResult(1003, "抱歉,该卡券存在店铺使用范围限制,您所在店铺无法核销!");
                     }
                 }
             }

+ 21 - 6
fuint-application/src/main/java/com/fuint/module/merchantApi/controller/MerchantCouponController.java

@@ -7,6 +7,7 @@ import com.fuint.common.util.TokenUtil;
 import com.fuint.framework.exception.BusinessCheckException;
 import com.fuint.framework.web.BaseController;
 import com.fuint.framework.web.ResponseObject;
+import com.fuint.repository.model.MtCoupon;
 import com.fuint.repository.model.MtStaff;
 import com.fuint.repository.model.MtUser;
 import com.fuint.utils.StringUtil;
@@ -65,19 +66,33 @@ public class MerchantCouponController extends BaseController {
             return getFailureResult(1001);
         }
 
-        MtStaff staffInfo = null;
+        MtStaff staff = null;
         MtUser mtUser = memberService.queryMemberById(userInfo.getId());
         if (mtUser != null && mtUser.getMobile() != null) {
-            staffInfo = staffService.queryStaffByMobile(mtUser.getMobile());
+            staff = staffService.queryStaffByMobile(mtUser.getMobile());
         }
-        if (staffInfo == null) {
+        if (staff == null) {
             return getFailureResult(201, "该账号不是商户");
         }
-        if (!merchantId.equals(staffInfo.getMerchantId())) {
+        if (!merchantId.equals(staff.getMerchantId())) {
             return getFailureResult(201, "您没有操作权限");
         }
-
-        couponService.sendCoupon(receiveParam.getCouponId(), receiveParam.getUserId(), receiveParam.getNum(), true, null, staffInfo.getRealName());
+        // 判断店铺权限
+        MtCoupon couponInfo = couponService.queryCouponById(receiveParam.getCouponId());
+        if (StringUtil.isNotEmpty(couponInfo.getStoreIds())) {
+            String[] storeIds = couponInfo.getStoreIds().split(",");
+            Boolean isSameStore = false;
+            for (String hid : storeIds) {
+                if (staff.getStoreId().toString().equals(hid)) {
+                    isSameStore = true;
+                    break;
+                }
+            }
+            if (!isSameStore) {
+                return getFailureResult(1003, "抱歉,该卡券存在店铺使用范围限制,您所在的店铺无发券权限!");
+            }
+        }
+        couponService.sendCoupon(receiveParam.getCouponId(), receiveParam.getUserId(), receiveParam.getNum(), true, null, staff.getRealName());
         return getSuccessResult(true);
     }
 }