Quellcode durchsuchen

二手商品增加商品可见度

plf vor 3 Jahren
Ursprung
Commit
dcf997b612

+ 17 - 17
src/main/java/com/caimei365/commodity/controller/SecondHandApi.java

@@ -13,7 +13,6 @@ import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
 import lombok.RequiredArgsConstructor;
-import org.apache.commons.lang.StringUtils;
 import org.springframework.http.HttpHeaders;
 import org.springframework.web.bind.annotation.*;
 
@@ -25,7 +24,7 @@ import java.util.List;
  * @author : Charles
  * @date : 2021/4/14
  */
-@Api(tags="二手商品API")
+@Api(tags = "二手商品API")
 @RestController
 @RequiredArgsConstructor
 @RequestMapping("/commodity/second")
@@ -38,17 +37,18 @@ public class SecondHandApi {
      */
     @ApiOperation("二手商品列表(旧:/product/getSecondHandProductList)")
     @ApiImplicitParams({
-        @ApiImplicitParam(required = false, name = "secondHandType", value = "二手商品分类,1二手仪器,2临期产品,3其他"),
-        @ApiImplicitParam(required = false, name = "instrumentType", value = "二手仪器分类的类型,1轻光电、2重光电、3耗材配件"),
-        @ApiImplicitParam(required = false, name = "name", value = "二手商品名称搜索关键词"),
-        @ApiImplicitParam(required = false, name = "pageNum", value = "页码"),
-        @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量")
+            @ApiImplicitParam(required = false, name = "userId", value = "机构用户id"),
+            @ApiImplicitParam(required = false, name = "secondHandType", value = "二手商品分类,1二手仪器,2临期产品,3其他"),
+            @ApiImplicitParam(required = false, name = "instrumentType", value = "二手仪器分类的类型,1轻光电、2重光电、3耗材配件"),
+            @ApiImplicitParam(required = false, name = "name", value = "二手商品名称搜索关键词"),
+            @ApiImplicitParam(required = false, name = "pageNum", value = "页码"),
+            @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量")
     })
     @GetMapping("list")
-    public ResponseJson<PaginationVo<SecondListVo>> getSecondHandList(Integer secondHandType, Integer instrumentType, String name,
+    public ResponseJson<PaginationVo<SecondListVo>> getSecondHandList(Integer userId, Integer secondHandType, Integer instrumentType, String name,
                                                                       @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
                                                                       @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
-        return secondHandService.getSecondHandList(secondHandType, instrumentType, name, pageNum, pageSize);
+        return secondHandService.getSecondHandList(userId, secondHandType, instrumentType, name, pageNum, pageSize);
     }
 
     /**
@@ -94,7 +94,7 @@ public class SecondHandApi {
     @ApiOperation("发布二手商品(旧:/product/releaseSecondHandProduct)")
     @Idempotent(prefix = "idempotent_secondhand", keys = {"#secondDto"}, expire = 5)
     @PostMapping("/release")
-    public ResponseJson releaseSecondHand(SecondDto secondDto, @RequestHeader HttpHeaders headers){
+    public ResponseJson releaseSecondHand(SecondDto secondDto, @RequestHeader HttpHeaders headers) {
         return secondHandService.releaseSecondHand(secondDto, headers);
     }
 
@@ -107,16 +107,16 @@ public class SecondHandApi {
      */
     @ApiOperation("二手下单页面商品(旧:/product/getOrderSecondHandProductList)")
     @ApiImplicitParams({
-        @ApiImplicitParam(required = false, name = "searchKeyword", value = "二手商品搜索关键词"),
-        @ApiImplicitParam(required = false, name = "secondHandType", value = "二手商品分类,1二手仪器,2临期产品,3其他"),
-        @ApiImplicitParam(required = false, name = "instrumentType", value = "二手仪器分类的类型,1轻光电、2重光电、3耗材配件"),
-        @ApiImplicitParam(required = false, name = "pageNum", value = "页码"),
-        @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量")
+            @ApiImplicitParam(required = false, name = "searchKeyword", value = "二手商品搜索关键词"),
+            @ApiImplicitParam(required = false, name = "secondHandType", value = "二手商品分类,1二手仪器,2临期产品,3其他"),
+            @ApiImplicitParam(required = false, name = "instrumentType", value = "二手仪器分类的类型,1轻光电、2重光电、3耗材配件"),
+            @ApiImplicitParam(required = false, name = "pageNum", value = "页码"),
+            @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量")
     })
     @GetMapping("order/products")
     public ResponseJson<PaginationVo<SecondListVo>> getOrderPageSecondList(String searchKeyword, Integer secondHandType, Integer instrumentType,
-                                                                      @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
-                                                                      @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
+                                                                           @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
+                                                                           @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
         return secondHandService.getOrderPageSecondList(searchKeyword, secondHandType, instrumentType, pageNum, pageSize);
     }
 

+ 19 - 4
src/main/java/com/caimei365/commodity/mapper/SecondHandMapper.java

@@ -8,6 +8,7 @@ import com.caimei365.commodity.model.vo.BrandVo;
 import com.caimei365.commodity.model.vo.SecondDetailVo;
 import com.caimei365.commodity.model.vo.SecondListVo;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -21,39 +22,50 @@ import java.util.List;
 public interface SecondHandMapper {
     /**
      * 二手商品列表
-     * @param secondHandType  二手商品分类,1二手仪器,2临期产品,3其他
-     * @param instrumentType  二手仪器分类的类型,1轻光电、2重光电、3耗材配件
-     * @param name            二手商品名称搜索关键词
+     *
+     * @param userIdentity   用户身份
+     * @param secondHandType 二手商品分类,1二手仪器,2临期产品,3其他
+     * @param instrumentType 二手仪器分类的类型,1轻光电、2重光电、3耗材配件
+     * @param name           二手商品名称搜索关键词
      */
-    List<SecondListVo> getSeconHandList(Integer secondHandType, Integer instrumentType, String name);
+    List<SecondListVo> getSeconHandList(@Param("userIdentity") Integer userIdentity, @Param("secondHandType") Integer secondHandType, @Param("instrumentType") Integer instrumentType, @Param("name") String name);
+
     /**
      * 获取二手商品详情
+     *
      * @param productId 商品Id
      */
     SecondDetailVo getSecondHandDetail(Integer productId);
+
     /**
      * 获取二手商品图片
+     *
      * @param productId 商品Id
      */
     List<String> getImageByProductId(Integer productId);
 
     /**
      * 保存商品二手附加详细信息
+     *
      * @param secondPo ProductSecondPo
      */
     void saveSencondHandProduct(ProductSecondPo secondPo);
+
     /**
      * 二手商品通过地址ID获取详细省市区
      */
     AddressVo getAddressInfo(Integer townId);
+
     /**
      * 保存商品图片信息
      */
     void insertProductImage(ProductImagePo imagePo);
+
     /**
      * 保存商品表
      */
     void insertProduct(ProductPo product);
+
     /**
      * 二手下单页面商品
      *
@@ -62,11 +74,14 @@ public interface SecondHandMapper {
      * @param instrumentType 二手仪器分类的类型,1轻光电、2重光电、3耗材配件
      */
     List<SecondListVo> getOrderPageSecondList(String searchKeyword, Integer secondHandType, Integer instrumentType);
+
     /**
      * 获取对应分类的最新10条有效数据
+     *
      * @param secondHandType 二手商品分类,1二手仪器,2临期产品,3其他
      */
     List<SecondListVo> getSecondListByLimit(Integer secondHandType);
+
     /**
      * 商品品牌列表
      */

+ 7 - 6
src/main/java/com/caimei365/commodity/service/SecondHandService.java

@@ -20,14 +20,15 @@ public interface SecondHandService {
     /**
      * 二手商品列表
      *
-     * @param secondHandType  二手商品分类,1二手仪器,2临期产品,3其他
-     * @param instrumentType  二手仪器分类的类型,1轻光电、2重光电、3耗材配件
-     * @param name            二手商品名称搜索关键词
-     * @param pageNum         页码
-     * @param pageSize        每页数量
+     * @param userId         机构用户id
+     * @param secondHandType 二手商品分类,1二手仪器,2临期产品,3其他
+     * @param instrumentType 二手仪器分类的类型,1轻光电、2重光电、3耗材配件
+     * @param name           二手商品名称搜索关键词
+     * @param pageNum        页码
+     * @param pageSize       每页数量
      * @return List<SecondHandVo>
      */
-    ResponseJson<PaginationVo<SecondListVo>> getSecondHandList(Integer secondHandType, Integer instrumentType, String name, int pageNum, int pageSize);
+    ResponseJson<PaginationVo<SecondListVo>> getSecondHandList(Integer userId, Integer secondHandType, Integer instrumentType, String name, int pageNum, int pageSize);
 
     /**
      * 获取二手商品详情

+ 12 - 3
src/main/java/com/caimei365/commodity/service/impl/SecondHandServiceImpl.java

@@ -1,6 +1,7 @@
 package com.caimei365.commodity.service.impl;
 
 import com.caimei365.commodity.components.RedisService;
+import com.caimei365.commodity.mapper.PriceMapper;
 import com.caimei365.commodity.mapper.SecondHandMapper;
 import com.caimei365.commodity.model.ResponseJson;
 import com.caimei365.commodity.model.dto.SecondDto;
@@ -39,11 +40,14 @@ public class SecondHandServiceImpl implements SecondHandService {
     private SecondHandMapper secondHandMapper;
     @Resource
     private RedisService redisService;
+    @Resource
+    private PriceMapper priceMapper;
 
 
     /**
      * 二手商品列表
      *
+     * @param userId         机构用户id
      * @param secondHandType 二手商品分类,1二手仪器,2临期产品,3其他
      * @param instrumentType 二手仪器分类的类型,1轻光电、2重光电、3耗材配件
      * @param name           二手商品名称搜索关键词
@@ -52,9 +56,14 @@ public class SecondHandServiceImpl implements SecondHandService {
      * @return List<SecondHandVo>
      */
     @Override
-    public ResponseJson<PaginationVo<SecondListVo>> getSecondHandList(Integer secondHandType, Integer instrumentType, String name, int pageNum, int pageSize) {
+    public ResponseJson<PaginationVo<SecondListVo>> getSecondHandList(Integer userId, Integer secondHandType, Integer instrumentType, String name, int pageNum, int pageSize) {
+        //0游客,2会员机构,4普通机构
+        Integer userIdentity = 0;
+        if (userId != null && userId > 0) {
+            userIdentity = priceMapper.getIdentityByUserId(userId);
+        }
         PageHelper.startPage(pageNum, pageSize);
-        List<SecondListVo> secondList = secondHandMapper.getSeconHandList(secondHandType, instrumentType, name);
+        List<SecondListVo> secondList = secondHandMapper.getSeconHandList(userIdentity, secondHandType, instrumentType, name);
         if (!CollectionUtils.isEmpty(secondList)) {
             // 初始化商品产品标签
             int initNewNum = 0;
@@ -281,7 +290,7 @@ public class SecondHandServiceImpl implements SecondHandService {
                 // 设置最新标签
                 for (SecondListVo limit : secondLimitTen) {
                     // 是否新上架 0非新上架,1新上架
-                    if (shp.getProductId().equals(limit.getProductId())){
+                    if (shp.getProductId().equals(limit.getProductId())) {
                         shp.setNewAdded(1);
                     } else {
                         shp.setNewAdded(0);

+ 6 - 0
src/main/resources/mapper/SecondHandMapper.xml

@@ -63,6 +63,12 @@
         <if test="name != null and name != ''">
             and p.name like CONCAT('%',#{name},'%')
         </if>
+        <if test="userIdentity == null or userIdentity == 0">
+            AND p.visibility = 3
+        </if>
+        <if test="userIdentity == 4">
+            AND p.visibility IN (2,3)
+        </if>
         order by cshd.onLineDate desc
     </select>
     <select id="getSecondHandDetail" resultType="com.caimei365.commodity.model.vo.SecondDetailVo">