Bladeren bron

平台审核商品详情,和es单字模糊搜索

ytf 2 jaren geleden
bovenliggende
commit
4d3f199274

+ 590 - 0
b2b2c/b2b2c-web/src/main/java/com/slodon/b2b2c/controller/goods/admin/GoodsAdminSellerController.java

@@ -0,0 +1,590 @@
1
+package com.slodon.b2b2c.controller.goods.admin;
2
+
3
+import com.slodon.b2b2c.core.constant.GoodsCategoryConst;
4
+import com.slodon.b2b2c.core.constant.GoodsConst;
5
+import com.slodon.b2b2c.core.constant.StoreConst;
6
+import com.slodon.b2b2c.core.exception.MallException;
7
+import com.slodon.b2b2c.core.response.JsonResult;
8
+import com.slodon.b2b2c.core.response.PageVO;
9
+import com.slodon.b2b2c.core.response.PagerInfo;
10
+import com.slodon.b2b2c.core.response.SldResponse;
11
+import com.slodon.b2b2c.core.util.AssertUtil;
12
+import com.slodon.b2b2c.core.util.UserUtil;
13
+import com.slodon.b2b2c.core.util.WebUtil;
14
+import com.slodon.b2b2c.goods.example.*;
15
+import com.slodon.b2b2c.goods.pojo.*;
16
+import com.slodon.b2b2c.model.goods.*;
17
+import com.slodon.b2b2c.model.seller.StoreBindCategoryModel;
18
+import com.slodon.b2b2c.model.seller.StoreInnerLabelModel;
19
+import com.slodon.b2b2c.model.seller.StoreLabelBindGoodsModel;
20
+import com.slodon.b2b2c.model.seller.StoreModel;
21
+import com.slodon.b2b2c.seller.example.StoreBindCategoryExample;
22
+import com.slodon.b2b2c.seller.example.StoreInnerLabelExample;
23
+import com.slodon.b2b2c.seller.example.StoreLabelBindGoodsExample;
24
+import com.slodon.b2b2c.seller.pojo.*;
25
+import com.slodon.b2b2c.vo.goods.*;
26
+import com.slodon.b2b2c.vo.seller.StoreCategoryTreeVO;
27
+import io.swagger.annotations.Api;
28
+import io.swagger.annotations.ApiImplicitParam;
29
+import io.swagger.annotations.ApiImplicitParams;
30
+import io.swagger.annotations.ApiOperation;
31
+import org.apache.commons.collections.map.HashedMap;
32
+import org.springframework.util.CollectionUtils;
33
+import org.springframework.web.bind.annotation.GetMapping;
34
+import org.springframework.web.bind.annotation.RequestMapping;
35
+import org.springframework.web.bind.annotation.RequestParam;
36
+import org.springframework.web.bind.annotation.RestController;
37
+
38
+import javax.annotation.Resource;
39
+import javax.servlet.http.HttpServletRequest;
40
+import java.util.ArrayList;
41
+import java.util.List;
42
+import java.util.Map;
43
+
44
+import static com.slodon.b2b2c.core.constant.GoodsConst.TEMPLATE_CONTENT_1;
45
+import static com.slodon.b2b2c.core.constant.GoodsConst.TEMPLATE_CONTENT_2;
46
+
47
+@Api(tags = "admin产品管理")
48
+@RestController
49
+@RequestMapping("v3/goods/admin/seller")
50
+public class GoodsAdminSellerController {
51
+
52
+    //seller商品分类
53
+    @Resource
54
+    private GoodsCategoryModel goodsCategoryModel;
55
+    @Resource
56
+    private StoreBindCategoryModel storeBindCategoryModel;
57
+    @Resource
58
+    private StoreModel storeModel;
59
+
60
+    //seller关联版式
61
+    @Resource
62
+    private GoodsRelatedTemplateModel goodsRelatedTemplateModel;
63
+
64
+    //seller-商品管理
65
+    @Resource
66
+    private GoodsModel goodsModel;
67
+    @Resource
68
+    private GoodsExtendModel goodsExtendModel;
69
+    @Resource
70
+    private GoodsBindLabelModel goodsBindLabelModel;
71
+    @Resource
72
+    private ProductModel productModel;
73
+    @Resource
74
+    private GoodsPictureModel goodsPictureModel;
75
+    @Resource
76
+    private StoreLabelBindGoodsModel storeLabelBindGoodsModel;
77
+
78
+    //seller分类绑定信息
79
+    @Resource
80
+    private GoodsAttributeModel goodsAttributeModel;
81
+    @Resource
82
+    private GoodsAttributeValueModel goodsAttributeValueModel;
83
+    @Resource
84
+    private GoodsCategoryBindAttributeModel goodsCategoryBindAttributeModel;
85
+    @Resource
86
+    private GoodsCategoryBindBrandModel goodsCategoryBindBrandModel;
87
+    @Resource
88
+    private GoodsBrandModel goodsBrandModel;
89
+
90
+    //seller-属性分组
91
+    @Resource
92
+    private GoodsParameterGroupModel goodsParameterGroupModel;
93
+    @Resource
94
+    private GoodsParameterModel goodsParameterModel;
95
+
96
+    //seller-店铺分类管理
97
+    @Resource
98
+    private StoreInnerLabelModel storeInnerLabelModel;
99
+
100
+    //seller-商品标签
101
+    @Resource
102
+    private GoodsLabelModel goodsLabelModel;
103
+
104
+    //seller规格管理
105
+    @Resource
106
+    private GoodsSpecModel goodsSpecModel;
107
+    @Resource
108
+    private GoodsSpecValueModel goodsSpecValueModel;
109
+
110
+    //seller物流运费模板
111
+    @Resource
112
+    private GoodsFreightTemplateModel goodsFreightTemplateModel;
113
+    @Resource
114
+    private GoodsFreightExtendModel goodsFreightExtendModel;
115
+
116
+    @ApiOperation("获取发布商品分类列表")
117
+    @GetMapping("cateList")
118
+    public JsonResult<List<GoodsCategoryListVO>> cateList(HttpServletRequest request,
119
+                                                          @RequestParam(value = "storeId") Long storeId) {
120
+        // Vendor vendor = UserUtil.getUser(request, Vendor.class);
121
+
122
+        //获取店铺信息
123
+        Store storeDb = storeModel.getStoreByStoreId(storeId);
124
+        AssertUtil.notNull(storeDb, "未获取到店铺信息");
125
+        //根据店铺类型获取分类
126
+        List<GoodsCategoryListVO> vos = new ArrayList<>();
127
+        List<GoodsCategory> thirdList = new ArrayList<>();
128
+        if (storeDb.getIsOwnStore().equals(StoreConst.IS_OWN_STORE)) {
129
+            //自营店铺,获取所有可用的分类
130
+            //获取一级分类列表
131
+            GoodsCategoryExample goodsCategoryExample = new GoodsCategoryExample();
132
+            goodsCategoryExample.setState(GoodsCategoryConst.CATEGORY_STATE_1);
133
+            goodsCategoryExample.setGrade(1);
134
+            goodsCategoryExample.setOrderBy("sort asc");
135
+            List<GoodsCategory> cates1 = goodsCategoryModel.getGoodsCategoryList(goodsCategoryExample, null);
136
+            //遍历一级分类列表,根据pid获取二级分类列表
137
+            if (!CollectionUtils.isEmpty(cates1)) {
138
+                for (GoodsCategory goodsCategory : cates1) {
139
+                    GoodsCategoryListVO vo = new GoodsCategoryListVO(goodsCategory);
140
+                    GoodsCategoryExample goodsCategoryExample2 = new GoodsCategoryExample();
141
+                    goodsCategoryExample2.setPid(goodsCategory.getCategoryId());
142
+                    goodsCategoryExample2.setGrade(2);
143
+                    goodsCategoryExample2.setState(GoodsCategoryConst.CATEGORY_STATE_1);
144
+                    goodsCategoryExample2.setOrderBy("sort asc");
145
+                    List<GoodsCategory> cates2 = goodsCategoryModel.getGoodsCategoryList(goodsCategoryExample2, null);
146
+                    List<GoodsCategoryListVO> secondvos = new ArrayList<>();
147
+                    if (!CollectionUtils.isEmpty(cates2)) {
148
+                        for (GoodsCategory category : cates2) {
149
+                            GoodsCategoryListVO secondvo = new GoodsCategoryListVO(category);
150
+                            GoodsCategoryExample goodsCategoryExample3 = new GoodsCategoryExample();
151
+                            goodsCategoryExample3.setPid(category.getCategoryId());
152
+                            goodsCategoryExample3.setGrade(3);
153
+                            goodsCategoryExample3.setState(GoodsCategoryConst.CATEGORY_STATE_1);
154
+                            goodsCategoryExample3.setOrderBy("sort asc");
155
+                            List<GoodsCategory> cates3 = goodsCategoryModel.getGoodsCategoryList(goodsCategoryExample3, null);
156
+                            List<GoodsCategoryListVO> thirdvos = new ArrayList<>();
157
+                            if (!CollectionUtils.isEmpty(cates3)) {
158
+                                for (GoodsCategory category3 : cates3) {
159
+                                    GoodsCategoryListVO thirdvo = new GoodsCategoryListVO(category3);
160
+                                    thirdvos.add(thirdvo);
161
+                                }
162
+                            }
163
+                            secondvo.setChildren(thirdvos);
164
+                            secondvos.add(secondvo);
165
+                        }
166
+                    }
167
+                    vo.setChildren(secondvos);
168
+                    vos.add(vo);
169
+                }
170
+            }
171
+        } else {
172
+            //入驻店铺,获取审核通过的分类
173
+            StoreBindCategoryExample example = new StoreBindCategoryExample();
174
+            example.setStoreId(storeDb.getStoreId());
175
+            example.setState(StoreConst.STORE_CATEGORY_STATE_PASS);
176
+            List<StoreBindCategory> storeBindCategoryList = storeBindCategoryModel.getStoreBindCategoryList(example, null);
177
+            if (!CollectionUtils.isEmpty(storeBindCategoryList)) {
178
+                for (StoreBindCategory storeBindCategory : storeBindCategoryList) {
179
+                    GoodsCategory category3 = goodsCategoryModel.getGoodsCategoryByCategoryId(storeBindCategory.getGoodsCategoryId3());
180
+                    thirdList.add(category3);
181
+                }
182
+            }
183
+            if (!CollectionUtils.isEmpty(thirdList)) {
184
+                Map<Integer, List<GoodsCategoryListVO>> secondMap = new HashedMap();
185
+                thirdList.forEach(goodsCategory -> {
186
+                    if (secondMap.containsKey(goodsCategory.getPid())) {
187
+                        secondMap.get(goodsCategory.getPid()).add(new GoodsCategoryListVO(goodsCategory));
188
+                    } else {
189
+                        List<GoodsCategoryListVO> thirdVos = new ArrayList<>();
190
+                        thirdVos.add(new GoodsCategoryListVO(goodsCategory));
191
+                        secondMap.put(goodsCategory.getPid(), thirdVos);
192
+                    }
193
+                });
194
+                List<GoodsCategoryListVO> secondVos = new ArrayList<>();
195
+                secondMap.forEach((cateId2, cate3List) -> {
196
+                    GoodsCategory goodsCategory2 = goodsCategoryModel.getGoodsCategoryByCategoryId(cateId2);
197
+                    GoodsCategoryListVO vo = new GoodsCategoryListVO(goodsCategory2);
198
+                    vo.setChildren(cate3List);
199
+                    secondVos.add(vo);
200
+                });
201
+                //一级id和二级列表
202
+                Map<Integer, List<GoodsCategoryListVO>> thirdMap = new HashedMap();
203
+                secondVos.forEach(categoryListVO -> {
204
+                    if (thirdMap.containsKey(categoryListVO.getPid())) {
205
+                        thirdMap.get(categoryListVO.getPid()).add(categoryListVO);
206
+                    } else {
207
+                        ArrayList<GoodsCategoryListVO> listVOS = new ArrayList<>();
208
+                        listVOS.add(categoryListVO);
209
+                        thirdMap.put(categoryListVO.getPid(), listVOS);
210
+                    }
211
+                });
212
+                thirdMap.forEach((cateId1, cate2List) -> {
213
+                    GoodsCategory goodCategory1 = goodsCategoryModel.getGoodsCategoryByCategoryId(cateId1);
214
+                    GoodsCategoryListVO vo = new GoodsCategoryListVO(goodCategory1);
215
+                    vo.setChildren(cate2List);
216
+                    vos.add(vo);
217
+                });
218
+            }
219
+        }
220
+        return SldResponse.success(vos);
221
+    }
222
+
223
+    @ApiOperation("关联版式列表")
224
+    @ApiImplicitParams({
225
+            @ApiImplicitParam(name = "templateName", value = "版式名称", paramType = "query"),
226
+            @ApiImplicitParam(name = "templatePosition", value = "版式位置", paramType = "query"),
227
+            @ApiImplicitParam(name = "pageSize", value = "分页大小", defaultValue = "20", paramType = "query"),
228
+            @ApiImplicitParam(name = "current", value = "当前页面位置", defaultValue = "1", paramType = "query")
229
+    })
230
+    @GetMapping("bsList")
231
+    public JsonResult<PageVO<GoodsRelatedTemplateVO>> getBsList(HttpServletRequest request,
232
+                                                              @RequestParam(value = "templateName", required = false) String templateName,
233
+                                                              @RequestParam(value = "templatePosition", required = false) Integer templatePosition,
234
+                                                              @RequestParam(value = "storeId") Long storeId) {
235
+        // Vendor vendor = UserUtil.getUser(request, Vendor.class);
236
+        //分页设置
237
+        PagerInfo pager = WebUtil.handlerPagerInfo(request);
238
+
239
+        //根据条件查询集合
240
+        GoodsRelatedTemplateExample example = new GoodsRelatedTemplateExample();
241
+        example.setStoreId(storeId);
242
+        example.setTemplateNameLike(templateName);
243
+        if (templatePosition != null && (templatePosition == TEMPLATE_CONTENT_1 || templatePosition == TEMPLATE_CONTENT_2)) {
244
+            example.setTemplatePosition(templatePosition);
245
+        }
246
+        List<GoodsRelatedTemplate> list = goodsRelatedTemplateModel.getGoodsRelatedTemplateList(example, pager);
247
+
248
+        //响应
249
+        List<GoodsRelatedTemplateVO> vos = new ArrayList<>();
250
+        if (!CollectionUtils.isEmpty(list)) {
251
+            list.forEach(goodsRelatedTemplate -> {
252
+                GoodsRelatedTemplateVO vo = new GoodsRelatedTemplateVO(goodsRelatedTemplate);
253
+                vos.add(vo);
254
+            });
255
+        }
256
+        return SldResponse.success(new PageVO<>(vos, pager));
257
+    }
258
+
259
+    @ApiOperation("获取商品信息")
260
+    @ApiImplicitParams({
261
+            @ApiImplicitParam(name = "goodsId", value = "商品Id", paramType = "query", required = true),
262
+    })
263
+    @GetMapping("getGoodsInfo")
264
+    public JsonResult<SellerGoodsDetailVO> getGoodsInfo(HttpServletRequest request,
265
+                                                        @RequestParam(value = "goodsId") Long goodsId) {
266
+        Goods goods = goodsModel.getGoodsByGoodsId(goodsId);
267
+        if (goods == null) {
268
+            throw new MallException("商品不存在,请重试!");
269
+        }
270
+        GoodsExtend goodsExtend = goodsExtendModel.getGoodsExtendByGoodsId(goodsId);
271
+        if (goodsExtend == null) {
272
+            throw new MallException("商品不存在,请重试!");
273
+        }
274
+        //商品绑定标签
275
+        GoodsBindLabelExample goodsBindLabelExample = new GoodsBindLabelExample();
276
+        goodsBindLabelExample.setGoodsId(goodsId);
277
+        goodsBindLabelExample.setOrderBy("bind_id asc");
278
+        List<GoodsBindLabel> goodsBindLabelList = goodsBindLabelModel.getGoodsBindLabelList(goodsBindLabelExample, null);
279
+
280
+        //商品绑定店铺内部分类
281
+        StoreLabelBindGoodsExample storeLabelBindGoodsExample = new StoreLabelBindGoodsExample();
282
+        storeLabelBindGoodsExample.setGoodsId(goodsId);
283
+        storeLabelBindGoodsExample.setOrderBy("bind_id asc");
284
+        List<StoreLabelBindGoods> storeLabelBindGoodsList = storeLabelBindGoodsModel.getStoreLabelBindGoodsList(storeLabelBindGoodsExample, null);
285
+
286
+        //正常和禁用的货品
287
+        ProductExample productExample = new ProductExample();
288
+        productExample.setGoodsId(goodsId);
289
+        productExample.setStateIn(GoodsConst.PRODUCT_STATE_1 + "," + GoodsConst.PRODUCT_STATE_2);
290
+        productExample.setOrderBy("product_id asc");
291
+        List<Product> productList = productModel.getProductList(productExample, null);
292
+
293
+        //查询商品图片
294
+        GoodsPictureExample goodsPictureExample = new GoodsPictureExample();
295
+        goodsPictureExample.setGoodsId(goodsId);
296
+        goodsPictureExample.setOrderBy("picture_id asc");
297
+        List<GoodsPicture> goodsPictureList = goodsPictureModel.getGoodsPictureList(goodsPictureExample, null);
298
+
299
+
300
+        SellerGoodsDetailVO sellerGoodsDetailVO = new SellerGoodsDetailVO(goods, goodsExtend, goodsBindLabelList, storeLabelBindGoodsList, goodsPictureList, productList);
301
+        return SldResponse.success(sellerGoodsDetailVO);
302
+    }
303
+
304
+    @ApiOperation("分类绑定的属性,品牌列表")
305
+    @ApiImplicitParams({
306
+            @ApiImplicitParam(name = "categoryId", value = "分类Id", paramType = "query"),
307
+            @ApiImplicitParam(name = "pageSize", value = "20", paramType = "query"),
308
+            @ApiImplicitParam(name = "current", value = "1", paramType = "query")
309
+    })
310
+    @GetMapping("listByCategoryId")
311
+    public JsonResult<GoodsCategoryBindVO> getFlList(HttpServletRequest request,
312
+                                                   @RequestParam(value = "categoryId", required = false) Integer categoryId) {
313
+        AssertUtil.isTrue(categoryId < 1, "分类Id错误");
314
+        GoodsCategoryBindVO goodsCategoryBindVO = new GoodsCategoryBindVO(getBrandList(categoryId), getAttributeList(categoryId));
315
+        return SldResponse.success(goodsCategoryBindVO);
316
+    }
317
+    /**
318
+     * 查询分类绑定的属性列表
319
+     *
320
+     * @param categoryId
321
+     * @return
322
+     */
323
+    private List<GoodsAttributeVO> getAttributeList(Integer categoryId) {
324
+        //查分类绑定的属性表
325
+        GoodsCategoryBindAttributeExample goodsCategoryBindAttributeExample = new GoodsCategoryBindAttributeExample();
326
+        goodsCategoryBindAttributeExample.setCategoryId(categoryId);
327
+        List<GoodsCategoryBindAttribute> goodsCategoryBindAttributeList = goodsCategoryBindAttributeModel.getGoodsCategoryBindAttributeList(goodsCategoryBindAttributeExample, null);
328
+        if (CollectionUtils.isEmpty(goodsCategoryBindAttributeList)) {
329
+            return new ArrayList<>();
330
+        }
331
+
332
+        StringBuffer attributeIds = new StringBuffer();
333
+        goodsCategoryBindAttributeList.forEach(goodsCategoryBindAttribute -> {
334
+            attributeIds.append(",").append(goodsCategoryBindAttribute.getAttributeId());
335
+        });
336
+        //查属性表中的对应属性
337
+        GoodsAttributeExample goodsAttributeExample = new GoodsAttributeExample();
338
+        goodsAttributeExample.setAttributeIdIn(attributeIds.toString().substring(1));
339
+        goodsAttributeExample.setIsShow(GoodsConst.IS_ATTRIBUTE_YES);
340
+        goodsAttributeExample.setOrderBy("sort asc, create_time desc");
341
+        List<GoodsAttribute> goodsAttributeList = goodsAttributeModel.getGoodsAttributeList(goodsAttributeExample, null);
342
+        if (CollectionUtils.isEmpty(goodsAttributeList)) {
343
+            return new ArrayList<>();
344
+        }
345
+
346
+        List<GoodsAttributeVO> vos = new ArrayList<>();
347
+
348
+        goodsAttributeList.forEach(attribute -> {
349
+            //查属性值表
350
+            GoodsAttributeValueExample goodsAttributeValueExample = new GoodsAttributeValueExample();
351
+            goodsAttributeValueExample.setAttributeId(attribute.getAttributeId());
352
+            List<GoodsAttributeValue> goodsAttributeValueList = goodsAttributeValueModel.getGoodsAttributeValueList(goodsAttributeValueExample, null);
353
+
354
+            GoodsAttributeVO vo = new GoodsAttributeVO(attribute, goodsAttributeValueList);
355
+            vos.add(vo);
356
+        });
357
+
358
+        return vos;
359
+    }
360
+
361
+    /**
362
+     * 查询分类绑定的品牌
363
+     *
364
+     * @param categoryId
365
+     * @return
366
+     */
367
+    private List<GoodsBrandVO> getBrandList(Integer categoryId) {
368
+        GoodsCategoryBindBrandExample goodsCategoryBindBrandExample = new GoodsCategoryBindBrandExample();
369
+        goodsCategoryBindBrandExample.setCategoryId(categoryId);
370
+        List<GoodsCategoryBindBrand> goodsCategoryBindBrandList = goodsCategoryBindBrandModel.getGoodsCategoryBindBrandList(goodsCategoryBindBrandExample, null);
371
+
372
+        if (CollectionUtils.isEmpty(goodsCategoryBindBrandList)) {
373
+            //未绑定品牌
374
+            return new ArrayList<>();
375
+        }
376
+
377
+        StringBuffer brandIds = new StringBuffer();
378
+        goodsCategoryBindBrandList.forEach(goodsCategoryBindBrand -> {
379
+            brandIds.append(",").append(goodsCategoryBindBrand.getBrandId());
380
+        });
381
+
382
+        GoodsBrandExample goodsBrandExample = new GoodsBrandExample();
383
+        goodsBrandExample.setBrandIdIn(brandIds.toString().substring(1));
384
+        List<GoodsBrand> brandList = goodsBrandModel.getGoodsBrandList(goodsBrandExample, null);
385
+        List<GoodsBrandVO> vos = new ArrayList<>();
386
+        if (!CollectionUtils.isEmpty(brandList)) {
387
+            brandList.forEach(brand -> {
388
+                GoodsBrandVO vo = new GoodsBrandVO(brand);
389
+                vos.add(vo);
390
+            });
391
+        }
392
+        return vos;
393
+    }
394
+
395
+    @ApiOperation("可用属性分组列表")
396
+    @ApiImplicitParams({
397
+            @ApiImplicitParam(name = "pageSize", value = "分页大小", defaultValue = "20", paramType = "query"),
398
+            @ApiImplicitParam(name = "current", value = "当前页面位置", defaultValue = "1", paramType = "query")
399
+    })
400
+    @GetMapping("canUseList")
401
+    public JsonResult<PageVO<GoodsParameterGroupVO>> canUseList(HttpServletRequest request,@RequestParam(value = "storeId") Long storeId) {
402
+        // Vendor vendor = UserUtil.getUser(request, Vendor.class);
403
+
404
+        //分页设置
405
+        PagerInfo pager = WebUtil.handlerPagerInfo(request);
406
+        //根据条件查询集合
407
+        GoodsParameterGroupExample example = new GoodsParameterGroupExample();
408
+        example.setStoreId(storeId);
409
+        example.setIsShow(GoodsConst.IS_ATTRIBUTE_YES);
410
+        example.setOrderBy("sort asc, create_time desc");
411
+        List<GoodsParameterGroup> list = goodsParameterGroupModel.getGoodsParameterGroupList(example, pager);
412
+        List<GoodsParameterGroupVO> vos = new ArrayList<>();
413
+        if (!CollectionUtils.isEmpty(list)) {
414
+            list.forEach(goodsParameterGroup -> {
415
+                GoodsParameterExample parameterExample = new GoodsParameterExample();
416
+                parameterExample.setStoreId(storeId);
417
+                parameterExample.setGroupId(goodsParameterGroup.getGroupId());
418
+                parameterExample.setIsShow(GoodsConst.IS_ATTRIBUTE_YES);
419
+                List<GoodsParameter> parameterList = goodsParameterModel.getGoodsParameterList(parameterExample, null);
420
+                if (CollectionUtils.isEmpty(parameterList)) {
421
+                    pager.setRowsCount(pager.getRowsCount() - 1);
422
+                } else {
423
+                    GoodsParameterGroupVO vo = new GoodsParameterGroupVO(goodsParameterGroup);
424
+                    vos.add(vo);
425
+                }
426
+            });
427
+        }
428
+        return SldResponse.success(new PageVO<>(vos, pager));
429
+    }
430
+
431
+    @ApiOperation("获取店铺分类列表")
432
+    @GetMapping("dpList")
433
+    public JsonResult getDpList(HttpServletRequest request,@RequestParam(value = "storeId") Long storeId) {
434
+        PagerInfo pager = WebUtil.handlerPagerInfo(request);
435
+        // Vendor vendor = UserUtil.getUser(request, Vendor.class);
436
+
437
+        List<StoreCategoryTreeVO> tree = new ArrayList<>();
438
+        StoreInnerLabelExample storeInnerLabelExample = new StoreInnerLabelExample();
439
+        storeInnerLabelExample.setParentInnerLabelId(0);
440
+        storeInnerLabelExample.setStoreId(storeId);
441
+        List<StoreInnerLabel> storeInnerLabelList = storeInnerLabelModel.getStoreInnerLabelList(storeInnerLabelExample, pager);
442
+        generateTree(tree, storeInnerLabelList, 2);
443
+
444
+        return SldResponse.success(tree);
445
+    }
446
+
447
+    /**
448
+     * 递归生成树
449
+     *
450
+     * @param treeList
451
+     * @param data
452
+     * @return
453
+     */
454
+    private List<StoreCategoryTreeVO> generateTree(List<StoreCategoryTreeVO> treeList, List<StoreInnerLabel> data, Integer grade) {
455
+        if (grade > 0) {
456
+            for (StoreInnerLabel storeInnerLabel : data) {
457
+                StoreCategoryTreeVO tree = new StoreCategoryTreeVO();
458
+                tree.setInnerLabelId(storeInnerLabel.getInnerLabelId());
459
+                tree.setInnerLabelName(storeInnerLabel.getInnerLabelName());
460
+                tree.setInnerLabelSort(storeInnerLabel.getInnerLabelSort());
461
+                tree.setIsShow(storeInnerLabel.getIsShow());
462
+                tree.setParentInnerLabelId(storeInnerLabel.getParentInnerLabelId());
463
+                tree.setCreateTime(storeInnerLabel.getCreateTime());
464
+                tree.setUpdateTime(storeInnerLabel.getUpdateTime());
465
+
466
+                StoreInnerLabelExample storeInnerLabelExample = new StoreInnerLabelExample();
467
+                storeInnerLabelExample.setParentInnerLabelId(storeInnerLabel.getInnerLabelId());
468
+                List<StoreCategoryTreeVO> vos = generateTree(new ArrayList<>(),
469
+                        storeInnerLabelModel.getStoreInnerLabelList(storeInnerLabelExample, null), grade - 1);
470
+                if (!CollectionUtils.isEmpty(vos)) {
471
+                    tree.setChildren(vos);
472
+                } else {
473
+                    tree.setChildren(null);
474
+                }
475
+                treeList.add(tree);
476
+            }
477
+        }
478
+        return treeList;
479
+    }
480
+
481
+    @ApiOperation("商品标签列表")
482
+    @ApiImplicitParams({
483
+            @ApiImplicitParam(name = "labelName", value = "标签名称", paramType = "query"),
484
+            @ApiImplicitParam(name = "pageSize", value = "分页大小", defaultValue = "20", paramType = "query"),
485
+            @ApiImplicitParam(name = "current", value = "当前页面位置", defaultValue = "1", paramType = "query")
486
+    })
487
+    @GetMapping("bqList")
488
+    public JsonResult<PageVO<GoodsLabelVO>> getBqList(HttpServletRequest request, String labelName) {
489
+        //分页设置
490
+        PagerInfo pager = WebUtil.handlerPagerInfo(request);
491
+
492
+        //根据标签名称查询商品标签集合
493
+        GoodsLabelExample example = new GoodsLabelExample();
494
+        example.setLabelNameLike(labelName);
495
+        example.setOrderBy("sort asc, create_time desc");
496
+        List<GoodsLabel> list = goodsLabelModel.getGoodsLabelList(example, pager);
497
+
498
+        ArrayList<GoodsLabelVO> vos = new ArrayList<>();
499
+        if (!CollectionUtils.isEmpty(list)) {
500
+            list.forEach(goodsLabel -> {
501
+                GoodsLabelVO vo = new GoodsLabelVO(goodsLabel);
502
+                vos.add(vo);
503
+            });
504
+        }
505
+        return SldResponse.success(new PageVO<>(vos, pager));
506
+    }
507
+
508
+    @ApiOperation("规格列表")
509
+    @ApiImplicitParams({
510
+            @ApiImplicitParam(name = "specName", value = "规则名称", paramType = "query"),
511
+            @ApiImplicitParam(name = "pageSize", value = "20", paramType = "query"),
512
+            @ApiImplicitParam(name = "current", value = "1", paramType = "query")
513
+    })
514
+    @GetMapping("ggList")
515
+    public JsonResult<PageVO<SellerGoodsSpecVO>> getGgList(HttpServletRequest request,
516
+                                                           @RequestParam(value = "storeId") Long storeId,
517
+                                                            @RequestParam(value = "specName", required = false) String specName) {
518
+        // Vendor vendor = UserUtil.getUser(request, Vendor.class);
519
+        PagerInfo pager = WebUtil.handlerPagerInfo(request);
520
+        GoodsSpecValueExample goodsSpecValueExample = new GoodsSpecValueExample();
521
+        GoodsSpecExample goodsSpecExample = new GoodsSpecExample();
522
+        goodsSpecExample.setSpecNameLike(specName);
523
+        goodsSpecExample.setStoreIdOrZero(storeId);
524
+        goodsSpecExample.setPager(pager);
525
+        List<GoodsSpec> goodsSpecList = goodsSpecModel.getGoodsSpecList(goodsSpecExample, pager);
526
+        List<SellerGoodsSpecVO> vos = new ArrayList<>();
527
+        if (!CollectionUtils.isEmpty(goodsSpecList)) {
528
+            goodsSpecList.forEach(spec -> {
529
+                goodsSpecValueExample.setSpecId(spec.getSpecId());
530
+                List<GoodsSpecValue> goodsSpecValueList = goodsSpecValueModel.getGoodsSpecValueList(goodsSpecValueExample, null);
531
+                SellerGoodsSpecVO vo = new SellerGoodsSpecVO(spec, goodsSpecValueList);
532
+                vos.add(vo);
533
+            });
534
+        }
535
+        return SldResponse.success(new PageVO<>(vos, goodsSpecExample.getPager()));
536
+    }
537
+
538
+    @ApiOperation("分类列表,获取当前分类的下级分类,0代表获取所有1级分类")
539
+    @ApiImplicitParams({
540
+            @ApiImplicitParam(name = "categoryId", value = "分类Id", paramType = "query"),
541
+            @ApiImplicitParam(name = "pageSize", value = "20", paramType = "query"),
542
+            @ApiImplicitParam(name = "current", value = "1", paramType = "query")
543
+    })
544
+    @GetMapping("list")
545
+    public JsonResult<PageVO<GoodsCategoryListVO>> getList(HttpServletRequest request,
546
+                                                           @RequestParam(value = "categoryId", required = true) Integer categoryId) {
547
+        PagerInfo pager = WebUtil.handlerPagerInfo(request);
548
+        GoodsCategoryExample goodsCategoryExample = new GoodsCategoryExample();
549
+        goodsCategoryExample.setPid(categoryId);
550
+        goodsCategoryExample.setPager(pager);
551
+        goodsCategoryExample.setOrderBy("sort asc");
552
+        List<GoodsCategory> goodsCategoryList = goodsCategoryModel.getGoodsCategoryList(goodsCategoryExample, pager);
553
+        List<GoodsCategoryListVO> vos = new ArrayList<>();
554
+        AssertUtil.notNull(goodsCategoryList, "未查询到分类");
555
+        for (GoodsCategory goodsCategory : goodsCategoryList) {
556
+            vos.add(new GoodsCategoryListVO(goodsCategory));
557
+        }
558
+        return SldResponse.success(new PageVO<>(vos, goodsCategoryExample.getPager()));
559
+    }
560
+
561
+    @ApiOperation("获取运费模板列表接口")
562
+    @ApiImplicitParams({
563
+            @ApiImplicitParam(name = "templateName", value = "模板名称", paramType = "query"),
564
+            @ApiImplicitParam(name = "pageSize", value = "分页大小", defaultValue = "20", paramType = "query"),
565
+            @ApiImplicitParam(name = "current", value = "当前页面位置", defaultValue = "1", paramType = "query")
566
+    })
567
+    @GetMapping("yfList")
568
+    public JsonResult<PageVO<GoodsFreightTemplateVO>> getYfList(HttpServletRequest request,
569
+                                                                @RequestParam(value = "storeId") Long storeId,
570
+                                                                @RequestParam(value = "templateName", required = false) String templateName) {
571
+        PagerInfo pager = WebUtil.handlerPagerInfo(request);
572
+        // Vendor vendor = UserUtil.getUser(request, Vendor.class);
573
+
574
+        GoodsFreightTemplateExample goodsFreightTemplateExample = new GoodsFreightTemplateExample();
575
+        goodsFreightTemplateExample.setStoreId(storeId);
576
+        goodsFreightTemplateExample.setTemplateNameLike(templateName);
577
+        List<GoodsFreightTemplate> goodsFreightTemplateList = goodsFreightTemplateModel.getGoodsFreightTemplateList(goodsFreightTemplateExample, pager);
578
+        List<GoodsFreightTemplateVO> vos = new ArrayList<>();
579
+        if (!CollectionUtils.isEmpty(goodsFreightTemplateList)) {
580
+            for (GoodsFreightTemplate goodsFreightTemplate : goodsFreightTemplateList) {
581
+                GoodsFreightExtendExample extendExample = new GoodsFreightExtendExample();
582
+                extendExample.setFreightTemplateId(goodsFreightTemplate.getFreightTemplateId());
583
+                goodsFreightTemplate.setFreightExtendList(goodsFreightExtendModel.getGoodsFreightExtendList(extendExample, null));
584
+                GoodsFreightTemplateVO vo = new GoodsFreightTemplateVO(goodsFreightTemplate);
585
+                vos.add(vo);
586
+            }
587
+        }
588
+        return SldResponse.success(new PageVO<>(vos, pager));
589
+    }
590
+}

