sum('gold'); //总充值金额(人民币)各支付充值+客服代充(每笔资金备注充值来源,支付宝 微信 客服代充等) $total_recharge_money = Db::name('user_wallet')->sum('pay_money'); //今天总充值金额 $today_recharge_gold = $mt_user_gold_log->where(['log_type' => ['in', [1, 10]], 'change_value' => ['gt', 0], 'createtime' => ['egt', $start]])->sum('change_value'); //昨天总充值金额 $yesterday_recharge_gold = $mt_user_gold_log->where(['log_type' => ['in', [1, 10]], 'change_value' => ['gt', 0], 'createtime' => ['between', [$start - 86400, $start - 1]]])->sum('change_value'); //今天总消耗金币 $today_use_gold = $mt_user_gold_log->where(['change_value' => ['lt', 0], 'createtime' => ['egt', $start]])->sum('change_value'); $today_use_gold = abs($today_use_gold); //昨日总消耗金币 $yesterday_use_gold = $mt_user_gold_log->where(['change_value' => ['lt', 0], 'createtime' => ['between', [$start - 86400, $start - 1]]])->sum('change_value'); $yesterday_use_gold = abs($yesterday_use_gold); //累计总消耗金币 $total_use_gold = $mt_user_gold_log->where(['change_value' => ['lt', 0]])->sum('change_value'); $total_use_gold = abs($total_use_gold); //今天总提现/今天总提现支出 $today_withdraw = Db::name('take_cash')->where(['status' => 1, 'createtime' => ['egt', $start]])->sum('number'); $today_withdraw_ava = Db::name('take_cash')->where(['status' => 1, 'createtime' => ['egt', $start]])->sum('money'); //昨日总提现/昨日总提现支出 $yesterday_withdraw = Db::name('take_cash')->where(['status' => 1, 'createtime' => ['between', [$start - 86400, $start - 1]]])->sum('number'); $yesterday_withdraw_ava = Db::name('take_cash')->where(['status' => 1, 'createtime' => ['between', [$start - 86400, $start - 1]]])->sum('money'); //累计总提现/累计总提现支出 $total_withdraw = Db::name('take_cash')->where(['status' => 1])->sum('number'); $total_withdraw_ava = Db::name('take_cash')->where(['status' => 1])->sum('money'); //今天总兑换金币 $today_exchange_gold = $mt_user_gold_log->where(['log_type' => 19, 'createtime' => ['egt', $start]])->sum('change_value'); //昨日总兑换金币 $yesterday_exchange_gold = $mt_user_gold_log->where(['log_type' => 19, 'createtime' => ['between', [$start - 86400, $start - 1]]])->sum('change_value'); //累计总兑换金币 $total_exchange_gold = $mt_user_gold_log->where(['log_type' => 19])->sum('change_value'); //用户下载注册统计 //男用户统计 //总数 $man_num = Db::name('user')->where(['gender' => 1])->count('id'); //今日注册 $today_man_num = Db::name('user')->where(['gender' => 1, 'createtime' => ['egt', $start]])->count('id'); //昨日注册 $yesterday_man_num = Db::name('user')->where(['gender' => 1, 'createtime' => ['between', [$start - 86400, $start - 1]]])->count('id'); //注册来源 //明确注册来源的数量 $from_man_num = Db::name('user')->where(['gender' => 1, 'register_from' => ['neq', '']])->count('id'); //ios数量 $ios_from_man_num = Db::name('user')->where(['gender' => 1, 'register_from' => 'iOS'])->count('id'); //安卓数量 $android_from_man_num = $from_man_num - $ios_from_man_num; //女用户统计 //总数 $woman_num = Db::name('user')->where(['gender' => 0])->count('id'); //今日注册 $today_woman_num = Db::name('user')->where(['gender' => 0, 'createtime' => ['egt', $start]])->count('id'); //昨日注册 $yesterday_woman_num = Db::name('user')->where(['gender' => 0, 'createtime' => ['between', [$start - 86400, $start - 1]]])->count('id'); //注册来源 //明确注册来源的数量 $from_woman_num = Db::name('user')->where(['gender' => 0, 'register_from' => ['neq', '']])->count('id'); //ios数量 $ios_from_woman_num = Db::name('user')->where(['gender' => 0, 'register_from' => 'iOS'])->count('id'); //安卓数量 $android_from_woman_num = $from_woman_num - $ios_from_woman_num; //邀请奖励 邀请充值奖励和邀请收益分开统计 $today = day_now(); $yesterday = day_yesterday(); //邀请收益总奖励 //今日邀请收益 //昨日邀请收益 68 $userMoneyLog = Db::name('user_money_log'); $inviteWhere['log_type'] = 68; $inviteTotal = $userMoneyLog->where($inviteWhere)->sum('change_value'); $inviteNow = $userMoneyLog->where($inviteWhere)->where(['createtime' => ['between', [$today[0],$today[1]]]])->sum('change_value'); $inviteYesterday = $userMoneyLog->where($inviteWhere)->where(['createtime' => ['between', [$yesterday[0],$yesterday[1]]]])->sum('change_value'); //邀请充值总奖励 今日邀请充值收益 昨日邀请充值收益 65 $inviteRechargeWhere['log_type'] = 65; $inviteRechargeTotal = $userMoneyLog->where($inviteRechargeWhere)->sum('change_value'); $inviteRechargeNow = $userMoneyLog->where($inviteRechargeWhere)->where(['createtime' => ['between', [$today[0],$today[1]]]])->sum('change_value'); $inviteRechargeYesterday = $userMoneyLog->where($inviteRechargeWhere)->where(['createtime' => ['between', [$yesterday[0],$yesterday[1]]]])->sum('change_value'); //送金币 //男 任务总送金币 //今日送金币 //昨日送金币 20 //充会员送金币 //今日充值送金币 //昨日充值送金币 14 //总送金币 14,17,20,41,101 $goldTaskWhere['g.log_type'] = ['in',[14,17,20,41,101]]; $goldTaskField = 'g.id,u.gender,g.change_value,g.log_type,g.createtime'; //$goldModelObj = $mt_user_gold_log->alias('g')->field($goldTaskField)->join('user u','u.id = g.user_id','LEFT')->where($goldTaskWhere)->select(); $goldModelObj = Cache::remember('admin_statis_gold_log',function () use ($mt_user_gold_log,$goldTaskField,$goldTaskWhere){ return $mt_user_gold_log->alias('g')->field($goldTaskField)->join('user u','u.id = g.user_id','LEFT')->where($goldTaskWhere)->select(); },20); $manGoldTaskTotal = $manGoldTaskNow = $manGoldTaskYesterday = $manGoldTotal = $goldTotal = 0; $manGoldRechargeTotal = $manGoldRechargeNow = $manGoldRechargeYesterday = 0; $manGoldSignTotal = $manGoldSignNow = $manGoldSignYesterday = 0; $womanGoldTaskTotal = $womanGoldTaskNow = $womanGoldTaskYesterday = $womanGoldTotal = 0; $womanGoldRechargeTotal = $womanGoldRechargeNow = $womanGoldRechargeYesterday = 0; $womanGoldSignTotal = $womanGoldSignNow = $womanGoldSignYesterday = 0; if (!empty($goldModelObj)) { foreach ($goldModelObj as $goldKey =>$goldValue) { if ($goldValue['gender'] == 1) {//男用户 if (in_array($goldValue['log_type'],[20])) {//任务送金币 if ($goldValue['createtime'] >= $today[0] && $goldValue['createtime'] < $today[1]) {//今天 $manGoldTaskNow = bcadd($manGoldTaskNow,$goldValue['change_value']); } elseif ($goldValue['createtime'] >= $yesterday[0] && $goldValue['createtime'] < $yesterday[1]) {//昨天 $manGoldTaskYesterday = bcadd($manGoldTaskYesterday,$goldValue['change_value']); } $manGoldTaskTotal = bcadd($manGoldTaskTotal,$goldValue['change_value']); } elseif (in_array($goldValue['log_type'],[14,17,101])) {//充值送金币 if ($goldValue['createtime'] >= $today[0] && $goldValue['createtime'] < $today[1]) {//今天 $manGoldRechargeNow = bcadd($manGoldRechargeNow,$goldValue['change_value']); } elseif ($goldValue['createtime'] >= $yesterday[0] && $goldValue['createtime'] < $yesterday[1]) {//昨天 $manGoldRechargeYesterday = bcadd($manGoldRechargeYesterday,$goldValue['change_value']); } $manGoldRechargeTotal = bcadd($manGoldRechargeTotal,$goldValue['change_value']); } elseif (in_array($goldValue['log_type'],[41])) {//签到送金币 if ($goldValue['createtime'] >= $today[0] && $goldValue['createtime'] < $today[1]) {//今天 $manGoldSignNow = bcadd($manGoldSignNow,$goldValue['change_value']); } elseif ($goldValue['createtime'] >= $yesterday[0] && $goldValue['createtime'] < $yesterday[1]) {//昨天 $manGoldSignYesterday = bcadd($manGoldSignYesterday,$goldValue['change_value']); } $manGoldSignTotal = bcadd($manGoldSignTotal,$goldValue['change_value']); } $manGoldTotal = bcadd($manGoldTotal,$goldValue['change_value']); } elseif ($goldValue['gender'] == 0) {//女用户 if (in_array($goldValue['log_type'],[20])) {//任务送金币 if ($goldValue['createtime'] >= $today[0] && $goldValue['createtime'] < $today[1]) {//今天 $womanGoldTaskNow = bcadd($womanGoldTaskNow, $goldValue['change_value']); } elseif ($goldValue['createtime'] >= $yesterday[0] && $goldValue['createtime'] < $yesterday[1]) {//昨天 $womanGoldTaskYesterday = bcadd($womanGoldTaskYesterday, $goldValue['change_value']); } $womanGoldTaskTotal = bcadd($womanGoldTaskTotal, $goldValue['change_value']); } elseif (in_array($goldValue['log_type'],[14,17,101])) {//充值送金币 if ($goldValue['createtime'] >= $today[0] && $goldValue['createtime'] < $today[1]) {//今天 $womanGoldRechargeNow = bcadd($womanGoldRechargeNow,$goldValue['change_value']); } elseif ($goldValue['createtime'] >= $yesterday[0] && $goldValue['createtime'] < $yesterday[1]) {//昨天 $womanGoldRechargeYesterday = bcadd($womanGoldRechargeYesterday,$goldValue['change_value']); } $womanGoldRechargeTotal = bcadd($womanGoldRechargeTotal,$goldValue['change_value']); } elseif (in_array($goldValue['log_type'],[41])) {//签到送金币 if ($goldValue['createtime'] >= $today[0] && $goldValue['createtime'] < $today[1]) {//今天 $womanGoldSignNow = bcadd($womanGoldSignNow,$goldValue['change_value']); } elseif ($goldValue['createtime'] >= $yesterday[0] && $goldValue['createtime'] < $yesterday[1]) {//昨天 $womanGoldSignYesterday = bcadd($womanGoldSignYesterday,$goldValue['change_value']); } $womanGoldSignTotal = bcadd($womanGoldSignTotal,$goldValue['change_value']); } $womanGoldTotal = bcadd($womanGoldTotal,$goldValue['change_value']); } } } $goldTotal = bcadd($manGoldTotal,$womanGoldTotal);//总送金币 //充值 //微信 总充值 //今日充值 //昨日充值 //$userGoldLog = Db::name('user_gold_log'); $wechatTotal = $wechatNow = $wechatYesterday = 0.00; $payOrder = Db::name('pay_order'); $payOrderWhere['status'] = 1; $payOrderWhere['type'] = 'recharge_gold'; $payOrderWhere['payment_class'] = 'wechat'; $wechatTotal = $payOrder->where($payOrderWhere)->sum('money'); $wechatNow = $payOrder->where($payOrderWhere)->where(['createtime' => ['between', [$today[0],$today[1]]]])->sum('money'); $wechatYesterday = $payOrder->where($payOrderWhere)->where(['createtime' => ['between', [$yesterday[0],$yesterday[1]]]])->sum('money'); //支付宝 总充值 //今日充值 //昨日充值 /*$goldLogWhere['log_type'] = 10; $goldLogWhere['remark'] = ['like','%支付宝%']; $alipayTotal = $userGoldLog->where($goldLogWhere)->sum('change_value'); $alipayNow = $userGoldLog->where($goldLogWhere)->where(['createtime' => ['between', [$today[0],$today[1]]]])->sum('change_value'); $alipayYesterday = $userGoldLog->where($goldLogWhere)->where(['createtime' => ['between', [$yesterday[0],$yesterday[1]]]])->sum('change_value');*/ $payOrder = Db::name('pay_order'); $payOrderWhere['status'] = 1; $payOrderWhere['type'] = 'recharge_gold'; $payOrderWhere['payment_class'] = 'alipay'; $alipayTotal = $payOrder->where($payOrderWhere)->sum('money'); $alipayNow = $payOrder->where($payOrderWhere)->where(['createtime' => ['between', [$today[0],$today[1]]]])->sum('money'); $alipayYesterday = $payOrder->where($payOrderWhere)->where(['createtime' => ['between', [$yesterday[0],$yesterday[1]]]])->sum('money'); $statistics = [ 'invite_total' => $inviteTotal,//邀请奖励余额 'invite_now' => $inviteNow, 'invite_yesterday' => $inviteYesterday, 'invite_recharge_total' => $inviteRechargeTotal,//邀请充值奖励余额 'invite_recharge_now' => $inviteRechargeNow, 'invite_recharge_yesterday' => $inviteRechargeYesterday, 'man_gold_task_total' => $manGoldTaskTotal,//男任务送金币 'man_gold_task_now' => $manGoldTaskNow, 'man_gold_task_yesterday' => $manGoldTaskYesterday, 'man_gold_recharge_total' => $manGoldRechargeTotal,//男充值送金币 'man_gold_recharge_now' => $manGoldRechargeNow, 'man_gold_recharge_yesterday' => $manGoldRechargeYesterday, 'man_gold_sign_total' => $manGoldSignTotal,//男签到送金币 'man_gold_sign_now' => $manGoldSignNow, 'man_gold_sign_yesterday' => $manGoldSignYesterday, 'man_gold_total' => $manGoldTotal, 'woman_gold_task_total' => $womanGoldTaskTotal,//女任务送金币 'woman_gold_task_now' => $womanGoldTaskNow, 'woman_gold_task_yesterday' => $womanGoldTaskYesterday, 'woman_gold_recharge_total' => $womanGoldRechargeTotal,//女充值送金币 'woman_gold_recharge_now' => $womanGoldRechargeNow, 'woman_gold_recharge_yesterday' => $womanGoldRechargeYesterday, 'woman_gold_sign_total' => $womanGoldSignTotal,//女签到送金币 'woman_gold_sign_now' => $womanGoldSignNow, 'woman_gold_sign_yesterday' => $womanGoldSignYesterday, 'woman_gold_total' => $womanGoldTotal, 'gold_total' => $goldTotal,//总送金币 'wechat_total' => $wechatTotal,//微信充值 'wechat_now' => $wechatNow, 'wechat_yesterday' => $wechatYesterday, 'alipay_total' => $alipayTotal,//支付宝充值 'alipay_now' => $alipayNow, 'alipay_yesterday' => $alipayYesterday, ]; $this->assign('total_gold', $total_gold); $this->assign('total_recharge_money', $total_recharge_money); $this->assign('today_recharge_gold', $today_recharge_gold); $this->assign('yesterday_recharge_gold', $yesterday_recharge_gold); $this->assign('today_use_gold', $today_use_gold); $this->assign('yesterday_use_gold', $yesterday_use_gold); $this->assign('total_use_gold', $total_use_gold); $this->assign('today_withdraw', $today_withdraw); $this->assign('today_withdraw_ava', $today_withdraw_ava); $this->assign('yesterday_withdraw', $yesterday_withdraw); $this->assign('yesterday_withdraw_ava', $yesterday_withdraw_ava); $this->assign('total_withdraw', $total_withdraw); $this->assign('total_withdraw_ava', $total_withdraw_ava); $this->assign('today_exchange_gold', $today_exchange_gold); $this->assign('yesterday_exchange_gold', $yesterday_exchange_gold); $this->assign('total_exchange_gold', $total_exchange_gold); $this->assign('man_num', $man_num); $this->assign('today_man_num', $today_man_num); $this->assign('yesterday_man_num', $yesterday_man_num); $this->assign('android_from_man_num', $android_from_man_num); $this->assign('ios_from_man_num', $ios_from_man_num); $this->assign('woman_num', $woman_num); $this->assign('today_woman_num', $today_woman_num); $this->assign('yesterday_woman_num', $yesterday_woman_num); $this->assign('android_from_woman_num', $android_from_woman_num); $this->assign('ios_from_woman_num', $ios_from_woman_num); $this->assign($statistics); return $this->view->fetch(); } }