AuthMapper.xml 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633
  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"
  5. parameterType="com.caimei.model.po.CmBrandAuthPo">
  6. insert into cm_brand_auth (authUserId, authParty, provinceId, cityId, townId, address, lng, lat,
  7. mobile, userMobile, linkMan, linkMobile, firstClubType, secondClubType,
  8. medicalLicenseImage, empNum,
  9. logo, customFlag, remarks, authCode, authDate, authImageLogo, authImage,
  10. authImageType, status, createTime, createBy, createSource, auditBy,
  11. auditTime, auditStatus, shopAuditBy, shopAuditTime, shopAuditStatus, checkFlag,
  12. delFlag)
  13. values (#{authUserId}, #{authParty}, #{provinceId}, #{cityId}, #{townId}, #{address}, #{lng}, #{lat},
  14. #{mobile}, #{userMobile}, #{linkMan}, #{linkMobile}, #{firstClubType}, #{secondClubType},
  15. #{medicalLicenseImage}, #{empNum},
  16. #{logo}, #{customFlag}, #{remarks}, #{authCode}, #{authDate}, #{authImageLogo}, #{authImage},
  17. #{authImageType}, #{status}, NOW(), #{createBy}, #{createSource}, #{auditBy},
  18. #{auditTime}, #{auditStatus}, #{shopAuditBy}, #{shopAuditTime}, #{shopAuditStatus}, #{checkFlag},
  19. #{delFlag})
  20. </insert>
  21. <insert id="insertBanner">
  22. insert into cm_brand_auth_banner (authId, banner)
  23. VALUES (#{authId}, #{banner})
  24. </insert>
  25. <update id="updateAuthStatusByAuthId">
  26. update cm_brand_auth
  27. set status = #{status}
  28. where id = #{authId}
  29. </update>
  30. <update id="updateAuthByAuthId">
  31. update cm_brand_auth
  32. set authParty = #{authParty},
  33. provinceId = #{provinceId},
  34. cityId = #{cityId},
  35. townId = #{townId},
  36. address = #{address},
  37. lng = #{lng},
  38. lat = #{lat},
  39. mobile = #{mobile},
  40. userMobile = #{userMobile},
  41. linkMan = #{linkMan},
  42. linkMobile = #{linkMobile},
  43. firstClubType = #{firstClubType},
  44. secondClubType = #{secondClubType},
  45. medicalLicenseImage = #{medicalLicenseImage},
  46. empNum = #{empNum},
  47. logo = #{logo},
  48. customFlag = #{customFlag},
  49. remarks = #{remarks},
  50. authCode = #{authCode},
  51. authDate = #{authDate},
  52. authImageLogo = #{authImageLogo},
  53. authImage = #{authImage},
  54. authImageType = #{authImageType},
  55. status = #{status},
  56. auditStatus = #{auditStatus},
  57. shopAuditStatus = #{shopAuditStatus},
  58. checkFlag = #{checkFlag},
  59. relationId = #{relationId},
  60. relationName = #{relationName}
  61. where id = #{id}
  62. </update>
  63. <update id="updateAuthAuditStatus">
  64. update cm_brand_auth
  65. set status = #{status},
  66. auditStatus = #{auditStatus},
  67. invalidReason = #{invalidReason},
  68. auditBy = #{auditBy},
  69. auditTime = #{auditTime}
  70. where id = #{authId}
  71. </update>
  72. <update id="deleteAuthByAuthId">
  73. update cm_brand_auth
  74. set delFlag = 1
  75. where id = #{authId}
  76. </update>
  77. <update id="updateLdmLatestClubId">
  78. update ldm_latest_club_id
  79. set ldmClubId = #{ldmLatestClubId}
  80. where id = 1;
  81. </update>
  82. <update id="updateRemarks">
  83. update cm_brand_auth
  84. set customFlag = 1,
  85. remarks = #{remarks}
  86. where id = #{authId}
  87. </update>
  88. <update id="updateAuthShopAuditStatus">
  89. update cm_brand_auth
  90. set shopAuditStatus = #{shopAuditStatus},
  91. status = #{status},
  92. auditStatus = #{shopAuditStatus},
  93. shopInvalidReason = #{shopInvalidReason},
  94. shopAuditBy = #{shopAuditBy},
  95. shopAuditTime = #{shopAuditTime}
  96. where id = #{authId}
  97. </update>
  98. <update id="updateSendStatus">
  99. update cm_brand_auth
  100. set sendStatus = 1
  101. where id = #{authId}
  102. </update>
  103. <update id="updateAuthImage">
  104. update cm_brand_auth
  105. set authImage = #{authImage},
  106. pcAuthImage = #{pcAuthImage},
  107. appletsAuthImage = #{appletsAuthImage}
  108. where id = #{id}
  109. </update>
  110. <update id="checkAuth">
  111. update cm_brand_auth
  112. set checkFlag = 1
  113. where id = #{authId}
  114. </update>
  115. <update id="starAuth">
  116. update cm_brand_auth
  117. set starFlag = #{starFlag},
  118. <choose>
  119. <when test="starNum != null and starNum != ''">
  120. starNum=#{starNum}
  121. </when>
  122. <otherwise>
  123. starNum=null
  124. </otherwise>
  125. </choose>
  126. where id = #{authId}
  127. </update>
  128. <update id="addScanCount">
  129. update cm_brand_auth
  130. set scanCount = scanCount + 1
  131. where id = #{authId}
  132. </update>
  133. <delete id="deleteBanner">
  134. delete
  135. from cm_brand_auth_banner
  136. where authId = #{authId}
  137. </delete>
  138. <select id="getAuthList" resultType="com.caimei.model.vo.AuthVo">
  139. select a.id as authId, a.authUserId, authParty, cbcu2.mobile, a.status, a.auditStatus, a.shopAuditStatus,
  140. a.createTime,
  141. if(a.createSource = 1,ifnull(cu.loginAccount, cu.name),cbcu1.mobile) as createBy,ifnull(au.loginAccount,au.name)
  142. as auditBy,a.auditTime,a.invalidReason,
  143. ifnull(a.shopInvalidReason, a.invalidReason) as shopInvalidReason,
  144. a.sendStatus, ifnull(au1.loginAccount,au1.name) as shopAuditBy,a.shopAuditTime,
  145. ifnull(ap.waitAuditNum,0) as waitAuditNum,
  146. ifnull(bp.waitAuditNum,0) as shopWaitAuditNum,
  147. if(ifnull(ap.waitAuditNum,0)>0,0,1) as lowerAuditStatus,
  148. a.checkFlag,a.starFlag,a.scanCount,ifnull(cp.productNum,0) as productNum
  149. from cm_brand_auth a
  150. left join cm_brand_auth_user cu on a.createBy = cu.authUserId
  151. left join cm_brand_club_user cbcu1 on a.createBy = cbcu1.id and cbcu1.delFlag = 0
  152. left join cm_brand_auth_user au on a.auditBy = au.authUserId
  153. left join cm_brand_auth_user au1 on a.shopAuditBy = au1.authUserId
  154. left join cm_brand_club_user cbcu2 on a.id = cbcu2.authId and cbcu2.delFlag = 0
  155. left join (select r.authId,count(*) as waitAuditNum from cm_brand_auth_product p
  156. left join cm_brand_product_relation r on p.id = r.productId
  157. where auditStatus = 2 and shopAuditStatus = 1 group by r.authId) ap on a.id = ap.authId
  158. left join (select r.authId,count(*) as waitAuditNum from cm_brand_auth_product p
  159. left join cm_brand_product_relation r on p.id = r.productId
  160. where shopAuditStatus = 2 group by r.authId) bp on a.id = bp.authId
  161. left join (select r.authId,count(*) as productNum from cm_brand_auth_product p
  162. left join cm_brand_product_relation r on p.id = r.productId and p.shopAuditStatus = 1 group by r.authId) cp
  163. on a.id = cp.authId
  164. where a.authUserId = #{authUserId} and a.delFlag = 0
  165. <if test="authParty != null and authParty != ''">
  166. and a.authParty like CONCAT('%',#{authParty},'%')
  167. </if>
  168. <if test="status != null">
  169. and a.status = #{status}
  170. </if>
  171. <if test="starFlag != null">
  172. and a.starFlag = #{starFlag}
  173. </if>
  174. <if test="auditStatus != null">
  175. and a.auditStatus = #{auditStatus}
  176. </if>
  177. <if test="1 == listType or 2 == listType">
  178. and a.shopAuditStatus = 1
  179. </if>
  180. <if test="mobile != null and mobile != ''">
  181. and cbcu2.mobile like concat('%', #{mobile},'%')
  182. </if>
  183. <if test="4 == listType">
  184. and a.auditStatus = 1
  185. </if>
  186. <if test="shopAuditStatus != null">
  187. <if test="0 == shopAuditStatus">
  188. and (a.shopAuditStatus = 2 or (a.shopAuditStatus = 1 and ifnull(bp.waitAuditNum,0) > 0))
  189. </if>
  190. <if test="1 == shopAuditStatus">
  191. and (a.shopAuditStatus = 0 or (a.shopAuditStatus = 1 and ifnull(bp.waitAuditNum,0) = 0))
  192. </if>
  193. </if>
  194. <if test="sendStatus != null">
  195. <if test="0 == sendStatus">
  196. and a.sendStatus != 1
  197. </if>
  198. <if test="1 == sendStatus">
  199. and a.sendStatus = 1
  200. </if>
  201. </if>
  202. <if test="lowerAuditStatus != null">
  203. <if test="0 == lowerAuditStatus">
  204. and ifnull(ap.waitAuditNum,0) > 0
  205. </if>
  206. <if test="1 == lowerAuditStatus">
  207. and ifnull(ap.waitAuditNum,0) = 0
  208. </if>
  209. </if>
  210. <choose>
  211. <when test="listType == 2">
  212. order by (case a.auditStatus when 2 then 2 when 0 then 1 else 0 end) desc,waitAuditNum desc,
  213. a.createTime desc
  214. </when>
  215. <when test="listType == 3">
  216. order by (case a.shopAuditStatus when 2 then 2 when 0 then 1 else 0 end) desc,shopWaitAuditNum desc,
  217. a.createTime desc
  218. </when>
  219. <otherwise>
  220. order by a.createTime desc, a.id desc
  221. </otherwise>
  222. </choose>
  223. </select>
  224. <select id="getAuthListAll" resultType="com.caimei.model.vo.AuthVo">
  225. select DISTINCT a.id as authId, a.authUserId, authParty, cbcu2.mobile, a.status, a.auditStatus, a.shopAuditStatus,
  226. a.createTime,
  227. if(a.createSource = 1,ifnull(cu.loginAccount, cu.name),cbcu1.mobile) as createBy,ifnull(au.loginAccount,au.name)
  228. as auditBy,a.auditTime,a.invalidReason,
  229. ifnull(a.shopInvalidReason, a.invalidReason) as shopInvalidReason,
  230. a.sendStatus, ifnull(au1.loginAccount,au1.name) as shopAuditBy,a.shopAuditTime,
  231. ifnull(ap.waitAuditNum,0) as waitAuditNum,
  232. ifnull(bp.waitAuditNum,0) as shopWaitAuditNum,
  233. if(ifnull(ap.waitAuditNum,0)>0,0,1) as lowerAuditStatus,
  234. a.checkFlag,a.starFlag,a.scanCount,ifnull(cp.productNum,0) as productNum,
  235. a.starNum,a.relationId,a.relationName
  236. from cm_brand_auth a
  237. left join cm_brand_auth_user cu on a.createBy = cu.authUserId
  238. left join cm_brand_club_user cbcu1 on a.createBy = cbcu1.id and cbcu1.delFlag = 0
  239. left join cm_brand_auth_user au on a.auditBy = au.authUserId
  240. left join cm_brand_auth_user au1 on a.shopAuditBy = au1.authUserId
  241. left join cm_brand_club_user cbcu2 on a.id = cbcu2.authId and cbcu2.delFlag = 0
  242. left join (select r.authId,p.name,p.snCode,count(*) as waitAuditNum from cm_brand_auth_product p
  243. left join cm_brand_product_relation r on p.id = r.productId
  244. where auditStatus = 2 and shopAuditStatus = 1 group by r.authId) ap on a.id = ap.authId
  245. left join (select r.authId,count(*) as waitAuditNum from cm_brand_auth_product p
  246. left join cm_brand_product_relation r on p.id = r.productId
  247. where shopAuditStatus = 2 group by r.authId) bp on a.id = bp.authId
  248. left join (select r.authId,count(*) as productNum from cm_brand_auth_product p
  249. left join cm_brand_product_relation r on p.id = r.productId and p.shopAuditStatus = 1 group by r.authId) cp
  250. on a.id = cp.authId
  251. LEFT JOIN (SELECT
  252. r.authId,
  253. if(p.name IS NULL,t.name,p.name) as productName,
  254. p.snCode
  255. FROM
  256. cm_brand_auth_product p
  257. LEFT JOIN cm_brand_product_relation r ON p.id = r.productId
  258. LEFT JOIN cm_brand_auth aw on aw.id=r.authId
  259. LEFT JOIN cm_brand_product_type t on p.productTypeId = t.id and t.delFlag = 0
  260. where p.shopAuditStatus=1
  261. ) dp on a.id = dp.authId
  262. where a.authUserId = #{authUserId} and a.delFlag = 0
  263. <if test="authParty != null and authParty != ''">
  264. and a.authParty like CONCAT('%',#{authParty},'%')
  265. </if>
  266. <if test="status != null">
  267. and a.status = #{status}
  268. </if>
  269. <if test="starFlag != null">
  270. and a.starFlag = #{starFlag}
  271. </if>
  272. <if test="auditStatus != null">
  273. and a.auditStatus = #{auditStatus}
  274. </if>
  275. <if test="name != null and name != ''">
  276. and dp.productName = #{name}
  277. </if>
  278. <if test="snCode != null and snCode != ''">
  279. and dp.snCode = #{snCode}
  280. </if>
  281. <if test="1 == listType or 2 == listType">
  282. and a.shopAuditStatus = 1
  283. </if>
  284. <if test="mobile != null and mobile != ''">
  285. and cbcu2.mobile like concat('%', #{mobile},'%')
  286. </if>
  287. <if test="4 == listType">
  288. and a.auditStatus = 1
  289. </if>
  290. <if test="shopAuditStatus != null">
  291. <if test="0 == shopAuditStatus">
  292. and (a.shopAuditStatus = 2 or (a.shopAuditStatus = 1 and ifnull(bp.waitAuditNum,0) > 0))
  293. </if>
  294. <if test="1 == shopAuditStatus">
  295. and (a.shopAuditStatus = 0 or (a.shopAuditStatus = 1 and ifnull(bp.waitAuditNum,0) = 0))
  296. </if>
  297. </if>
  298. <if test="sendStatus != null">
  299. <if test="0 == sendStatus">
  300. and a.sendStatus != 1
  301. </if>
  302. <if test="1 == sendStatus">
  303. and a.sendStatus = 1
  304. </if>
  305. </if>
  306. <if test="lowerAuditStatus != null">
  307. <if test="0 == lowerAuditStatus">
  308. and ifnull(ap.waitAuditNum,0) > 0
  309. </if>
  310. <if test="1 == lowerAuditStatus">
  311. and ifnull(ap.waitAuditNum,0) = 0
  312. </if>
  313. </if>
  314. <choose>
  315. <when test="listType == 2">
  316. order by (case a.auditStatus when 2 then 2 when 0 then 1 else 0 end) desc,waitAuditNum desc,
  317. a.createTime desc
  318. </when>
  319. <when test="listType == 3">
  320. order by (case a.shopAuditStatus when 2 then 2 when 0 then 1 else 0 end) desc,shopWaitAuditNum desc,
  321. a.createTime desc
  322. </when>
  323. <otherwise>
  324. order by a.starNum is null, a.starNum*1,a.createTime desc, a.id desc
  325. </otherwise>
  326. </choose>
  327. </select>
  328. <select id="getProductWaitAuditNum" resultType="java.lang.Integer">
  329. select count(*)
  330. from cm_brand_auth_product p
  331. left join cm_brand_product_relation r on p.id = r.productId
  332. where r.authId = #{authId}
  333. and p.auditStatus = 2
  334. </select>
  335. <select id="getClubStatus" resultType="java.lang.Integer">
  336. select status
  337. from cm_brand_auth
  338. where id = #{authId}
  339. </select>
  340. <select id="getAuthIdByAuthParty" resultType="java.lang.Integer">
  341. select id
  342. from cm_brand_auth
  343. where authParty = #{authParty}
  344. and authUserId = #{authUserId}
  345. and delFlag = 0
  346. </select>
  347. <select id="getAuthPartyList" resultType="com.caimei.model.vo.AuthFormVo">
  348. select authParty,
  349. concat(ifnull(p.name, ''), '/', ifnull(c.name, ''), '/', ifnull(t.name, '')) as area,
  350. address,
  351. concat(lng, ',', lat) as lngAndLat,
  352. mobile,
  353. authCode,
  354. authDate,
  355. empNum,
  356. if(customFlag = 1, remarks, '') as remarks
  357. from cm_brand_auth a
  358. left join province p on a.provinceId = p.provinceID
  359. left join city c on a.cityId = c.cityID
  360. left join town t on a.townId = t.townID
  361. where a.delFlag = 0
  362. and find_in_set(a.id, #{authIds})
  363. order by createTime desc
  364. </select>
  365. <select id="getBannerList" resultType="java.lang.String">
  366. select banner
  367. from cm_brand_auth_banner
  368. where authId = #{authId}
  369. </select>
  370. <select id="getLdmData" resultType="com.caimei.model.po.LdmDataPo">
  371. select name as authParty,
  372. if(status = 1, 1, 0) as status,
  373. if(status = 1, 1, 0) as auditStatus,
  374. tel as mobile,
  375. addr as address,
  376. pic1,
  377. pic2,
  378. pic3,
  379. pic4,
  380. pic5,
  381. du as lngAndLat,
  382. if(deleted_at is null, 0, 1) as delFlag,
  383. regId1,
  384. regId2,
  385. regId3
  386. from nissan_ht_alcohol;
  387. </select>
  388. <select id="getProvinceId" resultType="java.lang.Integer">
  389. select provinceID
  390. from province
  391. where name like
  392. concat(#{provinceName}, '%') limit 1;
  393. </select>
  394. <select id="getCityId" resultType="java.lang.Integer">
  395. select cityID
  396. from city
  397. where name like
  398. concat(#{cityName}, '%') limit 1;
  399. </select>
  400. <select id="getTownId" resultType="java.lang.Integer">
  401. select townID
  402. from town
  403. where name like
  404. concat(#{townName}, '%') limit 1;
  405. </select>
  406. <select id="getLdmLatestClubId" resultType="java.lang.Integer">
  407. select ldmClubId
  408. from ldm_latest_club_id
  409. where id = 1;
  410. </select>
  411. <select id="getCityIdByTownId" resultType="java.lang.Integer">
  412. select cityID
  413. from town
  414. where townID = #{townId}
  415. </select>
  416. <select id="getProvinceName" resultType="java.lang.String">
  417. select name
  418. from nissan_base_region1
  419. where code = #{regId1}
  420. and level = 0 limit 1
  421. </select>
  422. <select id="getCityName" resultType="java.lang.String">
  423. select name
  424. from nissan_base_region1
  425. where code = #{regId1}
  426. and level = 1 limit 1
  427. </select>
  428. <select id="getTownName" resultType="java.lang.String">
  429. select name
  430. from nissan_base_region1
  431. where code = #{regId1}
  432. and level = 2 limit 1
  433. </select>
  434. <select id="getTownList" resultType="com.caimei.model.po.TownPo">
  435. select townID as townId, cityID as cityId
  436. from town
  437. where name like
  438. concat(#{townName}, '%');
  439. </select>
  440. <select id="getProvinceIdByCityId" resultType="java.lang.Integer">
  441. select provinceID
  442. from city
  443. where cityID = #{cityId}
  444. </select>
  445. <select id="getAuthBaseInfo" resultType="com.caimei.model.vo.AuthFormVo">
  446. select a.id as authId, authParty, auditStatus, shopAuditStatus,if(u.id is null,0,1) as bindStatus
  447. from cm_brand_auth a
  448. left join cm_brand_club_user u on a.id = u.authId and u.delFlag = 0
  449. <where>
  450. a.delFlag = 0
  451. <if test="authUserId != null">
  452. and a.authUserId = #{authUserId}
  453. </if>
  454. <if test="authId != null">
  455. and a.id = #{authId}
  456. </if>
  457. </where>
  458. </select>
  459. <select id="getAuthById" resultType="com.caimei.model.vo.AuthVo">
  460. select id as authId,
  461. a.authUserId,
  462. authParty,
  463. a.status,
  464. a.auditStatus,
  465. a.createTime,
  466. cu.name as createBy,
  467. ifnull(au.loginAccount, au.name) as auditBy,
  468. a.auditTime,
  469. a.invalidReason
  470. from cm_brand_auth a
  471. left join cm_brand_auth_user cu on a.createBy = cu.authUserId
  472. left join cm_brand_auth_user au on a.auditBy = au.authUserId
  473. where a.delFlag = 0
  474. and a.id = #{authId}
  475. </select>
  476. <select id="getAuthFormById" resultType="com.caimei.model.vo.AuthFormVo">
  477. select id as authId,
  478. authParty,
  479. authUserId,
  480. a.provinceId,
  481. a.cityId,
  482. a.townId,
  483. concat(ifnull(p.name, ''), '/', ifnull(c.name, ''), '/', ifnull(t.name, '')) as area,
  484. address,
  485. lng,
  486. lat,
  487. mobile,
  488. userMobile,
  489. linkMan,
  490. linkMobile,
  491. firstClubType,
  492. secondClubType,
  493. medicalLicenseImage,
  494. empNum,
  495. logo,
  496. customFlag,
  497. remarks,
  498. authCode,
  499. authDate,
  500. authImageLogo,
  501. authImage,
  502. authImageType,
  503. status,
  504. auditStatus,
  505. relationId,
  506. relationName,
  507. if(shopAuditStatus = 0, shopInvalidReason, invalidReason) as invalidReason
  508. from cm_brand_auth a
  509. left join province p on a.provinceId = p.provinceID
  510. left join city c on a.cityId = c.cityID
  511. left join town t on a.townId = t.townID
  512. where id = #{authId}
  513. and a.delFlag = 0
  514. </select>
  515. <select id="getTownNames" resultType="java.lang.String">
  516. select name
  517. from town
  518. </select>
  519. <select id="getProvinceNames" resultType="java.lang.String">
  520. SELECT NAME
  521. FROM province
  522. </select>
  523. <select id="getCityNames" resultType="java.lang.String">
  524. select name from city
  525. <if test="ProvinceId !=null">
  526. where provinceID = #{ProvinceId}
  527. </if>
  528. </select>
  529. <select id="getCityIdByProvinceId" resultType="java.lang.Integer">
  530. select cityId from city
  531. where name like concat(#{cityName},'%')
  532. <if test="provinceId !=null">
  533. and provinceID = #{provinceId}
  534. </if>
  535. limit 1
  536. </select>
  537. <select id="getProvinceNameById" resultType="java.lang.String">
  538. select name
  539. from province
  540. where provinceID = #{provinceId}
  541. </select>
  542. <select id="getCityNameByCityId" resultType="java.lang.String">
  543. select name
  544. from city
  545. where cityID = #{cityId}
  546. </select>
  547. <select id="getTownNameById" resultType="java.lang.String">
  548. select name
  549. from town
  550. where townID = #{townId}
  551. </select>
  552. <select id="getAuthByNameAndAddress" resultType="com.caimei.model.vo.AuthVo">
  553. select id as authId
  554. from cm_brand_auth
  555. where authParty like concat('%', #{authParty}, '%')
  556. and address like concat('%', #{address}, '%')
  557. and delFlag = 0
  558. </select>
  559. <select id="getAdminUserId" resultType="java.lang.Integer">
  560. select authUserId
  561. from cm_brand_auth_user
  562. where userIdentity = 1 limit 1
  563. </select>
  564. <select id="getAuthTemplate" resultType="com.caimei.model.vo.TemplateVo">
  565. select at.id as templateId, templateImage, qrPosition, qrSize
  566. from cm_brand_auth_template at
  567. left join cm_brand_auth a on at.authUserId = a.authUserId and a.delFlag = 0
  568. where at.status = 1
  569. <if test="templateType == 1">
  570. and at.authFlag = 1
  571. </if>
  572. <if test="templateType == 2">
  573. and at.productFlag = 1
  574. </if>
  575. <if test="authId != null">
  576. and a.id = #{authId}
  577. </if>
  578. <if test="authUserId != null">
  579. and at.authUserId = #{authUserId}
  580. </if>
  581. limit 1
  582. </select>
  583. <select id="getAllAuth" resultType="com.caimei.model.po.CmBrandAuthPo">
  584. select id, authUserId, authImageType, authCode, authDate, authImageLogo
  585. from cm_brand_auth
  586. where authUserId = #{authUserId}
  587. and delFlag = 0
  588. </select>
  589. <select id="getAuthIdList" resultType="com.caimei.model.vo.AuthFormVo">
  590. select id as authId,authParty from cm_brand_auth where
  591. id in
  592. <foreach collection="relationIdList" open="(" separator="," close=")" item="reId">
  593. #{reId,jdbcType=VARCHAR}
  594. </foreach>
  595. </select>
  596. <select id="getRelationgInfo" resultType="com.caimei.model.vo.AuthFormVo">
  597. select relationId, relationName
  598. from cm_brand_auth
  599. where authUserId = #{authUserId}
  600. and id = #{authId}
  601. and delFlag = 0
  602. </select>
  603. <select id="getClubBindAuth" resultType="com.caimei.model.vo.AuthFormVo">
  604. select au.id as authId,au.authParty
  605. from cm_brand_auth au
  606. where au.id not in (
  607. select cu.authId
  608. from cm_brand_auth a
  609. left join cm_brand_club_user cu on cu.authId = a.id
  610. where cu.authUserId = #{authUserId}
  611. and cu.delFlag = 0
  612. and (a.id is null || a.delFlag = 0))
  613. and au.delFlag = 0 and au.authUserId = #{authUserId}
  614. </select>
  615. <select id="getRelationgList" resultType="com.caimei.model.vo.ProductFormVo">
  616. select DISTINCT r.authId as relationId
  617. from cm_brand_product_relation r
  618. LEFT JOIN cm_brand_auth_product a on r.productId = a.id
  619. where snCode =#{snCode}
  620. </select>
  621. </mapper>