Browse Source

fixed 获取商品分类接口

fushengqian 2 weeks ago
parent
commit
bdb6be01a6

+ 6 - 4
fuint-application/src/main/java/com/fuint/common/service/CateService.java

@@ -7,7 +7,6 @@ import com.fuint.framework.pagination.PaginationRequest;
 import com.fuint.framework.pagination.PaginationResponse;
 import com.fuint.repository.model.MtGoodsCate;
 import java.util.List;
-import java.util.Map;
 
 /**
  * 商品分类业务接口
@@ -61,12 +60,15 @@ public interface CateService extends IService<MtGoodsCate> {
     MtGoodsCate updateCate(MtGoodsCate reqDto) throws BusinessCheckException;
 
     /**
-     * 根据条件搜索分类
+     * 获取分类列表
      *
-     * @param params 查询参数
+     * @param merchantId 商户
+     * @param storeId 店铺ID
+     * @param name 店铺名称
+     * @param status 状态
      * @return
      * */
-    List<MtGoodsCate> queryCateListByParams(Map<String, Object> params) throws BusinessCheckException;
+    List<MtGoodsCate> getCateList(Integer merchantId, Integer storeId, String name, String status) throws BusinessCheckException;
 
     /**
      * 获取分类ID

+ 16 - 20
fuint-application/src/main/java/com/fuint/common/service/impl/CateServiceImpl.java

@@ -234,24 +234,29 @@ public class CateServiceImpl extends ServiceImpl<MtGoodsCateMapper, MtGoodsCate>
         return mtCate;
     }
 
+    /**
+     * 获取分类列表
+     *
+     * @param merchantId 商户
+     * @param storeId 店铺ID
+     * @param name 店铺名称
+     * @param status 状态
+     * @return
+     * */
     @Override
