log_file = 'bobing.log'; $this->load->model('bobing/bobing_user_model', 'mdBobingUser'); $this->load->model('bobing/bobing_user_credit_model', 'mdBobingUserCredit'); $this->appConfig = $this->mdBobingUser->appConfig(); } public function index() { } /** * Notes:设置每日中奖 * Created on: 2021/8/27 17:20 * Created by: dengbw * https://liche-api-dev.xiaoyu.com/plan/bobing/lottery * https://api.liche.cn/plan/bobing/lottery */ public function lottery() { $params = $this->input->get(); $hour = date('H'); if ($hour != '00' && !$params['sd']) { echo '[0]点过后才会开奖昨天的中奖用户[' . $hour . ']'; return; } if ($this->appConfig['game_start_date'] > date('Y-m-d')) { echo '博饼未开始'; return; } $date = date('Y-m-d', strtotime('+1 day')); if ($this->appConfig['game_end_date'] < $date) { echo '博饼已结束'; return; } $date = date('Y-m-d', strtotime('-1 day'));//中奖用户 $where = array('app_id' => $this->appConfig['app_id'], 'act_key' => $this->appConfig['act_key'], 'bo_date' => $date, 'lottery' => 1); $re = $this->mdBobingUserCredit->get($where); if ($re) { echo '[' . $date . ']已执行过中奖了'; return; } $where['lottery'] = 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'); if ($res_c) {//设置中奖用户 $ids = implode(',', array_column($res_c, 'id'));//中奖用户 $this->mdBobingUserCredit->update(array('lottery' => 1), array('id in (' . $ids . ')' => null)); $lottery = json_encode($res_c, JSON_UNESCAPED_UNICODE); debug_log('lottery:' . $lottery, $this->log_file); echo json_encode($lottery, JSON_UNESCAPED_UNICODE); return; } } }