AuthMapper.xml 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912
  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="updateRelaByAuthId">
  64. update cm_brand_auth
  65. set relationId = #{relationId},
  66. relationName = #{relationName}
  67. where id = #{authId}
  68. </update>
  69. <update id="updateAuthAuditStatus">
  70. update cm_brand_auth
  71. set status = #{status},
  72. auditStatus = #{auditStatus},
  73. invalidReason = #{invalidReason},
  74. auditBy = #{auditBy},
  75. auditTime = #{auditTime}
  76. where id = #{authId}
  77. </update>
  78. <select id="getRelationInfo" resultType="com.caimei.model.po.CmBrandAuthPo">
  79. select relationId,relationName from cm_brand_auth where id=#{id}
  80. </select>
  81. <update id="deleteAuthByAuthId">
  82. update cm_brand_auth
  83. set delFlag = 1
  84. where id = #{authId}
  85. </update>
  86. <update id="updateLdmLatestClubId">
  87. update ldm_latest_club_id
  88. set ldmClubId = #{ldmLatestClubId}
  89. where id = 1;
  90. </update>
  91. <update id="updateRemarks">
  92. update cm_brand_auth
  93. set customFlag = 1,
  94. remarks = #{remarks}
  95. where id = #{authId}
  96. </update>
  97. <update id="updateAuthShopAuditStatus">
  98. update cm_brand_auth
  99. set shopAuditStatus = #{shopAuditStatus},
  100. status = #{status},
  101. auditStatus = #{shopAuditStatus},
  102. shopInvalidReason = #{shopInvalidReason},
  103. shopAuditBy = #{shopAuditBy},
  104. shopAuditTime = #{shopAuditTime}
  105. where id = #{authId}
  106. </update>
  107. <update id="updateSendStatus">
  108. update cm_brand_auth
  109. set sendStatus = 1
  110. where id = #{authId}
  111. </update>
  112. <update id="updateAuthImage">
  113. update cm_brand_auth
  114. set authImage = #{authImage},
  115. pcAuthImage = #{pcAuthImage},
  116. appletsAuthImage = #{appletsAuthImage}
  117. where id = #{id}
  118. </update>
  119. <update id="checkAuth">
  120. update cm_brand_auth
  121. set checkFlag = 1
  122. where id = #{authId}
  123. </update>
  124. <update id="starAuth">
  125. update cm_brand_auth
  126. set starFlag = #{starFlag},
  127. <choose>
  128. <when test="starNum != null and starNum != ''">
  129. starNum=#{starNum}
  130. </when>
  131. <otherwise>
  132. starNum=null
  133. </otherwise>
  134. </choose>
  135. where id = #{authId}
  136. </update>
  137. <update id="addScanCount">
  138. update cm_brand_auth
  139. set scanCount = scanCount + 1
  140. where id = #{authId}
  141. </update>
  142. <delete id="deleteBanner">
  143. delete
  144. from cm_brand_auth_banner
  145. where authId = #{authId}
  146. </delete>
  147. <select id="getClubUserIdByAuthId" resultType="java.lang.Integer">
  148. select * from cm_brand_club_user cbcu1 left join cm_brand_auth a
  149. on a.createBy = cbcu1.id
  150. where a.authId=#{authId}
  151. </select>
  152. <select id="getAuthList" resultType="com.caimei.model.vo.AuthVo">
  153. select a.id as authId, a.authUserId, authParty, cbcu2.mobile, a.status, a.auditStatus, a.shopAuditStatus,
  154. a.createTime,a.authCode,
  155. if(a.createSource = 1,ifnull(cu.loginAccount, cu.name),cbcu1.mobile) as createBy,ifnull(au.loginAccount,au.name)
  156. as auditBy,a.auditTime,a.invalidReason,
  157. ifnull(a.shopInvalidReason, a.invalidReason) as shopInvalidReason,
  158. a.sendStatus, ifnull(au1.loginAccount,au1.name) as shopAuditBy,a.shopAuditTime,
  159. ifnull(ap.waitAuditNum,0) as waitAuditNum,
  160. ifnull(bp.waitAuditNum,0) as shopWaitAuditNum,
  161. if(ifnull(ap.waitAuditNum,0)>0,0,1) as lowerAuditStatus,
  162. a.checkFlag,a.starFlag,a.scanCount,ifnull(cp.productNum,0) as productNum
  163. from cm_brand_auth a
  164. left join cm_brand_auth_user cu on a.createBy = cu.authUserId
  165. left join cm_brand_club_user cbcu1 on a.createBy = cbcu1.id and cbcu1.delFlag = 0
  166. left join cm_brand_auth_user au on a.auditBy = au.authUserId
  167. left join cm_brand_auth_user au1 on a.shopAuditBy = au1.authUserId
  168. left join cm_brand_club_user cbcu2 on a.id = cbcu2.authId and cbcu2.delFlag = 0
  169. left join (select r.authId,count(*) as waitAuditNum from cm_brand_auth_product p
  170. left join cm_brand_product_relation r on p.id = r.productId
  171. where auditStatus = 2 and shopAuditStatus = 1 group by r.authId) ap on a.id = ap.authId
  172. left join (select r.authId,count(*) as waitAuditNum from cm_brand_auth_product p
  173. left join cm_brand_product_relation r on p.id = r.productId
  174. where shopAuditStatus = 2 group by r.authId) bp on a.id = bp.authId
  175. left join (select r.authId,count(*) as productNum from cm_brand_auth_product p
  176. left join cm_brand_product_relation r on p.id = r.productId and p.shopAuditStatus = 1 group by r.authId) cp
  177. on a.id = cp.authId
  178. where a.authUserId = #{authUserId} and a.delFlag = 0
  179. <if test="authParty != null and authParty != ''">
  180. and a.authParty like CONCAT('%',#{authParty},'%')
  181. </if>
  182. <if test="authCode != null and authCode != ''">
  183. and a.authCode=#{authCode}
  184. </if>
  185. <if test="status != null">
  186. and a.status = #{status}
  187. </if>
  188. <if test="starFlag != null">
  189. and a.starFlag = #{starFlag}
  190. </if>
  191. <if test="auditStatus != null">
  192. and a.auditStatus = #{auditStatus}
  193. </if>
  194. <if test="1 == listType or 2 == listType">
  195. and a.shopAuditStatus = 1
  196. </if>
  197. <if test="mobile != null and mobile != ''">
  198. and cbcu2.mobile like concat('%', #{mobile},'%')
  199. </if>
  200. <if test="4 == listType">
  201. and a.auditStatus = 1
  202. </if>
  203. <if test="shopAuditStatus != null">
  204. <if test="0 == shopAuditStatus">
  205. and (a.shopAuditStatus = 2 or (a.shopAuditStatus = 1 and ifnull(bp.waitAuditNum,0) > 0))
  206. </if>
  207. <if test="1 == shopAuditStatus">
  208. and (a.shopAuditStatus = 0 or (a.shopAuditStatus = 1 and ifnull(bp.waitAuditNum,0) = 0))
  209. </if>
  210. </if>
  211. <if test="sendStatus != null">
  212. <if test="0 == sendStatus">
  213. and a.sendStatus != 1
  214. </if>
  215. <if test="1 == sendStatus">
  216. and a.sendStatus = 1
  217. </if>
  218. </if>
  219. <if test="lowerAuditStatus != null">
  220. <if test="0 == lowerAuditStatus">
  221. and ifnull(ap.waitAuditNum,0) > 0
  222. </if>
  223. <if test="1 == lowerAuditStatus">
  224. and ifnull(ap.waitAuditNum,0) = 0
  225. </if>
  226. </if>
  227. <choose>
  228. <when test="listType == 2">
  229. order by (case a.auditStatus when 2 then 2 when 0 then 1 else 0 end) desc,waitAuditNum desc,
  230. a.createTime desc
  231. </when>
  232. <when test="listType == 3">
  233. order by (case a.shopAuditStatus when 2 then 2 when 0 then 1 else 0 end) desc,shopWaitAuditNum desc,
  234. a.createTime desc
  235. </when>
  236. <otherwise>
  237. order by a.createTime desc, a.id desc
  238. </otherwise>
  239. </choose>
  240. </select>
  241. <select id="getAuthListAll" resultType="com.caimei.model.vo.AuthVo">
  242. select DISTINCT a.id as authId, a.authUserId, authParty, cbcu2.mobile, a.status, a.auditStatus, a.shopAuditStatus,
  243. a.createTime,
  244. if(a.createSource = 1,ifnull(cu.loginAccount, cu.name),cbcu1.mobile) as createBy,ifnull(au.loginAccount,au.name)
  245. as auditBy,a.auditTime,a.invalidReason,
  246. ifnull(a.shopInvalidReason, a.invalidReason) as shopInvalidReason,
  247. a.sendStatus, ifnull(au1.loginAccount,au1.name) as shopAuditBy,a.shopAuditTime,
  248. ifnull(ap.waitAuditNum,0) as waitAuditNum,
  249. ifnull(bp.waitAuditNum,0) as shopWaitAuditNum,
  250. if(ifnull(ap.waitAuditNum,0)>0,0,1) as lowerAuditStatus,
  251. a.checkFlag,a.starFlag,a.scanCount,ifnull(cp.productNum,0) as productNum,
  252. a.starNum,a.relationId,a.relationName
  253. from cm_brand_auth a
  254. left join cm_brand_auth_user cu on a.createBy = cu.authUserId
  255. left join cm_brand_club_user cbcu1 on a.createBy = cbcu1.id and cbcu1.delFlag = 0
  256. left join cm_brand_auth_user au on a.auditBy = au.authUserId
  257. left join cm_brand_auth_user au1 on a.shopAuditBy = au1.authUserId
  258. left join cm_brand_club_user cbcu2 on a.id = cbcu2.authId and cbcu2.delFlag = 0
  259. left join (select r.authId,p.name,p.snCode,count(*) as waitAuditNum from cm_brand_auth_product p
  260. left join cm_brand_product_relation r on p.id = r.productId
  261. where auditStatus = 2 and shopAuditStatus = 1 group by r.authId) ap on a.id = ap.authId
  262. left join (select r.authId,count(*) as waitAuditNum from cm_brand_auth_product p
  263. left join cm_brand_product_relation r on p.id = r.productId
  264. where shopAuditStatus = 2 group by r.authId) bp on a.id = bp.authId
  265. left join (select r.authId,count(*) as productNum from cm_brand_auth_product p
  266. left join cm_brand_product_relation r on p.id = r.productId and p.shopAuditStatus = 1 group by r.authId) cp
  267. on a.id = cp.authId
  268. LEFT JOIN (SELECT
  269. r.authId,
  270. if(p.name IS NULL,t.name,p.name) as productName,
  271. p.snCode
  272. FROM
  273. cm_brand_auth_product p
  274. LEFT JOIN cm_brand_product_relation r ON p.id = r.productId
  275. LEFT JOIN cm_brand_auth aw on aw.id=r.authId
  276. LEFT JOIN cm_brand_product_type t on p.productTypeId = t.id and t.delFlag = 0
  277. where p.shopAuditStatus=1
  278. ) dp on a.id = dp.authId
  279. where a.authUserId = #{authUserId} and a.delFlag = 0
  280. <if test="authParty != null and authParty != ''">
  281. and a.authParty like CONCAT('%',#{authParty},'%')
  282. </if>
  283. <if test="status != null">
  284. and a.status = #{status}
  285. </if>
  286. <if test="starFlag != null">
  287. and a.starFlag = #{starFlag}
  288. </if>
  289. <if test="auditStatus != null">
  290. and a.auditStatus = #{auditStatus}
  291. </if>
  292. <if test="name != null and name != ''">
  293. and dp.productName = #{name}
  294. </if>
  295. <if test="snCode != null and snCode != ''">
  296. and dp.snCode = #{snCode}
  297. </if>
  298. <if test="1 == listType or 2 == listType">
  299. and a.shopAuditStatus = 1
  300. </if>
  301. <if test="mobile != null and mobile != ''">
  302. and cbcu2.mobile like concat('%', #{mobile},'%')
  303. </if>
  304. <if test="4 == listType">
  305. and a.auditStatus = 1
  306. </if>
  307. <if test="shopAuditStatus != null">
  308. <if test="0 == shopAuditStatus">
  309. and (a.shopAuditStatus = 2 or (a.shopAuditStatus = 1 and ifnull(bp.waitAuditNum,0) > 0))
  310. </if>
  311. <if test="1 == shopAuditStatus">
  312. and (a.shopAuditStatus = 0 or (a.shopAuditStatus = 1 and ifnull(bp.waitAuditNum,0) = 0))
  313. </if>
  314. </if>
  315. <if test="sendStatus != null">
  316. <if test="0 == sendStatus">
  317. and a.sendStatus != 1
  318. </if>
  319. <if test="1 == sendStatus">
  320. and a.sendStatus = 1
  321. </if>
  322. </if>
  323. <if test="lowerAuditStatus != null">
  324. <if test="0 == lowerAuditStatus">
  325. and ifnull(ap.waitAuditNum,0) > 0
  326. </if>
  327. <if test="1 == lowerAuditStatus">
  328. and ifnull(ap.waitAuditNum,0) = 0
  329. </if>
  330. </if>
  331. <choose>
  332. <when test="listType == 2">
  333. order by (case a.auditStatus when 2 then 2 when 0 then 1 else 0 end) desc,waitAuditNum desc,
  334. a.createTime desc
  335. </when>
  336. <when test="listType == 3">
  337. order by (case a.shopAuditStatus when 2 then 2 when 0 then 1 else 0 end) desc,shopWaitAuditNum desc,
  338. a.createTime desc
  339. </when>
  340. <otherwise>
  341. order by a.starNum is null, a.starNum*1,a.createTime desc, a.id desc
  342. </otherwise>
  343. </choose>
  344. </select>
  345. <select id="getProductWaitAuditNum" resultType="java.lang.Integer">
  346. select count(*)
  347. from cm_brand_auth_product p
  348. left join cm_brand_product_relation r on p.id = r.productId
  349. where r.authId = #{authId}
  350. and p.auditStatus = 2
  351. </select>
  352. <select id="getClubStatus" resultType="java.lang.Integer">
  353. select status
  354. from cm_brand_auth
  355. where id = #{authId}
  356. </select>
  357. <select id="getAuthIdByAuthParty" resultType="java.lang.Integer">
  358. select id
  359. from cm_brand_auth
  360. where authParty = #{authParty}
  361. and authUserId = #{authUserId}
  362. and delFlag = 0
  363. </select>
  364. <select id="getAuthPartyList" resultType="com.caimei.model.vo.AuthFormVo">
  365. select authParty,
  366. concat(ifnull(p.name, ''), '/', ifnull(c.name, ''), '/', ifnull(t.name, '')) as area,
  367. address,
  368. concat(lng, ',', lat) as lngAndLat,
  369. mobile,
  370. authCode,
  371. authDate,
  372. empNum,
  373. if(customFlag = 1, remarks, '') as remarks
  374. from cm_brand_auth a
  375. left join province p on a.provinceId = p.provinceID
  376. left join city c on a.cityId = c.cityID
  377. left join town t on a.townId = t.townID
  378. where a.delFlag = 0
  379. and find_in_set(a.id, #{authIds})
  380. order by createTime desc
  381. </select>
  382. <select id="getBannerList" resultType="java.lang.String">
  383. select banner
  384. from cm_brand_auth_banner
  385. where authId = #{authId}
  386. </select>
  387. <select id="getLdmData" resultType="com.caimei.model.po.LdmDataPo">
  388. select name as authParty,
  389. if(status = 1, 1, 0) as status,
  390. if(status = 1, 1, 0) as auditStatus,
  391. tel as mobile,
  392. addr as address,
  393. pic1,
  394. pic2,
  395. pic3,
  396. pic4,
  397. pic5,
  398. du as lngAndLat,
  399. if(deleted_at is null, 0, 1) as delFlag,
  400. regId1,
  401. regId2,
  402. regId3
  403. from nissan_ht_alcohol;
  404. </select>
  405. <select id="getProvinceId" resultType="java.lang.Integer">
  406. select provinceID
  407. from province
  408. where name like
  409. concat(#{provinceName}, '%') limit 1;
  410. </select>
  411. <select id="getCityId" resultType="java.lang.Integer">
  412. select cityID
  413. from city
  414. where name like
  415. concat(#{cityName}, '%') limit 1;
  416. </select>
  417. <select id="getTownId" resultType="java.lang.Integer">
  418. select townID
  419. from town
  420. where name like
  421. concat(#{townName}, '%') limit 1;
  422. </select>
  423. <select id="getLdmLatestClubId" resultType="java.lang.Integer">
  424. select ldmClubId
  425. from ldm_latest_club_id
  426. where id = 1;
  427. </select>
  428. <select id="getCityIdByTownId" resultType="java.lang.Integer">
  429. select cityID
  430. from town
  431. where townID = #{townId}
  432. </select>
  433. <select id="getProvinceName" resultType="java.lang.String">
  434. select name
  435. from nissan_base_region1
  436. where code = #{regId1}
  437. and level = 0 limit 1
  438. </select>
  439. <select id="getCityName" resultType="java.lang.String">
  440. select name
  441. from nissan_base_region1
  442. where code = #{regId1}
  443. and level = 1 limit 1
  444. </select>
  445. <select id="getTownName" resultType="java.lang.String">
  446. select name
  447. from nissan_base_region1
  448. where code = #{regId1}
  449. and level = 2 limit 1
  450. </select>
  451. <select id="getTownList" resultType="com.caimei.model.po.TownPo">
  452. select townID as townId, cityID as cityId
  453. from town
  454. where name like
  455. concat(#{townName}, '%');
  456. </select>
  457. <select id="getProvinceIdByCityId" resultType="java.lang.Integer">
  458. select provinceID
  459. from city
  460. where cityID = #{cityId}
  461. </select>
  462. <select id="getAuthBaseInfo" resultType="com.caimei.model.vo.AuthFormVo">
  463. select a.id as authId, authParty, auditStatus, shopAuditStatus,if(u.id is null,0,1) as bindStatus
  464. from cm_brand_auth a
  465. left join cm_brand_club_user u on a.id = u.authId and u.delFlag = 0
  466. <where>
  467. a.delFlag = 0
  468. <if test="authUserId != null">
  469. and a.authUserId = #{authUserId}
  470. </if>
  471. <if test="authId != null">
  472. and a.id = #{authId}
  473. </if>
  474. </where>
  475. </select>
  476. <select id="getAuthById" resultType="com.caimei.model.vo.AuthVo">
  477. select id as authId,
  478. a.authUserId,
  479. authParty,
  480. a.status,
  481. a.auditStatus,
  482. a.createTime,
  483. cu.name as createBy,
  484. ifnull(au.loginAccount, au.name) as auditBy,
  485. a.auditTime,
  486. a.invalidReason
  487. from cm_brand_auth a
  488. left join cm_brand_auth_user cu on a.createBy = cu.authUserId
  489. left join cm_brand_auth_user au on a.auditBy = au.authUserId
  490. where a.delFlag = 0
  491. and a.id = #{authId}
  492. </select>
  493. <select id="getAuthFormById" resultType="com.caimei.model.vo.AuthFormVo">
  494. select id as authId,
  495. authParty,
  496. authUserId,
  497. a.provinceId,
  498. a.cityId,
  499. a.townId,
  500. concat(ifnull(p.name, ''), '/', ifnull(c.name, ''), '/', ifnull(t.name, '')) as area,
  501. address,
  502. lng,
  503. lat,
  504. mobile,
  505. userMobile,
  506. linkMan,
  507. linkMobile,
  508. firstClubType,
  509. secondClubType,
  510. medicalLicenseImage,
  511. empNum,
  512. logo,
  513. customFlag,
  514. remarks,
  515. authCode,
  516. authDate,
  517. authImageLogo,
  518. authImage,
  519. authImageType,
  520. status,
  521. auditStatus,
  522. relationId,
  523. relationName,
  524. if(shopAuditStatus = 0, shopInvalidReason, invalidReason) as invalidReason
  525. from cm_brand_auth a
  526. left join province p on a.provinceId = p.provinceID
  527. left join city c on a.cityId = c.cityID
  528. left join town t on a.townId = t.townID
  529. where id = #{authId}
  530. and a.delFlag = 0
  531. </select>
  532. <select id="getTownNames" resultType="java.lang.String">
  533. select name
  534. from town
  535. </select>
  536. <select id="getProvinceNames" resultType="java.lang.String">
  537. SELECT NAME
  538. FROM province
  539. </select>
  540. <select id="getCityNames" resultType="java.lang.String">
  541. select name from city
  542. <if test="ProvinceId !=null">
  543. where provinceID = #{ProvinceId}
  544. </if>
  545. </select>
  546. <select id="getCityIdByProvinceId" resultType="java.lang.Integer">
  547. select cityId from city
  548. where name like concat(#{cityName},'%')
  549. <if test="provinceId !=null">
  550. and provinceID = #{provinceId}
  551. </if>
  552. limit 1
  553. </select>
  554. <select id="getProvinceNameById" resultType="java.lang.String">
  555. select name
  556. from province
  557. where provinceID = #{provinceId}
  558. </select>
  559. <select id="getCityNameByCityId" resultType="java.lang.String">
  560. select name
  561. from city
  562. where cityID = #{cityId}
  563. </select>
  564. <select id="getTownNameById" resultType="java.lang.String">
  565. select name
  566. from town
  567. where townID = #{townId}
  568. </select>
  569. <select id="getAuthByNameAndAddress" resultType="com.caimei.model.vo.AuthVo">
  570. select id as authId
  571. from cm_brand_auth
  572. where authParty like concat('%', #{authParty}, '%')
  573. and address like concat('%', #{address}, '%')
  574. and delFlag = 0
  575. </select>
  576. <select id="getAdminUserId" resultType="java.lang.Integer">
  577. select authUserId
  578. from cm_brand_auth_user
  579. where userIdentity = 1 limit 1
  580. </select>
  581. <select id="getAuthTemplate" resultType="com.caimei.model.vo.TemplateVo">
  582. select at.id as templateId, templateImage, qrPosition, qrSize
  583. from cm_brand_auth_template at
  584. left join cm_brand_auth a on at.authUserId = a.authUserId and a.delFlag = 0
  585. where at.status = 1
  586. <if test="templateType == 1">
  587. and at.authFlag = 1
  588. </if>
  589. <if test="templateType == 2">
  590. and at.productFlag = 1
  591. </if>
  592. <if test="authId != null">
  593. and a.id = #{authId}
  594. </if>
  595. <if test="authUserId != null">
  596. and at.authUserId = #{authUserId}
  597. </if>
  598. limit 1
  599. </select>
  600. <select id="getAllAuth" resultType="com.caimei.model.po.CmBrandAuthPo">
  601. select id, authUserId, authImageType, authCode, authDate, authImageLogo
  602. from cm_brand_auth
  603. where authUserId = #{authUserId}
  604. and delFlag = 0
  605. </select>
  606. <select id="getAuthIdList" resultType="com.caimei.model.vo.AuthFormVo">
  607. select id as authId,authParty from cm_brand_auth where
  608. id in
  609. <foreach collection="relationIdList" open="(" separator="," close=")" item="reId">
  610. #{reId,jdbcType=VARCHAR}
  611. </foreach>
  612. </select>
  613. <select id="getRelationgInfo" resultType="com.caimei.model.vo.AuthFormVo">
  614. select relationId, relationName
  615. from cm_brand_auth
  616. where authUserId = #{authUserId}
  617. and id = #{authId}
  618. and delFlag = 0
  619. </select>
  620. <select id="getClubBindAuth" resultType="com.caimei.model.vo.AuthFormVo">
  621. select au.id as authId,au.authParty
  622. from cm_brand_auth au
  623. where au.id not in (
  624. select cu.authId
  625. from cm_brand_auth a
  626. left join cm_brand_club_user cu on cu.authId = a.id
  627. where cu.authUserId = #{authUserId}
  628. and cu.delFlag = 0
  629. and (a.id is null || a.delFlag = 0))
  630. and au.delFlag = 0 and au.authUserId = #{authUserId}
  631. </select>
  632. <select id="getRelationgList" resultType="com.caimei.model.vo.ProductFormVo">
  633. select DISTINCT r.authId as relationId
  634. from cm_brand_product_relation r
  635. LEFT JOIN cm_brand_auth_product a on r.productId = a.id
  636. where snCode =#{snCode}
  637. </select>
  638. <select id="getPrefix" resultType="java.lang.String">
  639. select ifnull(prefix,'app')
  640. from cm_brand_auth_user
  641. where authUserId = #{authUserId}
  642. </select>
  643. <insert id="saveVideoInfo">
  644. insert into cm_challenge_round(userName,title,ossName,ossUrl,cover,releaseTime,authId,authUserId)
  645. values(#{userName},#{title},#{ossName},#{ossUrl},#{cover},#{releaseTime},#{authId},#{authUserId})
  646. </insert>
  647. <insert id="saveVideo">
  648. insert into cm_ross_challenge_video(userName,title,ossName,ossUrl,cover,releaseTime,authId,linked,authUserId)
  649. values(#{userName},#{title},#{ossName},#{ossUrl},#{cover},#{releaseTime},#{authId},#{linked},#{authUserId})
  650. </insert>
  651. <select id="getauthUserId" resultType="java.lang.String">
  652. select authUserId
  653. from cm_brand_auth
  654. where id = #{authId}
  655. </select>
  656. <select id="getuserName" resultType="java.lang.String">
  657. select userName
  658. from cm_challenge_round
  659. where userName = #{userName}
  660. </select>
  661. <select id="checkActivityTime" resultType="java.lang.Integer">
  662. select id
  663. from cm_challenge_activity
  664. where startTime &lt;#{releaseTime} and endTime &gt;#{releaseTime} and status=1
  665. </select>
  666. <select id="getPublishedVideoList" resultType="com.caimei.model.vo.ChallengeRoundVo">
  667. 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,cr.diggCount,cr.playCount
  668. from cm_challenge_round cr
  669. left join cm_brand_auth cba on cr.authId=cba.id
  670. left join cm_challenge_activity cca on cca.authUserId=cr.authUserId
  671. where cr.authUserId=#{authUserId}
  672. <if test="clubUserName != null and clubUserName != ''">
  673. and (cr.userName like concat('%', #{clubUserName})
  674. or cba.authParty like concat('%', #{clubUserName},'%') )
  675. </if>
  676. and cr.releaseTime &gt;#{startTime} and cr.releaseTime&lt;#{endTime}
  677. </select>
  678. <select id="getPublishedVideoListNoRanking" resultType="com.caimei.model.vo.ChallengeRoundVo">
  679. 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,cr.diggCount,cr.playCount
  680. from cm_challenge_round cr
  681. left join cm_brand_auth cba on cr.authId=cba.id
  682. left join cm_challenge_activity cca on cca.authUserId=cr.authUserId
  683. where cr.authUserId=#{authUserId}
  684. <if test="clubUserName != null and clubUserName != ''">
  685. and (cr.userName like concat('%', #{clubUserName})
  686. or cba.authParty like concat('%', #{clubUserName},'%') )
  687. </if>
  688. and (cr.releaseTime &lt;#{startTime} or cr.releaseTime &gt;#{endTime})
  689. </select>
  690. <select id="getPublishedVideo" resultType="com.caimei.model.vo.ChallengeRoundVo">
  691. 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,cr.diggCount,cr.playCount
  692. from cm_challenge_round cr
  693. left join cm_brand_auth cba on cr.authId=cba.id
  694. left join cm_challenge_activity cca on cca.authUserId=cr.authUserId
  695. where cr.authUserId=#{authUserId}
  696. and cr.releaseTime &gt;#{startTime} and cr.releaseTime&lt;#{endTime}
  697. <if test="mobile != null and mobile != ''">
  698. and cr.userName like concat('%', #{mobile})
  699. </if>
  700. <if test="authParty != null and authParty != ''">
  701. and cba.authParty like concat('%', #{authParty},'%')
  702. </if>
  703. <if test="status != null">
  704. and cr.status = #{status}
  705. </if>
  706. </select>
  707. <select id="getPublishedVideoNoRanking" resultType="com.caimei.model.vo.ChallengeRoundVo">
  708. 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,cr.diggCount,cr.playCount
  709. from cm_challenge_round cr
  710. left join cm_brand_auth cba on cr.authId=cba.id
  711. left join cm_challenge_activity cca on cca.authUserId=cr.authUserId
  712. where cr.authUserId=#{authUserId}
  713. and (cr.releaseTime &lt;#{startTime} or cr.releaseTime &gt;#{endTime})
  714. <if test="mobile != null and mobile != ''">
  715. and cr.userName like concat('%', #{mobile})
  716. </if>
  717. <if test="authParty != null and authParty != ''">
  718. and cba.authParty like concat('%', #{authParty},'%')
  719. </if>
  720. <if test="status != null">
  721. and cr.status = #{status}
  722. </if>
  723. </select>
  724. <select id="checkActivityId" resultType="com.caimei.model.vo.ChallengeActivityVo">
  725. select id,authUserId
  726. from cm_challenge_activity
  727. </select>
  728. <insert id="saveActivityInfo">
  729. insert into cm_challenge_activity(startTime,endTime,status,authUserId)
  730. values(#{startTime},#{endTime},#{status},#{authUserId})
  731. </insert>
  732. <update id="upActivityInfo">
  733. update cm_challenge_activity set
  734. startTime=#{startTime},
  735. endTime=#{endTime},
  736. status = #{status}
  737. where authUserId=#{authUserId}
  738. </update>
  739. <select id="getActivityTime" resultType="com.caimei.model.vo.ChallengeActivityVo">
  740. select id,startTime,endTime,status,authUserId
  741. from cm_challenge_activity
  742. where authUserId=#{authUserId}
  743. </select>
  744. <update id="savaShareIdByAuthId">
  745. update cm_challenge_round set
  746. shareId=#{shareId}
  747. where authId=#{authId}
  748. </update>
  749. <select id="getShareId" resultType="java.lang.String">
  750. select shareId
  751. from cm_challenge_round
  752. where shareId=#{shareId}
  753. </select>
  754. <update id="savaItemIdByShareId">
  755. update cm_challenge_round set
  756. itemId=#{itemId},
  757. status=1
  758. where shareId=#{shareId}
  759. </update>
  760. <select id="getAuthUserName" resultType="java.lang.String">
  761. select name
  762. from cm_brand_auth cba
  763. left join cm_brand_auth_user cu on cu.authUserId=cba.authUserId
  764. where cba.id=#{authId}
  765. </select>
  766. <select id="getMobileByAuthId" resultType="java.lang.String">
  767. select userName
  768. from cm_challenge_round cr
  769. where cr.authId=#{authId}
  770. </select>
  771. <update id="savaDyCommand">
  772. update cm_challenge_round set
  773. dyCommand=#{content}
  774. where authId=#{authId}
  775. </update>
  776. <select id="getAuthPartylist" resultType="com.caimei.model.vo.ChallengeRoundVo">
  777. 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,cr.diggCount,cr.playCount
  778. from cm_challenge_round cr left join cm_brand_auth cba
  779. on cr.authId=cba.id
  780. where cr.authUserId=#{authUserId}
  781. </select>
  782. <select id="getOssNameId" resultType="java.lang.String">
  783. select ossName
  784. from cm_challenge_round cr
  785. where cr.id=#{videoID}
  786. </select>
  787. <delete id="deleteVideoById">
  788. delete
  789. from cm_challenge_round
  790. where id = #{videoID}
  791. </delete>
  792. <select id="getChallengeRoundInfo" resultType="com.caimei.model.vo.ChallengeRoundVo">
  793. 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,cr.diggCount,cr.playCount
  794. from cm_challenge_round cr
  795. where cr.id=#{videoID}
  796. </select>
  797. <select id="getChallengeVideoInfo" resultType="com.caimei.model.vo.RossChallengeVideo">
  798. select cr.*
  799. from cm_ross_challenge_video cr
  800. where cr.id=#{videoID}
  801. </select>
  802. <update id="upStatusById">
  803. update cm_challenge_activity set
  804. status = 0
  805. where id=#{id}
  806. </update>
  807. <select id="getReleaseTime" resultType="java.lang.String">
  808. select releaseTime
  809. from cm_challenge_round cr
  810. where cr.userName=#{userName}
  811. </select>
  812. <select id="getRoundlist" resultType="com.caimei.model.vo.ChallengeRoundVo">
  813. select cr.id,cr.userName,cr.authUserId,cr.itemId,cr.title,cr.ossName,cr.ossUrl,cr.cover,cr.releaseTime,cr.status,cr.shareId, cr.authId,cr.dyCommand,cr.diggCount,cr.playCount
  814. from cm_challenge_round cr
  815. </select>
  816. <update id="upVidoInfoById">
  817. update cm_challenge_round set
  818. diggCount=#{diggCount},
  819. playCount=#{playCount}
  820. where id=#{videoId}
  821. </update>
  822. <insert id="saveRossInfo" parameterType="com.caimei.model.vo.RossChallengeRoundVo">
  823. insert into cm_ross_challenge_round(authUserId,authId,userName,contestStatus,contestTime,licenseOssUrl,licenseOssName,authenticationStatus,clubUserId)
  824. values(#{authUserId},#{authId},#{userName},#{contestStatus},#{contestTime},#{licenseOssUrl},#{licenseOssName},#{authenticationStatus},#{clubUserId})
  825. </insert>
  826. <select id="getClubUserId" resultType="java.lang.Integer">
  827. select id from cm_brand_club_user where mobile=#{mobile}
  828. </select>
  829. <select id="getInfoByUserName" resultType="com.caimei.model.vo.RossChallengeRoundVo">
  830. select * from cm_ross_challenge_round where userName=#{userName} and contestStatus=1
  831. </select>
  832. <select id="getcontestedInfo" resultType="com.caimei.model.vo.RossChallengeRoundVo">
  833. select * from cm_ross_challenge_round where contestStatus=1 and authUserId=#{authUserId}
  834. </select>
  835. <select id="getcontestedInfoByUserName" resultType="com.caimei.model.vo.RossChallengeRoundVo">
  836. select * from cm_ross_challenge_round where userName=#{mobile}
  837. and contestTime &gt; #{startTime} and contestTime &lt; #{endTime}
  838. </select>
  839. <select id="getVideoAll" resultType="com.caimei.model.vo.RossChallengeVideo">
  840. select cr.*,cba.authParty from cm_ross_challenge_video cr
  841. left join cm_brand_auth cba on cr.authId=cba.id
  842. where cr.authUserId=#{authUserId}
  843. <if test="mobileOrAuthpart != null and mobileOrAuthpart != ''">
  844. and (cr.userName like concat('%', #{mobileOrAuthpart})
  845. or cba.authParty like concat('%', #{mobileOrAuthpart},'%') )
  846. </if>
  847. order by cr.diggCount desc,releaseTime
  848. </select>
  849. <select id="getVideoByUsername" resultType="com.caimei.model.vo.RossChallengeVideo">
  850. select * from cm_ross_challenge_video
  851. where
  852. userName = #{mobile}
  853. order by diggCount desc,releaseTime
  854. </select>
  855. <select id="checkVideoByUsername" resultType="com.caimei.model.vo.RossChallengeVideo">
  856. select * from cm_ross_challenge_video
  857. where userName = #{mobile}
  858. and releaseTime &gt; #{startTime} and releaseTime &lt; #{endTime}
  859. </select>
  860. <update id="upVideoDiggCount">
  861. update cm_ross_challenge_video
  862. <set>
  863. clubUserIds=#{clubUserIds}
  864. <if test="null != diggFlag and diggFlag==1">
  865. ,diggCount=diggCount+1
  866. </if>
  867. <if test="null != diggFlag and diggFlag==0">
  868. ,diggCount=diggCount-1
  869. </if>
  870. </set>
  871. where id=#{videoId}
  872. </update>
  873. <select id="getAuthInfo" resultType="com.caimei.model.vo.RossChallengeRoundVo">
  874. select cr.*,cba.authParty from cm_ross_challenge_round cr
  875. left join cm_brand_auth cba on cr.authId=cba.id
  876. where cr.authUserId=#{authUserId}
  877. and cr.contestTime &gt; #{StartTime} and cr.contestTime &lt; #{endTime}
  878. <if test="null!=mobile and mobile !=''">
  879. and cr.userName like concat('%', #{mobile})
  880. </if>
  881. order by contestTime desc
  882. </select>
  883. <delete id="delAuthInfoById">
  884. delete from cm_ross_challenge_round where id=#{id}
  885. </delete>
  886. <delete id="delVideoInfoById">
  887. delete from cm_ross_challenge_video where id=#{id}
  888. </delete>
  889. <delete id="delVideoInfoByUserName">
  890. delete from cm_ross_challenge_video where userName=#{mobile}
  891. </delete>
  892. <select id="getRoundById" resultType="com.caimei.model.vo.RossChallengeRoundVo">
  893. select * from cm_ross_challenge_round where id=#{id}
  894. </select>
  895. <select id="getRoundByAuthUserID" resultType="com.caimei.model.vo.RossChallengeRoundVo">
  896. select * from cm_ross_challenge_round where authUserId=#{authUserId} and contestStatus=1
  897. </select>
  898. <select id="getAuthparty" resultType="java.lang.String">
  899. select name from cm_brand_auth_user where authUserId=#{authUserId}
  900. </select>
  901. </mapper>