|
|
@@ -321,50 +321,43 @@
|
|
|
|
|
|
<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,
|
|
|
- cast((sum(if(o.goods_id = 15,money,0)) - sum(ifnull(if(o.goods_id = 15,refund_money,0), 0))) / 100 as decimal(10,2)) as epOrderMoney,
|
|
|
- count(distinct corpUserId) as numOfUser
|
|
|
- from (select cu.id as corpUserId,
|
|
|
- cu.user_id,
|
|
|
- date_format(s.created_time, '%Y-%m-%d') as joinTime
|
|
|
- from (select relation_id,
|
|
|
- min(ct.created_time) as created_time
|
|
|
- from `corp_user_tag` ct
|
|
|
- where tag_id = #{tagIdStr}
|
|
|
- group by ct.relation_id
|
|
|
+ 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,
|
|
|
+ cast((sum(if(o.goods_id = 15,money,0)) - sum(ifnull(if(o.goods_id = 15,refund_money,0), 0))) / 100 as
|
|
|
+ decimal(10,2)) as epOrderMoney
|
|
|
+ from (select distinct cu.user_id,cu.created_time from (select DISTINCT relation_id from corp_user_tag where tag_id = #{tagIdStr})
|
|
|
+ ct inner join corp_user_follow_relation cufr on cufr.id = ct.relation_id
|
|
|
+ inner join corp_user_auth ca on ca.external_userid = cufr.corp_user_id
|
|
|
+ inner join corp_user cu on cu.id = ca.corp_user_id
|
|
|
+ where cu.user_id != 0
|
|
|
<if test="startTime != null">
|
|
|
- having date_format(min(ct.created_time), '%Y-%m-%d') >= #{startTime}
|
|
|
+ and cu.created_time >= #{startTime}
|
|
|
</if>
|
|
|
<if test="endTime != null">
|
|
|
- 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
|
|
|
- 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
|
|
|
+ and cu.created_time < #{endTime}
|
|
|
+ </if>)
|
|
|
+ cu inner join order_don o on o.user_id = cu.user_id
|
|
|
+ and o.`status` not in ('close','noPayment')
|
|
|
+ AND o.money > 0
|
|
|
+ and o.created_time > cu.created_time
|
|
|
<if test="consumeStTime != null">
|
|
|
- and date_format(o.created_time, '%Y-%m-%d') >= #{consumeStTime}
|
|
|
+ and o.created_time >= #{consumeStTime}
|
|
|
</if>
|
|
|
<if test="consumeEtTime != null">
|
|
|
- and date_format(o.created_time, '%Y-%m-%d') < #{consumeEtTime}
|
|
|
+ and o.created_time < #{consumeEtTime}
|
|
|
</if>
|
|
|
</select>
|
|
|
|
|
|
<select id="getTagUserDataPage" resultType="com.cyksj.model.views.UserOrderDetailView">
|
|
|
- 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 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 date_format(cu.created_time, '%Y-%m-%d') as `date`,
|
|
|
+ count(distinct cu.id) as numOfUser
|
|
|
+ from (select distinct cu.id, cu.user_id, cu.created_time
|
|
|
+ from (select DISTINCT relation_id from corp_user_tag where tag_id = #{tagIdStr}) ct
|
|
|
+ inner join corp_user_follow_relation cufr on cufr.id = ct.relation_id
|
|
|
+ inner join corp_user_auth ca on ca.external_userid = cufr.corp_user_id
|
|
|
+ inner join corp_user cu on cu.id = ca.corp_user_id) cu
|
|
|
+ group by date_format(cu.created_time, '%Y-%m-%d')
|
|
|
+ order by date_format(cu.created_time, '%Y-%m-%d') desc
|
|
|
</select>
|
|
|
|
|
|
<select id="getTagUserTimeOrderData" resultType="com.cyksj.model.views.CorpTagUserOrderDataView">
|
|
|
@@ -372,18 +365,12 @@
|
|
|
(select nickname from user u where u.id = o.user_id limit 1),
|
|
|
o.order_no,o.goods_id,g.title,o.sku_id,sku.spec_val,
|
|
|
o.money/100 as money,o.created_time
|
|
|
- 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
|
|
|
- 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
|
|
|
+ from (select distinct cu.user_id, date_format(cu.created_time, '%Y-%m-%d') joinTime
|
|
|
+ from (select DISTINCT relation_id from corp_user_tag where tag_id = #{tagIdStr}) ct
|
|
|
+ inner join corp_user_follow_relation cufr on cufr.id = ct.relation_id
|
|
|
+ inner join corp_user_auth ca on ca.external_userid = cufr.corp_user_id
|
|
|
+ inner join corp_user cu on cu.id = ca.corp_user_id
|
|
|
+ where cu.user_id != 0) cu inner join order_don o on o.user_id = cu.user_id
|
|
|
and o.status not in ('close', 'noPayment','refund')
|
|
|
and date_format(o.created_time, '%Y-%m-%d') = joinTime
|
|
|
and o.money > 0
|
|
|
@@ -450,65 +437,54 @@
|
|
|
</select>
|
|
|
|
|
|
<select id="getPastRecord" resultType="com.cyksj.model.views.UserOrderDetailView">
|
|
|
- select date_format(o.created_time,'%Y-%m-%d') 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
|
|
|
- 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 where cu.user_id != 0)s
|
|
|
- inner 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') >= joinTime
|
|
|
- and o.money > 0
|
|
|
- group by date_format(o.created_time,'%Y-%m-%d')
|
|
|
- order by date_format(o.created_time,'%Y-%m-%d') desc
|
|
|
+ select date_format(o.created_time, '%Y-%m-%d') 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 distinct cu.user_id, cu.created_time
|
|
|
+ from (select DISTINCT relation_id from corp_user_tag where tag_id = #{tagIdStr}) ct
|
|
|
+ inner join corp_user_follow_relation cufr on cufr.id = ct.relation_id
|
|
|
+ inner join corp_user_auth ca on ca.external_userid = cufr.corp_user_id
|
|
|
+ inner join corp_user cu on cu.id = ca.corp_user_id
|
|
|
+ where cu.user_id != 0) cu
|
|
|
+ inner join order_don o
|
|
|
+ on o.user_id = cu.user_id
|
|
|
+ and o.`status` not in ('close', 'noPayment')
|
|
|
+ AND money > 0
|
|
|
+ and o.created_time > cu.created_time
|
|
|
+ group by date_format(o.created_time, '%Y-%m-%d')
|
|
|
+ order by date_format(o.created_time, '%Y-%m-%d') desc
|
|
|
</select>
|
|
|
|
|
|
<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
|
|
|
- <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
|
|
|
+ select count(distinct cu.id) as numOfUser,
|
|
|
+ count(distinct if(cufr.status = 0,cu.id,NULL)) as delNumOfUser
|
|
|
+ from (select distinct relation_id from `corp_user_tag` where tag_id = #{tagIdStr}) s
|
|
|
inner join corp_user_follow_relation cufr on cufr.id = s.relation_id
|
|
|
+ inner join corp_user_auth ca on ca.external_userid = cufr.corp_user_id
|
|
|
+ inner join corp_user cu on cu.id = ca.corp_user_id
|
|
|
+ <where>
|
|
|
+ <if test="startTime != null">
|
|
|
+ cu.created_time >= #{startTime}
|
|
|
+ </if>
|
|
|
+ <if test="endTime != null">
|
|
|
+ and cu.created_time < #{endTime}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
</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
|
|
|
+ from (select distinct cu.user_id, cu.created_time
|
|
|
+ from (select DISTINCT relation_id from corp_user_tag where tag_id = #{tagIdStr}) ct
|
|
|
+ inner join corp_user_follow_relation cufr on cufr.id = ct.relation_id
|
|
|
+ inner join corp_user_auth ca on ca.external_userid = cufr.corp_user_id
|
|
|
+ inner join corp_user cu on cu.id = ca.corp_user_id
|
|
|
+ where cu.user_id != 0) cu
|
|
|
+ inner join order_don o on o.user_id = cu.user_id
|
|
|
+ and o.`status` not in ('close', 'noPayment')
|
|
|
+ AND money > 0
|
|
|
+ and date_format(o.created_time, '%Y-%m-%d') = date_format(cu.created_time, '%Y-%m-%d')
|
|
|
+ and date_format(o.created_time, '%Y-%m-%d') = #{date}
|
|
|
</select>
|
|
|
</mapper>
|