-    public List<MtGoodsCate> queryCateListByParams(Map<String, Object> params) {
+    public List<MtGoodsCate> getCateList(Integer merchantId, Integer storeId, String name, String status) {
         LambdaQueryWrapper<MtGoodsCate> lambdaQueryWrapper = Wrappers.lambdaQuery();
         lambdaQueryWrapper.ne(MtGoodsCate::getStatus, StatusEnum.DISABLE.getKey());
-        String storeId =  params.get("storeId") == null ? "" : params.get("storeId").toString();
-        String merchantId =  params.get("merchantId") == null ? "" : params.get("merchantId").toString();
-        if (StringUtils.isNotBlank(merchantId)) {
+        if (merchantId != null && merchantId > 0) {
             lambdaQueryWrapper.eq(MtGoodsCate::getMerchantId, merchantId);
         }
-        String name =  params.get("name") == null ? "" : params.get("name").toString();
         if (StringUtils.isNotBlank(name)) {
             lambdaQueryWrapper.like(MtGoodsCate::getName, name);
         }
-        String status =  params.get("status") == null ? StatusEnum.ENABLED.getKey(): params.get("status").toString();
         if (StringUtils.isNotBlank(status)) {
             lambdaQueryWrapper.eq(MtGoodsCate::getStatus, status);
         }
-        if (StringUtils.isNotBlank(storeId)) {
+        if (storeId != null && storeId > 0) {
             lambdaQueryWrapper.and(wq -> wq
                     .eq(MtGoodsCate::getStoreId, 0)
                     .or()
@@ -271,20 +276,11 @@ public class CateServiceImpl extends ServiceImpl<MtGoodsCateMapper, MtGoodsCate>
      * */
     @Override
     public Integer getGoodsCateId(Integer merchantId, Integer storeId, String name) {
-        Integer cate = 0;
-        Map<String, Object> param = new HashMap<>();
-        param.put("status", StatusEnum.ENABLED.getKey());
-        param.put("name", name);
-        if (storeId != null && storeId > 0) {
-            param.put("storeId", storeId);
-        }
-        if (merchantId != null && merchantId > 0) {
-            param.put("merchantId", merchantId);
-        }
-        List<MtGoodsCate> cateList = queryCateListByParams(param);
+        Integer cateId = 0;
+        List<MtGoodsCate> cateList = getCateList(merchantId, storeId, name, StatusEnum.ENABLED.getKey());
         if (cateList != null && cateList.size() > 0) {
-            cate = cateList.get(0).getId();
+            cateId = cateList.get(0).getId();
         }
-        return cate;
+        return cateId;
     }
 }

+ 1 - 14
fuint-application/src/main/java/com/fuint/module/backendApi/controller/BackendCashierController.java

@@ -122,21 +122,8 @@ public class BackendCashierController extends BaseController {
         if (userId != null && userId > 0) {
             memberInfo = memberService.queryMemberById(userId);
         }
-        Map<String, Object> param = new HashMap<>();
-        param.put("status", StatusEnum.ENABLED.getKey());
-        if (accountInfo.getMerchantId() != null && accountInfo.getMerchantId() > 0) {
-            param.put("merchantId", accountInfo.getMerchantId());
-        } else {
-            param.put("merchantId", 0);
-        }
-        if (storeId > 0) {
-            param.put("storeId", storeId);
-        } else {
-            param.put("storeId", 0);
-        }
-        List<MtGoodsCate> cateList = cateService.queryCateListByParams(param);
 
-        param.put("status", StatusEnum.ENABLED.getKey());
+        List<MtGoodsCate> cateList = cateService.getCateList(accountInfo.getMerchantId(), storeId, null, StatusEnum.ENABLED.getKey());
         Map<String, Object> goodsData = goodsService.getStoreGoodsList(storeId, "", PlatformTypeEnum.PC.getCode(), cateId, page, pageSize);
 
         Map<String, Object> result = new HashMap<>();

+ 2 - 2
fuint-application/src/main/java/com/fuint/module/backendApi/controller/BackendGoodsController.java

@@ -132,7 +132,7 @@ public class BackendGoodsController extends BaseController {
         if (storeId > 0) {
             cateParam.put("storeId", storeId.toString());
         }
-        List<MtGoodsCate> cateList = cateService.queryCateListByParams(cateParam);
+        List<MtGoodsCate> cateList = cateService.getCateList(accountInfo.getMerchantId(), storeId, null, StatusEnum.ENABLED.getKey());
 
         Map<String, Object> result = new HashMap<>();
         result.put("paginationResponse", paginationResponse);
@@ -264,7 +264,7 @@ public class BackendGoodsController extends BaseController {
         if (accountInfo.getMerchantId() != null && accountInfo.getMerchantId() > 0) {
             param.put("merchantId", accountInfo.getMerchantId());
         }
-        List<MtGoodsCate> cateList = cateService.queryCateListByParams(param);
+        List<MtGoodsCate> cateList = cateService.getCateList(accountInfo.getMerchantId(), null, null, StatusEnum.ENABLED.getKey());
         result.put("cateList", cateList);
 
         String imagePath = settingService.getUploadBasePath();

+ 2 - 6
fuint-application/src/main/java/com/fuint/module/clientApi/controller/ClientCouponController.java

@@ -96,7 +96,7 @@ public class ClientCouponController extends BaseController {
     @ApiOperation(value = "领取卡券")
     @RequestMapping(value = "/receive", method = RequestMethod.POST)
     @CrossOrigin
-    public ResponseObject receive(HttpServletRequest request, @RequestBody CouponReceiveParam couponReceiveParam) {
+    public ResponseObject receive(HttpServletRequest request, @RequestBody CouponReceiveParam couponReceiveParam) throws BusinessCheckException {
         String token = request.getHeader("Access-Token");
         UserInfo mtUser = TokenUtil.getUserInfoByToken(token);
 
@@ -106,11 +106,7 @@ public class ClientCouponController extends BaseController {
             return getFailureResult(1001);
         }
 
-        try {
-            userCouponService.receiveCoupon(couponReceiveParam);
-        } catch (BusinessCheckException e) {
-            return getFailureResult(1006, e.getMessage());
-        }
+        userCouponService.receiveCoupon(couponReceiveParam);
 
         // 组织返回参数
         Map<String, Object> result = new HashMap<>();

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

@@ -76,16 +76,8 @@ public class ClientGoodsController extends BaseController {
         Integer storeId = request.getHeader("storeId") == null ? 0 : Integer.parseInt(request.getHeader("storeId"));
         String platform = request.getHeader("platform") == null ? "" : request.getHeader("platform");
 
-        Map<String, Object> param = new HashMap<>();
-        param.put("status", StatusEnum.ENABLED.getKey());
         Integer merchantId = merchantService.getMerchantId(merchantNo);
-        if (merchantId > 0) {
-            param.put("merchantId", merchantId);
-        }
-        if (storeId > 0) {
-            param.put("storeId", storeId);
-        }
-        List<MtGoodsCate> cateList = cateService.queryCateListByParams(param);
+        List<MtGoodsCate> cateList = cateService.getCateList(merchantId, storeId, null, StatusEnum.ENABLED.getKey());
         Map<String, Object> goodsData = goodsService.getStoreGoodsList(storeId, "", platform, 0, 1, 500);
         List<MtGoods> goodsList = (ArrayList)goodsData.get("goodsList");
         String baseImage = settingService.getUploadBasePath();

+ 1 - 1
fuint-framework/src/main/java/com/fuint/framework/pagination/PaginationRequest.java

@@ -11,8 +11,8 @@ import java.util.Map;
  */
 public class PaginationRequest implements Serializable {
 
-    /**  */
     private static final long serialVersionUID = -344484321130132260L;
+
     /**
      * 当前页码
      */