AuthProductMapper.xml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.caimei.mapper.cmMapper.AuthProductMapper">
  4. <insert id="insertProduct" keyColumn="id" keyProperty="productId" useGeneratedKeys="true" parameterType="com.caimei.model.po.ProductPo">
  5. insert into cm_brand_auth_product(`authId`, `brandId`, `productTypeId`, `snCode`,
  6. `originalCertificateImage`,`certificateImage`,`pcCertificateImage`,
  7. `appletsCertificateImage`, `addQrCodeFlag`,`addTemplateType`, `status`,
  8. `auditStatus`,`createTime`, `createBy`)
  9. values (#{authId}, #{brandId}, #{productTypeId}, #{snCode},
  10. #{originalCertificateImage}, #{certificateImage}, #{pcCertificateImage},
  11. #{appletsCertificateImage}, #{addQrCodeFlag}, #{addTemplateType}, #{status},
  12. #{auditStatus}, #{createTime},#{createBy})
  13. </insert>
  14. <insert id="insertProductParam">
  15. insert into cm_brand_product_param (`productId`, `name`, `content`)
  16. values (#{productId}, #{paramName}, #{paramContent})
  17. </insert>
  18. <insert id="insertProductType">
  19. insert into cm_brand_product_type (authUserId, name, image, pcImage, appletsImage, status, auditStatus, createBy, createTime, delFlag)
  20. values (#{authUserId}, #{name}, #{image}, #{pcImage}, #{appletsImage}, #{status}, #{auditStatus}, #{createBy}, #{createTime}, 0)
  21. </insert>
  22. <update id="updateProductStatusByProductId">
  23. update cm_brand_auth_product
  24. set status = #{status}
  25. where id = #{productId}
  26. </update>
  27. <update id="updateProductByProductId">
  28. update cm_brand_auth_product
  29. <set>
  30. `brandId` = #{brandId},
  31. `productTypeId` = #{productTypeId},
  32. `snCode` = #{snCode},
  33. `certificateImage` = #{certificateImage},
  34. `addQrCodeFlag` = #{addQrCodeFlag},
  35. `addTemplateType` = #{addTemplateType},
  36. <if test="originalCertificateImage != null and originalCertificateImage != ''">
  37. `originalCertificateImage` = #{originalCertificateImage},
  38. </if>
  39. <if test="pcCertificateImage != null and pcCertificateImage != ''">
  40. `pcCertificateImage` = #{pcCertificateImage},
  41. </if>
  42. <if test="appletsCertificateImage != null and appletsCertificateImage != ''">
  43. `appletsCertificateImage` = #{appletsCertificateImage},
  44. </if>
  45. `status` = #{status},
  46. `auditStatus` = #{auditStatus},
  47. </set>
  48. where id = #{productId};
  49. </update>
  50. <update id="updateImageByProductId">
  51. update cm_brand_auth_product
  52. set `pcImage` = #{pcImage},
  53. `appletsImage` = #{appletsImage},
  54. `pcCertificateImage` = #{pcCertificateImage},
  55. `appletsCertificateImage` = #{appletsCertificateImage}
  56. where id = #{productId};
  57. </update>
  58. <update id="updateProductAuditStatus">
  59. update cm_brand_auth_product
  60. set status = #{status},
  61. auditStatus = #{auditStatus},
  62. invalidReason = #{invalidReason},
  63. auditBy = #{auditBy},
  64. auditTime = #{auditTime}
  65. where id = #{productId}
  66. </update>
  67. <update id="updateCertificateImage">
  68. update cm_brand_auth_product
  69. set certificateImage = #{certificateImage},
  70. pcCertificateImage = #{pcCertificateImage},
  71. appletsCertificateImage = #{appletsCertificateImage}
  72. where id = #{productId}
  73. </update>
  74. <update id="updateProductType">
  75. update cm_brand_product_type
  76. set name = #{name},
  77. <if test="pcImage != null and pcImage != ''">
  78. pcImage = #{pcImage},
  79. </if>
  80. <if test="appletsImage != null and appletsImage != ''">
  81. appletsImage = #{appletsImage},
  82. </if>
  83. image = #{image},
  84. status = #{status},
  85. auditStatus = #{auditStatus}
  86. where id = #{productTypeId}
  87. </update>
  88. <update id="updateProductTypeStatus">
  89. update cm_brand_product_type
  90. set status = #{status}
  91. where id = #{productTypeId}
  92. </update>
  93. <update id="updateProductTypeAuditStatus">
  94. update cm_brand_product_type
  95. set status = #{status},
  96. auditStatus = #{auditStatus},
  97. invalidReason = #{invalidReason},
  98. auditBy = #{auditBy},
  99. auditTime = #{auditTime}
  100. where id = #{productTypeId}
  101. </update>
  102. <delete id="deleteProductByProductId">
  103. delete from cm_brand_auth_product where id = #{productId}
  104. </delete>
  105. <delete id="deleteParamsByProductId">
  106. delete from cm_brand_product_param where productId = #{productId}
  107. </delete>
  108. <update id="deleteProductType">
  109. update cm_brand_product_type set delFlag = 1 where id = #{productTypeId}
  110. </update>
  111. <select id="getProductList" resultType="com.caimei.model.vo.ProductListVo">
  112. select p.id as productId,t.name as productName,snCode,p.status,p.auditStatus,p.createTime,cu.name as createBy,
  113. au.name as auditBy,p.auditTime,p.invalidReason
  114. from cm_brand_auth_product p
  115. left join cm_brand_product_type t on p.productTypeId = t.id and t.delFlag = 0
  116. left join cm_brand_auth_user cu on p.createBy = cu.authUserId
  117. left join cm_brand_auth_user au on p.auditBy = au.authUserId
  118. where authId = #{authId}
  119. <if test="productName != null and productName != ''">
  120. and t.name like CONCAT('%',#{productName},'%')
  121. </if>
  122. <if test="snCode != null and snCode != ''">
  123. and snCode like CONCAT('%',#{snCode},'%')
  124. </if>
  125. <if test="status != null">
  126. and p.status = #{status}
  127. </if>
  128. <if test="auditStatus != null">
  129. and p.auditStatus = #{auditStatus}
  130. </if>
  131. <choose>
  132. <when test="listType == 2">
  133. order by (case p.auditStatus when 2 then 2 when 0 then 1 else 0 end) desc,p.createTime desc
  134. </when>
  135. <otherwise>
  136. order by p.createTime desc
  137. </otherwise>
  138. </choose>
  139. </select>
  140. <select id="getProductIdBySnCode" resultType="java.lang.Integer">
  141. select id from cm_brand_auth_product where snCode = #{snCode} limit 1
  142. </select>
  143. <select id="getProductFormByProductId" resultType="com.caimei.model.vo.ProductFormVo">
  144. select p.`id` as productId,
  145. `authId`,
  146. `brandId`,
  147. p.productTypeId,
  148. t.name as productName,
  149. `snCode`,
  150. t.`image` as productImage,
  151. `certificateImage`,
  152. `originalCertificateImage`,
  153. addQrCodeFlag,
  154. addTemplateType,
  155. p.`status`
  156. from cm_brand_auth_product p
  157. left join cm_brand_product_type t on p.productTypeId = t.id and t.delFlag = 0
  158. where p.id = #{productId}
  159. </select>
  160. <select id="getParamsByProductId" resultType="com.caimei.model.po.ProductParamPo">
  161. select `name` as paramName, `content` as paramContent
  162. from cm_brand_product_param
  163. where productId = #{productId}
  164. </select>
  165. <select id="getProductIdsByAuthId" resultType="java.lang.Integer">
  166. select id from cm_brand_auth_product where authId = #{authId}
  167. </select>
  168. <select id="getImageByProductId" resultType="com.caimei.model.po.ProductPo">
  169. select t.image as productImage,
  170. t.pcImage,
  171. t.appletsImage,
  172. addQrCodeFlag,
  173. originalCertificateImage,
  174. certificateImage,
  175. pcCertificateImage,
  176. appletsCertificateImage,
  177. addQrCodeFlag,
  178. addTemplateType
  179. from cm_brand_auth_product p
  180. left join cm_brand_product_type t on p.productTypeId = t.id and t.delFlag = 0
  181. where p.id = #{productId}
  182. </select>
  183. <select id="getAllImage" resultType="com.caimei.model.po.ProductPo">
  184. select id as productId,
  185. image as productImage,
  186. pcImage,
  187. appletsImage,
  188. certificateImage,
  189. pcCertificateImage,
  190. appletsCertificateImage
  191. from cm_brand_auth_product
  192. </select>
  193. <select id="getWxProductList" resultType="com.caimei.model.vo.WxProductListVo">
  194. select p.id as productId,p.authId, t.name as productName,p.snCode,t.image as productImage,a.authParty as clubName
  195. from cm_brand_auth_product p
  196. left join cm_brand_product_type t on p.productTypeId = t.id and t.delFlag = 0
  197. left join cm_brand_auth a on p.authId = a.id
  198. left join cm_brand_auth_user au on a.authUserId = au.authUserId
  199. where p.productTypeId = #{productTypeId}
  200. <if test="snCode != null and snCode != ''">
  201. and p.snCode like concat('%',#{snCode})
  202. </if>
  203. and au.status = 1
  204. and a.status = 1
  205. and a.auditStatus = 1
  206. and p.status = 1
  207. and p.auditStatus = 1
  208. order by p.createTime desc
  209. </select>
  210. <select id="getBrandIdByBrandName" resultType="java.lang.Integer">
  211. select id from cm_brand where name = #{brand}
  212. </select>
  213. <select id="getAuthProductList" resultType="com.caimei.model.vo.ProductFormVo">
  214. select p.id as productId,t.name as productName,snCode,cb.name as brandName,t.image as productImage,certificateImage
  215. from cm_brand_auth_product p
  216. left join cm_brand_product_type t on p.productTypeId = t.id and t.delFlag = 0
  217. left join cm_brand cb on p.brandId = cb.id
  218. where authId = #{authId}
  219. order by createTime desc
  220. </select>
  221. <select id="getAuthProductByProductId" resultType="com.caimei.module.base.entity.vo.AuthProductVo">
  222. select t.name as productName,
  223. p.snCode,
  224. t.pcImage,
  225. t.appletsImage,
  226. p.pcCertificateImage,
  227. p.appletsCertificateImage,
  228. p.brandId,
  229. b.authLogo,
  230. b.name as brandName,
  231. c.name as productionPlace,
  232. a.id as authId,
  233. a.authParty,
  234. u.authUserId as authUserId,
  235. u.name as shopName,
  236. u.shopType,
  237. u.qrCodeImage,
  238. i.securityLink,
  239. i.statementType,
  240. i.statementContent,
  241. i.statementLink,
  242. i.statementImage
  243. from cm_brand_auth_product p
  244. left join cm_brand_product_type t on p.productTypeId = t.id and t.delFlag = 0
  245. left join cm_brand_auth a on p.authId = a.id
  246. left join cm_brand_auth_user u on a.authUserId = u.authUserId
  247. left join cm_brand_auth_shop_info i on u.authUserId = i.authUserId and p.brandId = i.brandId
  248. left join cm_brand b on i.brandId = b.id
  249. left join country c on i.countryId = c.countryId
  250. where p.id = #{productId}
  251. and u.status = 1
  252. and a.status = 1
  253. and p.status = 1
  254. and a.auditStatus = 1
  255. and p.auditStatus = 1
  256. </select>
  257. <select id="getStatementFile" resultType="com.caimei.module.base.entity.vo.StatementFileVo">
  258. select name,ossName,md5Hex,uploadTime
  259. from cm_brand_auth_file
  260. where authUserId = #{authUserId}
  261. and brandId = #{brandId}
  262. limit 1
  263. </select>
  264. <select id="getAuthProductParams" resultType="com.caimei.module.base.entity.po.CmBrandProductParamPo">
  265. select name, content
  266. from cm_brand_product_param
  267. where productId = #{productId}
  268. </select>
  269. <select id="getClubProductList" resultType="com.caimei.model.vo.WxProductListVo">
  270. select p.id as productId, t.name as productName, p.snCode
  271. from cm_brand_auth_product p
  272. left join cm_brand_product_type t on p.productTypeId = t.id and t.delFlag = 0
  273. where p.authId = #{authId}
  274. and p.status = 1
  275. and p.auditStatus = 1
  276. order by p.createTime desc
  277. </select>
  278. <select id="getProductTypeList" resultType="com.caimei.model.vo.ProductTypeListVo">
  279. select id as productTypeId,t.name,t.image,t.status,t.auditStatus,t.createTime,cu.name as createBy,
  280. au.name as auditBy,t.auditTime,t.invalidReason
  281. from cm_brand_product_type t
  282. left join cm_brand_auth_user cu on t.createBy = cu.authUserId
  283. left join cm_brand_auth_user au on t.auditBy = au.authUserId
  284. where t.authUserId = #{authUserId} and t.delFlag = 0
  285. <if test="name != null and name != ''">
  286. and t.name like CONCAT('%',#{name},'%')
  287. </if>
  288. <if test="status != null">
  289. and t.status = #{status}
  290. </if>
  291. <if test="auditStatus != null">
  292. and t.auditStatus = #{auditStatus}
  293. </if>
  294. <choose>
  295. <when test="listType == 2">
  296. order by (case t.auditStatus when 2 then 2 when 0 then 1 else 0 end) desc,t.createTime desc
  297. </when>
  298. <otherwise>
  299. order by t.createTime desc
  300. </otherwise>
  301. </choose>
  302. </select>
  303. <select id="getWxProductTypeList" resultType="com.caimei.model.vo.WxProductTypeListVo">
  304. select t.id as productTypeId,t.name,t.image
  305. from cm_brand_product_type t
  306. left join cm_brand_auth_user u on t.authUserId = u.authUserId
  307. where u.authUserId = #{authUserId} and t.delFlag = 0
  308. <if test="name != null and name != ''">
  309. and t.name like concat('%',#{name},'%')
  310. </if>
  311. order by t.id desc
  312. </select>
  313. <select id="getProductType" resultType="com.caimei.model.po.ProductTypePo">
  314. select id as productTypeId, name, image, pcImage, appletsImage
  315. from cm_brand_product_type
  316. where id = #{productTypeId};
  317. </select>
  318. <select id="getProductCountByTypeId" resultType="java.lang.Integer">
  319. select count(*) from cm_brand_auth_product where productTypeId = #{productTypeId}
  320. </select>
  321. </mapper>