|
|
@@ -535,4 +535,35 @@
|
|
|
and o.created_time < #{endDate}
|
|
|
</if>
|
|
|
</select>
|
|
|
+
|
|
|
+ <select id="getDistributeOrderView" resultType="com.cyksj.model.views.DistributeOrderStatisticsDataView">
|
|
|
+ select user_id, goods_id, nickname, `date`, money
|
|
|
+ from (
|
|
|
+ select us.shared_id as user_id,
|
|
|
+ o.goods_id,
|
|
|
+ (select nickname from `user` where id = us.shared_id limit 1) as nickname,
|
|
|
+ date_format(o.created_time,'%Y-%m-%d') `date`,
|
|
|
+ sum(money)/100 as money,
|
|
|
+ row_number() over (partition by date_format(o.created_time,'%Y-%m-%d') order by sum(money) desc) as rn
|
|
|
+ from user_distribute_shared us
|
|
|
+ <if test="isGeneral != null">
|
|
|
+ left join user_distribute ud on ud.user_id = us.shared_id and ud.deleted
|
|
|
+ </if>
|
|
|
+ inner join order_don o on o.user_Id = us.user_id
|
|
|
+ where o.`status` not in ('close','noPayment','refund')
|
|
|
+ and o.created_time BETWEEN #{start} and #{end}
|
|
|
+ and o.goods_id = #{goodsId} and o.is_fixed_distribute
|
|
|
+ <if test="isGeneral != null">
|
|
|
+ <if test="isGeneral">
|
|
|
+ and ud.id is null
|
|
|
+ </if>
|
|
|
+ <if test="!isGeneral">
|
|
|
+ and ud.id is not null
|
|
|
+ </if>
|
|
|
+ </if>
|
|
|
+ group by us.shared_id,o.goods_id,date_format(o.created_time,'%Y-%m-%d')
|
|
|
+ ) ranked
|
|
|
+ where rn <= 5
|
|
|
+ order by `date` asc, money desc
|
|
|
+ </select>
|
|
|
</mapper>
|