瀏覽代碼

no message

FengChaoYu 1 月之前
父節點
當前提交
d1653ec95f

+ 43 - 44
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/controller/goods/GoodsController.java

@@ -37,7 +37,7 @@ import java.util.concurrent.locks.Lock;
 
 @Slf4j
 @RestController
-@Api(value = "商品列表", tags ={"商品列表"} )
+@Api(value = "商品列表", tags = {"商品列表"})
 @RequestMapping(value = "/goods", produces = "application/json; charset=utf-8")
 public class GoodsController {
     @Resource
@@ -58,9 +58,9 @@ public class GoodsController {
     @ApiOperation(value = "分类列表(树形)")
     public ResponseHelper<List<CategoryBean>> category(
             HttpServletRequest request,
-            @ApiParam(value = "是否显示在服务页 true/false",required = false) @RequestParam(required = false) Boolean isServiceShow
+            @ApiParam(value = "是否显示在服务页 true/false", required = false) @RequestParam(required = false) Boolean isServiceShow
     ) throws Exception {
-        List<CategoryBean> categoryBeans = categoryLogic.queryAll(request,isServiceShow);
+        List<CategoryBean> categoryBeans = categoryLogic.queryAll(request, isServiceShow);
         return ResponseHelper.success(categoryBeans);
     }
 
@@ -68,8 +68,8 @@ public class GoodsController {
     @ApiOperation(value = "获取一级分类列表")
     public ResponseHelper<List<GoodsCategory>> categoryFirst(
             HttpServletRequest request,
-            @ApiParam(value = "是否显示在服务页",required = false) @RequestParam(required = false) Boolean isServiceShow) throws Exception {
-        List<GoodsCategory> categoryBeans = categoryLogic.queryFirst(request,isServiceShow);
+            @ApiParam(value = "是否显示在服务页", required = false) @RequestParam(required = false) Boolean isServiceShow) throws Exception {
+        List<GoodsCategory> categoryBeans = categoryLogic.queryFirst(request, isServiceShow);
         return ResponseHelper.success(categoryBeans);
     }
 
@@ -77,9 +77,9 @@ public class GoodsController {
     @ApiOperation(value = "获取二级分类列表")
     public ResponseHelper<List<GoodsCategory>> categorySecond(
             HttpServletRequest request,
-            @ApiParam(value = "一级分类id",required = true) @RequestParam(required = true) String categoryId
+            @ApiParam(value = "一级分类id", required = true) @RequestParam(required = true) String categoryId
     ) throws Exception {
-        List<GoodsCategory> categoryBeans = categoryLogic.querySecond(request , categoryId);
+        List<GoodsCategory> categoryBeans = categoryLogic.querySecond(request, categoryId);
         return ResponseHelper.success(categoryBeans);
     }
 
@@ -89,19 +89,18 @@ public class GoodsController {
     @ApiOperation(value = "分类列表")
     public ResponseHelper<List<GoodsCategory>> category(
             HttpServletRequest request,
-            @ApiParam(value = "分类id",required = false) @RequestParam(required = false) String parentId,
-            @ApiParam(value = "类型 1=商品分类 2=服务分类",required = false) @RequestParam(required = false) Integer type,
-            @ApiParam(value = "分类名称",required = false) @RequestParam(required = false) String name,
-            @ApiParam(value = "是否只查询以旧换新的分类",required = false) @RequestParam(required = false) Boolean yjhx
+            @ApiParam(value = "分类id", required = false) @RequestParam(required = false) String parentId,
+            @ApiParam(value = "类型 1=商品分类 2=服务分类", required = false) @RequestParam(required = false) Integer type,
+            @ApiParam(value = "分类名称", required = false) @RequestParam(required = false) String name
     ) throws Exception {
-        List<GoodsCategory> list = categoryLogic.list(request,parentId,type,name,yjhx);
+        List<GoodsCategory> list = categoryLogic.list(request, parentId, type, name);
         return ResponseHelper.success(list);
     }
 
     @GetMapping("/category/brand")
     @ApiOperation(value = "品牌列表-根据一级分类查询")
     public ResponseHelper<List<Brand>> brand(
-            @ApiParam(value = "一级分类id",required = false) @RequestParam(required = false) String categoryId
+            @ApiParam(value = "一级分类id", required = false) @RequestParam(required = false) String categoryId
     ) throws Exception {
         //List<CategoryBean> categoryBeans = categoryLogic.queryAll(request);
         List<Brand> brands = categoryLogic.brandList(categoryId);
@@ -112,11 +111,11 @@ public class GoodsController {
     @ApiOperation(value = "根据一级分类查询商品列表")
     public ResponseHelper<IPage<Goods>> listByLevel1(
             HttpServletRequest request,
-            @ApiParam(value = "一级分类id",required = true) @RequestParam(required = true) String categoryId,
-            @ApiParam(value = "页号",required = true) @RequestParam Integer pageNum,
-            @ApiParam(value = "页大小",required = true) @RequestParam Integer pageSize
+            @ApiParam(value = "一级分类id", required = true) @RequestParam(required = true) String categoryId,
+            @ApiParam(value = "页号", required = true) @RequestParam Integer pageNum,
+            @ApiParam(value = "页大小", required = true) @RequestParam Integer pageSize
     ) throws Exception {
-        IPage<Goods> categoryGoodBeans = categoryLogic.categoryGoodsList(request,categoryId,pageNum,pageSize);
+        IPage<Goods> categoryGoodBeans = categoryLogic.categoryGoodsList(request, categoryId, pageNum, pageSize);
         return ResponseHelper.success(categoryGoodBeans);
     }
 
@@ -124,18 +123,18 @@ public class GoodsController {
     @ApiOperation(value = "商品列表")
     public ResponseHelper<IPage<GoodsNewBean>> page(
             HttpServletRequest request,
-            @ApiParam(value = "品牌id",required = false) @RequestParam(required = false) List<String> brandId,
-            @ApiParam(value = "最低价",required = false) @RequestParam(required = false) BigDecimal minPrice,
-            @ApiParam(value = "最高价",required = false) @RequestParam(required = false) BigDecimal maxPrice,
-            @ApiParam(value = "商品标签",required = false) @RequestParam(required = false) List<String> tag,
+            @ApiParam(value = "品牌id", required = false) @RequestParam(required = false) List<String> brandId,
+            @ApiParam(value = "最低价", required = false) @RequestParam(required = false) BigDecimal minPrice,
+            @ApiParam(value = "最高价", required = false) @RequestParam(required = false) BigDecimal maxPrice,
+            @ApiParam(value = "商品标签", required = false) @RequestParam(required = false) List<String> tag,
             @ApiParam(value = "商品关键字") @RequestParam(required = false) String keyword,
-            @ApiParam(value = "排序 0=综合 1=销量 2=价格升 3=价格降 4=上新") @RequestParam(required = false,defaultValue = "0") Integer sort,
+            @ApiParam(value = "排序 0=综合 1=销量 2=价格升 3=价格降 4=上新") @RequestParam(required = false, defaultValue = "0") Integer sort,
             @ApiParam(value = "分类id") @RequestParam(required = false) String categoryId,
-            @ApiParam(value = "是否只查询以旧换新的商品",required = false) @RequestParam(required = false) Boolean yjhx,
-            @ApiParam(value = "页号",required = true) @RequestParam Integer pageNum,
-            @ApiParam(value = "页大小",required = true) @RequestParam Integer pageSize
+            @ApiParam(value = "是否只查询以旧换新的商品", required = false) @RequestParam(required = false) Boolean yjhx,
+            @ApiParam(value = "页号", required = true) @RequestParam Integer pageNum,
+            @ApiParam(value = "页大小", required = true) @RequestParam Integer pageSize
     ) throws Exception {
-        IPage<GoodsNewBean> page = goodsLogic.page(request,brandId,minPrice,maxPrice,tag,keyword,categoryId,sort,yjhx, pageNum, pageSize);
+        IPage<GoodsNewBean> page = goodsLogic.page(request, brandId, minPrice, maxPrice, tag, keyword, categoryId, sort, yjhx, pageNum, pageSize);
         return ResponseHelper.success(page);
     }
 
@@ -143,18 +142,18 @@ public class GoodsController {
     @ApiOperation(value = "商品列表")
     public ResponseHelper<IPage<GoodsNewBean>> page1(
             HttpServletRequest request,
-            @ApiParam(value = "品牌id",required = false) @RequestParam(required = false) List<String> brandId,
-            @ApiParam(value = "最低价",required = false) @RequestParam(required = false) BigDecimal minPrice,
-            @ApiParam(value = "最高价",required = false) @RequestParam(required = false) BigDecimal maxPrice,
-            @ApiParam(value = "商品标签",required = false) @RequestParam(required = false) List<String> tag,
+            @ApiParam(value = "品牌id", required = false) @RequestParam(required = false) List<String> brandId,
+            @ApiParam(value = "最低价", required = false) @RequestParam(required = false) BigDecimal minPrice,
+            @ApiParam(value = "最高价", required = false) @RequestParam(required = false) BigDecimal maxPrice,
+            @ApiParam(value = "商品标签", required = false) @RequestParam(required = false) List<String> tag,
             @ApiParam(value = "商品关键字") @RequestParam(required = false) String keyword,
-            @ApiParam(value = "排序 0=综合 1=销量 2=价格升 3=价格降 4=上新") @RequestParam(required = false,defaultValue = "0") Integer sort,
+            @ApiParam(value = "排序 0=综合 1=销量 2=价格升 3=价格降 4=上新") @RequestParam(required = false, defaultValue = "0") Integer sort,
             @ApiParam(value = "分类id") @RequestParam(required = false) String categoryId,
-            @ApiParam(value = "是否只查询以旧换新的商品",required = false) @RequestParam(required = false) Boolean yjhx,
-            @ApiParam(value = "页号",required = true) @RequestParam Integer pageNum,
-            @ApiParam(value = "页大小",required = true) @RequestParam Integer pageSize
+            @ApiParam(value = "是否只查询以旧换新的商品", required = false) @RequestParam(required = false) Boolean yjhx,
+            @ApiParam(value = "页号", required = true) @RequestParam Integer pageNum,
+            @ApiParam(value = "页大小", required = true) @RequestParam Integer pageSize
     ) throws Exception {
-        IPage<GoodsNewBean> page = goodsLogic.page(request,brandId,minPrice,maxPrice,tag,keyword,categoryId,sort, yjhx,pageNum, pageSize);
+        IPage<GoodsNewBean> page = goodsLogic.page(request, brandId, minPrice, maxPrice, tag, keyword, categoryId, sort, yjhx, pageNum, pageSize);
         return ResponseHelper.success(page);
     }
 
@@ -163,9 +162,9 @@ public class GoodsController {
     @ApiOperation(value = "商品详情")
     public ResponseHelper<GoodsBean> detail(
             HttpServletRequest request,
-            @ApiParam(value = "id",required = true) @RequestParam String goodsId,
-            @ApiParam(value = "userId",required = false) @RequestParam(required = false) String userId,
-            @ApiParam(value = "storageId",required = true) @RequestParam(required = false) String storageId
+            @ApiParam(value = "id", required = true) @RequestParam String goodsId,
+            @ApiParam(value = "userId", required = false) @RequestParam(required = false) String userId,
+            @ApiParam(value = "storageId", required = true) @RequestParam(required = false) String storageId
     ) throws RemoteServiceException {
         GoodsBean detail = goodsLogic.detail(request, goodsId, userId, storageId);
         return ResponseHelper.success(detail);
@@ -174,7 +173,7 @@ public class GoodsController {
     @GetMapping("/qrcode")
     @ApiOperation("获取商品二维码")
     public ResponseHelper<String> qrcode(
-            @ApiParam(value = "url",required = true) @RequestParam String url
+            @ApiParam(value = "url", required = true) @RequestParam String url
     ) throws IOException, RemoteServiceException {
 
         byte[] bytes = QrCodeUtil.generatePng(url, 300, 300);
@@ -188,13 +187,13 @@ public class GoodsController {
     @PostMapping("/advice/notice")
     @ApiOperation("到货通知")
     public ResponseHelper<String> qrcode(
-            @ApiParam(value = "商品id",required = true) @RequestParam String goodsId,
-            @ApiParam(value = "商品规格id",required = true) @RequestParam String goodsSpecId,
-            @ApiParam(value = "仓库id",required = true) @RequestParam String storageId
+            @ApiParam(value = "商品id", required = true) @RequestParam String goodsId,
+            @ApiParam(value = "商品规格id", required = true) @RequestParam String goodsSpecId,
+            @ApiParam(value = "仓库id", required = true) @RequestParam String storageId
     ) throws Exception {
 
         Lock obtain = redisLockRegistry.obtain(Constant.RedisPrefix.LOCK_COMMON + goodsId + goodsSpecId);
-        if(!obtain.tryLock(10, TimeUnit.SECONDS)){
+        if (!obtain.tryLock(10, TimeUnit.SECONDS)) {
             return ResponseHelper.error("系统繁忙,请稍后再试");
         }
         try {
@@ -208,7 +207,7 @@ public class GoodsController {
     @PostMapping("/documents")
     @ApiOperation("商品文档")
     public ResponseHelper<List<GoodsDocumentsRelaBean>> documents(
-            @ApiParam(value = "商品id",required = true) @RequestParam String goodsId
+            @ApiParam(value = "商品id", required = true) @RequestParam String goodsId
     ) {
         List<GoodsDocumentsRelaBean> list = goodsLogic.documents(goodsId);
         return ResponseHelper.success(list);

+ 1 - 0
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/logic/common/CommonLogic.java

@@ -90,6 +90,7 @@ public class CommonLogic {
 
         String userId = CommonUtils.getUserId(request);
         String token = CommonUtils.getToken(request);
+        String storageId = CommonUtils.getStorageId(request);
 
         if (StringUtils.isBlank(token)) {
             token = request.getParameter("x-token");

+ 5 - 21
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/logic/goods/CategoryLogic.java

@@ -6,7 +6,9 @@ import com.gree.mall.miniapp.bean.goods.CategoryBean;
 import com.gree.mall.miniapp.bean.user.CurrentCompanyWechat;
 import com.gree.mall.miniapp.commonmapper.CategoryMapper;
 import com.gree.mall.miniapp.logic.common.CommonLogic;
-import com.gree.mall.miniapp.plus.entity.*;
+import com.gree.mall.miniapp.plus.entity.Brand;
+import com.gree.mall.miniapp.plus.entity.Goods;
+import com.gree.mall.miniapp.plus.entity.GoodsCategory;
 import com.gree.mall.miniapp.plus.service.GoodsCategoryService;
 import com.gree.mall.miniapp.plus.service.GoodsService;
 import com.gree.mall.miniapp.plus.service.GoodsTagRelaService;
@@ -16,7 +18,6 @@ import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 
 import javax.servlet.http.HttpServletRequest;
-import java.util.ArrayList;
 import java.util.List;
 import java.util.stream.Collectors;
 
@@ -40,30 +41,13 @@ public class CategoryLogic {
      * 分类列表
      * @return
      */
-    public List<GoodsCategory> list(HttpServletRequest request,String parentId,Integer type,String name,Boolean yjhx){
+    public List<GoodsCategory> list(HttpServletRequest request,String parentId,Integer type,String name){
         CurrentCompanyWechat currentCompanyWechat = commonLogic.getCurrentCompanyWechat(request);
         if(type == null){
             type = 1;
         }
         List<String> parentIds = null;
-        if(yjhx != null && yjhx){
-            //拥有以旧换新商品的子分类id
-            List<Goods> categoryIds2List = goodsService.lambdaQuery()
-                    .select(Goods::getCategoryId)
-                    .eq(Goods::getDel, false)
-                    .eq(Goods::getStatus, true)
-                    .eq(Goods::getCompanyWechatId, currentCompanyWechat.getCurrentCompanyWechatId())
-                    .list();
-            if(CollectionUtils.isEmpty(categoryIds2List)){
-                return new ArrayList<>();
-            }
-            List<String> categoryIds2 = categoryIds2List.stream().map(Goods::getCategoryId).distinct().collect(Collectors.toList());
-            List<GoodsCategory> goodsCategoryList = goodsCategoryService.lambdaQuery().in(GoodsCategory::getCategoryId, categoryIds2).list();
-            if(CollectionUtils.isEmpty(goodsCategoryList)){
-                return new ArrayList<>();
-            }
-            parentIds = goodsCategoryList.stream().map(GoodsCategory::getParentId).distinct().collect(Collectors.toList());
-        }
+
         List<GoodsCategory> list = goodsCategoryService.lambdaQuery()
                 .in(!CollectionUtils.isEmpty(parentIds) && StringUtils.isBlank(parentId),GoodsCategory::getCategoryId,parentIds)
                 .eq(type != null,GoodsCategory::getType,type)

+ 4 - 12
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/utils/CommonUtils.java

@@ -165,19 +165,11 @@ public class CommonUtils {
     }
 
     /**
-     * 获取性别code
-     *
-     * @param gender
-     * @return
+     * 获取storageId
      */
-    public static String getGenderCode(String gender) {
-        if (org.apache.commons.lang3.StringUtils.equals(gender, "男")) {
-            return "1";
-        } else if (org.apache.commons.lang3.StringUtils.equals(gender, "女")) {
-            return "2";
-        }
-        //未知
-        return "0";
+    public static String getStorageId(HttpServletRequest request) {
+        String storageId = request.getHeader("storage_id");
+        return storageId;
     }
 
     public static void downloadFile(String fileName, HttpServletResponse response) throws IOException {