diff --git a/application/api/controller/Cron.php b/application/api/controller/Cron.php index acb8c102..6646a45d 100644 --- a/application/api/controller/Cron.php +++ b/application/api/controller/Cron.php @@ -95,6 +95,15 @@ class Cron $cron = new \app\cron\controller\RoomHourRanking(); $cron->index(); } + //每日执行(每天23点59分执行) + /* + * 每日任务开始 + * + */ + public function DayTask(){ + $cron = new \app\cron\controller\AppTodayStatistical(); + $cron->index(); + } //临时 public function teset(){ diff --git a/application/api/model/Gift.php b/application/api/model/Gift.php index 6a7939f7..6f1cf279 100644 --- a/application/api/model/Gift.php +++ b/application/api/model/Gift.php @@ -68,7 +68,7 @@ class Gift extends Model // if($room_id){ // $is_open_blind_box_turntable = Db::name('vs_room')->where(['id'=>$room_id])->value('is_open_blind_box_turntable'); // } - $list = $this->field('gid as gift_id,gift_name,base_image,gift_price,icon')->where($map)->where($where)->order('sort asc, gift_price asc')->select(); + $list = $this->field('gid as gift_id,gift_name,base_image,gift_price,icon')->where($map)->where($where)->order('sort desc, gift_price asc')->select(); if($label==2){ $list_data = []; foreach ($list as &$v) { @@ -104,9 +104,9 @@ class Gift extends Model } } } - usort($list_data, function($a, $b) { - return $a['gift_id'] <=> $b['gift_id']; - }); +// usort($list_data, function($a, $b) { +// return $a['gift_id'] <=> $b['gift_id']; +// }); $list = $list_data; } diff --git a/application/api/model/Tasks.php b/application/api/model/Tasks.php index 3c011d8c..38726439 100644 --- a/application/api/model/Tasks.php +++ b/application/api/model/Tasks.php @@ -109,20 +109,13 @@ class Tasks extends Model //查询是否实名认证 $mobile = db::name('user')->where(['id' => $user_id,'status'=>1])->value('mobile'); $is_real = db::name('user_auth')->where('mobile' , $mobile)->field('real_name,card_id,is_real,mobile')->find(); - if(empty($is_real)){ - return ['code' => 0, 'msg' => '请先实名认证','data' => null]; - }else{ - if($is_real['is_real'] !=1){ - return ['code' => 0, 'msg' => '请先实名认证','data' => null]; + if($is_real && $is_real['is_real'] ==1){ + //查询同一个身份证下的 用户 + $user_auth_mobile = db::name('user_auth')->where(['card_id'=>$is_real['card_id']])->column('mobile'); + if(count($user_auth_mobile)>1){ + $user_ids = db::name('user')->whereIn('mobile',$user_auth_mobile)->column('id'); }else{ - //查询同一个身份证下的 用户 - $user_auth_mobile = db::name('user_auth')->where(['card_id'=>$is_real['card_id']])->column('mobile'); - if(count($user_auth_mobile)>1){ - $user_ids = db::name('user')->whereIn('mobile',$user_auth_mobile)->column('id'); - }else{ - $user_ids = db::name('user')->where('mobile',$is_real['mobile'])->column('id'); - } - + $user_ids = db::name('user')->where('mobile',$is_real['mobile'])->column('id'); } } @@ -350,7 +343,7 @@ class Tasks extends Model //判断用户是否实名认证,并查询用户手机号下的用户 $mobile = db::name('user')->where(['id' => $user_id,'status'=>1])->value('mobile'); $is_real = db::name('user_auth')->where('mobile' , $mobile)->field('real_name,card_id,is_real,mobile')->find(); - if($is_real['is_real'] ==1){ + if($is_real && $is_real['is_real'] ==1){ //查询同一个身份证下的 用户 $user_auth_mobile = db::name('user_auth')->where(['card_id'=>$is_real['card_id']])->column('mobile'); if(count($user_auth_mobile)>1){ diff --git a/application/cron/controller/AppTodayStatistical.php b/application/cron/controller/AppTodayStatistical.php new file mode 100644 index 00000000..f28d7ee1 --- /dev/null +++ b/application/cron/controller/AppTodayStatistical.php @@ -0,0 +1,78 @@ +daily_statistics(); + echo "每日12点统计用户数据结束 \n"; + + } + + + /* + * 每日12点统计用户数据 + */ + public function daily_statistics(){ + echo date('Y-m-d')."每日统计开始:\n"; + $time = strtotime(date('Y-m-d')); + $user_list = Db::name('user_wallet')->select(); + foreach ($user_list as $k=>$v){ + $gift_pack = Db::name('vs_user_gift_pack')->field('gid,num')->where(['user_id'=>$v['user_id'],'is_tester'=>1])->select(); + $gift_pack_price = 0; + foreach ($gift_pack as $key=>$val){ + $gift_pack_price += Db::name('vs_gift')->where(['gid'=>$val['gid'],])->value('gift_price')*$val['num']; + } + //用户房间今日总流水 + //用户房间id + $room_id = db::name('vs_room')->where('user_id', $v['user_id'])->value('room_id'); + $transaction = 0; + if($room_id){ + $transaction = db::name('vs_give_gift') + ->where('from_id',$room_id) + ->where('from',2) + ->whereTime('createtime', 'today') + ->sum('total_price'); + } + //公会流水 + $guild_flow_price = 0; + $guild_id = db::name('vs_guild')->where(['user_id'=>$v['user_id'],'status'=>1,'delete_time'=>0])->value('guild_id'); + if($guild_id){ + $guild_flow_price= db::name('vs_guild_flow')->where('guild_id', $guild_id)->where('day', date('Y-m-d',$time))->sum('flow_price'); + } + //充值金额 + $recharge_price = db::name('vs_user_recharge')->where('pay_status',2)->whereTime('pay_time', 'today') + ->sum('money'); + //提现 + $withdraw_price = db::name('vs_user_withdrawal')->whereIn('status',[2,6])->whereTime('createtime', 'today')->sum('money'); + $data = [ + 'user_id'=>$v['user_id'], + 'coin'=>$v['coin'], + 'earnings'=>$v['earnings'], + 'gift_pack_price'=>$gift_pack_price, + 'room_flow_price'=>$transaction, + 'guild_flow_price'=>$guild_flow_price, + 'recharge_price'=>$recharge_price, + 'withdraw_price'=>$withdraw_price, + 'day'=>date('Y-m-d',$time), + 'createtime'=>$time, + ]; + Db::name('app_today_statistical')->insert($data); + } + echo date('Y-m-d')."每日统计结束 用户数量".count($user_list)." \n"; + } +} \ No newline at end of file