ask("日期?"); $headers = ["日期", "总人数", "手机号人数", "卡片人数", "报名人数", "普通会员人数"]; $data = []; $dates = [ '2018-07', '2018-08', '2018-09', '2018-10', '2018-11', '2018-12', '2019-01', '2019-02', '2019-03', '2019-04', '2019-05', '2019-06', '2019-07', ]; // foreach ($dates as $date) { // $y = date("Y", strtotime($date)); // $m = date("m", strtotime($date)); // $begin = mktime(0, 0, 0, $m, 1, $y); // $end = mktime(0, 0, 0, $m + 1, 1, $y) - 1; $begin = 0; $end = time(); // 总人数 $total = \DB::table('kdgx_partner_charge_user as u') ->join('kddx_user_openid as o', 'o.uid', '=', 'u.uid') ->where('o.public_id', 'gh_b598cb7474d8') ->where('o.subscribe', 1) ->whereBetween('u.login_at', [$begin, $end]) ->count(); // 手机号人数 $phone_total = \DB::table('kdgx_partner_charge_user as u') ->join('kddx_user_openid as o', 'o.uid', '=', 'u.uid') ->where('o.public_id', 'gh_b598cb7474d8') ->where('o.subscribe', 1) ->whereNotNull('u.phone') ->whereBetween('u.login_at', [$begin, $end]) ->count(); // 卡片人数 $partner_total = \DB::table('kdgx_partner_charge_user as u') ->join('kddx_user_openid as o', 'o.uid', '=', 'u.uid') ->where('o.public_id', 'gh_b598cb7474d8') ->where('o.subscribe', 1) ->where('u.partner_id', '>', 0) ->whereBetween('u.login_at', [$begin, $end]) ->count(); // 报名人数 $pair_total = \DB::table('kdgx_partner_charge_user as u') ->join('kddx_user_openid as o', 'o.uid', '=', 'u.uid') ->join('kdgx_partner_charge_pair as p', 'p.uid', '=', 'u.uid') ->where('o.public_id', 'gh_b598cb7474d8') ->where('o.subscribe', 1) ->whereBetween('u.login_at', [$begin, $end]) ->distinct() ->count('u.uid'); // 普通会员人数 $vip_total = \DB::table('kdgx_partner_charge_user as u') ->join('kddx_user_openid as o', 'o.uid', '=', 'u.uid') ->where('o.public_id', 'gh_b598cb7474d8') ->where('o.subscribe', 1) ->whereBetween('u.be_vip_at', [$begin, $end]) ->count(); array_push($data, [ // "date"=>$date, "date" => "全部", "total" => $total, "phone_total" => $phone_total, "partner_total" => $partner_total, "pair_total" => $pair_total, "vip_total" => $vip_total ]); // } $this->table($headers, $data); } }