From 5baf9270c079bfe742d8f0cccfc3aed6c5913f83 Mon Sep 17 00:00:00 2001 From: xianyi Date: Mon, 5 Jan 2026 10:26:36 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E5=8A=A0=E9=A1=B9=E6=94=AF?= =?UTF-8?q?=E4=BB=98=E6=8E=A5=E5=8F=A3=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/types.ts | 22 ++++++++-- src/components/exam/ExamAddonPanel.tsx | 59 +++++++++++++++++--------- 2 files changed, 57 insertions(+), 24 deletions(-) diff --git a/src/api/types.ts b/src/api/types.ts index 94df6de..7cb852b 100644 --- a/src/api/types.ts +++ b/src/api/types.ts @@ -524,6 +524,8 @@ export interface PoPhysicalExamAddItem { times?: number | null; /** 组合项目代码 */ combination_item_code?: number | null; + /** 是否享受折扣(1-是 0-否) */ + is_enjoy_discount?: number | null; } /** @@ -546,6 +548,8 @@ export interface OutputPhysicalExamAddItem { times?: number | null; /** 组合项目代码 */ combination_item_code?: number | null; + /** 是否享受折扣(1-是 0-否) */ + is_enjoy_discount?: number | null; } /** @@ -635,6 +639,18 @@ export interface InputPhysicalExamAddOrder { */ export type PhysicalExamQrcodeCreateResponse = CommonActionResult; +/** + * 加项组合项目支付信息 + */ +export interface InputAddItemCombinationInfo { + /** 体检组合项目代码 */ + combination_item_code: string; + /** 体检组合项目价格 */ + combination_item_price: number; + /** 折扣比例 */ + discount_rate: number; +} + /** * 体检支付结果查询入参(Native 查询支付是否成功) */ @@ -643,10 +659,8 @@ export interface InputOrderPaymentInfo { physical_exam_id: number; /** 患者ID */ patient_id: number; - /** 体检组合项目代码(addItemList.combination_item_code 多个加项逗号分隔) */ - combinationItemCodes: string; - /** 折扣比例 */ - discount_rate: number; + /** 体检组合项目信息 */ + listAddItemCombination?: InputAddItemCombinationInfo[] | null; /** 支付方式(12-微信 13-挂账公司) */ pay_type: number; /** 挂账公司ID(挂账公司传对应的ID,其他传0) */ diff --git a/src/components/exam/ExamAddonPanel.tsx b/src/components/exam/ExamAddonPanel.tsx index 96250a7..3972100 100644 --- a/src/components/exam/ExamAddonPanel.tsx +++ b/src/components/exam/ExamAddonPanel.tsx @@ -20,6 +20,7 @@ interface AddonItem { originalPrice?: string; currentPrice?: string; combinationItemCode?: number | null; + isEnjoyDiscount?: number | null; } interface ExamAddonPanelProps { @@ -210,6 +211,7 @@ export const ExamAddonPanel = ({ client }: ExamAddonPanelProps) => { ? Number(item.original_price).toFixed(2) : '0.00', combinationItemCode: item.combination_item_code ?? null, + isEnjoyDiscount: item.is_enjoy_discount ?? null, tags: [], paid: false, })); @@ -412,8 +414,11 @@ export const ExamAddonPanel = ({ client }: ExamAddonPanelProps) => { const startPaymentPolling = ( physical_exam_id: number, patient_id: number, - combinationItemCodes: string, - discount_rate: number, + listAddItemCombination: Array<{ + combination_item_code: string; + combination_item_price: number; + discount_rate: number; + }>, pay_type: number, company_id: number ) => { @@ -426,8 +431,7 @@ export const ExamAddonPanel = ({ client }: ExamAddonPanelProps) => { const res = await checkNativePaymentStatus({ physical_exam_id, patient_id, - combinationItemCodes, - discount_rate, + listAddItemCombination, pay_type, company_id, }); @@ -497,18 +501,33 @@ export const ExamAddonPanel = ({ client }: ExamAddonPanelProps) => { try { const selectedItems = allAddons.filter((item) => selectedIds.has(item.id || item.name)); - // 获取组合项目代码(combination_item_code) - const combinationItemCodes = selectedItems - .map((item) => item.combinationItemCode) - .filter((code) => code !== null && code !== undefined) - .join(','); + // 构建加项组合项目信息列表 + const listAddItemCombination = selectedItems + .map((item) => { + const combinationItemCode = item.combinationItemCode; + if (combinationItemCode === null || combinationItemCode === undefined) { + return null; + } + const combinationItemPrice = parseFloat(item.currentPrice || item.originalPrice || '0'); + return { + combination_item_code: String(combinationItemCode), + combination_item_price: combinationItemPrice, + discount_rate: discountRatio, + }; + }) + .filter((item): item is { combination_item_code: string; combination_item_price: number; discount_rate: number } => item !== null); - if (!combinationItemCodes) { + if (listAddItemCombination.length === 0) { setPaymentMessage('缺少加项信息,请稍后重试'); setPaymentLoading(false); return; } + // 获取组合项目代码(用于生成二维码接口,多个加项逗号分隔) + const combinationItemCodes = listAddItemCombination + .map((item) => item.combination_item_code) + .join(','); + // 获取 patient_id(必须从接口返回的客户信息中获取) if (!customerInfo?.patient_id) { setPaymentMessage('缺少患者ID,请稍后重试'); @@ -539,8 +558,7 @@ export const ExamAddonPanel = ({ client }: ExamAddonPanelProps) => { startPaymentPolling( physical_exam_id, patient_id, - combinationItemCodes, - discountRatio, + listAddItemCombination, 12, // 微信支付 0 // 自费模式,company_id 传 0 ); @@ -562,8 +580,7 @@ export const ExamAddonPanel = ({ client }: ExamAddonPanelProps) => { const res = await checkNativePaymentStatus({ physical_exam_id, patient_id, - combinationItemCodes, - discount_rate: discountRatio, + listAddItemCombination, pay_type: 13, // 挂账公司 company_id: selectedCompany.company_id, }); @@ -697,12 +714,14 @@ export const ExamAddonPanel = ({ client }: ExamAddonPanelProps) => { className='border rounded-lg p-3 cursor-pointer transition-all flex flex-col relative' onClick={() => toggleSelect(id)} > - {/* 无折扣标签图片 - 浮动在右上角 */} - 无折扣 + {/* 无折扣标签图片 - 浮动在右上角(当 is_enjoy_discount 为 0 或 null 时显示) */} + {(!item.isEnjoyDiscount || item.isEnjoyDiscount === 0) && ( + 无折扣 + )} {/* 第一行:复选框 + 名称 */}