|
|
@@ -22,71 +22,10 @@ import java.util.List;
|
|
|
@Mapper
|
|
|
public interface PlatformBillMapper extends BaseMapper<PlatformBill> {
|
|
|
|
|
|
- @Insert("INSERT INTO `tcwm2.5`.platform_bill \n" +
|
|
|
- "(day_id, user_id, shop_name, `type`, start_money, revenue, revenue_count, \n" +
|
|
|
- "shop_payouts, shop_payouts_rates, shop_payouts_count, rider_payouts, rider_payouts_rates,\n" +
|
|
|
- "rider_payouts_count, refund_money, refund_count, end_money,sys_gift_amount, platform_rates,total_income,pay_money,create_time,update_time)\n" +
|
|
|
- "select #{dayId}, tu.user_id, null,2,null,sum(ti.rider_money),count(ti.rider_money),null,null,null,\n" +
|
|
|
- "sum(co.money),sum(co.rate), count(co.money),null,null,max(tu.balance),\n" +
|
|
|
- "(select sum(money) b from user_money_details ud1 where ud1.user_id =tu.user_id and ud1.title like '系统赠送%' \n" +
|
|
|
- "and ud1.create_time>#{startTime} and ud1.create_time <=#{endTime})\n" +
|
|
|
- "-(select sum(money) a from user_money_details ud2 where ud2.user_id =tu.user_id and ud2.title like '系统扣除%' \n" +
|
|
|
- "and ud2.create_time>#{startTime} and ud2.create_time <= #{endTime}) as gift_amount,null,\n" +
|
|
|
- "sum(ti.rider_money),null,#{now},#{now}\n" +
|
|
|
- "from tb_user tu USE INDEX(tb_user_rider_open_id_IDX)\n" +
|
|
|
- "left join tb_indent ti USE INDEX(tb_indent_finish_time_IDX) on \n" +
|
|
|
- " ti.finish_time >#{startTime} \n" +
|
|
|
- "and ti.finish_time <= #{endTime}\n" +
|
|
|
- "and ti.rider_user_id =tu.user_id\n" +
|
|
|
- "and ti.indent_state ='6'\n" +
|
|
|
- "left join cash_out co on co.user_id =tu.user_id and co.type =1 and co.state=1\n" +
|
|
|
- "and co.out_at >#{startTime} \n" +
|
|
|
- "and co.out_at <=#{endTime}\n" +
|
|
|
- "where tu.rider_open_id is not null \n" +
|
|
|
- "group by tu.user_id \n" +
|
|
|
- "union all \n" +
|
|
|
- "select #{dayId}, tu.user_id, null,1,null,sum(tor.shop_income_money),count(tor.shop_income_money),\n" +
|
|
|
- "sum(co.money),sum(co.rate),count(co.money),null,null,null,sum(to1.pay_money),count(to1.pay_money),max(um.money),\n" +
|
|
|
- "(select sum(money) b from user_money_details ud1 where ud1.user_id =tu.user_id and ud1.title like '系统赠送%' \n" +
|
|
|
- "and ud1.create_time>#{startTime} and ud1.create_time <=#{endTime})\n" +
|
|
|
- "-(select sum(money) a from user_money_details ud2 where ud2.user_id =tu.user_id and ud2.title like '系统扣除%' \n" +
|
|
|
- "and ud2.create_time>#{startTime} and ud2.create_time <=#{endTime}) as gift_amount\n" +
|
|
|
- ",sum(tor.shop_income_money*(1-gs.shop_rate)/gs.shop_rate) platform_rates,sum(tor.shop_income_money),\n" +
|
|
|
- "sum(tor.pay_money),#{now},#{now} \n" +
|
|
|
- "from tb_user tu \n" +
|
|
|
- "left join goods_shop gs on tu.user_id =gs.user_id\n" +
|
|
|
- "left join tb_order tor USE INDEX(tb_order_update_time_IDX) on gs.shop_id =tor.shop_id \n" +
|
|
|
- "and tor.update_time >#{startTime}\n" +
|
|
|
- "and tor.update_time <=#{endTime}\n" +
|
|
|
- "and tor.status=4\n" +
|
|
|
- "left join tb_order to1 USE INDEX(tb_order_update_time_IDX) on gs.shop_id =to1.shop_id \n" +
|
|
|
- "and to1.update_time >#{startTime}\n" +
|
|
|
- "and to1.update_time <=#{endTime}\n" +
|
|
|
- "and to1.status in(5,8)\n" +
|
|
|
- "left join cash_out co on co.user_id =tu.user_id and co.type =2 and co.state=1\n" +
|
|
|
- "and co.out_at >#{startTime} \n" +
|
|
|
- "and co.out_at <=#{endTime}\n" +
|
|
|
- "left join user_money um on um.user_id =tu.user_id\n" +
|
|
|
- "where tu.admin_user_id is not null\n" +
|
|
|
- "group by tu.user_id ")
|
|
|
Integer insertPlatformBill(@Param("dayId") String dayId,@Param("startTime") String startTime, @Param("endTime")String endTime, @Param("now") String now);
|
|
|
|
|
|
- @Update("update platform_bill a join platform_bill b on a.user_id =b.user_id and a.type =b.type and TO_DAYS(a.day_id)-TO_DAYS(b.day_id)= 1 " +
|
|
|
- "set a.start_money=b.end_money,a.end_money=b.end_money+a.end_money\n" +
|
|
|
- "where a.day_id =#{dayId} ")
|
|
|
- Integer updateStartMoney(@Param("dayId") String dayId);
|
|
|
+ Integer updateShopStartMoney(@Param("dayId") String dayId);
|
|
|
|
|
|
- @Insert("INSERT INTO `tcwm2.5`.platform_bill \n" +
|
|
|
- "(day_id, user_id, shop_name, `type`, start_money, revenue, revenue_count, \n" +
|
|
|
- "shop_payouts, shop_payouts_rates, shop_payouts_count, rider_payouts, rider_payouts_rates,\n" +
|
|
|
- "rider_payouts_count, refund_money, refund_count, end_money,sys_gift_amount, platform_rates,total_income,pay_money,create_time,update_time)\n" +
|
|
|
- "select\n" +
|
|
|
- "day_id,null,null,0,sum(if(type=1, start_money ,0)),sum(if(type=1, revenue,0)),sum(if(type=1, revenue_count,0)),\n" +
|
|
|
- "sum(if(type=1, shop_payouts ,0)),sum(if(type=1, shop_payouts_rates ,0)),sum(if(type=1, shop_payouts_count ,0)),\n" +
|
|
|
- "sum(if(type=2, rider_payouts ,0)),sum(if(type=2, rider_payouts_rates ,0)),sum(if(type=2, rider_payouts_count ,0)),\n" +
|
|
|
- "sum(if(type=1, refund_money ,0)),sum(if(type=1, refund_count ,0)),sum(if(type=1, end_money ,0)),null,\n" +
|
|
|
- "sum(if(type=1, platform_rates ,0)),null,null,max(create_time) ,max(update_time) \n" +
|
|
|
- "from platform_bill pb where day_id =#{dayId}\n")
|
|
|
Integer insertTotalPlatformBill(@Param("dayId") String dayId);
|
|
|
|
|
|
IPage<PlatformBill> platformBill(@Param("page")Page<PlatformBill> pages, @Param("params")PlatformBillDto platformBillDto);
|
|
|
@@ -100,4 +39,6 @@ public interface PlatformBillMapper extends BaseMapper<PlatformBill> {
|
|
|
List<ShopBillVo> excelShopBillList(@Param("params") PlatformBillDto query);
|
|
|
|
|
|
List<PlatformBill> excelPlatformBillList(@Param("params") PlatformBillDto query);
|
|
|
+
|
|
|
+ Integer updateRiderStartMoney(@Param("dayId") String dayId);
|
|
|
}
|