ShopMapper.xml 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  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.ShopMapper">
  4. <insert id="insertStatementFile" keyColumn="id" keyProperty="id" useGeneratedKeys="true" parameterType="com.caimei.model.po.CmBrandAuthFilePo">
  5. insert into cm_brand_auth_file (`authUserId`, `brandId`, `name`, `ossName`, `md5Hex`, `uploadTime`)
  6. values (#{authUserId}, #{brandId}, #{name}, #{ossName}, #{md5Hex}, #{uploadTime})
  7. </insert>
  8. <insert id="insertShop" keyColumn="authUserId" keyProperty="authUserId" useGeneratedKeys="true" parameterType="com.caimei.model.po.UserPo">
  9. insert into cm_brand_auth_user (`name`, cmShopId, `mobile`, `password`, `linkMan`, `userIdentity`, `shopType`, `logo`, `qrCodeImage`, `wxAccountType`, `appId`, `appSecret`, `createTime`,
  10. `createBy`,`status`)
  11. values (#{name}, #{cmShopId}, #{mobile}, #{password}, #{linkMan}, #{userIdentity}, #{shopType}, #{logo}, #{qrCodeImage}, #{wxAccountType}, #{appId}, #{appSecret}, #{createTime}, #{createBy}, #{status});
  12. </insert>
  13. <insert id="insertShopInfo">
  14. insert into cm_brand_auth_shop_info (authUserId, brandName, brandLogo, producePlace, manufacturer)
  15. values (#{authUserId}, #{brandName}, #{brandLogo}, #{producePlace}, #{manufacturer})
  16. </insert>
  17. <update id="updateShopStatusByUserId">
  18. update cm_brand_auth_user
  19. set status = #{status}
  20. where authUserId = #{authUserId};
  21. </update>
  22. <update id="updateBrandAuthLogo">
  23. update cm_brand
  24. set authLogo = #{brandAuthLogo}
  25. where id = #{brandId}
  26. </update>
  27. <update id="updateFileUserId">
  28. update cm_brand_auth_file
  29. set authUserId =#{authUserId}
  30. where id = #{statementFileId};
  31. </update>
  32. <update id="updateShopByUserId">
  33. update cm_brand_auth_user
  34. set cmShopId = #{cmShopId},
  35. name = #{name},
  36. shopType = #{shopType},
  37. `mobile` = #{mobile},
  38. `linkMan` = #{linkMan},
  39. `status` = #{status},
  40. `logo` = #{logo},
  41. `qrCodeImage` = #{qrCodeImage},
  42. `wxAccountType` = #{wxAccountType},
  43. `appId` = #{appId},
  44. `appSecret` = #{appSecret}
  45. where authUserId = #{authUserId}
  46. </update>
  47. <update id="updateShopInfo">
  48. update cm_brand_auth_shop_info
  49. set brandName = #{brandName},
  50. brandLogo = #{brandLogo},
  51. producePlace = #{producePlace},
  52. manufacturer = #{manufacturer}
  53. where id = #{infoId}
  54. </update>
  55. <update id="handleFeedback">
  56. update cm_brand_club_feedback
  57. set handleResult = #{handleResult},
  58. handleStatus = 1,
  59. handleTime = NOW()
  60. where id = #{feedbackId}
  61. </update>
  62. <update id="updateShopMobile">
  63. update cm_brand_auth_user
  64. set mobile = #{newMobile}
  65. where authUserId = #{authUserId}
  66. </update>
  67. <update id="bindLoginAccount">
  68. update cm_brand_auth_user
  69. set loginAccount = #{loginAccount}
  70. where authUserId = #{authUserId}
  71. </update>
  72. <update id="updateShopLinkMan">
  73. update cm_brand_auth_user
  74. set linkMan = #{linkMan}
  75. where authUserId = #{authUserId}
  76. </update>
  77. <update id="updateShopLogo">
  78. update cm_brand_auth_user
  79. set logo = #{logo}
  80. where authUserId = #{authUserId}
  81. </update>
  82. <delete id="deleteStatementFile">
  83. delete from cm_brand_auth_file where id = #{id}
  84. </delete>
  85. <delete id="deleteShopInfoById">
  86. delete from cm_brand_auth_shop_info where id = #{infoId}
  87. </delete>
  88. <select id="getShopList" resultType="com.caimei.model.vo.ShopListVo">
  89. select u.authUserId,u.name,u.loginAccount,u.shopType,group_concat(cb.name) as brandName,group_concat(cb.id) as brandId,
  90. u.mobile,u.linkMan,u.status as shopStatus,u.createTime,
  91. (select au.name from cm_brand_auth_user au where au.authUserId = u.createBy) as createBy,
  92. (ifnull(aw.authWaitNum,0)+ifnull(pw.productWaitNum,0)) as waitAuditNum,
  93. ifnull(arw.articleWaitNum,0) as articleWaitNum,
  94. ifnull(iw.imageWaitNum,0) as imageWaitNum,
  95. ifnull(vw.videoWaitNum,0) as videoWaitNum,
  96. ifnull(fw.fileWaitNum,0) as fileWaitNum,
  97. ifnull(zw.zipWaitNum,0) as zipWaitNum,
  98. ifnull(dw.doctorWaitNum,0) as doctorWaitNum,
  99. ifnull(tw.productTypeWaitNum,0) as productTypeWaitNum
  100. from cm_brand_auth_user u
  101. left join cm_brand_auth_shop_info s on u.authUserId = s.authUserId
  102. left join cm_brand cb on cb.id = s.brandId
  103. left join (select authUserId, count(*) as authWaitNum from cm_brand_auth where auditStatus = 2 and shopAuditStatus = 1 group by authUserId) aw on u.authUserId = aw.authUserId
  104. left join (select a.authUserId, count(*) as productWaitNum from cm_brand_auth_product p left join cm_brand_auth a on p.authId = a.id
  105. where p.auditStatus = 2 and p.shopAuditStatus = 1 group by a.authUserId) pw on u.authUserId = pw.authUserId
  106. left join (select authUserId, count(*) as articleWaitNum from cm_brand_article where auditStatus = 2 group by authUserId) arw on u.authUserId = arw.authUserId
  107. left join (select authUserId, count(*) as imageWaitNum from cm_brand_image where auditStatus = 2 group by authUserId) iw on u.authUserId = iw.authUserId
  108. left join (select authUserId, count(*) as videoWaitNum from cm_brand_video where auditStatus = 2 group by authUserId) vw on u.authUserId = vw.authUserId
  109. left join (select authUserId, count(*) as fileWaitNum from cm_brand_file where auditStatus = 2 and fileType = 1 group by authUserId) fw on u.authUserId = fw.authUserId
  110. left join (select authUserId, count(*) as zipWaitNum from cm_brand_file where auditStatus = 2 and fileType = 2 group by authUserId) zw on u.authUserId = zw.authUserId
  111. left join (select authUserId, count(*) as doctorWaitNum from cm_brand_doctor where auditStatus = 2 group by authUserId) dw on u.authUserId = dw.authUserId
  112. left join (select authUserId, count(*) as productTypeWaitNum from cm_brand_product_type where auditStatus = 2 group by authUserId) tw on u.authUserId = tw.authUserId
  113. left join (select authUserId, count(*) as waitSendNum from cm_brand_auth where auditStatus = 1 and sendStatus = 0 group by authUserId) sw on u.authUserId = sw.authUserId
  114. where u.userIdentity = 2
  115. <if test="shopName != null and shopName !=''">
  116. AND u.name like CONCAT('%',#{shopName},'%')
  117. </if>
  118. <if test="listType == 5">
  119. AND u.status = 1
  120. </if>
  121. <if test="loginAccount != null and loginAccount != ''">
  122. AND u.loginAccount like CONCAT('%',#{loginAccount},'%')
  123. </if>
  124. <if test="shopType != null ">
  125. AND u.shopType = #{shopType}
  126. </if>
  127. <if test="brandId != null">
  128. AND s.brandId = #{brandId}
  129. </if>
  130. <if test="mobile != null and mobile !=''">
  131. AND u.mobile like CONCAT('%',#{mobile},'%')
  132. </if>
  133. <if test="linkMan != null and linkMan !=''">
  134. AND u.linkMan like CONCAT('%',#{linkMan},'%')
  135. </if>
  136. <if test="sendStatus != null">
  137. <if test="0 == sendStatus">
  138. and ifnull(sw.waitSendNum,0) > 0
  139. </if>
  140. <if test="1 == sendStatus">
  141. and ifnull(sw.waitSendNum,0) = 0
  142. </if>
  143. </if>
  144. <if test="lowerAuditStatus != null">
  145. <if test="0 == lowerAuditStatus">
  146. <if test="listType == 2">
  147. and (ifnull(aw.authWaitNum,0)+ifnull(pw.productWaitNum,0)) > 0
  148. </if>
  149. <if test="listType == 3">
  150. and (ifnull(articleWaitNum,0) + ifnull(imageWaitNum,0) + ifnull(videoWaitNum,0) + ifnull(fileWaitNum,0) + ifnull(zipWaitNum,0)) > 0
  151. </if>
  152. <if test="listType == 4">
  153. and ifnull(dw.doctorWaitNum,0) > 0
  154. </if>
  155. <if test="listType == 6">
  156. and ifnull(tw.productTypeWaitNum,0) > 0
  157. </if>
  158. </if>
  159. <if test="1 == lowerAuditStatus">
  160. <if test="listType == 2">
  161. and (ifnull(aw.authWaitNum,0)+ifnull(pw.productWaitNum,0)) = 0
  162. </if>
  163. <if test="listType == 3">
  164. and (ifnull(articleWaitNum,0) + ifnull(imageWaitNum,0) + ifnull(videoWaitNum,0) + ifnull(fileWaitNum,0) + ifnull(zipWaitNum,0)) = 0
  165. </if>
  166. <if test="listType == 4">
  167. and ifnull(dw.doctorWaitNum,0) = 0
  168. </if>
  169. <if test="listType == 6">
  170. and ifnull(tw.productTypeWaitNum,0) = 0
  171. </if>
  172. </if>
  173. </if>
  174. group by u.authUserId,u.createTime
  175. <choose>
  176. <when test="listType == 2">
  177. ORDER BY waitAuditNum desc, u.createTime DESC
  178. </when>
  179. <when test="listType == 3">
  180. ORDER BY (ifnull(articleWaitNum,0) + ifnull(imageWaitNum,0) + ifnull(videoWaitNum,0) + ifnull(fileWaitNum,0) + ifnull(zipWaitNum,0)) desc, u.createTime DESC
  181. </when>
  182. <when test="listType == 4">
  183. ORDER BY ifnull(dw.doctorWaitNum,0) desc, u.createTime DESC
  184. </when>
  185. <when test="listType == 6">
  186. ORDER BY ifnull(tw.productTypeWaitNum,0) desc, u.createTime DESC
  187. </when>
  188. <otherwise>
  189. ORDER BY u.createTime DESC
  190. </otherwise>
  191. </choose>
  192. </select>
  193. <select id="getShopMobileByUserId" resultType="java.lang.String">
  194. select mobile from cm_brand_auth_user where authUserId = #{authUserId}
  195. </select>
  196. <select id="getStatementFile" resultType="com.caimei.model.po.CmBrandAuthFilePo">
  197. select id, authUserId, name, ossName, md5Hex, uploadTime
  198. from cm_brand_auth_file
  199. <where>
  200. <if test="id != null">
  201. and id = #{id}
  202. </if>
  203. <if test="authUserId != null">
  204. and authUserId = #{authUserId}
  205. </if>
  206. <if test="brandId != null">
  207. and brandId = #{brandId}
  208. </if>
  209. <if test="md5Hex != null and md5Hex != ''">
  210. and md5Hex = #{md5Hex}
  211. </if>
  212. </where>
  213. limit 1
  214. </select>
  215. <select id="getFileNumByMd5Hex" resultType="java.lang.Integer">
  216. select count(*) from cm_brand_auth_file where md5Hex = #{md5Hex}
  217. </select>
  218. <select id="getShopByUserId" resultType="com.caimei.model.vo.ShopFormVo">
  219. select u.authUserId, u.cmShopId, u.name as shopName, u.loginAccount, u.mobile, u.linkMan, u.status as shopStatus, u.shopType,
  220. u.wxAccountType, u.logo, u.qrCodeImage, u.appId, u.appSecret,
  221. if(avu.id is null, 3, (if(NOW() <![CDATA[<]]> avu.endTime, 1, 0))) as vipStatus
  222. from cm_brand_auth_user u
  223. left join auth_vip_user avu on u.authUserId = avu.authUserId
  224. where u.authUserId = #{authUserId};
  225. </select>
  226. <select id="getBrandList" resultType="com.caimei.model.vo.BrandVo">
  227. select id,name,authLogo from cm_brand
  228. <where>
  229. <if test="type == 1">
  230. id not in (select brandId
  231. from cm_brand_auth_shop_info i
  232. left join cm_brand_auth_user u on i.authUserId= u.authUserId
  233. where u.shopType = 1 and i.brandId is not null);
  234. </if>
  235. <if test="type == 3">
  236. id in (select brandId
  237. from cm_brand_auth_shop_info
  238. where authUserId = #{authUserId})
  239. </if>
  240. </where>
  241. </select>
  242. <select id="getCountryList" resultType="com.caimei.model.vo.CountryVo">
  243. select countryId, name as countryName
  244. from country
  245. where validFlag = 1
  246. </select>
  247. <select id="getUserIdByMobile" resultType="java.lang.Integer">
  248. select authUserId from cm_brand_auth_user where mobile = #{mobile} and userIdentity = 2 limit 1
  249. </select>
  250. <select id="getDbInfoBrandList" resultType="com.caimei.model.vo.ShopBrandVo">
  251. select id, brandName
  252. from cm_brand_auth_shop_info
  253. where authUserId = #{authUserId}
  254. </select>
  255. <select id="getShopInfoByUserId" resultType="com.caimei.model.vo.ShopInfoVo">
  256. select i.id as infoId, i.brandName,i.brandLogo,i.producePlace,i.manufacturer
  257. from cm_brand_auth_shop_info i
  258. where i.authUserId = #{authUserId}
  259. </select>
  260. <select id="getUserIdByShopName" resultType="java.lang.Integer">
  261. select authUserId from cm_brand_auth_user where name = #{shopName} and userIdentity = 2 limit 1
  262. </select>
  263. <select id="getAuthWaitAuditNum" resultType="java.lang.Integer">
  264. select count(*)
  265. from cm_brand_auth
  266. where authUserId = #{authUserId}
  267. and auditStatus = 2
  268. </select>
  269. <select id="getProductWaitAuditNum" resultType="java.lang.Integer">
  270. select count(*)
  271. from cm_brand_auth_product p
  272. left join cm_brand_auth a on p.authId = a.id
  273. where a.authUserId = #{authUserId}
  274. and p.auditStatus = 2
  275. </select>
  276. <select id="getProductCount" resultType="java.lang.Integer">
  277. select count(*)
  278. from cm_brand_auth a
  279. left join cm_brand_auth_product p on p.authId = a.id
  280. where a.authUserId = #{authUserId} and p.brandId = #{brandId}
  281. </select>
  282. <select id="getFeedbackList" resultType="com.caimei.model.vo.FeedbackVo">
  283. select cf.id as feedbackId, a.authParty as clubName, cu.mobile, content, commitTime, handleStatus, handleResult,
  284. handleTime
  285. from cm_brand_club_feedback cf
  286. left join cm_brand_club_user cu on cf.clubUserId = cu.id
  287. left join cm_brand_auth a on cu.authId = a.id
  288. left join cm_brand_auth_user au on cu.authUserId = au.authUserId
  289. where (a.authUserId = #{authUserId} or au.authUserId = #{authUserId})
  290. <if test="clubName != null and clubName != ''">
  291. and a.authParty like concat('%',#{clubName},'%')
  292. </if>
  293. <if test="mobile != null and mobile != ''">
  294. and cu.mobile like concat('%',#{mobile},'%')
  295. </if>
  296. <if test="handleStatus != null">
  297. and cf.handleStatus = #{handleStatus}
  298. </if>
  299. </select>
  300. <select id="getFeedback" resultType="com.caimei.model.vo.FeedbackVo">
  301. select cf.id as feedbackId, a.authParty as clubName, cu.mobile, content, commitTime, handleStatus, handleResult, handleTime
  302. from cm_brand_club_feedback cf
  303. left join cm_brand_club_user cu on cf.clubUserId = cu.id
  304. left join cm_brand_auth a on cu.authId = a.id
  305. where cf.id = #{feedbackId}
  306. </select>
  307. <select id="getShopStatus" resultType="java.lang.Integer">
  308. select status
  309. from cm_brand_auth_user
  310. where authUserId = #{authUserId}
  311. </select>
  312. <select id="getUserIdByAppId" resultType="java.lang.Integer">
  313. select authUserId from cm_brand_auth_user where appId = #{appId} and userIdentity = 2 and appId is not null limit 1
  314. </select>
  315. <select id="getAppSecretByAppId" resultType="java.lang.String">
  316. select appSecret from cm_brand_auth_user where appId = #{appId} and status = 1
  317. </select>
  318. <select id="getAppId" resultType="java.lang.String">
  319. select appId from cm_brand_auth_user where authUserId = #{authUserId} and status = 1
  320. </select>
  321. <select id="getShopNameByAppId" resultType="java.lang.String">
  322. select name from cm_brand_auth_user where appId = #{appId} and status = 1
  323. </select>
  324. <select id="getShopBrands" resultType="java.lang.String">
  325. select b.name
  326. from cm_brand_auth_shop_info i
  327. left join cm_brand b on i.brandId = b.id
  328. where i.authUserId = #{authUserId}
  329. </select>
  330. <select id="getWxShopInfo" resultType="com.caimei.model.vo.WxShopVo">
  331. select au.authUserId, au.appId, au.name as shopName, if(au.shopType = 1, cb.authLogo, au.logo) as logo
  332. from cm_brand_auth_user au
  333. left join cm_brand_auth_shop_info si on au.authUserId = si.authUserId
  334. left join cm_brand cb on si.brandId = cb.id
  335. where au.authUserId = #{authUserId}
  336. and au.status = 1
  337. limit 1
  338. </select>
  339. <select id="getWxAccountTypeByAppId" resultType="java.lang.Integer">
  340. select wxAccountType from cm_brand_auth_user where appId = #{appId} and status = 1
  341. </select>
  342. <select id="getLoginAccount" resultType="java.lang.String">
  343. select loginAccount from cm_brand_auth_user where authUserId = #{authUserId}
  344. </select>
  345. </mapper>