zhijiezhao 1 месяц назад
Родитель
Сommit
b8a1c4f00e

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

@@ -35,7 +35,7 @@ public interface AuthProductMapper {
 
     void insertProductParam(@Param("productId") Integer productId, @Param("paramName") String paramName, @Param("paramContent") String paramContent);
 
-    Integer getProductIdBySnCode(String snCode);
+    Integer getProductIdBySnCode(@Param("snCode") String snCode, @Param("productTypeId") Integer productTypeId);
 
     ProductFormVo getProductFormData(@Param("relationId") Integer relationId);
 

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

@@ -199,7 +199,7 @@ public class AuthProductServiceImpl implements AuthProductService {
         // 当前设备id
         Integer productId = null;
         // 数据库中sn码对应设备id
-        Integer productIdBySnCode = authProductMapper.getProductIdBySnCode(snCode);
+        Integer productIdBySnCode = authProductMapper.getProductIdBySnCode(snCode, productTypeId);
         if (newRelation) {
             // 添加
             if (1 == authType) {
@@ -778,7 +778,7 @@ public class AuthProductServiceImpl implements AuthProductService {
             }
         }
         PageHelper.startPage(pageNum, pageSize);
-        List<WxProductListVo> productList = authProductMapper.getWxProductList(listType, authId, authParty, productTypeId, provinceId, cityId, townId,snCode);
+        List<WxProductListVo> productList = authProductMapper.getWxProductList(listType, authId, authParty, productTypeId, provinceId, cityId, townId, snCode);
         productList.forEach(product -> {
             List<WxClubListVo> clubList = authProductMapper.getProductClubList(product.getProductId());
             product.setClubList(clubList);

+ 98 - 53
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,11 @@
         </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}
+          and productTypeId = #{productTypeId}
+        limit 1
     </select>
     <select id="getProductFormData" resultType="com.caimei.model.vo.ProductFormVo">
         select p.`id`                                                      as productId,
@@ -388,11 +408,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">
@@ -443,7 +464,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
@@ -460,7 +482,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
@@ -472,8 +496,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
@@ -513,7 +538,7 @@
     </select>
 
     <select id="getSnCodeList" resultType="com.caimei.model.vo.ProductListVo">
-        select  p.id as productId,p.productTypeId as productTypeId,t.name as productName,snCode,a.authParty as
+        select p.id as productId,p.productTypeId as productTypeId,t.name as productName,snCode,a.authParty as
         authParty
         from cm_brand_auth_product p
         left join cm_brand_product_relation r on p.id = r.productId
@@ -538,7 +563,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>
@@ -549,24 +574,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">
@@ -574,13 +600,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
@@ -589,16 +629,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="findProductByQr" resultType="java.lang.Integer">
         SELECT cap.id
         FROM cm_brand_auth_product cap
-        LEFT JOIN cm_brand_product_relation cbr ON cap.id = cbr.productId
-        LEFT JOIN cm_brand_auth_qrcode cbq ON cbq.authId = cbr.authId
+                 LEFT JOIN cm_brand_product_relation cbr ON cap.id = cbr.productId
+                 LEFT JOIN cm_brand_auth_qrcode cbq ON cbq.authId = cbr.authId
         WHERE cbq.id = #{substring}
         LIMIT 1
     </select>