更新
This commit is contained in:
@@ -289,6 +289,45 @@ class OrderController extends BaseAdminController
|
||||
return $this->success($msg, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 拆分订单:生成多笔子单(待支付/待审核/已支付继承支付信息),金额合计须等于原单;原单软删除;业务订单关联自动迁移
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function split()
|
||||
{
|
||||
$params = (new OrderValidate())->post()->goCheck('split');
|
||||
$orderId = (int) $params['id'];
|
||||
$amounts = $params['amounts'] ?? [];
|
||||
if (! is_array($amounts)) {
|
||||
return $this->fail('子单金额格式错误');
|
||||
}
|
||||
$orderTypes = $params['order_types'] ?? [];
|
||||
if (! is_array($orderTypes)) {
|
||||
return $this->fail('子单订单类型格式错误');
|
||||
}
|
||||
|
||||
$order = \app\common\model\Order::find($orderId);
|
||||
if (! $order) {
|
||||
return $this->fail('订单不存在');
|
||||
}
|
||||
if (! $this->canEditOrder($order)) {
|
||||
return $this->fail('无权限拆分此订单');
|
||||
}
|
||||
|
||||
$result = OrderLogic::split($orderId, $amounts, $orderTypes);
|
||||
if ($result === false) {
|
||||
return $this->fail(OrderLogic::getError());
|
||||
}
|
||||
|
||||
$summary = '拆分为子单 id=' . implode(',', $result['new_order_ids'] ?? []);
|
||||
$this->logOrderAction($orderId, 'split', $summary);
|
||||
foreach ($result['new_order_ids'] ?? [] as $nid) {
|
||||
$this->logOrderAction((int) $nid, 'split_child', '来源原单 id=' . $orderId . ' ' . (string) ($order->order_no ?? ''));
|
||||
}
|
||||
|
||||
return $this->success('拆分成功', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 编辑订单(关联患者、订单类型)
|
||||
* 权限:超管或指定角色组可修改任意订单;其他用户只能修改自己创建的订单
|
||||
|
||||
Reference in New Issue
Block a user