Quellcode durchsuchen

正品联盟商品详情接口迁移

Aslee vor 3 Jahren
Ursprung
Commit
847d031073

+ 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);
 }

+ 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

@@ -645,5 +645,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>