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){ // $order=$order->toArray(); 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); } } } } } } }