|
|
|
@ -23,6 +23,7 @@ use app\common\model\UploadFile; |
|
|
|
|
use app\common\model\TransferRecord as TransferRecordModel; |
|
|
|
|
use app\api\model\Express as ExpressModel; |
|
|
|
|
use app\common\model\order\Delivery as DeliveryModel; |
|
|
|
|
use app\common\model\Standard as StandardModel; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 订单管理 |
|
|
|
@ -317,4 +318,87 @@ class Order extends Controller |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 审单 |
|
|
|
|
* @param $orderId |
|
|
|
|
* @return Json |
|
|
|
|
*/ |
|
|
|
|
public function standard($orderId): Json |
|
|
|
|
{ |
|
|
|
|
$model = new OrderModel; |
|
|
|
|
$standardCount = new StandardModel(); |
|
|
|
|
$params = $this->postForm(); |
|
|
|
|
$type = $params['type']; |
|
|
|
|
$orderDetail = $model->where('order_id', $orderId)->find(); |
|
|
|
|
$count = $standardCount->where('order_id', $orderId)->count(); |
|
|
|
|
$num = $orderDetail['standard_count'] +1; |
|
|
|
|
if (!$orderDetail) { |
|
|
|
|
return $this->renderError('订单不存在'); |
|
|
|
|
} |
|
|
|
|
//第一次审核 |
|
|
|
|
if (($orderDetail['standard_count'] !=0 && $type == 10) || ($count <1 && $type == 20) ) { |
|
|
|
|
return $this->renderError('审核状态不对'); |
|
|
|
|
} |
|
|
|
|
if($orderDetail['standard_status'] == 30) |
|
|
|
|
{ |
|
|
|
|
return $this->renderError('请先在审单记录当中进行审核'); |
|
|
|
|
} |
|
|
|
|
//第二次审核 |
|
|
|
|
if ($orderDetail['standard_count'] !=1 && $type == 20) { |
|
|
|
|
return $this->renderError('审核状态不对'); |
|
|
|
|
} |
|
|
|
|
if($orderDetail['standard_count'] == 1 || $orderDetail['standard_count'] == 0){ |
|
|
|
|
if ($model->where('order_id', $orderId)->update(['is_standard' => 1,"standard_count"=>$num])) { |
|
|
|
|
// Db::name('order')->where('order_id',$orderId)->Inc('standard_count',1); |
|
|
|
|
return $this->renderSuccess('操作成功'); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return $this->renderError($model->getError() ?: '操作失败'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 获取审单记录 |
|
|
|
|
* @param $orderId |
|
|
|
|
* @return Json |
|
|
|
|
*/ |
|
|
|
|
public function getStandard(int $orderId): Json |
|
|
|
|
{ |
|
|
|
|
$model = new StandardModel; |
|
|
|
|
$list = $model->where("order_id",$orderId)->select(); |
|
|
|
|
foreach ($list as $key => $value) { |
|
|
|
|
$value['order_image_url'] = UploadFile::withoutGlobalScope()->where("file_id",'in',$value['order_image'])->select(); |
|
|
|
|
$value['transfer_image_url'] = UploadFile::withoutGlobalScope()->where("file_id",'in',$value['transfer_image'])->select(); |
|
|
|
|
} |
|
|
|
|
return $this->renderSuccess(compact('list')); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 修改审单记录 |
|
|
|
|
* [10通过 20不通过] |
|
|
|
|
* @param $standardId |
|
|
|
|
* @return Json |
|
|
|
|
*/ |
|
|
|
|
public function updateStandard(int $standardId): Json |
|
|
|
|
{ |
|
|
|
|
$model = new StandardModel; |
|
|
|
|
$standard = $model->where('id', $standardId)->find(); |
|
|
|
|
if (!$standard) { |
|
|
|
|
return $this->renderError('该记录不存在'); |
|
|
|
|
} |
|
|
|
|
if ($standard['standard_status'] == 10|| $standard['standard_status'] == 20) { |
|
|
|
|
return $this->renderError('该订单以审核过了'); |
|
|
|
|
} |
|
|
|
|
$orderId = $standard['order_id']; |
|
|
|
|
$data = $this->postForm(); |
|
|
|
|
$status = $data['standard_status']; |
|
|
|
|
$cause = $data['cause'] ?? ''; |
|
|
|
|
$order = new OrderModel; |
|
|
|
|
if ($status != 10 && $status != 20 ) { |
|
|
|
|
return $this->renderError('状态错误'); |
|
|
|
|
} |
|
|
|
|
$model->where("id",$standardId)->update(['standard_status'=>$status ,'cause'=>$cause]); |
|
|
|
|
$order->where("order_id",$orderId)->update(['standard_status'=>$status,'standard_time'=>time(),'cause'=>$cause]); |
|
|
|
|
|
|
|
|
|
return $this->renderSuccess('修改成功'); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|