OrderBaseCMapper.xml 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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.gree.mall.manager.commonmapper.workorder.OrderBaseCMapper">
  4. <select id="countOrderStatus" resultType="java.util.Map">
  5. select
  6. count(distinct a.id) 'total',
  7. order_status 'orderStatus',
  8. order_status_text 'orderStatusText'
  9. from pg_order_base a
  10. where 1=1
  11. <include refid="orderBaseSqlWhere"></include>
  12. <if test="orderSmallType != null and orderSmallType != ''">
  13. and a.order_small_type = #{orderSmallType}
  14. </if>
  15. <if test="orderSmallTypeText != null and orderSmallTypeText != ''">
  16. and a.order_small_type_text = #{orderSmallTypeText}
  17. </if>
  18. <if test="startTime != null and startTime != ''">
  19. and a.create_time between #{startTime} and #{endTime}
  20. </if>
  21. group by order_status_text
  22. union
  23. select
  24. count(distinct a.id) 'total',
  25. 'YCD' as 'orderStatus',
  26. '异常待处理' as 'orderStatusText'
  27. from pg_order_base a
  28. where is_exception=1 and a.order_status NOT IN ('YWG','YWGO','YJS')
  29. <include refid="orderBaseSqlWhere"></include>
  30. <if test="orderSmallType != null and orderSmallType != ''">
  31. and a.order_small_type = #{orderSmallType}
  32. </if>
  33. <if test="orderSmallTypeText != null and orderSmallTypeText != ''">
  34. and a.order_small_type_text = #{orderSmallTypeText}
  35. </if>
  36. <if test="startTime != null and startTime != ''">
  37. and a.create_time between #{startTime} and #{endTime}
  38. </if>
  39. union
  40. select
  41. count(distinct a.id) 'total',
  42. 'DYY' as 'orderStatus',
  43. '待预约' as 'orderStatusText'
  44. from pg_order_base a
  45. where appointment_time is null and a.order_status in('DYY','DSHPG','DWDPG','DJD')
  46. <include refid="orderBaseSqlWhere"></include>
  47. <if test="orderSmallType != null and orderSmallType != ''">
  48. and a.order_small_type = #{orderSmallType}
  49. </if>
  50. <if test="orderSmallTypeText != null and orderSmallTypeText != ''">
  51. and a.order_small_type_text = #{orderSmallTypeText}
  52. </if>
  53. <if test="startTime != null and startTime != ''">
  54. and a.create_time between #{startTime} and #{endTime}
  55. </if>
  56. union
  57. select
  58. count(distinct a.id) 'total',
  59. 'PJSQZ' AS 'orderStatus',
  60. '配件申请中' AS 'orderStatusText'
  61. from pg_order_base a join websit_parts_apply b on a.id = b.order_base_id
  62. where b.status = 'ING'
  63. <include refid="orderBaseSqlWhere"></include>
  64. <if test="orderSmallType != null and orderSmallType != ''">
  65. and a.order_small_type = #{orderSmallType}
  66. </if>
  67. <if test="orderSmallTypeText != null and orderSmallTypeText != ''">
  68. and a.order_small_type_text = #{orderSmallTypeText}
  69. </if>
  70. <if test="startTime != null and startTime != ''">
  71. and a.create_time between #{startTime} and #{endTime}
  72. </if>
  73. union
  74. select
  75. count(distinct a.id) 'total',
  76. 'PJYDH' AS 'orderStatus',
  77. '配件已到货' as 'orderStatusText'
  78. from pg_order_base a join websit_parts_apply b on a.id = b.order_base_id
  79. where b.status = 'END'
  80. <include refid="orderBaseSqlWhere"></include>
  81. <if test="orderSmallType != null and orderSmallType != ''">
  82. and a.order_small_type = #{orderSmallType}
  83. </if>
  84. <if test="orderSmallTypeText != null and orderSmallTypeText != ''">
  85. and a.order_small_type_text = #{orderSmallTypeText}
  86. </if>
  87. <if test="startTime != null and startTime != ''">
  88. and a.create_time between #{startTime} and #{endTime}
  89. </if>
  90. union
  91. select
  92. count(distinct a.id) 'total',
  93. 'PJYQX' AS 'orderStatus',
  94. '配件已取消' as 'orderStatusText'
  95. from pg_order_base a join websit_parts_apply b on a.id = b.order_base_id
  96. where b.status = 'CANCEL'
  97. <include refid="orderBaseSqlWhere"></include>
  98. <if test="orderSmallType != null and orderSmallType != ''">
  99. and a.order_small_type = #{orderSmallType}
  100. </if>
  101. <if test="orderSmallTypeText != null and orderSmallTypeText != ''">
  102. and a.order_small_type_text = #{orderSmallTypeText}
  103. </if>
  104. <if test="startTime != null and startTime != ''">
  105. and a.create_time between #{startTime} and #{endTime}
  106. </if>
  107. </select>
  108. <select id="countOrderBaseIndex" resultType="com.gree.mall.manager.bean.workorder.OrderBaseCountBean">
  109. select
  110. count(if(order_status in ('DSHPG','DWDPG'),1,null)) as 'dpg',
  111. count(if(order_status in ('DJD'),1,null)) as 'djs',
  112. count(if(order_status in ('DQD'),1,null)) as 'dqd',
  113. count(if(order_status in ('FWZ'),1,null)) as 'fwz',
  114. count(if(order_status in ('DYY'),1,null)) as 'dyy',
  115. count(if(is_exception = 1,1,null)) as 'ycdcl',
  116. count(if(appraise_status in ('C'),1,null)) as 'cp'
  117. from pg_order_base a
  118. where 1=1
  119. <include refid="orderBaseSqlWhere"></include>
  120. </select>
  121. <sql id="orderBaseSqlWhere">
  122. <if test="companyWechatId != null and companyWechatId !=''">
  123. and a.company_wechat_id = #{companyWechatId}
  124. </if>
  125. <if test="adminWebsitIds != null and adminWebsitIds.size > 0 and adminUserType != null and adminUserType == 0">
  126. AND (
  127. a.websit_id IN
  128. <foreach item="item" index="index" collection="adminWebsitIds" open="(" separator="," close=")">
  129. #{item}
  130. </foreach>
  131. or
  132. a.create_websit_id IN
  133. <foreach item="item" index="index" collection="adminWebsitIds" open="(" separator="," close=")">
  134. #{item}
  135. </foreach>
  136. )
  137. </if>
  138. </sql>
  139. <select id="countOrderStatus2" resultType="java.util.Map">
  140. SELECT
  141. COUNT(DISTINCT a.id) 'total',
  142. order_status 'orderStatus',
  143. order_status_text 'orderStatusText'
  144. FROM pg_order_base a JOIN pg_order_product b ON a.id = b.order_base_id
  145. JOIN pg_order_settle_norm c ON b.id = c.pg_order_product_id AND c.settle_norm_type IN ('INSTALL','REPAIR')
  146. WHERE 1=1
  147. <include refid="orderBaseSqlWhere"></include>
  148. <if test="orderSmallTypeText != null and orderSmallTypeText != ''">
  149. AND a.order_small_type_text = #{orderSmallTypeText}
  150. </if>
  151. GROUP BY order_status_text
  152. </select>
  153. </mapper>