123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322 |
- <?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`,
- `originalCertificateImage`,`certificateImage`,`pcCertificateImage`,
- `appletsCertificateImage`, `addQrCodeFlag`,`addTemplateType`, `status`,
- `auditStatus`,`createTime`, `createBy`)
- values (#{authId}, #{brandId}, #{productTypeId}, #{snCode},
- #{originalCertificateImage}, #{certificateImage}, #{pcCertificateImage},
- #{appletsCertificateImage}, #{addQrCodeFlag}, #{addTemplateType}, #{status},
- #{auditStatus}, #{createTime},#{createBy})
- </insert>
- <insert id="insertProductParam">
- insert into cm_brand_product_param (`productId`, `name`, `content`)
- values (#{productId}, #{paramName}, #{paramContent})
- </insert>
- <insert id="insertProductType">
- insert into cm_brand_product_type (authUserId, name, image, pcImage, appletsImage, status, auditStatus, createBy, createTime, delFlag)
- values (#{authUserId}, #{name}, #{image}, #{pcImage}, #{appletsImage}, #{status}, #{auditStatus}, #{createBy}, #{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>
- `status` = #{status},
- `auditStatus` = #{auditStatus},
- </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},
- 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>
- <select id="getProductList" resultType="com.caimei.model.vo.ProductListVo">
- select p.id as productId,t.name as productName,snCode,p.status,p.auditStatus,p.createTime,cu.name as createBy,
- au.name as auditBy,p.auditTime,p.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_auth_user cu on p.createBy = cu.authUserId
- left join cm_brand_auth_user au on p.auditBy = au.authUserId
- where authId = #{authId}
- <if test="productName != null and productName != ''">
- and 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>
- <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>
- <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`,
- p.productTypeId,
- t.name as productName,
- `snCode`,
- t.`image` as productImage,
- `certificateImage`,
- `originalCertificateImage`,
- addQrCodeFlag,
- addTemplateType,
- p.`status`
- 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="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 as productImage,
- 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, t.name as productName,p.snCode,t.image as productImage,a.authParty as clubName
- 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 p.productTypeId = #{productTypeId}
- <if test="snCode != null and snCode != ''">
- and p.snCode like concat('%',#{snCode})
- </if>
- and au.status = 1
- and a.status = 1
- and a.auditStatus = 1
- and p.status = 1
- and p.auditStatus = 1
- 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,t.name as productName,snCode,cb.name as brandName,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 createTime desc
- </select>
- <select id="getAuthProductByProductId" resultType="com.caimei.module.base.entity.vo.AuthProductVo">
- select t.name as productName,
- p.snCode,
- t.pcImage,
- t.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_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
- </select>
- <select id="getStatementFile" resultType="com.caimei.module.base.entity.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.module.base.entity.po.CmBrandProductParamPo">
- select name, content
- 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 id as productTypeId,t.name,t.image,t.status,t.auditStatus,t.createTime,cu.name 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
- 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
- <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 id = #{productTypeId};
- </select>
- <select id="getProductCountByTypeId" resultType="java.lang.Integer">
- select count(*) from cm_brand_auth_product where productTypeId = #{productTypeId}
- </select>
- </mapper>
|