AuthMapper.xml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  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.AuthMapper">
  4. <insert id="insertAuth" keyColumn="id" keyProperty="id" useGeneratedKeys="true" parameterType="com.caimei.model.po.CmBrandAuthPo">
  5. insert into cm_brand_auth (authUserId, authParty, provinceId, cityId, townId, address, lng, lat,
  6. mobile, userMobile, firstClubType, secondClubType, medicalLicenseImage, empNum,
  7. logo, customFlag, remarks, authCode, authDate, authImageLogo, authImage,
  8. authImageType, status, createTime, createBy, createSource, auditBy,
  9. auditTime, auditStatus, shopAuditBy, shopAuditTime, shopAuditStatus, delFlag)
  10. values (#{authUserId}, #{authParty}, #{provinceId}, #{cityId}, #{townId}, #{address}, #{lng}, #{lat},
  11. #{mobile}, #{userMobile}, #{firstClubType}, #{secondClubType}, #{medicalLicenseImage}, #{empNum},
  12. #{logo}, #{customFlag}, #{remarks}, #{authCode}, #{authDate}, #{authImageLogo}, #{authImage},
  13. #{authImageType}, #{status}, NOW(), #{createBy}, #{createSource}, #{auditBy},
  14. #{auditTime}, #{auditStatus}, #{shopAuditBy}, #{shopAuditTime}, #{shopAuditStatus}, #{delFlag})
  15. </insert>
  16. <insert id="insertBanner">
  17. insert into cm_brand_auth_banner (authId, banner)
  18. VALUES (#{authId}, #{banner})
  19. </insert>
  20. <update id="updateAuthStatusByAuthId">
  21. update cm_brand_auth
  22. set status = #{status}
  23. where id = #{authId}
  24. </update>
  25. <update id="updateAuthByAuthId">
  26. update cm_brand_auth
  27. set authParty = #{authParty},
  28. provinceId = #{provinceId},
  29. cityId = #{cityId},
  30. townId = #{townId},
  31. address = #{address},
  32. lng = #{lng},
  33. lat = #{lat},
  34. mobile = #{mobile},
  35. userMobile = #{userMobile},
  36. firstClubType = #{firstClubType},
  37. secondClubType = #{secondClubType},
  38. medicalLicenseImage = #{medicalLicenseImage},
  39. empNum = #{empNum},
  40. logo = #{logo},
  41. customFlag = #{customFlag},
  42. remarks = #{remarks},
  43. authCode = #{authCode},
  44. authDate = #{authDate},
  45. authImageLogo = #{authImageLogo},
  46. authImage = #{authImage},
  47. authImageType = #{authImageType},
  48. status = #{status},
  49. auditStatus = #{auditStatus},
  50. shopAuditStatus = #{shopAuditStatus}
  51. where id = #{id}
  52. </update>
  53. <update id="updateAuthAuditStatus">
  54. update cm_brand_auth
  55. set status = #{status},
  56. auditStatus = #{auditStatus},
  57. invalidReason = #{invalidReason},
  58. auditBy = #{auditBy},
  59. auditTime = #{auditTime}
  60. where id = #{authId}
  61. </update>
  62. <update id="deleteAuthByAuthId">
  63. update cm_brand_auth set delFlag = 1 where id = #{authId}
  64. </update>
  65. <update id="updateLdmLatestClubId">
  66. update ldm_latest_club_id set ldmClubId = #{ldmLatestClubId} where id = 1;
  67. </update>
  68. <update id="updateRemarks">
  69. update cm_brand_auth
  70. set customFlag = 1,
  71. remarks = #{remarks}
  72. where id = #{authId}
  73. </update>
  74. <update id="updateAuthShopAuditStatus">
  75. update cm_brand_auth
  76. set shopAuditStatus = #{shopAuditStatus},
  77. status = #{status},
  78. auditStatus = #{shopAuditStatus},
  79. shopInvalidReason = #{shopInvalidReason},
  80. shopAuditBy = #{shopAuditBy},
  81. shopAuditTime = #{shopAuditTime}
  82. where id = #{authId}
  83. </update>
  84. <update id="updateSendStatus">
  85. update cm_brand_auth
  86. set sendStatus = 1
  87. where id = #{authId}
  88. </update>
  89. <update id="updateAuthImage">
  90. update cm_brand_auth
  91. set authImage = #{authImage},
  92. pcAuthImage = #{pcAuthImage},
  93. appletsAuthImage = #{appletsAuthImage}
  94. where id = #{id}
  95. </update>
  96. <delete id="deleteBanner">
  97. delete from cm_brand_auth_banner where authId = #{authId}
  98. </delete>
  99. <select id="getAuthList" resultType="com.caimei.model.vo.AuthVo">
  100. select a.id as authId, a.authUserId, authParty, cbcu2.mobile, a.status, a.auditStatus, a.shopAuditStatus, a.createTime,
  101. if(a.createSource = 1,cu.name,cbcu1.mobile) as createBy,au.name as auditBy,a.auditTime,a.invalidReason,
  102. a.sendStatus, au1.name as shopAuditBy,a.shopAuditTime,
  103. ifnull(ap.waitAuditNum,0) as waitAuditNum,
  104. ifnull(bp.waitAuditNum,0) as shopWaitAuditNum,
  105. if(ifnull(ap.waitAuditNum,0)>0,0,1) as lowerAuditStatus,
  106. ifnull(cp.productNum,0) as productNum
  107. from cm_brand_auth a
  108. left join cm_brand_auth_user cu on a.createBy = cu.authUserId
  109. left join cm_brand_club_user cbcu1 on a.createBy = cbcu1.id and cbcu1.delFlag = 0
  110. left join cm_brand_auth_user au on a.auditBy = au.authUserId
  111. left join cm_brand_auth_user au1 on a.shopAuditBy = au1.authUserId
  112. left join cm_brand_club_user cbcu2 on a.id = cbcu2.authId and cbcu2.delFlag = 0
  113. left join (select authId,count(*) as waitAuditNum from cm_brand_auth_product where auditStatus = 2 and shopAuditStatus = 1 group by
  114. authId) ap on a.id = ap.authId
  115. left join (select authId,count(*) as waitAuditNum from cm_brand_auth_product where shopAuditStatus = 2 group by
  116. authId) bp on a.id = bp.authId
  117. left join (select authId,count(*) as productNum from cm_brand_auth_product group by
  118. authId) cp on a.id = cp.authId
  119. where a.authUserId = #{authUserId} and a.delFlag = 0
  120. <if test="authParty != null and authParty != ''">
  121. and a.authParty like CONCAT('%',#{authParty},'%')
  122. </if>
  123. <if test="status != null">
  124. and a.status = #{status}
  125. </if>
  126. <if test="auditStatus != null">
  127. and a.auditStatus = #{auditStatus}
  128. </if>
  129. <if test="1 == listType or 2 == listType">
  130. and a.shopAuditStatus = 1
  131. </if>
  132. <if test="mobile != null and mobile != ''">
  133. and cbcu2.mobile like concat('%', #{mobile},'%')
  134. </if>
  135. <if test="4 == listType">
  136. and a.auditStatus = 1
  137. </if>
  138. <if test="shopAuditStatus != null">
  139. <if test="0 == shopAuditStatus">
  140. and (a.shopAuditStatus = 2 or (a.shopAuditStatus = 1 and ifnull(bp.waitAuditNum,0) > 0))
  141. </if>
  142. <if test="1 == shopAuditStatus">
  143. and (a.shopAuditStatus = 0 or (a.shopAuditStatus = 1 and ifnull(bp.waitAuditNum,0) = 0))
  144. </if>
  145. </if>
  146. <if test="sendStatus != null">
  147. <if test="0 == sendStatus">
  148. and a.sendStatus != 1
  149. </if>
  150. <if test="1 == sendStatus">
  151. and a.sendStatus = 1
  152. </if>
  153. </if>
  154. <if test="lowerAuditStatus != null">
  155. <if test="0 == lowerAuditStatus">
  156. and ifnull(ap.waitAuditNum,0) > 0
  157. </if>
  158. <if test="1 == lowerAuditStatus">
  159. and ifnull(ap.waitAuditNum,0) = 0
  160. </if>
  161. </if>
  162. <choose>
  163. <when test="listType == 2">
  164. order by (case a.auditStatus when 2 then 2 when 0 then 1 else 0 end) desc,waitAuditNum desc, a.createTime desc
  165. </when>
  166. <when test="listType == 3">
  167. order by (case a.shopAuditStatus when 2 then 2 when 0 then 1 else 0 end) desc,shopWaitAuditNum desc, a.createTime desc
  168. </when>
  169. <otherwise>
  170. order by a.createTime desc, a.id desc
  171. </otherwise>
  172. </choose>
  173. </select>
  174. <select id="getProductWaitAuditNum" resultType="java.lang.Integer">
  175. select count(*)
  176. from cm_brand_auth_product
  177. where authId = #{authId}
  178. and auditStatus = 2
  179. </select>
  180. <select id="getClubStatus" resultType="java.lang.Integer">
  181. select status
  182. from cm_brand_auth
  183. where id = #{authId}
  184. </select>
  185. <select id="getAuthIdByAuthParty" resultType="java.lang.Integer">
  186. select id
  187. from cm_brand_auth
  188. where authParty = #{authParty}
  189. and authUserId = #{authUserId}
  190. and delFlag = 0
  191. </select>
  192. <select id="getAuthPartyList" resultType="com.caimei.model.po.CmBrandAuthPo">
  193. select id, authParty
  194. from cm_brand_auth
  195. where authUserId = #{authUserId}
  196. order by createTime desc
  197. </select>
  198. <select id="getBannerList" resultType="java.lang.String">
  199. select banner from cm_brand_auth_banner where authId = #{authId}
  200. </select>
  201. <select id="getLdmData" resultType="com.caimei.model.po.LdmDataPo">
  202. select name as authParty,if(status = 1,1,0) as status,if(status = 1,1,0) as auditStatus,
  203. tel as mobile,addr as address,pic1,pic2,pic3,pic4,pic5,du as lngAndLat,
  204. if(deleted_at is null,0,1) as delFlag,regId1,regId2,regId3
  205. from nissan_ht_alcohol;
  206. </select>
  207. <select id="getProvinceId" resultType="java.lang.Integer">
  208. select provinceID
  209. from province
  210. where name like
  211. concat(#{provinceName},'%') limit 1;
  212. </select>
  213. <select id="getCityId" resultType="java.lang.Integer">
  214. select cityID
  215. from city
  216. where name like
  217. concat(#{cityName},'%') limit 1;
  218. </select>
  219. <select id="getTownId" resultType="java.lang.Integer">
  220. select townID
  221. from town
  222. where name like
  223. concat(#{townName},'%') limit 1;
  224. </select>
  225. <select id="getLdmLatestClubId" resultType="java.lang.Integer">
  226. select ldmClubId from ldm_latest_club_id where id = 1;
  227. </select>
  228. <select id="getCityIdByTownId" resultType="java.lang.Integer">
  229. select cityID from town where townID = #{townId}
  230. </select>
  231. <select id="getProvinceName" resultType="java.lang.String">
  232. select name from nissan_base_region1 where code = #{regId1} and level = 0 limit 1
  233. </select>
  234. <select id="getCityName" resultType="java.lang.String">
  235. select name from nissan_base_region1 where code = #{regId1} and level = 1 limit 1
  236. </select>
  237. <select id="getTownName" resultType="java.lang.String">
  238. select name from nissan_base_region1 where code = #{regId1} and level = 2 limit 1
  239. </select>
  240. <select id="getTownList" resultType="com.caimei.model.po.TownPo">
  241. select townID as townId, cityID as cityId
  242. from town
  243. where name like
  244. concat(#{townName},'%');
  245. </select>
  246. <select id="getProvinceIdByCityId" resultType="java.lang.Integer">
  247. select provinceID from city where cityID = #{cityId}
  248. </select>
  249. <select id="getAuthBaseInfo" resultType="com.caimei.model.vo.AuthFormVo">
  250. select a.id as authId, authParty, auditStatus, shopAuditStatus,if(u.id is null,0,1) as bindStatus
  251. from cm_brand_auth a
  252. left join cm_brand_club_user u on a.id = u.authId and u.delFlag = 0
  253. <where>
  254. <if test="authUserId != null">
  255. and a.authUserId = #{authUserId}
  256. </if>
  257. <if test="authId != null">
  258. and a.id = #{authId}
  259. </if>
  260. </where>
  261. </select>
  262. <select id="getAuthById" resultType="com.caimei.model.vo.AuthVo">
  263. select id as authId,
  264. a.authUserId,
  265. authParty,
  266. a.status,
  267. a.auditStatus,
  268. a.createTime,
  269. cu.name as createBy,
  270. au.name as auditBy,
  271. a.auditTime,
  272. a.invalidReason
  273. from cm_brand_auth a
  274. left join cm_brand_auth_user cu on a.createBy = cu.authUserId
  275. left join cm_brand_auth_user au on a.auditBy = au.authUserId
  276. where a.delFlag = 0
  277. and a.id = #{authId}
  278. </select>
  279. <select id="getAuthFormById" resultType="com.caimei.model.vo.AuthFormVo">
  280. select id as authId,
  281. authParty,
  282. authUserId,
  283. a.provinceId,
  284. a.cityId,
  285. a.townId,
  286. concat(ifnull(p.name, ''), '/', ifnull(c.name, ''), '/', ifnull(t.name, '')) as area,
  287. address,
  288. lng,
  289. lat,
  290. mobile,
  291. userMobile,
  292. firstClubType,
  293. secondClubType,
  294. medicalLicenseImage,
  295. empNum,
  296. logo,
  297. customFlag,
  298. remarks,
  299. authCode,
  300. authDate,
  301. authImageLogo,
  302. authImage,
  303. authImageType,
  304. status,
  305. auditStatus,
  306. if(shopAuditStatus = 0, shopInvalidReason, invalidReason) as invalidReason
  307. from cm_brand_auth a
  308. left join province p on a.provinceId = p.provinceID
  309. left join city c on a.cityId = c.cityID
  310. left join town t on a.townId = t.townID
  311. where id = #{authId}
  312. </select>
  313. <select id="getTownNames" resultType="java.lang.String">
  314. select name from town
  315. </select>
  316. <select id="getProvinceNames" resultType="java.lang.String">
  317. SELECT NAME FROM province
  318. </select>
  319. <select id="getCityNames" resultType="java.lang.String">
  320. select name from city
  321. <if test="ProvinceId !=null">
  322. where provinceID = #{ProvinceId}
  323. </if>
  324. </select>
  325. <select id="getCityIdByProvinceId" resultType="java.lang.Integer">
  326. select cityId from city
  327. where name like concat(#{cityName},'%')
  328. <if test="provinceId !=null">
  329. and provinceID = #{provinceId}
  330. </if>
  331. limit 1
  332. </select>
  333. <select id="getProvinceNameById" resultType="java.lang.String">
  334. select name from province
  335. where provinceID = #{provinceId}
  336. </select>
  337. <select id="getCityNameByCityId" resultType="java.lang.String">
  338. select name from city
  339. where cityID = #{cityId}
  340. </select>
  341. <select id="getTownNameById" resultType="java.lang.String">
  342. select name from town
  343. where townID = #{townId}
  344. </select>
  345. <select id="getAuthByNameAndAddress" resultType="com.caimei.model.vo.AuthVo">
  346. select id as authId from cm_brand_auth
  347. where authParty like concat('%',#{authParty},'%') and address like concat('%',#{address},'%')
  348. and delFlag = 0
  349. </select>
  350. <select id="getAdminUserId" resultType="java.lang.Integer">
  351. select authUserId
  352. from cm_brand_auth_user
  353. where userIdentity = 1
  354. limit 1
  355. </select>
  356. <select id="getAuthTemplate" resultType="com.caimei.model.vo.TemplateVo">
  357. select at.id as templateId, templateImage, qrPosition, qrSize
  358. from cm_brand_auth_template at
  359. left join cm_brand_auth a on at.authUserId = a.authUserId
  360. where at.status = 1
  361. <if test="templateType == 1">
  362. and at.authFlag = 1
  363. </if>
  364. <if test="templateType == 2">
  365. and at.productFlag = 1
  366. </if>
  367. <if test="authId != null">
  368. and a.id = #{authId}
  369. </if>
  370. <if test="authUserId != null">
  371. and at.authUserId = #{authUserId}
  372. </if>
  373. limit 1
  374. </select>
  375. <select id="getAllAuth" resultType="com.caimei.model.po.CmBrandAuthPo">
  376. select id, authUserId, authImageType, authCode, authDate, authImageLogo
  377. from cm_brand_auth
  378. where authUserId = #{authUserId}
  379. and delFlag = 0
  380. </select>
  381. </mapper>