order("id desc")->paginate(["list_row" => $limit, "page" => $page])->each(function ($item) { $user = \app\common\model\User::where(["id" => $item["buy_user"]])->field("name")->find(); $item["user_name"] = $user->name; $item["add_time"]=date("Y-m-d H:i:s",$item["add_time"]); switch ($item["status"]){ case 0:$item["status"]="未匹配";break; case 1:$item["status"]="已匹配或待支付";break; case 2:$item["status"]="已上传数据";break; case 3:$item["status"]="已完成";break; case 4:$item["status"]="已撤销";break; case 5:$item["status"]="交易失败";break; } if ($item["image"]){ $item["image"]=explode(",",$item["image"]); } return $item; })->toArray(); return $result = ['code' => 0, 'msg' => lang('get info success'), 'data' => $list['data'] ?: [], 'count' => $list['total'] ?: 0]; } $where["admin"]=1; $user=\app\common\model\User::where($where)->field("id,name")->select(); if ($user){ $data=$user->toArray(); }else{ $data=[]; } View::assign("data",$data); return View::fetch(); } /** * 持有订单列表 */ public function push() { if (Request::isPost()) { $name = input("name"); $page = input("page") ?: 1; $limit = input("limit") ?: 10; $where = []; $where[]=["status",">",0]; $where[]=["is_admin","=",0]; $list = \app\common\model\Order::where($where)->order("status asc,id desc")->paginate(["list_row" => $limit, "page" => $page])->each(function ($item) { $user = \app\common\model\User::where(["id" => $item["buy_user"]])->field("name")->find(); $item["user_name"] = $user->name; $item["add_time"]=date("Y-m-d H:i:s",$item["add_time"]); switch ($item["status"]){ case 0:$item["status"]="未匹配";break; case 1:$item["status"]="已匹配或待支付";break; case 2:$item["status"]="已上传数据";break; case 3:$item["status"]="已完成";break; case 4:$item["status"]="已撤销";break; case 5:$item["status"]="交易失败";break; } if ($item["image"]){ $item["image"]=explode(",",$item["image"]); } return $item; })->toArray(); return $result = ['code' => 0, 'msg' => lang('get info success'), 'data' => $list['data'] ?: [], 'count' => $list['total'] ?: 0]; } return View::fetch(); } /** * 申述处理 state */ public function bond() { if (Request::isPost()) { $name = input("name"); $page = input("page") ?: 1; $limit = input("limit") ?: 10; $where = []; // if ($name){ // $where["name"]=["like","% $name %"]; // } $list = State::where($where)->order("id desc")->paginate(["list_row" => $limit, "page" => $page])->each(function ($item) { $user = \app\common\model\User::where(["id" => $item["user_id"]])->field("name")->find(); $item["user_name"] = $user->name; $item["add_time"]=date("Y-m-d H:i:s",$item["add_time"]); if ($item["image"]){ $item["image"]=explode(",",$item["image"]); } return $item; })->toArray(); return $result = ['code' => 0, 'msg' => lang('get info success'), 'data' => $list['data'] ?: [], 'count' => $list['total'] ?: 0]; } return View::fetch(); } // 所有 买入订单匹配 public function allmatching() { } //单个 买入订单匹配 public function matching() { $user_id=input("user_id"); $order_id=input("order_id"); $update["push_user"]=$user_id; $update["status"]=1; $update["is_admin"]=1; $update["stat_time"]=time()+1*3600; OrderS::update($update,["id"=>$order_id]); json_result(200,"匹配成功"); } // 后台账号匹配订单 public function adminorder() { if (Request::isPost()) { $name = input("name"); $page = input("page") ?: 1; $limit = input("limit") ?: 10; $where = []; $where[]=["status",">",0]; $where[]=["is_admin","=",1]; $list = \app\common\model\Order::where($where)->order("status asc,id desc")->paginate(["list_row" => $limit, "page" => $page])->each(function ($item) { $user = \app\common\model\User::where(["id" => $item["buy_user"]])->field("name")->find(); $item["user_name"] = $user->name; $item["add_time"]=date("Y-m-d H:i:s",$item["add_time"]); switch ($item["status"]){ case 0:$item["status"]="未匹配";break; case 1:$item["status"]="已匹配或待支付";break; case 2:$item["status"]="已上传数据";break; case 3:$item["status"]="已完成";break; case 4:$item["status"]="已撤销";break; case 5:$item["status"]="交易失败";break; } if ($item["image"]){ $item["image"]=explode(",",$item["image"]); } return $item; })->toArray(); return $result = ['code' => 0, 'msg' => lang('get info success'), 'data' => $list['data'] ?: [], 'count' => $list['total'] ?: 0]; } return View::fetch(); } // 驳回订单 public function reject() { $id=input("id"); $msg=input("text"); $where["id"]=$id; $order=\app\common\model\Order::where($where)->find(); if ($order->status==3){ json_result(400,"该订单已经完成或交易失败"); } Orde::order_fail($msg,$order); json_result(200,"驳回成功"); } // 交易成功 public function confirms() { $id=input("id"); $where["id"]=$id; $order=\app\common\model\Order::where($where)->find(); // if ($order->status==3||$order->status==4||$order->status==5){ if ($order->status==3){ json_result(400,"该订单已经完成或交易失败"); } Orde::order_success($order); json_result(200,"交易成功"); } }