Sfoglia il codice sorgente

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

Aslee 3 anni fa
parent
commit
ebdf3a4389

+ 13 - 0
src/main/java/com/caimei365/commodity/controller/ProductPageApi.java

@@ -372,4 +372,17 @@ public class ProductPageApi {
         }
         return pageService.getRechargeGoods(productId);
     }
+
+    /**
+     * 正品联盟商品详情
+     */
+    @ApiOperation("充值商品详情(旧:/product/auth/details)")
+    @ApiImplicitParam(required = false, name = "productId", value = "正品联盟商品Id")
+    @GetMapping("/auth/details")
+    public ResponseJson<AuthProductVo> getAuthProductDetails(Integer productId) {
+        if (null == productId) {
+            return ResponseJson.error("参数异常", null);
+        }
+        return pageService.getAuthProductDetails(productId);
+    }
 }

+ 13 - 0
src/main/java/com/caimei365/commodity/mapper/PageMapper.java

@@ -2,6 +2,7 @@ package com.caimei365.commodity.mapper;
 
 import com.caimei365.commodity.model.po.ArchiveFilePo;
 import com.caimei365.commodity.model.po.ArchivePo;
+import com.caimei365.commodity.model.po.BrandProductParamPo;
 import com.caimei365.commodity.model.search.ProductListVo;
 import com.caimei365.commodity.model.vo.*;
 import org.apache.ibatis.annotations.Mapper;
@@ -316,4 +317,16 @@ public interface PageMapper {
      * 查询首页直播宣传图
      */
     String getLiveAdvertisingImage();
+    /**
+     * 查询正品联盟商品详情
+     */
+    AuthProductVo getAuthProductByProductId(Integer productId);
+    /**
+     * 查询正品联盟声明文件
+     */
+    StatementFileVo getStatementFile(Integer authUserId, Integer brandId);
+    /**
+     * 查询正品联盟商品参数
+     */
+    List<BrandProductParamPo> getAuthProductParams(Integer productId);
 }

+ 0 - 1
src/main/java/com/caimei365/commodity/mapper/SearchMapper.java

@@ -248,5 +248,4 @@ public interface SearchMapper {
     List<Integer> findPromotion(List<Integer> productIds);
 
     List<Integer> findPromotionId(Integer p_id);
-
 }

+ 22 - 0
src/main/java/com/caimei365/commodity/model/po/BrandProductParamPo.java

@@ -0,0 +1,22 @@
+package com.caimei365.commodity.model.po;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @author Aslee
+ */
+@Data
+public class BrandProductParamPo implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 商品参数名称
+     */
+    private String name;
+    /**
+     * 商品参数内容
+     */
+    private String content;
+}

+ 116 - 0
src/main/java/com/caimei365/commodity/model/vo/AuthProductVo.java

@@ -0,0 +1,116 @@
+package com.caimei365.commodity.model.vo;
+
+import com.caimei365.commodity.model.po.BrandProductParamPo;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * @author Aslee
+ */
+@Data
+public class AuthProductVo implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 商品名称
+     */
+    private String productName;
+    /**
+     * 商品SN码
+     */
+    private String snCode;
+    /**
+     * 商品图片
+     */
+    private String productImage;
+    /**
+     * 供应商公众号二维码图片
+     */
+    private String qrCodeImage;
+    /**
+     * 授权牌照
+     */
+    private String certificateImage;
+    /**
+     * 品牌授权Id
+     */
+    private Integer authId;
+    /**
+     * 品牌授权logo
+     */
+    private String authLogo;
+    /**
+     * 品牌Id
+     */
+    private Integer brandId;
+    /**
+     * 品牌名称
+     */
+    private String brandName;
+    /**
+     * 产地
+     */
+    private String productionPlace;
+    /**
+     * 防伪链接
+     */
+    private String securityLink;
+    /**
+     * 供应商类型:1品牌方,2代理商
+     */
+    private Integer shopType;
+    /**
+     * 供应商名称
+     */
+    private String shopName;
+    /**
+     * 供应商用户id
+     */
+    private Integer authUserId;
+    /**
+     * 声明类型:1弹窗声明,2链接声明
+     */
+    private Integer statementType;
+    /**
+     * 声明弹窗内容
+     */
+    private String statementContent;
+    /**
+     * 声明链接
+     */
+    private String statementLink;
+    /**
+     * 声明图片
+     */
+    private String statementImage;
+    /**
+     * 声明文件
+     */
+    private StatementFileVo statementFile;
+    /**
+     * 被授权方
+     */
+    private String authParty;
+    /**
+     * 商品参数
+     */
+    private List<BrandProductParamPo> paramList;
+    /**
+     * pc商品图片(含水印)
+     */
+    private String pcImage;
+    /**
+     * 小程序商品图片(含水印)
+     */
+    private String appletsImage;
+    /**
+     * pc授权牌照图片(含水印)
+     */
+    private String pcCertificateImage;
+    /**
+     * 小程序授权牌照图片(含水印)
+     */
+    private String appletsCertificateImage;
+}

+ 45 - 0
src/main/java/com/caimei365/commodity/model/vo/StatementFileVo.java

@@ -0,0 +1,45 @@
+package com.caimei365.commodity.model.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * @author Aslee
+ */
+@Data
+public class StatementFileVo implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    private Integer id;
+    /**
+     * 对应cm_brand_auth表id
+     */
+    private Integer brandAuthId;
+
+    /**
+     * 声明文件名称
+     */
+    private String name;
+
+    /**
+     * oss存储名
+     */
+    private String ossName;
+
+    /**
+     * 文件唯一标识
+     */
+    private String md5Hex;
+
+    /**
+     * 上传时间
+     */
+    private Date uploadTime;
+
+    /**
+     * 访问声明文件链接
+     */
+    private String url;
+}

