123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- <?php
- namespace app\worker\controller;
- use app\common\controller\Orde;
- use app\common\model\Order;
- use think\facade\Db;
- use Workerman\Lib\Timer;
- use app\common\model\User as USers;
- class User
- {
-
- public function index()
- {
- Timer::add(5, function () {
- $this->order_cal();
- }, true);
- }
-
- public function fb()
- {
- Timer::add(20,function (){
- $this->fab();
- },true);
- }
-
- public function order_cal()
- {
- $where[]=["stat_time","<",time()];
- $where[]=["status","=",1];
- $order=Order::where($where)->limit(5)->order("id asc")->select();
- if ($order){
- foreach ($order as $v){
- Orde::order_fail("系统处理交易失败",$v);
- }
- }
- }
- public function test()
- {
- dump(1212);
- }
- public function fab()
- {
- $list = Db::name('system')
- ->where(["type"=>"fb"])
- ->field('name,value')
- ->column('value','name');
- if ($list["fbkg"]){
-
- $count=Order::where(["status"=>0])->count();
- if ($count){
-
- $fbsamll=$list["fbsamll"];
- $now=$count/$fbsamll;
- if ($now>1){
- $now=round($now);
- $order=Order::where(["status"=>0])->orderRaw('rand()')->limit($now)->column("id");
- if ($order){
- foreach ($order as $v){
- $mnum=rand(100,999);
-
- $user= USers::where(["admin"=>1])->orderRaw('rand()')->limit(1)->value("id");
- $wheres["id"]=$v;
- $update["stat_time"]=time()+(1*3600+$mnum);
- $update["is_admin"]=1;
- $update["status"]=1;
- $update["push_user"]=$user;
- Order::update($update,$wheres);
- }
- }
- }
- }
- }
- }
- }
|