OrderMapper.xml 55 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296
  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. <result property="handleOrderSn" column="handle_order_sn"/>
  29. </resultMap>
  30. <resultMap type="com.zhongzheng.modules.order.vo.OrderListVo" id="OrderResultVo">
  31. <result property="orderId" column="order_id"/>
  32. <result property="orderSn" column="order_sn"/>
  33. <result property="userId" column="user_id"/>
  34. <result property="orderPrice" column="order_price"/>
  35. <result property="orderGeneral" column="order_general"/>
  36. <result property="orderStatus" column="order_status"/>
  37. <result property="createTime" column="create_time"/>
  38. <result property="payTime" column="pay_time"/>
  39. <result property="payType" column="pay_type"/>
  40. <result property="transid" column="transid"/>
  41. <result property="cancelTime" column="cancel_time"/>
  42. <result property="finishTime" column="finish_time"/>
  43. <result property="orderType" column="order_type"/>
  44. <result property="payPrice" column="pay_price"/>
  45. <result property="chargingType" column="charging_type"/>
  46. <result property="orderFrom" column="order_from"/>
  47. <result property="status" column="status"/>
  48. <result property="periodStatus" column="period_status"/>
  49. <result property="goodsName" column="goods_name"/>
  50. <result property="goodsId" column="goods_id"/>
  51. <result property="year" column="year"/>
  52. <result property="coverUrl" column="cover_url"/>
  53. <result property="code" column="code"/>
  54. <result property="rebuyOrderGoodsId" column="rebuy_order_goods_id"/>
  55. <result property="educationName" column="education_name"/>
  56. <result property="projectName" column="project_name"/>
  57. <result property="businessName" column="business_name"/>
  58. <result property="schoolName" column="school_name"/>
  59. <result property="categoryName" column="category_name"/>
  60. <result property="goodsPrice" column="goods_price"/>
  61. <result property="goodsRealPrice" column="goods_real_price"/>
  62. <result property="idCard" column="id_card" typeHandler="com.zhongzheng.common.type.EncryptHandler"/>
  63. <result property="telphone" column="telphone" typeHandler="com.zhongzheng.common.type.EncryptHandler"/>
  64. <result property="realname" column="realname"/>
  65. <result property="companyName" column="company_name"/>
  66. <result property="goodsReceived" column="goods_received"/>
  67. <result property="refundStatus" column="refund_status"/>
  68. <result property="payStatus" column="pay_status"/>
  69. <result property="orderGoodsId" column="order_goods_id"/>
  70. <result property="periodPlush" column="period_plush"/>
  71. <result property="goodsPayStatus" column="goods_pay_status"/>
  72. <result property="goodsType" column="goods_type"/>
  73. <result property="invoiceStatus" column="invoice_status"/>
  74. <result property="serviceStartTime" column="service_start_time"/>
  75. <result property="serviceEndTime" column="service_end_time"/>
  76. <result property="handleOrderSn" column="handle_order_sn"/>
  77. <result property="offlineRefundSign" column="offline_refund_sign"/>
  78. </resultMap>
  79. <select id="getGradePeriod" parameterType="Map" resultType="integer">
  80. SELECT
  81. cgu.period_plush
  82. FROM
  83. order_goods og
  84. LEFT JOIN class_grade_user cgu ON og.order_goods_id = cgu.order_goods_id
  85. AND cgu.user_id = #{userId} where og.order_goods_id = #{orderGoodsId}
  86. AND cgu.`status` = 1 limit 1
  87. </select>
  88. <select id="selectListByBo" parameterType="com.zhongzheng.modules.order.bo.OrderQueryBo" resultMap="OrderResultVo">
  89. SELECT
  90. o.*,
  91. g.goods_id,
  92. g.goods_name,
  93. g.year,
  94. g.cover_url,
  95. g.code,
  96. g.goods_type,
  97. og.goods_price,
  98. og.rebuy_order_goods_id,
  99. og.order_goods_id,
  100. og.goods_real_price,
  101. og.offline_refund_sign,
  102. u.telphone,
  103. u.realname,
  104. u.id_card,
  105. u.company_name,
  106. cet.education_name,
  107. cpt.project_name,
  108. cb.business_name,
  109. s.school_name,
  110. m.category_name,
  111. og.goods_received,
  112. og.refund_status,
  113. og.pay_status as goods_pay_status,
  114. (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,
  115. (SELECT oi.invoice_status FROM order_invoice oi LEFT JOIN order_invoice_order oio ON oio.invoice_id = oi.invoice_id WHERE
  116. oio.order_goods_id = og.order_goods_id AND oi.period_status != 2 limit 1) invoice_status
  117. FROM
  118. `order` o
  119. LEFT JOIN order_goods og ON o.order_sn = og.order_sn
  120. LEFT JOIN goods g ON og.goods_id = g.goods_id
  121. LEFT JOIN `user` u ON o.user_id = u.user_id
  122. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  123. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  124. LEFT JOIN course_business cb ON g.business_id = cb.id
  125. LEFT JOIN school s ON s.id = g.school_id
  126. LEFT JOIN major m ON g.major_id = m.id
  127. WHERE 1=1
  128. <if test="educationTypeId != null and educationTypeId != ''">
  129. AND g.education_type_id = #{educationTypeId}
  130. </if>
  131. <if test="businessId != null and businessId != ''">
  132. AND g.business_id = #{businessId}
  133. </if>
  134. <if test="schoolId != null and schoolId != ''">
  135. AND g.school_id = #{schoolId}
  136. </if>
  137. <if test="majorId != null and majorId != ''">
  138. AND g.major_id = #{majorId}
  139. </if>
  140. <if test="orderSn != null and orderSn != ''">
  141. AND o.order_sn = #{orderSn}
  142. </if>
  143. <if test="orderStatus != null ">
  144. AND o.order_status in
  145. <foreach collection="orderStatus" item="item" index="index" open="(" close=")" separator=",">
  146. #{item}
  147. </foreach>
  148. </if>
  149. <if test="status != null ">
  150. AND o.status in
  151. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  152. #{item}
  153. </foreach>
  154. </if>
  155. <if test="orderGoodsStatus == 1">
  156. AND og.pay_status in (2,3,4) AND og.refund_status != 2
  157. </if>
  158. <if test="startTime != null">
  159. AND o.create_time >= #{startTime}
  160. </if>
  161. <if test="endTime != null">
  162. AND #{endTime} >= o.create_time
  163. </if>
  164. <if test="payStatus != null">
  165. AND o.pay_status = #{payStatus}
  166. </if>
  167. <if test="goodsPayStatus != null">
  168. AND og.pay_status = #{goodsPayStatus}
  169. </if>
  170. <if test="refundStatus != null">
  171. AND og.refund_status = #{refundStatus}
  172. </if>
  173. <if test="goodsType != null">
  174. AND g.goods_type = #{goodsType}
  175. </if>
  176. <if test="userId != null">
  177. AND u.user_id = #{userId}
  178. AND og.pay_status in (2,3,4)
  179. </if>
  180. <if test="inputOrderSn != null">
  181. AND o.input_order_sn = #{inputOrderSn}
  182. </if>
  183. <if test="companyName != null and companyName != ''">
  184. AND u.company_name like concat('%', #{companyName}, '%')
  185. </if>
  186. <if test="searchKey != null and searchKey != ''">
  187. AND (u.realname like concat('%', #{searchKey}, '%') or o.order_sn = #{searchKey} or u.id_card = #{searchKey} or g.goods_name like concat('%', #{searchKey}, '%'))
  188. </if>
  189. <if test="orderGoodsIds != null ">
  190. AND og.order_goods_id in
  191. <foreach collection="orderGoodsIds" item="item" index="index" open="(" close=")" separator=",">
  192. #{item}
  193. </foreach>
  194. </if>
  195. <if test="orderFroms != null and orderFroms.size()!=0">
  196. AND o.order_from in
  197. <foreach collection="orderFroms" item="item" index="index" open="(" close=")" separator=",">
  198. #{item}
  199. </foreach>
  200. </if>
  201. ORDER BY o.order_id DESC
  202. </select>
  203. <select id="selectDangAnOrderList" parameterType="com.zhongzheng.modules.order.bo.OrderQueryBo" resultMap="OrderResultVo">
  204. SELECT
  205. o.*,
  206. g.goods_id,
  207. g.goods_name,
  208. g.year,
  209. g.cover_url,
  210. g.code,
  211. g.goods_type,
  212. og.goods_price,
  213. og.rebuy_order_goods_id,
  214. og.order_goods_id,
  215. og.goods_real_price,
  216. u.telphone,
  217. u.realname,
  218. u.id_card,
  219. cet.education_name,
  220. cpt.project_name,
  221. cb.business_name,
  222. og.goods_received,
  223. og.refund_status,
  224. og.pay_status as goods_pay_status,
  225. og.service_start_time,
  226. og.service_end_time
  227. FROM
  228. `order` o
  229. LEFT JOIN order_goods og ON o.order_sn = og.order_sn
  230. LEFT JOIN goods g ON og.goods_id = g.goods_id
  231. LEFT JOIN `user` u ON o.user_id = u.user_id
  232. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  233. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  234. LEFT JOIN course_business cb ON g.business_id = cb.id
  235. WHERE 1=1
  236. <if test="educationTypeId != null and educationTypeId != ''">
  237. AND g.education_type_id = #{educationTypeId}
  238. </if>
  239. <if test="businessId != null and businessId != ''">
  240. AND g.business_id = #{businessId}
  241. </if>
  242. <if test="orderSn != null and orderSn != ''">
  243. AND o.order_sn = #{orderSn}
  244. </if>
  245. <if test="orderStatus != null ">
  246. AND o.order_status in
  247. <foreach collection="orderStatus" item="item" index="index" open="(" close=")" separator=",">
  248. #{item}
  249. </foreach>
  250. </if>
  251. <if test="status != null ">
  252. AND o.status in
  253. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  254. #{item}
  255. </foreach>
  256. </if>
  257. <if test="orderGoodsStatus == 1">
  258. AND og.pay_status in (2,3,4) AND og.refund_status != 2
  259. </if>
  260. <if test="startTime != null">
  261. AND o.create_time >= #{startTime}
  262. </if>
  263. <if test="endTime != null">
  264. AND #{endTime} >= o.create_time
  265. </if>
  266. <if test="payStatus != null">
  267. AND o.pay_status = #{payStatus}
  268. </if>
  269. <if test="goodsPayStatus != null">
  270. AND og.pay_status = #{goodsPayStatus}
  271. </if>
  272. <if test="refundStatus != null">
  273. AND og.refund_status = #{refundStatus}
  274. </if>
  275. <if test="goodsType != null">
  276. AND g.goods_type = #{goodsType}
  277. </if>
  278. <if test="userId != null">
  279. AND u.user_id = #{userId}
  280. </if>
  281. <if test="inputOrderSn != null">
  282. AND o.input_order_sn = #{inputOrderSn}
  283. </if>
  284. <if test="searchKey != null and searchKey != ''">
  285. AND (u.realname like concat('%', #{searchKey}, '%') or o.order_sn = #{searchKey} or u.id_card = #{searchKey} or g.goods_name like concat('%', #{searchKey}, '%'))
  286. </if>
  287. <if test="orderGoodsIds != null ">
  288. AND og.order_goods_id in
  289. <foreach collection="orderGoodsIds" item="item" index="index" open="(" close=")" separator=",">
  290. #{item}
  291. </foreach>
  292. </if>
  293. <if test="orderFroms != null ">
  294. AND o.order_from in
  295. <foreach collection="orderFroms" item="item" index="index" open="(" close=")" separator=",">
  296. #{item}
  297. </foreach>
  298. </if>
  299. ORDER BY o.order_id DESC
  300. </select>
  301. <select id="selectRebuyList" parameterType="com.zhongzheng.modules.order.bo.OrderQueryBo" resultMap="OrderResultVo">
  302. SELECT
  303. o.*,
  304. g.goods_id,
  305. g.goods_name,
  306. g.year,
  307. g.cover_url,
  308. g.code,
  309. g.goods_type,
  310. og.goods_price,
  311. og.rebuy_order_goods_id,
  312. og.order_goods_id,
  313. og.goods_real_price,
  314. u.telphone,
  315. u.realname,
  316. u.id_card,
  317. cet.education_name,
  318. cpt.project_name,
  319. cb.business_name,
  320. s.school_name,
  321. m.category_name,
  322. og.goods_received,
  323. og.refund_status,
  324. og.pay_status as goods_pay_status,
  325. cgu.period_plush,
  326. (SELECT oi.invoice_status FROM order_invoice oi LEFT JOIN order_invoice_order oio ON oio.invoice_id = oi.invoice_id WHERE
  327. oio.order_goods_id = og.order_goods_id AND oi.period_status != 2 limit 1) invoice_status
  328. FROM
  329. `order` o
  330. LEFT JOIN order_goods og ON o.order_sn = og.order_sn
  331. LEFT JOIN goods g ON og.goods_id = g.goods_id
  332. LEFT JOIN `user` u ON o.user_id = u.user_id
  333. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  334. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  335. LEFT JOIN course_business cb ON g.business_id = cb.id
  336. LEFT JOIN school s ON s.id = g.school_id
  337. LEFT JOIN major m ON g.major_id = m.id
  338. LEFT JOIN order_goods og2 ON og.rebuy_order_goods_id = og2.order_goods_id
  339. 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
  340. WHERE 1=1
  341. AND og.rebuy_order_goods_id >0
  342. AND cgu.period_plush = 1
  343. <if test="educationTypeId != null and educationTypeId != ''">
  344. AND g.education_type_id = #{educationTypeId}
  345. </if>
  346. <if test="businessId != null and businessId != ''">
  347. AND g.business_id = #{businessId}
  348. </if>
  349. <if test="schoolId != null and schoolId != ''">
  350. AND g.school_id = #{schoolId}
  351. </if>
  352. <if test="majorId != null and majorId != ''">
  353. AND g.major_id = #{majorId}
  354. </if>
  355. <if test="orderSn != null and orderSn != ''">
  356. AND o.order_sn = #{orderSn}
  357. </if>
  358. <if test="orderStatus != null ">
  359. AND o.order_status in
  360. <foreach collection="orderStatus" item="item" index="index" open="(" close=")" separator=",">
  361. #{item}
  362. </foreach>
  363. </if>
  364. <if test="status != null ">
  365. AND o.status in
  366. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  367. #{item}
  368. </foreach>
  369. </if>
  370. <if test="startTime != null">
  371. AND o.create_time >= #{startTime}
  372. </if>
  373. <if test="endTime != null">
  374. AND #{endTime} >= o.create_time
  375. </if>
  376. <if test="payStatus != null">
  377. AND o.pay_status = #{payStatus}
  378. </if>
  379. <if test="goodsPayStatus != null">
  380. AND og.pay_status = #{goodsPayStatus}
  381. </if>
  382. <if test="refundStatus != null">
  383. AND og.refund_status = #{refundStatus}
  384. </if>
  385. AND g.goods_type = 1
  386. <if test="userId != null">
  387. AND u.user_id = #{userId}
  388. AND og.pay_status in (2,3,4)
  389. </if>
  390. <if test="inputOrderSn != null">
  391. AND o.input_order_sn = #{inputOrderSn}
  392. </if>
  393. <if test="searchKey != null and searchKey != ''">
  394. AND (u.realname like concat('%', #{searchKey}, '%') or o.order_sn = #{searchKey} or u.id_card = #{searchKey} or g.goods_name like concat('%', #{searchKey}, '%'))
  395. </if>
  396. <if test="orderGoodsIds != null ">
  397. AND og.order_goods_id in
  398. <foreach collection="orderGoodsIds" item="item" index="index" open="(" close=")" separator=",">
  399. #{item}
  400. </foreach>
  401. </if>
  402. <if test="orderFroms != null ">
  403. AND o.order_from in
  404. <foreach collection="orderFroms" item="item" index="index" open="(" close=")" separator=",">
  405. #{item}
  406. </foreach>
  407. </if>
  408. ORDER BY o.order_id DESC
  409. </select>
  410. <select id="selectUserClass" parameterType="map" resultType="integer">
  411. SELECT
  412. COUNT(cg.grade_id)
  413. FROM
  414. class_grade_goods cgg
  415. LEFT JOIN class_grade_user cgu ON cgu.grade_id = cgg.grade_id
  416. LEFT JOIN class_grade cg ON cg.grade_id = cgg.grade_id
  417. WHERE cgg.goods_id =#{goodsId}
  418. and cgu.user_id=#{userId}
  419. and cg.`status` =1
  420. </select>
  421. <select id="selectListApp" parameterType="com.zhongzheng.modules.order.bo.OrderQueryBo" resultMap="OrderResultVo">
  422. SELECT
  423. o.*
  424. FROM
  425. `order` o
  426. where 1=1
  427. <if test="userId != null">
  428. AND o.user_id = #{userId}
  429. </if>
  430. <if test="orderStatus != null">
  431. AND o.order_status in
  432. <foreach collection="orderStatus" item="item" index="index" open="(" close=")" separator=",">
  433. #{item}
  434. </foreach>
  435. </if>
  436. <if test="status != null">
  437. AND o.status in
  438. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  439. #{item}
  440. </foreach>
  441. </if>
  442. <if test="startTime != null">
  443. AND o.create_time >= #{startTime}
  444. </if>
  445. ORDER BY o.order_id DESC
  446. </select>
  447. <select id="queryByOrderSn" parameterType="String" resultType="Integer">
  448. SELECT order_status from `order` where order_sn = #{orderSn}
  449. </select>
  450. <select id="getConsoleStudentNum" parameterType="com.zhongzheng.modules.base.bo.ConsoleQueryBo" resultType="Integer">
  451. SELECT
  452. count( DISTINCT o.user_id )
  453. FROM
  454. `order` o
  455. LEFT JOIN order_goods og ON o.order_sn = og.order_sn
  456. LEFT JOIN goods g ON og.goods_id = g.goods_id
  457. WHERE
  458. og.pay_status IN ( 2, 3, 4 )
  459. AND og.refund_status != 2
  460. <if test="businessId != null">
  461. AND g.business_id = #{businessId}
  462. </if>
  463. <if test="startTime != null">
  464. AND og.create_time >= #{startTime}
  465. </if>
  466. <if test="endTime != null">
  467. AND #{endTime} >= og.create_time
  468. </if>
  469. </select>
  470. <select id="getConsoleInfoUpdateNum" parameterType="com.zhongzheng.modules.base.bo.ConsoleQueryBo" resultType="Integer">
  471. SELECT
  472. count( DISTINCT uu.id )
  473. FROM
  474. `order` o
  475. LEFT JOIN order_goods og ON o.order_sn = og.order_sn
  476. LEFT JOIN goods g ON og.goods_id = g.goods_id
  477. LEFT JOIN user_update uu on o.user_id = uu.user_id
  478. WHERE
  479. og.pay_status IN ( 2, 3, 4 )
  480. AND og.refund_status != 2
  481. <if test="businessId != null">
  482. AND g.business_id = #{businessId}
  483. </if>
  484. <if test="startTime != null">
  485. AND uu.create_time >= #{startTime}
  486. </if>
  487. <if test="endTime != null">
  488. AND #{endTime} >= uu.create_time
  489. </if>
  490. </select>
  491. <select id="getConsoleOrder" parameterType="com.zhongzheng.modules.base.bo.ConsoleQueryBo" resultMap="OrderResultVo">
  492. SELECT
  493. o.order_from,g.goods_type
  494. FROM
  495. `order` o
  496. LEFT JOIN order_goods og ON o.order_sn = og.order_sn
  497. LEFT JOIN goods g ON og.goods_id = g.goods_id
  498. WHERE 1 = 1
  499. <!-- og.pay_status IN ( 2, 3, 4 )
  500. AND og.refund_status != 2 -->
  501. <if test="businessId != null">
  502. AND g.business_id = #{businessId}
  503. </if>
  504. <if test="startTime != null">
  505. AND og.create_time >= #{startTime}
  506. </if>
  507. <if test="endTime != null">
  508. AND #{endTime} >= og.create_time
  509. </if>
  510. </select>
  511. <select id="getConsoleRebuyNum" parameterType="com.zhongzheng.modules.base.bo.ConsoleQueryBo" resultType="Integer">
  512. SELECT
  513. COUNT(og.order_goods_id)
  514. FROM
  515. `order` o
  516. LEFT JOIN order_goods og ON o.order_sn = og.order_sn
  517. LEFT JOIN goods g ON og.goods_id = g.goods_id
  518. LEFT JOIN order_goods og2 ON og.rebuy_order_goods_id = og2.order_goods_id
  519. 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
  520. WHERE 1=1
  521. AND og.pay_status IN ( 2, 3, 4 )
  522. AND og.rebuy_order_goods_id >0
  523. AND cgu.period_plush = 1
  524. <if test="businessId != null">
  525. AND g.business_id = #{businessId}
  526. </if>
  527. <if test="startTime != null">
  528. AND og.create_time >= #{startTime}
  529. </if>
  530. <if test="endTime != null">
  531. AND #{endTime} >= og.create_time
  532. </if>
  533. </select>
  534. <select id="queryDetailByOrderSn" parameterType="String" resultMap="OrderResultVo">
  535. SELECT * from `order` where order_sn = #{orderSn}
  536. </select>
  537. <select id="getUserGoods" resultType="java.lang.Long" parameterType="java.lang.Long">
  538. SELECT DISTINCT og.goods_id
  539. FROM `order` o
  540. LEFT JOIN order_goods og ON o.order_sn = og.order_sn
  541. WHERE o.user_id = #{userId}
  542. and o.order_status = 1
  543. and o.pay_status in (2,3)
  544. and og.status = 1
  545. </select>
  546. <select id="queryBusinessFullNameBySn" resultType="java.lang.String" parameterType="java.lang.String">
  547. SELECT DISTINCT
  548. CONCAT( cet.education_name, cb.business_name, cpt.project_name ) AS business_name
  549. FROM
  550. order_goods og
  551. INNER JOIN goods g ON og.goods_id = g.goods_id
  552. INNER JOIN course_education_type cet ON g.education_type_id = cet.id
  553. INNER JOIN course_project_type cpt ON g.project_id = cpt.id
  554. INNER JOIN course_business cb ON g.business_id = cb.id
  555. AND og.order_sn = #{orderSn}
  556. AND og.`status` = 1
  557. AND og.pay_status IN (2,3,4)
  558. </select>
  559. <select id="getSevenGrade" resultType="com.zhongzheng.modules.grade.domain.ClassGrade" parameterType="java.lang.Long">
  560. SELECT cg.* FROM class_grade cg
  561. WHERE cg.`status` = 1 AND (
  562. (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) +
  563. (SELECT COUNT(DISTINCT cgut.user_id) FROM class_grade_user_temp cgut WHERE cgut.grade_id = cg.grade_id AND cgut.`status` = 1 )
  564. ) <![CDATA[ < ]]> cg.student_upper AND cg.grade_id IN
  565. <foreach collection="gradeIds" item="item" index="index" open="(" close=")" separator=",">
  566. #{item}
  567. </foreach>
  568. LIMIT 1
  569. </select>
  570. <select id="getSevenGradeNoTenant" resultType="com.zhongzheng.modules.grade.domain.ClassGrade" parameterType="java.lang.Long">
  571. SELECT cg.* FROM class_grade cg
  572. WHERE cg.`status` = 1 AND (
  573. (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) +
  574. (SELECT COUNT(DISTINCT cgut.user_id) FROM class_grade_user_temp cgut WHERE cgut.grade_id = cg.grade_id AND cgut.`status` = 1 )
  575. ) <![CDATA[ < ]]> cg.student_upper AND cg.grade_id IN
  576. <foreach collection="gradeIds" item="item" index="index" open="(" close=")" separator=",">
  577. #{item}
  578. </foreach>
  579. LIMIT 1
  580. </select>
  581. <select id="getStudeCountByCode" 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="getStudeCountByCodeNoTenant" resultType="java.lang.Integer" parameterType="java.lang.String">
  589. SELECT SUM(
  590. (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) +
  591. (SELECT COUNT(DISTINCT cgut.user_id) FROM class_grade_user_temp cgut WHERE cgut.grade_id = cg.grade_id AND cgut.`status` = 1 )
  592. ) as num FROM class_grade cg
  593. WHERE cg.`status` = 1 AND cg.seven_code = #{sevenCode}
  594. </select>
  595. <select id="getOrderInvoiceList" resultType="com.zhongzheng.modules.top.goods.vo.TopOldOrderInvoiceVo" parameterType="java.lang.String">
  596. SELECT
  597. tnm.create_time as applyUpTime,
  598. tnm.`status` as invoiceStatus,
  599. tnm.update_time as invoiceTime,
  600. tnm.oss_pdf_url as ossPdfUrl,
  601. tnm.content
  602. FROM
  603. order_goods og
  604. LEFT JOIN order_invoice_order oio ON og.order_goods_id = oio.order_goods_id
  605. LEFT JOIN order_invoice oi ON oio.invoice_id = oi.invoice_id
  606. LEFT JOIN top_nuo_mplatform_log tnm ON oi.serial_number = tnm.order_no
  607. WHERE og.order_sn = #{orderSn}
  608. </select>
  609. <select id="getClassNameByGoods" resultType="com.zhongzheng.modules.grade.domain.ClassGrade" parameterType="java.lang.Long">
  610. SELECT
  611. cg.*
  612. FROM
  613. class_grade cg
  614. LEFT JOIN class_grade_goods cgg ON cg.grade_id = cgg.grade_id
  615. LEFT JOIN goods g ON cgg.goods_id = g.goods_id
  616. WHERE
  617. cg.`status` = 1
  618. AND g.education_type_id = #{educationTypeId}
  619. AND g.project_id = #{projectId}
  620. AND g.business_id = #{businessId}
  621. AND major_id = #{majorId}
  622. AND (
  623. (
  624. SELECT
  625. COUNT( DISTINCT cgu.user_id )
  626. FROM
  627. class_grade_user cgu
  628. WHERE
  629. cgu.grade_id = cg.grade_id
  630. AND cgu.`status` = 1
  631. AND cgu.change_grade = 0
  632. ) + ( SELECT COUNT( DISTINCT cgut.user_id ) FROM class_grade_user_temp cgut WHERE cgut.grade_id = cg.grade_id AND cgut.`status` = 1 )
  633. ) <![CDATA[ < ]]> cg.student_upper
  634. </select>
  635. <select id="getClassNameByGoodsNotTenant" resultType="com.zhongzheng.modules.grade.domain.ClassGrade" parameterType="java.lang.Long">
  636. SELECT
  637. cg.*
  638. FROM
  639. class_grade cg
  640. LEFT JOIN class_grade_goods cgg ON cg.grade_id = cgg.grade_id
  641. LEFT JOIN goods g ON cgg.goods_id = g.goods_id
  642. WHERE
  643. cg.`status` = 1
  644. AND g.education_type_id = #{educationTypeId}
  645. AND g.project_id = #{projectId}
  646. AND g.business_id = #{businessId}
  647. AND major_id = #{majorId}
  648. AND (
  649. (
  650. SELECT
  651. COUNT( DISTINCT cgu.user_id )
  652. FROM
  653. class_grade_user cgu
  654. WHERE
  655. cgu.grade_id = cg.grade_id
  656. AND cgu.`status` = 1
  657. AND cgu.change_grade = 0
  658. ) + ( SELECT COUNT( DISTINCT cgut.user_id ) FROM class_grade_user_temp cgut WHERE cgut.grade_id = cg.grade_id AND cgut.`status` = 1 )
  659. ) <![CDATA[ < ]]> cg.student_upper
  660. </select>
  661. <select id="getBusinessNameBySn" resultType="java.lang.String" parameterType="java.lang.String">
  662. SELECT
  663. CONCAT( cet.education_name, '-', cb.business_name, cpt.project_name ) AS business_name
  664. FROM
  665. order_goods og
  666. LEFT JOIN goods g ON og.goods_id = g.goods_id
  667. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  668. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  669. LEFT JOIN course_business cb ON g.business_id = cb.id
  670. WHERE
  671. og.`status` = 1
  672. AND og.order_sn = #{orderSn}
  673. </select>
  674. <select id="getOrderGoodsByBo" resultType="java.lang.Long" parameterType="java.lang.Long">
  675. SELECT
  676. COUNT(*)
  677. FROM
  678. `order` o
  679. LEFT JOIN order_goods og ON o.order_sn = og.order_sn
  680. WHERE
  681. o.user_id = #{userId}
  682. AND og.goods_id = #{goodsId}
  683. AND og.pay_status != 1
  684. AND og.refund_status != 2
  685. AND UNIX_TIMESTAMP(
  686. NOW()) <![CDATA[ >= ]]> og.service_start_time
  687. AND UNIX_TIMESTAMP(
  688. NOW()) <![CDATA[ <= ]]> og.service_end_time
  689. </select>
  690. <select id="getCountByGoods" resultType="java.lang.Long" parameterType="java.lang.Long">
  691. SELECT
  692. COUNT(*)
  693. FROM
  694. goods g
  695. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  696. WHERE
  697. INSTR( cpt.project_name, '施工现场专业人员' )
  698. AND g.goods_id IN
  699. <foreach collection="goodsIds" item="item" index="index" open="(" close=")" separator=",">
  700. #{item}
  701. </foreach>
  702. </select>
  703. <!-- <select id="exportNew" resultType="com.zhongzheng.modules.order.vo.OrderExportNewVo"-->
  704. <!-- parameterType="com.zhongzheng.modules.order.bo.OrderExportNewBo">-->
  705. <!-- SELECT-->
  706. <!-- FROM_UNIXTIME( og.create_time, '%Y-%m-%d %H:%i:%s' ) AS orderTime,-->
  707. <!-- u.realname AS realname,-->
  708. <!-- AES_DECRYPT( UNHEX( u.id_card ), 'base20230213zzkj' ) AS idCard,-->
  709. <!-- AES_DECRYPT( UNHEX( u.telphone ), 'base20230213zzkj' ) AS telphone,-->
  710. <!-- u.company_name AS companyName,-->
  711. <!-- m.category_name AS majorName,-->
  712. <!-- g.seven_year AS goodsYear,-->
  713. <!-- CASE-->
  714. <!-- WHEN og.`status` = 1 THEN-->
  715. <!-- '否'-->
  716. <!-- WHEN og.`status` = 0 THEN-->
  717. <!-- '是' ELSE '其他'-->
  718. <!-- END AS orderStatus-->
  719. <!-- FROM-->
  720. <!-- order_goods og-->
  721. <!-- LEFT JOIN `order` o ON og.order_sn = o.order_sn-->
  722. <!-- LEFT JOIN `user` u ON o.user_id = u.user_id-->
  723. <!-- LEFT JOIN goods g ON og.goods_id = g.goods_id-->
  724. <!-- LEFT JOIN major m ON g.major_id = m.id-->
  725. <!-- WHERE-->
  726. <!-- og.refund_status != 2-->
  727. <!-- AND og.pay_status != 1-->
  728. <!-- <if test="orderSn != null and orderSn != ''">-->
  729. <!-- AND o.order_sn = #{orderSn}-->
  730. <!-- </if>-->
  731. <!-- <if test="orderStartTime != null and orderStartTime != ''">-->
  732. <!-- AND og.create_time <![CDATA[ >= ]]> #{orderStartTime}-->
  733. <!-- </if>-->
  734. <!-- <if test="orderEndTime != null and orderEndTime != ''">-->
  735. <!-- AND og.create_time <![CDATA[ <= ]]> #{orderEndTime}-->
  736. <!-- </if>-->
  737. <!-- <if test="educationTypeId != null and educationTypeId != ''">-->
  738. <!-- AND g.education_type_id = #{educationTypeId}-->
  739. <!-- </if>-->
  740. <!-- <if test="businessId != null and businessId != ''">-->
  741. <!-- AND g.business_id = #{businessId}-->
  742. <!-- </if>-->
  743. <!-- <if test="companyName != null and companyName != ''">-->
  744. <!-- AND u.company_name = #{companyName}-->
  745. <!-- </if>-->
  746. <!-- </select>-->
  747. <select id="exportNew" resultType="com.zhongzheng.modules.order.vo.OrderExportNewVo"
  748. parameterType="com.zhongzheng.modules.order.bo.OrderExportNewBo">
  749. SELECT
  750. o.order_sn,
  751. FROM_UNIXTIME( og.create_time, '%Y-%m-%d %H:%i:%s' ) AS orderTime,
  752. u.realname,
  753. AES_DECRYPT(UNHEX(u.id_card),'base20230213zzkj') AS idCard,
  754. AES_DECRYPT(UNHEX(u.telphone),'base20230213zzkj') AS telphone,
  755. u.company_name AS companyName,
  756. g.goods_name AS goodsName,
  757. g.seven_year AS sevenYear,
  758. CONCAT(cet.education_name,cb.business_name,cpt.project_name) AS businessName,
  759. m.category_name AS categoryName,
  760. cg.class_name AS className,
  761. CASE
  762. WHEN cg.class_status = 1 THEN '已开班'
  763. WHEN cg.class_status = 0 THEN '未开班'
  764. ELSE '其他' END AS classStatus,
  765. FROM_UNIXTIME( cg.class_end_time, '%Y-%m-%d %H:%i:%s' ) AS classEndTime,
  766. CASE
  767. WHEN o.order_status = 0 THEN '待支付'
  768. WHEN o.order_status = 1 THEN '已支付'
  769. WHEN o.order_status = -1 OR o.order_status = -2 THEN '已关闭'
  770. WHEN o.order_status = 3 OR o.order_status = 4 THEN '已退款'
  771. ELSE '其他' END AS orderStatus,
  772. CONCAT((
  773. ((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) +
  774. (
  775. SELECT
  776. COUNT( DISTINCT course_id, module_id, chapter_id, section_id )
  777. FROM
  778. user_study_record
  779. WHERE
  780. current_status = 1
  781. AND grade_id = og.grade_id
  782. AND order_goods_id = og.order_goods_id
  783. AND user_id = o.user_id
  784. AND status = 1
  785. AND goods_id = og.goods_id
  786. ))),"/",og.course_num + og.exam_num) AS studySchedule
  787. FROM
  788. `order` o
  789. LEFT JOIN order_goods og ON o.order_sn = og.order_sn
  790. LEFT JOIN goods g ON og.goods_id = g.goods_id
  791. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  792. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  793. LEFT JOIN course_business cb ON g.business_id = cb.id
  794. LEFT JOIN major m ON g.major_id = m.id
  795. LEFT JOIN `user` u ON o.user_id = u.user_id
  796. LEFT JOIN class_grade_user cgu ON og.order_goods_id = cgu.order_goods_id
  797. LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id
  798. WHERE
  799. 1=1
  800. AND og.`status` = 1
  801. AND o.input_order_sn IS NULL
  802. <if test="orderSn != null and orderSn != ''">
  803. AND o.order_sn = #{orderSn}
  804. </if>
  805. <if test="orderSnList != null and orderSnList.size()!=0">
  806. AND o.order_sn in
  807. <foreach collection="orderSnList" item="item" index="index" open="(" close=")" separator=",">
  808. #{item}
  809. </foreach>
  810. </if>
  811. <if test="orderStartTime != null and orderStartTime != ''">
  812. AND og.create_time <![CDATA[ >= ]]> #{orderStartTime}
  813. </if>
  814. <if test="orderEndTime != null and orderEndTime != ''">
  815. AND og.create_time <![CDATA[ <= ]]> #{orderEndTime}
  816. </if>
  817. <if test="educationTypeId != null and educationTypeId != ''">
  818. AND g.education_type_id = #{educationTypeId}
  819. </if>
  820. <if test="businessId != null and businessId != ''">
  821. AND g.business_id = #{businessId}
  822. </if>
  823. <if test="companyName != null and companyName != ''">
  824. AND u.company_name = #{companyName}
  825. </if>
  826. ORDER BY og.create_time DESC
  827. </select>
  828. <select id="getSevenOrder" parameterType="com.zhongzheng.modules.order.bo.RepetitionOrderBo"
  829. resultType="com.zhongzheng.modules.order.vo.RepetitionOrderVo">
  830. SELECT
  831. u.user_id,
  832. og.order_goods_id,
  833. g.goods_id,
  834. o.order_sn
  835. FROM
  836. order_goods og
  837. LEFT JOIN `order` o ON og.order_sn = o.order_sn
  838. LEFT JOIN `user` u ON o.user_id = u.user_id
  839. LEFT JOIN goods g ON og.goods_id = g.goods_id
  840. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  841. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  842. LEFT JOIN course_business cb ON g.business_id = cb.id
  843. WHERE
  844. og.`status` = 1
  845. AND og.pay_status != 1
  846. AND og.refund_status != 2
  847. AND g.goods_type = 1
  848. AND INSTR( CONCAT( cet.education_name, cpt.project_name ), "考前培训施工现场专业人员" )
  849. <if test="userId != null and userId != ''">
  850. AND u.user_id = #{userId}
  851. </if>
  852. </select>
  853. <select id="getGoodsIdByBusiness" parameterType="com.zhongzheng.modules.order.bo.GoodsByBusinessQuery" resultType="java.lang.Long">
  854. SELECT
  855. g.goods_id
  856. FROM
  857. goods g
  858. LEFT JOIN course_business cb ON g.business_id = cb.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 major m ON g.major_id = m.id
  862. WHERE
  863. g.`status` = 1
  864. AND g.goods_status = 1
  865. AND INSTR( CONCAT( cet.education_name, cb.business_name, cpt.project_name ), #{businessName} )
  866. AND m.category_name = #{majorName}
  867. <if test="year != null and year != ''">
  868. AND g.seven_year = #{year}
  869. </if>
  870. ORDER BY g.create_time DESC
  871. LIMIT 1
  872. </select>
  873. <select id="getGradeByBusiness" parameterType="com.zhongzheng.modules.order.bo.CommonGradeBo" resultType="com.zhongzheng.modules.order.vo.CommonGradeVo">
  874. SELECT
  875. cg.grade_id,
  876. cg.class_name AS gradeName,
  877. CASE
  878. WHEN cg.class_status = 1 THEN '已开班'
  879. WHEN cg.class_status = 0 THEN '未开班'
  880. ELSE '其他' END AS gradeStatus,
  881. FROM_UNIXTIME( cg.class_start_time, '%Y-%m-%d %H:%i:%s' ) AS startTime,
  882. FROM_UNIXTIME( cg.class_end_time, '%Y-%m-%d %H:%i:%s' ) AS endTime,
  883. cg.student_upper AS upperNum,
  884. ((
  885. SELECT
  886. COUNT(*)
  887. FROM
  888. class_grade_user cgu
  889. WHERE
  890. cgu.grade_id = cg.grade_id
  891. AND cgu.`status` = 1
  892. ) + ( SELECT COUNT(*) FROM class_grade_user_temp cgut WHERE cgut.grade_id = cg.grade_id AND cgut.`status` = 1 )) AS studyNum
  893. FROM
  894. class_grade cg
  895. LEFT JOIN class_grade_goods cgg ON cg.grade_id = cgg.grade_id
  896. LEFT JOIN goods g ON cgg.goods_id = g.goods_id
  897. LEFT JOIN course_business cb ON g.business_id = cb.id
  898. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  899. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  900. LEFT JOIN major m ON g.major_id = m.id
  901. WHERE
  902. cg.`status` = 1
  903. AND g.`status` = 1
  904. AND g.goods_status = 1
  905. AND INSTR( CONCAT( cet.education_name, cb.business_name, cpt.project_name ), #{businessName})
  906. AND m.category_name = #{majorName}
  907. ORDER BY cg.create_time DESC
  908. </select>
  909. <select id="getOfflineOrderList" parameterType="com.zhongzheng.modules.order.bo.OfflineOrderBo" resultType="com.zhongzheng.modules.order.vo.OfflineOrderVo">
  910. SELECT
  911. o.order_sn,
  912. og.create_time,
  913. u.user_id,
  914. u.realname AS userName,
  915. AES_DECRYPT(UNHEX(u.telphone),'base20230213zzkj') AS userPhone,
  916. AES_DECRYPT(UNHEX(u.id_card),'base20230213zzkj') AS userCard,
  917. u.company_name,
  918. g.goods_name,
  919. CONCAT(cet.education_name,'-',cb.business_name,'-',cpt.project_name) AS businessName,
  920. og.goods_price AS orderPrice,
  921. o.check_status,
  922. ea.apply_name AS examApplyName
  923. FROM
  924. `order` o
  925. LEFT JOIN order_goods og ON o.order_sn = og.order_sn
  926. LEFT JOIN `user` u ON o.user_id = u.user_id
  927. LEFT JOIN goods g ON og.goods_id = g.goods_id
  928. LEFT JOIN course_business cb ON g.business_id = cb.id
  929. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  930. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  931. LEFT JOIN exam_apply ea ON og.exam_sign = ea.apply_id
  932. WHERE
  933. o.order_type = 6
  934. AND o.order_from = 12
  935. <if test="userName != null and userName != ''">
  936. AND u.realname like concat('%', #{userName}, '%')
  937. </if>
  938. <if test="checkStatus != null and checkStatus != ''">
  939. AND o.check_status = #{checkStatus}
  940. </if>
  941. ORDER BY og.create_time DESC
  942. </select>
  943. <select id="getCommonOrderInfo" parameterType="com.zhongzheng.modules.order.bo.CommonOrderInfoBo" resultType="com.zhongzheng.modules.order.vo.CommonOrderInfoVo">
  944. SELECT
  945. o.order_sn,
  946. FROM_UNIXTIME( og.create_time, '%Y-%m-%d %H:%i:%s' ) AS orderTime,
  947. u.realname AS userName,
  948. AES_DECRYPT(UNHEX(u.id_card),'base20230213zzkj') AS userCard,
  949. AES_DECRYPT(UNHEX(u.telphone),'base20230213zzkj') AS userPhone,
  950. u.company_name AS companyName,
  951. g.goods_name AS goodsName,
  952. g.seven_year AS sevenYear,
  953. CONCAT(cet.education_name,cb.business_name,cpt.project_name) AS businessName,
  954. m.category_name AS majorName,
  955. cg.class_name AS className,
  956. CASE
  957. WHEN cg.class_status = 1 THEN '已开班'
  958. WHEN cg.class_status = 0 THEN '未开班'
  959. ELSE '其他' END AS classStatus,
  960. FROM_UNIXTIME( cg.class_end_time, '%Y-%m-%d %H:%i:%s' ) AS classEndTime,
  961. CONCAT((
  962. ((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) +
  963. (
  964. SELECT
  965. COUNT( DISTINCT course_id, module_id, chapter_id, section_id )
  966. FROM
  967. user_study_record
  968. WHERE
  969. current_status = 1
  970. AND grade_id = og.grade_id
  971. AND order_goods_id = og.order_goods_id
  972. AND user_id = o.user_id
  973. AND status = 1
  974. AND goods_id = og.goods_id
  975. ))
  976. ),"/",og.course_num + og.exam_num) AS studySchedule
  977. FROM
  978. `order` o
  979. LEFT JOIN order_goods og ON o.order_sn = og.order_sn
  980. LEFT JOIN goods g ON og.goods_id = g.goods_id
  981. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  982. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  983. LEFT JOIN course_business cb ON g.business_id = cb.id
  984. LEFT JOIN major m ON g.major_id = m.id
  985. LEFT JOIN `user` u ON o.user_id = u.user_id
  986. LEFT JOIN class_grade_user cgu ON og.order_goods_id = cgu.order_goods_id
  987. LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id
  988. WHERE
  989. 1=1
  990. AND o.tenant_id = #{tenantId}
  991. AND og.pay_status != 1
  992. AND og.refund_status != 2
  993. AND o.`status` = 1
  994. AND og.`status` = 1
  995. AND cgu.`status` = 1
  996. <if test="orderSnList != null and orderSnList.size()!=0">
  997. AND o.order_sn in
  998. <foreach collection="orderSnList" item="item" index="index" open="(" close=")" separator=",">
  999. #{item}
  1000. </foreach>
  1001. </if>
  1002. </select>
  1003. <select id="selectWithoutListByBo" parameterType="com.zhongzheng.modules.order.bo.OrderQueryBo" resultMap="OrderResultVo">
  1004. SELECT
  1005. o.*,
  1006. g.goods_id,
  1007. g.goods_name,
  1008. g.year,
  1009. g.cover_url,
  1010. g.code,
  1011. g.goods_type,
  1012. og.goods_price,
  1013. og.rebuy_order_goods_id,
  1014. og.order_goods_id,
  1015. og.goods_real_price,
  1016. og.offline_refund_sign,
  1017. u.telphone,
  1018. u.realname,
  1019. u.id_card,
  1020. u.company_name,
  1021. cet.education_name,
  1022. cpt.project_name,
  1023. cb.business_name,
  1024. s.school_name,
  1025. m.category_name,
  1026. og.goods_received,
  1027. og.refund_status,
  1028. og.pay_status as goods_pay_status,
  1029. (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,
  1030. (SELECT oi.invoice_status FROM order_invoice oi LEFT JOIN order_invoice_order oio ON oio.invoice_id = oi.invoice_id WHERE
  1031. oio.order_goods_id = og.order_goods_id AND oi.period_status != 2 limit 1) invoice_status
  1032. FROM
  1033. `order` o
  1034. LEFT JOIN order_goods og ON o.order_sn = og.order_sn
  1035. LEFT JOIN goods g ON og.goods_id = g.goods_id
  1036. LEFT JOIN `user` u ON o.user_id = u.user_id
  1037. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  1038. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  1039. LEFT JOIN course_business cb ON g.business_id = cb.id
  1040. LEFT JOIN school s ON s.id = g.school_id
  1041. LEFT JOIN major m ON g.major_id = m.id
  1042. WHERE 1=1
  1043. AND o.order_type = 3
  1044. AND og.status = 1
  1045. <if test="educationTypeId != null and educationTypeId != ''">
  1046. AND g.education_type_id = #{educationTypeId}
  1047. </if>
  1048. <if test="businessId != null and businessId != ''">
  1049. AND g.business_id = #{businessId}
  1050. </if>
  1051. <if test="schoolId != null and schoolId != ''">
  1052. AND g.school_id = #{schoolId}
  1053. </if>
  1054. <if test="majorId != null and majorId != ''">
  1055. AND g.major_id = #{majorId}
  1056. </if>
  1057. <if test="orderSn != null and orderSn != ''">
  1058. AND o.order_sn = #{orderSn}
  1059. </if>
  1060. <if test="orderStatus != null ">
  1061. AND o.order_status in
  1062. <foreach collection="orderStatus" item="item" index="index" open="(" close=")" separator=",">
  1063. #{item}
  1064. </foreach>
  1065. </if>
  1066. <if test="status != null ">
  1067. AND o.status in
  1068. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  1069. #{item}
  1070. </foreach>
  1071. </if>
  1072. <if test="orderGoodsStatus == 1">
  1073. AND og.pay_status in (2,3,4) AND og.refund_status != 2
  1074. </if>
  1075. <if test="startTime != null">
  1076. AND o.create_time >= #{startTime}
  1077. </if>
  1078. <if test="endTime != null">
  1079. AND #{endTime} >= o.create_time
  1080. </if>
  1081. <if test="payStatus != null">
  1082. AND o.pay_status = #{payStatus}
  1083. </if>
  1084. <if test="goodsPayStatus != null">
  1085. AND og.pay_status = #{goodsPayStatus}
  1086. </if>
  1087. <if test="refundStatus != null">
  1088. AND og.refund_status = #{refundStatus}
  1089. </if>
  1090. <if test="goodsType != null">
  1091. AND g.goods_type = #{goodsType}
  1092. </if>
  1093. <if test="userId != null">
  1094. AND u.user_id = #{userId}
  1095. AND og.pay_status in (2,3,4)
  1096. </if>
  1097. <if test="inputOrderSn != null">
  1098. AND o.input_order_sn = #{inputOrderSn}
  1099. </if>
  1100. <if test="companyName != null and companyName != ''">
  1101. AND u.company_name like concat('%', #{companyName}, '%')
  1102. </if>
  1103. <if test="searchKey != null and searchKey != ''">
  1104. AND (u.realname like concat('%', #{searchKey}, '%') or o.order_sn = #{searchKey} or AES_DECRYPT(UNHEX(u.id_card),'base20230213zzkj') = #{searchKey} or g.goods_name like concat('%', #{searchKey}, '%'))
  1105. </if>
  1106. <if test="orderGoodsIds != null ">
  1107. AND og.order_goods_id in
  1108. <foreach collection="orderGoodsIds" item="item" index="index" open="(" close=")" separator=",">
  1109. #{item}
  1110. </foreach>
  1111. </if>
  1112. <if test="orderFroms != null and orderFroms.size()!=0">
  1113. AND o.order_from in
  1114. <foreach collection="orderFroms" item="item" index="index" open="(" close=")" separator=",">
  1115. #{item}
  1116. </foreach>
  1117. </if>
  1118. ORDER BY o.order_id DESC
  1119. </select>
  1120. <select id="getUserStudyCondition" parameterType="com.zhongzheng.modules.order.bo.UserStudyConditionBo" resultType="com.zhongzheng.modules.order.vo.UserStudyConditionVo">
  1121. SELECT
  1122. o.order_sn,
  1123. FROM_UNIXTIME( og.create_time, '%Y-%m-%d %H:%i:%s' ) AS orderTime,
  1124. u.realname AS userName,
  1125. AES_DECRYPT(UNHEX(u.id_card),'base20230213zzkj') AS userCard,
  1126. AES_DECRYPT(UNHEX(u.telphone),'base20230213zzkj') AS userPhone,
  1127. u.password_aes AS userPassword,
  1128. u.company_name AS companyName,
  1129. g.goods_name AS goodsName,
  1130. g.seven_year AS sevenYear,
  1131. CONCAT(cet.education_name,cb.business_name,cpt.project_name) AS businessName,
  1132. m.category_name AS majorName,
  1133. cg.class_name AS className,
  1134. CASE
  1135. WHEN cg.class_status = 1 THEN '已开班'
  1136. WHEN cg.class_status = 0 THEN '未开班'
  1137. ELSE '其他' END AS classStatus,
  1138. CASE
  1139. WHEN cgu.official_status = 1 THEN '是'
  1140. ELSE '否' END AS officialStatus,
  1141. CASE
  1142. WHEN cgu.period_plush = 1 THEN '是'
  1143. ELSE '否' END AS periodPlush,
  1144. FROM_UNIXTIME( cg.class_end_time, '%Y-%m-%d %H:%i:%s' ) AS classEndTime,
  1145. CONCAT((
  1146. ((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) +
  1147. (
  1148. SELECT
  1149. COUNT( DISTINCT course_id, module_id, chapter_id, section_id )
  1150. FROM
  1151. user_study_record
  1152. WHERE
  1153. current_status = 1
  1154. AND grade_id = og.grade_id
  1155. AND order_goods_id = og.order_goods_id
  1156. AND user_id = o.user_id
  1157. AND status = 1
  1158. AND goods_id = og.goods_id
  1159. ))
  1160. ),"/",og.course_num + og.exam_num) AS studySchedule
  1161. FROM
  1162. `order` o
  1163. LEFT JOIN order_goods og ON o.order_sn = og.order_sn
  1164. LEFT JOIN goods g ON og.goods_id = g.goods_id
  1165. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  1166. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  1167. LEFT JOIN course_business cb ON g.business_id = cb.id
  1168. LEFT JOIN major m ON g.major_id = m.id
  1169. LEFT JOIN `user` u ON o.user_id = u.user_id
  1170. LEFT JOIN class_grade_user cgu ON og.order_goods_id = cgu.order_goods_id
  1171. LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id
  1172. WHERE
  1173. 1=1
  1174. AND og.pay_status != 1
  1175. AND og.refund_status != 2
  1176. AND o.`status` = 1
  1177. AND og.`status` = 1
  1178. AND cgu.`status` = 1
  1179. <if test="tenantId != null and tenantId != ''">
  1180. AND o.tenant_id = #{tenantId}
  1181. </if>
  1182. <if test="userCard != null and userCard != ''">
  1183. AND UPPER(AES_DECRYPT(UNHEX(id_card),'base20230213zzkj')) = UPPER(#{userCard})
  1184. </if>
  1185. <if test="userName != null and userName != ''">
  1186. AND u.realname = #{userName}
  1187. </if>
  1188. <if test="sevenYear != null and sevenYear != ''">
  1189. AND og.seven_year = #{sevenYear}
  1190. </if>
  1191. <if test="companyName != null and companyName != ''">
  1192. AND u.company_name = #{companyName}
  1193. </if>
  1194. <if test="businessName != null and businessName != ''">
  1195. AND INSTR(CONCAT(cet.education_name,cb.business_name,cpt.project_name),#{businessName})
  1196. </if>
  1197. <if test="majorName != null and majorName != ''">
  1198. AND m.category_name = #{majorName}
  1199. </if>
  1200. </select>
  1201. <select id="getOrderSnByXY" parameterType="com.zhongzheng.modules.order.vo.UserStudyConditionVo" resultType="java.lang.String">
  1202. SELECT
  1203. o.order_sn
  1204. FROM
  1205. `order` o
  1206. LEFT JOIN order_goods og ON o.order_sn = og.order_sn
  1207. LEFT JOIN goods g ON og.goods_id = g.goods_id
  1208. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  1209. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  1210. LEFT JOIN course_business cb ON g.business_id = cb.id
  1211. LEFT JOIN major m ON g.major_id = m.id
  1212. LEFT JOIN `user` u ON o.user_id = u.user_id
  1213. LEFT JOIN class_grade_user cgu ON og.order_goods_id = cgu.order_goods_id
  1214. LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id
  1215. WHERE
  1216. 1=1
  1217. AND og.pay_status != 1
  1218. AND og.refund_status != 2
  1219. AND o.`status` = 1
  1220. AND og.`status` = 1
  1221. AND cgu.`status` = 1
  1222. AND o.tenant_id = 867735392558919680
  1223. <if test="userCard != null and userCard != ''">
  1224. AND UPPER(AES_DECRYPT(UNHEX(id_card),'base20230213zzkj')) = UPPER(#{userCard})
  1225. </if>
  1226. <if test="userName != null and userName != ''">
  1227. AND u.realname = #{userName}
  1228. </if>
  1229. <if test="sevenYear != null and sevenYear != ''">
  1230. AND og.seven_year = #{sevenYear}
  1231. </if>
  1232. <if test="companyName != null and companyName != ''">
  1233. AND u.company_name = #{companyName}
  1234. </if>
  1235. <if test="businessName != null and businessName != ''">
  1236. AND INSTR(CONCAT(cet.education_name,cb.business_name,cpt.project_name),#{businessName})
  1237. </if>
  1238. <if test="majorName != null and majorName != ''">
  1239. AND m.category_name = #{majorName}
  1240. </if>
  1241. LIMIT 1
  1242. </select>
  1243. <select id="getOrderSnByYW" parameterType="java.lang.String" resultType="java.lang.String">
  1244. SELECT
  1245. ( SELECT too.order_sn FROM top_old_order too WHERE too.input_order_sn = o.input_order_sn AND too.`status` = 1 LIMIT 1 ) AS order_sn
  1246. FROM
  1247. `order` o
  1248. WHERE
  1249. o.order_sn = #{orderSn}
  1250. AND o.input_order_sn IS NOT NULL
  1251. </select>
  1252. </mapper>