OrderGoodsMapper.xml 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104
  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.order.mapper.OrderGoodsMapper">
  6. <resultMap type="com.zhongzheng.modules.order.domain.OrderGoods" id="OrderGoodsResult">
  7. <result property="orderGoodsId" column="order_goods_id"/>
  8. <result property="orderSn" column="order_sn"/>
  9. <result property="goodsId" column="goods_id"/>
  10. <result property="goodsInputData" column="goods_input_data"/>
  11. <result property="goodsPrice" column="goods_price"/>
  12. <result property="goodsRealPrice" column="goods_real_price"/>
  13. <result property="createTime" column="create_time"/>
  14. <result property="updateTime" column="update_time"/>
  15. <result property="status" column="status"/>
  16. <result property="goodsReceived" column="goods_received"/>
  17. <result property="refundStatus" column="refund_status"/>
  18. <result property="payStatus" column="pay_status"/>
  19. <result property="businessOwner" column="business_owner"/>
  20. <result property="dept" column="dept"/>
  21. <result property="source" column="source"/>
  22. <result property="school" column="school"/>
  23. <result property="address" column="address"/>
  24. <result property="company" column="company"/>
  25. <result property="remark" column="remark"/>
  26. <result property="gradeId" column="grade_id"/>
  27. <result property="rebuyOrderGoodsId" column="rebuy_order_goods_id"/>
  28. <result property="studyCount" column="study_count"/>
  29. <result property="serviceStartTime" column="service_start_time"/>
  30. <result property="serviceEndTime" column="service_end_time"/>
  31. <result property="closeReason" column="close_reason"/>
  32. <result property="sevenClassVersion" column="seven_class_version"/>
  33. <result property="sevenClassStatus" column="seven_class_status"/>
  34. <result property="sevenYear" column="seven_year"/>
  35. <result property="sevenClassCopy" column="seven_class_copy"/>
  36. </resultMap>
  37. <resultMap type="com.zhongzheng.modules.order.vo.OrderGoodsVo" id="OrderGoodsResultVo">
  38. <result property="orderGoodsId" column="order_goods_id"/>
  39. <result property="orderSn" column="order_sn"/>
  40. <result property="goodsId" column="goods_id"/>
  41. <result property="goodsInputData" column="goods_input_data"/>
  42. <result property="goodsPrice" column="goods_price"/>
  43. <result property="goodsRealPrice" column="goods_real_price"/>
  44. <result property="status" column="status"/>
  45. <result property="goodsReceived" column="goods_received"/>
  46. <result property="refundStatus" column="refund_status"/>
  47. <result property="payStatus" column="pay_status"/>
  48. <result property="businessOwner" column="business_owner"/>
  49. <result property="dept" column="dept"/>
  50. <result property="source" column="source"/>
  51. <result property="school" column="school"/>
  52. <result property="address" column="address"/>
  53. <result property="company" column="company"/>
  54. <result property="createTime" column="create_time"/>
  55. <result property="remark" column="remark"/>
  56. <result property="userId" column="user_id"/>
  57. <result property="realname" column="realname"/>
  58. <result property="rebuyOrderGoodsId" column="rebuy_order_goods_id"/>
  59. <result property="externalLink" column="external_link"/>
  60. <result property="externalLinkStatus" column="external_link_status"/>
  61. <result property="periodStatus" column="period_status"/>
  62. <result property="distributionCode" column="distribution_code"/>
  63. <result property="distributionLinkCode" column="distribution_link_code"/>
  64. <result property="offlineRefundSign" column="offline_refund_sign"/>
  65. <result property="code" column="code"/>
  66. <result property="goodsName" column="goods_name"/>
  67. <result property="educationName" column="education_name"/>
  68. <result property="projectName" column="project_name"/>
  69. <result property="businessName" column="business_name"/>
  70. <result property="createBy" column="create_by"/>
  71. <result property="goodsType" column="goods_type"/>
  72. <result property="gradeId" column="grade_id"/>
  73. <result property="coverUrl" column="cover_url"/>
  74. <result property="gradeName" column="class_name"/>
  75. <result property="studyCount" column="study_count"/>
  76. <result property="class_name" column="gradeName"/>
  77. <result property="serviceStartTime" column="service_start_time"/>
  78. <result property="serviceEndTime" column="service_end_time"/>
  79. <result property="orderStatus" column="order_status"/>
  80. <result property="classStartTime" column="class_start_time"/>
  81. <result property="classEndTime" column="class_end_time"/>
  82. <result property="interfaceAccountId" column="interface_account_id"/>
  83. <result property="interfacePushId" column="interface_push_id"/>
  84. <result property="introduce" column="introduce"/>
  85. <result property="learningStatus" column="learning_status"/>
  86. <result property="learningTimeStart" column="learning_time_start"/>
  87. <result property="officialLearningUrl" column="official_learning_url"/>
  88. <result property="learnStatus" column="learn_status"/>
  89. <result property="officialStatus" column="official_status"/>
  90. <result property="classStatus" column="class_status"/>
  91. <result property="closeReason" column="close_reason"/>
  92. <result property="joinLiveNum" column="join_live_num"/>
  93. <result property="seeTime" column="see_time"/>
  94. <result property="categoryName" column="category_name"/>
  95. <result property="subjectIds" column="subject_ids"/>
  96. <result property="businessId" column="business_id"/>
  97. <result property="examNum" column="exam_num"/>
  98. <result property="recordNum" column="record_num"/>
  99. <result property="sysUserId" column="sys_user_id"/>
  100. <result property="applyStatus" column="apply_status"/>
  101. <result property="subExamStatus" column="sub_exam_status"/>
  102. <result property="subPerformance" column="sub_performance"/>
  103. <result property="subResult" column="sub_result"/>
  104. <result property="subApplySiteStartTime" column="sub_apply_site_start_time"/>
  105. <result property="subApplySiteEndTime" column="sub_apply_site_end_time"/>
  106. <result property="subApplySiteExamTime" column="sub_apply_site_exam_time"/>
  107. <result property="subscribeId" column="subscribe_id"/>
  108. <result property="gradeId" column="grade_id"/>
  109. <result property="userStudyCount" column="user_study_count"/>
  110. <result property="goodsLearningOrder" column="goods_learning_order"/>
  111. <result property="classHours" column="class_hours"/>
  112. <result property="courseNum" column="course_num"/>
  113. <result property="idCard" column="id_card" typeHandler="com.zhongzheng.common.type.EncryptHandler"/>
  114. <result property="sevenClassVersion" column="seven_class_version"/>
  115. <result property="sevenClassStatus" column="seven_class_status"/>
  116. <result property="sevenYear" column="seven_year"/>
  117. <result property="orderYear" column="order_year"/>
  118. <result property="sevenClassCopy" column="seven_class_copy"/>
  119. <result property="studyStatus" column="study_status"/>
  120. <result property="mailSign" column="mail_sign"/>
  121. <result property="profileStatus" column="profile_status"/>
  122. <result property="profileChangeStatus" column="profile_change_status"/>
  123. <result property="majorName" column="major_name"/>
  124. </resultMap>
  125. <select id="selectListBybo" parameterType="com.zhongzheng.modules.order.bo.OrderGoodsQueryBo"
  126. resultMap="OrderGoodsResultVo">
  127. SELECT
  128. og.*,
  129. g.`code`,
  130. g.goods_name,
  131. g.goods_type,
  132. g.cover_url,
  133. g.mail_sign,
  134. cet.education_name,
  135. cpt.project_name,
  136. cb.business_name
  137. FROM
  138. order_goods og
  139. LEFT JOIN goods g ON og.goods_id = g.goods_id
  140. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  141. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  142. LEFT JOIN course_business cb ON g.business_id = cb.id
  143. LEFT JOIN `order` o ON o.order_sn = og.order_sn
  144. WHERE
  145. 1 = 1
  146. and og.status = 1
  147. <if test="refundStatusList != null and refundStatusList.size()!=0 ">
  148. AND og.refund_status in
  149. <foreach collection="refundStatusList" item="item" index="index" open="(" close=")" separator=",">
  150. #{item}
  151. </foreach>
  152. </if>
  153. <if test="goodsId != null and goodsId != ''">
  154. AND og.goods_id = #{goodsId}
  155. </if>
  156. <if test="userId != null">
  157. AND o.user_id = #{userId}
  158. </if>
  159. <if test="orderSn != null and orderSn != ''">
  160. AND og.order_sn = #{orderSn}
  161. </if>
  162. <if test="payStatusList != null and payStatusList.size()!=0 ">
  163. AND og.pay_status in
  164. <foreach collection="payStatusList" item="item" index="index" open="(" close=")" separator=",">
  165. #{item}
  166. </foreach>
  167. </if>
  168. <if test="orderGoodsIds != null and orderGoodsIds.size()!=0 ">
  169. AND og.order_goods_id in
  170. <foreach collection="orderGoodsIds" item="item" index="index" open="(" close=")" separator=",">
  171. #{item}
  172. </foreach>
  173. </if>
  174. </select>
  175. <select id="selectDetail" parameterType="com.zhongzheng.modules.order.bo.OrderGoodsQueryBo"
  176. resultMap="OrderGoodsResultVo">
  177. SELECT
  178. og.*,
  179. o.order_status,
  180. g.`code`,
  181. g.goods_name,
  182. g.goods_type,
  183. cet.education_name,
  184. cpt.project_name,
  185. cb.business_name,
  186. cg.class_name,
  187. o.create_username as create_by,
  188. cg.class_start_time,
  189. cg.class_end_time,
  190. cg.interface_account_id,
  191. cg.interface_push_id,
  192. g.introduce,
  193. cg.learning_status,
  194. cg.learning_time_start,
  195. cg.official_learning_url,
  196. cgu.learn_status,
  197. cgu.official_status,
  198. cg.class_status,
  199. m.category_name
  200. FROM
  201. order_goods og
  202. LEFT JOIN class_grade cg on og.grade_id = cg.grade_id
  203. LEFT JOIN goods g ON og.goods_id = g.goods_id
  204. LEFT JOIN major m ON g.major_id = m.id
  205. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  206. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  207. LEFT JOIN course_business cb ON g.business_id = cb.id
  208. LEFT JOIN `order` o ON og.order_sn = o.order_sn
  209. LEFT JOIN class_grade_user cgu on cgu.user_id = o.user_id and cgu.grade_id = cg.grade_id and cgu.order_goods_id = og.order_goods_id
  210. WHERE
  211. 1=1
  212. <if test="orderSn != null and orderSn != ''">
  213. AND og.order_sn = #{orderSn} AND og.goods_id = #{goodsId}
  214. </if>
  215. <if test="orderGoodsId != null and orderGoodsId != ''">
  216. AND og.order_goods_id= #{orderGoodsId}
  217. </if>
  218. </select>
  219. <select id="selectOrderGoods" parameterType="com.zhongzheng.modules.order.bo.OrderGoodsQueryBo"
  220. resultMap="OrderGoodsResultVo">
  221. SELECT og.*,
  222. o.user_id
  223. FROM `order` o
  224. LEFT JOIN order_goods og on o.order_sn = og.order_sn
  225. where 1 = 1
  226. and og.`status` = 1
  227. and og.refund_status in (0, 1, 3)
  228. and og.pay_status in (2, 3, 4)
  229. AND (SELECT COUNT(1)
  230. FROM inform_user iu
  231. where iu.user_id = o.user_id and iu.goods_id = og.goods_id and system_status = 1) &lt; 1
  232. </select>
  233. <select id="selectOrderTwoGoods" parameterType="com.zhongzheng.modules.order.bo.OrderGoodsQueryBo"
  234. resultMap="OrderGoodsResultVo">
  235. SELECT og.*,
  236. o.user_id
  237. FROM `order` o
  238. LEFT JOIN order_goods og on o.order_sn = og.order_sn
  239. where 1 = 1
  240. and og.`status` = 1
  241. and og.refund_status in (0, 1, 3)
  242. and og.pay_status in (2, 3, 4)
  243. AND (SELECT COUNT(1)
  244. FROM inform_user iu
  245. where iu.user_id = o.user_id and iu.goods_id = og.goods_id and system_status = 3) &lt; 1
  246. </select>
  247. <select id="sendGoods" resultMap="OrderGoodsResultVo">
  248. SELECT og.*,
  249. o.user_id
  250. FROM `order` o
  251. LEFT JOIN order_goods og on o.order_sn = og.order_sn
  252. where 1 = 1
  253. and og.`status` = 1
  254. and og.refund_status in (0, 1, 3)
  255. and og.pay_status in (2, 3, 4)
  256. and (SELECT COUNT(1)
  257. FROM user_exam_goods ueg
  258. where ueg.user_id = o.user_id and og.goods_id = ueg.goods_id) &lt; 1
  259. and (SELECT COUNT(1)
  260. FROM exam_number en
  261. LEFT JOIN exam_number_goods eng on en.exam_number_id = eng.exam_number_id
  262. where eng.goods_id = og.goods_id
  263. and en.`status` = 1) > 0
  264. </select>
  265. <select id="getBuyGoodsHistory" parameterType="com.zhongzheng.modules.order.bo.OrderGoodsQueryBo" resultType="Long">
  266. SELECT ifnull(count(*), 0) num
  267. FROM `order` o
  268. LEFT JOIN order_goods og ON o.order_sn = og.order_sn
  269. WHERE o.user_id = #{userId}
  270. AND og.goods_id = #{goodsId}
  271. AND og.`status` = 1
  272. AND og.pay_status > 1
  273. AND og.refund_status != 2
  274. </select>
  275. <select id="getBuyGoodsReadyPay" parameterType="com.zhongzheng.modules.order.bo.OrderGoodsQueryBo"
  276. resultType="Long">
  277. SELECT ifnull(count(*), 0) num
  278. FROM `order` o
  279. LEFT JOIN order_goods og ON o.order_sn = og.order_sn
  280. WHERE o.user_id = #{userId}
  281. AND og.goods_id = #{goodsId}
  282. AND o.order_status = 0
  283. </select>
  284. <select id="rebuyInfo" parameterType="com.zhongzheng.modules.order.bo.OrderGoodsQueryBo"
  285. resultMap="OrderGoodsResultVo">
  286. SELECT og.order_sn,
  287. g.goods_name,
  288. cg.class_name
  289. FROM order_goods og
  290. LEFT JOIN goods g ON og.goods_id = g.goods_id
  291. LEFT JOIN class_grade cg ON og.grade_id = cg.grade_id
  292. LEFT JOIN `order` o on og.order_sn = o.order_sn
  293. LEFT JOIN class_grade_user cgu ON cgu.grade_id = cg.grade_id and cgu.order_goods_id = og.order_goods_id and cgu.user_id = #{userId}
  294. WHERE o.user_id = #{userId}
  295. and og.goods_id = #{goodsId}
  296. and og.pay_status in (2, 3, 4)
  297. and og.order_goods_id != #{orderGoodsId}
  298. and cgu.period_plush = 1
  299. </select>
  300. <select id="gradeGoods" parameterType="com.zhongzheng.modules.order.bo.OrderGoodsQueryBo"
  301. resultMap="OrderGoodsResultVo">
  302. SELECT og.*
  303. FROM order_goods og
  304. LEFT JOIN `order` o on og.order_sn = o.order_sn
  305. WHERE o.user_id = #{userId}
  306. and og.grade_id = #{gradeId}
  307. and og.order_goods_id = #{orderGoodsId}
  308. and og.pay_status in (2, 3, 4)
  309. and og.refund_status !=2
  310. </select>
  311. <select id="selectCanInvoiceList" parameterType="com.zhongzheng.modules.order.bo.OrderGoodsQueryBo"
  312. resultMap="OrderGoodsResultVo">
  313. SELECT
  314. og.*,
  315. g.`code`,
  316. g.goods_name,
  317. g.goods_type,
  318. g.cover_url
  319. FROM
  320. order_goods og
  321. LEFT JOIN goods g ON og.goods_id = g.goods_id
  322. LEFT JOIN `order` o ON o.order_sn = og.order_sn
  323. WHERE
  324. 1 = 1
  325. AND og.order_goods_id NOT IN (
  326. SELECT
  327. oio.order_goods_id
  328. FROM
  329. order_invoice oi
  330. LEFT JOIN order_invoice_order oio ON oi.invoice_id = oio.invoice_id
  331. WHERE
  332. oi.period_status IN ( 1, 3 ) and oi.user_id = #{userId} and oi.status != -1 and oio.order_goods_id is not NULL)
  333. <if test="refundStatusList != null and refundStatusList.size()!=0 ">
  334. AND og.refund_status in
  335. <foreach collection="refundStatusList" item="item" index="index" open="(" close=")" separator=",">
  336. #{item}
  337. </foreach>
  338. </if>
  339. <if test="goodsId != null and goodsId != ''">
  340. AND og.goods_id = #{goodsId}
  341. </if>
  342. <if test="userId != null">
  343. AND o.user_id = #{userId}
  344. </if>
  345. <if test="orderSn != null and orderSn != ''">
  346. AND og.order_sn = #{orderSn}
  347. </if>
  348. <if test="payStatusList != null and payStatusList.size()!=0 ">
  349. AND og.pay_status in
  350. <foreach collection="payStatusList" item="item" index="index" open="(" close=")" separator=",">
  351. #{item}
  352. </foreach>
  353. </if>
  354. <if test="orderGoodsIds != null and orderGoodsIds.size()!=0 ">
  355. AND og.order_goods_id in
  356. <foreach collection="orderGoodsIds" item="item" index="index" open="(" close=")" separator=",">
  357. #{item}
  358. </foreach>
  359. </if>
  360. </select>
  361. <select id="selectBuyGoodsUserList" parameterType="com.zhongzheng.modules.order.bo.OrderGoodsQueryBo"
  362. resultMap="OrderGoodsResultVo">
  363. SELECT DISTINCT u.user_id,
  364. u.realname
  365. FROM order_goods og
  366. LEFT JOIN `order` o ON og.order_sn = o.order_sn
  367. LEFT JOIN `user` u ON o.user_id = u.user_id
  368. WHERE og.`status` = 1
  369. -- AND og.refund_status IN (0, 1, 3)
  370. AND og.refund_status IN (0,3)
  371. AND og.pay_status IN (2, 3, 4)
  372. AND og.goods_id = #{goodsId}
  373. </select>
  374. <select id="listLiveGoodsList" parameterType="com.zhongzheng.modules.goods.bo.GoodsQueryBo"
  375. resultMap="OrderGoodsResultVo">
  376. SELECT
  377. g.*,
  378. o.user_id,
  379. o.order_sn,
  380. og.service_start_time,
  381. og.service_end_time,
  382. og.order_goods_id,
  383. u.realname,
  384. u.id_card,
  385. u.user_id,
  386. un.live_num as join_live_num,
  387. un.study_duration as see_time
  388. FROM `order` o
  389. LEFT JOIN order_goods og ON o.order_sn = og.order_sn
  390. LEFT JOIN goods g ON og.goods_id = g.goods_id
  391. LEFT JOIN `user` u ON u.user_id = o.user_id
  392. LEFT JOIN (SELECT
  393. usr.order_goods_id,
  394. count( DISTINCT usr.section_id ) live_num,
  395. SUM( usr.study_duration ) study_duration
  396. FROM
  397. user_study_record usr
  398. LEFT JOIN course_section cs ON usr.section_id = cs.section_id
  399. WHERE
  400. cs.section_type IN ( 2, 3 )
  401. GROUP BY
  402. usr.order_goods_id)un on un.order_goods_id = og.order_goods_id
  403. WHERE
  404. 1 = 1
  405. AND g.goods_type = 6
  406. AND og.pay_status IN ( 2, 3, 4 )
  407. -- AND og.refund_status IN (0,3,1)
  408. AND og.refund_status IN (0,3)
  409. <if test="goodsId != null and goodsId != ''">
  410. AND og.goods_id = #{goodsId}
  411. </if>
  412. <if test="searchKey != null and searchKey != ''">
  413. and (g.goods_name like concat('%', #{searchKey}, '%') or g.code like concat('%', #{searchKey}, '%') or
  414. u.realname like concat('%', #{searchKey}, '%') or u.id_card like concat('%', #{searchKey}, '%'))
  415. </if>
  416. ORDER BY og.create_time DESC
  417. </select>
  418. <select id="listGoodsUserLive" parameterType="com.zhongzheng.modules.goods.bo.GoodsQueryBo"
  419. resultMap="OrderGoodsResultVo">
  420. SELECT
  421. g.*,
  422. cet.education_name,
  423. cpt.project_name,
  424. cb.business_name,
  425. o.user_id,
  426. og.create_time as order_create_time,
  427. og.service_start_time,
  428. og.service_end_time,
  429. og.order_goods_id
  430. FROM
  431. order_goods og
  432. LEFT JOIN goods g on g.goods_id =og.goods_id
  433. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  434. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  435. LEFT JOIN course_business cb ON g.business_id = cb.id
  436. LEFT JOIN `order` o on o.order_sn = og.order_sn
  437. WHERE
  438. 1 = 1
  439. AND g.goods_type = 6
  440. AND o.user_id=#{userId}
  441. AND og.`status` =1
  442. and og.pay_status in (2,3,4)
  443. -- AND og.refund_status in (0,3,1)
  444. AND og.refund_status in (0,3)
  445. <if test="educationTypeId != null and educationTypeId != ''">
  446. AND g.education_type_id = #{educationTypeId}
  447. </if>
  448. <if test="businessId != null and businessId != ''">
  449. AND g.business_id = #{businessId}
  450. </if>
  451. ORDER BY og.create_time DESC
  452. </select>
  453. <select id="listUserVideoLive" parameterType="com.zhongzheng.modules.goods.bo.GoodsQueryBo"
  454. resultMap="OrderGoodsResultVo">
  455. SELECT
  456. g.*,
  457. cet.education_name,
  458. cpt.project_name,
  459. cb.business_name,
  460. cb.goods_learning_order,
  461. o.user_id,
  462. og.create_time as order_create_time,
  463. og.service_start_time,
  464. og.service_end_time,
  465. og.order_goods_id,
  466. og.seven_year as order_year,
  467. og.grade_id,
  468. (SELECT m.category_name FROM major m where m.id = g.major_id) as major_name,
  469. (SELECT
  470. COUNT( m.id )
  471. FROM
  472. goods_course c LEFT JOIN course_menu_exam m ON m.course_id = c.course_id
  473. where
  474. m.type in (1,3)
  475. and c.goods_id = g.goods_id) as exam_num,
  476. -- (SELECT COUNT(DISTINCT ubr.module_id,ubr.chapter_id,ubr.exam_id) FROM user_bank_record ubr LEFT JOIN
  477. -- class_grade_goods cgg on cgg.goods_id
  478. -- = ubr.goods_id where ubr.`status`=1 and ubr.report_status=1 and ubr.grade_id = og.grade_id and ubr.order_goods_id = og.order_goods_id and ubr.user_id =
  479. -- o.user_id and ubr.current_status = 1) as record_num,
  480. (case WHEN (SELECT COUNT(1) FROM exam_apply_goods eag LEFT JOIN exam_apply ea on eag.apply_id = ea.apply_id LEFT JOIN exam_apply_user eau on eau.apply_id = ea.apply_id where eag.goods_id = g.goods_id and ea.`status` = 1 and unix_timestamp(now()) BETWEEN ea.apply_start_time and ea.apply_end_time) >0 then 1 ELSE 0 end) as apply_status,
  481. us.exam_status as sub_exam_status,
  482. us.performance as sub_performance,
  483. us.`result` as sub_result,
  484. us.subscribe_id,
  485. us.apply_site_start_time as sub_apply_site_start_time,
  486. us.apply_site_end_time as sub_apply_site_end_time,
  487. us.apply_site_exam_time as sub_apply_site_exam_time,
  488. (SELECT COUNT(1) FROM goods_course gc where gc.goods_id = g.goods_id) as course_num,
  489. og.study_count as user_study_count,
  490. (SELECT `status` from user_profile where user_id = o.user_id and goods_id = g.goods_id and current_status = 1 and type_status = 1 and order_goods_id = og.order_goods_id limit 1 ) as profile_status,
  491. (SELECT change_status from user_profile where user_id = o.user_id and goods_id = g.goods_id and current_status = 1 and type_status = 1 and order_goods_id = og.order_goods_id limit 1 ) as profile_change_status,
  492. (SELECT count(*) from user_study_record usr where usr.user_id = o.user_id and usr.order_goods_id = og.order_goods_id) as study_status
  493. FROM
  494. order_goods og
  495. LEFT JOIN goods g on g.goods_id =og.goods_id
  496. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  497. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  498. LEFT JOIN course_business cb ON g.business_id = cb.id
  499. LEFT JOIN `order` o on o.order_sn = og.order_sn
  500. LEFT JOIN (SELECT * from user_subscribe where subscribe_id in (SELECT MAX(subscribe_id) from user_subscribe where user_id = #{userId} and subscribe_status = 1 GROUP BY order_goods_id)) us on us.order_goods_id = og.order_goods_id
  501. WHERE
  502. 1 = 1
  503. AND g.goods_type in (1,6)
  504. AND o.user_id=#{userId}
  505. AND og.`status` =1
  506. and og.pay_status in (2,3,4)
  507. -- AND og.refund_status in (0,3,1)
  508. AND og.refund_status in (0,3)
  509. <if test="educationTypeId != null and educationTypeId != ''">
  510. AND g.education_type_id = #{educationTypeId}
  511. </if>
  512. <if test="businessId != null and businessId != ''">
  513. AND g.business_id = #{businessId}
  514. </if>
  515. ORDER BY og.create_time DESC
  516. </select>
  517. <select id="listUserSubjectGoods" parameterType="com.zhongzheng.modules.goods.bo.GoodsQueryBo"
  518. resultMap="OrderGoodsResultVo">
  519. SELECT
  520. og.goods_id,
  521. og.grade_id,
  522. og.order_sn,
  523. g.business_id,
  524. g.subject_ids,
  525. cg.class_status,
  526. cg.class_start_time,
  527. cg.class_end_time,
  528. cg.class_name,
  529. g.goods_name,
  530. og.goods_price,
  531. og.seven_year as order_year,
  532. og.goods_real_price
  533. FROM
  534. `order` o
  535. LEFT JOIN order_goods og ON o.order_sn = og.order_sn
  536. LEFT JOIN goods g ON og.goods_id = g.goods_id
  537. LEFT JOIN class_grade cg ON og.grade_id = cg.grade_id
  538. WHERE
  539. o.user_id = #{userId}
  540. AND og.`status` =1
  541. and og.pay_status in (2,3,4)
  542. AND og.refund_status in (0,3,1)
  543. <if test="businessId != null and businessId != ''">
  544. AND g.business_id = #{businessId}
  545. </if>
  546. <if test="subjectId != null and subjectId != ''">
  547. AND FIND_IN_SET(#{subjectId},g.subject_ids)
  548. </if>
  549. </select>
  550. <select id="selectBuyUserList" parameterType="java.lang.Long" resultMap="OrderGoodsResultVo">
  551. SELECT og.*,
  552. o.user_id
  553. FROM order_goods og
  554. LEFT JOIN `order` o ON og.order_sn = o.order_sn
  555. LEFT JOIN mock_major_subject_goods mmsg ON og.goods_id = mmsg.goods_id
  556. WHERE og.refund_status != 2
  557. and og.pay_status in (2,3,4)
  558. and og.`status` = 1
  559. and mmsg.mock_major_subject_id = #{mockMajorSubjectId}
  560. </select>
  561. <select id="getLiveList" parameterType="java.lang.Long" resultType="com.zhongzheng.modules.course.vo.CourseLiveVo">
  562. SELECT
  563. *
  564. FROM
  565. (
  566. SELECT
  567. gc.course_id AS courseId,
  568. og.order_goods_id AS orderGoodsId,
  569. g.goods_id AS goodsId,
  570. cm.menu_id AS chapterId,
  571. '' AS moduleId,
  572. ct.*
  573. FROM
  574. `order` o
  575. LEFT JOIN order_goods og ON o.order_sn = og.order_sn
  576. LEFT JOIN goods g ON og.goods_id = g.goods_id
  577. INNER JOIN goods_course gc ON g.goods_id = gc.goods_id
  578. LEFT JOIN course_menu cm ON gc.course_id = cm.course_id
  579. LEFT JOIN course_chapter_section cs ON cm.menu_id = cs.chapter_id
  580. LEFT JOIN course_section ct ON cs.section_id = ct.section_id
  581. WHERE
  582. o.user_id = #{userId}
  583. AND og.pay_status IN ( 2, 3, 4 )
  584. -- AND og.refund_status != 2
  585. AND og.refund_status IN (0,3)
  586. AND og.STATUS = 1
  587. AND o.`status` = 1
  588. AND g.`status` = 1
  589. AND g.goods_type = 6
  590. AND cm.type = 2
  591. AND ct.section_type = 2 UNION ALL
  592. SELECT
  593. gc.course_id AS courseId,
  594. og.order_goods_id AS orderGoodsId,
  595. g.goods_id AS goodsId,
  596. '' AS chapterId,
  597. '' AS moduleId,
  598. ct.*
  599. FROM
  600. `order` o
  601. LEFT JOIN order_goods og ON o.order_sn = og.order_sn
  602. LEFT JOIN goods g ON og.goods_id = g.goods_id
  603. INNER JOIN goods_course gc ON g.goods_id = gc.goods_id
  604. LEFT JOIN course_menu cm ON gc.course_id = cm.course_id
  605. LEFT JOIN course_section ct ON cm.menu_id = ct.section_id
  606. WHERE
  607. o.user_id = #{userId}
  608. AND og.pay_status IN ( 2, 3, 4 )
  609. -- AND og.refund_status != 2
  610. AND og.refund_status IN (0,3)
  611. AND og.STATUS = 1
  612. AND o.`status` = 1
  613. AND g.`status` = 1
  614. AND g.goods_type = 6
  615. AND cm.type = 3
  616. AND ct.section_type = 2 UNION ALL
  617. SELECT
  618. gc.course_id AS courseId,
  619. og.order_goods_id AS orderGoodsId,
  620. g.goods_id AS goodsId,
  621. cmc.chapter_id AS chapterId,
  622. cmc.module_id AS moduleId,
  623. ct.*
  624. FROM
  625. `order` o
  626. LEFT JOIN order_goods og ON o.order_sn = og.order_sn
  627. LEFT JOIN goods g ON og.goods_id = g.goods_id
  628. INNER JOIN goods_course gc ON g.goods_id = gc.goods_id
  629. LEFT JOIN course_menu cm ON gc.course_id = cm.course_id
  630. LEFT JOIN course_module_chapter cmc ON cm.menu_id = cmc.module_id
  631. LEFT JOIN course_chapter_section ccs ON cmc.chapter_id = ccs.chapter_id
  632. LEFT JOIN course_section ct ON ccs.section_id = ct.section_id
  633. WHERE
  634. o.user_id = #{userId}
  635. AND og.pay_status IN ( 2, 3, 4 )
  636. -- AND og.refund_status != 2
  637. AND og.refund_status IN (0,3)
  638. AND og.STATUS = 1
  639. AND o.`status` = 1
  640. AND g.`status` = 1
  641. AND g.goods_type = 6
  642. AND cm.type = 1
  643. AND ct.section_type = 2
  644. ) a
  645. ORDER BY
  646. a.live_start_time ASC
  647. </select>
  648. <select id="getBuyNotStudyList" parameterType="com.zhongzheng.modules.order.bo.OrderQueryBo" resultMap="OrderGoodsResultVo">
  649. SELECT
  650. o.user_id,
  651. any_value (og.order_goods_id) order_goods_id,
  652. any_value (g.goods_id) goods_id,
  653. any_value (og.grade_id) grade_id,
  654. any_value (cg.sys_user_id) sys_user_id,
  655. any_value (g.goods_name) goods_name
  656. FROM
  657. order_goods og
  658. LEFT JOIN `order` o ON og.order_sn = o.order_sn
  659. LEFT JOIN goods g ON og.goods_id = g.goods_id
  660. LEFT JOIN class_grade cg ON og.grade_id = cg.grade_id
  661. LEFT JOIN ( SELECT count(*) study_num, usr.user_id, usr.grade_id FROM user_study_record usr GROUP BY usr.user_id, usr.grade_id ) r ON r.grade_id = og.grade_id
  662. AND r.user_id = o.user_id
  663. WHERE
  664. og.refund_status != 2
  665. AND og.pay_status IN ( 2, 3, 4 )
  666. AND og.`status` = 1
  667. AND g.goods_type = 1
  668. AND r.study_num IS NULL
  669. AND og.create_time > #{startTime}
  670. AND #{endTime} >= og.create_time
  671. GROUP BY o.user_id
  672. </select>
  673. <select id="getLongNotStudyList" parameterType="com.zhongzheng.modules.order.bo.OrderQueryBo" resultMap="OrderGoodsResultVo">
  674. SELECT
  675. o.user_id,
  676. any_value (og.order_goods_id) order_goods_id,
  677. any_value (g.goods_id) goods_id,
  678. any_value (og.grade_id) grade_id,
  679. any_value (cg.sys_user_id) sys_user_id,
  680. any_value (g.goods_name) goods_name
  681. FROM
  682. order_goods og
  683. LEFT JOIN `order` o ON og.order_sn = o.order_sn
  684. LEFT JOIN goods g ON og.goods_id = g.goods_id
  685. LEFT JOIN class_grade cg ON og.grade_id = cg.grade_id
  686. LEFT JOIN ( SELECT MAX(usr.update_time) last_time, usr.user_id, usr.grade_id FROM user_study_record usr GROUP BY usr.user_id, usr.grade_id ) r ON r.grade_id = og.grade_id
  687. AND r.user_id = o.user_id
  688. WHERE
  689. og.refund_status != 2
  690. AND og.pay_status IN ( 2, 3, 4 )
  691. AND og.`status` = 1
  692. AND g.goods_type = 1
  693. AND r.last_time > #{startTime}
  694. AND #{endTime} >= r.last_time
  695. GROUP BY o.user_id
  696. </select>
  697. <select id="getGoodsSectionList" parameterType="java.lang.Long" resultType="com.zhongzheng.modules.goods.vo.GoodsSectionListVo">
  698. SELECT
  699. *
  700. FROM
  701. (
  702. SELECT
  703. gc.goods_id,
  704. gc.sort AS gcSort,
  705. cm.sort AS cmSort,
  706. cmd.sort AS cmdSort,
  707. ccs.sort AS ccsSort,
  708. cs.sort AS csSort,
  709. cm.course_id,
  710. cmd.module_id,
  711. ccs.chapter_id,
  712. cs.section_id,
  713. cs.`name` as sectionName
  714. FROM
  715. goods_course gc
  716. LEFT JOIN course_menu cm ON gc.course_id = cm.course_id
  717. LEFT JOIN course_module_chapter cmd ON cm.menu_id = cmd.module_id
  718. LEFT JOIN course_chapter_section ccs ON cmd.chapter_id = ccs.chapter_id
  719. LEFT JOIN course_section cs ON ccs.section_id = cs.section_id
  720. WHERE
  721. gc.goods_id = #{goodsId}
  722. AND cm.type = 1
  723. UNION ALL
  724. SELECT
  725. gc.goods_id,
  726. gc.sort AS gcSort,
  727. cm.sort AS cmSort,
  728. NULL AS cmdSort,
  729. ccs.sort AS ccsSort,
  730. cs.sort AS csSort,
  731. cm.course_id,
  732. 0 AS module_id,
  733. ccs.chapter_id,
  734. cs.section_id,
  735. cs.`name` as sectionName
  736. FROM
  737. goods_course gc
  738. LEFT JOIN course_menu cm ON gc.course_id = cm.course_id
  739. LEFT JOIN course_chapter_section ccs ON cm.menu_id = ccs.chapter_id
  740. LEFT JOIN course_section cs ON ccs.section_id = cs.section_id
  741. WHERE
  742. gc.goods_id = #{goodsId}
  743. AND cm.type = 2
  744. UNION ALL
  745. SELECT
  746. gc.goods_id,
  747. gc.sort AS gcSort,
  748. cm.sort AS cmSort,
  749. NULL AS cmdSort,
  750. NULL AS ccsSort,
  751. cs.sort AS csSort,
  752. cm.course_id,
  753. 0 AS module_id,
  754. 0 AS chapter_id,
  755. cs.section_id,
  756. cs.`name` as sectionName
  757. FROM
  758. goods_course gc
  759. LEFT JOIN course_menu cm ON gc.course_id = cm.course_id
  760. LEFT JOIN course_section cs ON cm.menu_id = cs.section_id
  761. WHERE
  762. gc.goods_id = #{goodsId}
  763. AND cm.type = 3
  764. ) a
  765. ORDER BY
  766. a.gcSort,
  767. cmSort,
  768. cmdSort,
  769. ccsSort,
  770. csSort
  771. </select>
  772. <select id="getOrderByGoods" parameterType="java.lang.Long" resultType="com.zhongzheng.modules.order.domain.OrderGoods">
  773. SELECT
  774. *
  775. FROM
  776. order_goods og
  777. LEFT JOIN `order` o ON og.order_sn = o.order_sn
  778. LEFT JOIN goods g ON og.goods_id = g.goods_id
  779. WHERE
  780. og.`status` = 1
  781. AND o.`status` = 1
  782. AND g.`status` = 1
  783. AND og.refund_status != 2
  784. AND og.pay_status IN ( 2, 3, 4 )
  785. AND o.user_id = #{userId}
  786. AND g.goods_id = #{goodsId}
  787. LIMIT 1
  788. </select>
  789. <resultMap id="getlist" type="com.zhongzheng.modules.top.goods.vo.TopOldOrderGoodsListVo">
  790. <result property="orderGoodsId" column="order_goods_id"/>
  791. <result property="gradeId" column="grade_id"/>
  792. <result property="goodsId" column="goods_id"/>
  793. <result property="userId" column="user_id" />
  794. <result property="userName" column="realname" />
  795. <result property="userCard" column="id_card" typeHandler="com.zhongzheng.common.type.EncryptHandler"/>
  796. <result property="userPhone" column="telphone" typeHandler="com.zhongzheng.common.type.EncryptHandler"/>
  797. <result property="goodsName" column="goods_name"/>
  798. <result property="goodsType" column="goods_type"/>
  799. <result property="subjectIds" column="subject_ids"/>
  800. <result property="businessName" column="business_name"/>
  801. <result property="goodsPrice" column="goods_price"/>
  802. <result property="goodsRealPrice" column="goods_real_price"/>
  803. <result property="checkStatus" column="check_status"/>
  804. <result property="goodsYear" column="goods_year"/>
  805. <result property="divideType" column="divide_type"/>
  806. <result property="divideRate" column="divide_rate"/>
  807. <result property="divideMoney" column="divide_money"/>
  808. </resultMap>
  809. <select id="listByOrderSn" parameterType="com.zhongzheng.modules.top.goods.bo.TopOldOrderGoodsQuery" resultMap="getlist">
  810. SELECT
  811. og.order_goods_id,
  812. og.grade_id,
  813. og.goods_id,
  814. u.user_id,
  815. u.realname,
  816. u.id_card,
  817. u.telphone,
  818. g.goods_name,
  819. g.goods_type,
  820. g.subject_ids,
  821. CONCAT( cb.business_name, cpt.project_name ) AS business_name,
  822. og.goods_price,
  823. og.goods_real_price,
  824. og.goods_year,
  825. og.divide_type,
  826. og.divide_rate,
  827. og.divide_money,
  828. 1 as check_status
  829. FROM
  830. order_goods og
  831. LEFT JOIN goods g ON og.goods_id = g.goods_id
  832. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  833. LEFT JOIN course_business cb ON g.business_id = cb.id
  834. LEFT JOIN `order` o ON og.order_sn = o.order_sn
  835. LEFT JOIN `user` u ON o.user_id = u.user_id
  836. WHERE
  837. og.order_sn = #{orderSn}
  838. AND og.`status` = 1
  839. -- AND og.refund_status != 2
  840. -- AND og.pay_status IN ( 2, 3, 4 )
  841. <if test="userCard != null and userCard != ''">
  842. AND u.id_card = #{userCard,typeHandler=com.zhongzheng.common.type.EncryptHandler}
  843. </if>
  844. <if test="userName != null and userName != ''">
  845. AND u.realname LIKE CONCAT( '%', #{userName}, '%' )
  846. </if>
  847. </select>
  848. <select id="getBusinessById" parameterType="java.lang.Long" resultType="java.lang.String">
  849. SELECT
  850. CONCAT( '学校业务', cet.education_name, cb.business_name, cpt.project_name ) AS businessName
  851. FROM
  852. order_goods og
  853. LEFT JOIN goods g ON og.goods_id = g.goods_id
  854. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  855. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  856. LEFT JOIN course_business cb ON g.business_id = cb.id
  857. WHERE
  858. og.`status` = 1
  859. AND og.order_goods_id = #{orderGoodsId}
  860. </select>
  861. <select id="getApplyOrderGoods" parameterType="map" resultType="com.zhongzheng.modules.order.domain.OrderGoods">
  862. SELECT
  863. og.*
  864. FROM
  865. order_goods og
  866. LEFT JOIN `order` o ON og.order_sn = o.order_sn
  867. WHERE
  868. og.`status` = 1
  869. AND og.refund_status != 2
  870. AND og.pay_status IN ( 2, 3, 4 )
  871. AND og.goods_id in
  872. <foreach collection="goodsIds" item="item" index="index" open="(" close=")" separator=",">
  873. #{item}
  874. </foreach>
  875. AND o.`status` = 1
  876. AND o.user_id = #{userId}
  877. </select>
  878. <select id="getSevenLastOne" parameterType="map" resultType="com.zhongzheng.modules.order.domain.OrderGoods">
  879. SELECT
  880. og.*
  881. FROM
  882. order_goods og
  883. LEFT JOIN goods g ON og.goods_id = g.goods_id
  884. LEFT JOIN `order` o ON og.order_sn = o.order_sn
  885. WHERE
  886. og.`status` = 1
  887. AND og.refund_status != 2
  888. AND o.user_id = #{userId}
  889. AND og.pay_status IN ( 2, 3, 4 )
  890. AND g.project_id = #{projectId}
  891. AND og.seven_class_status = 3
  892. AND og.seven_year = #{sevenYear}
  893. AND og.seven_class_version > 0
  894. ORDER BY og.seven_class_version DESC
  895. LIMIT 1
  896. </select>
  897. <select id="countOrderGoodsByYear" parameterType="map" resultType="java.lang.Long">
  898. SELECT
  899. COUNT( og.order_goods_id )
  900. FROM
  901. order_goods og
  902. LEFT JOIN `order` o ON og.order_sn = o.order_sn
  903. WHERE
  904. og.refund_status != 2
  905. AND og.pay_status IN ( 2, 3, 4 )
  906. AND og.`status` = 1
  907. AND o.`status` = 1
  908. AND o.user_id = #{userId}
  909. AND og.goods_id = #{goodsId}
  910. AND og.seven_year = #{sevenYear}
  911. AND og.service_start_time <![CDATA[ <= ]]> UNIX_TIMESTAMP()
  912. AND og.service_end_time <![CDATA[ >= ]]> UNIX_TIMESTAMP()
  913. </select>
  914. <select id="getByIdNoTenant" parameterType="java.lang.Long" resultType="com.zhongzheng.modules.order.domain.OrderGoods">
  915. SELECT
  916. *
  917. FROM
  918. order_goods
  919. WHERE
  920. order_goods_id = #{orderGoodsId}
  921. </select>
  922. <select id="getMailList" parameterType="com.zhongzheng.modules.order.bo.MailOrderBo" resultType="com.zhongzheng.modules.order.vo.MailOrderVo">
  923. SELECT
  924. order_sn,
  925. mail_status,
  926. consignee,
  927. consignee_phone,
  928. consignee_site,
  929. mail_remark
  930. FROM
  931. `order`
  932. WHERE
  933. `status` = 1
  934. AND order_type = 5
  935. <if test="orderSn != null and orderSn != ''">
  936. AND order_sn = #{orderSn}
  937. </if>
  938. <if test="mailStatus != null">
  939. AND mail_status = #{mailStatus}
  940. </if>
  941. order by create_time DESC
  942. </select>
  943. <select id="sendTenOrderGoods" parameterType="java.lang.Long" resultMap="OrderGoodsResultVo">
  944. SELECT
  945. og.*,o.user_id
  946. FROM
  947. order_goods og
  948. LEFT JOIN `order` o on og.order_sn = o.order_sn
  949. LEFT JOIN goods g on og.goods_id = g.goods_id
  950. LEFT JOIN inform_remind_business irb on irb.business_id = g.business_id
  951. LEFT JOIN class_grade_user cgu on cgu.order_goods_id = og.order_goods_id
  952. where 1=1
  953. and irb.remind_id =#{remindId}
  954. and og.status = 1
  955. and cgu.period_status in (0,-1)
  956. AND og.service_end_time BETWEEN ( unix_timestamp(now()) + 864000) AND (unix_timestamp(now()) + 950400)
  957. </select>
  958. <select id="listByNotTenant" resultType="com.zhongzheng.modules.order.domain.OrderGoods">
  959. SELECT og.* FROM order_goods og
  960. LEFT JOIN goods g ON og.goods_id = g.goods_id
  961. WHERE og.`status` = 1
  962. AND (( og.course_num IS NULL OR og.course_num = 0 ) AND ( og.exam_num IS NULL OR og.exam_num = 0 ))
  963. AND og.refund_status != 2
  964. AND og.pay_status != 1
  965. AND g.goods_type = 1
  966. </select>
  967. <update id="upBatchNumById" parameterType="com.zhongzheng.modules.order.domain.OrderGoods">
  968. UPDATE order_goods SET course_num = #{courseNum}, exam_num = #{examNum} WHERE order_goods_id = #{orderGoodsId}
  969. </update>
  970. <select id="listRepByOrderSn" parameterType="com.zhongzheng.modules.top.order.bo.TopOrderRepGoodsQueryBo"
  971. resultType="com.zhongzheng.modules.top.order.vo.TopOldOrderRepDetailVo">
  972. SELECT
  973. og.order_sn,
  974. og.order_goods_id,
  975. og.goods_id,
  976. u.user_id,
  977. u.realname as userName,
  978. u.sex,
  979. u.id_card,
  980. g.goods_name,
  981. og.goods_price,
  982. og.goods_year,
  983. m.category_name as majorName,
  984. og.refund_status,
  985. og.finish_time,
  986. og.publicity_time,
  987. og.acquire_time,
  988. (SELECT ogr.refund_time FROM order_goods_refund ogr WHERE ogr.order_goods_id = og.order_goods_id AND ogr.`status` = 1 AND ogr.period_status = 3 LIMIT 1) AS refund_time
  989. FROM
  990. order_goods og
  991. LEFT JOIN goods g ON og.goods_id = g.goods_id
  992. LEFT JOIN `order` o ON og.order_sn = o.order_sn
  993. LEFT JOIN `user` u ON o.user_id = u.user_id
  994. LEFT JOIN major m ON g.major_id = m.id
  995. WHERE
  996. og.order_sn = #{orderSn}
  997. AND og.`status` = 1
  998. </select>
  999. <select id="getHandleStudyList" parameterType="com.zhongzheng.modules.order.bo.HandleStudyQuery" resultType="com.zhongzheng.modules.order.vo.HandleStudyVo">
  1000. SELECT
  1001. o.order_sn ,
  1002. FROM_UNIXTIME( og.create_time, '%Y-%m-%d %H:%i:%s' ) AS orderTime,
  1003. u.realname AS userName,
  1004. AES_DECRYPT(UNHEX(u.id_card),'base20230213zzkj') AS userCard,
  1005. AES_DECRYPT(UNHEX(u.telphone),'base20230213zzkj') AS userTel,
  1006. u.company_name,
  1007. g.goods_name,
  1008. g.seven_year,
  1009. CONCAT(cet.education_name,cb.business_name,cpt.project_name) AS businessName,
  1010. m.category_name,
  1011. cg.class_name,
  1012. CASE
  1013. WHEN cg.class_status = 1 THEN '已开班'
  1014. WHEN cg.class_status = 0 THEN '未开班'
  1015. ELSE '其他' END AS classStart,
  1016. FROM_UNIXTIME( cg.class_end_time, '%Y-%m-%d %H:%i:%s' ) AS classTime,
  1017. CONCAT((
  1018. ((SELECT COUNT(DISTINCT ubr.module_id,ubr.chapter_id,ubr.exam_id) FROM user_bank_record ubr where ubr.`status`=1 and ubr.report_status=1 and ubr.grade_id = og.grade_id and ubr.order_goods_id = og.order_goods_id and ubr.user_id = cgu.user_id and ubr.current_status = 1) +
  1019. (
  1020. SELECT
  1021. COUNT( DISTINCT course_id, module_id, chapter_id, section_id )
  1022. FROM
  1023. user_study_record
  1024. WHERE
  1025. current_status = 1
  1026. AND grade_id = og.grade_id
  1027. AND order_goods_id = og.order_goods_id
  1028. AND user_id = o.user_id
  1029. AND status = 1
  1030. AND goods_id = og.goods_id
  1031. ))
  1032. ),"/",og.course_num + og.exam_num) AS studySchedule
  1033. FROM
  1034. order_handle oh
  1035. LEFT JOIN `order` o ON oh.handle_order_sn = o.handle_order_sn
  1036. LEFT JOIN order_goods og ON o.order_sn = og.order_sn
  1037. LEFT JOIN goods g ON og.goods_id = g.goods_id
  1038. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  1039. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  1040. LEFT JOIN course_business cb ON g.business_id = cb.id
  1041. LEFT JOIN major m ON g.major_id = m.id
  1042. LEFT JOIN `user` u ON o.user_id = u.user_id
  1043. LEFT JOIN class_grade_user cgu ON og.order_goods_id = cgu.order_goods_id
  1044. LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id
  1045. WHERE
  1046. 1=1
  1047. AND og.pay_status != 1
  1048. AND og.refund_status != 2
  1049. AND o.`status` = 1
  1050. AND og.`status` = 1
  1051. AND cgu.`status` = 1
  1052. AND oh.create_user_id = #{userId}
  1053. <if test="orderSn != null and orderSn != ''">
  1054. AND o.order_sn = #{orderSn}
  1055. </if>
  1056. <if test="userName != null and userName != ''">
  1057. AND u.realname LIKE CONCAT('%',#{userName},'%')
  1058. </if>
  1059. <if test="userCard != null and userCard != ''">
  1060. AND AES_DECRYPT(UNHEX(u.id_card),'base20230213zzkj') = #{userCard}
  1061. </if>
  1062. <if test="userTel != null and userTel != ''">
  1063. AND AES_DECRYPT(UNHEX(u.telphone),'base20230213zzkj') = #{userTel}
  1064. </if>
  1065. </select>
  1066. </mapper>