12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- <?php
- namespace app\api\controller;
- use app\api\model\UsersModel;
- use app\common\lib\WxPay;
- use think\Controller;
- use think\Db;
- /**
- * 宝塔计划任务类
- * @ApiInternal
- * Class Plan
- * @package app\api\controller
- */
- class Plan extends Controller
- {
- // 每月清空VIP开通限制 /api/plan/clearVipData
- public function clearVipData()
- {
- $ids = UsersModel::field('user_id')->select();
- $ip = $this->request->ip();
- foreach ($ids as $v) {
- UsersModel::where('user_id', $v['user_id'])->update(['vip_use_num' => 0, 'vip_discount_quota' => 0]);
- }
- $info = array(
- 'desc' => '每月清空VIP开通限制',
- 'status' => '成功',
- 'ip' => $ip,
- 'time' => date('Y-m-d H:i:s', time())
- );
- Db::name('plan_log')->insert($info);
- }
- // 清空今日已用的基础排队次数 /api/plan/clearTodayQueueUseNum
- public function clearTodayQueueUseNum()
- {
- $ids = UsersModel::field('user_id')->select();
- $ip = $this->request->ip();
- foreach ($ids as $v) {
- UsersModel::where('user_id', $v['user_id'])->update(['queue_num_today' => 0]);
- }
- $info = array(
- 'desc' => '每天清空已用基础排队次数',
- 'status' => '成功',
- 'ip' => $ip,
- 'time' => date('Y-m-d H:i:s', time())
- );
- Db::name('plan_log')->insert($info);
- }
- // 用户白豆每日千分之一递减至红豆
- public function whiteToRed()
- {
- $users = UsersModel::where('user_whitebean', '>', '1')->select();
- $bean = Db::name('setbean')->find();
- foreach ($users as &$v) {
- // 求出每个用户要递减白豆和递加红豆的数量
- $bean = $v['user_whitebean'] * $bean['num'];
- // 红豆递加
- Db::name('users')->where('user_id', $v['user_id'])->setInc('user_redbean', $bean);
- // 白豆递减
- Db::name('users')->where('user_id', $v['user_id'])->setDec('user_whitebean', $bean);
- }
- // 获取当前访问IP
- $ip = $this->request->ip();
- $info = array(
- 'desc' => '白豆红豆递减递加',
- 'status' => '成功',
- 'ip' => $ip,
- 'time' => date('Y-m-d H:i:s', time())
- );
- // 生成记录
- Db::name('plan_log')->insert($info);
- }
- }
|