完善加项支付接口参数

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;
/** 组合项目代码 */
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<string>;
/**
* 加项组合项目支付信息
*/
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 */

View File

@@ -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) && (
<img
src={nozImage}
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'>