AuthMapper.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  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" parameterType="com.caimei.model.po.CmBrandAuthPo">
  5. insert into cm_brand_auth (authUserId, authParty, provinceId, cityId, townId, address, lng, lat,
  6. mobile, userMobile, firstClubType, secondClubType, medicalLicenseImage, empNum,
  7. logo, customFlag, remarks, status, createTime, createBy, auditStatus, shopAuditStatus, delFlag)
  8. values (#{authUserId}, #{authParty}, #{provinceId}, #{cityId}, #{townId}, #{address}, #{lng}, #{lat},
  9. #{mobile}, #{userMobile}, #{firstClubType}, #{secondClubType}, #{medicalLicenseImage}, #{empNum},
  10. #{logo}, #{customFlag}, #{remarks}, #{status}, NOW(), #{createBy}, #{auditStatus}, #{shopAuditStatus}, #{delFlag})
  11. </insert>
  12. <insert id="insertBanner">
  13. insert into cm_brand_auth_banner (authId, banner)
  14. VALUES (#{authId}, #{banner})
  15. </insert>
  16. <insert id="sendCertificate">
  17. insert into logistics_information (type, authId, nu, state, logisticsCompanyName, logisticsCompanyCode,
  18. updateDate, remarks, remarksImage)
  19. values (#{type}, #{authId}, #{logisticsNumber}, #{state}, #{companyName}, #{companyCode}, #{updateDate},
  20. #{remarks}, #{image})
  21. </insert>
  22. <update id="updateAuthStatusByAuthId">
  23. update cm_brand_auth
  24. set status = #{status}
  25. where id = #{authId}
  26. </update>
  27. <update id="updateAuthByAuthId">
  28. update cm_brand_auth
  29. set authParty = #{authParty},
  30. provinceId = #{provinceId},
  31. cityId = #{cityId},
  32. townId = #{townId},
  33. address = #{address},
  34. lng = #{lng},
  35. lat = #{lat},
  36. mobile = #{mobile},
  37. userMobile = #{userMobile},
  38. firstClubType = #{firstClubType},
  39. secondClubType = #{secondClubType},
  40. logo = #{logo},
  41. customFlag = #{customFlag},
  42. remarks = #{remarks},
  43. status = #{status},
  44. auditStatus = #{auditStatus},
  45. shopAuditStatus = #{shopAuditStatus}
  46. where id = #{id}
  47. </update>
  48. <update id="updateAuthAuditStatus">
  49. update cm_brand_auth
  50. set status = #{status},
  51. auditStatus = #{auditStatus},
  52. invalidReason = #{invalidReason},
  53. auditBy = #{auditBy},
  54. auditTime = #{auditTime}
  55. where id = #{authId}
  56. </update>
  57. <update id="deleteAuthByAuthId">
  58. update cm_brand_auth set delFlag = 1 where id = #{authId}
  59. </update>
  60. <update id="updateLdmLatestClubId">
  61. update ldm_latest_club_id set ldmClubId = #{ldmLatestClubId} where id = 1;
  62. </update>
  63. <update id="updateAuthShopAuditStatus">
  64. update cm_brand_auth
  65. set shopAuditStatus = #{shopAuditStatus},
  66. shopInvalidReason = #{shopInvalidReason},
  67. shopAuditTime = #{shopAuditTime}
  68. where id = #{authId}
  69. </update>
  70. <update id="updateSendStatus">
  71. update cm_brand_auth
  72. set sendStatus = 1
  73. where id = #{authId}
  74. </update>
  75. <delete id="deleteBanner">
  76. delete from cm_brand_auth_banner where authId = #{authId}
  77. </delete>
  78. <select id="getAuthList" resultType="com.caimei.model.vo.AuthVo">
  79. select id as authId, authParty, a.status, a.auditStatus, a.shopAuditStatus, a.createTime, cu.name as createBy,
  80. au.name as auditBy,a.auditTime,a.invalidReason,
  81. ifnull(ap.waitAuditNum,0) as waitAuditNum,
  82. ifnull(bp.waitAuditNum,0) as shopWaitAuditNum,
  83. if(ifnull(ap.waitAuditNum,0)>0,0,1) as lowerAuditStatus
  84. from cm_brand_auth a
  85. left join cm_brand_auth_user cu on a.createBy = cu.authUserId
  86. left join cm_brand_auth_user au on a.auditBy = au.authUserId
  87. left join (select authId,count(*) as waitAuditNum from cm_brand_auth_product where auditStatus = 2 group by
  88. authId) ap on a.id = ap.authId
  89. left join (select authId,count(*) as waitAuditNum from cm_brand_auth_product where shopAuditStatus = 2 group by
  90. authId) bp on a.id = bp.authId
  91. where a.authUserId = #{authUserId} and delFlag = 0
  92. <if test="authParty != null and authParty != ''">
  93. and a.authParty like CONCAT('%',#{authParty},'%')
  94. </if>
  95. <if test="status != null">
  96. and a.status = #{status}
  97. </if>
  98. <if test="auditStatus != null">
  99. and a.auditStatus = #{auditStatus}
  100. </if>
  101. <if test="1 == listType or 2 == listType">
  102. and a.shopAuditStatus = 1
  103. </if>
  104. <if test="4 == listType">
  105. and a.auditStatus = 1
  106. </if>
  107. <if test="shopAuditStatus != null">
  108. <if test="0 == shopAuditStatus">
  109. and (a.shopAuditStatus = 2 or ifnull(bp.waitAuditNum,0) > 0)
  110. </if>
  111. <if test="1 == shopAuditStatus">
  112. and (a.shopAuditStatus = 0 or a.shopAuditStatus = 1 or ifnull(bp.waitAuditNum,0) > 0)
  113. </if>
  114. </if>
  115. <if test="lowerAuditStatus != null">
  116. <if test="0 == lowerAuditStatus">
  117. and ifnull(ap.waitAuditNum,0) > 0
  118. </if>
  119. <if test="1 == lowerAuditStatus">
  120. and ifnull(ap.waitAuditNum,0) = 0
  121. </if>
  122. </if>
  123. <choose>
  124. <when test="listType == 2">
  125. order by (case a.auditStatus when 2 then 2 when 0 then 1 else 0 end) desc,waitAuditNum desc, a.createTime desc
  126. </when>
  127. <when test="listType == 3">
  128. order by (case a.shopAuditStatus when 2 then 2 when 0 then 1 else 0 end) desc,shopWaitAuditNum desc, a.createTime desc
  129. </when>
  130. <otherwise>
  131. order by a.createTime desc, a.id desc
  132. </otherwise>
  133. </choose>
  134. </select>
  135. <select id="getProductWaitAuditNum" resultType="java.lang.Integer">
  136. select count(*)
  137. from cm_brand_auth_product
  138. where authId = #{authId}
  139. and auditStatus = 2
  140. </select>
  141. <select id="getClubStatus" resultType="java.lang.Integer">
  142. select status
  143. from cm_brand_auth
  144. where id = #{authId}
  145. </select>
  146. <select id="getAuthIdByAuthParty" resultType="java.lang.Integer">
  147. select id
  148. from cm_brand_auth
  149. where authParty = #{authParty}
  150. and authUserId = #{authUserId}
  151. </select>
  152. <select id="getAuthPartyList" resultType="com.caimei.model.po.CmBrandAuthPo">
  153. select id, authParty
  154. from cm_brand_auth
  155. where authUserId = #{authUserId}
  156. order by createTime desc
  157. </select>
  158. <select id="getBannerList" resultType="java.lang.String">
  159. select banner from cm_brand_auth_banner where authId = #{authId}
  160. </select>
  161. <select id="getLdmData" resultType="com.caimei.model.po.LdmDataPo">
  162. select name as authParty,if(status = 1,1,0) as status,if(status = 1,1,0) as auditStatus,
  163. tel as mobile,addr as address,pic1,pic2,pic3,pic4,pic5,du as lngAndLat,
  164. if(deleted_at is null,0,1) as delFlag,regId1,regId2,regId3
  165. from nissan_ht_alcohol;
  166. </select>
  167. <select id="getProvinceId" resultType="java.lang.Integer">
  168. select provinceID
  169. from province
  170. where name like
  171. concat(#{provinceName},'%') limit 1;
  172. </select>
  173. <select id="getCityId" resultType="java.lang.Integer">
  174. select cityID
  175. from city
  176. where name like
  177. concat(#{cityName},'%') limit 1;
  178. </select>
  179. <select id="getTownId" resultType="java.lang.Integer">
  180. select townID
  181. from town
  182. where name like
  183. concat(#{townName},'%') limit 1;
  184. </select>
  185. <select id="getLdmLatestClubId" resultType="java.lang.Integer">
  186. select ldmClubId from ldm_latest_club_id where id = 1;
  187. </select>
  188. <select id="getCityIdByTownId" resultType="java.lang.Integer">
  189. select cityID from town where townID = #{townId}
  190. </select>
  191. <select id="getProvinceName" resultType="java.lang.String">
  192. select name from nissan_base_region1 where code = #{regId1} and level = 0 limit 1
  193. </select>
  194. <select id="getCityName" resultType="java.lang.String">
  195. select name from nissan_base_region1 where code = #{regId1} and level = 1 limit 1
  196. </select>
  197. <select id="getTownName" resultType="java.lang.String">
  198. select name from nissan_base_region1 where code = #{regId1} and level = 2 limit 1
  199. </select>
  200. <select id="getTownList" resultType="com.caimei.model.po.TownPo">
  201. select townID as townId, cityID as cityId
  202. from town
  203. where name like
  204. concat(#{townName},'%');
  205. </select>
  206. <select id="getProvinceIdByCityId" resultType="java.lang.Integer">
  207. select provinceID from city where cityID = #{cityId}
  208. </select>
  209. <select id="getAuthByUserMobile" resultType="com.caimei.model.vo.AuthFormVo">
  210. select id as authId, authParty
  211. from cm_brand_auth
  212. where authUserId = #{authUserId}
  213. and userMobile = #{mobile}
  214. </select>
  215. <select id="getAuthById" resultType="com.caimei.model.vo.AuthVo">
  216. select id as authId,
  217. a.authUserId,
  218. authParty,
  219. a.status,
  220. a.auditStatus,
  221. a.createTime,
  222. cu.name as createBy,
  223. au.name as auditBy,
  224. a.auditTime,
  225. a.invalidReason
  226. from cm_brand_auth a
  227. left join cm_brand_auth_user cu on a.createBy = cu.authUserId
  228. left join cm_brand_auth_user au on a.auditBy = au.authUserId
  229. where a.delFlag = 0
  230. and a.id = #{authId}
  231. </select>
  232. <select id="getAuthFormById" resultType="com.caimei.model.vo.AuthFormVo">
  233. select id as authId,
  234. authParty,
  235. authUserId,
  236. a.provinceId,
  237. a.cityId,
  238. a.townId,
  239. concat(p.name, '/', c.name, '/', t.name) as area,
  240. address,
  241. lng,
  242. lat,
  243. mobile,
  244. userMobile,
  245. firstClubType,
  246. secondClubType,
  247. medicalLicenseImage,
  248. empNum,
  249. logo,
  250. customFlag,
  251. remarks,
  252. status,
  253. auditStatus,
  254. shopAuditStatus,
  255. shopInvalidReason
  256. from cm_brand_auth a
  257. left join province p on a.provinceId = p.provinceID
  258. left join city c on a.cityId = c.cityID
  259. left join town t on a.townId = t.townID
  260. where id = #{authId}
  261. </select>
  262. </mapper>