|
@@ -348,7 +348,7 @@
|
|
|
<select id="getMonthAmountOfOrderByType" resultType="java.math.BigDecimal">
|
|
<select id="getMonthAmountOfOrderByType" resultType="java.math.BigDecimal">
|
|
|
select ifnull((sum(o.money) - ifnull(sum(o.refund_money),0))/100,0) from `order_don` o left join `user_distribute_shared`
|
|
select ifnull((sum(o.money) - ifnull(sum(o.refund_money),0))/100,0) from `order_don` o left join `user_distribute_shared`
|
|
|
us on us.user_id = o.user_Id
|
|
us on us.user_id = o.user_Id
|
|
|
- left join `user_distribute` ud on ud.user_id = us.shared_id
|
|
|
|
|
|
|
+ left join `user_distribute` ud on ud.user_id = us.shared_id and ud.deleted is true
|
|
|
where
|
|
where
|
|
|
<choose>
|
|
<choose>
|
|
|
<when test="type == 1">
|
|
<when test="type == 1">
|
|
@@ -368,14 +368,23 @@
|
|
|
<select id="getMonthGoodsTypeAmountOfOrderByType" resultType="java.math.BigDecimal">
|
|
<select id="getMonthGoodsTypeAmountOfOrderByType" resultType="java.math.BigDecimal">
|
|
|
select ifnull((sum(o.money) - ifnull(sum(o.refund_money),0))/100,0) from `order_don` o left join `user_distribute_shared`
|
|
select ifnull((sum(o.money) - ifnull(sum(o.refund_money),0))/100,0) from `order_don` o left join `user_distribute_shared`
|
|
|
us on us.user_id = o.user_Id
|
|
us on us.user_id = o.user_Id
|
|
|
- left join `user_distribute` ud on ud.user_id = us.shared_id
|
|
|
|
|
|
|
+ left join `user_distribute` ud on ud.user_id = us.shared_id and ud.deleted is true
|
|
|
where
|
|
where
|
|
|
<choose>
|
|
<choose>
|
|
|
<when test="type == 1">
|
|
<when test="type == 1">
|
|
|
us.id is null
|
|
us.id is null
|
|
|
</when>
|
|
</when>
|
|
|
|
|
+ <when test="type == 4">
|
|
|
|
|
+ us.id is not null
|
|
|
|
|
+ <if test="isBind != null">
|
|
|
|
|
+ and us.is_bind = 0
|
|
|
|
|
+ </if>
|
|
|
|
|
+ </when>
|
|
|
<otherwise>
|
|
<otherwise>
|
|
|
us.id is not null
|
|
us.id is not null
|
|
|
|
|
+ <if test="isBind != null">
|
|
|
|
|
+ and us.is_bind = 1
|
|
|
|
|
+ </if>
|
|
|
</otherwise>
|
|
</otherwise>
|
|
|
</choose>
|
|
</choose>
|
|
|
<if test="startDate != null">
|
|
<if test="startDate != null">
|
|
@@ -466,12 +475,13 @@
|
|
|
(case
|
|
(case
|
|
|
when us.id is null then 1
|
|
when us.id is null then 1
|
|
|
when us.id is not null and ud.id is null then 2
|
|
when us.id is not null and ud.id is null then 2
|
|
|
- when ud.id is not null then 3
|
|
|
|
|
|
|
+ when ud.id is not null and us.is_bind = 1 then 3
|
|
|
|
|
+ when ud.id is not null and us.is_bind = 0 then 4
|
|
|
else 1
|
|
else 1
|
|
|
end) as `type`
|
|
end) as `type`
|
|
|
from `order_don` o
|
|
from `order_don` o
|
|
|
left join `user_distribute_shared` us on us.user_id = o.user_Id
|
|
left join `user_distribute_shared` us on us.user_id = o.user_Id
|
|
|
- left join `user_distribute` ud on ud.user_id = us.shared_id
|
|
|
|
|
|
|
+ left join `user_distribute` ud on ud.user_id = us.shared_id and ud.deleted is true
|
|
|
where status not in ('close', 'noPayment')
|
|
where status not in ('close', 'noPayment')
|
|
|
<if test="startDate != null">
|
|
<if test="startDate != null">
|
|
|
and o.created_time >= #{startDate}
|
|
and o.created_time >= #{startDate}
|
|
@@ -480,4 +490,39 @@
|
|
|
and o.created_time < #{endDate}
|
|
and o.created_time < #{endDate}
|
|
|
</if>) s group by `type`
|
|
</if>) s group by `type`
|
|
|
</select>
|
|
</select>
|
|
|
|
|
+
|
|
|
|
|
+ <select id="getMonthlyUserOrderDetail" resultType="com.cyksj.model.dto.MonthlyUserOrderDetailDto">
|
|
|
|
|
+ select cast(((sum(money) - sum(ifnull(refund_money, 0))) / 100) as decimal(10,2)) as money,
|
|
|
|
|
+ count(if(`status` != 'refund', 1, NUll)) as orders,
|
|
|
|
|
+ 1 type
|
|
|
|
|
+ from `order_don` o
|
|
|
|
|
+ left join user u on u.id = o.user_id
|
|
|
|
|
+
|
|
|
|
|
+ where o.status not in ('close', 'noPayment')
|
|
|
|
|
+ and o.created_time BETWEEN #{thisMonth} and #{nextMonth}
|
|
|
|
|
+ and u.created_time < #{thisMonth}
|
|
|
|
|
+ union all
|
|
|
|
|
+ select cast(((sum(money) - sum(ifnull(refund_money, 0))) / 100) as decimal(10,2)) as money,
|
|
|
|
|
+ count(if(`status` != 'refund', 1, NUll)) as orders,
|
|
|
|
|
+ 2 type
|
|
|
|
|
+ from `order_don` o
|
|
|
|
|
+ left join user u on u.id = o.user_id
|
|
|
|
|
+ where o.status not in ('close', 'noPayment')
|
|
|
|
|
+ and o.created_time BETWEEN #{thisMonth} and #{nextMonth}
|
|
|
|
|
+ and u.created_time BETWEEN #{thisMonth} and #{nextMonth}
|
|
|
|
|
+ </select>
|
|
|
|
|
+
|
|
|
|
|
+ <select id="getEpOrderNumsGroupSource" resultType="java.util.Map">
|
|
|
|
|
+ select count(if(is_distribute = 0,1,NULL)) naturalEpOrders,count(if(is_distribute = 1,1,NULL)) distributeOrders
|
|
|
|
|
+ from order_don
|
|
|
|
|
+ where status not in ('close', 'noPayment', 'refund')
|
|
|
|
|
+ and goods_id = 15
|
|
|
|
|
+ <if test="startDate != null">
|
|
|
|
|
+ and created_time >= #{startDate}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="endDate != null">
|
|
|
|
|
+ and created_time < #{endDate}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ group by DATE_FORMAT(created_time, '%Y-%m')
|
|
|
|
|
+ </select>
|
|
|
</mapper>
|
|
</mapper>
|