Bladeren bron

Merge remote-tracking branch 'remotes/origin/developer' into developerB

plf 3 jaren geleden
bovenliggende
commit
7cae19eb38

+ 23 - 20
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);
     }
 
     /**
@@ -57,10 +57,13 @@ public class SecondHandApi {
      * @param productId 商品表的商品Id
      */
     @ApiOperation("二手商品详情(旧:/product/getSecondHandProductDetail)")
-    @ApiImplicitParam(required = true, name = "productId", value = "商品Id")
+    @ApiImplicitParams({
+            @ApiImplicitParam(required = true, name = "userId", value = "机构用户id"),
+            @ApiImplicitParam(required = true, name = "productId", value = "商品Id")
+    })
     @GetMapping("detail")
-    public ResponseJson<SecondDetailVo> getSecondDetail(Integer productId) {
-        return secondHandService.getSecondHandDetail(productId);
+    public ResponseJson<SecondDetailVo> getSecondDetail(Integer userId, Integer productId) {
+        return secondHandService.getSecondHandDetail(userId, productId);
     }
 
     /**
@@ -94,7 +97,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 +110,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);
+
     /**
      * 商品品牌列表
      */

+ 97 - 31
src/main/java/com/caimei365/commodity/model/vo/SecondDetailVo.java

@@ -15,69 +15,135 @@ import java.util.List;
 @Data
 public class SecondDetailVo implements Serializable {
     private static final long serialVersionUID = 1L;
-    /** 商品productID */
+    /**
+     * 商品productID
+     */
     private Integer productId;
-    /** 名称name */
+    /**
+     * 名称name
+     */
     private String name;
-    /** 主图mainImage */
+    /**
+     * 主图mainImage
+     */
     private String image;
-    /** 品牌 */
+    /**
+     * 品牌
+     */
     private String brandName;
     private Integer brandId;
-    /** 是否已售 0和空未出售,1已出售 */
+    /**
+     * 是否已售 0和空未出售,1已出售
+     */
     private String sold;
-    /** 是否新上架 0非新上架,1新上架 */
+    /**
+     * 是否新上架 0非新上架,1新上架
+     */
     private String newAdded;
-    /** 是否启用详聊,1不开启,2开启(开启详聊不展示交易价)*/
+    /**
+     * 是否启用详聊,1不开启,2开启(开启详聊不展示交易价)
+     */
     private Integer detailTalkFlag;
-    /** 价格 */
+    /**
+     * 价格
+     */
     private Double price;
-    /** 交易价字符串千分位 */
+    /**
+     * 交易价字符串千分位
+     */
     private String priceStr;
-    /** 上架时间(审核时上架变化、自动下架后再上架变化、手动下架后上架如果不在有效期内才变化) */
+    /**
+     * 上架时间(审核时上架变化、自动下架后再上架变化、手动下架后上架如果不在有效期内才变化)
+     */
     private Date onLineDate;
-    /** 上架时间字符串(年月日) */
+    /**
+     * 上架时间字符串(年月日)
+     */
     private String onLineDateStr;
-    /** 浏览量 */
+    /**
+     * 浏览量
+     */
     private Integer viewingNum;
-    /** 省市区(地址前部分) */
+    /**
+     * 省市区(地址前部分)
+     */
     private String provinceCityDistrict;
-    /** 二手商品列表图片数据集合 */
+    /**
+     * 二手商品列表图片数据集合
+     */
     private List<String> imageList;
 
-    /** 商品类型:0其它类型(默认),1妆字号,2械字号 */
+    /**
+     * 商品类型:0其它类型(默认),1妆字号,2械字号
+     */
     private String productType;
-    /** 二手商品分类,1二手仪1器,2临期产品,3其他 */
+    /**
+     * 二手商品分类,1二手仪1器,2临期产品,3其他
+     */
     private String secondHandType;
-    /** 二手仪器分类的类型,1轻光电、2重光电、3耗材配件(仅适用于二手仪器分类多个用英文逗号分分隔) */
+    /**
+     * 二手仪器分类的类型,1轻光电、2重光电、3耗材配件(仅适用于二手仪器分类多个用英文逗号分分隔)
+     */
     private String instrumentType;
-    /** 商品类型(二手仪器-重光电) */
+    /**
+     * 商品类型(二手仪器-重光电)
+     */
     private String typeStr;
-    /** 品牌信息(品牌描述) */
+    /**
+     * 品牌信息(品牌描述)
+     */
     private String brandInfo;
-    /** 商品详情信息(补充信息) */
+    /**
+     * 商品详情信息(补充信息)
+     */
     private String productDetails;
-    /** 是否已售 0和空未出售,1已出售 */
+    /**
+     * 是否已售 0和空未出售,1已出售
+     */
     private String productQuality;
-    /** 库存 */
+    /**
+     * 库存
+     */
     private Integer stock;
-    /** 市场价 */
+    /**
+     * 市场价
+     */
     private Double normalPrice;
-    /** 市场价价字符串千分位 */
+    /**
+     * 市场价价字符串千分位
+     */
     private String normalPriceStr;
-    /** 采购价/原价(该二手原始购买价格) */
+    /**
+     * 采购价/原价(该二手原始购买价格)
+     */
     private Double originalPrice;
-    /** 采购价/原价(该二手原始购买价格)千分位串 */
+    /**
+     * 采购价/原价(该二手原始购买价格)千分位串
+     */
     private String originalPriceStr;
-    /** 出厂日期格式:2020年6月 */
+    /**
+     * 出厂日期格式:2020年6月
+     */
     private String fixedYears;
-    /** 产品到期日格式:2020年6月(仅适用于临期产品) */
+    /**
+     * 产品到期日格式:2020年6月(仅适用于临期产品)
+     */
     private String maturityYears;
-    /** 是否显示联系人,1不显示,2显示 */
+    /**
+     * 是否显示联系人,1不显示,2显示
+     */
     private String showContactFlag;
-    /** 联系人名字 */
+    /**
+     * 联系人名字
+     */
     private String contactName;
-    /** 联系方式 */
+    /**
+     * 联系方式
+     */
     private String contactMobile;
+    /**
+     * 商品可见度:(3:所有人可见,2:普通机构可见,1:会员机构可见)
+     */
+    private Integer visibility;
 
 }

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

@@ -20,22 +20,24 @@ 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);
 
     /**
      * 获取二手商品详情
      *
+     * @param userId    机构用户id
      * @param productId 商品表的商品Id
      * @return SecondDetailVo
      */
