AuthMapper.xml 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760
  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,a.authCode,
  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="authCode != null and authCode != ''">
  169. and a.authCode=#{authCode}
  170. </if>
  171. <if test="status != null">
  172. and a.status = #{status}
  173. </if>
  174. <if test="starFlag != null">
  175. and a.starFlag = #{starFlag}
  176. </if>
  177. <if test="auditStatus != null">
  178. and a.auditStatus = #{auditStatus}
  179. </if>
  180. <if test="1 == listType or 2 == listType">
  181. and a.shopAuditStatus = 1
  182. </if>
  183. <if test="mobile != null and mobile != ''">
  184. and cbcu2.mobile like concat('%', #{mobile},'%')
  185. </if>
  186. <if test="4 == listType">
  187. and a.auditStatus = 1
  188. </if>
  189. <if test="shopAuditStatus != null">
  190. <if test="0 == shopAuditStatus">
  191. and (a.shopAuditStatus = 2 or (a.shopAuditStatus = 1 and ifnull(bp.waitAuditNum,0) > 0))
  192. </if>
  193. <if test="1 == shopAuditStatus">
  194. and (a.shopAuditStatus = 0 or (a.shopAuditStatus = 1 and ifnull(bp.waitAuditNum,0) = 0))
  195. </if>
  196. </if>
  197. <if test="sendStatus != null">
  198. <if test="0 == sendStatus">
  199. and a.sendStatus != 1
  200. </if>
  201. <if test="1 == sendStatus">
  202. and a.sendStatus = 1
  203. </if>
  204. </if>
  205. <if test="lowerAuditStatus != null">
  206. <if test="0 == lowerAuditStatus">
  207. and ifnull(ap.waitAuditNum,0) > 0
  208. </if>
  209. <if test="1 == lowerAuditStatus">
  210. and ifnull(ap.waitAuditNum,0) = 0
  211. </if>
  212. </if>
  213. <choose>
  214. <when test="listType == 2">
  215. order by (case a.auditStatus when 2 then 2 when 0 then 1 else 0 end) desc,waitAuditNum desc,
  216. a.createTime desc
  217. </when>
  218. <when test="listType == 3">
  219. order by (case a.shopAuditStatus when 2 then 2 when 0 then 1 else 0 end) desc,shopWaitAuditNum desc,
  220. a.createTime desc
  221. </when>
  222. <otherwise>
  223. order by a.createTime desc, a.id desc
  224. </otherwise>
  225. </choose>
  226. </select>
  227. <select id="getAuthListAll" resultType="com.caimei.model.vo.AuthVo">
  228. select DISTINCT a.id as authId, a.authUserId, authParty, cbcu2.mobile, a.status, a.auditStatus, a.shopAuditStatus,
  229. a.createTime,
  230. if(a.createSource = 1,ifnull(cu.loginAccount, cu.name),cbcu1.mobile) as createBy,ifnull(au.loginAccount,au.name)
  231. as auditBy,a.auditTime,a.invalidReason,
  232. ifnull(a.shopInvalidReason, a.invalidReason) as shopInvalidReason,
  233. a.sendStatus, ifnull(au1.loginAccount,au1.name) as shopAuditBy,a.shopAuditTime,
  234. ifnull(ap.waitAuditNum,0) as waitAuditNum,
  235. ifnull(bp.waitAuditNum,0) as shopWaitAuditNum,
  236. if(ifnull(ap.waitAuditNum,0)>0,0,1) as lowerAuditStatus,
  237. a.checkFlag,a.starFlag,a.scanCount,ifnull(cp.productNum,0) as productNum,
  238. a.starNum,a.relationId,a.relationName
  239. from cm_brand_auth a
  240. left join cm_brand_auth_user cu on a.createBy = cu.authUserId
  241. left join cm_brand_club_user cbcu1 on a.createBy = cbcu1.id and cbcu1.delFlag = 0
  242. left join cm_brand_auth_user au on a.auditBy = au.authUserId
  243. left join cm_brand_auth_user au1 on a.shopAuditBy = au1.authUserId
  244. left join cm_brand_club_user cbcu2 on a.id = cbcu2.authId and cbcu2.delFlag = 0
  245. left join (select r.authId,p.name,p.snCode,count(*) as waitAuditNum from cm_brand_auth_product p
  246. left join cm_brand_product_relation r on p.id = r.productId
  247. where auditStatus = 2 and shopAuditStatus = 1 group by r.authId) ap on a.id = ap.authId
  248. left join (select r.authId,count(*) as waitAuditNum from cm_brand_auth_product p
  249. left join cm_brand_product_relation r on p.id = r.productId
  250. where shopAuditStatus = 2 group by r.authId) bp on a.id = bp.authId
  251. left join (select r.authId,count(*) as productNum from cm_brand_auth_product p
  252. left join cm_brand_product_relation r on p.id = r.productId and p.shopAuditStatus = 1 group by r.authId) cp
  253. on a.id = cp.authId
  254. LEFT JOIN (SELECT
  255. r.authId,
  256. if(p.name IS NULL,t.name,p.name) as productName,
  257. p.snCode
  258. FROM
  259. cm_brand_auth_product p
  260. LEFT JOIN cm_brand_product_relation r ON p.id = r.productId
  261. LEFT JOIN cm_brand_auth aw on aw.id=r.authId
  262. LEFT JOIN cm_brand_product_type t on p.productTypeId = t.id and t.delFlag = 0
  263. where p.shopAuditStatus=1
  264. ) dp on a.id = dp.authId
  265. where a.authUserId = #{authUserId} and a.delFlag = 0
  266. <if test="authParty != null and authParty != ''">
  267. and a.authParty like CONCAT('%',#{authParty},'%')
  268. </if>
  269. <if test="status != null">
  270. and a.status = #{status}
  271. </if>
  272. <if test="starFlag != null">
  273. and a.starFlag = #{starFlag}
  274. </if>
  275. <if test="auditStatus != null">
  276. and a.auditStatus = #{auditStatus}
  277. </if>
  278. <if test="name != null and name != ''">
  279. and dp.productName = #{name}
  280. </if>
  281. <if test="snCode != null and snCode != ''">
  282. and dp.snCode = #{snCode}
  283. </if>
  284. <if test="1 == listType or 2 == listType">
  285. and a.shopAuditStatus = 1
  286. </if>
  287. <if test="mobile != null and mobile != ''">
  288. and cbcu2.mobile like concat('%', #{mobile},'%')
  289. </if>
  290. <if test="4 == listType">
  291. and a.auditStatus = 1
  292. </if>
  293. <if test="shopAuditStatus != null">
  294. <if test="0 == shopAuditStatus">
  295. and (a.shopAuditStatus = 2 or (a.shopAuditStatus = 1 and ifnull(bp.waitAuditNum,0) > 0))
  296. </if>
  297. <if test="1 == shopAuditStatus">
  298. and (a.shopAuditStatus = 0 or (a.shopAuditStatus = 1 and ifnull(bp.waitAuditNum,0) = 0))
  299. </if>
  300. </if>
  301. <if test="sendStatus != null">
  302. <if test="0 == sendStatus">
  303. and a.sendStatus != 1
  304. </if>
  305. <if test="1 == sendStatus">
  306. and a.sendStatus = 1
  307. </if>
  308. </if>
  309. <if test="lowerAuditStatus != null">
  310. <if test="0 == lowerAuditStatus">
  311. and ifnull(ap.waitAuditNum,0) > 0
  312. </if>
  313. <if test="1 == lowerAuditStatus">
  314. and ifnull(ap.waitAuditNum,0) = 0
  315. </if>
  316. </if>
  317. <choose>
  318. <when test="listType == 2">
  319. order by (case a.auditStatus when 2 then 2 when 0 then 1 else 0 end) desc,waitAuditNum desc,
  320. a.createTime desc
  321. </when>
  322. <when test="listType == 3">
  323. order by (case a.shopAuditStatus when 2 then 2 when 0 then 1 else 0 end) desc,shopWaitAuditNum desc,
  324. a.createTime desc
  325. </when>
  326. <otherwise>
  327. order by a.starNum is null, a.starNum*1,a.createTime desc, a.id desc
  328. </otherwise>
  329. </choose>
  330. </select>
  331. <select id="getProductWaitAuditNum" resultType="java.lang.Integer">
  332. select count(*)
  333. from cm_brand_auth_product p
  334. left join cm_brand_product_relation r on p.id = r.productId
  335. where r.authId = #{authId}
  336. and p.auditStatus = 2
  337. </select>
  338. <select id="getClubStatus" resultType="java.lang.Integer">
  339. select status
  340. from cm_brand_auth
  341. where id = #{authId}
  342. </select>
  343. <select id="getAuthIdByAuthParty" resultType="java.lang.Integer">
  344. select id
  345. from cm_brand_auth
  346. where authParty = #{authParty}
  347. and authUserId = #{authUserId}
  348. and delFlag = 0
  349. </select>
  350. <select id="getAuthPartyList" resultType="com.caimei.model.vo.AuthFormVo">
  351. select authParty,
  352. concat(ifnull(p.name, ''), '/', ifnull(c.name, ''), '/', ifnull(t.name, '')) as area,
  353. address,
  354. concat(lng, ',', lat) as lngAndLat,
  355. mobile,
  356. authCode,
  357. authDate,
  358. empNum,
  359. if(customFlag = 1, remarks, '') as remarks
  360. from cm_brand_auth a
  361. left join province p on a.provinceId = p.provinceID
  362. left join city c on a.cityId = c.cityID
  363. left join town t on a.townId = t.townID
  364. where a.delFlag = 0
  365. and find_in_set(a.id, #{authIds})
  366. order by createTime desc
  367. </select>
  368. <select id="getBannerList" resultType="java.lang.String">
  369. select banner
  370. from cm_brand_auth_banner
  371. where authId = #{authId}
  372. </select>
  373. <select id="getLdmData" resultType="com.caimei.model.po.LdmDataPo">
  374. select name as authParty,
  375. if(status = 1, 1, 0) as status,
  376. if(status = 1, 1, 0) as auditStatus,
  377. tel as mobile,
  378. addr as address,
  379. pic1,
  380. pic2,
  381. pic3,
  382. pic4,
  383. pic5,
  384. du as lngAndLat,
  385. if(deleted_at is null, 0, 1) as delFlag,
  386. regId1,
  387. regId2,
  388. regId3
  389. from nissan_ht_alcohol;
  390. </select>
  391. <select id="getProvinceId" resultType="java.lang.Integer">
  392. select provinceID
  393. from province
  394. where name like
  395. concat(#{provinceName}, '%') limit 1;
  396. </select>
  397. <select id="getCityId" resultType="java.lang.Integer">
  398. select cityID
  399. from city
  400. where name like
  401. concat(#{cityName}, '%') limit 1;
  402. </select>
  403. <select id="getTownId" resultType="java.lang.Integer">
  404. select townID
  405. from town
  406. where name like
  407. concat(#{townName}, '%') limit 1;
  408. </select>
  409. <select id="getLdmLatestClubId" resultType="java.lang.Integer">
  410. select ldmClubId
  411. from ldm_latest_club_id
  412. where id = 1;
  413. </select>
  414. <select id="getCityIdByTownId" resultType="java.lang.Integer">
  415. select cityID
  416. from town
  417. where townID = #{townId}
  418. </select>
  419. <select id="getProvinceName" resultType="java.lang.String">
  420. select name
  421. from nissan_base_region1
  422. where code = #{regId1}
  423. and level = 0 limit 1
  424. </select>
  425. <select id="getCityName" resultType="java.lang.String">
  426. select name
  427. from nissan_base_region1
  428. where code = #{regId1}
  429. and level = 1 limit 1
  430. </select>
  431. <select id="getTownName" resultType="java.lang.String">
  432. select name
  433. from nissan_base_region1
  434. where code = #{regId1}
  435. and level = 2 limit 1
  436. </select>
  437. <select id="getTownList" resultType="com.caimei.model.po.TownPo">
  438. select townID as townId, cityID as cityId
  439. from town
  440. where name like
  441. concat(#{townName}, '%');
  442. </select>
  443. <select id="getProvinceIdByCityId" resultType="java.lang.Integer">
  444. select provinceID
  445. from city
  446. where cityID = #{cityId}
  447. </select>
  448. <select id="getAuthBaseInfo" resultType="com.caimei.model.vo.AuthFormVo">
  449. select a.id as authId, authParty, auditStatus, shopAuditStatus,if(u.id is null,0,1) as bindStatus
  450. from cm_brand_auth a
  451. left join cm_brand_club_user u on a.id = u.authId and u.delFlag = 0
  452. <where>
  453. a.delFlag = 0
  454. <if test="authUserId != null">
  455. and a.authUserId = #{authUserId}
  456. </if>
  457. <if test="authId != null">
  458. and a.id = #{authId}
  459. </if>
  460. </where>
  461. </select>
  462. <select id="getAuthById" resultType="com.caimei.model.vo.AuthVo">
  463. select id as authId,
  464. a.authUserId,
  465. authParty,
  466. a.status,
  467. a.auditStatus,
  468. a.createTime,
  469. cu.name as createBy,
  470. ifnull(au.loginAccount, au.name) as auditBy,
  471. a.auditTime,
  472. a.invalidReason
  473. from cm_brand_auth a
  474. left join cm_brand_auth_user cu on a.createBy = cu.authUserId
  475. left join cm_brand_auth_user au on a.auditBy = au.authUserId
  476. where a.delFlag = 0
  477. and a.id = #{authId}
  478. </select>
  479. <select id="getAuthFormById" resultType="com.caimei.model.vo.AuthFormVo">
  480. select id as authId,
  481. authParty,
  482. authUserId,
  483. a.provinceId,
  484. a.cityId,
  485. a.townId,
  486. concat(ifnull(p.name, ''), '/', ifnull(c.name, ''), '/', ifnull(t.name, '')) as area,
  487. address,
  488. lng,
  489. lat,
  490. mobile,
  491. userMobile,
  492. linkMan,
  493. linkMobile,
  494. firstClubType,
  495. secondClubType,
  496. medicalLicenseImage,
  497. empNum,
  498. logo,
  499. customFlag,
  500. remarks,
  501. authCode,
  502. authDate,
  503. authImageLogo,
  504. authImage,
  505. authImageType,
  506. status,
  507. auditStatus,
  508. relationId,
  509. relationName,
  510. if(shopAuditStatus = 0, shopInvalidReason, invalidReason) as invalidReason
  511. from cm_brand_auth a
  512. left join province p on a.provinceId = p.provinceID
  513. left join city c on a.cityId = c.cityID
  514. left join town t on a.townId = t.townID
  515. where id = #{authId}
  516. and a.delFlag = 0
  517. </select>
  518. <select id="getTownNames" resultType="java.lang.String">
  519. select name
  520. from town
  521. </select>
  522. <select id="getProvinceNames" resultType="java.lang.String">
  523. SELECT NAME
  524. FROM province
  525. </select>
  526. <select id="getCityNames" resultType="java.lang.String">
  527. select name from city
  528. <if test="ProvinceId !=null">
  529. where provinceID = #{ProvinceId}
  530. </if>
  531. </select>
  532. <select id="getCityIdByProvinceId" resultType="java.lang.Integer">
  533. select cityId from city
  534. where name like concat(#{cityName},'%')
  535. <if test="provinceId !=null">
  536. and provinceID = #{provinceId}
  537. </if>
  538. limit 1
  539. </select>
  540. <select id="getProvinceNameById" resultType="java.lang.String">
  541. select name
  542. from province
  543. where provinceID = #{provinceId}
  544. </select>
  545. <select id="getCityNameByCityId" resultType="java.lang.String">
  546. select name
  547. from city
  548. where cityID = #{cityId}
  549. </select>
  550. <select id="getTownNameById" resultType="java.lang.String">
  551. select name
  552. from town
  553. where townID = #{townId}
  554. </select>
  555. <select id="getAuthByNameAndAddress" resultType="com.caimei.model.vo.AuthVo">
  556. select id as authId
  557. from cm_brand_auth
  558. where authParty like concat('%', #{authParty}, '%')
  559. and address like concat('%', #{address}, '%')
  560. and delFlag = 0
  561. </select>
  562. <select id="getAdminUserId" resultType="java.lang.Integer">
  563. select authUserId
  564. from cm_brand_auth_user
  565. where userIdentity = 1 limit 1
  566. </select>
  567. <select id="getAuthTemplate" resultType="com.caimei.model.vo.TemplateVo">
  568. select at.id as templateId, templateImage, qrPosition, qrSize
  569. from cm_brand_auth_template at
  570. left join cm_brand_auth a on at.authUserId = a.authUserId and a.delFlag = 0
  571. where at.status = 1
  572. <if test="templateType == 1">
  573. and at.authFlag = 1
  574. </if>
  575. <if test="templateType == 2">
  576. and at.productFlag = 1
  577. </if>
  578. <if test="authId != null">
  579. and a.id = #{authId}
  580. </if>
  581. <if test="authUserId != null">
  582. and at.authUserId = #{authUserId}
  583. </if>
  584. limit 1
  585. </select>
  586. <select id="getAllAuth" resultType="com.caimei.model.po.CmBrandAuthPo">
  587. select id, authUserId, authImageType, authCode, authDate, authImageLogo
  588. from cm_brand_auth
  589. where authUserId = #{authUserId}
  590. and delFlag = 0
  591. </select>
  592. <select id="getAuthIdList" resultType="com.caimei.model.vo.AuthFormVo">
  593. select id as authId,authParty from cm_brand_auth where
  594. id in
  595. <foreach collection="relationIdList" open="(" separator="," close=")" item="reId">
  596. #{reId,jdbcType=VARCHAR}
  597. </foreach>
  598. </select>
  599. <select id="getRelationgInfo" resultType="com.caimei.model.vo.AuthFormVo">
  600. select relationId, relationName
  601. from cm_brand_auth
  602. where authUserId = #{authUserId}
  603. and id = #{authId}
  604. and delFlag = 0
  605. </select>
  606. <select id="getClubBindAuth" resultType="com.caimei.model.vo.AuthFormVo">
  607. select au.id as authId,au.authParty
  608. from cm_brand_auth au
  609. where au.id not in (
  610. select cu.authId
  611. from cm_brand_auth a
  612. left join cm_brand_club_user cu on cu.authId = a.id
  613. where cu.authUserId = #{authUserId}
  614. and cu.delFlag = 0
  615. and (a.id is null || a.delFlag = 0))
  616. and au.delFlag = 0 and au.authUserId = #{authUserId}
  617. </select>
  618. <select id="getRelationgList" resultType="com.caimei.model.vo.ProductFormVo">
  619. select DISTINCT r.authId as relationId
  620. from cm_brand_product_relation r
  621. LEFT JOIN cm_brand_auth_product a on r.productId = a.id
  622. where snCode =#{snCode}
  623. </select>
  624. <select id="getPrefix" resultType="java.lang.String">
  625. select ifnull(prefix,'app')
  626. from cm_brand_auth_user
  627. where authUserId = #{authUserId}
  628. </select>
  629. <insert id="saveVideoInfo">
  630. insert into cm_challenge_round(userName,title,ossName,ossUrl,cover,releaseTime,authId,authUserId)
  631. values(#{userName},#{title},#{ossName},#{ossUrl},#{cover},#{releaseTime},#{authId},#{authUserId})
  632. </insert>
  633. <select id="getauthUserId" resultType="java.lang.String">
  634. select authUserId
  635. from cm_brand_auth
  636. where id = #{authId}
  637. </select>
  638. <select id="getuserName" resultType="java.lang.String">
  639. select userName
  640. from cm_challenge_round
  641. where userName = #{userName}
  642. </select>
  643. <select id="checkActivityTime" resultType="java.lang.Integer">
  644. select id
  645. from cm_challenge_activity
  646. where startTime &lt;#{releaseTime} and endTime &gt;#{releaseTime} and status=1
  647. </select>
  648. <select id="getPublishedVideoList" resultType="com.caimei.model.vo.ChallengeRoundVo">
  649. select cr.id,cr.userName,cr.itemId,cr.title,cr.ossName,cr.ossUrl,cr.cover,cr.releaseTime,cr.status,cr.shareId,cr.authId,cba.authParty,cr.dyCommand
  650. from cm_challenge_round cr left join cm_brand_auth cba
  651. on cr.authId=cba.id
  652. where 1=1
  653. <if test="clubUserName != null and clubUserName != ''">
  654. and (cr.userName like concat('%', #{clubUserName})
  655. or cba.authParty=#{clubUserName})
  656. </if>
  657. <if test="status != null">
  658. and cr.status = #{status}
  659. </if>
  660. </select>
  661. <select id="getPublishedVideo" resultType="com.caimei.model.vo.ChallengeRoundVo">
  662. select cr.id,cr.userName,cr.itemId,cr.title,cr.ossName,cr.ossUrl,cr.cover,cr.releaseTime,cr.status,cr.shareId,cr.authId,cba.authParty,cr.dyCommand
  663. from cm_challenge_round cr left join cm_brand_auth cba
  664. on cr.authId=cba.id
  665. where cr.authUserId=#{authUserId}
  666. <if test="mobile != null and mobile != ''">
  667. and cr.userName like concat('%', #{mobile})
  668. </if>
  669. <if test="authParty != null and authParty != ''">
  670. or cba.authParty=#{authParty})
  671. </if>
  672. <if test="status != null">
  673. and cr.status = #{status}
  674. </if>
  675. </select>
  676. <select id="checkActivityId" resultType="com.caimei.model.vo.ChallengeActivityVo">
  677. select id,authUserId
  678. from cm_challenge_activity
  679. </select>
  680. <insert id="saveActivityInfo">
  681. insert into cm_challenge_activity(startTime,endTime,status,authUserId)
  682. values(#{startTime},#{endTime},#{status},#{authUserId})
  683. </insert>
  684. <update id="upActivityInfo">
  685. update cm_challenge_activity set
  686. startTime=#{startTime},
  687. endTime=#{endTime},
  688. status = #{status}
  689. where authUserId=#{authUserId}
  690. </update>
  691. <select id="getActivityTime" resultType="com.caimei.model.vo.ChallengeActivityVo">
  692. select id,startTime,endTime,status,authUserId
  693. from cm_challenge_activity
  694. where authUserId=#{authUserId}
  695. </select>
  696. <update id="savaShareIdByAuthId">
  697. update cm_challenge_round set
  698. shareId=#{shareId}
  699. where authId=#{authId}
  700. </update>
  701. <select id="getShareId" resultType="java.lang.String">
  702. select shareId
  703. from cm_challenge_round
  704. where shareId=#{shareId}
  705. </select>
  706. <update id="savaItemIdByShareId">
  707. update cm_challenge_round set
  708. itemId=#{itemId},
  709. status=1
  710. where shareId=#{shareId}
  711. </update>
  712. <select id="getAuthUserName" resultType="java.lang.String">
  713. select name
  714. from cm_brand_auth cba
  715. left join cm_brand_auth_user cu on cu.authUserId=cba.authUserId
  716. where cba.id=#{authId}
  717. </select>
  718. <select id="getMobileByAuthId" resultType="java.lang.String">
  719. select userName
  720. from cm_challenge_round cr
  721. where cr.authId=#{authId}
  722. </select>
  723. <update id="savaDyCommand">
  724. update cm_challenge_round set
  725. dyCommand=#{content}
  726. where authId=#{authId}
  727. </update>
  728. <select id="getAuthPartylist" resultType="com.caimei.model.vo.ChallengeRoundVo">
  729. select cr.id,cr.userName,cr.itemId,cr.title,cr.ossName,cr.ossUrl,cr.cover,cr.releaseTime,cr.status,cr.shareId, cr.authId,cba.authParty,cr.dyCommand
  730. from cm_challenge_round cr left join cm_brand_auth cba
  731. on cr.authId=cba.id
  732. where cr.authUserId=#{authUserId}
  733. </select>
  734. <select id="getOssNameId" resultType="java.lang.String">
  735. select ossName
  736. from cm_challenge_round cr
  737. where cr.id=#{videoID}
  738. </select>
  739. <delete id="deleteVideoById">
  740. delete
  741. from cm_challenge_round
  742. where id = #{videoID}
  743. </delete>
  744. <select id="getChallengeRoundInfo" resultType="com.caimei.model.vo.ChallengeRoundVo">
  745. select cr.id,cr.userName,cr.itemId,cr.title,cr.ossName,cr.ossUrl,cr.cover,cr.releaseTime,cr.status,cr.shareId, cr.authId,cr.dyCommand
  746. from cm_challenge_round cr
  747. where cr.id=#{videoID}
  748. </select>
  749. </mapper>