CmDiscernReceiptMapper.xml 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.caimei.modules.order.dao.CmDiscernReceiptDao">
  4. <sql id="cmDiscernReceiptColumns">
  5. a.id AS "id",
  6. a.payWay AS "payWay",
  7. a.payType AS "payType",
  8. a.receiptType AS "receiptType",
  9. a.receiptStatus AS "receiptStatus",
  10. a.smsContent AS "smsContent",
  11. a.smsMd5Code AS "smsMd5Code",
  12. a.receiptAmount AS "receiptAmount",
  13. a.handlingFee AS "handlingFee",
  14. a.confirmType AS "confirmType",
  15. a.confirmUserPermissionID AS "confirmUserPermissionID",
  16. a.reviewUserPermissionID AS "reviewUserPermissionID",
  17. a.cancelUserPermissionID AS "cancelUserPermissionID",
  18. a.transactionNum AS "transactionNum",
  19. a.bankID AS "bankID",
  20. a.bankCode AS "bankCode",
  21. a.kuaiQianPayTypeID AS "kuaiQianPayTypeID",
  22. a.kuaiQianPayerID AS "kuaiQianPayerID",
  23. a.rePayFlag AS "rePayFlag",
  24. a.actualAmount AS "actualAmount",
  25. a.formData AS "formData",
  26. a.problem AS "problem",
  27. a.noOrderReason AS "noOrderReason",
  28. a.reviewReason AS "reviewReason",
  29. a.cancelReason AS "cancelReason",
  30. a.receiptDate AS "receiptDate",
  31. a.confirmDate AS "confirmDate",
  32. a.reviewDate AS "reviewDate",
  33. a.cancelDate AS "cancelDate",
  34. a.updateDate AS "updateDate",
  35. a.delFlag AS "delFlag",
  36. a.newReceiptType
  37. </sql>
  38. <sql id="cmDiscernReceiptJoins">
  39. </sql>
  40. <select id="get" resultType="CmDiscernReceipt">
  41. SELECT
  42. <include refid="cmDiscernReceiptColumns"/>
  43. FROM cm_discern_receipt a
  44. <include refid="cmDiscernReceiptJoins"/>
  45. WHERE a.id = #{id}
  46. </select>
  47. <select id="getAssociateAmount" resultType="double">
  48. select IFNULL(sum(cdr.receiptAmount),0) From cm_receipt_order_relation cror
  49. LEFT JOIN cm_discern_receipt cdr on cdr.id = cror.receiptID
  50. where cror.orderID = #{orderID} and cror.relationType = '2' and cdr.delFlag = 0
  51. and cror.delFlag = 0 and cdr.receiptStatus in (3) and payWay != '3';
  52. </select>
  53. <select id="getReturnBalanceAmount" resultType="double">
  54. select IFNULL(sum(amount),0) from cm_user_balance_record where balanceType = 2 and receiptId = #{receiptId} and delFlag = 0;
  55. </select>
  56. <select id="discern" resultType="String">
  57. SELECT
  58. u.userID,
  59. csp.id AS receiptID,
  60. cms.orderID,
  61. cms.shopOrderID,
  62. cms.shopOrderNo,
  63. cms.orderType as orderType,
  64. s.name AS shopName,
  65. cms.productAmount,
  66. cmo.orderNo,
  67. u.userName,
  68. u.name AS jgName,
  69. cmo.confirmTime,
  70. cms.receiptAmount,
  71. cms.needPayAmount
  72. FROM cm_shop_order cms
  73. LEFT JOIN shop s ON s.shopID = cms.shopID
  74. LEFT JOIN cm_order cmo ON cmo.orderID = cms.orderID
  75. LEFT JOIN `user` u ON u.userID = cms.userID
  76. LEFT JOIN cm_discern_receipt csp ON csp.shopOrderID = cms.shopOrderID
  77. </select>
  78. <select id="orderlist" resultType="CmDiscernReceipt">
  79. SELECT
  80. u.userID,
  81. csp.id AS receiptID,
  82. cms.orderID,
  83. cms.shopOrderID,
  84. cms.shopOrderNo,
  85. cms.orderType as orderType,
  86. s.name AS shopName,
  87. cms.productAmount,
  88. cmo.orderNo,
  89. u.userName,
  90. u.name AS jgName,
  91. cmo.confirmTime,
  92. cms.receiptAmount,
  93. cms.needPayAmount
  94. FROM cm_shop_order cms
  95. LEFT JOIN shop s ON s.shopID = cms.shopID
  96. LEFT JOIN cm_order cmo ON cmo.orderID = cms.orderID
  97. LEFT JOIN `user` u ON u.userID = cms.userID
  98. LEFT JOIN cm_discern_receipt csp ON csp.shopOrderID = cms.shopOrderID
  99. where csp.id=#{id}
  100. </select>
  101. <select id="findList" resultType="CmDiscernReceipt">
  102. -- relationType值为1是为子订单ID,为2时为主订单ID)
  103. SELECT
  104. <include refid="cmDiscernReceiptColumns"/>,
  105. cso_s.orderID AS orderID,
  106. cso_s.shopOrderNo as shopOrderNos,
  107. cso.shopOrderId as shopOrderId,
  108. s.checkMan,
  109. IF(crr.relationType = '1', s.name,IFNULL(s_a.name,'')) AS shopName,
  110. (case when crr.relationType = '1' then u_cr.userName else u.userName
  111. end) AS "userName",
  112. (case when crr.relationType = '1' then u_cr.name else u.name
  113. end) AS "name",
  114. IF(crr.relationType = '6',(SELECT NAME FROM USER mu WHERE mu.userId=ccb.userId),'') AS "backname",
  115. cr.organizeID AS organizeID
  116. FROM cm_discern_receipt a
  117. left join cm_receipt_order_relation crr on crr.receiptID = a.id and crr.delFlag = '0'
  118. LEFT JOIN cm_coupon_buyrecord ccb ON crr.couponRecordId=ccb.id
  119. -- 主订单
  120. left join cm_order cr on cr.orderID = crr.orderID
  121. left join user u on u.userID = cr.userID
  122. -- 子订单
  123. left join cm_shop_order cso on cso.shopOrderID = crr.orderID
  124. left join cm_order cso_cr on cso.orderID = cso_cr.orderID
  125. LEFT JOIN USER u_cr ON u_cr.userID = cso_cr.userID
  126. -- 供应商
  127. LEFT JOIN shop s ON s.shopID = cso.shopID
  128. LEFT JOIN cm_shop_order cso_s ON cso_s.shopOrderID = a.shopOrderID
  129. LEFT JOIN cm_shop_order cso_a ON cso_a.shopOrderID = crr.shopOrderID
  130. LEFT JOIN shop s_a ON s_a.shopID = cso_a.shopID
  131. <where>
  132. <if test="id != null and id != '' and id != 0 ">
  133. AND a.id = #{id}
  134. </if>
  135. <if test="organizeID != null and organizeID != 9999 ">
  136. AND cr.organizeID = #{organizeID}
  137. </if>
  138. <if test="organizeID == 9999 ">
  139. AND cr.orderType = 2
  140. </if>
  141. <if test="startTime != null and startTime != ''">
  142. AND (a.receiptDate &gt; #{startTime} OR a.receiptDate = #{startTime})
  143. </if>
  144. <if test="endTime != null and endTime != ''">
  145. AND (a.receiptDate &lt; #{endTime} OR a.receiptDate = #{endTime})
  146. </if>
  147. <if test="payWay != null and payWay != ''">
  148. AND a.payWay = #{payWay}
  149. </if>
  150. <if test="payType != null and payType != ''">
  151. AND a.payType = #{payType}
  152. </if>
  153. <if test="receiptType != null and receiptType != ''">
  154. <if test="receiptType==2 and newReceiptType==3">
  155. and (a.receiptType = 9)
  156. or a.receiptType = #{receiptType}
  157. </if>
  158. <if test="receiptType!=2">
  159. AND a.receiptType = #{receiptType}
  160. </if>
  161. AND a.receiptType = #{receiptType}
  162. </if>
  163. <if test="newReceiptType !=null">
  164. <if test="newReceiptType==3">
  165. and a.newReceiptType =3
  166. </if>
  167. <if test="newReceiptType != 3">
  168. and a.newReceiptType=#{newReceiptType}
  169. </if>
  170. </if>
  171. <if test="receiptStatus != null and receiptStatus != ''">
  172. AND a.receiptStatus = #{receiptStatus}
  173. </if>
  174. <if test="orderNo != null and orderNo != ''">
  175. AND ((cr.orderNo like concat('%',#{orderNo},'%')) OR (cso.shopOrderNo like concat('%',#{orderNo},'%')))
  176. </if>
  177. <if test="orderID != null and orderID != ''">
  178. AND (cr.orderID = #{orderID} OR (crr.relationType = '1' AND cso_cr.orderID = #{orderID}))
  179. </if>
  180. <if test="userName != null and userName != ''">
  181. AND (u.userName LIKE concat('%',#{userName},'%') or u.name LIKE concat('%',#{userName},'%'))
  182. </if>
  183. <if test="receiptProgress != null and receiptProgress != ''">
  184. and (case when crr.relationType = '1' then
  185. cso_cr.receiptStatus
  186. else
  187. cr.receiptStatus
  188. end) = #{receiptProgress}
  189. </if>
  190. <if test="receiptOrderType != null and receiptOrderType != ''">
  191. and (case when crr.relationType = '1' then
  192. cso.orderType
  193. else
  194. cr.orderType
  195. end) = #{receiptOrderType}
  196. </if>
  197. <if test="associationNum != null and associationNum != ''">
  198. <if test="associationNum == 1">
  199. and (select count(1) from cm_receipt_order_relation where receiptID = a.id and delFlag = '0') = 1
  200. </if>
  201. <if test="associationNum == 2">
  202. and (select count(1) from cm_receipt_order_relation where receiptID = a.id and delFlag = '0')
  203. <![CDATA[ > ]]> 1
  204. </if>
  205. </if>
  206. <if test="paYee !=null and paYee != ''">
  207. <if test="paYee == '采美'">
  208. and a.payWay = 3
  209. OR a.payWay = 2
  210. AND a.newReceiptType != 3 AND a.payWay = 2
  211. </if>
  212. <if test="payWay==1">
  213. and s.name=#{paYee}
  214. </if>
  215. </if>
  216. and a.delFlag = '0' group by a.id
  217. </where>
  218. <choose>
  219. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  220. ORDER BY ${page.orderBy}
  221. </when>
  222. <otherwise>
  223. order by a.receiptDate desc
  224. </otherwise>
  225. </choose>
  226. </select>
  227. <select id="findAllList" resultType="CmDiscernReceipt">
  228. SELECT
  229. <include refid="cmDiscernReceiptColumns"/>
  230. FROM cm_discern_receipt a
  231. <include refid="cmDiscernReceiptJoins"/>
  232. <where>
  233. </where>
  234. <choose>
  235. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  236. ORDER BY ${page.orderBy}
  237. </when>
  238. <otherwise>
  239. </otherwise>
  240. </choose>
  241. </select>
  242. <select id="exportTest" resultType="com.caimei.modules.order.entity.CmMainReceiptExport">
  243. SELECT
  244. r.orderID,
  245. (select group_concat(distinct p.name) from product p left join cm_order_product cop on p.productID = cop.productID where cop.orderID = o.orderID group by cop.orderID) as productNames,
  246. IF(u.userIdentity = 2,u.name,u.userName) AS userName,
  247. d.receiptDate,
  248. d.payType,
  249. IFNULL(r.associateAmount,0) as associateAmount,
  250. d.receiptType
  251. FROM
  252. cm_receipt_order_relation r
  253. LEFT JOIN cm_discern_receipt d ON d.id = r.receiptID
  254. LEFT JOIN cm_order o ON r.orderID = o.orderID
  255. LEFT JOIN USER u ON u.userID = o.userID
  256. <where>
  257. <if test="startTime != null and startTime != ''">
  258. AND (d.receiptDate <![CDATA[ >= ]]> #{startTime})
  259. </if>
  260. <if test="endTime != null and endTime != ''">
  261. AND (d.receiptDate <![CDATA[ <= ]]> #{endTime})
  262. </if>
  263. <if test="receiptProgress != null and receiptProgress != ''">
  264. AND o.receiptStatus = #{receiptProgress}
  265. </if>
  266. AND d.receiptType = 1
  267. AND d.receiptStatus = 3
  268. AND d.delFlag = '0'
  269. AND r.delFlag = '0'
  270. </where>
  271. ORDER BY
  272. d.receiptDate DESC;
  273. </select>
  274. <select id="exportRebate" resultType="com.caimei.modules.order.entity.CmMainReceiptExport">
  275. SELECT
  276. so.orderID,
  277. (select group_concat(distinct p.name) from product p left join cm_order_product cop on p.productID = cop.productID where cop.orderID = so.orderID group by cop.orderID) as productNames,
  278. IF(u.userIdentity = 2,u.name,u.userName) AS userName,
  279. d.receiptDate,
  280. d.payType,
  281. IFNULL(d.receiptAmount,0) as associateAmount,
  282. d.receiptType
  283. FROM
  284. cm_receipt_order_relation r
  285. LEFT JOIN cm_discern_receipt d ON d.id = r.receiptID
  286. LEFT JOIN cm_shop_order so ON r.orderID = so.shopOrderID
  287. LEFT JOIN USER u ON u.userID = so.userID
  288. <where>
  289. <if test="startTime != null and startTime != ''">
  290. AND (d.receiptDate <![CDATA[ >= ]]> #{startTime})
  291. </if>
  292. <if test="endTime != null and endTime != ''">
  293. AND (d.receiptDate <![CDATA[ <= ]]> #{endTime})
  294. </if>
  295. <if test="receiptProgress != null and receiptProgress != ''">
  296. AND o.receiptStatus = #{receiptProgress}
  297. </if>
  298. AND d.receiptStatus = 2
  299. AND d.delFlag = '0'
  300. AND r.delFlag = '0'
  301. AND r.relationType='1'
  302. </where>
  303. ORDER BY
  304. d.receiptDate DESC;
  305. </select>
  306. <!--订单已付款又进行交易全退,此处需要结合订单状态导出,单纯的进账会不明确-->
  307. <select id="exportReceiptPay" resultType="com.caimei.modules.order.entity.CmMainReceiptExport">
  308. SELECT
  309. DISTINCT r.orderID
  310. FROM
  311. cm_receipt_order_relation r
  312. LEFT JOIN cm_discern_receipt d ON d.id = r.receiptID
  313. LEFT JOIN cm_order o ON r.orderID = o.orderID
  314. LEFT JOIN USER u ON u.userID = o.userID
  315. <where>
  316. <if test="startTime != null and startTime != ''">
  317. AND (d.receiptDate <![CDATA[ > ]]> #{startTime} OR d.receiptDate = #{startTime})
  318. </if>
  319. <if test="endTime != null and endTime != ''">
  320. AND (d.receiptDate <![CDATA[ < ]]> #{endTime} OR d.receiptDate = #{endTime})
  321. </if>
  322. <if test="receiptProgress != null and receiptProgress != ''">
  323. AND o.receiptStatus = #{receiptProgress}
  324. </if>
  325. AND d.receiptStatus = 3
  326. AND d.delFlag = '0'
  327. AND r.delFlag = '0'
  328. </where>
  329. ORDER BY
  330. d.receiptDate DESC;
  331. </select>
  332. <select id="exportOnlyBalancePay" resultType="com.caimei.modules.order.entity.CmMainReceiptExport">
  333. SELECT
  334. DISTINCT o.orderID
  335. FROM
  336. cm_order o
  337. <where>
  338. <if test="startTime != null and startTime != ''">
  339. AND (o.orderTime <![CDATA[ > ]]> #{startTime} OR o.orderTime = #{startTime})
  340. </if>
  341. <if test="endTime != null and endTime != ''">
  342. AND (o.orderTime <![CDATA[ < ]]> #{endTime} OR o.orderTime = #{endTime})
  343. </if>
  344. <if test="receiptProgress != null and receiptProgress != ''">
  345. AND o.receiptStatus = #{receiptProgress}
  346. </if>
  347. AND o.balancePayFee > 0
  348. AND o.delFlag = '0'
  349. </where>
  350. HAVING (SELECT count(a.id) as num from cm_receipt_order_relation a left JOIN cm_discern_receipt d on a.receiptID
  351. = d.id where a.orderID=o.orderID and d.receiptStatus = 3 and d.delFlag = '0') = 0
  352. ORDER BY
  353. o.orderTime DESC;
  354. </select>
  355. <select id="exportPay" resultType="com.caimei.modules.order.entity.CmMainReceiptExport">
  356. SELECT
  357. ps.id AS orderID,
  358. u.`name` AS userName,
  359. r.payTime AS receiptDate,
  360. ps.payType AS payType,
  361. ps.totalAmount AS associateAmount,
  362. GROUP_CONCAT(CONCAT(ss.shopOrderID , '/' ,ss.payedShopAmount , '/' , ss.`userName` )) AS shopOrderID
  363. FROM
  364. cm_pay_shop ps
  365. LEFT JOIN cm_pay_shop_record r ON ps.id = r.payShopID
  366. LEFT JOIN (select so.shopOrderID,so.payedShopAmount,o.userName from cm_shop_order so LEFT JOIN user o on
  367. o.userID = so.userID) as ss on ss.shopOrderID = r.shopOrderID
  368. LEFT JOIN shop u ON r.shopID = u.shopID
  369. <where>
  370. <if test="startTime != null and startTime != ''">
  371. AND (r.payTime <![CDATA[ > ]]> #{startTime} OR r.payTime = #{startTime})
  372. </if>
  373. <if test="endTime != null and endTime != ''">
  374. AND (r.payTime <![CDATA[ < ]]> #{endTime} OR r.payTime = #{endTime})
  375. </if>
  376. AND r. STATUS = 1
  377. AND ps. STATUS = 1
  378. </where>
  379. GROUP BY
  380. ps.id
  381. ORDER BY
  382. r.payTime DESC;
  383. </select>
  384. <select id="exportPayData" resultType="com.caimei.modules.order.entity.CmMainReceiptExport">
  385. SELECT DISTINCT
  386. o.orderID
  387. FROM
  388. cm_order o
  389. LEFT JOIN cm_shop_order so ON so.orderID = o.orderID
  390. LEFT JOIN cm_pay_shop_record psr ON psr.shopOrderID = so.shopOrderID
  391. <where>
  392. <if test="startTime != null and startTime != ''">
  393. AND (psr.payTime <![CDATA[ > ]]> #{startTime} OR psr.payTime = #{startTime})
  394. </if>
  395. <if test="endTime != null and endTime != ''">
  396. AND (psr.payTime <![CDATA[ < ]]> #{endTime} OR psr.payTime = #{endTime})
  397. </if>
  398. <if test="receiptProgress != null and receiptProgress != ''">
  399. AND o.payStatus = #{receiptProgress}
  400. </if>
  401. AND psr. STATUS = 1
  402. </where>
  403. ORDER BY
  404. psr.payTime DESC
  405. </select>
  406. <select id="exportOrderDate" resultType="com.caimei.modules.order.entity.CmMainReceiptExport">
  407. SELECT DISTINCT
  408. o.orderID,o.status
  409. FROM
  410. cm_order o
  411. <where>
  412. <if test="startTime != null and startTime != ''">
  413. AND (o.orderTime <![CDATA[ > ]]> #{startTime} OR o.orderTime = #{startTime})
  414. </if>
  415. <if test="endTime != null and endTime != ''">
  416. AND (o.orderTime <![CDATA[ < ]]> #{endTime} OR o.orderTime = #{endTime})
  417. </if>
  418. AND o.delFlag='0'
  419. AND o.status!='6'
  420. AND o.orderID NOT IN (
  421. SELECT so.orderID
  422. FROM cm_shop_order so
  423. LEFT JOIN cm_receipt_order_relation ror ON ror.orderID = so.shopOrderID
  424. LEFT JOIN cm_discern_receipt dr ON dr.id = ror.receiptID
  425. WHERE ror.relationType = '1'
  426. AND dr.receiptStatus = '2'
  427. AND so.delFlag = '0'
  428. GROUP BY so.orderID
  429. )
  430. </where>
  431. </select>
  432. <select id="getListOrder" resultType="com.caimei.modules.order.entity.CmMainReceiptExport">
  433. SELECT o.orderID, o.status, SUM(dr.receiptAmount) AS receiptAmount, ror.relationType
  434. FROM cm_order o
  435. LEFT JOIN cm_shop_order so ON so.orderID = o.orderID
  436. LEFT JOIN cm_receipt_order_relation ror ON so.shopOrderID = ror.`orderID`
  437. LEFT JOIN cm_discern_receipt dr ON dr.id = ror.receiptID
  438. <where>
  439. <if test="startTime != null and startTime != ''">
  440. AND (o.orderTime <![CDATA[ > ]]> #{startTime} OR o.orderTime = #{startTime})
  441. </if>
  442. <if test="endTime != null and endTime != ''">
  443. AND (o.orderTime <![CDATA[ < ]]> #{endTime} OR o.orderTime = #{endTime})
  444. </if>
  445. AND ror.`relationType` = '1'
  446. AND dr.receiptStatus = '2'
  447. AND o.delFlag='0'
  448. </where>
  449. GROUP BY o.orderID
  450. </select>
  451. <select id="exportPayment" resultType="com.caimei.modules.order.entity.CmMainReceiptExport">
  452. SELECT so.orderID, ror.relationType, SUM(dr.receiptAmount) AS receiptAmount
  453. FROM cm_shop_order so
  454. LEFT JOIN cm_receipt_order_relation ror ON ror.orderID = so.shopOrderID
  455. LEFT JOIN cm_discern_receipt dr ON dr.id = ror.receiptID
  456. <where>
  457. <if test="startTime != null and startTime != ''">
  458. AND (dr.receiptDate <![CDATA[ > ]]> #{startTime} OR dr.receiptDate = #{startTime})
  459. </if>
  460. <if test="endTime != null and endTime != ''">
  461. AND (dr.receiptDate <![CDATA[ < ]]> #{endTime} OR dr.receiptDate = #{endTime})
  462. </if>
  463. AND ror.relationType = '1'
  464. AND dr.receiptStatus = '2'
  465. AND so.delFlag = '0'
  466. </where>
  467. GROUP BY so.orderID
  468. </select>
  469. <insert id="insert" parameterType="CmDiscernReceipt" keyProperty="id" useGeneratedKeys="true">
  470. INSERT INTO cm_discern_receipt(
  471. payWay,
  472. payType,
  473. receiptType,
  474. receiptStatus,
  475. smsContent,
  476. smsMd5Code,
  477. receiptAmount,
  478. handlingFee,
  479. confirmType,
  480. confirmUserPermissionID,
  481. reviewUserPermissionID,
  482. cancelUserPermissionID,
  483. transactionNum,
  484. bankID,
  485. bankCode,
  486. kuaiQianPayTypeID,
  487. kuaiQianPayerID,
  488. rePayFlag,
  489. actualAmount,
  490. formData,
  491. problem,
  492. noOrderReason,
  493. reviewReason,
  494. cancelReason,
  495. receiptDate,
  496. confirmDate,
  497. reviewDate,
  498. cancelDate,
  499. updateDate,
  500. delFlag
  501. ) VALUES (
  502. #{payWay},
  503. #{payType},
  504. #{receiptType},
  505. #{receiptStatus},
  506. #{smsContent},
  507. #{smsMd5Code},
  508. #{receiptAmount},
  509. #{handlingFee},
  510. #{confirmType},
  511. #{confirmUserPermissionID},
  512. #{reviewUserPermissionID},
  513. #{cancelUserPermissionID},
  514. #{transactionNum},
  515. #{bankID},
  516. #{bankCode},
  517. #{kuaiQianPayTypeID},
  518. #{kuaiQianPayerID},
  519. #{rePayFlag},
  520. #{actualAmount},
  521. #{formData},
  522. #{problem},
  523. #{noOrderReason},
  524. #{reviewReason},
  525. #{cancelReason},
  526. #{receiptDate},
  527. #{confirmDate},
  528. #{reviewDate},
  529. #{cancelDate},
  530. #{cancelDate},
  531. #{delFlag}
  532. )
  533. </insert>
  534. <update id="update">
  535. UPDATE cm_discern_receipt SET
  536. payWay = #{payWay},
  537. payType = #{payType},
  538. receiptType = #{receiptType},
  539. receiptStatus = #{receiptStatus},
  540. smsContent = #{smsContent},
  541. smsMd5Code = #{smsMd5Code},
  542. receiptAmount = #{receiptAmount},
  543. handlingFee = #{handlingFee},
  544. confirmType = #{confirmType},
  545. confirmUserPermissionID = #{confirmUserPermissionID},
  546. reviewUserPermissionID = #{reviewUserPermissionID},
  547. cancelUserPermissionID = #{cancelUserPermissionID},
  548. transactionNum = #{transactionNum},
  549. bankID = #{bankID},
  550. bankCode = #{bankCode},
  551. kuaiQianPayTypeID = #{kuaiQianPayTypeID},
  552. kuaiQianPayerID = #{kuaiQianPayerID},
  553. rePayFlag = #{rePayFlag},
  554. actualAmount = #{actualAmount},
  555. formData = #{formData},
  556. problem = #{problem},
  557. noOrderReason = #{noOrderReason},
  558. reviewReason = #{reviewReason},
  559. cancelReason = #{cancelReason},
  560. receiptDate = #{receiptDate},
  561. confirmDate = #{confirmDate},
  562. reviewDate = #{reviewDate},
  563. cancelDate = #{cancelDate},
  564. updateDate = DATE_FORMAT(#{updateDate},'%Y-%m-%d %H:%i:%s'),
  565. balanceAccountsRemark = #{balanceAccountsRemark},
  566. delFlag = #{delFlag}
  567. WHERE id = #{id}
  568. </update>
  569. <delete id="delete">
  570. DELETE FROM cm_discern_receipt
  571. WHERE id = #{id}
  572. </delete>
  573. <select id="getOrderIDStr" parameterType="string" resultType="map">
  574. -- relationType值为1是为子订单ID,为2时为主订单ID)
  575. select
  576. (case when cror.relationType = '1'
  577. then concat('子订单',cso.shopOrderNo,'(', cso.shopOrderID,')')
  578. else concat(cou.orderNo,'(', cou.orderID,')')
  579. end) AS orderNo,
  580. (CASE WHEN cror.relationType = '1'
  581. THEN co.orderID
  582. ELSE cou.orderID
  583. END) AS orderID ,
  584. (case when cror.relationType = '1'
  585. then (select b.orderType from cm_shop_order b where cso.shopOrderID = b.shopOrderID)
  586. else (select c.orderType from cm_order c where cou.orderID = c.orderID)
  587. end) AS orderType
  588. from cm_receipt_order_relation cror
  589. left join cm_shop_order cso on cror.orderID = cso.shopOrderID
  590. left join cm_order co on cso.orderID = co.orderID
  591. LEFT JOIN cm_order cou ON cror.orderID = cou.orderID
  592. where cror.receiptID = #{id} and cror.delFlag = '0'
  593. </select>
  594. <select id="getInfos" parameterType="CmDiscernReceipt" resultType="com.caimei.modules.order.entity.ReceiptDetailVo">
  595. select
  596. cdr.id AS receiptID,
  597. cdr.receiptType AS receiptType,
  598. cdr.confirmType AS confirmType,
  599. cdr.payType AS payType,
  600. cdr.receiptAmount AS receiptAmount,
  601. cdr.receiptDate AS receiptDate,
  602. cdr.receiptStatus AS receiptStatus,
  603. cdr.noOrderReason AS noOrderReason,
  604. cdr.confirmDate AS confirmTime,
  605. cdr.smsContent AS smsContent,
  606. cdr.cancelReason AS cancelReason,
  607. cdr.payWay AS payWay,
  608. rup.name AS confirmer,
  609. cdr.rebateRemarks AS rebateRemarks,
  610. cdr.shopName as shopName
  611. from
  612. cm_discern_receipt cdr
  613. left join receipt_user_permission rup on cdr.confirmUserPermissionID = rup.id
  614. where cdr.id = #{receiptID}
  615. </select>
  616. <select id="getOrderInfoByShopOrderID" resultType="com.caimei.modules.order.entity.ReceiptOrderInfoVo">
  617. select
  618. cso.orderNo AS orderNo,
  619. cso.orderID AS orderID,
  620. co.payTotalFee AS orderAmount,
  621. co.payableAmount AS payableAmount,
  622. co.onlinePayFlag,
  623. (select
  624. sum(o.needPayAmount)
  625. from cm_receipt_order_relation cror
  626. left join cm_shop_order o on cror.orderID = o.shopOrderID
  627. left join cm_discern_receipt cdr on cdr.id = cror.receiptID
  628. where o.orderID = cso.orderID and cror.delFlag = '0' and cdr.delFlag = '0'
  629. and cdr.receiptStatus = '2'
  630. ) AS receiptAmount,
  631. bou.name AS customerName,
  632. co.receiptStatus AS receiptStatus,
  633. co.orderType AS orderType,
  634. co.orderTime AS orderTime,
  635. co.userID AS userID,
  636. cso.shopOrderNo AS shopOrderNo,
  637. cso.shopOrderID AS shopOrderID,
  638. cso.needPayAmount AS shopOrderAmount,
  639. cso.shouldPayShopAmount AS shouldPayShopAmount,
  640. cso.payedShopAmount AS payedShopAmount,
  641. s.name AS shopName
  642. from cm_shop_order cso
  643. left join cm_order co on cso.orderID = co.orderID
  644. left join shop s on cso.shopID = s.shopID
  645. left join bp_order_userinfo bou on bou.orderId = cso.orderID
  646. where cso.shopOrderID = #{shopOrderID}
  647. </select>
  648. <select id="getOrderInfoByOrderID" resultType="com.caimei.modules.order.entity.ReceiptOrderInfoVo">
  649. select
  650. co.orderNo AS orderNo,
  651. co.orderID AS orderID,
  652. co.payTotalFee AS orderAmount,
  653. co.payableAmount AS payableAmount,
  654. co.onlinePayFlag,
  655. (select
  656. sum(cror.associateAmount)
  657. from cm_receipt_order_relation cror
  658. left join cm_order o on o.orderID = cror.orderID
  659. left join cm_discern_receipt cdr on cdr.id = cror.receiptID
  660. where o.orderID = co.orderID and cror.delFlag = '0' and cdr.delFlag = '0'
  661. and cdr.receiptStatus = '3'
  662. ) AS receiptAmount,
  663. bou.name AS customerName,
  664. co.receiptStatus AS receiptStatus,
  665. co.orderType AS orderType,
  666. co.orderTime AS orderTime,
  667. co.organizeID AS organizeID,
  668. co.userID AS userID
  669. from cm_order co
  670. left join bp_order_userinfo bou on bou.orderId = co.orderID
  671. where co.orderID = #{orderID}
  672. </select>
  673. <select id="findReceiptRecordByOrderID" resultType="com.caimei.modules.order.entity.ReceiptRecordVo">
  674. select
  675. cror.receiptID AS receiptID,
  676. cdr.receiptDate AS receiptTime,
  677. cdr.receiptStatus AS receiptStatus,
  678. cdr.confirmType AS confirmType,
  679. cdr.receiptType AS receiptType,
  680. cdr.payType AS payType,
  681. cdr.receiptAmount AS receiptAmount,
  682. cror.associationType AS associationType,
  683. cdr.payWay AS payWay,
  684. cdr.transactionNum AS transactionNum,
  685. cror.mbOrderId AS mbOrderId,
  686. cdr.confirmUserPermissionID AS confirmUserPermissionID,
  687. (select rup.name from receipt_user_permission rup where rup.id = cdr.confirmUserPermissionID) AS
  688. confirmUserName,
  689. cdr.confirmDate AS confirmDate,
  690. cdr.reviewUserPermissionID AS reviewUserPermissionID,
  691. (select rup.name from receipt_user_permission rup where rup.id = cdr.reviewUserPermissionID) AS reviewUserName,
  692. cdr.reviewDate AS reviewDate,
  693. cdr.cancelUserPermissionID AS cancelUserPermissionID,
  694. (select su.name from sys_user su where su.id = cdr.cancelUserPermissionID) AS cancelUserName,
  695. cdr.cancelDate AS cancelDate,
  696. cdr.cancelReason AS cancelReason
  697. from cm_receipt_order_relation cror
  698. join cm_discern_receipt cdr on cdr.id = cror.receiptID
  699. where cror.delFlag = '0' and cdr.delFlag = '0'
  700. <if test="relationType == 1">
  701. and cror.orderID in (select shopOrderID from cm_shop_order where orderID = #{orderID}) and cror.relationType
  702. = '1'
  703. </if>
  704. <if test="relationType == 2">
  705. and cror.orderID = #{orderID} and cror.relationType = '2'
  706. </if>
  707. </select>
  708. <select id="findOrderIDs" resultType="string">
  709. select orderID from cm_receipt_order_relation cror
  710. where cror.receiptID = #{receiptID} and cror.delFlag = '0' and cror.relationType = '2'
  711. </select>
  712. <select id="hasReceiptRecordOrder" resultType="string">
  713. select cror.receiptID
  714. from cm_receipt_order_relation cror
  715. join cm_discern_receipt cdr on cror.receiptID = cdr.id
  716. where cror.orderID = #{orderID} and cror.receiptID != #{receiptID}
  717. and cror.relationType = '2' and cror.delFlag = '0'
  718. and cdr.receiptStatus = '3' and cdr.delFlag = '0'
  719. </select>
  720. <select id="findShopOrderIDs" resultType="string">
  721. select cror.orderID from cm_receipt_order_relation cror
  722. where cror.receiptID = #{receiptID} and cror.delFlag = '0' and cror.relationType = '1'
  723. </select>
  724. <select id="hasReceiptRecordShopOrder" resultType="string">
  725. select cror.receiptID
  726. from cm_receipt_order_relation cror
  727. join cm_discern_receipt cdr on cror.receiptID = cdr.id
  728. where cror.orderID in
  729. (select cso2.shopOrderID
  730. from cm_shop_order cso1
  731. left join cm_shop_order cso2 on cso2.orderID = cso1.orderID
  732. where cso1.shopOrderID = #{shopOrderID} and cso2.shopOrderID != #{shopOrderID})
  733. and cror.orderID != #{shopOrderID}
  734. and cdr.receiptStatus = '2' and cdr.delFlag = '0'
  735. and cror.relationType = '1' and cror.delFlag = '0'
  736. </select>
  737. <select id="getExportInfo" resultType="com.caimei.modules.order.entity.ReceiptExportVo">
  738. -- 1订单款,2非订单款,3返佣款
  739. select
  740. (case when co.orderType = '0' then '协销' else '自主' end) AS type,
  741. (case when co.freePostFlag = '1'
  742. then co.freight else 0 end) as freight,
  743. (select sum(cop.totalAddedValueTax) from cm_order_product cop where cop.orderID = co.orderID) AS tax,
  744. <if test="t == 1">
  745. -- 1订单款
  746. co.payTotalFee AS amount,
  747. cror.associateAmount AS associateAmount,
  748. co.orderNo AS no,
  749. </if>
  750. <if test="t == 3">
  751. -- 3返佣款
  752. concat(cso.needPayAmount, '(子)') AS amount,
  753. concat(cso.needPayAmount, '(子)') AS associateAmount,
  754. concat(cso.shopOrderNo, '(子)') AS no,
  755. </if>
  756. co.orderID AS id
  757. from cm_receipt_order_relation cror
  758. left join cm_discern_receipt cdr on cror.receiptID = cdr.id
  759. <if test="t == 1">
  760. left join cm_order co on cror.orderID = co.orderID
  761. </if>
  762. <if test="t == 3">
  763. left join cm_shop_order cso on cror.orderID = cso.shopOrderID
  764. left join cm_order co on cso.orderID = co.orderID
  765. </if>
  766. where cror.receiptID = #{id} and cror.delFlag = '0'
  767. and cdr.delFlag = '0'
  768. <if test="t == 1">
  769. and cror.relationType = '2'
  770. </if>
  771. <if test="t == 3">
  772. and cror.relationType = '1'
  773. </if>
  774. </select>
  775. <select id="getReceiptRecords" resultType="integer">
  776. select cror.receiptID from cm_receipt_order_relation cror
  777. where cror.delFlag = '0' and (
  778. (cror.orderID = #{shopOrderID} and cror.relationType = '1')
  779. or
  780. (cror.orderID in (select orderID from cm_shop_order where shopOrderID = #{shopOrderID}) and cror.relationType = '2')
  781. )
  782. </select>
  783. <select id="findRebateOrderID" resultType="integer">
  784. select cso.orderID AS orderID
  785. from cm_receipt_order_relation cror left join cm_shop_order cso
  786. on cror.orderID = cso.shopOrderID
  787. LEFT JOIN cm_discern_receipt cdr ON cror.receiptID = cdr.id
  788. where cror.relationType = '1' and cror.delFlag = '0' AND cdr.receiptStatus = '2'
  789. and cdr.receiptType = '3' and cso.orderID in
  790. <foreach collection="orderIds" item="id" open="(" close=")" separator=",">
  791. #{id}
  792. </foreach>
  793. </select>
  794. <select id="findShopOrder" resultType="com.caimei.modules.order.entity.CmReceiptExport">
  795. SELECT
  796. o.orderID,
  797. o.payStatus,
  798. so.shopID,
  799. so.shopOrderID,
  800. o.orderTime,
  801. u.userName,
  802. p. NAME AS supplierName,
  803. (
  804. so.productAmount - IFNULL(so.discountAmount, 0)
  805. ) AS productFee,
  806. IFNULL(so.totalAddedValueTax,0) AS taxFee,
  807. IFNULL(so.totalAmount,0) AS receiptAmount,
  808. IFNULL(so.shopTaxFee,0) AS payTaxFee,
  809. IFNULL(so.shopPostFee,0) AS payFreight,
  810. IFNULL(so.shopOtherFee,0) AS payOther,
  811. IFNULL(so.shouldPayShopAmount,0) AS payAmount,
  812. IFNULL(so.productAmount,0) AS productAmount
  813. FROM
  814. cm_order o
  815. LEFT JOIN cm_shop_order so ON so.orderID = o.orderID
  816. LEFT JOIN user u ON u.userID = o.userID
  817. LEFT JOIN shop p ON p.shopID = so.shopID
  818. WHERE
  819. o.orderID = #{orderID}
  820. AND so.delFlag = 0
  821. AND o.delFlag = 0;
  822. </select>
  823. <select id="findSmoothoutInfo" resultType="com.caimei.modules.order.entity.CmDiscernReceipt">
  824. select * from cm_discern_receipt cdr
  825. LEFT JOIN cm_receipt_order_relation cror on cror.receiptID = cdr.id
  826. where cdr.receiptType = 1 and cror.relationType = 2 and cror.delFlag = 0
  827. and cdr.delFlag = 0 and cdr.confirmType in (1,2,3) and cdr.receiptStatus = '3'
  828. and cror.orderID = #{orderID} LIMIT 1;
  829. </select>
  830. <select id="findOrderReceipt" resultType="double">
  831. select sum(associateAmount) from cm_receipt_order_relation cror
  832. left join cm_discern_receipt cdr on cror.receiptID = cdr.id
  833. where cror.orderID = #{orderID} and cror.delFlag = '0' and cror.relationType = '2'
  834. and cdr.delFlag = '0' and cdr.receiptStatus = '3' and cdr.payWay != '3'
  835. </select>
  836. <select id="gathering" resultType="com.caimei.modules.order.entity.CmMainReceiptExport">
  837. SELECT
  838. d.receiptDate,d.payType
  839. FROM
  840. cm_receipt_order_relation r
  841. LEFT JOIN cm_discern_receipt d ON d.id = r.receiptID
  842. WHERE r.orderID=#{orderID}
  843. AND d.receiptStatus = 3
  844. AND d.delFlag = '0'
  845. AND r.delFlag = '0'
  846. </select>
  847. <select id="exportRefund" resultType="com.caimei.modules.order.entity.CmReturnedPurchase">
  848. SELECT bou.name as userName, crp.*
  849. FROM `cm_returned_purchase` crp
  850. LEFT JOIN bp_order_userinfo bou ON bou.orderId = crp.orderId
  851. <where>
  852. <if test="startTime != null and startTime != ''">
  853. AND (crp.confirmReturnTime <![CDATA[ > ]]> #{startTime} OR crp.confirmReturnTime = #{startTime})
  854. </if>
  855. <if test="endTime != null and endTime != ''">
  856. AND (crp.confirmReturnTime <![CDATA[ < ]]> #{endTime} OR crp.confirmReturnTime = #{endTime})
  857. </if>
  858. AND crp.status= 2
  859. </where>
  860. ORDER BY crp.confirmReturnTime DESC
  861. </select>
  862. <select id="theOrder" resultType="com.caimei.modules.order.entity.CmMainReceiptExport">
  863. SELECT d.receiptDate, d.payType, IFNULL(d.receiptAmount, 0) AS associateAmount
  864. , d.receiptType
  865. FROM cm_discern_receipt d
  866. <where>
  867. <if test="startTime != null and startTime != ''">
  868. AND (d.receiptDate <![CDATA[ > ]]> #{startTime} OR d.receiptDate = #{startTime})
  869. </if>
  870. <if test="endTime != null and endTime != ''">
  871. AND (d.receiptDate <![CDATA[ < ]]> #{endTime} OR d.receiptDate = #{endTime})
  872. </if>
  873. AND d.receiptStatus = 2
  874. AND d.receiptType = 2
  875. AND d.delFlag = '0'
  876. </where>
  877. ORDER BY d.receiptDate DESC;
  878. </select>
  879. <select id="findDiscernReceipt" resultType="com.caimei.modules.order.entity.CmDiscernReceipt">
  880. SELECT
  881. cdr.*
  882. FROM
  883. cm_discern_receipt cdr
  884. LEFT JOIN cm_receipt_order_relation cror ON cror.receiptID = cdr.id
  885. WHERE
  886. cdr.receiptType = 1
  887. AND cror.relationType = 2
  888. AND cdr.receiptStatus = 3
  889. AND cror.delFlag = 0
  890. AND cdr.delFlag = 0
  891. AND cror.orderID = #{orderID}
  892. ORDER BY
  893. id DESC
  894. LIMIT
  895. 1
  896. </select>
  897. <select id="findPayType" resultType="com.caimei.modules.order.entity.CmDiscernReceipt">
  898. SELECT
  899. cdr.*
  900. FROM
  901. cm_discern_receipt cdr
  902. LEFT JOIN cm_receipt_order_relation cror ON cror.receiptID = cdr.id
  903. WHERE
  904. cdr.receiptType = 1
  905. AND cror.relationType = 2
  906. AND cdr.receiptStatus = 3
  907. AND cror.delFlag = 0
  908. AND cdr.delFlag = 0
  909. AND cror.orderID = #{orderID}
  910. ORDER BY
  911. payWay ASC
  912. LIMIT
  913. 1
  914. </select>
  915. <select id="findOrderLastReceiptDetailId" resultType="java.lang.Integer">
  916. select cdr.id
  917. from cm_discern_receipt cdr
  918. left join cm_receipt_order_relation cror on cdr.id = cror.receiptID
  919. where cdr.delFlag = '0'
  920. and cror.delFlag = '0'
  921. and cror.orderID = #{orderID}
  922. order by cdr.id desc
  923. limit 1
  924. </select>
  925. <select id="findSplitTime" resultType="date">
  926. SELECT
  927. splitTime
  928. FROM
  929. cm_split_account
  930. WHERE
  931. payStatus = 1
  932. AND orderId = #{orderID}
  933. ORDER BY
  934. splitTime DESC
  935. LIMIT
  936. 1
  937. </select>
  938. <select id="getVipRecordId" resultType="java.lang.Integer">
  939. select vipRecordId from cm_receipt_order_relation where receiptID=#{receiptId}
  940. </select>
  941. <select id="getVipUserId" resultType="java.lang.Integer">
  942. select userId from cm_svip_history where id=#{vipRecordId}
  943. </select>
  944. <select id="getUserNameByUserId" resultType="java.lang.String">
  945. select userName from user where userID = #{userId} LIMIT 1
  946. </select>
  947. <select id="getReceiptVipInfo" resultType="com.caimei.modules.order.entity.ReceiptVipInfoVo">
  948. select svipr.id,
  949. svipr.userId,
  950. svipr.packageId,
  951. svipr.beginTime,
  952. svipr.endTime,
  953. svipr.price,
  954. svipr.payTime,
  955. cror.orderRequestNo,
  956. cror.vipRecordId,
  957. svipp.duration,
  958. c.name as clubName
  959. from cm_svip_history svipr
  960. left join cm_receipt_order_relation cror on svipr.id = cror.vipRecordId
  961. left join club c on svipr.userId = c.userId
  962. left join cm_svip_package svipp on svipp.id = svipr.packageId
  963. where cror.receiptID=#{receiptID}
  964. LIMIT 1
  965. </select>
  966. <select id="svipReceipt" resultType="com.caimei.modules.order.entity.CmMainReceiptExport">
  967. SELECT d.receiptDate, u.userName, d.payType, IFNULL(d.receiptAmount, 0) AS associateAmount
  968. , d.receiptType
  969. FROM cm_discern_receipt d
  970. left join cm_receipt_order_relation cror on d.id = cror.receiptID
  971. left join cm_svip_history csh on cror.vipRecordId = csh.id
  972. left join user u on csh.userId = u.userID
  973. <where>
  974. <if test="startTime != null and startTime != ''">
  975. AND (d.receiptDate <![CDATA[ > ]]> #{startTime} OR d.receiptDate = #{startTime})
  976. </if>
  977. <if test="endTime != null and endTime != ''">
  978. AND (d.receiptDate <![CDATA[ < ]]> #{endTime} OR d.receiptDate = #{endTime})
  979. </if>
  980. AND d.receiptStatus = 3
  981. AND d.receiptType = 6
  982. AND d.delFlag = '0'
  983. </where>
  984. ORDER BY d.receiptDate DESC;
  985. </select>
  986. <select id="secondReceipt" resultType="com.caimei.modules.order.entity.CmMainReceiptExport">
  987. SELECT d.receiptDate, d.payType, IFNULL(d.receiptAmount, 0) AS associateAmount
  988. , d.receiptType
  989. FROM cm_discern_receipt d
  990. <where>
  991. <if test="startTime != null and startTime != ''">
  992. AND (d.receiptDate <![CDATA[ > ]]> #{startTime} OR d.receiptDate = #{startTime})
  993. </if>
  994. <if test="endTime != null and endTime != ''">
  995. AND (d.receiptDate <![CDATA[ < ]]> #{endTime} OR d.receiptDate = #{endTime})
  996. </if>
  997. AND d.receiptStatus = 3
  998. AND d.receiptType = 7
  999. AND d.delFlag = '0'
  1000. </where>
  1001. ORDER BY d.receiptDate DESC;
  1002. </select>
  1003. <select id="getCouponInfo" resultType="com.caimei.modules.order.entity.ReceipCouponInfoVo">
  1004. SELECT c.name as clubName,cc.touchPrice,cc.couponAmount,cror.mborderId,cc.couponType,cdr.confirmDate
  1005. FROM cm_receipt_order_relation cror
  1006. LEFT JOIN cm_discern_receipt cdr ON cror.receiptID=cdr.id
  1007. LEFT JOIN cm_order co ON cror.orderId=co.orderID
  1008. LEFT JOIN club c ON co.userID=c.userID
  1009. LEFT JOIN cm_coupon_buyrecord ccb ON ccb.id=cror.couponRecordId
  1010. LEFT JOIN cm_coupon cc ON ccb.couponId=cc.id
  1011. WHERE receiptID = #{receiptID}
  1012. </select>
  1013. <select id="getShopOrderInfos" resultType="com.caimei.modules.order.entity.NewShopOrder">
  1014. select cso.shopOrderNo,shopOrderID,cso.realPay,cso.receiptAmount,cso.receiptStatus as shopReceiptStatus from cm_order co left join cm_shop_order cso on co.orderID = cso.orderID
  1015. <where>
  1016. <if test="shopOrderId != null and shopOrderId != ''">
  1017. and cso.shopOrderID = #{shopOrderId}
  1018. </if>
  1019. <if test="orderId != null and orderId != ''">
  1020. and co.orderId = #{orderId}
  1021. </if>
  1022. </where>
  1023. </select>
  1024. </mapper>