UserSubscribeMapper.xml 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.zhongzheng.modules.user.mapper.UserSubscribeMapper">
  6. <resultMap type="com.zhongzheng.modules.user.domain.UserSubscribe" id="UserSubscribeResult">
  7. <result property="subscribeId" column="subscribe_id"/>
  8. <result property="goodsId" column="goods_id"/>
  9. <result property="userId" column="user_id"/>
  10. <result property="subscribeStatus" column="subscribe_status"/>
  11. <result property="beforeStatus" column="before_status"/>
  12. <result property="examStatus" column="exam_status"/>
  13. <result property="performance" column="performance"/>
  14. <result property="result" column="result"/>
  15. <result property="certificateCode" column="certificate_code"/>
  16. <result property="applyId" column="apply_id"/>
  17. <result property="studentType" column="student_type"/>
  18. <result property="examExpend" column="exam_expend"/>
  19. <result property="beforeExpend" column="before_expend"/>
  20. <result property="createTime" column="create_time"/>
  21. <result property="updateTime" column="update_time"/>
  22. <result property="importNo" column="import_no"/>
  23. <result property="orderGoodsId" column="order_goods_id"/>
  24. <result property="examineeCode" column="examinee_code"/>
  25. <result property="reportStatus" column="report_status"/>
  26. <result property="seatNumber" column="seat_number"/>
  27. <result property="reportFile" column="report_file"/>
  28. <result property="siteId" column="site_id"/>
  29. <result property="syncStatus" column="sync_status"/>
  30. <result property="roomAddress" column="room_address"/>
  31. <result property="syncResult" column="sync_result"/>
  32. <result property="roomName" column="room_name"/>
  33. <result property="roomId" column="room_id"/>
  34. <result property="roomCode" column="room_code"/>
  35. <result property="wisdomExamStatus" column="wisdom_exam_status"/>
  36. <result property="wisdomReportTime" column="wisdom_report_time"/>
  37. <result property="wisdomTemperature" column="wisdom_temperature"/>
  38. <result property="syncExamResult" column="sync_exam_result"/>
  39. <result property="signaturePushTime" column="signature_push_time"/>
  40. <result property="reportFileTime" column="report_file_time"/>
  41. <result property="snapPictures" column="snap_pictures"/>
  42. </resultMap>
  43. <resultMap type="com.zhongzheng.modules.user.vo.UserSubscribeVo" id="UserSubscribeVo">
  44. <result property="subscribeId" column="subscribe_id"/>
  45. <result property="goodsId" column="goods_id"/>
  46. <result property="userId" column="user_id"/>
  47. <result property="subscribeStatus" column="subscribe_status"/>
  48. <result property="beforeStatus" column="before_status"/>
  49. <result property="examStatus" column="exam_status"/>
  50. <result property="performance" column="performance"/>
  51. <result property="result" column="result"/>
  52. <result property="certificateCode" column="certificate_code"/>
  53. <result property="applyId" column="apply_id"/>
  54. <result property="studentType" column="student_type"/>
  55. <result property="examExpend" column="exam_expend"/>
  56. <result property="beforeExpend" column="before_expend"/>
  57. <result property="createTime" column="create_time"/>
  58. <result property="goodsName" column="goods_name"/>
  59. <result property="categoryName" column="category_name"/>
  60. <result property="goodsCode" column="goods_code"/>
  61. <result property="remark" column="remark"/>
  62. <result property="standPrice" column="stand_price"/>
  63. <result property="realname" column="realname"/>
  64. <result property="idCard" column="id_card" typeHandler="com.zhongzheng.common.type.EncryptHandler"/>
  65. <result property="applyName" column="apply_name"/>
  66. <result property="beforeId" column="before_id"/>
  67. <result property="beforeName" column="before_name"/>
  68. <result property="applySiteAddress" column="apply_site_address"/>
  69. <result property="applySiteStartTime" column="apply_site_start_time"/>
  70. <result property="applySiteEndTime" column="apply_site_end_time"/>
  71. <result property="applySiteExamTime" column="apply_site_exam_time"/>
  72. <result property="applySiteAddressTrain" column="apply_site_address_train"/>
  73. <result property="applySiteStartTrainTime" column="apply_site_start_train_time"/>
  74. <result property="applySiteEndTrainTime" column="apply_site_end_train_time"/>
  75. <result property="applySiteExamTrainTime" column="apply_site_exam_train_time"/>
  76. <result property="applyStartTime" column="apply_start_time"/>
  77. <result property="applyEndTime" column="apply_end_time"/>
  78. <result property="businessId" column="business_id"/>
  79. <result property="beforeCount" column="before_count"/>
  80. <result property="beforeName" column="before_name"/>
  81. <result property="importNo" column="import_no"/>
  82. <result property="orderGoodsId" column="order_goods_id"/>
  83. <result property="examineeCode" column="examinee_code"/>
  84. <result property="reportStatus" column="report_status"/>
  85. <result property="seatNumber" column="seat_number"/>
  86. <result property="reportFile" column="report_file"/>
  87. <result property="siteId" column="site_id"/>
  88. <result property="syncStatus" column="sync_status"/>
  89. <result property="roomAddress" column="room_address"/>
  90. <result property="syncResult" column="sync_result"/>
  91. <result property="roomName" column="room_name"/>
  92. <result property="telphone" column="telphone" typeHandler="com.zhongzheng.common.type.EncryptHandler"/>
  93. <result property="idCardImg1" column="id_card_img1"/>
  94. <result property="idCardImg2" column="id_card_img2"/>
  95. <result property="oneInchPhotos" column="one_inch_photos"/>
  96. <result property="centerId" column="center_id"/>
  97. <result property="applyCode" column="apply_code"/>
  98. <result property="roomId" column="room_id"/>
  99. <result property="roomCode" column="room_code"/>
  100. <result property="wisdomExamStatus" column="wisdom_exam_status"/>
  101. <result property="wisdomReportTime" column="wisdom_report_time"/>
  102. <result property="wisdomTemperature" column="wisdom_temperature"/>
  103. <result property="syncExamResult" column="sync_exam_result"/>
  104. <result property="signaturePushTime" column="signature_push_time"/>
  105. <result property="reportFileTime" column="report_file_time"/>
  106. <result property="applyReportStatus" column="apply_report_status"/>
  107. <result property="fromPlat" column="from_plat"/>
  108. <result property="snapPictures" column="snap_pictures"/>
  109. </resultMap>
  110. <resultMap type="com.zhongzheng.modules.user.vo.UserVo" id="UserVoResult">
  111. <result property="telphone" column="telphone" typeHandler="com.zhongzheng.common.type.EncryptHandler"/>
  112. <result property="realname" column="realname"/>
  113. <result property="job" column="job"/>
  114. <result property="sex" column="sex"/>
  115. <result property="telphone" column="telphone" typeHandler="com.zhongzheng.common.type.EncryptHandler"/>
  116. <result property="idCard" column="id_card" typeHandler="com.zhongzheng.common.type.EncryptHandler"/>
  117. <result property="eduLevel" column="edu_level"/>
  118. <result property="oneInchPhotos" column="one_inch_photos"/>
  119. <result property="idCardImg1" column="id_card_img1"/>
  120. <result property="idCardImg2" column="id_card_img2"/>
  121. <result property="keyValue" column="key_value"/>
  122. <result property="applySiteExamTime" column="apply_site_exam_time"/>
  123. <result property="applySiteStartTime" column="apply_site_start_time"/>
  124. <result property="applySiteEndTime" column="apply_site_end_time"/>
  125. <result property="subscribeId" column="subscribe_id"/>
  126. <result property="seatNumber" column="seat_number"/>
  127. </resultMap>
  128. <select id="listSubscribe" parameterType="com.zhongzheng.modules.user.bo.UserSubscribeQueryBo" resultMap="UserSubscribeVo">
  129. SELECT
  130. us.*, eb.before_name,
  131. (SELECT g.goods_name FROM goods g where us.goods_id = g.goods_id) as goods_name,
  132. (SELECT g.code FROM goods g where us.goods_id = g.goods_id) as goods_code,
  133. (SELECT g.stand_price FROM goods g where us.goods_id = g.goods_id) as stand_price,
  134. (SELECT m.category_name FROM goods g LEFT JOIN major m on g.major_id= m.id where us.goods_id = g.goods_id) as category_name,
  135. u.realname,
  136. u.id_card,
  137. (SELECT ea.apply_name FROM exam_apply ea where ea.apply_id = us.apply_id) as apply_name,
  138. (SELECT ea.apply_start_time FROM exam_apply ea where ea.apply_id = us.apply_id) as apply_start_time,
  139. (SELECT ea.apply_end_time FROM exam_apply ea where ea.apply_id = us.apply_id) as apply_end_time,
  140. (SELECT eb.before_name FROM exam_before eb where eb.before_id = us.before_id) as before_name,
  141. (SELECT ea.report_status FROM exam_apply ea where ea.apply_id = us.apply_id) as apply_report_status,
  142. (SELECT ueg.do_number-ueg.expend_before FROM user_exam_goods ueg where ueg.goods_id = us.goods_id and ueg.user_id = us.user_id ORDER BY user_exam_goods_id DESC limit 1) as before_count,
  143. ueg.exam_number,
  144. ueg.do_number,
  145. ueg.expend_number,
  146. es.from_plat,
  147. ueg.expend_before
  148. FROM
  149. user_subscribe us
  150. LEFT JOIN exam_before eb ON us.before_id = eb.before_id
  151. LEFT JOIN `user` u ON us.user_id = u.user_id
  152. LEFT JOIN goods g ON us.goods_id = g.goods_id
  153. <if test="createUsername != null and createUsername != '' ">
  154. LEFT JOIN order_goods og ON us.order_goods_id = og.order_goods_id
  155. LEFT JOIN `order` o ON og.order_sn = o.order_sn
  156. </if>
  157. LEFT JOIN course_business cb on g.business_id = cb.id
  158. LEFT JOIN user_exam_goods ueg ON ueg.order_goods_id = us.order_goods_id
  159. LEFT JOIN exam_site es ON us.site_id = es.site_id
  160. WHERE
  161. 1 =1
  162. <if test="applySiteAddress != null and applySiteAddress != '' ">
  163. and us.apply_site_address = #{applySiteAddress}
  164. </if>
  165. <if test="canCancel != null and canCancel == 1 ">
  166. and us.subscribe_status = 1
  167. and LEFT(us.apply_site_start_time,2)*3600+RIGHT(us.apply_site_start_time,2)*60+us.apply_site_exam_time > unix_timestamp(now())
  168. and us.exam_status = 0
  169. and us.before_status = 0
  170. </if>
  171. <if test="canBefore != null and canBefore == 1 ">
  172. and us.subscribe_status = 1
  173. and us.exam_status = 0
  174. and us.before_id = #{beforeId}
  175. and (SELECT count(*) from exam_before_apply eba LEFT JOIN exam_apply_goods eag on eag.apply_id = eba.apply_id where eba.before_id = #{beforeId} and eag.goods_id = us.goods_id) >0
  176. and (us.before_status = 1 or (SELECT count(*) from user_exam_goods ueg where ueg.user_id = us.user_id and ueg.goods_id = us.goods_id and ueg.do_number - ueg.expend_before>0)>0)
  177. </if>
  178. <if test="canExam != null and canExam == 1 ">
  179. and us.subscribe_status = 1
  180. </if>
  181. <if test="searchKey != null and searchKey != '' and searchType == 0 ">
  182. and (u.realname like concat('%', #{searchKey}, '%') or u.id_card like concat('%', #{searchKey}, '%'))
  183. </if>
  184. <if test="idCards != null and idCards.size()!=0 and searchType == 0" >
  185. AND u.id_card in
  186. <foreach collection="idCards" item="item" index="index" open="(" close=")" separator=",">
  187. #{item,typeHandler=com.zhongzheng.common.type.EncryptHandler}
  188. </foreach>
  189. </if>
  190. <if test="searchType == 1" >
  191. and (u.realname like concat('%', #{searchKey}, '%') or u.id_card like concat('%', #{searchKey}, '%') or
  192. u.id_card in
  193. <foreach collection="idCards" item="item" index="index" open="(" close=")" separator=",">
  194. #{item,typeHandler=com.zhongzheng.common.type.EncryptHandler}
  195. </foreach>)
  196. </if>
  197. <if test="userId != null and userId != '' ">
  198. and us.user_id = #{userId}
  199. </if>
  200. <if test="goodsId != null and goodsId != '' ">
  201. and us.goods_id = #{goodsId}
  202. </if>
  203. <if test="gradeType != null and gradeType != '' ">
  204. and g.grade_type = #{gradeType}
  205. </if>
  206. <if test="educationTypeId != null and educationTypeId != '' ">
  207. and g.education_type_id = #{educationTypeId}
  208. </if>
  209. <if test="businessId != null and businessId != '' ">
  210. and g.business_id = #{businessId}
  211. </if>
  212. <if test="createUsername != null and createUsername != '' ">
  213. and o.create_username like concat('%', #{create_username}, '%')
  214. </if>
  215. <if test="questionOpenNum != null and questionOpenNum != '' ">
  216. and u.question_open_num = #{questionOpenNum}
  217. </if>
  218. <if test="questionMerchantName != null and questionMerchantName != '' ">
  219. and o.question_merchant_name = #{questionMerchantName}
  220. </if>
  221. <if test="orderGoodsId != null and orderGoodsId != '' ">
  222. and us.order_goods_id = #{orderGoodsId}
  223. </if>
  224. <if test="result != null ">
  225. and us.result = #{result}
  226. </if>
  227. <if test="subscribeId != null and subscribeId != '' ">
  228. and us.subscribe_id = #{subscribeId}
  229. </if>
  230. <if test="applySiteExamTime != null and applySiteExamTime != '' ">
  231. and us.apply_site_exam_time = #{applySiteExamTime}
  232. </if>
  233. <if test="monthStartTime != null and monthStartTime != '' ">
  234. and us.apply_site_exam_time &gt;= #{monthStartTime}
  235. </if>
  236. <if test="monthEndTime != null and monthEndTime != '' ">
  237. and us.apply_site_exam_time &lt;= #{monthEndTime}
  238. </if>
  239. <if test="applySiteStartTime != null and applySiteStartTime != '' ">
  240. and us.apply_site_start_time = #{applySiteStartTime}
  241. </if>
  242. <if test="applySiteEndTime != null and applySiteEndTime != '' ">
  243. and us.apply_site_end_time = #{applySiteEndTime}
  244. </if>
  245. <if test="subscribeStatus != null and subscribeStatus != '' ">
  246. and us.subscribe_status = #{subscribeStatus}
  247. </if>
  248. <if test="beforeStatus != null and beforeStatus != '' ">
  249. and us.before_status = #{beforeStatus}
  250. </if>
  251. <if test="applyId != null and applyId != '' ">
  252. and us.apply_id = #{applyId}
  253. </if>
  254. <if test="studentType != null and studentType != '' ">
  255. and us.student_type = #{studentType}
  256. </if>
  257. <if test="examStatus != null ">
  258. and us.exam_status = #{examStatus}
  259. </if>
  260. <if test="beforeStatus != null ">
  261. and us.before_status = #{beforeStatus}
  262. </if>
  263. <if test="examExpend != null ">
  264. and us.exam_expend is NOT NULL
  265. </if>
  266. <if test="beforeExpend != null ">
  267. and us.before_expend is NOT NULL
  268. </if>
  269. <if test="beforeId != null and canBefore == null">
  270. and us.before_id =#{beforeId}
  271. </if>
  272. <if test="exceedExamExpend != null and exceedExamExpend == 1">
  273. and us.exam_expend = 1
  274. </if>
  275. <if test="exceedExamExpend != null and exceedExamExpend == 2">
  276. and (us.exam_expend is null or us.exam_expend = 0)
  277. </if>
  278. <if test="exceed != null ">
  279. and unix_timestamp(now()) > us.apply_site_exam_time and us.exam_expend is NULL and us.subscribe_status = 1
  280. </if>
  281. <if test="majorId != null and majorId != '' ">
  282. and (SELECT m.id FROM goods g LEFT JOIN major m on g.major_id= m.id where us.goods_id = g.goods_id) = #{majorId}
  283. </if>
  284. <if test="realname != null and realname != '' ">
  285. and (SELECT u.realname FROM `user` u where us.user_id = u.user_id) like concat('%', #{realname}, '%')
  286. </if>
  287. <if test="syncStatus != null ">
  288. and us.sync_status = #{syncStatus}
  289. </if>
  290. <!-- 数据范围过滤 -->
  291. ${params.dataScope}
  292. order by us.create_time desc
  293. </select>
  294. <select id="selectGoodsName" parameterType="string" resultType="String">
  295. SELECT g.goods_name FROM goods g where g.`code`=#{code} and g.status = 1
  296. </select>
  297. <select id="selectGoodsId" parameterType="string" resultType="Long">
  298. SELECT g.goods_id FROM goods g where g.`code`=#{code} and g.status = 1
  299. </select>
  300. <select id="selectUserId" parameterType="map" resultType="Long">
  301. SELECT u.user_id FROM `user` u where u.realname=#{userName} and u.id_card=#{idCard,typeHandler=com.zhongzheng.common.type.EncryptHandler}
  302. </select>
  303. <select id="selectBeforeId" parameterType="map" resultType="Long">
  304. SELECT eb.before_id FROM exam_before eb where eb.before_name=#{beforeName} and eb.status = 1
  305. </select>
  306. <select id="findApplyId" parameterType="map" resultType="Long">
  307. SELECT ea.apply_id FROM exam_apply ea where ea.apply_name=#{applyName} and ea.status != -1
  308. </select>
  309. <select id="selectApplyId" parameterType="map" resultType="Long">
  310. SELECT ea.apply_id FROM exam_apply ea where ea.apply_name=#{applyName} and ea.status != -1
  311. </select>
  312. <select id="selectSubscribeId" parameterType="map" resultType="Long">
  313. SELECT
  314. us.subscribe_id
  315. FROM
  316. user_subscribe us
  317. WHERE 1=1
  318. and us.subscribe_status =1
  319. and us.apply_id = #{applyId}
  320. and us.goods_id=#{goodsId}
  321. and us.user_id = #{userId}
  322. LIMIT 1
  323. </select>
  324. <select id="selectSubscribeUpdateId" parameterType="map" resultMap="UserSubscribeVo">
  325. SELECT
  326. us.*
  327. FROM
  328. user_subscribe us
  329. WHERE 1=1
  330. and us.subscribe_status =1
  331. and us.apply_id = #{applyId}
  332. and us.goods_id=#{goodsId}
  333. and us.user_id = #{userId}
  334. and us.apply_site_exam_time = #{applySiteExamTime}
  335. and us.apply_site_start_time = #{applySiteStartTime}
  336. and us.apply_site_end_time = #{applySiteEndTime}
  337. and us.apply_site_address = #{applySiteAddress}
  338. LIMIT 1
  339. </select>
  340. <select id="selectAddSubscribeId" parameterType="map" resultType="Long">
  341. SELECT
  342. us.subscribe_id
  343. FROM
  344. user_subscribe us
  345. WHERE 1=1
  346. and ((us.subscribe_status =1 and us.exam_status =0) or us.result = 1)
  347. and us.apply_id = #{applyId}
  348. and us.goods_id=#{goodsId}
  349. and us.user_id = #{userId}
  350. limit 1
  351. </select>
  352. <select id="selectAddSubscribeCount" parameterType="map" resultType="Long">
  353. SELECT
  354. COUNT(us.subscribe_id)
  355. FROM
  356. user_subscribe us
  357. WHERE 1=1
  358. and ((us.subscribe_status =1 and us.exam_status =0) or us.result = 1)
  359. and us.order_goods_id = #{orderGoodsId}
  360. and us.user_id = #{userId}
  361. </select>
  362. <select id="queryBusinessId" parameterType="map" resultType="Long">
  363. SELECT
  364. COUNT( 1 )
  365. FROM
  366. user_subscribe us
  367. LEFT JOIN exam_apply ea ON ea.apply_id = us.apply_id
  368. LEFT JOIN exam_apply_goods eag on ea.apply_id = eag.apply_id
  369. LEFT JOIN goods g on eag.goods_id = g.goods_id
  370. where 1=1
  371. AND g.business_id = #{businessId}
  372. AND us.subscribe_id = #{subscribeId}
  373. </select>
  374. <select id="timeSend" resultMap="UserSubscribeVo">
  375. SELECT
  376. * ,
  377. (SELECT g.business_id FROM goods g where g.goods_id = us.goods_id) as business_id
  378. FROM
  379. user_subscribe us
  380. WHERE us.subscribe_status = 1
  381. and unix_timestamp(now())+86400 > us.apply_site_exam_time
  382. and unix_timestamp(now()) &lt; us.apply_site_exam_time
  383. and (SELECT COUNT(1) FROM inform_remind ir LEFT JOIN inform_remind_business irb on ir.id = irb.remind_id where ir.id=16 and (SELECT g.business_id FROM goods g where g.goods_id = us.goods_id) = irb.business_id) > 0
  384. </select>
  385. <select id="signTimeSend" resultMap="UserSubscribeVo">
  386. SELECT
  387. us.*,
  388. ea.apply_name
  389. FROM
  390. user_subscribe us
  391. LEFT JOIN exam_apply ea on us.apply_id = ea.apply_id
  392. WHERE us.subscribe_status = 1
  393. and ea.report_status = 1
  394. and us.report_status = 0
  395. and us.signature_push_time is NULL
  396. and unix_timestamp(now())+86400 > us.apply_site_exam_time
  397. and unix_timestamp(now()) &lt; us.apply_site_exam_time
  398. and (SELECT COUNT(1) FROM inform_remind ir LEFT JOIN inform_remind_business irb on ir.id = irb.remind_id where ir.id=34 and (SELECT g.business_id FROM goods g where g.goods_id = us.goods_id) = irb.business_id) > 0
  399. </select>
  400. <select id="sendExamSucceed" parameterType="map" resultType="Long">
  401. SELECT
  402. COUNT( 1 )
  403. FROM
  404. inform_remind ir
  405. LEFT JOIN inform_remind_business irb on irb.remind_id =ir.id
  406. LEFT JOIN goods g on g.business_id = irb.business_id
  407. where 1=1
  408. and g.goods_id = #{goodsId}
  409. </select>
  410. <select id="listSubscribeByUser" parameterType="com.zhongzheng.modules.user.bo.UserSubscribeQueryBo" resultMap="UserSubscribeVo">
  411. SELECT
  412. us.user_id,
  413. u.realname,
  414. u.id_card
  415. FROM
  416. ( SELECT user_id FROM user_subscribe GROUP BY user_id ) us
  417. LEFT JOIN `user` u ON us.user_id = u.user_id
  418. WHERE
  419. 1 =1
  420. <if test="searchKey != null and searchKey != '' ">
  421. and (u.realname like concat('%', #{searchKey}, '%') or u.id_card like concat('%', #{searchKey}, '%'))
  422. </if>
  423. </select>
  424. <select id="getRecentExam" parameterType="com.zhongzheng.modules.user.bo.UserSubscribeQueryBo" resultMap="UserSubscribeVo">
  425. SELECT
  426. us.*
  427. FROM
  428. user_subscribe us
  429. WHERE
  430. 1 =1
  431. AND us.user_id = #{userId}
  432. AND us.subscribe_status = 1
  433. AND LEFT(us.apply_site_start_time,2)*3600+RIGHT(us.apply_site_start_time,2)*60+us.apply_site_exam_time > unix_timestamp(now())
  434. ORDER by us.apply_site_exam_time limit 1
  435. </select>
  436. <select id="getConsoleTestSubscribeNum" parameterType="com.zhongzheng.modules.base.bo.ConsoleQueryBo" resultType="Integer">
  437. SELECT
  438. COUNT(us.subscribe_id)
  439. FROM
  440. user_subscribe us
  441. LEFT JOIN goods g ON us.goods_id = g.goods_id
  442. WHERE
  443. 1=1
  444. <if test="orderGoodsId != null">
  445. AND us.order_goods_id = #{orderGoodsId}
  446. </if>
  447. <if test="businessId != null">
  448. AND g.business_id = #{businessId}
  449. </if>
  450. <if test="subscribeStatus != null">
  451. AND us.subscribe_status = #{subscribeStatus}
  452. </if>
  453. <if test="examStatus != null">
  454. AND us.exam_status = #{examStatus}
  455. </if>
  456. <if test="subStartTime != null">
  457. AND us.create_time &gt; #{subStartTime}
  458. </if>
  459. <if test="subEndTime != null">
  460. AND us.create_time &lt; #{subEndTime}
  461. </if>
  462. </select>
  463. <select id="selectApplyUserList" parameterType="map" resultMap="UserSubscribeVo">
  464. SELECT
  465. us.*,
  466. u.realname,
  467. u.id_card,
  468. u.telphone,
  469. u.id_card_img1,
  470. u.id_card_img2,
  471. u.one_inch_photos,
  472. es.center_id,
  473. ea.code as apply_code,
  474. ea.apply_name
  475. FROM
  476. user_subscribe us
  477. LEFT JOIN `user` u on u.user_id =us.user_id
  478. LEFT JOIN exam_apply ea on us.apply_id = ea.apply_id
  479. LEFT JOIN exam_site es on us.site_id = es.site_id
  480. WHERE 1=1
  481. and us.apply_id = #{applyId}
  482. and es.from_plat = 2
  483. </select>
  484. <select id="listUserExport" parameterType="com.zhongzheng.modules.user.bo.UserSubscribeQueryBo" resultMap="UserVoResult">
  485. SELECT
  486. us.*,u.company_name,u.job,u.edu_level,u.realname,u.telphone,u.id_card,u.sex,u.id_card_img1,u.id_card_img2,u.one_inch_photos,up.key_value
  487. FROM
  488. user_subscribe us
  489. LEFT JOIN `user` u on u.user_id =us.user_id
  490. LEFT JOIN user_profile up on us.order_goods_id =up.order_goods_id and up.current_status = 1
  491. and up.type_status = 1
  492. WHERE
  493. us.subscribe_status = 1
  494. <if test="applyId != null and applyId != '' ">
  495. and us.apply_id = #{applyId}
  496. </if>
  497. <if test="applySiteExamTime != null and applySiteExamTime != '' ">
  498. and us.apply_site_exam_time = #{applySiteExamTime}
  499. </if>
  500. <if test="applySiteStartTime != null and applySiteStartTime != '' ">
  501. and us.apply_site_start_time = #{applySiteStartTime}
  502. </if>
  503. <if test="applySiteEndTime != null and applySiteEndTime != '' ">
  504. and us.apply_site_end_time = #{applySiteEndTime}
  505. </if>
  506. <if test="siteId != null and siteId != '' ">
  507. and us.site_id = #{siteId}
  508. </if>
  509. </select>
  510. <select id="listSignExport" parameterType="com.zhongzheng.modules.user.bo.UserSubscribeQueryBo" resultMap="UserSubscribeVo">
  511. SELECT
  512. us.*,u.realname,u.id_card,u.telphone
  513. FROM
  514. user_subscribe us
  515. LEFT JOIN `user` u on u.user_id =us.user_id
  516. WHERE
  517. us.subscribe_status = 1
  518. <if test="applyId != null and applyId != '' ">
  519. and us.apply_id = #{applyId}
  520. </if>
  521. <if test="applySiteExamTime != null and applySiteExamTime != '' ">
  522. and us.apply_site_exam_time = #{applySiteExamTime}
  523. </if>
  524. <if test="applySiteStartTime != null and applySiteStartTime != '' ">
  525. and us.apply_site_start_time = #{applySiteStartTime}
  526. </if>
  527. <if test="applySiteEndTime != null and applySiteEndTime != '' ">
  528. and us.apply_site_end_time = #{applySiteEndTime}
  529. </if>
  530. <if test="siteId != null and siteId != '' ">
  531. and us.site_id = #{siteId}
  532. </if>
  533. </select>
  534. <select id="selectMajorId" parameterType="java.lang.String" resultType="java.lang.Long">
  535. SELECT
  536. DISTINCT(m.id)
  537. FROM
  538. major m
  539. LEFT JOIN major_project mp ON m.id = mp.major_id
  540. LEFT JOIN course_project_type cpt ON mp.project_id = cpt.id
  541. LEFT JOIN course_education_type cet ON cpt.education_id = cet.id
  542. WHERE
  543. m.category_name = #{majorName}
  544. AND INSTR( '施工现场专业人员', cpt.project_name ) > 0
  545. AND INSTR( '考前培训', cet.education_name ) > 0
  546. </select>
  547. <select id="getGoodsIds" parameterType="map" resultType="java.lang.Long">
  548. SELECT
  549. DISTINCT(g.goods_id)
  550. FROM
  551. `exam_apply` ea
  552. LEFT JOIN exam_apply_goods eag ON ea.apply_id = eag.apply_id
  553. LEFT JOIN goods g ON eag.goods_id = g.goods_id
  554. LEFT JOIN order_goods og ON g.goods_id = og.goods_id
  555. LEFT JOIN `order` o ON og.order_sn = o.order_sn
  556. WHERE
  557. ea.apply_id = #{applyId}
  558. AND o.user_id = #{userId}
  559. AND g.major_id = #{majorId}
  560. AND g.`status` = 1
  561. AND og.`status` = 1
  562. AND og.refund_status != 2
  563. AND og.pay_status IN (2,3,4)
  564. </select>
  565. <select id="getExamApplyNum" parameterType="java.lang.String" resultType="java.lang.Integer">
  566. SELECT
  567. COUNT( DISTINCT us.user_id )
  568. FROM
  569. exam_apply ea
  570. LEFT JOIN user_subscribe us ON ea.apply_id = us.apply_id
  571. WHERE
  572. ea.rel_code = ''
  573. AND ea.`status` = 1
  574. AND us.subscribe_status = 1
  575. </select>
  576. <select id="getListSubscribe" parameterType="com.zhongzheng.modules.user.bo.UserSubQueryBo" resultType="com.zhongzheng.modules.user.vo.UserSubVo">
  577. SELECT
  578. us.subscribe_id,
  579. us.order_goods_id,
  580. u.realname AS userName,
  581. u.id_card AS userCard,
  582. u.telphone AS userPhone,
  583. u.company_name AS companyName,
  584. g.goods_name,
  585. m.category_name AS majorName,
  586. t.tenant_name,
  587. us.create_time,
  588. us.subscribe_status,
  589. ( SELECT SUM( ueg.exam_number ) FROM user_exam_goods ueg WHERE us.order_goods_id = ueg.order_goods_id GROUP BY ueg.order_goods_id ) AS applyNum,
  590. us.exam_status,
  591. us.result,
  592. us.performance,
  593. us.apply_site_exam_time as applyTime,
  594. us.apply_site_start_time as applyStartTime,
  595. us.apply_site_end_time as applyEndTime,
  596. us.apply_site_address as applyAddress,
  597. us.certificate_start_time as certificateStartTime,
  598. us.certificate_end_time as certificateEndTime,
  599. us.certificate_code,
  600. CASE
  601. WHEN (
  602. SELECT
  603. COUNT( usu.order_goods_id )
  604. FROM
  605. user_subscribe usu
  606. WHERE
  607. usu.user_id = us.user_id
  608. AND usu.order_goods_id = us.order_goods_id
  609. AND usu.subscribe_status = 1
  610. ) = 1
  611. THEN 1
  612. WHEN (
  613. SELECT
  614. COUNT( usu.order_goods_id )
  615. FROM
  616. user_subscribe usu
  617. WHERE
  618. usu.user_id = us.user_id
  619. AND usu.order_goods_id = us.order_goods_id
  620. AND usu.subscribe_status = 1
  621. ) >1
  622. THEN 2
  623. ELSE 0 END
  624. AS newApply
  625. FROM
  626. user_subscribe us
  627. LEFT JOIN order_goods og ON us.order_goods_id = og.order_goods_id
  628. LEFT JOIN goods g ON og.goods_id = g.goods_id
  629. LEFT JOIN major m ON g.major_id = m.id
  630. LEFT JOIN sys_tenant t ON us.tenant_id = t.tenant_id
  631. LEFT JOIN `user` u ON us.user_id = u.user_id
  632. WHERE
  633. 1 = 1
  634. <if test="subscribeStatus != null and subscribeStatus != '' and (subscribeStatus == 1 or subscribeStatus == 2)">
  635. AND us.subscribe_status = #{subscribeStatus}
  636. </if>
  637. <if test="subscribeStatus != null and subscribeStatus != '' and subscribeStatus == 3">
  638. AND (us.subscribe_status = 1 AND #{dataTime} &gt; us.apply_site_exam_time)
  639. </if>
  640. <if test="applyStatus != null and applyStatus != '' and applyStatus == 1 ">
  641. AND ( us.exam_status = 1 AND us.result IS NULL )
  642. </if>
  643. <if test="applyStatus != null and applyStatus != '' and applyStatus == 2 ">
  644. AND ( us.exam_status = 1 AND us.result = 1 )
  645. </if>
  646. <if test="applyStatus != null and applyStatus != '' and applyStatus == 3 ">
  647. AND ( us.exam_status = 1 AND us.result = 0)
  648. </if>
  649. <if test="applyNum != null and applyNum != '' ">
  650. AND ( SELECT SUM( ueg.exam_number ) FROM user_exam_goods ueg WHERE us.order_goods_id = ueg.order_goods_id GROUP BY ueg.order_goods_id ) = #{applyNum}
  651. </if>
  652. <if test="newApply != null and newApply != '' and newApply == 1">
  653. AND (
  654. SELECT
  655. COUNT( usu.order_goods_id )
  656. FROM
  657. user_subscribe usu
  658. WHERE
  659. usu.user_id = us.user_id
  660. AND usu.order_goods_id = us.order_goods_id
  661. AND usu.subscribe_status = 1
  662. ) = 1
  663. </if>
  664. <if test="newApply != null and newApply != '' and newApply == 2">
  665. AND (
  666. SELECT
  667. COUNT( usu.order_goods_id )
  668. FROM
  669. user_subscribe usu
  670. WHERE
  671. usu.user_id = us.user_id
  672. AND usu.order_goods_id = us.order_goods_id
  673. AND usu.subscribe_status = 1
  674. ) &gt; 1
  675. </if>
  676. <if test="keyWord != null and keyWord != '' ">
  677. AND (u.realname LIKE concat('%',#{keyWord},'%') OR u.id_card = #{keyWord,typeHandler=com.zhongzheng.common.type.EncryptHandler})
  678. </if>
  679. <if test="applySiteExamTime != null and applySiteExamTime != '' ">
  680. and us.apply_site_exam_time = #{applySiteExamTime}
  681. </if>
  682. <if test="monthStartTime != null and monthStartTime != '' ">
  683. and us.apply_site_exam_time &gt;= #{monthStartTime}
  684. </if>
  685. <if test="monthEndTime != null and monthEndTime != '' ">
  686. and us.apply_site_exam_time &lt;= #{monthEndTime}
  687. </if>
  688. <if test="applySiteStartTime != null and applySiteStartTime != '' ">
  689. and us.apply_site_start_time = #{applySiteStartTime}
  690. </if>
  691. <if test="applySiteEndTime != null and applySiteEndTime != '' ">
  692. and us.apply_site_end_time = #{applySiteEndTime}
  693. </if>
  694. <if test="educationId != null and educationId != '' ">
  695. AND g.education_type_id = #{educationId}
  696. </if>
  697. <if test="businessId != null and businessId != '' ">
  698. AND g.business_id = #{businessId}
  699. </if>
  700. <if test="tenantIds != null and tenantIds.size()!=0 " >
  701. AND us.tenant_id in
  702. <foreach collection="tenantIds" item="item" index="index" open="(" close=")" separator=",">
  703. #{item}
  704. </foreach>
  705. </if>
  706. ORDER BY us.create_time DESC
  707. </select>
  708. <select id="getQuestionRel" parameterType="java.lang.Long" resultType="com.zhongzheng.modules.goods.domain.GoodsQuestionRel">
  709. SELECT * FROM goods_question_rel WHERE order_goods_id = #{orderGoodsId} AND `status` = 1 AND question_do_num &gt; 0 LIMIT 1
  710. </select>
  711. <select id="listByTimeNoTenant" parameterType="com.zhongzheng.modules.user.bo.SubUserExportBo" resultType="com.zhongzheng.modules.user.domain.UserSubscribe">
  712. SELECT * FROM user_subscribe
  713. WHERE subscribe_status = 1 AND exam_status = 0
  714. <if test="applyTime != null and applyTime != '' ">
  715. AND apply_site_exam_time = #{applyTime}
  716. </if>
  717. <if test="tenantIds != null and tenantIds.size()!=0 " >
  718. AND tenant_id IN
  719. <foreach collection="tenantIds" item="item" index="index" open="(" close=")" separator=",">
  720. #{item}
  721. </foreach>
  722. </if>
  723. </select>
  724. <update id="updateByIdNoTenant" parameterType="com.zhongzheng.modules.user.domain.UserSubscribe">
  725. UPDATE
  726. user_subscribe
  727. SET
  728. <if test="examStatus != null">
  729. exam_status = #{examStatus},
  730. </if>
  731. <if test="performance != null and performance != '' ">
  732. performance = #{performance},
  733. </if>
  734. <if test="result != null">
  735. `result` = #{result},
  736. </if>
  737. <if test="certificateCode != null and certificateCode != '' ">
  738. certificate_code = #{certificateCode},
  739. </if>
  740. <if test="certificateUrl != null and certificateUrl != '' ">
  741. certificate_url = #{certificateUrl},
  742. </if>
  743. <if test="certificateStartTime != null and certificateStartTime != '' ">
  744. certificate_start_time = #{certificateStartTime},
  745. </if>
  746. <if test="certificateEndTime != null and certificateEndTime != '' ">
  747. certificate_end_time = #{certificateEndTime},
  748. </if>
  749. update_time = unix_timestamp()
  750. WHERE
  751. subscribe_id = #{subscribeId}
  752. </update>
  753. <select id="listUserApply" parameterType="com.zhongzheng.modules.user.bo.UserApplyRecordBo" resultType="com.zhongzheng.modules.user.vo.UserApplyRecordVo">
  754. SELECT
  755. us.subscribe_id,
  756. us.exam_status,
  757. us.result as applyStatus,
  758. us.performance,
  759. us.create_time,
  760. g.goods_name,
  761. CONCAT(cet.education_name,'-',cb.business_name,cpt.project_name) AS businessName,
  762. m.category_name AS majorName,
  763. us.subscribe_status,
  764. us.apply_site_exam_time AS applyTime,
  765. us.apply_site_start_time AS applyStarTime,
  766. us.apply_site_end_time AS applyEndTime,
  767. CASE
  768. WHEN (
  769. SELECT
  770. COUNT( usu.order_goods_id )
  771. FROM
  772. user_subscribe usu
  773. WHERE
  774. usu.user_id = us.user_id
  775. AND usu.order_goods_id = us.order_goods_id
  776. AND usu.subscribe_status = 1
  777. ) = 1
  778. THEN 1
  779. WHEN (
  780. SELECT
  781. COUNT( usu.order_goods_id )
  782. FROM
  783. user_subscribe usu
  784. WHERE
  785. usu.user_id = us.user_id
  786. AND usu.order_goods_id = us.order_goods_id
  787. AND usu.subscribe_status = 1
  788. ) >1
  789. THEN 0 ELSE NULL END
  790. AS applyNew
  791. FROM user_subscribe us
  792. LEFT JOIN order_goods og ON us.order_goods_id = og.order_goods_id
  793. LEFT JOIN goods g ON og.goods_id = g.goods_id
  794. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  795. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  796. LEFT JOIN course_business cb ON g.business_id = cb.id
  797. LEFT JOIN major m ON g.major_id = m.id
  798. WHERE 1=1 AND us.exam_status != 0 AND us.subscribe_status = 1
  799. <if test="userId != null and userId !='' ">
  800. AND us.user_id = #{userId}
  801. </if>
  802. <if test="applyStartTime != null and applyStartTime !=''">
  803. AND us.apply_site_exam_time &gt;= #{applyStartTime}
  804. </if>
  805. <if test="applyEndTime != null and applyEndTime !=''">
  806. AND us.apply_site_exam_time &lt;= #{applyEndTime}
  807. </if>
  808. <if test="educationTypeId != null and educationTypeId !='' ">
  809. AND cet.id = #{educationTypeId}
  810. </if>
  811. <if test="businessId != null and businessId !='' ">
  812. AND cb.id = #{businessId}
  813. </if>
  814. <if test="majorId != null and majorId !='' ">
  815. AND m.id = #{majorId}
  816. </if>
  817. <if test="goodsName != null and goodsName !='' ">
  818. AND g.goods_name LIKE concat('%',#{goodsName},'%')
  819. </if>
  820. <if test="applyStatus != null ">
  821. AND us.result = #{applyStatus}
  822. </if>
  823. <if test="applyNew != null and applyNew == 1">
  824. AND (
  825. SELECT
  826. COUNT( usu.order_goods_id )
  827. FROM
  828. user_subscribe usu
  829. WHERE
  830. usu.user_id = us.user_id
  831. AND usu.order_goods_id = us.order_goods_id
  832. AND usu.subscribe_status = 1
  833. ) = 1
  834. </if>
  835. <if test="applyNew != null and applyNew == 0">
  836. AND (
  837. SELECT
  838. COUNT( usu.order_goods_id )
  839. FROM
  840. user_subscribe usu
  841. WHERE
  842. usu.user_id = us.user_id
  843. AND usu.order_goods_id = us.order_goods_id
  844. AND usu.subscribe_status = 1
  845. ) &gt; 1
  846. </if>
  847. </select>
  848. <select id="listPromise" parameterType="com.zhongzheng.modules.user.bo.UserPromiseRecordBo" resultType="com.zhongzheng.modules.user.vo.UserPromiseRecordVo">
  849. SELECT
  850. up.id,
  851. up.create_time as uploadTime,
  852. up.key_value,
  853. g.goods_name,
  854. CONCAT(cet.education_name,'-',cb.business_name,cpt.project_name) AS businessName,
  855. m.category_name AS majorName,
  856. 1 AS signStatus
  857. FROM
  858. user_profile up
  859. LEFT JOIN goods g ON up.goods_id = g.goods_id
  860. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  861. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  862. LEFT JOIN course_business cb ON g.business_id = cb.id
  863. LEFT JOIN major m ON g.major_id = m.id
  864. WHERE up.`status` != -1 AND up.current_status = 1
  865. <if test="userId != null ">
  866. AND up.user_id = #{userId}
  867. </if>
  868. <if test="uploadStartTime != null and uploadStartTime !=''">
  869. AND up.create_time &gt;= #{uploadStartTime}
  870. </if>
  871. <if test="uploadEndTime != null and uploadEndTime !=''">
  872. AND up.create_time &lt;= #{uploadEndTime}
  873. </if>
  874. <if test="educationTypeId != null and educationTypeId !='' ">
  875. AND cet.id = #{educationTypeId}
  876. </if>
  877. <if test="businessId != null and businessId !='' ">
  878. AND cb.id = #{businessId}
  879. </if>
  880. <if test="majorId != null and majorId !='' ">
  881. AND m.id = #{majorId}
  882. </if>
  883. <if test="goodsName != null and goodsName !='' ">
  884. AND g.goods_name LIKE concat('%',#{goodsName},'%')
  885. </if>
  886. </select>
  887. </mapper>