OrderMapper.xml 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699
  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.OrderMapper">
  6. <resultMap type="com.zhongzheng.modules.order.domain.Order" id="OrderResult">
  7. <result property="orderId" column="order_id"/>
  8. <result property="orderSn" column="order_sn"/>
  9. <result property="userId" column="user_id"/>
  10. <result property="orderPrice" column="order_price"/>
  11. <result property="orderGeneral" column="order_general"/>
  12. <result property="orderStatus" column="order_status"/>
  13. <result property="createTime" column="create_time"/>
  14. <result property="updateTime" column="update_time"/>
  15. <result property="payTime" column="pay_time"/>
  16. <result property="payType" column="pay_type"/>
  17. <result property="transid" column="transid"/>
  18. <result property="cancelTime" column="cancel_time"/>
  19. <result property="finishTime" column="finish_time"/>
  20. <result property="orderType" column="order_type"/>
  21. <result property="payPrice" column="pay_price"/>
  22. <result property="chargingType" column="charging_type"/>
  23. <result property="orderFrom" column="order_from"/>
  24. <result property="createUsername" column="create_username"/>
  25. <result property="createSysUserId" column="create_sys_user_id"/>
  26. <result property="inputOrderSn" column="input_order_sn"/>
  27. <result property="payStatus" column="pay_status"/>
  28. </resultMap>
  29. <resultMap type="com.zhongzheng.modules.order.vo.OrderListVo" id="OrderResultVo">
  30. <result property="orderId" column="order_id"/>
  31. <result property="orderSn" column="order_sn"/>
  32. <result property="userId" column="user_id"/>
  33. <result property="orderPrice" column="order_price"/>
  34. <result property="orderGeneral" column="order_general"/>
  35. <result property="orderStatus" column="order_status"/>
  36. <result property="createTime" column="create_time"/>
  37. <result property="payTime" column="pay_time"/>
  38. <result property="payType" column="pay_type"/>
  39. <result property="transid" column="transid"/>
  40. <result property="cancelTime" column="cancel_time"/>
  41. <result property="finishTime" column="finish_time"/>
  42. <result property="orderType" column="order_type"/>
  43. <result property="payPrice" column="pay_price"/>
  44. <result property="chargingType" column="charging_type"/>
  45. <result property="orderFrom" column="order_from"/>
  46. <result property="status" column="status"/>
  47. <result property="periodStatus" column="period_status"/>
  48. <result property="goodsName" column="goods_name"/>
  49. <result property="goodsId" column="goods_id"/>
  50. <result property="year" column="year"/>
  51. <result property="coverUrl" column="cover_url"/>
  52. <result property="code" column="code"/>
  53. <result property="rebuyOrderGoodsId" column="rebuy_order_goods_id"/>
  54. <result property="educationName" column="education_name"/>
  55. <result property="projectName" column="project_name"/>
  56. <result property="businessName" column="business_name"/>
  57. <result property="schoolName" column="school_name"/>
  58. <result property="categoryName" column="category_name"/>
  59. <result property="goodsPrice" column="goods_price"/>
  60. <result property="goodsRealPrice" column="goods_real_price"/>
  61. <result property="idCard" column="id_card" typeHandler="com.zhongzheng.common.type.EncryptHandler"/>
  62. <result property="telphone" column="telphone" typeHandler="com.zhongzheng.common.type.EncryptHandler"/>
  63. <result property="realname" column="realname"/>
  64. <result property="companyName" column="company_name"/>
  65. <result property="goodsReceived" column="goods_received"/>
  66. <result property="refundStatus" column="refund_status"/>
  67. <result property="payStatus" column="pay_status"/>
  68. <result property="orderGoodsId" column="order_goods_id"/>
  69. <result property="periodPlush" column="period_plush"/>
  70. <result property="goodsPayStatus" column="goods_pay_status"/>
  71. <result property="goodsType" column="goods_type"/>
  72. <result property="invoiceStatus" column="invoice_status"/>
  73. <result property="serviceStartTime" column="service_start_time"/>
  74. <result property="serviceEndTime" column="service_end_time"/>
  75. </resultMap>
  76. <select id="getGradePeriod" parameterType="Map" resultType="integer">
  77. SELECT
  78. cgu.period_plush
  79. FROM
  80. order_goods og
  81. LEFT JOIN class_grade_user cgu ON og.order_goods_id = cgu.order_goods_id
  82. AND cgu.user_id = #{userId} where og.order_goods_id = #{orderGoodsId}
  83. AND cgu.`status` = 1 limit 1
  84. </select>
  85. <select id="selectListByBo" parameterType="com.zhongzheng.modules.order.bo.OrderQueryBo" resultMap="OrderResultVo">
  86. SELECT
  87. o.*,
  88. g.goods_id,
  89. g.goods_name,
  90. g.year,
  91. g.cover_url,
  92. g.code,
  93. g.goods_type,
  94. og.goods_price,
  95. og.rebuy_order_goods_id,
  96. og.order_goods_id,
  97. og.goods_real_price,
  98. u.telphone,
  99. u.realname,
  100. u.id_card,
  101. u.company_name,
  102. cet.education_name,
  103. cpt.project_name,
  104. cb.business_name,
  105. s.school_name,
  106. m.category_name,
  107. og.goods_received,
  108. og.refund_status,
  109. og.pay_status as goods_pay_status,
  110. (select cgu.period_plush from class_grade_user cgu where cgu.grade_id = og.grade_id and cgu.order_goods_id = og.order_goods_id and cgu.user_id = o.user_id limit 1 ) period_plush,
  111. (SELECT oi.invoice_status FROM order_invoice oi LEFT JOIN order_invoice_order oio ON oio.invoice_id = oi.invoice_id WHERE
  112. oio.order_goods_id = og.order_goods_id AND oi.period_status != 2 limit 1) invoice_status
  113. FROM
  114. `order` o
  115. LEFT JOIN order_goods og ON o.order_sn = og.order_sn
  116. LEFT JOIN goods g ON og.goods_id = g.goods_id
  117. LEFT JOIN `user` u ON o.user_id = u.user_id
  118. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  119. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  120. LEFT JOIN course_business cb ON g.business_id = cb.id
  121. LEFT JOIN school s ON s.id = g.school_id
  122. LEFT JOIN major m ON g.major_id = m.id
  123. WHERE 1=1
  124. <if test="educationTypeId != null and educationTypeId != ''">
  125. AND g.education_type_id = #{educationTypeId}
  126. </if>
  127. <if test="businessId != null and businessId != ''">
  128. AND g.business_id = #{businessId}
  129. </if>
  130. <if test="schoolId != null and schoolId != ''">
  131. AND g.school_id = #{schoolId}
  132. </if>
  133. <if test="majorId != null and majorId != ''">
  134. AND g.major_id = #{majorId}
  135. </if>
  136. <if test="orderSn != null and orderSn != ''">
  137. AND o.order_sn = #{orderSn}
  138. </if>
  139. <if test="orderStatus != null ">
  140. AND o.order_status in
  141. <foreach collection="orderStatus" item="item" index="index" open="(" close=")" separator=",">
  142. #{item}
  143. </foreach>
  144. </if>
  145. <if test="status != null ">
  146. AND o.status in
  147. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  148. #{item}
  149. </foreach>
  150. </if>
  151. <if test="orderGoodsStatus == 1">
  152. AND og.pay_status in (2,3,4) AND og.refund_status != 2
  153. </if>
  154. <if test="startTime != null">
  155. AND o.create_time >= #{startTime}
  156. </if>
  157. <if test="endTime != null">
  158. AND #{endTime} >= o.create_time
  159. </if>
  160. <if test="payStatus != null">
  161. AND o.pay_status = #{payStatus}
  162. </if>
  163. <if test="goodsPayStatus != null">
  164. AND og.pay_status = #{goodsPayStatus}
  165. </if>
  166. <if test="refundStatus != null">
  167. AND og.refund_status = #{refundStatus}
  168. </if>
  169. <if test="goodsType != null">
  170. AND g.goods_type = #{goodsType}
  171. </if>
  172. <if test="userId != null">
  173. AND u.user_id = #{userId}
  174. AND og.pay_status in (2,3,4)
  175. </if>
  176. <if test="inputOrderSn != null">
  177. AND o.input_order_sn = #{inputOrderSn}
  178. </if>
  179. <if test="searchKey != null and searchKey != ''">
  180. AND (u.realname like concat('%', #{searchKey}, '%') or o.order_sn = #{searchKey} or u.id_card = #{searchKey} or g.goods_name like concat('%', #{searchKey}, '%'))
  181. </if>
  182. <if test="orderGoodsIds != null ">
  183. AND og.order_goods_id in
  184. <foreach collection="orderGoodsIds" item="item" index="index" open="(" close=")" separator=",">
  185. #{item}
  186. </foreach>
  187. </if>
  188. <if test="orderFroms != null ">
  189. AND o.order_from in
  190. <foreach collection="orderFroms" item="item" index="index" open="(" close=")" separator=",">
  191. #{item}
  192. </foreach>
  193. </if>
  194. ORDER BY o.order_id DESC
  195. </select>
  196. <select id="selectDangAnOrderList" parameterType="com.zhongzheng.modules.order.bo.OrderQueryBo" resultMap="OrderResultVo">
  197. SELECT
  198. o.*,
  199. g.goods_id,
  200. g.goods_name,
  201. g.year,
  202. g.cover_url,
  203. g.code,
  204. g.goods_type,
  205. og.goods_price,
  206. og.rebuy_order_goods_id,
  207. og.order_goods_id,
  208. og.goods_real_price,
  209. u.telphone,
  210. u.realname,
  211. u.id_card,
  212. cet.education_name,
  213. cpt.project_name,
  214. cb.business_name,
  215. og.goods_received,
  216. og.refund_status,
  217. og.pay_status as goods_pay_status,
  218. og.service_start_time,
  219. og.service_end_time
  220. FROM
  221. `order` o
  222. LEFT JOIN order_goods og ON o.order_sn = og.order_sn
  223. LEFT JOIN goods g ON og.goods_id = g.goods_id
  224. LEFT JOIN `user` u ON o.user_id = u.user_id
  225. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  226. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  227. LEFT JOIN course_business cb ON g.business_id = cb.id
  228. WHERE 1=1
  229. <if test="educationTypeId != null and educationTypeId != ''">
  230. AND g.education_type_id = #{educationTypeId}
  231. </if>
  232. <if test="businessId != null and businessId != ''">
  233. AND g.business_id = #{businessId}
  234. </if>
  235. <if test="orderSn != null and orderSn != ''">
  236. AND o.order_sn = #{orderSn}
  237. </if>
  238. <if test="orderStatus != null ">
  239. AND o.order_status in
  240. <foreach collection="orderStatus" item="item" index="index" open="(" close=")" separator=",">
  241. #{item}
  242. </foreach>
  243. </if>
  244. <if test="status != null ">
  245. AND o.status in
  246. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  247. #{item}
  248. </foreach>
  249. </if>
  250. <if test="orderGoodsStatus == 1">
  251. AND og.pay_status in (2,3,4) AND og.refund_status != 2
  252. </if>
  253. <if test="startTime != null">
  254. AND o.create_time >= #{startTime}
  255. </if>
  256. <if test="endTime != null">
  257. AND #{endTime} >= o.create_time
  258. </if>
  259. <if test="payStatus != null">
  260. AND o.pay_status = #{payStatus}
  261. </if>
  262. <if test="goodsPayStatus != null">
  263. AND og.pay_status = #{goodsPayStatus}
  264. </if>
  265. <if test="refundStatus != null">
  266. AND og.refund_status = #{refundStatus}
  267. </if>
  268. <if test="goodsType != null">
  269. AND g.goods_type = #{goodsType}
  270. </if>
  271. <if test="userId != null">
  272. AND u.user_id = #{userId}
  273. </if>
  274. <if test="inputOrderSn != null">
  275. AND o.input_order_sn = #{inputOrderSn}
  276. </if>
  277. <if test="searchKey != null and searchKey != ''">
  278. AND (u.realname like concat('%', #{searchKey}, '%') or o.order_sn = #{searchKey} or u.id_card = #{searchKey} or g.goods_name like concat('%', #{searchKey}, '%'))
  279. </if>
  280. <if test="orderGoodsIds != null ">
  281. AND og.order_goods_id in
  282. <foreach collection="orderGoodsIds" item="item" index="index" open="(" close=")" separator=",">
  283. #{item}
  284. </foreach>
  285. </if>
  286. <if test="orderFroms != null ">
  287. AND o.order_from in
  288. <foreach collection="orderFroms" item="item" index="index" open="(" close=")" separator=",">
  289. #{item}
  290. </foreach>
  291. </if>
  292. ORDER BY o.order_id DESC
  293. </select>
  294. <select id="selectRebuyList" parameterType="com.zhongzheng.modules.order.bo.OrderQueryBo" resultMap="OrderResultVo">
  295. SELECT
  296. o.*,
  297. g.goods_id,
  298. g.goods_name,
  299. g.year,
  300. g.cover_url,
  301. g.code,
  302. g.goods_type,
  303. og.goods_price,
  304. og.rebuy_order_goods_id,
  305. og.order_goods_id,
  306. og.goods_real_price,
  307. u.telphone,
  308. u.realname,
  309. u.id_card,
  310. cet.education_name,
  311. cpt.project_name,
  312. cb.business_name,
  313. s.school_name,
  314. m.category_name,
  315. og.goods_received,
  316. og.refund_status,
  317. og.pay_status as goods_pay_status,
  318. cgu.period_plush,
  319. (SELECT oi.invoice_status FROM order_invoice oi LEFT JOIN order_invoice_order oio ON oio.invoice_id = oi.invoice_id WHERE
  320. oio.order_goods_id = og.order_goods_id AND oi.period_status != 2 limit 1) invoice_status
  321. FROM
  322. `order` o
  323. LEFT JOIN order_goods og ON o.order_sn = og.order_sn
  324. LEFT JOIN goods g ON og.goods_id = g.goods_id
  325. LEFT JOIN `user` u ON o.user_id = u.user_id
  326. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  327. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  328. LEFT JOIN course_business cb ON g.business_id = cb.id
  329. LEFT JOIN school s ON s.id = g.school_id
  330. LEFT JOIN major m ON g.major_id = m.id
  331. LEFT JOIN order_goods og2 ON og.rebuy_order_goods_id = og2.order_goods_id
  332. LEFT JOIN class_grade_user cgu on cgu.grade_id = og2.grade_id and cgu.user_id = o.user_id and cgu.order_goods_id = og.order_goods_id
  333. WHERE 1=1
  334. AND og.rebuy_order_goods_id >0
  335. AND cgu.period_plush = 1
  336. <if test="educationTypeId != null and educationTypeId != ''">
  337. AND g.education_type_id = #{educationTypeId}
  338. </if>
  339. <if test="businessId != null and businessId != ''">
  340. AND g.business_id = #{businessId}
  341. </if>
  342. <if test="schoolId != null and schoolId != ''">
  343. AND g.school_id = #{schoolId}
  344. </if>
  345. <if test="majorId != null and majorId != ''">
  346. AND g.major_id = #{majorId}
  347. </if>
  348. <if test="orderSn != null and orderSn != ''">
  349. AND o.order_sn = #{orderSn}
  350. </if>
  351. <if test="orderStatus != null ">
  352. AND o.order_status in
  353. <foreach collection="orderStatus" item="item" index="index" open="(" close=")" separator=",">
  354. #{item}
  355. </foreach>
  356. </if>
  357. <if test="status != null ">
  358. AND o.status in
  359. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  360. #{item}
  361. </foreach>
  362. </if>
  363. <if test="startTime != null">
  364. AND o.create_time >= #{startTime}
  365. </if>
  366. <if test="endTime != null">
  367. AND #{endTime} >= o.create_time
  368. </if>
  369. <if test="payStatus != null">
  370. AND o.pay_status = #{payStatus}
  371. </if>
  372. <if test="goodsPayStatus != null">
  373. AND og.pay_status = #{goodsPayStatus}
  374. </if>
  375. <if test="refundStatus != null">
  376. AND og.refund_status = #{refundStatus}
  377. </if>
  378. AND g.goods_type = 1
  379. <if test="userId != null">
  380. AND u.user_id = #{userId}
  381. AND og.pay_status in (2,3,4)
  382. </if>
  383. <if test="inputOrderSn != null">
  384. AND o.input_order_sn = #{inputOrderSn}
  385. </if>
  386. <if test="searchKey != null and searchKey != ''">
  387. AND (u.realname like concat('%', #{searchKey}, '%') or o.order_sn = #{searchKey} or u.id_card = #{searchKey} or g.goods_name like concat('%', #{searchKey}, '%'))
  388. </if>
  389. <if test="orderGoodsIds != null ">
  390. AND og.order_goods_id in
  391. <foreach collection="orderGoodsIds" item="item" index="index" open="(" close=")" separator=",">
  392. #{item}
  393. </foreach>
  394. </if>
  395. <if test="orderFroms != null ">
  396. AND o.order_from in
  397. <foreach collection="orderFroms" item="item" index="index" open="(" close=")" separator=",">
  398. #{item}
  399. </foreach>
  400. </if>
  401. ORDER BY o.order_id DESC
  402. </select>
  403. <select id="selectUserClass" parameterType="map" resultType="integer">
  404. SELECT
  405. COUNT(cg.grade_id)
  406. FROM
  407. class_grade_goods cgg
  408. LEFT JOIN class_grade_user cgu ON cgu.grade_id = cgg.grade_id
  409. LEFT JOIN class_grade cg ON cg.grade_id = cgg.grade_id
  410. WHERE cgg.goods_id =#{goodsId}
  411. and cgu.user_id=#{userId}
  412. and cg.`status` =1
  413. </select>
  414. <select id="selectListApp" parameterType="com.zhongzheng.modules.order.bo.OrderQueryBo" resultMap="OrderResultVo">
  415. SELECT
  416. o.*
  417. FROM
  418. `order` o
  419. where 1=1
  420. <if test="userId != null">
  421. AND o.user_id = #{userId}
  422. </if>
  423. <if test="orderStatus != null">
  424. AND o.order_status in
  425. <foreach collection="orderStatus" item="item" index="index" open="(" close=")" separator=",">
  426. #{item}
  427. </foreach>
  428. </if>
  429. <if test="status != null">
  430. AND o.status in
  431. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  432. #{item}
  433. </foreach>
  434. </if>
  435. <if test="startTime != null">
  436. AND o.create_time >= #{startTime}
  437. </if>
  438. ORDER BY o.order_id DESC
  439. </select>
  440. <select id="queryByOrderSn" parameterType="String" resultType="Integer">
  441. SELECT order_status from `order` where order_sn = #{orderSn}
  442. </select>
  443. <select id="getConsoleStudentNum" parameterType="com.zhongzheng.modules.base.bo.ConsoleQueryBo" resultType="Integer">
  444. SELECT
  445. count( DISTINCT o.user_id )
  446. FROM
  447. `order` o
  448. LEFT JOIN order_goods og ON o.order_sn = og.order_sn
  449. LEFT JOIN goods g ON og.goods_id = g.goods_id
  450. WHERE
  451. og.pay_status IN ( 2, 3, 4 )
  452. AND og.refund_status != 2
  453. <if test="businessId != null">
  454. AND g.business_id = #{businessId}
  455. </if>
  456. <if test="startTime != null">
  457. AND og.create_time >= #{startTime}
  458. </if>
  459. <if test="endTime != null">
  460. AND #{endTime} >= og.create_time
  461. </if>
  462. </select>
  463. <select id="getConsoleInfoUpdateNum" parameterType="com.zhongzheng.modules.base.bo.ConsoleQueryBo" resultType="Integer">
  464. SELECT
  465. count( DISTINCT uu.id )
  466. FROM
  467. `order` o
  468. LEFT JOIN order_goods og ON o.order_sn = og.order_sn
  469. LEFT JOIN goods g ON og.goods_id = g.goods_id
  470. LEFT JOIN user_update uu on o.user_id = uu.user_id
  471. WHERE
  472. og.pay_status IN ( 2, 3, 4 )
  473. AND og.refund_status != 2
  474. <if test="businessId != null">
  475. AND g.business_id = #{businessId}
  476. </if>
  477. <if test="startTime != null">
  478. AND uu.create_time >= #{startTime}
  479. </if>
  480. <if test="endTime != null">
  481. AND #{endTime} >= uu.create_time
  482. </if>
  483. </select>
  484. <select id="getConsoleOrder" parameterType="com.zhongzheng.modules.base.bo.ConsoleQueryBo" resultMap="OrderResultVo">
  485. SELECT
  486. o.order_from,g.goods_type
  487. FROM
  488. `order` o
  489. LEFT JOIN order_goods og ON o.order_sn = og.order_sn
  490. LEFT JOIN goods g ON og.goods_id = g.goods_id
  491. WHERE 1 = 1
  492. <!-- og.pay_status IN ( 2, 3, 4 )
  493. AND og.refund_status != 2 -->
  494. <if test="businessId != null">
  495. AND g.business_id = #{businessId}
  496. </if>
  497. <if test="startTime != null">
  498. AND og.create_time >= #{startTime}
  499. </if>
  500. <if test="endTime != null">
  501. AND #{endTime} >= og.create_time
  502. </if>
  503. </select>
  504. <select id="getConsoleRebuyNum" parameterType="com.zhongzheng.modules.base.bo.ConsoleQueryBo" resultType="Integer">
  505. SELECT
  506. COUNT(og.order_goods_id)
  507. FROM
  508. `order` o
  509. LEFT JOIN order_goods og ON o.order_sn = og.order_sn
  510. LEFT JOIN goods g ON og.goods_id = g.goods_id
  511. LEFT JOIN order_goods og2 ON og.rebuy_order_goods_id = og2.order_goods_id
  512. LEFT JOIN class_grade_user cgu on cgu.grade_id = og2.grade_id and cgu.user_id = o.user_id and cgu.order_goods_id = og.order_goods_id
  513. WHERE 1=1
  514. AND og.pay_status IN ( 2, 3, 4 )
  515. AND og.rebuy_order_goods_id >0
  516. AND cgu.period_plush = 1
  517. <if test="businessId != null">
  518. AND g.business_id = #{businessId}
  519. </if>
  520. <if test="startTime != null">
  521. AND og.create_time >= #{startTime}
  522. </if>
  523. <if test="endTime != null">
  524. AND #{endTime} >= og.create_time
  525. </if>
  526. </select>
  527. <select id="queryDetailByOrderSn" parameterType="String" resultMap="OrderResultVo">
  528. SELECT * from `order` where order_sn = #{orderSn}
  529. </select>
  530. <select id="getUserGoods" resultType="java.lang.Long" parameterType="java.lang.Long">
  531. SELECT DISTINCT og.goods_id
  532. FROM `order` o
  533. LEFT JOIN order_goods og ON o.order_sn = og.order_sn
  534. WHERE o.user_id = #{userId}
  535. and o.order_status = 1
  536. and o.pay_status in (2,3)
  537. and og.status = 1
  538. </select>
  539. <select id="queryBusinessFullNameBySn" resultType="java.lang.String" parameterType="java.lang.String">
  540. SELECT DISTINCT
  541. CONCAT( cet.education_name, cb.business_name, cpt.project_name ) AS business_name
  542. FROM
  543. order_goods og
  544. INNER JOIN goods g ON og.goods_id = g.goods_id
  545. INNER JOIN course_education_type cet ON g.education_type_id = cet.id
  546. INNER JOIN course_project_type cpt ON g.project_id = cpt.id
  547. INNER JOIN course_business cb ON g.business_id = cb.id
  548. AND og.order_sn = #{orderSn}
  549. AND og.`status` = 1
  550. AND og.pay_status IN (2,3,4)
  551. </select>
  552. <select id="getSevenGrade" resultType="com.zhongzheng.modules.grade.domain.ClassGrade" parameterType="java.lang.Long">
  553. SELECT cg.* FROM class_grade cg
  554. WHERE cg.`status` = 1 AND (
  555. (SELECT COUNT(DISTINCT cgu.user_id) FROM class_grade_user cgu WHERE cgu.grade_id = cg.grade_id AND cgu.`status` = 1 AND cgu.change_grade = 0) +
  556. (SELECT COUNT(DISTINCT cgut.user_id) FROM class_grade_user_temp cgut WHERE cgut.grade_id = cg.grade_id AND cgut.`status` = 1 )
  557. ) <![CDATA[ < ]]> cg.student_upper AND cg.grade_id IN
  558. <foreach collection="gradeIds" item="item" index="index" open="(" close=")" separator=",">
  559. #{item}
  560. </foreach>
  561. LIMIT 1
  562. </select>
  563. <select id="getSevenGradeNoTenant" resultType="com.zhongzheng.modules.grade.domain.ClassGrade" parameterType="java.lang.Long">
  564. SELECT cg.* FROM class_grade cg
  565. WHERE cg.`status` = 1 AND (
  566. (SELECT COUNT(DISTINCT cgu.user_id) FROM class_grade_user cgu WHERE cgu.grade_id = cg.grade_id AND cgu.`status` = 1 AND cgu.change_grade = 0) +
  567. (SELECT COUNT(DISTINCT cgut.user_id) FROM class_grade_user_temp cgut WHERE cgut.grade_id = cg.grade_id AND cgut.`status` = 1 )
  568. ) <![CDATA[ < ]]> cg.student_upper AND cg.grade_id IN
  569. <foreach collection="gradeIds" item="item" index="index" open="(" close=")" separator=",">
  570. #{item}
  571. </foreach>
  572. LIMIT 1
  573. </select>
  574. <select id="getStudeCountByCode" resultType="java.lang.Integer" parameterType="java.lang.String">
  575. SELECT SUM(
  576. (SELECT COUNT(DISTINCT cgu.user_id) FROM class_grade_user cgu WHERE cgu.grade_id = cg.grade_id AND cgu.`status` = 1 AND cgu.change_grade = 0) +
  577. (SELECT COUNT(DISTINCT cgut.user_id) FROM class_grade_user_temp cgut WHERE cgut.grade_id = cg.grade_id AND cgut.`status` = 1 )
  578. ) as num FROM class_grade cg
  579. WHERE cg.`status` = 1 AND cg.seven_code = #{sevenCode}
  580. </select>
  581. <select id="getStudeCountByCodeNoTenant" resultType="java.lang.Integer" parameterType="java.lang.String">
  582. SELECT SUM(
  583. (SELECT COUNT(DISTINCT cgu.user_id) FROM class_grade_user cgu WHERE cgu.grade_id = cg.grade_id AND cgu.`status` = 1 AND cgu.change_grade = 0) +
  584. (SELECT COUNT(DISTINCT cgut.user_id) FROM class_grade_user_temp cgut WHERE cgut.grade_id = cg.grade_id AND cgut.`status` = 1 )
  585. ) as num FROM class_grade cg
  586. WHERE cg.`status` = 1 AND cg.seven_code = #{sevenCode}
  587. </select>
  588. <select id="getOrderInvoiceList" resultType="com.zhongzheng.modules.top.goods.vo.TopOldOrderInvoiceVo" parameterType="java.lang.String">
  589. SELECT
  590. tnm.create_time as applyUpTime,
  591. tnm.`status` as invoiceStatus,
  592. tnm.update_time as invoiceTime,
  593. tnm.oss_pdf_url as ossPdfUrl,
  594. tnm.content
  595. FROM
  596. order_goods og
  597. LEFT JOIN order_invoice_order oio ON og.order_goods_id = oio.order_goods_id
  598. LEFT JOIN order_invoice oi ON oio.invoice_id = oi.invoice_id
  599. LEFT JOIN top_nuo_mplatform_log tnm ON oi.serial_number = tnm.order_no
  600. WHERE og.order_sn = #{orderSn}
  601. </select>
  602. <select id="getClassNameByGoods" resultType="com.zhongzheng.modules.grade.domain.ClassGrade" parameterType="java.lang.Long">
  603. SELECT
  604. cg.*
  605. FROM
  606. class_grade cg
  607. LEFT JOIN class_grade_goods cgg ON cg.grade_id = cgg.grade_id
  608. LEFT JOIN goods g ON cgg.goods_id = g.goods_id
  609. WHERE
  610. cg.`status` = 1
  611. AND g.education_type_id = #{educationTypeId}
  612. AND g.project_id = #{projectId}
  613. AND g.business_id = #{businessId}
  614. AND major_id = #{majorId}
  615. AND (
  616. (
  617. SELECT
  618. COUNT( DISTINCT cgu.user_id )
  619. FROM
  620. class_grade_user cgu
  621. WHERE
  622. cgu.grade_id = cg.grade_id
  623. AND cgu.`status` = 1
  624. AND cgu.change_grade = 0
  625. ) + ( SELECT COUNT( DISTINCT cgut.user_id ) FROM class_grade_user_temp cgut WHERE cgut.grade_id = cg.grade_id AND cgut.`status` = 1 )
  626. ) <![CDATA[ < ]]> cg.student_upper
  627. </select>
  628. <select id="getClassNameByGoodsNotTenant" resultType="com.zhongzheng.modules.grade.domain.ClassGrade" parameterType="java.lang.Long">
  629. SELECT
  630. cg.*
  631. FROM
  632. class_grade cg
  633. LEFT JOIN class_grade_goods cgg ON cg.grade_id = cgg.grade_id
  634. LEFT JOIN goods g ON cgg.goods_id = g.goods_id
  635. WHERE
  636. cg.`status` = 1
  637. AND g.education_type_id = #{educationTypeId}
  638. AND g.project_id = #{projectId}
  639. AND g.business_id = #{businessId}
  640. AND major_id = #{majorId}
  641. AND (
  642. (
  643. SELECT
  644. COUNT( DISTINCT cgu.user_id )
  645. FROM
  646. class_grade_user cgu
  647. WHERE
  648. cgu.grade_id = cg.grade_id
  649. AND cgu.`status` = 1
  650. AND cgu.change_grade = 0
  651. ) + ( SELECT COUNT( DISTINCT cgut.user_id ) FROM class_grade_user_temp cgut WHERE cgut.grade_id = cg.grade_id AND cgut.`status` = 1 )
  652. ) <![CDATA[ < ]]> cg.student_upper
  653. </select>
  654. <select id="getBusinessNameBySn" resultType="java.lang.String" parameterType="java.lang.String">
  655. SELECT
  656. CONCAT( cet.education_name, '-', cb.business_name, cpt.project_name ) AS business_name
  657. FROM
  658. order_goods og
  659. LEFT JOIN goods g ON og.goods_id = g.goods_id
  660. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  661. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  662. LEFT JOIN course_business cb ON g.business_id = cb.id
  663. WHERE
  664. og.`status` = 1
  665. AND og.order_sn = #{orderSn}
  666. </select>
  667. </mapper>