AuthMapper.xml 37 KB

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