From c468c57cda239f78f1143cbdf13889834ad75c2b Mon Sep 17 00:00:00 2001 From: ShengLong <452591453@qq.com> Date: Mon, 11 May 2026 11:25:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=B3=E8=81=94=E6=94=AF=E4=BB=98=E5=8D=95?= =?UTF-8?q?=E8=B1=81=E5=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + admin/src/api/order.ts | 5 ++++ admin/src/views/order/index.vue | 27 +++++++++++++++++-- .../controller/order/OrderController.php | 18 +++++++++++++ .../app/adminapi/logic/order/OrderLogic.php | 14 +++++++++- .../logic/tcm/PrescriptionOrderLogic.php | 13 +++++++-- .../2026_05_11_order_exempt_menu.sql | 13 +++++++++ .../migrations/2026_05_11_order_is_exempt.sql | 3 +++ 8 files changed, 89 insertions(+), 5 deletions(-) create mode 100644 server/database/migrations/2026_05_11_order_exempt_menu.sql create mode 100644 server/database/migrations/2026_05_11_order_is_exempt.sql diff --git a/.gitignore b/.gitignore index bd2f47fe..f7dd36f3 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,4 @@ bin-release/ /.kbctx /server/.spool /server/.claude +/.spool diff --git a/admin/src/api/order.ts b/admin/src/api/order.ts index 91ba8688..8f7ac5d2 100644 --- a/admin/src/api/order.ts +++ b/admin/src/api/order.ts @@ -104,3 +104,8 @@ export function orderActionLogStats(params?: { start_time?: string; end_time?: s export function orderBatchAssignAssistant(params: { order_ids: number[]; assistant_id: number }) { return request.post({ url: '/order.order/assignAssistant', params }) } + +/** 设置/取消支付单豁免权 */ +export function orderSetExempt(params: { id: number; is_exempt: 0 | 1 }) { + return request.post({ url: '/order.order/setExempt', params }) +} diff --git a/admin/src/views/order/index.vue b/admin/src/views/order/index.vue index 1ff526c5..55b865f1 100644 --- a/admin/src/views/order/index.vue +++ b/admin/src/views/order/index.vue @@ -180,11 +180,12 @@ - + @@ -270,6 +271,14 @@ > 删除 + + {{ row.is_exempt === 1 ? '取消豁免' : '设为豁免' }} + @@ -779,7 +788,8 @@ import { orderActionLogs, orderActionLogStats, orderBatchAssignAssistant, - orderSplit + orderSplit, + orderSetExempt } from '@/api/order' import { getAssistants } from '@/api/tcm' import { generateOrderQrcode } from '@/api/tcm' @@ -1494,6 +1504,19 @@ const handleDelete = async (row: any) => { } } +const handleToggleExempt = async (row: any) => { + const newVal: 0 | 1 = row.is_exempt === 1 ? 0 : 1 + const actionText = newVal === 1 ? '设为豁免' : '取消豁免' + try { + await feedback.confirm(`确定要${actionText}该支付单吗?豁免后关联此单的业务订单将跳过定金门槛校验。`) + await orderSetExempt({ id: row.id, is_exempt: newVal }) + feedback.msgSuccess(`${actionText}成功`) + getLists() + } catch (error) { + // 用户取消操作 + } +} + // 小程序码相关 const qrcodeDialogVisible = ref(false) const qrcodeLoading = ref(false) diff --git a/server/app/adminapi/controller/order/OrderController.php b/server/app/adminapi/controller/order/OrderController.php index cedef3eb..2dff9aab 100644 --- a/server/app/adminapi/controller/order/OrderController.php +++ b/server/app/adminapi/controller/order/OrderController.php @@ -557,6 +557,24 @@ class OrderController extends BaseAdminController } } + public function setExempt() + { + $id = (int) $this->request->post('id', 0); + $isExempt = (int) $this->request->post('is_exempt', 0); + if ($id <= 0) { + return $this->fail('参数错误'); + } + if (!in_array($isExempt, [0, 1], true)) { + return $this->fail('is_exempt 值无效'); + } + $result = OrderLogic::setExempt($id, $isExempt); + if (!$result) { + return $this->fail(OrderLogic::getError()); + } + $this->logOrderAction($id, 'set_exempt', $isExempt === 1 ? '设置豁免权' : '取消豁免权'); + return $this->success($isExempt === 1 ? '已设置豁免权' : '已取消豁免权'); + } + private function logOrderAction(int $orderId, string $action, string $summary = ''): void { OrderActionLogLogic::record($orderId, (int) $this->adminId, $this->adminInfo, $action, $summary); diff --git a/server/app/adminapi/logic/order/OrderLogic.php b/server/app/adminapi/logic/order/OrderLogic.php index 87209f67..0523c404 100644 --- a/server/app/adminapi/logic/order/OrderLogic.php +++ b/server/app/adminapi/logic/order/OrderLogic.php @@ -1213,7 +1213,7 @@ class OrderLogic } $rows = $q - ->field(['id', 'order_no', 'order_type', 'amount', 'status', 'create_time', 'creator_id', 'remark']) + ->field(['id', 'order_no', 'order_type', 'amount', 'status', 'create_time', 'creator_id', 'remark', 'is_exempt']) ->order('id', 'desc') ->select() ->toArray(); @@ -1400,4 +1400,16 @@ class OrderLogic 'errors' => $errors, ]; } + + public static function setExempt(int $id, int $isExempt): bool + { + $order = Order::find($id); + if (!$order) { + self::setError('订单不存在'); + return false; + } + $order->is_exempt = $isExempt; + $order->save(); + return true; + } } diff --git a/server/app/adminapi/logic/tcm/PrescriptionOrderLogic.php b/server/app/adminapi/logic/tcm/PrescriptionOrderLogic.php index b1d129a0..0234c6fd 100644 --- a/server/app/adminapi/logic/tcm/PrescriptionOrderLogic.php +++ b/server/app/adminapi/logic/tcm/PrescriptionOrderLogic.php @@ -323,7 +323,16 @@ class PrescriptionOrderLogic if ($payOrderIds === []) { return '未关联支付单,关联支付单总金额须大于等于定金门槛 ¥' . $min; } - + + // 豁免权:关联的支付单中有豁免单则跳过金额校验 + $hasExempt = Order::whereIn('id', $payOrderIds) + ->whereNull('delete_time') + ->where('is_exempt', 1) + ->count(); + if ($hasExempt > 0) { + return null; + } + // 检查关联支付单的总金额 $rows = Order::whereIn('id', $payOrderIds)->whereNull('delete_time')->column('amount', 'id'); $totalAmount = 0.0; @@ -503,7 +512,7 @@ class PrescriptionOrderLogic return []; } $rows = Order::whereIn('id', $ids)->whereNull('delete_time') - ->field(['id', 'order_no', 'order_type', 'amount', 'status', 'create_time', 'creator_id', 'remark']) + ->field(['id', 'order_no', 'order_type', 'amount', 'status', 'create_time', 'creator_id', 'remark', 'is_exempt']) ->order('id', 'asc') ->select() ->toArray(); diff --git a/server/database/migrations/2026_05_11_order_exempt_menu.sql b/server/database/migrations/2026_05_11_order_exempt_menu.sql new file mode 100644 index 00000000..34cea3a3 --- /dev/null +++ b/server/database/migrations/2026_05_11_order_exempt_menu.sql @@ -0,0 +1,13 @@ +-- 支付单:设置/取消豁免权(权限节点) +SET @order_menu_id := (SELECT id FROM zyt_system_menu WHERE perms = 'order.order/lists' LIMIT 1); + +INSERT INTO zyt_system_menu ( + pid, type, name, icon, sort, perms, paths, component, + selected, params, is_cache, is_show, is_disable, create_time, update_time +) +SELECT + @order_menu_id, 'A', '设置豁免权', '', 0, 'order.order/setExempt', '', '', + '', '', 0, 1, 0, UNIX_TIMESTAMP(), UNIX_TIMESTAMP() +FROM DUAL +WHERE @order_menu_id IS NOT NULL + AND NOT EXISTS (SELECT 1 FROM zyt_system_menu WHERE perms = 'order.order/setExempt'); diff --git a/server/database/migrations/2026_05_11_order_is_exempt.sql b/server/database/migrations/2026_05_11_order_is_exempt.sql new file mode 100644 index 00000000..1973f51b --- /dev/null +++ b/server/database/migrations/2026_05_11_order_is_exempt.sql @@ -0,0 +1,3 @@ +ALTER TABLE `zyt_order` + ADD COLUMN `is_exempt` tinyint(1) unsigned NOT NULL DEFAULT 0 + COMMENT '豁免权:1=关联此单时跳过定金门槛校验' AFTER `status`;