'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() { $this->ci->load->model('bobing/bobing_user_model'); $this->ci->load->model('bobing/bobing_user_credit_model'); $this->ci->load->model('bobing/bobing_logs_model'); $this->appConfig = $this->ci->bobing_user_model->appConfig(); } /** * Notes:开桌博饼 * Created on: 2021/8/10 17:41 * Created by: dengbw * @return mixed */ public function kz_bo() { $data['app_id'] = $this->appConfig['app_id']; $data['act_key'] = $this->appConfig['act_key']; $re_u = $this->ci->bobing_user_model->get(array('app_id' => $data['app_id'], 'act_key' => $data['act_key'], 'uid' => $this->uid)); $all_car_gold = $re_u['car_gold'] + $re_u['buy_car_gold'] + $re_u['lotter_gold']; if ($this->valid_nums <= 0) { $content = '
今天博饼次数已经用完啦~
已累计获得' . $all_car_gold . '元购车金
明天还有' . $this->appConfig['kz_nums'] . '次博饼机会
立即邀请好友助力博饼
获得更多购车金
冲击汽车大奖!!!
'; $popup = array('title' => '邀请好友', 'content' => $content, 'btn' => array('title' => '邀请好友助力', 'url' => '/bobing/pages/game/invite/index')); return array('status' => 1, 'popup' => $popup); } $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(); if ($this->car_id == 15 && $level >= 6) {//ex1用户博到状元时设为罚黑 $dices = $this->dicesAry[rand(1, 6)]; $level = $credit = 0; $level_name = '罚黑'; } $data['uid'] = $this->uid; $data['dices'] = implode(',', $dices); $data['level'] = $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 = ''; if ($re_u['car_gold'] < $this->appConfig['max_car_gold']) {//购车金小于购车金设定值 if ($this->appConfig['ratio_car_gold_kz'] && ($this->appConfig['ratio_car_gold_kz'] <= rand(1, 100))) {//购车金概率 //$car_gold = $this->carGoldAry[rand(1, 7)]; $car_gold = rand(25, 35); if (($car_gold + $re_u['car_gold']) > $this->appConfig['max_car_gold']) {//如果购车金大于设定值,那么本次增加到最大值 $car_gold = $this->appConfig['max_car_gold'] - $re_u['car_gold']; } $data['car_gold'] = $car_gold; $content = '
博到 ' . $car_gold . ' 元购车金!