+ 7 - 0
src/main/java/com/caimei365/commodity/service/PageService.java

@@ -192,4 +192,11 @@ public interface PageService {
      * @param productId 商品id
      */
     ResponseJson<ProductDetailVo> getRechargeGoods(Integer productId);
+
+    /**
+     * 正品联盟商品详情
+     * @param productId     正品联盟商品Id
+     * @return
+     */
+    ResponseJson<AuthProductVo> getAuthProductDetails(Integer productId);
 }

+ 22 - 0
src/main/java/com/caimei365/commodity/service/impl/PageServiceImpl.java

@@ -1172,4 +1172,26 @@ public class PageServiceImpl implements PageService {
         product.setMainImage(ImageUtils.getImageURL("product", product.getMainImage(), 0, domain));
         return ResponseJson.success(product);
     }
+
+    @Override
+    public ResponseJson<AuthProductVo> getAuthProductDetails(Integer productId) {
+        AuthProductVo authProduct = pageMapper.getAuthProductByProductId(productId);
+        if (null == authProduct) {
+            return ResponseJson.error("商品不存在", null);
+        }
+        // 代理声明文件
+        if (null != authProduct.getStatementType() && authProduct.getStatementType() == 4) {
+            StatementFileVo statementFile = pageMapper.getStatementFile(authProduct.getAuthUserId(), authProduct.getBrandId());
+            OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
+            // 设置URL过期时间为1个小时
+            Date expiration = new Date(System.currentTimeMillis() + 3600L * 1000);
+            String url = ossClient.generatePresignedUrl(bucketName, active + "/authFile/" + statementFile.getOssName(), expiration).toString();
+            statementFile.setUrl(url);
+            ossClient.shutdown();
+            authProduct.setStatementFile(statementFile);
+        }
+        // 商品参数
+        authProduct.setParamList(pageMapper.getAuthProductParams(productId));
+        return ResponseJson.success(authProduct);
+    }
 }

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

@@ -642,5 +642,47 @@
     <select id="getLiveAdvertisingImage" resultType="java.lang.String">
         SELECT advertisingImage FROM new_page_live_advertising_image LIMIT 1;
     </select>
+    <select id="getAuthProductByProductId" resultType="com.caimei365.commodity.model.vo.AuthProductVo">
+        select p.name  as productName,
+               p.snCode,
+               p.pcImage,
+               p.appletsImage,
+               p.pcCertificateImage,
+               p.appletsCertificateImage,
+               p.brandId,
+               b.authLogo,
+               b.name  as brandName,
+               c.name  as productionPlace,
+               a.id    as authId,
+               a.authParty,
+               u.authUserId as authUserId,
+               u.name  as shopName,
+               u.shopType,
+               u.qrCodeImage,
+               i.securityLink,
+               i.statementType,
+               i.statementContent,
+               i.statementLink,
+               i.statementImage
+        from cm_brand_auth_product p
+                 left join cm_brand_auth a on p.authId = a.id
+                 left join cm_brand_auth_user u on a.authUserId = u.authUserId
+                 left join cm_brand_auth_shop_info i on u.authUserId = i.authUserId and p.brandId = i.brandId
+                 left join cm_brand b on i.brandId = b.id
+                 left join country c on i.countryId = c.countryId
+        where p.id = #{productId} and u.status = 1 and a.status = 1 and p.status = 1 and a.auditStatus = 1 and p.auditStatus = 1
+    </select>
+    <select id="getStatementFile" resultType="com.caimei365.commodity.model.vo.StatementFileVo">
+        select name,ossName,md5Hex,uploadTime
+        from cm_brand_auth_file
+        where authUserId = #{authUserId}
+          and brandId = #{brandId}
+        limit 1
+    </select>
+    <select id="getAuthProductParams" resultType="com.caimei365.commodity.model.po.BrandProductParamPo">
+        select name, content
+        from cm_brand_product_param
+        where productId = #{productId}
+    </select>
 
 </mapper>

+ 11 - 7
src/main/resources/mapper/SearchMapper.xml

@@ -38,7 +38,7 @@
         left join shop as sh on p.shopID = sh.shopID
     </sql>
     <select id="searchProductById" resultType="com.caimei365.commodity.model.search.ProductDO">
-        select <include refid="Search_Product_List"/>, p.productCategory
+        select<include refid="Search_Product_List"/>, p.productCategory
         from product p
         <include refid="Product_Joins"/>
         where p.validFlag in (2,3,9) and p.productCategory = 1
@@ -527,11 +527,15 @@
         and cp.delflag = 0
     </select>
     <select id="findPromotionId" resultType="java.lang.Integer">
-        select cpp.promotionsId
-        from cm_promotions_product cpp
-        left join cm_promotions cp on cp.id=cpp.promotionsId
-        where cpp.productId = #{p_id}
-        and cp.endTime>now() or (cp.status='1')
-        and cp.delflag = 0
+        select pr.id
+        from cm_promotions pr
+                 left join cm_promotions_product prp on pr.id = prp.promotionsId
+        where (prp.productId = #{p_id} or
+               prp.supplierId = (select p.shopID from product p where p.productID = #{p_id})
+            )
+          and (pr.status = 1 or (pr.status = 2 and (NOW() between pr.beginTime and pr.endTime)))
+          and pr.delFlag not in (1, 2)
+        order by pr.type desc
+        limit 1
     </select>
 </mapper>