完善加项支付接口参数

This commit is contained in:
xianyi
2026-01-05 10:26:36 +08:00
parent f6cc55582e
commit 5baf9270c0
2 changed files with 57 additions and 24 deletions

View File

@@ -524,6 +524,8 @@ export interface PoPhysicalExamAddItem {
times?: number | null; times?: number | null;
/** 组合项目代码 */ /** 组合项目代码 */
combination_item_code?: number | null; combination_item_code?: number | null;
/** 是否享受折扣1-是 0-否) */
is_enjoy_discount?: number | null;
} }
/** /**
@@ -546,6 +548,8 @@ export interface OutputPhysicalExamAddItem {
times?: number | null; times?: number | null;
/** 组合项目代码 */ /** 组合项目代码 */
combination_item_code?: 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<string>; export type PhysicalExamQrcodeCreateResponse = CommonActionResult<string>;
/**
* 加项组合项目支付信息
*/
export interface InputAddItemCombinationInfo {
/** 体检组合项目代码 */
combination_item_code: string;
/** 体检组合项目价格 */
combination_item_price: number;
/** 折扣比例 */
discount_rate: number;
}
/** /**
* 体检支付结果查询入参Native 查询支付是否成功) * 体检支付结果查询入参Native 查询支付是否成功)
*/ */
@@ -643,10 +659,8 @@ export interface InputOrderPaymentInfo {
physical_exam_id: number; physical_exam_id: number;
/** 患者ID */ /** 患者ID */
patient_id: number; patient_id: number;
/** 体检组合项目代码addItemList.combination_item_code 多个加项逗号分隔) */ /** 体检组合项目信息 */
combinationItemCodes: string; listAddItemCombination?: InputAddItemCombinationInfo[] | null;
/** 折扣比例 */
discount_rate: number;
/** 支付方式12-微信 13-挂账公司) */ /** 支付方式12-微信 13-挂账公司) */
pay_type: number; pay_type: number;
/** 挂账公司ID挂账公司传对应的ID其他传0 */ /** 挂账公司ID挂账公司传对应的ID其他传0 */

View File

@@ -20,6 +20,7 @@ interface AddonItem {
originalPrice?: string; originalPrice?: string;
currentPrice?: string; currentPrice?: string;
combinationItemCode?: number | null; combinationItemCode?: number | null;
isEnjoyDiscount?: number | null;
} }
interface ExamAddonPanelProps { interface ExamAddonPanelProps {
@@ -210,6 +211,7 @@ export const ExamAddonPanel = ({ client }: ExamAddonPanelProps) => {
? Number(item.original_price).toFixed(2) ? Number(item.original_price).toFixed(2)
: '0.00', : '0.00',
combinationItemCode: item.combination_item_code ?? null, combinationItemCode: item.combination_item_code ?? null,
isEnjoyDiscount: item.is_enjoy_discount ?? null,
tags: [], tags: [],
paid: false, paid: false,
})); }));
@@ -412,8 +414,11 @@ export const ExamAddonPanel = ({ client }: ExamAddonPanelProps) => {
const startPaymentPolling = ( const startPaymentPolling = (
physical_exam_id: number, physical_exam_id: number,
patient_id: number, patient_id: number,
combinationItemCodes: string, listAddItemCombination: Array<{
discount_rate: number, combination_item_code: string;
combination_item_price: number;
discount_rate: number;
}>,
pay_type: number, pay_type: number,
company_id: number company_id: number
) => { ) => {
@@ -426,8 +431,7 @@ export const ExamAddonPanel = ({ client }: ExamAddonPanelProps) => {
const res = await checkNativePaymentStatus({ const res = await checkNativePaymentStatus({
physical_exam_id, physical_exam_id,
patient_id, patient_id,
combinationItemCodes, listAddItemCombination,
discount_rate,
pay_type, pay_type,
company_id, company_id,
}); });
@@ -497,18 +501,33 @@ export const ExamAddonPanel = ({ client }: ExamAddonPanelProps) => {
try { try {
const selectedItems = allAddons.filter((item) => selectedIds.has(item.id || item.name)); const selectedItems = allAddons.filter((item) => selectedIds.has(item.id || item.name));
// 获取组合项目代码combination_item_code // 构建加项组合项目信息列表
const combinationItemCodes = selectedItems const listAddItemCombination = selectedItems
.map((item) => item.combinationItemCode) .map((item) => {
.filter((code) => code !== null && code !== undefined) const combinationItemCode = item.combinationItemCode;
.join(','); 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('缺少加项信息,请稍后重试'); setPaymentMessage('缺少加项信息,请稍后重试');
setPaymentLoading(false); setPaymentLoading(false);
return; return;
} }
// 获取组合项目代码(用于生成二维码接口,多个加项逗号分隔)
const combinationItemCodes = listAddItemCombination
.map((item) => item.combination_item_code)
.join(',');
// 获取 patient_id必须从接口返回的客户信息中获取 // 获取 patient_id必须从接口返回的客户信息中获取
if (!customerInfo?.patient_id) { if (!customerInfo?.patient_id) {
setPaymentMessage('缺少患者ID请稍后重试'); setPaymentMessage('缺少患者ID请稍后重试');
@@ -539,8 +558,7 @@ export const ExamAddonPanel = ({ client }: ExamAddonPanelProps) => {
startPaymentPolling( startPaymentPolling(
physical_exam_id, physical_exam_id,
patient_id, patient_id,
combinationItemCodes, listAddItemCombination,
discountRatio,
12, // 微信支付 12, // 微信支付
0 // 自费模式company_id 传 0 0 // 自费模式company_id 传 0
); );
@@ -562,8 +580,7 @@ export const ExamAddonPanel = ({ client }: ExamAddonPanelProps) => {
const res = await checkNativePaymentStatus({ const res = await checkNativePaymentStatus({
physical_exam_id, physical_exam_id,
patient_id, patient_id,
combinationItemCodes, listAddItemCombination,
discount_rate: discountRatio,
pay_type: 13, // 挂账公司 pay_type: 13, // 挂账公司
company_id: selectedCompany.company_id, 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' className='border rounded-lg p-3 cursor-pointer transition-all flex flex-col relative'
onClick={() => toggleSelect(id)} onClick={() => toggleSelect(id)}
> >
{/* 无折扣标签图片 - 浮动在右上角 */} {/* 无折扣标签图片 - 浮动在右上角(当 is_enjoy_discount 为 0 或 null 时显示) */}
<img {(!item.isEnjoyDiscount || item.isEnjoyDiscount === 0) && (
src={nozImage} <img
alt='无折扣' src={nozImage}
className='absolute top-[-10px] right-[-10px] w-12 h-12 object-contain pointer-events-none z-10' alt='无折扣'
/> className='absolute top-[-10px] right-[-10px] w-12 h-12 object-contain pointer-events-none z-10'
/>
)}
{/* 第一行:复选框 + 名称 */} {/* 第一行:复选框 + 名称 */}
<div className='flex items-start gap-2 mb-1'> <div className='flex items-start gap-2 mb-1'>