UserSubscribeMapper.xml 40 KB

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