success('请求成功'); } public function cancel(){ $token = $this->request->request("token"); if (md5("ikea")!=$token){ return; } $model=new Order(); $order = $model->field("GROUP_CONCAT(id) ids")->where([ "createtime"=>["<",time()-1800], "have_paid"=>0, "status"=>1, ])->find(); if (!$order){ return; } $ids=explode(",",$order->ids); $orderProduct = new OrderProduct(); $list =$orderProduct->where([ 'order_id' => ["in",$ids], ])->select(); $list = collection($list)->toArray(); $product = new \app\admin\model\unishop\Product(); foreach ($list as $val){ $product->where(["id"=>$val['product_id']])->setInc("stock",$val["number"]); } $model->save(["status"=>0],["id"=>["in",$ids]]); } }