pull/1/head
wanghousheng 10 months ago
parent 75358804bc
commit 5127c1dcac
  1. 13
      app/api/controller/Recovery.php
  2. 2
      app/api/model/RecoveryOrder.php
  3. 6
      app/common/model/RecoveryOrder.php

@ -89,10 +89,23 @@ class Recovery extends Controller
$data['list'] = $list->items(); $data['list'] = $list->items();
$data['total'] = $list->total(); $data['total'] = $list->total();
if ($data['total']) { if ($data['total']) {
$recovery_id = array_column($data['list'], 'recovery_id');
$model = new ServerRecovery();
$recovery_list = $model->whereIn('recovery_id', $recovery_id)
->with(['image'])
->select()
->toArray();
$image_list = [];
if ($recovery_list) {
$image_list = array_column($recovery_list, 'recovery_image', 'recovery_id');
}
foreach ($data['list'] as $key => $value) { foreach ($data['list'] as $key => $value) {
$data['list'][$key]['is_cancel'] = 0; $data['list'][$key]['is_cancel'] = 0;
$data['list'][$key]['is_success'] = 0;
$data['list'][$key]['recovery_image'] = !empty($image_list[$value['recovery_id']]) ?: '';
if ($value['order_status'] == RecoveryStatusEnum::ACCEPTED) { if ($value['order_status'] == RecoveryStatusEnum::ACCEPTED) {
$data['list'][$key]['is_cancel'] = 1; $data['list'][$key]['is_cancel'] = 1;
$data['list'][$key]['is_success'] = 1;
} }
} }
} }

@ -38,7 +38,7 @@ class RecoveryOrder extends BaseRecoveryOrder
$where = array_merge($where, ['user_id' => $userId]); $where = array_merge($where, ['user_id' => $userId]);
} }
//分销商工程师 //分销商工程师
return $this->where($where) return $this
->where($where) ->where($where)
->order(['create_time' => 'desc']) ->order(['create_time' => 'desc'])
->paginate($listRows); ->paginate($listRows);

@ -3,6 +3,7 @@ declare (strict_types=1);
namespace app\common\model; namespace app\common\model;
use app\api\model\Server\ServerRecovery;
use app\common\enum\RecoveryStatusEnum; use app\common\enum\RecoveryStatusEnum;
use app\common\enum\RecoveryTypeEnum; use app\common\enum\RecoveryTypeEnum;
use cores\BaseModel; use cores\BaseModel;
@ -33,6 +34,11 @@ class RecoveryOrder extends BaseModel
return $this->hasMany(RecoveryImage::class, 'order_id', 'order_id')->order(['id']); return $this->hasMany(RecoveryImage::class, 'order_id', 'order_id')->order(['id']);
} }
public function recovery()
{
$this->hasOne(ServerRecovery::class, 'recovery_id', 'recovery_id');
}
public function getOrderStatusTextAttr($value, $data) public function getOrderStatusTextAttr($value, $data)
{ {
$result = RecoveryStatusEnum::data(); $result = RecoveryStatusEnum::data();

Loading…
Cancel
Save