OrderMapper.xml 57 KB

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