-    ResponseJson<SecondDetailVo> getSecondHandDetail(Integer productId);
+    ResponseJson<SecondDetailVo> getSecondHandDetail(Integer userId, Integer productId);
 
     /**
      * 发布二手商品

+ 25 - 4
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;
@@ -88,12 +97,24 @@ public class SecondHandServiceImpl implements SecondHandService {
     /**
      * 获取二手商品详情
      *
+     * @param userId    机构用户id
      * @param productId 商品表的商品Id
      * @return SecondDetailVo
      */
     @Override
-    public ResponseJson<SecondDetailVo> getSecondHandDetail(Integer productId) {
+    public ResponseJson<SecondDetailVo> getSecondHandDetail(Integer userId, Integer productId) {
+        //0游客,2会员机构,4普通机构
+        Integer userIdentity = 0;
+        if (userId != null && userId > 0) {
+            userIdentity = priceMapper.getIdentityByUserId(userId);
+        }
         SecondDetailVo second = secondHandMapper.getSecondHandDetail(productId);
+        Integer visibility = second.getVisibility();
+        boolean b = userIdentity == 0 && (visibility == 1 || visibility == 2);
+        boolean a = userIdentity == 4 && visibility == 1;
+        if (b || a) {
+            return ResponseJson.error("无权限查看", null);
+        }
         // 优化地址信息
         String provinceCityDistrict = second.getProvinceCityDistrict();
         provinceCityDistrict = provinceCityDistrict.replace("/", "").replace("市辖区", "");
@@ -277,7 +298,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);

+ 1 - 0
src/main/resources/mapper/PageMapper.xml

@@ -112,6 +112,7 @@
             p.bigTypeID as bigTypeId,
             p.smallTypeID as smallTypeId,
             p.tinyTypeID as tinyTypeId,
+            p.visibility as visibility,
             cshd.detailTalkFlag as detailTalkFlag
         from product p
         left join cm_second_hand_detail cshd on p.productID = cshd.productID

+ 7 - 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">
@@ -76,6 +82,7 @@
             p.productType,
             p.stock,
             p.brandID as brandId,
+            p.visibility as visibility,
 	        IF(p.brandID != 161,cb.name ,cshd.brandName) as "brandName",
 	        cb.description as "brandInfo",
 	        cshd.originalPrice,