123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427 |
- <?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 into cm_brand_auth_product(`authId`, `brandId`, `productTypeId`, `snCode`, name, image,
- `originalCertificateImage`, `certificateImage`, `pcCertificateImage`,
- `appletsCertificateImage`, `addQrCodeFlag`, `addTemplateType`,
- purchaseWay, invoiceImage, `status`, auditBy, auditTime,
- `auditStatus`, shopAuditStatus, `createTime`, `createBy`, createSource)
- values (#{authId}, #{brandId}, #{productTypeId}, #{snCode}, #{name}, #{image},
- #{originalCertificateImage}, #{certificateImage}, #{pcCertificateImage},
- #{appletsCertificateImage}, #{addQrCodeFlag}, #{addTemplateType},
- #{purchaseWay}, #{invoiceImage}, #{status}, #{auditBy}, #{auditTime},
- #{auditStatus}, #{shopAuditStatus}, #{createTime}, #{createBy}, #{createSource})
- </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, name, image, pcImage, appletsImage, status, auditStatus, auditBy, auditTime, createBy, createSource, createTime, delFlag)
- values (#{authUserId}, #{name}, #{image}, #{pcImage}, #{appletsImage}, #{status}, #{auditStatus}, #{auditBy}, #{auditTime}, #{createBy}, #{createSource}, #{createTime}, 0)
- </insert>
- <update id="updateProductStatusByProductId">
- update cm_brand_auth_product
- set status = #{status}
- where id = #{productId}
- </update>
- <update id="updateProductByProductId">
- update cm_brand_auth_product
- <set>
- `brandId` = #{brandId},
- `productTypeId` = #{productTypeId},
- `snCode` = #{snCode},
- `certificateImage` = #{certificateImage},
- `addQrCodeFlag` = #{addQrCodeFlag},
- `addTemplateType` = #{addTemplateType},
- <if test="originalCertificateImage != null and originalCertificateImage != ''">
- `originalCertificateImage` = #{originalCertificateImage},
- </if>
- <if test="pcCertificateImage != null and pcCertificateImage != ''">
- `pcCertificateImage` = #{pcCertificateImage},
- </if>
- <if test="appletsCertificateImage != null and appletsCertificateImage != ''">
- `appletsCertificateImage` = #{appletsCertificateImage},
- </if>
- <if test="name != null and name != ''">
- name = #{name},
- image = #{image},
- </if>
- <if test="productTypeId != null">
- productTypeId = #{productTypeId},
- name = null,
- image = null,
- </if>
- purchaseWay = #{purchaseWay},
- invoiceImage = #{invoiceImage},
- `status` = #{status},
- `auditStatus` = #{auditStatus},
- `shopAuditStatus` = #{shopAuditStatus},
- </set>
- where id = #{productId};
- </update>
- <update id="updateImageByProductId">
- update cm_brand_auth_product
- set `pcImage` = #{pcImage},
- `appletsImage` = #{appletsImage},
- `pcCertificateImage` = #{pcCertificateImage},
- `appletsCertificateImage` = #{appletsCertificateImage}
- where id = #{productId};
- </update>
- <update id="updateProductAuditStatus">
- update cm_brand_auth_product
- set status = #{status},
- auditStatus = #{auditStatus},
- invalidReason = #{invalidReason},
- auditBy = #{auditBy},
- <if test="productTypeId != null">
- productTypeId = #{productTypeId},
- name = null,
- image = null,
- </if>
- auditTime = #{auditTime}
- where id = #{productId}
- </update>
- <update id="updateCertificateImage">
- update cm_brand_auth_product
- set certificateImage = #{certificateImage},
- pcCertificateImage = #{pcCertificateImage},
- appletsCertificateImage = #{appletsCertificateImage}
- where id = #{productId}
- </update>
- <update id="updateProductType">
- update cm_brand_product_type
- set name = #{name},
- <if test="pcImage != null and pcImage != ''">
- pcImage = #{pcImage},
- </if>
- <if test="appletsImage != null and appletsImage != ''">
- appletsImage = #{appletsImage},
- </if>
- image = #{image},
- status = #{status},
- auditStatus = #{auditStatus}
- where id = #{productTypeId}
- </update>
- <update id="updateProductTypeStatus">
- update cm_brand_product_type
- set status = #{status}
- where id = #{productTypeId}
- </update>
- <update id="updateProductTypeAuditStatus">
- update cm_brand_product_type
- set status = #{status},
- auditStatus = #{auditStatus},
- invalidReason = #{invalidReason},
- auditBy = #{auditBy},
- auditTime = #{auditTime}
- where id = #{productTypeId}
- </update>
- <delete id="deleteProductByProductId">
- delete from cm_brand_auth_product where id = #{productId}
- </delete>
- <delete id="deleteParamsByProductId">
- delete from cm_brand_product_param where productId = #{productId}
- </delete>
- <update id="deleteProductType">
- update cm_brand_product_type set delFlag = 1 where id = #{productTypeId}
- </update>
- <update id="updateProductShopAuditStatus">
- update cm_brand_auth_product
- set shopAuditStatus = #{shopAuditStatus},
- status = #{status},
- auditStatus = #{shopAuditStatus},
- shopInvalidReason = #{shopInvalidReason},
- <if test="productTypeId != null">
- productTypeId = #{productTypeId},
- name = null,
- image = null,
- </if>
- shopAuditBy = #{shopAuditBy},
- shopAuditTime = #{shopAuditTime}
- where id = #{productId}
- </update>
- <select id="getProductList" resultType="com.caimei.model.vo.ProductListVo">
- select p.id as productId,if(p.productTypeId is null,p.name,t.name) as productName,
- snCode,p.status,p.auditStatus,p.shopAuditStatus, p.createTime,
- if(p.createSource = 1,cu.name,cbcu.mobile) as createBy,
- au.name as auditBy,p.auditTime,p.invalidReason,au1.name as shopAuditBy,p.shopAuditTime
- from cm_brand_auth_product p
- left join cm_brand_product_type t on p.productTypeId = t.id and t.delFlag = 0
- left join cm_brand_auth_user cu on p.createBy = cu.authUserId
- 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
- where p.authId = #{authId}
- <if test="productName != null and productName != ''">
- and (t.name like CONCAT('%',#{productName},'%') or t.name like CONCAT('%',#{productName},'%'))
- </if>
- <if test="snCode != null and snCode != ''">
- and snCode like CONCAT('%',#{snCode},'%')
- </if>
- <if test="status != null">
- and p.status = #{status}
- </if>
- <if test="auditStatus != null">
- and p.auditStatus = #{auditStatus}
- </if>
- <if test="1 == listType or 2 == listType">
- and p.shopAuditStatus = 1
- </if>
- <if test="shopAuditStatus != null">
- <if test="0 == shopAuditStatus">
- and p.shopAuditStatus = 2
- </if>
- <if test="1 == shopAuditStatus">
- and (p.shopAuditStatus = 0 or p.shopAuditStatus = 1)
- </if>
- </if>
- <choose>
- <when test="listType == 2">
- order by (case p.auditStatus when 2 then 2 when 0 then 1 else 0 end) desc,p.createTime desc
- </when>
- <when test="listType == 3">
- order by (case p.shopAuditStatus when 2 then 2 when 0 then 1 else 0 end) desc, p.createTime desc
- </when>
- <otherwise>
- order by p.createTime desc
- </otherwise>
- </choose>
- </select>
- <select id="getProductIdBySnCode" resultType="java.lang.Integer">
- select id from cm_brand_auth_product where snCode = #{snCode} limit 1
- </select>
- <select id="getProductFormByProductId" resultType="com.caimei.model.vo.ProductFormVo">
- select p.`id` as productId,
- `authId`,
- `brandId`,
- cb.name as brandName,
- p.productTypeId,
- if(p.productTypeId is null, p.name, t.name) as productName,
- `snCode`,
- if(p.productTypeId is null, p.image, t.image) as productImage,
- `certificateImage`,
- `originalCertificateImage`,
- addQrCodeFlag,
- addTemplateType,
- purchaseWay,
- invoiceImage,
- p.`status`,
- p.auditStatus,
- if(shopAuditStatus = 0,shopInvalidReason,p.invalidReason) as invalidReason
- from cm_brand_auth_product p
- left join cm_brand_product_type t on p.productTypeId = t.id and t.delFlag = 0
- left join cm_brand cb on p.brandId = cb.id
- where p.id = #{productId}
- </select>
- <select id="getParamsByProductId" resultType="com.caimei.model.po.ProductParamPo">
- select `name` as paramName, `content` as paramContent
- from cm_brand_product_param
- where productId = #{productId}
- </select>
- <select id="getProductIdsByAuthId" resultType="java.lang.Integer">
- select id from cm_brand_auth_product where authId = #{authId}
- </select>
- <select id="getImageByProductId" resultType="com.caimei.model.po.ProductPo">
- select t.image as productImage,
- t.pcImage,
- t.appletsImage,
- addQrCodeFlag,
- originalCertificateImage,
- certificateImage,
- pcCertificateImage,
- appletsCertificateImage,
- addQrCodeFlag,
- addTemplateType
- from cm_brand_auth_product p
- left join cm_brand_product_type t on p.productTypeId = t.id and t.delFlag = 0
- where p.id = #{productId}
- </select>
- <select id="getAllImage" resultType="com.caimei.model.po.ProductPo">
- select id as productId,
- image,
- pcImage,
- appletsImage,
- certificateImage,
- pcCertificateImage,
- appletsCertificateImage
- from cm_brand_auth_product
- </select>
- <select id="getWxProductList" resultType="com.caimei.model.vo.WxProductListVo">
- select p.id as productId,
- p.authId,
- if(p.productTypeId is null,p.name,t.name) as productName,
- p.snCode,
- if(p.productTypeId is null,p.image,t.image) as productImage,
- a.authParty as clubName,
- p.auditStatus
- from cm_brand_auth_product p
- left join cm_brand_product_type t on p.productTypeId = t.id and t.delFlag = 0
- left join cm_brand_auth a on p.authId = a.id
- left join cm_brand_auth_user au on a.authUserId = au.authUserId
- <where>
- <if test="listType == 1">
- and p.productTypeId = #{productTypeId}
- and au.status = 1
- and a.status = 1
- and a.auditStatus = 1
- and p.status = 1
- and p.auditStatus = 1
- and t.status = 1
- and t.auditStatus = 1
- </if>
- <if test="snCode != null and snCode != ''">
- and p.snCode like concat('%',#{snCode},'%')
- </if>
- <if test="authId != null">
- and p.authId = #{authId}
- </if>
- <if test="authParty != null and authParty != ''">
- and a.authParty like concat('%',#{authParty},'%')
- </if>
- </where>
- order by p.createTime desc
- </select>
- <select id="getBrandIdByBrandName" resultType="java.lang.Integer">
- select id from cm_brand where name = #{brand}
- </select>
- <select id="getAuthProductList" resultType="com.caimei.model.vo.ProductFormVo">
- select p.id as productId,
- if(p.productTypeId is null,p.name,t.name) as productName,snCode,cb.name as brandName,
- if(p.productTypeId is null,p.image,t.image) as productImage,certificateImage
- from cm_brand_auth_product p
- left join cm_brand_product_type t on p.productTypeId = t.id and t.delFlag = 0
- left join cm_brand cb on p.brandId = cb.id
- where authId = #{authId}
- order by p.createTime desc
- </select>
- <select id="getAuthProductByProductId" resultType="com.caimei.model.vo.AuthProductVo">
- select t.name as productName,
- p.snCode,
- t.image as pcImage,
- t.image as appletsImage,
- p.certificateImage as pcCertificateImage,
- p.certificateImage as 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.manufacturer,
- i.statementType,
- i.statementContent,
- i.statementLink,
- i.statementImage
- from cm_brand_auth_product p
- left join cm_brand_product_type t on p.productTypeId = t.id and t.delFlag = 0
- 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
- and t.status = 1
- and t.auditStatus = 1
- </select>
- <select id="getStatementFile" resultType="com.caimei.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.caimei.model.po.ProductParamPo">
- select name as paramName, content as paramContent
- from cm_brand_product_param
- where productId = #{productId}
- </select>
- <select id="getClubProductList" resultType="com.caimei.model.vo.WxProductListVo">
- select p.id as productId, t.name as productName, p.snCode
- from cm_brand_auth_product p
- left join cm_brand_product_type t on p.productTypeId = t.id and t.delFlag = 0
- where p.authId = #{authId}
- and p.status = 1
- and p.auditStatus = 1
- order by p.createTime desc
- </select>
- <select id="getProductTypeList" resultType="com.caimei.model.vo.ProductTypeListVo">
- select t.id as productTypeId,t.name,t.image,t.status,t.auditStatus,t.createTime,
- if(t.createSource = 1,cu.name,cbcu.mobile) as createBy,
- au.name as auditBy,t.auditTime,t.invalidReason
- from cm_brand_product_type t
- left join cm_brand_auth_user cu on t.createBy = cu.authUserId
- left join cm_brand_auth_user au on t.auditBy = au.authUserId
- left join cm_brand_club_user cbcu on t.createBy = cbcu.id
- where t.authUserId = #{authUserId} and t.delFlag = 0
- <if test="name != null and name != ''">
- and t.name like CONCAT('%',#{name},'%')
- </if>
- <if test="status != null">
- and t.status = #{status}
- </if>
- <if test="auditStatus != null">
- and t.auditStatus = #{auditStatus}
- </if>
- <choose>
- <when test="listType == 2">
- order by (case t.auditStatus when 2 then 2 when 0 then 1 else 0 end) desc,t.createTime desc
- </when>
- <otherwise>
- order by t.createTime desc
- </otherwise>
- </choose>
- </select>
- <select id="getWxProductTypeList" resultType="com.caimei.model.vo.WxProductTypeListVo">
- select t.id as productTypeId,t.name,t.image
- from cm_brand_product_type t
- left join cm_brand_auth_user u on t.authUserId = u.authUserId
- where u.authUserId = #{authUserId} and t.delFlag = 0 and t.status = 1 and auditStatus = 1
- <if test="name != null and name != ''">
- and t.name like concat('%',#{name},'%')
- </if>
- order by t.id desc
- </select>
- <select id="getProductType" resultType="com.caimei.model.po.ProductTypePo">
- select id as productTypeId, name, image, pcImage, appletsImage
- from cm_brand_product_type
- <where>
- <if test="productTypeId != null">
- and id = #{productTypeId}
- </if>
- <if test="productName != null and productName != ''">
- and name = #{productName}
- </if>
- <if test="authUserId != null">
- and authUserId = #{authUserId}
- </if>
- </where>
- limit 1
- </select>
- <select id="getProductCountByTypeId" resultType="java.lang.Integer">
- select count(*) from cm_brand_auth_product where productTypeId = #{productTypeId}
- </select>
- <select id="getProductPo" resultType="com.caimei.model.po.ProductPo">
- select id as productId, productTypeId, name, image, createBy
- from cm_brand_auth_product
- where id = #{productId}
- </select>
- <select id="getAuthUserIdByProductId" resultType="java.lang.Integer">
- select a.authUserId
- from cm_brand_auth_product p
- left join cm_brand_auth a on p.authId = a.id
- where p.id = #{productId}
- </select>
- </mapper>
|