wanghousheng 8 months ago
parent 7afd8f99d1
commit 717de7f96b
  1. 8
      app/api/controller/Recovery.php
  2. 15
      app/common/model/RecoveryOrder.php
  3. 43
      app/store/controller/Recovery.php

@ -134,7 +134,6 @@ class Recovery extends Controller
if (empty($params['order_id']) || empty($params['recovery_id']) || empty($params['status'])) {
return $this->renderError('缺少必要参数');
}
$model = (new RecoveryOrder())::detail($params['order_id']);
if ($model) {
if ($params['status'] == RecoveryStatusEnum::ALREADY || $params['status'] == RecoveryStatusEnum::FINISN) {
@ -144,7 +143,6 @@ class Recovery extends Controller
}
}
}
return $this->renderError('更新失败');
}
@ -408,6 +406,10 @@ class Recovery extends Controller
public function completeOrder(): Json
{
$order_id = intval($this->request->post('order_id'));
$real_price = $this->request->post('real_price');
if (!$real_price || helper::number2($real_price) <= 0) {
return $this->renderError('回收价不能为空');
}
if (!$order_id) {
return $this->renderError('缺少必要参数');
}
@ -415,7 +417,7 @@ class Recovery extends Controller
return $this->renderError('订单信息不存在');
}
$model = new RecoveryOrder();
if ($model->where(['order_id' => $order_id])->save(['order_status' => RecoveryStatusEnum::ALREADY])) {
if ($model->where(['order_id' => $order_id])->save(['order_status' => RecoveryStatusEnum::ALREADY, 'real_price' => helper::number2($real_price)])) {
return $this->renderSuccess('操作成功');
}
return $this->renderError('操作失败');

@ -33,13 +33,9 @@ class RecoveryOrder extends BaseModel
*/
public function images(): HasMany
{
return $this->hasMany(RecoveryImage::class, 'order_id', 'order_id')->order(['id']);
return $this->hasMany(RecoveryImage::class, 'order_id')->order(['id']);
}
public function recovery()
{
$this->hasOne(ServerRecovery::class, 'recovery_id', 'recovery_id');
}
public function getOrderStatusTextAttr($value, $data)
{
@ -71,10 +67,19 @@ class RecoveryOrder extends BaseModel
return static::get($where, $with);
}
public function user(): HasOne
{
return $this->hasOne(User::class, 'user_id', 'user_id');
}
public function shop(): HasOne
{
return $this->hasOne(Shop::class, 'shop_id', 'shop_id');
}
public function recovery(): HasOne
{
return $this->hasOne(ServerRecovery::class, 'recovery_id', 'recovery_id');
}
}

@ -203,23 +203,46 @@ class Recovery extends Controller
*/
public function orderList(Request $request): Json
{
$params = $request->param();
$filter = [];
if(!empty($params['order_no'])) {
$filter[] = ['order_no', 'like', "%{$params['order_no']}%"];
$server_name = $this->request->post('recovery_name');
$order_no = $this->request->post('order_no');
$order_status = intval($this->request->post('order_status'));
$user_mobile = $this->request->post('user_mobile');
$where = [];
if (!empty($server_name)) {
$where[] = ['a.recovery_name', 'like', "%$server_name%"];
}
if (!empty($params['order_status']) && $params['order_status'] != 'all') {
$filter[] = ['order_status', '=', $params['order_status']];
if (!empty($order_no)) {
$where[] = ['a.order_no', '=', $order_no];
}
if ($order_status) {
$where[] = ['a.order_status', '=', $order_status];
}
if ($user_mobile) {
$where[] = ['b.mobile', '=', $user_mobile];
}
$model = new RecoveryOrder();
$list = $model->where($filter)
$list = $model->where($where)
->alias('a')
->join('user b', 'b.user_id = a.user_id')
->field('a.*,b.mobile as user_mobile,b.nick_name as user_nick_name')
->order('create_time', 'desc')
->paginate(10);
return $this->renderSuccess(compact('list'));
->paginate(15);
$data['list'] = $list->items();
$data['total'] = $list->total();
return $this->renderSuccess($data);
}
/**
* @notes:订单详情
* @return Json
* @author: wanghousheng
*/
public function orderDetail(): Json
{
$orderId = intval($this->request->post('orderId'));
$data = RecoveryOrder::detail(['order_id' => $orderId], ['images.file', 'shop', 'user']);
return $this->renderSuccess(['detail' => $data]);
}
}
Loading…
Cancel
Save