zhijiezhao 2 tahun lalu
induk
melakukan
c4ab2d1d36

+ 9 - 3
src/main/java/com/caimei/mapper/cmMapper/AuthProductMapper.java

@@ -54,6 +54,7 @@ public interface AuthProductMapper {
     List<ProductFormVo> getAuthProductList(Integer authId);
 
     void updateCertificateImage(ProductPo product);
+
     void updateAuthImageLogo(ProductPo product);
 
 
@@ -105,8 +106,9 @@ public interface AuthProductMapper {
 
     ProductFormVo getProductInfo(@Param("productId") Integer productId, @Param("snCode") String snCode);
 
-    List<String> getSnCodeList(Integer authUserId, Integer authId,@Param("snCodeList") List<String> snCodeList);
-    List<String> getSnCodeList1(Integer authUserId, Integer authId,String[] relationIdList,@Param("snCodeList") List<String> snCodeList);
+    List<String> getSnCodeList(Integer authUserId, Integer authId, @Param("snCodeList") List<String> snCodeList);
+
+    List<String> getSnCodeList1(Integer authUserId, Integer authId, String[] relationIdList, @Param("snCodeList") List<String> snCodeList);
 
     List<Integer> getAllSn(Integer authId);
 
@@ -118,12 +120,16 @@ public interface AuthProductMapper {
     void addScanCount(Integer productId);
 
     void checkProductType(Integer productTypeId);
+
     //获取关联机构
     String getRelationId(Integer authId);
+
     //根据sn码产品id
-    List<ProductPo> getSnList( @Param("sn") String sn);
+    List<ProductPo> getSnList(@Param("sn") String sn);
 
     List<ProductListVo> getPronductInfo(Integer authId, Integer authUserId);
 
     Integer getNewestRelationId();
+
+    List<String> getAllSnlistByAuthId(Integer authId);
 }

+ 2 - 5
src/main/java/com/caimei/service/auth/impl/AuthProductServiceImpl.java

@@ -975,8 +975,7 @@ public class AuthProductServiceImpl implements AuthProductService {
     @Override
     public ResponseJson<List<String>> getSnCodeList(Integer authUserId, Integer authId) {
         //获取该机构下所有的sn码
-        List<Integer> liallSn = authProductMapper.getAllSn(authId);
-        List<String> allSnlist = authProductMapper.getAllSnlist(liallSn);
+        List<String> allSnlist = authProductMapper.getAllSnlistByAuthId(authId);
         List<String> snCodeList = authProductMapper.getSnCodeList(authUserId, authId, allSnlist);
         return ResponseJson.success(snCodeList);
     }
@@ -990,12 +989,10 @@ public class AuthProductServiceImpl implements AuthProductService {
         if (!"".equals(relationId) && null != relationId) {
             relationIdList = relationId.split(",");
             //获取该机构下所有的sn码
-            List<Integer> liallSn = authProductMapper.getAllSn(authId);
-            List<String> allSnlist = authProductMapper.getAllSnlist(liallSn);
+            List<String> allSnlist = authProductMapper.getAllSnlistByAuthId(authId);
             snCodeList = authProductMapper.getSnCodeList1(authUserId, authId, relationIdList, allSnlist);
         }
         return ResponseJson.success(snCodeList);
-
     }
 
     @Override

+ 105 - 52
src/main/resources/mapper/AuthProductMapper.xml

@@ -1,26 +1,31 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.caimei.mapper.cmMapper.AuthProductMapper">
-    <insert id="insertProduct" keyColumn="id" keyProperty="productId" useGeneratedKeys="true" parameterType="com.caimei.model.po.ProductPo">
+    <insert id="insertProduct" keyColumn="id" keyProperty="productId" useGeneratedKeys="true"
+            parameterType="com.caimei.model.po.ProductPo">
         insert into cm_brand_auth_product(`infoId`, `productTypeId`, `snCode`, name, image, certificateImageType,
                                           `certificateImage`, `pcCertificateImage`,
                                           `appletsCertificateImage`,
                                           purchaseWay, invoiceImage, `status`, auditBy, auditTime,
                                           `auditStatus`, shopAuditStatus, checkFlag, `createTime`, `createBy`,
-                                          createSource,authImageLogo,authDates)
+                                          createSource, authImageLogo, authDates)
         values (#{infoId}, #{productTypeId}, #{snCode}, #{name}, #{image}, #{certificateImageType},
                 #{certificateImage}, #{pcCertificateImage},
                 #{appletsCertificateImage},
                 #{purchaseWay}, #{invoiceImage}, #{status}, #{auditBy}, #{auditTime},
-                #{auditStatus}, #{shopAuditStatus}, #{checkFlag}, #{createTime}, #{createBy}, #{createSource},#{authImageLogo},#{authDate})
+                #{auditStatus}, #{shopAuditStatus}, #{checkFlag}, #{createTime}, #{createBy}, #{createSource},
+                #{authImageLogo}, #{authDate})
     </insert>
     <insert id="insertProductParam">
         insert into cm_brand_product_param (`productId`, `name`, `content`)
         values (#{productId}, #{paramName}, #{paramContent})
     </insert>
-    <insert id="insertProductType" keyColumn="id" keyProperty="productTypeId" useGeneratedKeys="true" parameterType="com.caimei.model.po.ProductTypePo">
-        insert into cm_brand_product_type (authUserId, infoId, name, image, pcImage, appletsImage, status, auditStatus, auditBy, auditTime, createBy, createSource, createTime, checkFlag, delFlag)
-        values (#{authUserId}, #{infoId}, #{name}, #{image}, #{pcImage}, #{appletsImage}, #{status}, #{auditStatus}, #{auditBy}, #{auditTime}, #{createBy}, #{createSource}, #{createTime}, #{checkFlag}, 0)
+    <insert id="insertProductType" keyColumn="id" keyProperty="productTypeId" useGeneratedKeys="true"
+            parameterType="com.caimei.model.po.ProductTypePo">
+        insert into cm_brand_product_type (authUserId, infoId, name, image, pcImage, appletsImage, status, auditStatus,
+                                           auditBy, auditTime, createBy, createSource, createTime, checkFlag, delFlag)
+        values (#{authUserId}, #{infoId}, #{name}, #{image}, #{pcImage}, #{appletsImage}, #{status}, #{auditStatus},
+                #{auditBy}, #{auditTime}, #{createBy}, #{createSource}, #{createTime}, #{checkFlag}, 0)
     </insert>
     <insert id="insertProductTypeParam">
         insert into cm_brand_product_type_param (productTypeId, name, content)
@@ -44,18 +49,18 @@
     <update id="updateProductByProductId">
         update cm_brand_auth_product
         set
-        `infoId`           = #{infoId},
-        `productTypeId`    = #{productTypeId},
-        `snCode`           = #{snCode},
+        `infoId` = #{infoId},
+        `productTypeId` = #{productTypeId},
+        `snCode` = #{snCode},
         `certificateImageType` = #{certificateImageType},
         `certificateImage` = #{certificateImage},
         authImageLogo=#{authImageLogo},
         authDates=#{authDate},
         <if test="pcCertificateImage != null and pcCertificateImage != ''">
-            `pcCertificateImage`      = #{pcCertificateImage},
+            `pcCertificateImage` = #{pcCertificateImage},
         </if>
         <if test="appletsCertificateImage != null and appletsCertificateImage != ''">
-            `appletsCertificateImage`      = #{appletsCertificateImage},
+            `appletsCertificateImage` = #{appletsCertificateImage},
         </if>
         <if test="name != null and name != ''">
             name = #{name},
@@ -66,12 +71,12 @@
             name = null,
             image = null,
         </if>
-        purchaseWay        = #{purchaseWay},
-        invoiceImage       = #{invoiceImage},
-        `status`           = #{status},
-        `auditStatus`      = #{auditStatus},
-        `shopAuditStatus`  = #{shopAuditStatus},
-        checkFlag          = #{checkFlag}
+        purchaseWay = #{purchaseWay},
+        invoiceImage = #{invoiceImage},
+        `status` = #{status},
+        `auditStatus` = #{auditStatus},
+        `shopAuditStatus` = #{shopAuditStatus},
+        checkFlag = #{checkFlag}
         where id = #{productId};
     </update>
     <update id="updateImageByProductId">
@@ -98,15 +103,14 @@
     </update>
     <update id="updateCertificateImage">
         update cm_brand_auth_product
-        set certificateImage = #{certificateImage},
-            pcCertificateImage = #{pcCertificateImage},
+        set certificateImage        = #{certificateImage},
+            pcCertificateImage      = #{pcCertificateImage},
             appletsCertificateImage = #{appletsCertificateImage}
         where id = #{productId}
     </update>
     <update id="updateAuthImageLogo">
         update cm_brand_auth_product
-        set
-            authImageLogo=#{authImageLogo}
+        set authImageLogo=#{authImageLogo}
         where id = #{productId}
     </update>
     <update id="updateProductType">
@@ -140,16 +144,24 @@
         where id = #{productTypeId}
     </update>
     <delete id="deleteProductByProductId">
-        delete from cm_brand_auth_product where id = #{productId}
+        delete
+        from cm_brand_auth_product
+        where id = #{productId}
     </delete>
     <delete id="deleteParamsByProductId">
-        delete from cm_brand_product_param where productId = #{productId}
+        delete
+        from cm_brand_product_param
+        where productId = #{productId}
     </delete>
     <delete id="deleteParamsByProductTypeId">
-        delete from cm_brand_product_type_param where productTypeId = #{productTypeId}
+        delete
+        from cm_brand_product_type_param
+        where productTypeId = #{productTypeId}
     </delete>
     <update id="deleteProductType">
-        update cm_brand_product_type set delFlag = 1 where id = #{productTypeId}
+        update cm_brand_product_type
+        set delFlag = 1
+        where id = #{productTypeId}
     </update>
     <update id="updateProductShopAuditStatus">
         update cm_brand_auth_product
@@ -167,7 +179,9 @@
         where id = #{productId}
     </update>
     <update id="checkAuthProduct">
-        update cm_brand_auth_product set checkFlag = 1 where id = #{productId}
+        update cm_brand_auth_product
+        set checkFlag = 1
+        where id = #{productId}
     </update>
     <update id="updateProductRelation">
         update cm_brand_product_relation
@@ -177,7 +191,9 @@
         where id = #{relationId}
     </update>
     <update id="checkProductType">
-        update cm_brand_product_type set checkFlag = 1 where id = #{productTypeId}
+        update cm_brand_product_type
+        set checkFlag = 1
+        where id = #{productTypeId}
     </update>
     <select id="getProductList" resultType="com.caimei.model.vo.ProductListVo">
         select r.id as relationId,p.id as productId,a.authUserId, if(p.productTypeId is null,p.name,t.name) as
@@ -232,7 +248,10 @@
         </choose>
     </select>
     <select id="getProductIdBySnCode" resultType="java.lang.Integer">
-        select id from cm_brand_auth_product where snCode = #{snCode} limit 1
+        select id
+        from cm_brand_auth_product
+        where snCode = #{snCode}
+        limit 1
     </select>
     <select id="getProductFormData" resultType="com.caimei.model.vo.ProductFormVo">
         select p.`id`                                                      as productId,
@@ -374,11 +393,12 @@
           and p.auditStatus = 1
           and t.status = 1
           and t.auditStatus = 1
-            limit 1
+        limit 1
     </select>
     <select id="getAuthProductParams" resultType="com.caimei.model.po.ProductParamPo">
         select p.name as paramName, p.content as paramContent
-        from cm_brand_product_type_param p left join cm_brand_auth_product ap on p.productTypeId = ap.productTypeId
+        from cm_brand_product_type_param p
+                 left join cm_brand_auth_product ap on p.productTypeId = ap.productTypeId
         where ap.id = #{productId}
     </select>
     <select id="getClubProductList" resultType="com.caimei.model.vo.WxProductListVo">
@@ -429,7 +449,8 @@
         order by t.id desc
     </select>
     <select id="getProductType" resultType="com.caimei.model.po.ProductTypePo">
-        select t.id as productTypeId, infoId, i.brandName, t.name, image, pcImage, appletsImage, t.authUserId, t.auditStatus, createBy
+        select t.id as productTypeId, infoId, i.brandName, t.name, image, pcImage, appletsImage, t.authUserId,
+        t.auditStatus, createBy
         from cm_brand_product_type t left join cm_brand_auth_shop_info i on t.infoId = i.id
         <where>
             t.delFlag = 0
@@ -446,7 +467,9 @@
         limit 1
     </select>
     <select id="getProductCountByTypeId" resultType="java.lang.Integer">
-        select count(*) from cm_brand_auth_product where productTypeId = #{productTypeId}
+        select count(*)
+        from cm_brand_auth_product
+        where productTypeId = #{productTypeId}
     </select>
     <select id="getProductPo" resultType="com.caimei.model.po.ProductPo">
         select id as productId, infoId, productTypeId, name, image, createBy
@@ -458,8 +481,9 @@
         from cm_brand_auth_product p
                  left join cm_brand_product_relation r on p.id = r.productId
                  left join cm_brand_auth a on r.authId = a.id
-        where p.id = #{productId} and a.delFlag = 0
-            limit 1
+        where p.id = #{productId}
+          and a.delFlag = 0
+        limit 1
     </select>
     <select id="getProductTypeParamList" resultType="com.caimei.model.po.ProductParamPo">
         select name as paramName, content as paramContent
@@ -502,7 +526,8 @@
         from cm_brand_auth_product p
         left join cm_brand_product_relation r on p.id = r.productId
         left join cm_brand_auth a on a.id = r.authId
-        where a.authUserId = #{authUserId} and a.delFlag = 0 and (r.authType = 2 or (r.authType = 1 and a.id != #{authId}) ) and p.auditStatus = 1
+        where a.authUserId = #{authUserId} and a.delFlag = 0 and (r.authType = 2 or (r.authType = 1 and a.id !=
+        #{authId}) ) and p.auditStatus = 1
         <if test="snCodeList != null and snCodeList.size>0">
             and p.snCode not in
             <foreach collection="snCodeList" open="(" separator="," close=")" item="sn">
@@ -517,7 +542,8 @@
         left join cm_brand_product_relation r on p.id = r.productId
         left join cm_brand_auth a on a.id = r.authId
         where
-        a.authUserId = #{authUserId} and a.delFlag = 0 and (r.authType = 2 or (r.authType = 1 and a.id != #{authId}) ) and p.auditStatus = 1
+        a.authUserId = #{authUserId} and a.delFlag = 0 and (r.authType = 2 or (r.authType = 1 and a.id != #{authId}) )
+        and p.auditStatus = 1
         <if test="snCodeList != null and snCodeList.size>0">
             and p.snCode not in
             <foreach collection="snCodeList" open="(" separator="," close=")" item="sn">
@@ -525,7 +551,7 @@
             </foreach>
         </if>
         <if test="relationIdList != null and relationIdList.length>0">
-            and   a.id in
+            and a.id in
             <foreach collection="relationIdList" open="(" separator="," close=")" item="reId">
                 #{reId,jdbcType=VARCHAR}
             </foreach>
@@ -536,24 +562,25 @@
         select a.id as authId, a.authParty, a.logo
         from cm_brand_auth a
                  left join cm_brand_product_relation r on a.id = r.authId
-        where r.productId = #{productId} and a.delFlag = 0
+        where r.productId = #{productId}
+          and a.delFlag = 0
     </select>
     <select id="getRelationId" resultType="java.lang.String">
         select a.relationId
         from cm_brand_auth a
-        where a.id=#{authId}
+        where a.id = #{authId}
     </select>
     <select id="getSnList" resultType="com.caimei.model.po.ProductPo">
         select a.id as productId
         from cm_brand_auth_product a
-        where a.snCode=#{sn}
+        where a.snCode = #{sn}
     </select>
-    <select id="getAllSn"  resultType="java.lang.Integer">
+    <select id="getAllSn" resultType="java.lang.Integer">
         select a.productId
         from cm_brand_product_relation a
-        where a.authId=#{authId}
+        where a.authId = #{authId}
     </select>
-    <select id="getAllSnlist"  resultType="java.lang.String">
+    <select id="getAllSnlist" resultType="java.lang.String">
         select a.snCode
         from cm_brand_auth_product a where a.id in
         <foreach collection="productIdList" open="(" separator="," close=")" item="reId">
@@ -561,13 +588,27 @@
         </foreach>
     </select>
     <select id="getPronductInfo" resultType="com.caimei.model.vo.ProductListVo">
-        select r.id as relationId,p.id as productId,a.authUserId, if(p.productTypeId is null,p.name,t.name) as
-                       productName,t.image,
-               snCode,p.status,p.auditStatus,p.shopAuditStatus, p.createTime,
-               if(p.createSource = 1,ifnull(cu.loginAccount, cu.name),cbcu.mobile) as createBy,
-               ifnull(au.loginAccount,au.name) as
-                   auditBy,p.auditTime,p.invalidReason,ifnull(p.shopInvalidReason,p.invalidReason) as shopInvalidReason,
-               ifnull(au1.loginAccount,au1.name) as shopAuditBy, p.shopAuditTime, p.checkFlag, p.scanCount
+        select r.id                                                                  as relationId,
+               p.id                                                                  as productId,
+               a.authUserId,
+               if(p.productTypeId is null, p.name, t.name)                           as
+                                                                                        productName,
+               t.image,
+               snCode,
+               p.status,
+               p.auditStatus,
+               p.shopAuditStatus,
+               p.createTime,
+               if(p.createSource = 1, ifnull(cu.loginAccount, cu.name), cbcu.mobile) as createBy,
+               ifnull(au.loginAccount, au.name)                                      as
+                                                                                        auditBy,
+               p.auditTime,
+               p.invalidReason,
+               ifnull(p.shopInvalidReason, p.invalidReason)                          as shopInvalidReason,
+               ifnull(au1.loginAccount, au1.name)                                    as shopAuditBy,
+               p.shopAuditTime,
+               p.checkFlag,
+               p.scanCount
         from cm_brand_auth_product p
                  left join cm_brand_product_relation r on p.id = r.productId
                  left join cm_brand_auth a on r.authId = a.id and a.delFlag = 0
@@ -576,9 +617,21 @@
                  left join cm_brand_auth_user au on p.auditBy = au.authUserId
                  left join cm_brand_auth_user au1 on p.shopAuditBy = au1.authUserId
                  left join cm_brand_club_user cbcu on p.createBy = cbcu.id and cbcu.delFlag = 0
-        where a.id = #{authId} and a.authUserId=#{authUserId} and p.shopAuditStatus=1
+        where a.id = #{authId}
+          and a.authUserId = #{authUserId}
+          and p.shopAuditStatus = 1
     </select>
     <select id="getNewestRelationId" resultType="java.lang.Integer">
-    select id from cm_brand_product_relation order by id desc limit 1
+        select id
+        from cm_brand_product_relation
+        order by id desc
+        limit 1
+    </select>
+    <select id="getAllSnlistByAuthId" resultType="java.lang.String">
+        SELECT a.snCode
+        FROM cm_brand_auth_product a
+        WHERE a.id IN (SELECT a.productId
+                       FROM cm_brand_product_relation a
+                       WHERE a.authId = #{authId})
     </select>
 </mapper>