AuthMapper.xml 25 KB

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