login_white = '';// $this->check_status = array();//用户状态校验 $this->check_mobile = array();//需要手机号 $this->check_headimg = array();//授权微信信息 $this->majia_white = array('get');//超级管理员披上马甲可操作权限 $this->load->model('bobing/bobing_user_model', 'mdBobingUser'); $this->load->model('bobing/bobing_user_credit_model', 'mdBobingUserCredit'); $this->load->model('apporder/order_purchase_model', 'mdOrderPurchase'); $this->appConfig = $this->mdBobingUser->appConfig(); $this->car_id = $inputs['car_id'] ? intval($inputs['car_id']) : 13; } /** * Notes:首页 * Created on: 2020/8/10 11:47 * Created by: dengbw * @return array * @throws Exception */ protected function get() { $params = $this->input_param(); $this->set_user($params); $this->data['banner'] = $this->mdBobingUser->appImg('banner', $this->car_id); $bo_nums = 0;//$this->mdBobingUser->boNums($this->appConfig['act_key']) $this->data['bodata'] = array('title' => "累计博饼次数", 'content' => $this->appConfig['content'], 'bo_nums' => $bo_nums); $lucky_car[] = array('title' => '', 'img' => $this->mdBobingUser->appImg('index-tip'), 'url' => '/bobing/pages/game/signUp/index'); $share = array('title' => '送你100元现金,帮我博取iPhone13、汽车大奖', 'img' => $this->mdBobingUser->appImg('share_tip', $this->car_id)); $this->data['lucky_car'] = $lucky_car; $this->data['group'] = $this->appConfig['group']; $this->data['share'] = $share; return $this->data; } /** * Notes:排名 * Created on: 2021/8/20 15:23 * Created by: dengbw * @return array */ protected function get_ranking() { $this->set_user(); $this->data['banner2'] = $this->mdBobingUser->appImg('banner2', $this->car_id); $this->data['dates'] = $this->pr_dates(false); $this->data['rank'] = $this->pr_ranking_date(true);//今日幸运分 $this->data['title'] = $this->appConfig['title']; $this->data['winners_day'] = $this->pr_winners(true); $this->data['winners_weeks'] = $this->pr_winners_lottery(2); $this->data['winners_all'] = $this->pr_winners_lottery(3); return $this->data; } /** * Notes:今日幸运分排名 * Created on: 2021/8/20 15:23 * Created by: dengbw * @return array */ public function get_ranking_date() { $params = $this->input->get(); $this->data['rank'] = $this->pr_ranking_date(false, $params); return $this->data; } /** * Notes:周排名 * Created on: 2021/8/20 15:23 * Created by: dengbw * @return array */ public function get_ranking_weeks() { $params = $this->input->get(); $page = $params['page'] ? intval($params['page']) : 1; $size = $params['size'] ? intval($params['size']) : 50; $list = array(); $where = array('app_id' => $this->appConfig['app_id'], 'act_key' => $this->appConfig['act_key'], 'credit >' => 0); $date = date('Y-m-d'); if ($date >= '2021-09-13' && $date <= '2021-09-19') { $where["bo_date >="] = '2021-09-13'; $where["bo_date <="] = '2021-09-19'; } else if ($date >= '2021-09-20' && $date <= '2021-09-26') { $where["bo_date >="] = '2021-09-20'; $where["bo_date <="] = '2021-09-26'; } else if ($date >= '2021-09-27' && $date <= '2021-10-03') { $where["bo_date >="] = '2021-09-27'; $where["bo_date <="] = '2021-10-03'; } else { $where["bo_date >="] = '2021-08-31'; $where["bo_date <="] = '2021-09-12'; } $select = 'uid, sum(credit) as credit_sum'; $res_c = $this->mdBobingUserCredit->select_groupby('uid', $where, 'credit_sum desc', $page, $size, $select); if ($res_c) { $users = array();//微信昵称 $uids = array_column($res_c, 'uid'); $re_u = $this->app_user_model->select(array('id in (' . implode(',', $uids) . ')' => null), 'id DESC', 0, 0, 'id,nickname,headimg'); foreach ($re_u as $key => $value) { $users[$value['id']] = array('nickname' => $value['nickname'], 'headimg' => $value['headimg']); } foreach ($res_c as $key => $value) { $user = $users[$value['uid']]; $list[] = array('id' => $key + 1, 'nickname' => $user['nickname'], 'headimg' => $user['headimg'] , 'credit' => $value['credit_sum'] . '分'); } } $this->data['weeks'] = array('list' => $list); return $this->data; } /** * Notes:总幸运分排名 * Created on: 2021/8/20 15:24 * Created by: dengbw * @return array */ public function get_ranking_all() { $params = $this->input->get(); $this->data['rank'] = $this->pr_ranking_all(false, $params); return $this->data; } /** * Notes:中奖用户 * Created on: 2021/8/20 15:38 * Created by: dengbw * @return array */ public function get_winners() { $params = $this->input->get(); $this->data['winners'] = $this->pr_winners(false, $params); return $this->data; } private function pr_ranking_date($return_array = false, $params = array()) { $page = $params['page'] ? intval($params['page']) : 1; $size = $params['size'] ? intval($params['size']) : 50; $bo_date = date('Y-m-d'); $list = array(); $where = array('app_id' => $this->appConfig['app_id'], 'act_key' => $this->appConfig['act_key'], 'bo_date' => $bo_date, 'credit >' => 0); $total = $this->mdBobingUserCredit->count($where); if ($total) { $res_c = $this->mdBobingUserCredit->select($where, 'credit desc,u_time asc', $page, $size, 'uid,credit'); if ($res_c) { $users = array();//微信昵称 $uids = array_column($res_c, 'uid'); $re_u = $this->app_user_model->select(array('id in (' . implode(',', $uids) . ')' => null), 'id DESC', 0, 0, 'id,nickname,headimg'); foreach ($re_u as $key => $value) { $users[$value['id']] = array('nickname' => $value['nickname'], 'headimg' => $value['headimg']); } foreach ($res_c as $key => $value) { $user = $users[$value['uid']]; $list[] = array('id' => $key + 1, 'nickname' => $user['nickname'], 'headimg' => $user['headimg'] , 'credit' => $value['credit'] . '分'); } } } if ($return_array) { return $list; } return array('list' => $list, 'total' => $total); } private function pr_ranking_all($return_array = false, $params = array()) { $page = $params['page'] ? intval($params['page']) : 1; $size = $params['size'] ? intval($params['size']) : 50; $list = array(); $where = array('app_id' => $this->appConfig['app_id'], 'act_key' => $this->appConfig['act_key'], 'credit >' => 0); $total = $this->mdBobingUser->count($where); if ($total) { $res_c = $this->mdBobingUser->select($where, 'credit desc,u_time asc', $page, $size, 'uid,credit'); if ($res_c) { $users = array();//微信昵称 $uids = array_column($res_c, 'uid'); $re_u = $this->app_user_model->select(array('id in (' . implode(',', $uids) . ')' => null), 'id DESC', 0, 0, 'id,nickname,headimg'); foreach ($re_u as $key => $value) { $users[$value['id']] = array('nickname' => $value['nickname'], 'headimg' => $value['headimg']); } foreach ($res_c as $key => $value) { $user = $users[$value['uid']]; $list[] = array('id' => $key + 1, 'nickname' => $user['nickname'], 'headimg' => $user['headimg'] , 'credit' => $value['credit'] . '分'); } } } if ($return_array) { return $list; } return array('list' => $list, 'total' => $total); } private function pr_winners($return_array = false, $params = array()) { $dates = $this->pr_dates(false); $date_default = $dates ? $dates[0] : date('Y-m-d'); $bo_date = $params['date'] ? $params['date'] : $date_default; //$bo_date = '2021-08-19'; $list = array(); $where = array('app_id' => $this->appConfig['app_id'], 'act_key' => $this->appConfig['act_key'], 'bo_date' => $bo_date, 'lottery' => 1); $total = $this->mdBobingUserCredit->count($where); if ($total) { $res_c = $this->mdBobingUserCredit->select($where, 'credit desc,u_time asc', 0, 0, 'uid,credit'); if ($res_c) { $users = array();//微信昵称 $uids = array_column($res_c, 'uid'); $re_u = $this->app_user_model->select(array('id in (' . implode(',', $uids) . ')' => null), 'id DESC', 0, 0, 'id,nickname,headimg'); foreach ($re_u as $key => $value) { $users[$value['id']] = array('nickname' => $value['nickname'], 'headimg' => $value['headimg']); } foreach ($res_c as $key => $value) { $user = $users[$value['uid']]; $list[] = array('id' => $key + 1, 'nickname' => $user['nickname'], 'headimg' => $user['headimg'] , 'credit' => $value['credit'] . '分'); } } } if ($return_array) { return $list; } return array('list' => $list, 'total' => $total); } private function pr_winners_lottery($lottery) { $list = array(); $where = array('app_id' => $this->appConfig['app_id'], 'act_key' => $this->appConfig['act_key'], 'lottery' => $lottery); $res_c = $this->mdBobingUserCredit->select($where, 'credit desc,u_time asc', 0, 0, 'uid,credit'); if ($res_c) { $users = array();//微信昵称 $uids = array_column($res_c, 'uid'); $re_u = $this->app_user_model->select(array('id in (' . implode(',', $uids) . ')' => null), 'id DESC', 0, 0, 'id,nickname,headimg'); foreach ($re_u as $key => $value) { $users[$value['id']] = array('nickname' => $value['nickname'], 'headimg' => $value['headimg']); } foreach ($res_c as $key => $value) { $user = $users[$value['uid']]; $list[] = array('id' => $key + 1, 'nickname' => $user['nickname'], 'headimg' => $user['headimg'] , 'credit' => $value['credit'] . '分'); } } return $list; } /** * Notes:规则 * Created on: 2021/8/19 17:08 * Created by: dengbw * @return array */ protected function get_rule() { $this->set_user(); $this->data['banner2'] = $this->mdBobingUser->appImg('banner2', $this->car_id); $this->data['rule'] = $this->appConfig['rule']; $this->data['title'] = $this->appConfig['title']; return $this->data; } /** * Notes:礼品 * Created on: 2021/8/19 17:45 * Created by: dengbw * @return array */ protected function get_gift() { $this->set_user(); $this->data['banner2'] = $this->mdBobingUser->appImg('banner2', $this->car_id); $this->data['gift'] = $this->mdBobingUser->appImg('gift', $this->car_id); $this->data['title'] = $this->appConfig['title']; return $this->data; } /** * Notes:我的 * Created on: 2021/8/27 10:29 * Created by: dengbw * @return array */ protected function get_mine() { $credit = $car_gold = 0; $re_u = $this->set_user(); $tips = ''; if ($re_u) { $credit = $re_u['credit']; $car_gold = $re_u['car_gold'] + $re_u['buy_car_gold'] + $re_u['lotter_gold']; if ($re_u['buy_car_gold'] > 0) { $tips = '