106 lines
3.6 KiB
PHP
106 lines
3.6 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Notes:博饼任务
|
|
* Created on: 2021/8/20 17:15
|
|
* Created by: dengbw
|
|
*/
|
|
class Bobing extends HD_Controller
|
|
{
|
|
|
|
private $log_file;
|
|
private $appConfig;
|
|
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->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['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');
|
|
if ($res_c) {//设置中奖用户
|
|
foreach ($res_c as $key => $value) {
|
|
//设中奖
|
|
$this->mdBobingUserCredit->update(array('lottery' => 1), array('id' => $value['id']));
|
|
//加中奖购车金
|
|
$this->mdBobingUser->update(array('lotter_gold' => $this->appConfig['lotter_gold'])
|
|
, array('uid' => $value['uid'], 'app_id' => $this->appConfig['app_id'], 'act_key' => $this->appConfig['act_key']));
|
|
}
|
|
$lottery = json_encode($res_c, JSON_UNESCAPED_UNICODE);
|
|
debug_log('lottery:' . $lottery, $this->log_file);
|
|
echo json_encode($lottery, JSON_UNESCAPED_UNICODE);
|
|
return;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Notes:
|
|
* Created on: 2021/9/8 11:59
|
|
* Created by: dengbw
|
|
*/
|
|
public function mj()
|
|
{
|
|
$hour = date('H');
|
|
if ($hour > 9 && $hour > 22) {
|
|
echo '9点到22点博';
|
|
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;
|
|
}
|
|
$uid = 14;
|
|
$credit = rand(50, 120);
|
|
$this->mdBobingUser->update(array('credit' => $credit), array('uid' => $uid,
|
|
'app_id' => $this->appConfig['app_id'], 'act_key' => $this->appConfig['act_key']));
|
|
}
|
|
}
|