|
|
@@ -319,7 +319,7 @@
|
|
|
</if>
|
|
|
</select>
|
|
|
|
|
|
- <select id="getTagUserData" resultType="com.cyksj.model.views.UserOrderDetailView">
|
|
|
+ <select id="getTagUserOrdersData" resultType="com.cyksj.model.views.UserOrderDetailView">
|
|
|
select count(if(status != 'refund', 1, NULL)) as numOfOrder,
|
|
|
cast((sum(money) - sum(ifnull(refund_money, 0))) / 100 as decimal(10,2)) as orderMoney,
|
|
|
count(if(status != 'refund' and o.goods_id = 15,1,NULL)) as numOfEpOrder,
|
|
|
@@ -334,43 +334,35 @@
|
|
|
where tag_id = #{tagIdStr}
|
|
|
group by ct.relation_id
|
|
|
<if test="startTime != null">
|
|
|
- having min(ct.created_time) >= #{startTime}
|
|
|
+ having date_format(min(ct.created_time), '%Y-%m-%d') >= #{startTime}
|
|
|
</if>
|
|
|
<if test="endTime != null">
|
|
|
- and min(ct.created_time) < #{endTime}
|
|
|
+ and date_format(min(ct.created_time), '%Y-%m-%d') < #{endTime}
|
|
|
</if>) s
|
|
|
left join corp_user_follow_relation cufr on cufr.id = s.relation_id
|
|
|
left join corp_user_auth ca on ca.external_userid = cufr.corp_user_id
|
|
|
left join corp_user cu on cu.id = ca.corp_user_id) s
|
|
|
- left join order_don o on o.user_id = s.user_id and o.user_id != 0
|
|
|
+ inner join order_don o on o.user_id = s.user_id and o.user_id != 0
|
|
|
and o.status not in ('close', 'noPayment')
|
|
|
and o.money > 0
|
|
|
and date_format(o.created_time, '%Y-%m-%d') >= joinTime
|
|
|
<if test="consumeStTime != null">
|
|
|
- and o.created_time >= #{consumeStTime}
|
|
|
+ and date_format(o.created_time, '%Y-%m-%d') >= #{consumeStTime}
|
|
|
</if>
|
|
|
<if test="consumeEtTime != null">
|
|
|
- and o.created_time < #{consumeEtTime}
|
|
|
+ and date_format(o.created_time, '%Y-%m-%d') < #{consumeEtTime}
|
|
|
</if>
|
|
|
</select>
|
|
|
|
|
|
<select id="getTagUserDataPage" resultType="com.cyksj.model.views.UserOrderDetailView">
|
|
|
- select joinTime as `date`,
|
|
|
- count(if(status != 'refund', 1, NULL)) as numOfOrder,
|
|
|
- cast((ifnull(sum(money), 0) - sum(ifnull(refund_money, 0))) / 100 as decimal(10, 2)) as orderMoney
|
|
|
- from (select cu.id as corpUserId, cu.user_id, date_format(s.created_time, '%Y-%m-%d') joinTime
|
|
|
- from (select relation_id, min(ct.created_time) as created_time
|
|
|
+ select joinTime as `date`,
|
|
|
+ count(distinct corp_user_id) as numOfUser
|
|
|
+ from (select cufr.corp_user_id, date_format(s.created_time, '%Y-%m-%d') joinTime
|
|
|
+ from (select relation_id, min(created_time) as created_time
|
|
|
from `corp_user_tag` ct
|
|
|
where tag_id = #{tagIdStr}
|
|
|
- group by ct.relation_id) s
|
|
|
- left join corp_user_follow_relation cufr on cufr.id = s.relation_id
|
|
|
- left join corp_user_auth ca on ca.external_userid = cufr.corp_user_id
|
|
|
- left join corp_user cu on cu.id = ca.corp_user_id) s
|
|
|
- inner join order_don o
|
|
|
- on o.user_id = s.user_id and o.user_id != 0
|
|
|
- and o.status not in ('close','noPayment')
|
|
|
- and date_format(o.created_time, '%Y-%m-%d') = joinTime
|
|
|
- and o.money > 0
|
|
|
+ group by relation_id) s
|
|
|
+ inner join corp_user_follow_relation cufr on cufr.id = s.relation_id) s
|
|
|
group by joinTime
|
|
|
order by joinTime desc
|
|
|
</select>
|
|
|
@@ -480,13 +472,43 @@
|
|
|
order by date_format(o.created_time,'%Y-%m-%d') desc
|
|
|
</select>
|
|
|
|
|
|
- <select id="getNumOfTagFansUser" resultType="java.lang.Integer">
|
|
|
- select count(distinct cufr.corp_user_id)
|
|
|
+ <select id="getNumOfTagFansUser" resultType="com.cyksj.model.views.UserOrderDetailView">
|
|
|
+ select count(distinct cufr.corp_user_id) as numOfUser,
|
|
|
+ count(distinct if(cufr.status = 0,cufr.corp_user_id,NULL)) as delNumOfUser
|
|
|
from (select relation_id
|
|
|
- from `corp_user_tag` ct
|
|
|
- where tag_id = #{tagIdStr}
|
|
|
- group by relation_id
|
|
|
- HAVING date_format(min(ct.created_time), '%Y-%m-%d') = #{date}) s
|
|
|
- inner join corp_user_follow_relation cufr on cufr.id = s.relation_id
|
|
|
+ from `corp_user_tag` ct
|
|
|
+ where tag_id = #{tagIdStr}
|
|
|
+ group by relation_id
|
|
|
+ <if test="startTime != null">
|
|
|
+ having min(ct.created_time) >= #{startTime}
|
|
|
+ </if>
|
|
|
+ <if test="endTime != null">
|
|
|
+ and min(ct.created_time) < #{endTime}
|
|
|
+ </if>
|
|
|
+ <if test="date != null">
|
|
|
+ HAVING date_format(min(ct.created_time), '%Y-%m-%d') = #{date}
|
|
|
+ </if>
|
|
|
+ ) s
|
|
|
+ inner join corp_user_follow_relation cufr on cufr.id = s.relation_id
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="getFansToDayOrdersView" resultType="com.cyksj.model.views.UserOrderDetailView">
|
|
|
+ select count(if(status != 'refund', 1, NULL)) as numOfOrder,
|
|
|
+ cast((ifnull(sum(money), 0) - sum(ifnull(refund_money, 0))) / 100 as decimal(10, 2)) as orderMoney
|
|
|
+ from (select cu.user_id
|
|
|
+ from (select relation_id
|
|
|
+ from `corp_user_tag` ct
|
|
|
+ where tag_id = #{tagIdStr}
|
|
|
+ group by ct.relation_id
|
|
|
+ having date_format(min(created_time), '%Y-%m-%d') = #{date}) s
|
|
|
+ left join corp_user_follow_relation cufr on cufr.id = s.relation_id
|
|
|
+ left join corp_user_auth ca on ca.external_userid = cufr.corp_user_id
|
|
|
+ left join corp_user cu on cu.id = ca.corp_user_id
|
|
|
+ where cu.user_id != 0) s
|
|
|
+ left join order_don o
|
|
|
+ on o.user_id = s.user_id
|
|
|
+ and o.status not in ('close', 'noPayment')
|
|
|
+ and date_format(o.created_time, '%Y-%m-%d') = #{date}
|
|
|
+ and o.money > 0
|
|
|
</select>
|
|
|
</mapper>
|