diff --git a/api/controllers/plan/Bobing.php b/api/controllers/plan/Bobing.php index 07fb5f3b..8f3fef13 100644 --- a/api/controllers/plan/Bobing.php +++ b/api/controllers/plan/Bobing.php @@ -57,6 +57,7 @@ class Bobing extends HD_Controller return; } $where['lottery'] = 0; + $where['credit >'] = 0; $where['uid not in(select uid from lc_bobing_user_credit where app_id = ' . $this->appConfig['app_id'] . ' and act_key = ' . $this->appConfig['act_key'] . ' and lottery= 1)'] = null; $res_c = $this->mdBobingUserCredit->select($where, 'credit desc,u_time asc', 1, $this->appConfig['lottery_nums'], 'id,uid,credit'); diff --git a/api/controllers/wxapp/bobing/Bobing.php b/api/controllers/wxapp/bobing/Bobing.php index a624e317..bdb02349 100644 --- a/api/controllers/wxapp/bobing/Bobing.php +++ b/api/controllers/wxapp/bobing/Bobing.php @@ -12,7 +12,7 @@ require_once APPPATH . 'controllers/wxapp/Wxapp.php'; */ class Bobing extends Wxapp { - private $uid; + private $car_id = 13; private $appConfig; function __construct($inputs, $app_key) @@ -23,12 +23,12 @@ class Bobing extends Wxapp $this->check_mobile = array();//需要手机号 $this->check_headimg = array();//授权微信信息 $this->majia_white = array('get');//超级管理员披上马甲可操作权限 - $this->uid = $this->session['uid']; - //$this->uid = 4; + //$this->myuid = 4; $this->load->model('bobing/bobing_user_model', 'mdBobingUser'); $this->load->model('bobing/bobing_user_credit_model', 'mdBobingUserCredit'); $this->load->model('bobing/bobing_logs_model', 'mdBobingLogs'); $this->appConfig = $this->mdBobingUser->appConfig(); + $this->appConfig['act_key'] = $this->appConfig['act_key']; } /** @@ -40,36 +40,32 @@ class Bobing extends Wxapp */ protected function get() { - $cf_uid = intval($this->input_param('cf_uid'));//要助力id - $this->uid == $cf_uid && $cf_uid = 0; - //$cf_uid = 14; - $where = array('act_key' => $this->appConfig['act_key'], 'app_id' => $this->app_id, 'uid' => $this->uid); - $re_u = $this->mdBobingUser->get($where); + $params = $this->input_param(); + $re_u = $this->set_user($params); + $cf_uid = intval($params['cf_uid']);//要助力id + $this->myuid == $cf_uid && $cf_uid = 0; + //$cf_uid = 2; + $where = array('act_key' => $this->appConfig['act_key'], 'app_id' => $this->appConfig['app_id'], 'uid' => $this->myuid); $credit = $percentage = 0; if ($re_u) { $credit = $re_u['credit']; if (!$cf_uid && $re_u['if_kz'] == 0) {//更新开桌 $this->mdBobingUser->update(array("if_kz" => 1), $where); } - $sum = $this->mdBobingUser->count(array('app_id' => $this->app_id, 'act_key' => $this->appConfig['act_key'])); - $row = $this->mdBobingUser->count(array('app_id' => $this->app_id, 'act_key' => $this->appConfig['act_key'], 'credit<=' => $credit)); + $sum = $this->mdBobingUser->count(array('app_id' => $this->appConfig['app_id'], 'act_key' => $this->appConfig['act_key'])); + $row = $this->mdBobingUser->count(array('app_id' => $this->appConfig['app_id'], 'act_key' => $this->appConfig['act_key'], 'credit<=' => $credit)); $percentage = round($row / $sum * 100, 2); - } else { - $if_kz = $cf_uid ? 0 : 1; - $addUser = array_merge($where, array('if_kz' => $if_kz, 'c_time' => time())); - $idu = $this->mdBobingUser->add($addUser); - if (!$idu && $if_kz == 1) { - throw new Hd_exception('开桌失败,请重试', API_CODE_FAIL); - } } - $share = array('title' => $this->appConfig['content'], 'content' => '
目前累计' . $credit . '幸运分,打败全闽南' . $percentage . '%的用户,
+ $share = array('title' => '送你100元现金,帮我博取iPhone13、汽车大奖', 'content' => '
目前累计' . $credit . '幸运分,打败全闽南' . $percentage . '%的用户,
继续邀请好友助力博饼,
冲刺购物卡、苹果手机、汽车大奖~
添加小狸微信,还可立即获得288幸运分!
' - , 'img' => 'https://qs.haodian.cn/wechat_app/liche/bobing/2021/share-tip.jpg', 'posters' => 'https://qs.haodian.cn/wechat_app/liche/bobing/2021/posterbg.jpg'); + , 'img' => $this->mdBobingUser->appImg('share_tip', $this->car_id), 'posters' => $this->mdBobingUser->appImg('posterbg', $this->car_id)); $result['valid_nums'] = $this->get_valid_nums($cf_uid); $result['top_title'] = $this->get_top_title($cf_uid); $result['users'] = $this->pr_users(true, array('cf_uid' => $cf_uid)); $result['logs'] = $this->pr_logs($cf_uid); $result['share'] = $share; + $result['invite_theme'] = $this->mdBobingUser->appImg('invite_theme', $this->car_id); + $result['banner2'] = $this->mdBobingUser->appImg('banner2', $this->car_id); return $result; } @@ -82,24 +78,25 @@ class Bobing extends Wxapp { $this->check_game_date(); $cf_uid = intval($this->input_param('cf_uid'));//要助力id - $this->uid == $cf_uid && $cf_uid = 0; - $re_cu = ''; + $this->myuid == $cf_uid && $cf_uid = 0; + //$cf_uid = 2; if ($cf_uid) { - $re_cu = $this->app_user_model->get(array('id' => $cf_uid)); - if (!$re_cu) { + $where = array('act_key' => $this->appConfig['act_key'], 'app_id' => $this->appConfig['app_id'], 'uid' => $cf_uid); + $re_u = $this->mdBobingUser->get($where); + if (!$re_u) { throw new Hd_exception('无此用户', API_CODE_FAIL); } } //$cf_uid = 14; $this->load->library('bobing/bo'); - $this->bo->uid = $this->uid; + $this->bo->uid = $this->myuid; $valid_nums = $this->get_valid_nums($cf_uid);//获取博饼剩余数 $this->bo->valid_nums = $valid_nums['value']; $nickname = ''; if ($cf_uid) {//助力博 $this->bo->cf_uid = $cf_uid; $result = $this->bo->zl_bo(); - $reU = $this->app_user_model->get(array('id' => $this->uid)); + $reU = $this->app_user_model->get(array('id' => $this->myuid)); $reU['nickname'] && $nickname = $reU['nickname']; } else {//开桌博 $result = $this->bo->kz_bo(); @@ -121,7 +118,7 @@ class Bobing extends Wxapp $log .= $cf_uid ? "和{$result['car_gold']}元购车金" : ",额外幸运地博到{$result['car_gold']}元购车金"; } else if ($result['hong_bao'] > 0) { $status = 4; - $data['hong_bao_url'] = http_host_com('home') . "/h5/hongbao?id={$result['lid']}&uid={$this->uid}"; + $data['hong_bao_url'] = http_host_com('home') . "/h5/hongbao?id={$result['lid']}&uid={$this->myuid}"; $log .= ",额外幸运地博到一个现金红包"; } $data['log'] = $log; @@ -131,7 +128,7 @@ class Bobing extends Wxapp $data['level'] = $result['level']; $data['bo_title'] = $result['level_name'] . ' + ' . $result['credit']; $data['valid_nums'] = $valid_nums; - $data['top_title'] = $this->get_top_title($cf_uid, $re_cu); + $data['top_title'] = $this->get_top_title($cf_uid); return $data; } @@ -153,13 +150,13 @@ class Bobing extends Wxapp private function get_valid_nums($cf_uid) { if ($cf_uid) { - $zl_nums = $this->mdBobingLogs->count(array('app_id' => $this->app_id, 'act_key' => $this->appConfig['act_key'] - , 'uid' => $cf_uid, 'cf_uid' => $this->uid, 'type' => 1)); + $zl_nums = $this->mdBobingLogs->count(array('app_id' => $this->appConfig['app_id'], 'act_key' => $this->appConfig['act_key'] + , 'uid' => $cf_uid, 'cf_uid' => $this->myuid, 'type' => 1)); $zl_nums = intval($this->appConfig['zl_nums'] - $zl_nums);//剩下助力博饼数 $valid_nums = array('title' => '剩余助力次数:', 'value' => $zl_nums <= 0 ? 0 : $zl_nums); } else { - $kz_nums = $this->mdBobingLogs->count(array('app_id' => $this->app_id, 'act_key' => $this->appConfig['act_key'] - , 'uid' => $this->uid, 'type' => 0)); + $kz_nums = $this->mdBobingLogs->count(array('app_id' => $this->appConfig['app_id'], 'act_key' => $this->appConfig['act_key'] + , 'uid' => $this->myuid, 'type' => 0)); $kz_nums = intval($this->appConfig['kz_nums'] - $kz_nums);//剩下开桌博饼数 $valid_nums = array('title' => '剩余博饼次数:', 'value' => $kz_nums <= 0 ? 0 : $kz_nums); } @@ -174,17 +171,17 @@ class Bobing extends Wxapp * @param string $reU * @return string */ - private function get_top_title($cf_uid, $reU = '') + private function get_top_title($cf_uid) { if ($cf_uid) { - !$reU && $reU = $this->app_user_model->get(array('id' => $cf_uid)); + $reU = $this->app_user_model->get(array('id' => $cf_uid)); $top_title = $reU['nickname'] ? $reU['nickname'] . '的桌子' : '未知用户的桌子'; } else { $credit = $ranking = 0; - $where = array('app_id' => $this->app_id, 'act_key' => $this->appConfig['act_key'], 'bo_date' => date('Y-m-d')); - $re_c = $this->mdBobingUserCredit->get(array_merge($where, array('uid' => $this->uid))); + $where = array('app_id' => $this->appConfig['app_id'], 'act_key' => $this->appConfig['act_key'], 'bo_date' => date('Y-m-d')); + $re_c = $this->mdBobingUserCredit->get(array_merge($where, array('uid' => $this->myuid))); $re_c && $credit = $re_c['credit']; - $ranking = $this->mdBobingUserCredit->count(array_merge($where, array('credit>=' => $credit, 'uid<>' => $this->uid))) + 1;//排名 + $ranking = $this->mdBobingUserCredit->count(array_merge($where, array('credit>=' => $credit, 'uid<>' => $this->myuid))) + 1;//排名 $ranking > 100 && $ranking = '100名外'; $top_title = "今日博饼分:{$credit} | 今日排名:{$ranking}"; } @@ -199,9 +196,9 @@ class Bobing extends Wxapp //$cf_uid = 14; $list = array(); if ($cf_uid) { - $where = array('app_id' => $this->app_id, 'act_key' => $this->appConfig['act_key'], 'uid' => $cf_uid, 'type' => 1); + $where = array('app_id' => $this->appConfig['app_id'], 'act_key' => $this->appConfig['act_key'], 'uid' => $cf_uid, 'type' => 1); } else { - $where = array('app_id' => $this->app_id, 'act_key' => $this->appConfig['act_key'], 'uid' => $this->uid, 'type' => 1); + $where = array('app_id' => $this->appConfig['app_id'], 'act_key' => $this->appConfig['act_key'], 'uid' => $this->myuid, 'type' => 1); } $total = $this->mdBobingLogs->count($where, 'distinct(cf_uid)'); if ($total) { @@ -229,9 +226,9 @@ class Bobing extends Wxapp //$cf_uid = 14; $logs = array(); if ($cf_uid) { - $where = array('app_id' => $this->app_id, 'act_key' => $this->appConfig['act_key'], 'uid' => $cf_uid); + $where = array('app_id' => $this->appConfig['app_id'], 'act_key' => $this->appConfig['act_key'], 'uid' => $cf_uid); } else { - $where = array('app_id' => $this->app_id, 'act_key' => $this->appConfig['act_key'], 'uid' => $this->uid); + $where = array('app_id' => $this->appConfig['app_id'], 'act_key' => $this->appConfig['act_key'], 'uid' => $this->myuid); } $res_l = $this->mdBobingLogs->select($where, 'id DESC', 1, 7, 'credit,hong_bao,car_gold,type,uid,cf_uid'); if ($res_l) { @@ -268,12 +265,46 @@ class Bobing extends Wxapp */ protected function check_game_date() { - if ($this->appConfig['game_start_date'] > date('Y-m-d')) { + $date = date('Y-m-d H:i'); + if ($this->appConfig['game_start_date'] > $date) { throw new Hd_exception('博饼未开始', API_CODE_FAIL); } - if ($this->appConfig['game_end_date'] < date('Y-m-d')) { + if ($this->appConfig['game_end_date'] < $date) { throw new Hd_exception('博饼已结束', API_CODE_FAIL); } } + /** + * Notes:设置car_id + * Created on: 2021/9/2 15:32 + * Created by: dengbw + * @param array $params + * @return mixed + */ + private function set_user($params = array()) + { + $this->myuid == $params['cf_uid'] && $params['cf_uid'] = 0; + $where = array('app_id' => $this->appConfig['app_id'], 'act_key' => $this->appConfig['act_key'], 'uid' => $this->myuid); + $re_u = $this->mdBobingUser->get($where); + if ($re_u['car_id']) { + $this->car_id = $re_u['car_id']; + } else if ($params['car_id']) { + $this->car_id = $params['car_id']; + } else if ($params['cf_uid']) { + $where['uid'] = $params['cf_uid']; + $re_u_c = $this->mdBobingUser->get($where); + $this->car_id = $re_u_c['car_id']; + } + !$this->car_id && $this->car_id = 13; + if (!$re_u['car_id']) { + $this->mdBobingUser->update(array("car_id" => $this->car_id), $where); + } + if (!$re_u) { + $where['uid'] = $this->myuid; + $addUser = array_merge($where, array('car_id' => $this->car_id, 'c_time' => time())); + $this->mdBobingUser->add($addUser); + } + return $re_u; + } + } diff --git a/api/controllers/wxapp/bobing/Home.php b/api/controllers/wxapp/bobing/Home.php index 110d5bd3..05d5f2b9 100644 --- a/api/controllers/wxapp/bobing/Home.php +++ b/api/controllers/wxapp/bobing/Home.php @@ -12,8 +12,7 @@ require_once APPPATH . 'controllers/wxapp/Wxapp.php'; */ class Home extends Wxapp { - private $uid; - private $appConfig; + private $appConfig, $car_id = 13; function __construct($inputs, $app_key) { @@ -23,7 +22,6 @@ class Home extends Wxapp $this->check_mobile = array();//需要手机号 $this->check_headimg = array();//授权微信信息 $this->majia_white = array('get');//超级管理员披上马甲可操作权限 - $this->uid = $this->session['uid']; $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'); @@ -39,11 +37,12 @@ class Home extends Wxapp */ protected function get() { - //$bo_nums = $this->mdBobingUser->boNums($this->appConfig['act_key']); - $bo_nums = 0; + $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' => 'https://qs.haodian.cn/wechat_app/liche/bobing/2021/index-tip.jpg' - , 'url' => '/pages/buyCar/detail/index?id=13'); + $lucky_car[] = array('title' => '', 'img' => $this->mdBobingUser->appImg('index-tip'), 'url' => '/pages/buyCar/detail/index?id=' . $this->car_id); $this->data['lucky_car'] = $lucky_car; $this->data['group'] = $this->appConfig['group']; $this->data['title'] = $this->appConfig['title']; @@ -58,11 +57,14 @@ class Home extends Wxapp */ 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['winners'] = $this->pr_winners(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; } @@ -79,6 +81,52 @@ class Home extends Wxapp 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 @@ -108,10 +156,10 @@ class Home extends Wxapp private function pr_ranking_date($return_array = false, $params = array()) { $page = $params['page'] ? intval($params['page']) : 1; - $size = $params['size'] ? intval($params['size']) : 100; + $size = $params['size'] ? intval($params['size']) : 50; $bo_date = date('Y-m-d'); $list = array(); - $where = array('app_id' => $this->app_id, 'act_key' => $this->appConfig['act_key'], 'bo_date' => $bo_date, 'credit >' => 0); + $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'); @@ -138,9 +186,9 @@ class Home extends Wxapp private function pr_ranking_all($return_array = false, $params = array()) { $page = $params['page'] ? intval($params['page']) : 1; - $size = $params['size'] ? intval($params['size']) : 100; + $size = $params['size'] ? intval($params['size']) : 50; $list = array(); - $where = array('app_id' => $this->app_id, 'act_key' => $this->appConfig['act_key'], 'credit >' => 0); + $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'); @@ -171,7 +219,7 @@ class Home extends Wxapp $bo_date = $params['date'] ? $params['date'] : $date_default; //$bo_date = '2021-08-19'; $list = array(); - $where = array('app_id' => $this->app_id, 'act_key' => $this->appConfig['act_key'], 'bo_date' => $bo_date, 'lottery' => 1); + $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', 1, 10, 'uid,credit'); @@ -195,6 +243,27 @@ class Home extends Wxapp 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 @@ -203,6 +272,8 @@ class Home extends Wxapp */ 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; @@ -216,7 +287,9 @@ class Home extends Wxapp */ protected function get_gift() { - $this->data['gift'] = $this->appConfig['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; } @@ -230,22 +303,38 @@ class Home extends Wxapp protected function get_mine() { $credit = $car_gold = 0; - $re_u = $this->mdBobingUser->get(array('app_id' => $this->app_id, 'act_key' => $this->appConfig['act_key'], 'uid' => $this->uid)); + $re_u = $this->set_user(); $tips = ''; if ($re_u) { $credit = $re_u['credit']; $car_gold = $re_u['car_gold'] + $re_u['buy_car_gold']; - $sum = $this->mdBobingUser->count(array('app_id' => $this->app_id, 'act_key' => $this->appConfig['act_key'])); - $row = $this->mdBobingUser->count(array('app_id' => $this->app_id, 'act_key' => $this->appConfig['act_key'], 'credit<=' => $credit)); - $percentage = round($row / $sum * 100, 2); - $tips = '
您已打败全闽南' . $percentage . '%的用户
继续邀请好友助力博饼,冲刺大奖吧~
'; + $where = array('app_id' => $this->appConfig['app_id'], 'act_key' => $this->appConfig['act_key']); + $re_u = $this->mdBobingUserCredit->select(array_merge($where, array('uid' => $this->myuid, 'lottery>' => 0)), 'lottery DESC', 0, 0, 'lottery'); + if ($re_u) { + $tipsAry = array(); + foreach ($re_u as $key => $value) { + if ($value['lottery'] == 1) { + $tipsAry[] = '购物卡1张'; + } else if ($value['lottery'] == 2) { + $tipsAry[] = 'iPhone13手机一只'; + } else if ($value['lottery'] == 3) { + $tipsAry[] = '新能源汽车一台'; + } + } + $tips = '
您已中奖' . implode(',', $tipsAry) . '
'; + } else { + $sum = $this->mdBobingUser->count($where); + $row = $this->mdBobingUser->count(array_merge($where, array('credit<=' => $credit))); + $percentage = round($row / $sum * 100, 2); + $tips = '
您已打败全闽南' . $percentage . '%的用户
'; + } + $tips = $tips . '
继续邀请好友助力博饼,冲刺大奖吧~
'; } - $img_url = 'https://qs.haodian.cn/wechat_app/liche'; - $menulist[] = array('title' => '9.9抢500购车金', 'url' => 'buy_car_gold', 'img' => $img_url . '/bobing/2021/icon-mine-1.png'); - $menulist[] = array('title' => '预约试驾', 'url' => '/pages/buyCar/detail/index?id=13', 'img' => $img_url . '/bobing/2021/icon-mine-4.png'); - $menulist[] = array('title' => '我的海报', 'url' => '/bobing/pages/game/invite/index', 'img' => $img_url . '/bobing/2021/icon-mine-2.png'); - $menulist[] = array('title' => '联系客服', 'url' => '/pages/', 'img' => $img_url . '/bobing/2021/icon-mine-3.png'); - $menulist[] = array('title' => '关于狸车', 'url' => 'lc://switchTab/pages/index/index', 'img' => $img_url . '/bobing/2021/icon-mine-5.png'); + $menulist[] = array('title' => '9.9抢500购车金', 'url' => 'buy_car_gold', 'img' => $this->mdBobingUser->appImg('icon-mine-1')); + $menulist[] = array('title' => '预约试驾', 'url' => '/pages/buyCar/detail/index?id=' . $this->car_id, 'img' => $this->mdBobingUser->appImg('icon-mine-4')); + $menulist[] = array('title' => '我的海报', 'url' => '/bobing/pages/game/invite/index', 'img' => $this->mdBobingUser->appImg('icon-mine-2')); + $menulist[] = array('title' => '联系客服', 'url' => '/pages/', 'img' => $this->mdBobingUser->appImg('icon-mine-3')); + $menulist[] = array('title' => '关于狸车', 'url' => 'lc://switchTab/pages/index/index', 'img' => $this->mdBobingUser->appImg('icon-mine-5')); $data = array( "title" => $this->appConfig['title'], "credit" => array('title' => '幸运分', 'value' => $credit), @@ -264,13 +353,13 @@ class Home extends Wxapp */ protected function get_buy_car_gold() { - $where = array('app_id' => $this->appConfig['act_key'], 'app_uid' => $this->uid, 'item_id' => 1); + $where = array('app_id' => $this->appConfig['act_key'], 'app_uid' => $this->myuid, 'item_id' => 1); $re_p = $this->mdOrderPurchase->get($where); if (!$re_p) { $sid = create_order_no(350200); $add_data = [ 'app_id' => $this->appConfig['act_key'], - 'app_uid' => $this->uid, + 'app_uid' => $this->myuid, 'sid' => $sid, 'item_id' => 1, 'item_title' => '9.9抢500购车金', @@ -354,28 +443,54 @@ class Home extends Wxapp //日期列表 private function pr_dates($include_today = true) { - $ttl = 60; - $mc = &load_cache(); - $key_dates = 'dates' . $this->appConfig['act_key'] . '_' . date('Y-m-d') . '_' . $include_today; - $dates = $mc->get($key_dates); - if (!$dates) { - $date_end = $include_today ? strtotime(date('Y-m-d')) : strtotime(date('Y-m-d', strtotime('-1 day'))); - $game_start_date = strtotime($this->appConfig['game_start_date']); - $game_start_end = strtotime($this->appConfig['game_end_date']); - $dates = array(); - $do = true; - while ($do) { - if ($game_start_date <= $date_end && $game_start_date <= $game_start_end) { - $dates[] = date('Y-m-d', $game_start_date); - $game_start_date = strtotime('+1 day', $game_start_date); - } else { - $do = false; - } + $date_end = $include_today ? strtotime(date('Y-m-d')) : strtotime(date('Y-m-d', strtotime('-1 day'))); + $game_start_date = strtotime(date('Y-m-d', strtotime($this->appConfig['game_start_date']))); + $game_start_end = strtotime(date('Y-m-d', strtotime($this->appConfig['game_end_date']))); + $dates = array(); + $do = true; + while ($do) { + if ($game_start_date <= $date_end && $game_start_date <= $game_start_end) { + $dates[] = date('Y-m-d', $game_start_date); + $game_start_date = strtotime('+1 day', $game_start_date); + } else { + $do = false; } - $dates = array_reverse($dates); - $mc->save($key_dates, $dates, $ttl); } + $dates = array_reverse($dates); return $dates; } + /** + * Notes:设置car_id + * Created on: 2021/9/2 15:32 + * Created by: dengbw + * @param array $params + * @return mixed + */ + private function set_user($params = array()) + { + $this->myuid == $params['cf_uid'] && $params['cf_uid'] = 0; + $where = array('app_id' => $this->appConfig['app_id'], 'act_key' => $this->appConfig['act_key'], 'uid' => $this->myuid); + $re_u = $this->mdBobingUser->get($where); + if ($re_u['car_id']) { + $this->car_id = $re_u['car_id']; + } else if ($params['car_id']) { + $this->car_id = $params['car_id']; + } else if ($params['cf_uid']) { + $where['uid'] = $params['cf_uid']; + $re_u_c = $this->mdBobingUser->get($where); + $this->car_id = $re_u_c['car_id']; + } + !$this->car_id && $this->car_id = 13; + if (!$re_u['car_id']) { + $this->mdBobingUser->update(array("car_id" => $this->car_id), $where); + } + if (!$re_u) { + $where['uid'] = $this->myuid; + $addUser = array_merge($where, array('car_id' => $this->car_id, 'c_time' => time())); + $this->mdBobingUser->add($addUser); + } + return $re_u; + } + } diff --git a/api/libraries/bobing/Bo.php b/api/libraries/bobing/Bo.php index 6dc46bd8..ec9396f3 100644 --- a/api/libraries/bobing/Bo.php +++ b/api/libraries/bobing/Bo.php @@ -10,6 +10,8 @@ class Bo extends Base { private $appConfig = array(); private $carGoldAry = array(1 => '100', 2 => '100', 3 => '150', 4 => '100', 5 => '150', 6 => '100', 7 => '150'); + private $dicesAry = array(1 => array(1, 3, 6, 1, 1, 5), 2 => array(6, 5, 3, 1, 2, 5), 3 => array(3, 3, 3, 6, 5, 5) + , 4 => array(6, 3, 1, 2, 2, 3), 5 => array(5, 5, 6, 3, 6, 6), 6 => array(5, 2, 3, 5, 6, 3));//罚黑随机数组 public function __construct() { @@ -32,30 +34,30 @@ class Bo extends Base $popup = array('title' => '邀请好友', 'content' => $content, 'btn' => array('title' => '立即邀请', 'url' => '/bobing/pages/game/invite/index')); return array('status' => 1, 'popup' => $popup); } -// $mc = &load_cache(); -// $key = 'LiChe_bobing_' . $this->act_key . $this->app_id . $this->uid; -// $timeout = $mc->get($key); -// if ($timeout && (time() - $timeout) < 2) { -// return array('status' => API_CODE_FAIL, 'content' => '您操作太快了,速度越慢越能博到状元,刷新页面再试试'); -// } -// $mc->save($key, time()); - $this->ci->load->library('bobing/dice'); - $this->ci->dice->init(); - $size_result = $this->ci->dice->getResultArr(); - $level = $this->ci->dice->getResultLevel(); $data['app_id'] = $this->appConfig['app_id']; $data['act_key'] = $this->appConfig['act_key']; $data['uid'] = $this->uid; - $data['dices'] = implode(',', $size_result); + $this->ci->load->library('bobing/dice'); + $this->ci->dice->init(); + $dices = $this->ci->dice->getResultArr(); + $level = $this->ci->dice->getResultLevel(); + $credit = $this->ci->dice->getcredit($level); + $level_name = $this->ci->dice->getResultName(); + $re_u = $this->ci->bobing_user_model->get(array('app_id' => $data['app_id'], 'act_key' => $data['act_key'], 'uid' => $this->uid)); + if ($re_u['car_id'] == 15 && $level >= 6) {//ex1用户博到状元时设为罚黑 + $dices = $this->dicesAry[rand(1, 6)]; + $level = $credit = 0; + $level_name = '罚黑'; + } + $data['dices'] = implode(',', $dices); $data['level'] = $level; - $data['credit'] = $this->ci->dice->getcredit($level); + $data['credit'] = $credit; $data['bo_date'] = date('Y-m-d'); $data['ip'] = get_client_ip(); $data['ua'] = $_SERVER['HTTP_USER_AGENT']; $data['type'] = 0; $data['c_time'] = time(); $popup = ''; - $re_u = $this->ci->bobing_user_model->get(array('app_id' => $data['app_id'], 'act_key' => $data['act_key'], 'uid' => $this->uid)); if ($re_u['car_gold'] < $this->appConfig['max_car_gold']) {//购车金小于购车金设定值 if ($this->appConfig['ratio_car_gold'] && $this->appConfig['ratio_car_gold'] >= rand(1, 100)) {//购车金概率 $car_gold = $this->carGoldAry[rand(1, 7)]; @@ -63,7 +65,7 @@ class Bo extends Base $car_gold = $this->appConfig['max_car_gold'] - $re_u['car_gold']; } $data['car_gold'] = $car_gold; - $content = '恭喜您,博到' . $car_gold . '元购车金,您已累计博得' . ($re_u['car_gold'] + $car_gold) . '元购车金'; + $content = '
博到' . $car_gold . '元购车金
您已累计博得' . ($re_u['car_gold'] + $car_gold) . '元购车金
'; $popup = array('title' => '恭喜您', 'content' => $content, 'btn' => array('title' => '立即使用购车金', 'url' => '/pages/buyCar/detail/index?id=13')); } } @@ -71,7 +73,7 @@ class Bo extends Base if ($re_l['status'] == 1) { return array('status' => API_CODE_FAIL, 'content' => '博饼日志添加失败'); } - $data['level_name'] = $this->ci->dice->getResultName(); + $data['level_name'] = $level_name; $data['status'] = 0; $data['lid'] = $re_l['lid']; $data['popup'] = $popup; @@ -88,6 +90,8 @@ class Bo extends Base { $data['app_id'] = $this->appConfig['app_id']; $data['act_key'] = $this->appConfig['act_key']; + $data['uid'] = $this->cf_uid; + $data['cf_uid'] = $this->uid; if ($this->valid_nums <= 0) { $re_u = $this->ci->bobing_user_model->get(array('app_id' => $data['app_id'], 'act_key' => $data['act_key'], 'uid' => $this->uid)); $credit = intval($re_u['credit']); @@ -95,29 +99,26 @@ class Bo extends Base $popup = array('title' => '开桌', 'content' => $content, 'btn' => array('title' => '立即开桌', 'url' => '/bobing/pages/game/index')); return array('status' => 2, 'popup' => $popup); } -// $mc = &load_cache(); -// $key = 'LiChe_bobing_' . $this->act_key . $this->app_id . $this->uid; -// $timeout = $mc->get($key); -// if ($timeout && (time() - $timeout) < 2) { -// return array('status' => API_CODE_FAIL, 'msg' => '您操作太快了,速度越慢越能博到状元,刷新页面再试试'); -// } -// $mc->save($key, time()); $this->ci->load->library('bobing/dice'); $this->ci->dice->init(); - $size_result = $this->ci->dice->getResultArr(); + $dices = $this->ci->dice->getResultArr(); $level = $this->ci->dice->getResultLevel(); - - $data['uid'] = $this->cf_uid; - $data['cf_uid'] = $this->uid; - $data['dices'] = implode(',', $size_result); + $credit = $this->ci->dice->getcredit($level); + $level_name = $this->ci->dice->getResultName(); + $re_u = $this->ci->bobing_user_model->get(array('app_id' => $data['app_id'], 'act_key' => $data['act_key'], 'uid' => $data['uid'])); + if ($re_u['car_id'] == 15 && $level >= 6) {//ex1用户博到状元时设为罚黑 + $dices = $this->dicesAry[rand(1, 6)]; + $level = $credit = 0; + $level_name = '罚黑'; + } + $data['dices'] = implode(',', $dices); $data['level'] = $level; - $data['credit'] = $this->ci->dice->getcredit($level); + $data['credit'] = $credit; $data['bo_date'] = date('Y-m-d'); $data['ip'] = get_client_ip(); $data['ua'] = $_SERVER['HTTP_USER_AGENT']; $data['type'] = 1; $popup = ''; - $re_u = $this->ci->bobing_user_model->get(array('app_id' => $data['app_id'], 'act_key' => $data['act_key'], 'uid' => $data['uid'])); if ($re_u['car_gold'] < $this->appConfig['max_car_gold']) {//购车金小于购车金设定值 if ($this->appConfig['ratio_car_gold'] && $this->appConfig['ratio_car_gold'] >= rand(1, 100)) {//购车金概率 $car_gold = $this->carGoldAry[rand(1, 7)]; @@ -125,7 +126,7 @@ class Bo extends Base $car_gold = $this->appConfig['max_car_gold'] - $re_u['car_gold']; } $data['car_gold'] = $car_gold; - $content = '
恭喜您
帮助好友博到博到' . $car_gold . '元购车金和' . $data['credit'] . '幸运分,
您的好友离汽车大奖更进一步了!
'; + $content = '
帮助好友博到' . $car_gold . '元购车金和' . $data['credit'] . '幸运分,
您的好友离汽车大奖更进一步了!
'; $popup = array('title' => '恭喜您', 'content' => $content, 'btn' => array('title' => '我也要开桌博取汽车大奖' , 'url' => '/bobing/pages/game/index')); } @@ -147,7 +148,7 @@ class Bo extends Base if ($log['status'] == 1) { return array('status' => API_CODE_FAIL, 'content' => '博饼日志添加失败'); } - $data['level_name'] = $this->ci->dice->getResultName(); + $data['level_name'] = $level_name; $data['status'] = 0; $data['lid'] = $log['lid']; $data['popup'] = $popup; @@ -161,7 +162,12 @@ class Bo extends Base */ public function wxqy_credit() { - $re_l = $this->ci->bobing_logs_model->get(array('uid' => $this->uid, 'app_id' => $this->appConfig['app_id'], 'type' => 3)); + $where = array('app_id' => $this->appConfig['app_id'], 'act_key' => $this->appConfig['act_key'], 'uid' => $this->uid); + $re_u = $this->ci->bobing_user_model->get($where); + if (!$re_u) { + return array('status' => -1, 'content' => '未参加博饼'); + } + $re_l = $this->ci->bobing_logs_model->get(array_merge($where, array('type' => 2))); if ($re_l) { return array('status' => -1, 'content' => '已添过企业微信加分了'); } diff --git a/api/libraries/bobing/Dice.php b/api/libraries/bobing/Dice.php index 71736613..dc884ecc 100644 --- a/api/libraries/bobing/Dice.php +++ b/api/libraries/bobing/Dice.php @@ -261,7 +261,7 @@ class Dice { $level = $level == false ? $this->_resultLevel : $level; $arr = array( - self::RESULT_ZYCJH => 110, //状元插金花 + self::RESULT_ZYCJH => 120, //状元插金花 self::RESULT_LBHONG => 100, //六勃红 //self::RESULT_BD => 13, //遍地锦 self::RESULT_LBHEI => 90, //六勃黑 diff --git a/common/models/bobing/Bobing_user_model.php b/common/models/bobing/Bobing_user_model.php index ab820341..b64eb9e0 100644 --- a/common/models/bobing/Bobing_user_model.php +++ b/common/models/bobing/Bobing_user_model.php @@ -34,14 +34,14 @@ class Bobing_user_model extends Base_model $config = array(); if ($act_key == 2021) { $config = array( - 'title' => 'LiChe博饼', 'content' => '2021闽南博饼嘉年华', 'game_start_date' => '2021-07-20', 'game_end_date' => '2021-09-31', + 'title' => 'LiChe博饼', 'content' => '2021闽南博饼嘉年华', 'game_start_date' => '2021-09-01 10:00', 'game_end_date' => '2021-10-08 15:00', 'group' => array('title' => '添加小狸', 'btn' => '加小狸企业微信', 'tips' => '通过后送288幸运分'), - 'app_id' => 1, 'act_key' => $act_key, 'kz_nums' => 25, 'zl_nums' => 20, 'wxqy_nums' => 288, 'ratio_hong_bao' => 50, 'ratio_car_gold' => 50, + 'app_id' => 1, 'act_key' => $act_key, 'kz_nums' => 5, 'zl_nums' => 3, 'wxqy_nums' => 288, 'ratio_hong_bao' => 50, 'ratio_car_gold' => 50, 'max_car_gold' => 500, 'buy_car_gold' => 500, 'hong_bao_day' => 1000, 'lottery_nums' => 10, 'rule' => array('title' => '活动流程及规则', 'content' => '
一、活动时间:2021年9月9日10:00-2021年10月8日15:00
二、活动流程及规则
-
1. 开桌用户可以直接获得5次博饼次数,博饼次数用完后,通过邀请助力用户为其博饼,双方可获得如下奖励
+
1. 开桌用户可以直接获得5次博饼次数,博饼次数用完后,通过邀请助力用户获得3次博饼次数为其博饼,双方可获得如下奖励
(1)开桌用户:
① 获得购车金:助力用户每次助力博饼,随机为开桌用户获得一定金额的购车金,购车金可以累计使用;
② 获得幸运分: 助力用户每次助力博饼,根据博出的结果,为开桌用户获得不同的幸运分:一秀1分、二举2分、四进5分、三红10分、对堂20分、状元50分
@@ -64,16 +64,55 @@ class Bobing_user_model extends Base_model
(4)购车金在指定经销商处使用,用户可在经销商处协商好购车价后,再提出购车金抵扣,不影响正常车辆优惠政策;
6. 任何问题均可联系新能源汽车顾问解答 (联系新能源汽车顾问按钮)
7. 在法律允许范围内,主办方拥有对本次活动的最终解释权。
'), - 'gift' => array( - array('id' => 1, 'title' => '第一名', 'img' => 'https://qs.haodian.cn/wechat_app/liche/bobing/2021/gift_box_tip_1.jpg'), - array('id' => 2, 'title' => '第2`11名', 'img' => 'https://qs.haodian.cn/wechat_app/liche/bobing/2021/gift_box_tip_2.jpg'), - array('id' => 3, 'title' => '购物金', 'img' => 'https://qs.haodian.cn/wechat_app/liche/bobing/2021/gift_box_tip_3.jpg'), - array('id' => 4, 'title' => '现金红包', 'img' => 'https://qs.haodian.cn/wechat_app/liche/bobing/2021/gift_box_tip_4.jpg')), ); } return $config; } + /** + * Notes:图片地址 + * Created on: 2021/9/2 10:02 + * Created by: dengbw + * @param $id + * @param $key + * @return mixed + */ + public function appImg($key = '', $id = 13) + { + $imgs = array(); + if (!$key) { + return $imgs; + } + $url = 'https://qs.haodian.cn/wechat_app/liche/bobing/2021/'; + $url_id = $url; + if ($id == 15) {//15ex1 13雷丁 + $url_id .= 'ex1-'; + } + $imgs['banner'] = $url_id . 'banner.jpg'; + //公用头图 + $imgs['banner2'] = $url_id . 'banner2.jpg'; + //邀请头图 + $imgs['invite_theme'] = $url_id . 'invite-theme.jpg'; + //邀请海报生成图 + $imgs['posterbg'] = $url_id . 'posterbg.jpg'; + //分享图 + $imgs['share_tip'] = $url_id . 'share-tip.jpg'; + //礼品 + $imgs['gift'] = array( + array('id' => 1, 'title' => '第一名', 'img' => $url_id . 'gift_box_tip_1.jpg'), + array('id' => 2, 'title' => '第2`11名', 'img' => $url . 'gift_box_tip_2.jpg'), + array('id' => 3, 'title' => '购物金', 'img' => $url . 'gift_box_tip_3.jpg'), + array('id' => 4, 'title' => '现金红包', 'img' => $url . 'gift_box_tip_4.jpg')); + //固定图片 + $imgs['index-tip'] = $url . 'index-tip.jpg'; + $imgs['icon-mine-1'] = $url . 'icon-mine-1.png'; + $imgs['icon-mine-2'] = $url . 'icon-mine-2.png'; + $imgs['icon-mine-3'] = $url . 'icon-mine-3.png'; + $imgs['icon-mine-4'] = $url . 'icon-mine-4.png'; + $imgs['icon-mine-5'] = $url . 'icon-mine-5.png'; + return $imgs[$key]; + } + //博饼总次数 public function boNums($act_key = '', $add = 0) {