Explorar el Código

feat(汇安融): 下单表单与接入文档同步 260924(biz 透传、trade_type 取值改名)

后端只负责透传,取值规则得由调用侧给上:

- HAR_TRADE_TYPE_OPTIONS 的非分期值改 alipay_un_stage。
- 新增 HAR_BIZ_UN_STAGE = "har_ali_un_stage"(规范只给了这一个取值)。
- 下单表单非分期时自带 biz;切到分期时清空 —— 分期那个取值规范没写,不猜。切回
  非分期会把 biz 补回来,否则「清掉它再切回来」会停在「非分期却不带 biz」。

har-openapi.md 是租户可见的契约,同步三处:trade_type 取值、新增 biz 行、回调样例
里的 trade_type。

验证:frontend/ 没有测试框架,ts:check 有 289 条历史遗留(命令恒 exit 2),所以只做同机
前后差分 —— 与 HEAD 跑出来的输出逐字节相同(sha256 4d85f23a…,289 条),零新增。
配正对照证明检查器确实在读这两个被改文件:往 har.ts 与 order/index.vue 各注入一条类型
错误,各多出 1 条、命中到正确文件行,其余 289 行逐字节不变;随后按备份还原,两个文件的
sha256 与改前一致。
alphaH hace 3 semanas
padre
commit
e8b9c1f9c8

+ 14 - 2
frontend/src/api/module_payment/har.ts

@@ -99,8 +99,10 @@ export interface HarOrderVO {
   third_shop_code?: string;
   price: string;
   title?: string;
-  /** alipay_stage=花呗分期 / alipay_payment=支付宝支付 */
+  /** alipay_stage=花呗分期 / alipay_un_stage=支付宝支付(260924 前叫 alipay_payment) */
   trade_type?: string;
+  /** 业务类型。非分期传 har_ali_un_stage(规范 260924 订单创建参数表 biz 行) */
+  biz?: string;
   stage_num?: string;
   /** 100=商户承担 / 0=用户承担 */
   percent?: string;
@@ -136,6 +138,12 @@ export interface HarOrderCreateParams {
   price: number | string;
   title: string;
   trade_type: string;
+  /**
+   * 业务类型。选填。规范 260924 订单创建参数表 biz 行:非分期传 `har_ali_un_stage`。
+   *
+   * 后端原样透传、不推导 —— 所以下单表单在非分期时自己带上这个值(见 order/index.vue)。
+   */
+  biz?: string;
   /** 分期时必填,3/6/12/24 */
   stage_num?: string;
   /** 分期时必填 */
@@ -161,11 +169,15 @@ export interface HarOrderQueryParams {
   page_size?: number;
 }
 
+/** 交易方式。非分期那个值 260924 起叫 alipay_un_stage(此前是 alipay_payment)。 */
 export const HAR_TRADE_TYPE_OPTIONS = [
-  { label: "支付宝支付", value: "alipay_payment" },
+  { label: "支付宝支付", value: "alipay_un_stage" },
   { label: "花呗分期", value: "alipay_stage" },
 ];
 
+/** 非分期的业务类型(上游 biz)。规范 260924 订单创建参数表 biz 行 只给了这一个取值。 */
+export const HAR_BIZ_UN_STAGE = "har_ali_un_stage";
+
 /** 上游订单状态枚举,与后端 HarOrderStatus 逐字一致 */
 export const HAR_TRADE_STATUS_TEXT: Record<string, string> = {
   "0": "等待支付",

+ 3 - 2
frontend/src/views/module_payment/apikey/docs/har-openapi.md

@@ -94,7 +94,8 @@ POST /payment/openapi/har/order/create
 | `merchant_code` | string | 否 | **你租户下配了多个商户号时必填**:这笔钱收进哪一个商户,见本章开头 |
 | `price` | number | 是 | 金额,**单位元**,必须 > 0。与 5 章的「整数分」不同,见下 |
 | `title` | string | 是 | 商品名称,≤64 字符 |
-| `trade_type` | string | 是 | `alipay_payment` 支付宝支付 / `alipay_stage` 花呗分期 |
+| `trade_type` | string | 是 | `alipay_un_stage` 支付宝支付 / `alipay_stage` 花呗分期 |
+| `biz` | string | 否 | 业务类型。**非分期传 `har_ali_un_stage`** |
 | `out_biz_no` | string | 否 | 你自己的订单号,≤64 字符,原样存下供你查询 |
 | `auth_code` | string | 否 | 用户的付款码。有值走被扫,不传走主扫 |
 | `stage_num` | string | 否 | 分期期数:`3` / `6` / `12` / `24`。`trade_type=alipay_stage` 时必填 |
@@ -193,7 +194,7 @@ Content-Type: application/x-www-form-urlencoded
   "third_shop_code": "S001",
   "price": 1.50,
   "title": "测试商品",
-  "trade_type": "alipay_payment",
+  "trade_type": "alipay_un_stage",
   "status": "1",
   "trade_time": "2026-09-24T10:30:00+08:00",
   "refund_time": null,

+ 14 - 3
frontend/src/views/module_payment/har/order/index.vue

@@ -415,6 +415,7 @@ import { onMounted, reactive, ref } from "vue";
 import { ElMessage, type FormInstance, type FormRules } from "element-plus";
 import dayjs from "dayjs";
 import HarAPI, {
+  HAR_BIZ_UN_STAGE,
   HAR_NOTIFY_STATUS_TEXT,
   HAR_TRADE_STATUS_TAG,
   HAR_TRADE_STATUS_TEXT,
@@ -471,7 +472,10 @@ const defaultForm = (): OrderForm => ({
   out_biz_no: "",
   price: undefined,
   title: "",
-  trade_type: "alipay_payment",
+  trade_type: "alipay_un_stage",
+  // 非分期要带业务类型(规范 260924)。后端纯透传、不推导,所以这里就得给上;
+  // 分期那个取值规范没写,留空 —— 真缺了上游会点名报出来。
+  biz: HAR_BIZ_UN_STAGE,
   stage_num: "",
   percent: "",
   third_shop_code: "",
@@ -576,8 +580,14 @@ function handleTradeTypeChange(v: string) {
   if (v !== "alipay_stage") {
     form.stage_num = "";
     form.percent = "";
-  } else if (!form.percent) {
-    form.percent = "100";
+    // 切回非分期要把业务类型补回来:清掉它再切回来仍是「非分期却不带 biz」
+    form.biz = HAR_BIZ_UN_STAGE;
+  } else {
+    // 分期的业务类型取值规范没给,不猜
+    form.biz = "";
+    if (!form.percent) {
+      form.percent = "100";
+    }
   }
 }
 
@@ -597,6 +607,7 @@ async function handleCreate() {
       // 已过表单必填校验,此处 price 必然有值
       price: form.price as number,
       out_biz_no: form.out_biz_no || undefined,
+      biz: form.biz || undefined,
       stage_num: form.stage_num || undefined,
       percent: form.percent || undefined,
       third_shop_code: form.third_shop_code || undefined,