pull/1/head
wanghousheng 1 year ago
parent cb624861d8
commit 6f6c8943ad
  1. 24
      app/api/controller/Recovery.php
  2. 24
      app/api/model/RecoveryOrder.php

@ -68,6 +68,10 @@ class Recovery extends Controller
$model = new RecoveryOrder();
$info = $model->getDetails($recoveryId);
if ($info && !empty($info['images'])) {
$info['is_cancel'] = 0;
if ($info['order_status'] == RecoveryStatusEnum::ACCEPTED) {
$info['is_cancel'] = 1;
}
$images_list = helper::getArrayColumn($info['images'], 'file');
$arr = [];
foreach ($images_list as $image) {
@ -79,6 +83,26 @@ class Recovery extends Controller
return $this->renderSuccess(['detail' => $info]);
}
/**
* @notes:取消订单
* @return Json
* @throws BaseException
* @author: wanghousheng
*/
public function cancel(): Json
{
$recoveryId = intval($this->request->post('recovery_id'));
if (!$recoveryId) {
return $this->renderError('缺少必要参数');
}
$model = new RecoveryOrder();
if ($model->cancel($recoveryId)) {
return $this->renderSuccess('操作成功');
}
return $this->renderError('操作失败');
}
/**
* @notes:新增记录
* @return Json

@ -3,6 +3,7 @@
namespace app\api\model;
use app\api\service\User as UserService;
use app\common\enum\RecoveryStatusEnum;
use app\common\model\RecoveryOrder as BaseRecoveryOrder;
use app\common\service\Order as OrderService;
use cores\exception\BaseException;
@ -100,4 +101,27 @@ class RecoveryOrder extends BaseRecoveryOrder
}
return false;
}
/**
* @notes:取消
* @param int $recoveryId
* @return bool
* @throws BaseException
* @author: wanghousheng
*/
public function cancel(int $recoveryId): bool
{
$where['recovery_id'] = $recoveryId;
// 当前用户ID
$userId = UserService::getCurrentLoginUserId();
if (!UserService::isStore()) {
$where['user_id'] = $userId;
}
$info = static::detail($where);
if (!$info->isEmpty() && $info['order_status'] == RecoveryStatusEnum::ACCEPTED) {
$this->where(['recovery_id' => $recoveryId])->save(['order_status' => RecoveryStatusEnum::CANCEL]);
return true;
}
return false;
}
}
Loading…
Cancel
Save