+ 5 - 1
b2b2c/b2b2c-web/src/main/java/com/slodon/b2b2c/vo/goods/SearchProductVO.java

@@ -80,7 +80,11 @@ public class SearchProductVO implements Serializable {
80 80
     public static BoolQueryBuilder searchIndexAssembling(String searchKeyword) {
81 81
         BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
82 82
         boolQueryBuilder.should(QueryBuilders.matchQuery(SearchProductVO.CONTENT_, searchKeyword).minimumShouldMatch("-49%"));
83
-        boolQueryBuilder.should(QueryBuilders.matchQuery(SearchProductVO.GOODS_NAME_, searchKeyword).minimumShouldMatch("-49%"));
83
+        if(searchKeyword.length()>1){
84
+            boolQueryBuilder.should(QueryBuilders.matchQuery(SearchProductVO.GOODS_NAME_, searchKeyword).minimumShouldMatch("-49%"));
85
+        }else{
86
+            boolQueryBuilder.should(QueryBuilders.wildcardQuery(SearchProductVO.GOODS_NAME_,"*"+searchKeyword+"*"));
87
+        }
84 88
         boolQueryBuilder.should(QueryBuilders.matchQuery(SearchProductVO.BRAND_NAME_, searchKeyword).minimumShouldMatch("-49%"));
85 89
         boolQueryBuilder.should(QueryBuilders.matchQuery(SearchProductVO.STORE_NAME_, searchKeyword).minimumShouldMatch("-49%"));
86 90
         boolQueryBuilder.should(QueryBuilders.matchQuery(SearchProductVO.CATEGORY_NAME_, searchKeyword).minimumShouldMatch("-49%"));