您已累计获得
' . ($all_car_gold + $car_gold) . ' 元购车金
购车金可无限叠加使用
'; $nums = $this->valid_nums - 1; if ($nums > 0) { $content .= '
今天还可再博' . $nums . '
'; } $popup = array('title' => '恭喜您', 'content' => $content, 'btn' => array('title' => '立即使用购车金', 'url' => '/bobing/pages/game/signUp/index')); } } $re_l = $this->add_log($data); if ($re_l['status'] == 1) { return array('status' => API_CODE_FAIL, 'content' => '博饼日志添加失败'); } $data['level_name'] = $level_name; $data['status'] = 0; $data['lid'] = $re_l['lid']; $data['popup'] = $popup; return $data; } /** * Notes:助力博饼 * Created on: 2021/8/12 17:13 * Created by: dengbw * @return mixed */ public function zl_bo() { $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) { $sum_credit = $this->ci->bobing_logs_model->sum('credit', array('app_id' => $data['app_id'], 'act_key' => $data['act_key'], 'uid' => $data['uid'], 'cf_uid' => $data['cf_uid'])); $sum_car_gold = $this->ci->bobing_logs_model->sum('car_gold', array('app_id' => $data['app_id'], 'act_key' => $data['act_key'], 'uid' => $data['uid'], 'cf_uid' => $data['cf_uid'])); $content = '
您已帮好友博到
' . $sum_credit['credit'] . ' 幸运分和 ' . intval($sum_car_gold['car_gold']) . ' 元购车金
同时您还获得 ' . $sum_credit['credit'] . ' 积分
立即开桌获得更多幸运分
冲刺汽车大奖!
'; $popup = array('title' => '开桌', 'content' => $content, 'btn' => array('title' => '我也要开桌', 'url' => '/bobing/pages/index/index')); return array('status' => 2, 'popup' => $popup); } $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' => $data['uid'])); if ($this->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'] = $credit; $data['bo_date'] = date('Y-m-d'); $data['ip'] = get_client_ip(); $data['ua'] = $_SERVER['HTTP_USER_AGENT']; $data['type'] = 1; $data['c_time'] = time(); $popup = ''; if ($re_u['car_gold'] < $this->appConfig['max_car_gold']) {//购车金小于购车金设定值 if ($this->appConfig['ratio_car_gold_zl'] && ($this->appConfig['ratio_car_gold_zl'] <= rand(1, 100))) {//购车金概率 //$car_gold = $this->carGoldAry[rand(1, 7)]; $car_gold = rand(40, 60); if (($car_gold + $re_u['car_gold']) > $this->appConfig['max_car_gold']) {//如果购车金大于设定值,那么本次增加到最大值 $car_gold = $this->appConfig['max_car_gold'] - $re_u['car_gold']; } $data['car_gold'] = $car_gold; $content = '
恭喜您
帮好友博到' . $car_gold . '元购车金
'; $popup = array('title' => '恭喜您', 'content' => $content, 'btn' => array('title' => '我也要博大奖' , 'url' => '/bobing/pages/index/index')); } } $hong_bao_day = $this->ci->bobing_logs_model->sum('hong_bao', array('app_id' => $this->appConfig['app_id'], 'act_key' => $this->appConfig['act_key'] , 'bo_date' => date('Y-m-d'), 'status' => 2)); if ($hong_bao_day['hong_bao'] < $this->appConfig['max_hong_bao_day']) {//无购车金时抽红包与红包小于每日设定值 if ($this->appConfig['ratio_hong_bao'] && $this->appConfig['ratio_hong_bao'] <= rand(1, 100)) {//红包概率 $hb_count = $this->ci->bobing_logs_model->count(array('app_id' => $data['app_id'], 'act_key' => $data['act_key'], 'uid' => $data['uid'] , 'cf_uid' => $data['cf_uid'], 'hong_bao >' => 0)); if (!$hb_count) {//帮博时最多出现1次红包 //$hong_bao = '0.' . rand(30, 68); $hong_bao = '0.30'; $data['hong_bao'] = $hong_bao; $data['status'] = 1; $this->ci->bobing_user_model->hongBaoDay($data['act_key'], $hong_bao); } } } $log = $this->add_log($data); if ($log['status'] == 1) { return array('status' => API_CODE_FAIL, 'content' => '博饼日志添加失败'); } $data['level_name'] = $level_name; $data['status'] = 0; $data['lid'] = $log['lid']; $data['popup'] = $popup; return $data; } /** * Notes:添加企业微信加购车金 * Created on: 2021/8/25 10:04 * Created by: dengbw */ public function wxqy_car_gold() { $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' => '已添过企业微信加购车金了'); } $data['app_id'] = $this->appConfig['app_id']; $data['act_key'] = $this->appConfig['act_key']; $data['uid'] = $this->uid; $data['credit'] = 0; $data['car_gold'] = $this->appConfig['wxqy_nums']; $data['bo_date'] = date('Y-m-d'); $data['ip'] = get_client_ip(); $data['ua'] = $_SERVER['HTTP_USER_AGENT']; $data['type'] = 2; $data['c_time'] = time(); $log = $this->add_log($data); if ($log['status'] == 1) { return array('status' => -1, 'content' => '博饼日志添加失败'); } return array('status' => $log['lid'], 'content' => '企业微信加购车金成功'); } //博饼结果保存到数据库 private function add_log($data) { $_data['status'] = 0; $this->ci->bobing_logs_model->db->trans_begin(); try { $lid = $this->ci->bobing_logs_model->add($data); if ($lid) { $map = array('act_key' => $data['act_key'], 'app_id' => $data['app_id'], 'uid' => $data['uid']); $up_data["credit = credit+{$data['credit']}"] = null;//加积分 if ($data['type'] == 2) {//加企业微信 $up_data["wxqy"] = 1; $up_data["buy_car_gold"] = $data['car_gold']; } else { $data['car_gold'] && $up_data["car_gold = car_gold+{$data['car_gold']}"] = null;//加购车金 } $this->ci->bobing_user_model->update($up_data, $map); $map['bo_date'] = $data['bo_date']; $re_c = $this->ci->bobing_user_credit_model->get($map); if ($re_c) { $this->ci->bobing_user_credit_model->update(array("credit = credit+{$data['credit']}" => null), $map); } else { $map['credit'] = $data['credit']; $map['c_time'] = time(); $this->ci->bobing_user_credit_model->add($map); } //助力加分 if ($data['type'] == 1) { $map_my = array('act_key' => $data['act_key'], 'app_id' => $data['app_id'], 'uid' => $data['cf_uid']); $this->ci->bobing_user_model->update(array("credit = credit+{$data['credit']}" => null), $map_my); $map_my['bo_date'] = $data['bo_date']; $re_c = $this->ci->bobing_user_credit_model->get($map_my); if ($re_c) { $this->ci->bobing_user_credit_model->update(array("credit = credit+{$data['credit']}" => null), $map_my); } else { $map_my['credit'] = $data['credit']; $map_my['c_time'] = time(); $this->ci->bobing_user_credit_model->add($map_my); } } $this->ci->bobing_user_model->boNums($data['act_key'], 1); } $_data['lid'] = $lid; } catch (Exception $e) { $this->ci->bobing_logs_model->db->trans_rollback(); $_data['status'] = 1; return $_data; } if ($this->ci->bobing_logs_model->db->trans_status() === FALSE) { $this->ci->bobing_logs_model->db->trans_rollback(); $_data['status'] = 1; return $_data; } $this->ci->bobing_logs_model->db->trans_commit(); return $_data; } }