StatisticsExportMapper.xml 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
  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.cyksj.mapper.manage.statistics.StatisticsExportMapper">
  4. <select id="getMonthNfExNumOfUser" resultType="java.lang.Integer">
  5. select count(distinct user_id)
  6. from (select user_id
  7. from `order_don`
  8. where sku_id = 4
  9. and status not in ('close', 'noPayment', 'refund')
  10. and created_time between #{lastMonth} and #{thisMonth}
  11. union all
  12. select user_id
  13. from `order_don`
  14. where sku_id = 5
  15. and status not in ('close', 'noPayment', 'refund')
  16. and created_time between #{lastThreeMonth} and #{lastTwoMonth}
  17. union all
  18. select user_id
  19. from `order_don`
  20. where sku_id = 6
  21. and status not in ('close', 'noPayment', 'refund')
  22. and created_time between #{lastYearMonth}
  23. and #{lastElevMonth}
  24. ) s
  25. </select>
  26. <select id="getMonthNfExNumOfUserByType" resultType="java.lang.Integer">
  27. select count(distinct user_id)
  28. from (select user_id
  29. from `order_don`
  30. where sku_id = 4
  31. and status not in ('close', 'noPayment', 'refund')
  32. and created_time between #{lastMonth} and #{thisMonth}
  33. union all
  34. select user_id
  35. from `order_don`
  36. where sku_id = 5
  37. and status not in ('close', 'noPayment', 'refund')
  38. and created_time between #{lastThreeMonth} and #{lastTwoMonth}
  39. union all
  40. select user_id
  41. from `order_don`
  42. where sku_id = 6
  43. and status not in ('close', 'noPayment', 'refund')
  44. and created_time between #{lastYearMonth}
  45. and #{lastElevMonth}) s
  46. where EXISTS(select id
  47. from order_don od
  48. where status not in ('close', 'refund', 'noPayment')
  49. and created_time between #{thisMonth} and #{nextMonth}
  50. and order_type = #{type}
  51. and od.user_id = s.user_id
  52. and goods_id = #{goodsId})
  53. </select>
  54. <select id="getMonthNfRenewNumOfUser" resultType="java.lang.Integer">
  55. select count(distinct user_id)
  56. from `order_don`
  57. where goods_id = #{goodsId}
  58. and order_type = 2
  59. and status not in ('close', 'refund', 'noPayment')
  60. and created_time between #{thisMonth} and #{nextMonth}
  61. </select>
  62. <select id="getAiMonthPlus" resultType="java.lang.Long">
  63. select id
  64. from `goods_don_sku`
  65. where goods_id = #{goodsId}
  66. and months = 1
  67. </select>
  68. <select id="getMonthAiExNumOfUser" resultType="java.lang.Integer">
  69. select count(distinct user_id)
  70. from `order_don` od
  71. where status not in ('close','noPayment')
  72. and (refund_money is null or refund_money != money)
  73. and created_time BETWEEN #{lastMonth} and #{thisMonth}
  74. and sku_id in
  75. <foreach collection="skuIds" item="item" open="(" separator="," close=")">
  76. #{item}
  77. </foreach>
  78. </select>
  79. <select id="getMonthAiExNumOfUserByType" resultType="java.lang.Integer">
  80. select count(distinct user_id) from (select user_id
  81. from `order_don` od
  82. where status not in ('close','noPayment')
  83. and (refund_money is null or refund_money != money)
  84. and created_time BETWEEN #{lastMonth} and #{thisMonth}
  85. and sku_id in
  86. <foreach collection="skuIds" item="item" open="(" separator="," close=")">
  87. #{item}
  88. </foreach>) s where EXISTS(select id
  89. from order_don
  90. where status not in ('close','noPayment')
  91. and (refund_money is null or refund_money != money)
  92. and created_time between #{thisMonth} and #{nextMonth}
  93. and order_type = #{type}
  94. and user_id = s.user_id
  95. and sku_id in
  96. <foreach collection="skuIds" item="item" open="(" separator="," close=")">
  97. #{item}
  98. </foreach>
  99. )
  100. </select>
  101. <select id="getMonthAiRenewNumOfUser" resultType="java.lang.Integer">
  102. select count(distinct user_id)
  103. from `order_don` od
  104. where status not in ('close','noPayment')
  105. and (refund_money is null or refund_money != money)
  106. and created_time BETWEEN #{thisMonth} and #{nextMonth}
  107. and order_type = 2
  108. and sku_id in
  109. <foreach collection="skuIds" item="item" open="(" separator="," close=")">
  110. #{item}
  111. </foreach>
  112. </select>
  113. <select id="getMonthStreamingNewNumOfUser" resultType="java.lang.Integer">
  114. select count(DISTINCT user_id)
  115. from (select user_id, created_time
  116. from `order_don`
  117. where goods_id in
  118. (select goods_id
  119. from `goods_don_category_relate`
  120. where category = 2)
  121. and status not in ('close', 'refund', 'noPayment')
  122. and created_time BETWEEN
  123. #{thisMonth} and #{nextMonth}) s
  124. where not EXISTS(select id
  125. from order_don od
  126. where status not in ('close', 'refund', 'noPayment')
  127. and od.user_id = s.user_id
  128. and od.created_time &lt;
  129. s.created_time)
  130. </select>
  131. <select id="getMonthStreamingNewPayOtherNumOfUser" resultType="java.lang.Integer">
  132. select count(DISTINCT user_id)
  133. from (select user_id, created_time
  134. from `order_don`
  135. where goods_id in
  136. (select goods_id
  137. from `goods_don_category_relate`
  138. where category = 2)
  139. and status not in ('close', 'refund', 'noPayment')
  140. and created_time BETWEEN
  141. #{thisMonth} and #{nextMonth}) s
  142. where not EXISTS(select id
  143. from order_don od
  144. where status not in ('close', 'refund', 'noPayment')
  145. and od.user_id = s.user_id
  146. and od.created_time &lt;
  147. s.created_time)
  148. and EXISTS(select id
  149. from order_don od
  150. where status not in ('close', 'refund', 'noPayment')
  151. and od.user_id = s.user_id
  152. and od.created_time between
  153. #{thisMonth} and #{nextMonth}
  154. and od.created_time > s.created_time)
  155. </select>
  156. <select id="getMonthStreamingNewPayAiNumOfUser" resultType="java.lang.Integer">
  157. select count(DISTINCT user_id)
  158. from (select user_id, created_time
  159. from `order_don`
  160. where goods_id in
  161. (select goods_id
  162. from `goods_don_category_relate`
  163. where category = 2)
  164. and status not in ('close', 'refund', 'noPayment')
  165. and created_time BETWEEN
  166. #{thisMonth} and #{nextMonth}) s
  167. where not EXISTS(select id
  168. from order_don od
  169. where status not in ('close', 'refund', 'noPayment')
  170. and od.user_id = s.user_id
  171. and od.created_time &lt;
  172. s.created_time)
  173. and EXISTS(select id
  174. from (select id, goods_id
  175. from order_don od
  176. where status not in ('close', 'refund', 'noPayment')
  177. and od.user_id = s.user_id
  178. and od.created_time between #{thisMonth} and #{nextMonth}
  179. order by od.created_time limit 1,1) s
  180. where s.goods_id in (select goods_id
  181. from `goods_don_category_relate`
  182. where category = 1))
  183. </select>
  184. <select id="getMonthAiNewNumOfUser" resultType="java.lang.Integer">
  185. select count(DISTINCT user_id)
  186. from (select user_id, created_time
  187. from `order_don`
  188. where goods_id in
  189. (select goods_id
  190. from `goods_don_category_relate`
  191. where category = 1)
  192. and status not in ('close', 'refund', 'noPayment')
  193. and created_time BETWEEN
  194. #{thisMonth} and #{nextMonth}) s
  195. where not EXISTS(select id
  196. from order_don od
  197. where status not in ('close', 'refund', 'noPayment')
  198. and od.user_id = s.user_id
  199. and od.created_time &lt;
  200. s.created_time)
  201. </select>
  202. <select id="getMonthAiNewPayOtherNumOfUser" resultType="java.lang.Integer">
  203. select count(DISTINCT user_id)
  204. from (select user_id, created_time
  205. from `order_don`
  206. where goods_id in
  207. (select goods_id
  208. from `goods_don_category_relate`
  209. where category = 1)
  210. and status not in ('close', 'refund', 'noPayment')
  211. and created_time BETWEEN
  212. #{thisMonth} and #{nextMonth}) s
  213. where not EXISTS(select id
  214. from order_don od
  215. where status not in ('close', 'refund', 'noPayment')
  216. and od.user_id = s.user_id
  217. and od.created_time &lt;
  218. s.created_time)
  219. and EXISTS(select id
  220. from order_don od
  221. where status not in ('close', 'refund', 'noPayment')
  222. and od.user_id = s.user_id
  223. and od.created_time between #{thisMonth} and #{nextMonth}
  224. and od.created_time > s.created_time)
  225. </select>
  226. <select id="getMonthAiNewPayStreamingNumOfUser" resultType="java.lang.Integer">
  227. select count(DISTINCT user_id)
  228. from (select user_id, created_time
  229. from `order_don`
  230. where goods_id in
  231. (select goods_id
  232. from `goods_don_category_relate`
  233. where category = 1)
  234. and status not in ('close', 'refund', 'noPayment')
  235. and created_time BETWEEN
  236. #{thisMonth} and #{nextMonth}) s
  237. where not EXISTS(select id
  238. from order_don od
  239. where status not in ('close', 'refund', 'noPayment')
  240. and od.user_id = s.user_id
  241. and od.created_time &lt;
  242. s.created_time)
  243. and EXISTS(select id
  244. from (select id, goods_id
  245. from order_don od
  246. where status not in ('close', 'refund', 'noPayment')
  247. and od.user_id = s.user_id
  248. and od.created_time between #{thisMonth} and #{nextMonth}
  249. order by od.created_time limit 1,1) s
  250. where s.goods_id in (select goods_id
  251. from `goods_don_category_relate`
  252. where category = 2))
  253. </select>
  254. <select id="getMonthPrivateCorpNumOfUser" resultType="java.lang.Integer">
  255. select count(distinct s.user_id) from (select user_id from (select user_id,created_time from `order_don` where
  256. goods_id in
  257. (select id from goods_don
  258. <where>
  259. <if test="category!=null">
  260. and category = #{category}
  261. </if>
  262. <if test="type!=null">
  263. and `type` = #{type}
  264. </if>
  265. </where>
  266. )
  267. and status not in ('close','noPayment','refund')) s where not exists (select id from `order_don` where status
  268. not
  269. in ('close','noPayment','refund')
  270. and user_id= s.user_id and created_time &lt; s.created_time)) s inner join user u on u.id = s.user_id and
  271. u.unionid != '' inner join corp_user cu on cu.user_id =
  272. u.id
  273. inner join corp_user_auth ca on ca.corp_user_id = cu.id and ca.wx_corp_id = 2
  274. </select>
  275. <select id="getShouldApplyMoney" resultType="java.math.BigDecimal">
  276. select sum(points) / 1000
  277. from `distribute_waiting_send_points`
  278. where send_status = 'success'
  279. and created_time &lt; #{endDate}
  280. </select>
  281. <select id="getRealApplyMoney" resultType="java.math.BigDecimal">
  282. select sum(money) / 100
  283. from `distribute_money_apply`
  284. where `verify_status` = 'success'
  285. and created_time &lt; #{endDate}
  286. </select>
  287. <select id="getMonthUserSourceNumByType" resultType="java.lang.Integer">
  288. select count(u.id)
  289. from (select id from `user` where created_time >= #{startDate} and created_time &lt; #{endDate}) u
  290. left join user_distribute_shared us on us.user_id = u.id
  291. left join user_distribute ud on ud.user_id = us.shared_id
  292. <where>
  293. <choose>
  294. <when test="type == 1">
  295. us.id is null
  296. </when>
  297. <otherwise>
  298. us.id is not null
  299. </otherwise>
  300. </choose>
  301. </where>
  302. </select>
  303. <select id="getNfTicketNumOfUser" resultType="java.lang.Integer">
  304. select count(distinct user_id)
  305. from `order_don`
  306. where goods_id = #{goodsId}
  307. and status not in ('close', 'noPayment', 'refund')
  308. </select>
  309. <select id="getAiTicketNumOfUser" resultType="java.lang.Integer">
  310. select count(distinct o.user_id)
  311. from `order_don` o
  312. left join goods_don g on g.id = o.goods_id
  313. where g.id in (select goods_id
  314. from `goods_don_category_relate`
  315. where category = 1)
  316. and o.status not in ('close', 'noPayment', 'refund')
  317. </select>
  318. <select id="getNfAiTicketNumOfUser" resultType="java.lang.Integer">
  319. select count(distinct o.user_id)
  320. from `order_don` o
  321. left join order_don o2 on o2.user_id = o.user_id
  322. left join goods_don g on g.id = o2.goods_id
  323. where o.goods_id = #{goodsId}
  324. and o.status not in ('close', 'noPayment', 'refund')
  325. and o2.status not in ('close', 'noPayment', 'refund')
  326. and g.id in (select goods_id
  327. from `goods_don_category_relate`
  328. where category = 1)
  329. </select>
  330. <select id="getMonthAmountOfOrderByType" resultType="java.math.BigDecimal">
  331. select ifnull((sum(o.money) - ifnull(sum(o.refund_money),0))/100,0) from `order_don` o left join `user_distribute_shared`
  332. us on us.user_id = o.user_Id
  333. left join `user_distribute` ud on ud.user_id = us.shared_id and ud.deleted is true
  334. where
  335. <choose>
  336. <when test="type == 1">
  337. us.id is null
  338. </when>
  339. <when test="type == 2">
  340. us.id is not null and ud.id is null
  341. </when>
  342. <when test="type == 3">
  343. ud.id is not null
  344. </when>
  345. </choose>
  346. and o.created_time >= #{startDate} and o.created_time &lt; #{endDate}
  347. and status not in ('close', 'noPayment')
  348. </select>
  349. <select id="getMonthGoodsTypeAmountOfOrderByType" resultType="java.math.BigDecimal">
  350. select ifnull((sum(o.money) - ifnull(sum(o.refund_money),0))/100,0) from `order_don` o left join `user_distribute_shared`
  351. us on us.user_id = o.user_Id
  352. left join `user_distribute` ud on ud.user_id = us.shared_id and ud.deleted is true
  353. where
  354. <choose>
  355. <when test="type == 1">
  356. us.id is null
  357. </when>
  358. <when test="type == 4">
  359. us.id is not null
  360. <if test="isBind != null">
  361. and us.is_bind = 0
  362. </if>
  363. </when>
  364. <otherwise>
  365. us.id is not null
  366. <if test="isBind != null">
  367. and us.is_bind = 1
  368. </if>
  369. </otherwise>
  370. </choose>
  371. <if test="startDate != null">
  372. and o.created_time >= #{startDate}
  373. </if>
  374. <if test="endDate != null">
  375. and o.created_time &lt; #{endDate}
  376. </if>
  377. and status not in ('close', 'noPayment')
  378. and goods_id in (select id from goods_don
  379. <where>
  380. <if test="goodsType != null">
  381. `type` = #{goodsType}
  382. </if>
  383. <if test="category!=null">
  384. and id in (select goods_id from goods_don_category_relate where category = #{category})
  385. </if>
  386. </where>
  387. )
  388. </select>
  389. <select id="getMonthUserSourceNumOrderByType" resultType="java.lang.Integer">
  390. select count(distinct s.id) from (select u.id
  391. from (select id from `user` where created_time >= #{startDate} and created_time &lt; #{endDate}) u
  392. left join user_distribute_shared us on us.user_id = u.id
  393. left join user_distribute ud on ud.user_id = us.shared_id
  394. <where>
  395. <choose>
  396. <when test="type == 1">
  397. us.id is null
  398. </when>
  399. <otherwise>
  400. us.id is not null
  401. </otherwise>
  402. </choose>
  403. </where>
  404. ) s left join order_don o on o.user_id = s.id where o.status not in ('close', 'noPayment','refund')
  405. and o.created_time >= #{startDate} and o.created_time &lt; #{endDate}
  406. </select>
  407. <select id="getAppleOneDataThisMonth" resultType="com.cyksj.model.excel.statistics.ExcelAppleOneData">
  408. select count(distinct if(status = 'refund',NUll,user_id)) as numOfUser,
  409. count(if(status = 'refund',NULL,id)) as numOfOrder,
  410. cast((ifnull(sum(money),0)-ifnull(sum(refund_money),0))/100 as decimal(10,2)) as money,
  411. count(if(type = 'EX_CODE' and status != 'refund',id,NULL)) as numOfExCodeOrder,
  412. count(if(is_distribute = 1 and status != 'refund',id,NULL)) as disOrder,
  413. cast((sum(if(is_distribute = 1,money,0))-ifnull(sum(if(is_distribute = 1,refund_money,0)),0))/100 as
  414. decimal(10,2)) as disMoney
  415. from `order_don`
  416. where sku_id in
  417. <foreach collection="skuIds" item="item" open="(" separator="," close=")">
  418. #{item}
  419. </foreach>
  420. and status not in ('close','noPayment')
  421. <if test="startDate != null">
  422. and created_time >= #{startDate}
  423. </if>
  424. <if test="endDate != null">
  425. and created_time &lt; #{endDate}
  426. </if>
  427. </select>
  428. <select id="getAppleOnePayMonthTypeOrderThisMonth" resultType="java.lang.Integer">
  429. select count(*) from `order_don` where sku_id = #{skuId}
  430. and status not in ('close','noPayment','refund')
  431. <if test="startDate != null">
  432. and created_time >= #{startDate}
  433. </if>
  434. <if test="endDate != null">
  435. and created_time &lt; #{endDate}
  436. </if>
  437. </select>
  438. <select id="getTransferData" resultType="java.util.Map">
  439. select sum(if(money &lt;= 40000, money, 0)) autoMoney,
  440. sum(if(type = 'usdt', money, 0)) usdtMoney,
  441. sum(if(money > 40000 and type != 'usdt', money, 0)) manualMoney
  442. from distribute_money_apply
  443. where created_time >= #{startDate}
  444. and created_time &lt; #{endDate}
  445. and verify_status = 'success'
  446. </select>
  447. <select id="getGroupsOrderData" resultType="com.cyksj.model.dto.NatureOrderDataDto">
  448. select type,
  449. ifnull((sum(money) - ifnull(sum(refund_money),0))/100,0) as money from (select money,
  450. refund_money,
  451. (case
  452. when us.id is null then 1
  453. when us.id is not null and ud.id is null then 2
  454. when ud.id is not null and us.is_bind = 1 then 3
  455. when ud.id is not null and us.is_bind = 0 then 4
  456. else 1
  457. end) as `type`
  458. from `order_don` o
  459. left join `user_distribute_shared` us on us.user_id = o.user_Id
  460. left join `user_distribute` ud on ud.user_id = us.shared_id and ud.deleted is true
  461. where status not in ('close', 'noPayment')
  462. <if test="startDate != null">
  463. and o.created_time >= #{startDate}
  464. </if>
  465. <if test="endDate != null">
  466. and o.created_time &lt; #{endDate}
  467. </if>) s group by `type`
  468. </select>
  469. <select id="getMonthlyUserOrderDetail" resultType="com.cyksj.model.dto.MonthlyUserOrderDetailDto">
  470. select cast(((sum(money) - sum(ifnull(refund_money, 0))) / 100) as decimal(10,2)) as money,
  471. count(if(`status` != 'refund', 1, NUll)) as orders,
  472. 1 type
  473. from `order_don` o
  474. left join user u on u.id = o.user_id
  475. where o.status not in ('close', 'noPayment')
  476. and o.created_time BETWEEN #{thisMonth} and #{nextMonth}
  477. and u.created_time &lt; #{thisMonth}
  478. union all
  479. select cast(((sum(money) - sum(ifnull(refund_money, 0))) / 100) as decimal(10,2)) as money,
  480. count(if(`status` != 'refund', 1, NUll)) as orders,
  481. 2 type
  482. from `order_don` o
  483. left join user u on u.id = o.user_id
  484. where o.status not in ('close', 'noPayment')
  485. and o.created_time BETWEEN #{thisMonth} and #{nextMonth}
  486. and u.created_time BETWEEN #{thisMonth} and #{nextMonth}
  487. </select>
  488. <select id="getEpOrderNumsGroupSource" resultType="java.util.Map">
  489. select count(if(is_distribute = 0,1,NULL)) naturalEpOrders,count(if(is_distribute = 1,1,NULL)) distributeOrders
  490. from order_don
  491. where status not in ('close', 'noPayment', 'refund')
  492. and goods_id = 15
  493. <if test="startDate != null">
  494. and created_time >= #{startDate}
  495. </if>
  496. <if test="endDate != null">
  497. and created_time &lt; #{endDate}
  498. </if>
  499. group by DATE_FORMAT(created_time, '%Y-%m')
  500. </select>
  501. <select id="getOverPayByGoodsId" resultType="java.lang.Integer">
  502. select count(DISTINCT user_id)
  503. from order_don o
  504. where created_time &lt; #{lastMonth}
  505. <if test="goodsId !=null">
  506. and goods_id = #{goodsId}
  507. </if>
  508. <if test="skuIds!=null">
  509. and sku_id in
  510. <foreach collection="skuIds" item="item" open="(" separator="," close=")">
  511. #{item}
  512. </foreach>
  513. </if>
  514. and `status` not in ('close', 'noPayment', 'refund')
  515. and NOT EXISTS (select 1
  516. from order_don
  517. where created_time BETWEEN #{lastMonth} and #{thisMonth}
  518. and `status` not in ('close', 'noPayment', 'refund')
  519. AND user_id = o.user_id
  520. <if test="goodsId !=null">
  521. and goods_id = #{goodsId}
  522. </if>
  523. <if test="skuIds!=null">
  524. and sku_id in
  525. <foreach collection="skuIds" item="item" open="(" separator="," close=")">
  526. #{item}
  527. </foreach>
  528. </if>
  529. )
  530. and EXISTS (select 1
  531. from order_don
  532. where created_time BETWEEN #{thisMonth} and #{nextMonth}
  533. and `status` not in ('close', 'noPayment', 'refund')
  534. and user_id = o.user_id
  535. <if test="goodsId !=null">
  536. and goods_id = #{goodsId}
  537. </if>
  538. <if test="skuIds!=null">
  539. and sku_id in
  540. <foreach collection="skuIds" item="item" open="(" separator="," close=")">
  541. #{item}
  542. </foreach>
  543. </if>
  544. )
  545. </select>
  546. <select id="getYearNumOfRenewalsByGoodsId" resultType="java.lang.Integer">
  547. select count(distinct user_id)
  548. from order_don
  549. where created_time BETWEEN #{lastYearMonth} and #{lastElevMonth}
  550. and `status` not in ('close', 'noPayment', 'refund')
  551. and goods_id = #{goodsId}
  552. </select>
  553. <select id="getActualNumberOfRenewalsByGoodsId" resultType="java.lang.Integer">
  554. select count(distinct user_id)
  555. from order_don o
  556. where created_time BETWEEN #{lastYearMonth} and #{lastElevMonth}
  557. and `status` not in ('close', 'noPayment', 'refund')
  558. and goods_id = #{goodsId}
  559. and exists (select 1 from order_don where created_time > #{lastElevMonth}
  560. and `status` not in ('close', 'noPayment', 'refund')
  561. and goods_id = #{goodsId} and user_id = o.user_id limit 1)
  562. </select>
  563. </mapper>