更新
This commit is contained in:
@@ -312,6 +312,20 @@ class PrescriptionOrderController extends BaseAdminController
|
||||
return $this->success('关联支付单成功', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 已发货/已签收:仅提交完单申请(不新增/关联支付单),并重置支付审核为待审核
|
||||
*/
|
||||
public function requestCompletion()
|
||||
{
|
||||
$params = (new PrescriptionOrderValidate())->post()->goCheck('requestCompletion');
|
||||
$result = PrescriptionOrderLogic::requestCompletion($params, $this->adminId, $this->adminInfo);
|
||||
if ($result === false) {
|
||||
return $this->fail(PrescriptionOrderLogic::getError());
|
||||
}
|
||||
|
||||
return $this->success('完单申请已提交', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将「已发货」且支付审核已通过的订单标记为「已完成」
|
||||
*/
|
||||
|
||||
@@ -2206,8 +2206,8 @@ class PrescriptionOrderLogic
|
||||
$remark = mb_substr(trim((string) ($params['pay_remark'] ?? '')), 0, 200);
|
||||
$completionRequest = (int) ($params['completion_request'] ?? 0);
|
||||
|
||||
if ($amount <= 0) {
|
||||
self::$error = '支付单金额须大于 0';
|
||||
if ($amount < 0) {
|
||||
self::$error = '支付单金额不能为负数';
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -2380,6 +2380,54 @@ class PrescriptionOrderLogic
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* 已发货/已签收订单:不新增/关联支付单,仅提交完单申请并将支付审核置为待审核。
|
||||
*
|
||||
* @param array<string,mixed> $params id
|
||||
* @return array<string,mixed>|false
|
||||
*/
|
||||
public static function requestCompletion(array $params, int $adminId, array $adminInfo)
|
||||
{
|
||||
self::$error = '';
|
||||
$id = (int) $params['id'];
|
||||
$order = PrescriptionOrder::where('id', $id)->whereNull('delete_time')->find();
|
||||
if (!$order) {
|
||||
self::$error = '订单不存在';
|
||||
return false;
|
||||
}
|
||||
if (!self::canAccessOrder($order, $adminId, $adminInfo)) {
|
||||
self::$error = '无权限操作';
|
||||
return false;
|
||||
}
|
||||
if (!in_array((int) $order->fulfillment_status, [5, 6], true)) {
|
||||
self::$error = '仅「已发货」或「已签收」状态的订单可申请完单';
|
||||
return false;
|
||||
}
|
||||
|
||||
$order->completion_request = 1;
|
||||
$order->completion_request_time = time();
|
||||
$order->completion_request_by = $adminId;
|
||||
$order->completion_request_by_name = (string) ($adminInfo['name'] ?? '');
|
||||
$order->payment_slip_audit_status = 0;
|
||||
$order->payment_slip_audit_remark = '';
|
||||
|
||||
try {
|
||||
$order->save();
|
||||
} catch (\Throwable $e) {
|
||||
self::$error = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
|
||||
self::writeLog($id, $adminId, $adminInfo, 'completion_request', '提交完单申请(未新增/关联支付单),等待支付审核');
|
||||
|
||||
$out = $order->toArray();
|
||||
self::maskInternalCostIfNeeded($out, $adminInfo);
|
||||
self::maskRemarkExtraIfNeeded($out, $adminInfo);
|
||||
self::attachLinkedPayOrders($out);
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
/** 完成订单时可选的履约终态:3=已完成,7-12=业务结案类状态 */
|
||||
private const COMPLETE_FULFILLMENT_TARGETS = [3, 7, 8, 9, 10, 11, 12];
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ class PrescriptionOrderValidate extends BaseValidate
|
||||
'fee_type' => 'require|in:1,2,3,4,5,6,7,8',
|
||||
'amount' => 'require|float',
|
||||
'order_type' => 'require|in:1,2,3,4,5,6,7,8',
|
||||
'pay_amount' => 'require|float|gt:0',
|
||||
'pay_amount' => 'require|float|egt:0',
|
||||
'pay_remark' => 'max:200',
|
||||
'remark_extra' => 'max:500',
|
||||
'remark_assistant' => 'max:500',
|
||||
@@ -73,6 +73,7 @@ class PrescriptionOrderValidate extends BaseValidate
|
||||
'paidPayOrders' => ['diagnosis_id'],
|
||||
'addPayOrder' => ['id', 'order_type', 'pay_amount', 'pay_remark'],
|
||||
'linkPayOrder' => ['id', 'pay_order_id'],
|
||||
'requestCompletion' => ['id'],
|
||||
'complete' => ['id', 'fulfillment_status'],
|
||||
'submitGancaoRecipel' => ['id'],
|
||||
'previewGancaoRecipel' => ['id'],
|
||||
|
||||
Reference in New Issue
Block a user