123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- <?php
- namespace App\Modules\Channel\Services;
- use App\Modules\Channel\Models\BusinessChannelDayStat;
- use DB;
- class BusinessChannelDayStatService
- {
-
- public static function createBusinessChannelDayStat($params) {
- $data = BusinessChannelDayStat::create($params);
- return $data;
- }
-
- public static function getList($params, $isAll = '') {
- $data = BusinessChannelDayStat::getList($params, $isAll);
- return $data;
- }
- public static function getAutoForceSubUserNum($channel_id,$start,$end){
- return DB::table('force_subscribe_users')
- ->where('distribution_channel_id',$channel_id)
- ->whereBetween('created_at',[$start,$end])
- ->where('official_account_id','<>',1)
- ->where('is_subscribed',1)
- ->count();
- }
- public static function getSelfForceSubUserNum($channel_id,$start,$end){
- return DB::table('force_subscribe_users')
- ->where('distribution_channel_id',$channel_id)
- ->whereBetween('created_at',[$start,$end])
- ->where('official_account_id','=',1)
- ->where('is_subscribed',1)
- ->count();
- }
- public static function getChannelSubscribeNum($channelId,$start,$end){
- $users = DB::table('users')
- ->where('distribution_channel_id',$channelId)
- ->get();
- $user_num = 0;
- foreach ($users as $user){
- $uid = ($user->id)%512;
- $chapter_orders = DB::connect('chapter_order_mysql')
- ->table('chapter_orders'.$uid)
- ->where('uid',$user->id)
- ->whereBetween('created_at',[$start,$end])
- ->first();
- if($chapter_orders){
- $user_num++;
- continue;
- }
- $book_orders = DB::table('book_orders')
- ->where('uid',$user->id)
- ->whereBetween('created_at',[$start,$end])
- ->first();
- if($book_orders){
- $user_num++;
- }
- }
- return $user_num;
- }
- public static function getChannelSubscribeRecharge($channelId,$start,$end){
- $users = DB::table('users')
- ->where('distribution_channel_id',$channelId)
- ->get();
- $fee = 0;
- foreach ($users as $user){
- $uid = ($user->id)%512;
- $chapter_orders = DB::connect('chapter_order_mysql')
- ->table('chapter_orders'.$uid)
- ->where('uid',$user->id)
- ->whereBetween('created_at',[$start,$end])
- ->sum('fee');
- $book_orders = DB::table('book_orders')
- ->where('uid',$user->id)
- ->whereBetween('created_at',[$start,$end])
- ->sum('fee');
- $fee=$fee+$chapter_orders+$book_orders;
- }
- return $fee;
- }
- }
|