StatisticsUserDataMapper.xml 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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.StatisticsUserDataMapper">
  4. <select id="getExportStreamingAccountData"
  5. resultType="com.cyksj.model.excel.statistics.ExcelStreamingAccountData">
  6. select count(distinct if(status = 'refund',NUll,user_id)) as numOfUser,
  7. count(if(status = 'refund',NULL,id)) as numOfOrder,
  8. cast((ifnull(sum(money),0)-ifnull(sum(refund_money),0))/100 as decimal(10,2)) as money,
  9. count(if(type = 'EX_CODE' and status != 'refund',id,NULL)) as numOfExCodeOrder,
  10. count(if(is_distribute = 1 and status != 'refund',id,NULL)) as disOrder,
  11. cast((sum(if(is_distribute = 1,money,0))-ifnull(sum(if(is_distribute = 1,refund_money,0)),0))/100 as decimal(10,2)) as disMoney
  12. from `order_don`
  13. where sku_id in (select id from `goods_don_sku` where goods_id = #{goodsId})
  14. and status not in ('close','noPayment')
  15. <if test="isDis!=null and isDis">
  16. and is_distribute = 1
  17. </if>
  18. <if test="isCode!=null and isCode">
  19. and `type` = 'EX_CODE'
  20. </if>
  21. <if test="start != null">
  22. and created_time >= #{start}
  23. </if>
  24. <if test="end != null">
  25. and created_time &lt; #{end}
  26. </if>
  27. </select>
  28. <select id="getTypeData" resultType="java.lang.Integer">
  29. select count(*) as numOfOrder from `order_don` od where
  30. sku_id in (select id from `goods_don_sku` where goods_id = #{goodsId} and spec_val like '%${type}%%'
  31. <if test="type =='月'.toString()">
  32. and spec_val not like '%年%'
  33. </if>)
  34. and status not in ('close','noPayment','refund')
  35. <if test="start != null">
  36. and created_time >= #{start}
  37. </if>
  38. <if test="end != null">
  39. and created_time &lt; #{end}
  40. </if>
  41. </select>
  42. <select id="getExportGoodsDonDataBySkuId" resultType="com.cyksj.model.excel.statistics.ExcelRealGoodsData">
  43. select count(distinct if(status = 'refund',NULL,user_id)) as numOfUser,
  44. count(if(status = 'refund',NULL,id)) as numOfOrder,
  45. cast((ifnull(sum(money),0) - ifnull(sum(refund_money),0)) / 100 as decimal(10,2)) as money
  46. from `order_don`
  47. where sku_id = #{skuId}
  48. and status not in ('close', 'noPayment')
  49. <if test="start != null">
  50. and created_time >= #{start}
  51. </if>
  52. <if test="end != null">
  53. and created_time &lt; #{end}
  54. </if>
  55. </select>
  56. <select id="getPlatformHasPaymentOrders" resultType="com.cyksj.model.entity.RegisterOrderDon">
  57. select id,
  58. platform,
  59. money,
  60. user_id
  61. from `register_order_don`
  62. where platform = #{platform}
  63. <if test="start != null">
  64. and created_time >= #{start}
  65. </if>
  66. <if test="end != null">
  67. and created_time &lt; #{end}
  68. </if>
  69. and status not in ('close', 'noPayment', 'refund')
  70. </select>
  71. </mapper>