ProfitsBillOrderMapper.xml 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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.ydd.module.mapper.ProfitsBillOrderMapper">
  6. <select id="selectSyncOrderShopId" resultType="java.lang.Long">
  7. SELECT
  8. o.shop_id
  9. FROM
  10. lb_waimai_order wo
  11. JOIN lb_order o ON wo.id = o.waimai_order_id
  12. WHERE
  13. wo.deleted = 0
  14. AND o.deleted = 0
  15. AND o.create_time >= #{startDate}
  16. AND #{endDate} >= o.create_time
  17. GROUP BY o.shop_id
  18. </select>
  19. <select id="selectListByShopId" resultType="com.ydd.module.dto.BillOrderDto">
  20. SELECT
  21. o.order_sn,
  22. o.shop_id,
  23. o.delivery_status,
  24. wo.status,
  25. wo.order_type
  26. FROM
  27. lb_waimai_order wo
  28. JOIN lb_order o ON wo.id = o.waimai_order_id
  29. WHERE
  30. wo.deleted = 0
  31. AND o.deleted = 0
  32. AND o.create_time >= #{startDate}
  33. AND #{endDate} >= o.create_time
  34. <if test="shopId != null">
  35. AND o.shop_id= #{shopId}
  36. </if>
  37. </select>
  38. <select id="selectBillOrderByShopId" resultType="com.ydd.module.dto.BillOrderDto">
  39. SELECT
  40. wor.shop_id,
  41. wo.status,
  42. wo.order_type
  43. FROM
  44. lb_waimai_order wo
  45. RIGHT JOIN lb_waimai_order_record wor ON wo.id = wor.waimai_order_id
  46. WHERE
  47. wo.deleted = 0
  48. AND wor.deleted = 0
  49. AND wor.create_time >= #{startDate}
  50. AND #{endDate} >= wor.create_time
  51. AND wor.shop_id= #{shopId}
  52. </select>
  53. <select id="selectBillOrderPage" resultType="com.ydd.module.dto.BillOrderDto">
  54. SELECT
  55. b.*
  56. FROM (
  57. SELECT
  58. a.*,
  59. round( ( a.order_bill_num / a.order_sync_num ), 4 ) * 100 AS orderBillRate,
  60. round( ( a.order_complete_num / a.order_sync_num ), 4 ) * 100 AS orderCompleteRate
  61. FROM (
  62. SELECT
  63. agent_id,
  64. merchant_id,
  65. shop_id,
  66. SUM(order_sync_num) AS order_sync_num,
  67. SUM(order_bill_num) AS order_bill_num,
  68. SUM(order_complete_num) AS order_complete_num
  69. FROM lb_profits_billOrder
  70. WHERE 1 = 1
  71. <if test="params.createStartTime != null and params.createStartTime != ''">
  72. AND create_time >= #{params.createStartTime}
  73. </if>
  74. <if test="params.createEndTime != null and params.createEndTime != ''">
  75. AND #{params.createEndTime} >= create_time
  76. </if>
  77. <if test="params.merchantIds != null and params.merchantIds.size > 0">
  78. AND
  79. merchant_id in
  80. <foreach collection="params.merchantIds" index="index" item="item" open="(" separator="," close=")">
  81. #{item}
  82. </foreach>
  83. </if>
  84. <if test="params.shopIds != null and params.shopIds.size > 0">
  85. AND
  86. shop_id in
  87. <foreach collection="params.shopIds" index="index" item="item" open="(" separator="," close=")">
  88. #{item}
  89. </foreach>
  90. </if>
  91. <if test="params.waimaiOrderType != null and params.waimaiOrderType != 4">
  92. AND order_type = #{params.waimaiOrderType}
  93. </if>
  94. GROUP BY
  95. shop_id
  96. ) a
  97. WHERE 1= 1
  98. <if test="params.startOrderSyncNum != null">
  99. AND a.order_sync_num >= #{params.startOrderSyncNum}
  100. </if>
  101. <if test="params.endOrderSyncNum != null">
  102. AND #{params.endOrderSyncNum} >= a.order_sync_num
  103. </if>
  104. <if test="params.startOrderCompleteRate != null">
  105. having round( ( a.order_complete_num / a.order_sync_num ), 4 ) * 100 >= #{params.startOrderCompleteRate}
  106. <if test="params.endOrderCompleteRate != null">
  107. AND #{params.endOrderCompleteRate} >= round( ( a.order_complete_num / a.order_sync_num ), 4 ) * 100
  108. </if>
  109. </if>
  110. ) b
  111. </select>
  112. </mapper>