Bladeren bron

fix: 调整医保支付成功后跳转到首页,方便通过验收

carver 1 jaar geleden
bovenliggende
commit
b71d3496e9

+ 21 - 0
antbuilder/core/utils/ywtService.js

@@ -141,6 +141,27 @@ export async function prePayConfirm({
 	return [null, res];
 }
 
+// 撤销预结算
+export async function revokeSettle({
+	hisOrderNo,
+	insuDivId,
+	hisPatientId,
+	isInsV2,
+}) {
+	const [err, res] = await ywtRequest({
+		url: "/outpatient/revokeSettle",
+		method: "post",
+		data: {
+			hisOrderNo,
+			insuDivId,
+			hisPatientId,
+			isInsV2,
+		},
+	});
+	if (err || !res) return [err, null];
+	return [null, res];
+}
+
 // 支付宝获取业务授权
 export async function getPayAuthInfo({ authCode, callUrl, reqBizNo }) {
 	const [err, res] = await ywtRequest({

+ 48 - 8
antbuilder/industry/hospitalV2/components/hospital-payment-detail-yibao/index.js

@@ -4,13 +4,23 @@ import { tradePay } from "../../utils/tradePay";
 import {
 	prePayConfirm,
 	getPayAuthInfo,
+	revokeSettle,
 } from "../../../../core/utils/ywtService";
 import history from "../../utils/history";
 import { createSubscribe } from "applet-page-component";
 
 Component(
 	createSubscribe({
-		onShow() {
+		onShow(options) {
+			console.log("onshow opt start ===>");
+			console.log(
+				"onshow opt ===> referrerInfo",
+				options && options.referrerInfo
+			);
+			console.log("onshow options ===> path", options && options.path);
+			console.log("onshow options ===> scene", options && options.scene);
+			console.log("onshow options ===> query", options && options.query);
+			console.log("onshow opt end ===>");
 			this.init("onShow");
 		},
 	})({
@@ -118,6 +128,11 @@ Component(
 			},
 
 			async handlePrePayConfirm() {
+				console.log(
+					"this.$page.data.query handlePrePayConfirm ==>",
+					this.$page.data.query
+				);
+				console.log("this.$page.data handlePrePayConfirm ==>", this.$page.data);
 				my.showLoading({ mask: true });
 				try {
 					const {
@@ -179,18 +194,37 @@ Component(
 				return newList || [];
 			},
 
-			handleIsUserPersonalAccount(e) {
+			async handleIsUserPersonalAccount(e) {
 				my.showLoading();
 				const _this = this;
 				const { valuex } = e.currentTarget.dataset;
+				const { hisOrderNo, hisPatientId } = this.$page.data.query;
+				const { preConfirmInfo } = this.data;
 				this.setData(
 					{
 						isUserPersonalAccount: valuex,
 						isCulculate: true,
 					},
-					() => {
-						my.hideLoading();
-						_this.handlePrePayConfirm();
+					async () => {
+						const [err, result] = await revokeSettle({
+							hisOrderNo,
+							insuDivId: preConfirmInfo.insuDivId || "",
+							hisPatientId,
+							isInsV2: true,
+						});
+						if (!err) {
+							_this.handlePrePayConfirm();
+						} else {
+							my.showToast({
+								type: "fail",
+								content: "撤销预结算失败",
+								duration: 2000,
+							});
+							setTimeout(() => {
+								my.hideLoading();
+								my.navigateBack();
+							}, 2000);
+						}
 					}
 				);
 			},
@@ -261,7 +295,6 @@ Component(
 					orderInsType,
 					prescribeDate,
 					payInsType = "2",
-					consumeType = "0",
 					medInsFee,
 					selfFee,
 					payName,
@@ -270,6 +303,7 @@ Component(
 				} = this.$page.data.query;
 				const {
 					preConfirmInfo: { invoiceNo, insuAdmDr, insUploadFeeResp },
+					isUserPersonalAccount,
 				} = this.data;
 				let result = false;
 				try {
@@ -295,7 +329,6 @@ Component(
 							prescribeDate,
 							orderInsType,
 							payInsType,
-							consumeType,
 							totalFee: total,
 							medInsFee,
 							selfFee,
@@ -304,6 +337,7 @@ Component(
 							invoiceNo,
 							insuAdmDr,
 							insUploadFeeResp,
+							consumeType: isUserPersonalAccount ? 0 : 2,
 						},
 						{
 							tradeType: "Outpatient",
@@ -318,7 +352,13 @@ Component(
 				if (result) {
 					console.log("pay result ===>", result);
 					// 支付成功后返回列表页
-					my.navigateBack();
+					// my.navigateBack();
+
+					// 支付成功后暂时返回首页,方便通过验收
+					const len = getCurrentPages().length;
+					my.navigateBack({
+						delta: len + 1,
+					});
 				}
 			},
 		},

+ 310 - 306
antbuilder/industry/hospitalV2/components/hospital-payment-detail/index.js

@@ -1,328 +1,332 @@
 import { payDetail } from "./service";
 import { tradePay } from "../../utils/tradePay";
 import history from "../../utils/history";
-import { getYbParams } from '../hospital-payment-detail-yibao/service'
+import { getYbParams } from "../hospital-payment-detail-yibao/service";
 import { reportApi, reportCmPV_YL } from "../../utils/cloudMonitorHelper";
-import { getSubscribeAuth, prePayConfirm } from "../../../../core/utils/ywtService";
+import {
+	getSubscribeAuth,
+	prePayConfirm,
+} from "../../../../core/utils/ywtService";
 import { createSubscribe } from "applet-page-component";
 
-Component(createSubscribe({
-  onShow() {
-    this.payDetail(this.$page.data.query);
-  },
-})({
-  props: {},
-  data: {
-    order: {
-      orderItems: [
-        // {
-        //   itemName: '项目名称',
-        //   itemNum: 2,
-        //   amount: 999.99,
-        // },
-      ],
-      depName: "",
-      outTradeNo: "",
-      tradeNo: "",
-      type: null,
-      // 1-挂号费订单 2-充值订单 3-诊间缴费订单
-      userName: "",
-      cardNum: "",
-      amount: 0,
-      createTime: "",
-      payTime: "",
-      payType: null,
-      // 1-自费 2-医保 3-其他
-      status: null,
-      // 0-待支付 1-已支付 9-已取消
-      medicareBinded: false,
-      idNum: "",
-      customInfo: "",
-      payDetails: "",
-      payDate: "",
-      doctorName: "",
-      reportRemind: "",
-      checkRemind: "",
-      medicineRemind: "",
-      refundRemind: "",
-      receiptRemind: "",
-    },
-    // 订单项
-    fromItem: [
-      {
-        label: "就诊人",
-        key: "name",
-      },
-      {
-        label: "病人ID号",
-        key: "hisPatientId",
-      },
-      {
-        label: "就诊科室",
-        key: "deptName",
-      },
-      {
-        label: "医生",
-        key: "doctorName",
-      },
-      // {
-      // 	label: "费用日期",
-      // 	key: "payDate",
-      // },
-      // {
-      // 	label: "支付单号",
-      // 	key: "outTradeNo",
-      // },
-      {
-        label: "开单时间",
-        key: "prescribeDate",
-      },
-      // {
-      // 	label: "付款时间",
-      // 	key: "payTime",
-      // },
-    ],
-    medicareExpand: false,
-    expand: false,
-    medicare: {
-      total: 0,
-      own: 0,
-      detail: {},
-    },
-    checkRemind: {},
-  },
+Component(
+	createSubscribe({
+		onShow() {
+			this.payDetail(this.$page.data.query);
+		},
+	})({
+		props: {},
+		data: {
+			order: {
+				orderItems: [
+					// {
+					//   itemName: '项目名称',
+					//   itemNum: 2,
+					//   amount: 999.99,
+					// },
+				],
+				depName: "",
+				outTradeNo: "",
+				tradeNo: "",
+				type: null,
+				// 1-挂号费订单 2-充值订单 3-诊间缴费订单
+				userName: "",
+				cardNum: "",
+				amount: 0,
+				createTime: "",
+				payTime: "",
+				payType: null,
+				// 1-自费 2-医保 3-其他
+				status: null,
+				// 0-待支付 1-已支付 9-已取消
+				medicareBinded: false,
+				idNum: "",
+				customInfo: "",
+				payDetails: "",
+				payDate: "",
+				doctorName: "",
+				reportRemind: "",
+				checkRemind: "",
+				medicineRemind: "",
+				refundRemind: "",
+				receiptRemind: "",
+			},
+			// 订单项
+			fromItem: [
+				{
+					label: "就诊人",
+					key: "name",
+				},
+				{
+					label: "病人ID号",
+					key: "hisPatientId",
+				},
+				{
+					label: "就诊科室",
+					key: "deptName",
+				},
+				{
+					label: "医生",
+					key: "doctorName",
+				},
+				// {
+				// 	label: "费用日期",
+				// 	key: "payDate",
+				// },
+				// {
+				// 	label: "支付单号",
+				// 	key: "outTradeNo",
+				// },
+				{
+					label: "开单时间",
+					key: "prescribeDate",
+				},
+				// {
+				// 	label: "付款时间",
+				// 	key: "payTime",
+				// },
+			],
+			medicareExpand: false,
+			expand: false,
+			medicare: {
+				total: 0,
+				own: 0,
+				detail: {},
+			},
+			checkRemind: {},
+		},
 
-  didMount() {
-    this.payDetail(this.$page.data.query);
-    /* 服务办结,门诊缴费 */
+		didMount() {
+			this.payDetail(this.$page.data.query);
+			/* 服务办结,门诊缴费 */
 
-    reportApi("门诊缴费");
-    /* 服务预警,门诊缴费 */
+			reportApi("门诊缴费");
+			/* 服务预警,门诊缴费 */
 
-    reportCmPV_YL({
-      title: "门诊缴费",
-    });
+			reportCmPV_YL({
+				title: "门诊缴费",
+			});
+		},
 
-  },
+		methods: {
+			saveSubscribe(ref) {
+				this.subscribe = ref;
+			},
 
-  methods: {
-    saveSubscribe(ref) {
-      this.subscribe = ref;
-    },
+			payDetail(send) {
+				const { orderItems } = send;
+				const status0OrderItems = JSON.parse(
+					decodeURIComponent(orderItems || "")
+				);
+				const newSend = Object.assign({}, send);
+				delete newSend["orderItems"];
+				payDetail(newSend).then((data) => {
+					const payDetails = JSON.parse(data.payDetails || "{}");
+					const detail = payDetails["医保支付"] || {};
+					let total = 0;
+					Object.entries(detail).forEach(([k, v]) => {
+						detail[k] = numFix(v);
+						total += v * 1;
+					});
+					this.setData({
+						order: Object.assign({}, this.data.order, data, {
+							orderItems: data.orderItems ? data.orderItems : status0OrderItems,
+						}),
+						medicare: {
+							total: numFix(total),
+							own: numFix(payDetails["自费支付金额"]) || "0.00",
+							detail,
+						},
+						checkRemind: JSON.parse(data.checkRemind || "{}"),
+					});
+				});
+			},
 
+			async handlePrePayConfirm() {
+				return new Promise(async (resolve) => {
+					const {
+						hisOrderNo: hisOrdNum,
+						hisPatientId: patientId,
+						hisClinicCode: clinicCode,
+						total: orderSum,
+						orderInsType,
+					} = this.$page.data.query;
+					const {
+						payAuthNo = "",
+						authNo = "",
+						medicalCardInstId = "",
+						medicalCardId = "",
+					} = this.data;
+					const [err, result] = await prePayConfirm({
+						patientId,
+						clinicCode,
+						hisOrdNum,
+						orderSum,
+						payInsType: "1",
+						orderInsType,
+						payAuthNo,
+						authNo,
+						medicalCardInstId,
+						medicalCardId,
+					});
+					if (!err) {
+						// 预结算成功
+						const ybData = getYbParams(result);
+						const preConfirmInfo = Object.assign(result, ybData);
+						this.setData(
+							{
+								preConfirmInfo,
+							},
+							resolve(preConfirmInfo)
+						);
+					}
+				});
+			},
 
+			// 查看更多
+			openForm() {
+				this.setData({
+					expand: !this.data.expand,
+				});
+			},
 
-    payDetail(send) {
-      const { orderItems } = send;
-      const status0OrderItems = JSON.parse(
-        decodeURIComponent(orderItems || "")
-      );
-      const newSend = Object.assign({}, send);
-      delete newSend["orderItems"];
-      payDetail(newSend).then((data) => {
-        const payDetails = JSON.parse(data.payDetails || "{}");
-        const detail = payDetails["医保支付"] || {};
-        let total = 0;
-        Object.entries(detail).forEach(([k, v]) => {
-          detail[k] = numFix(v);
-          total += v * 1;
-        });
-        this.setData({
-          order: Object.assign({}, this.data.order, data, {
-            orderItems: data.orderItems ? data.orderItems : status0OrderItems,
-          }),
-          medicare: {
-            total: numFix(total),
-            own: numFix(payDetails["自费支付金额"]) || "0.00",
-            detail,
-          },
-          checkRemind: JSON.parse(data.checkRemind || "{}"),
-        });
-      });
-    },
+			medicareExpand() {
+				this.setData({
+					medicareExpand: !this.data.medicareExpand,
+				});
+			},
 
-    async handlePrePayConfirm() {
-      return new Promise(async (resolve) => {
-        const {
-          hisOrderNo: hisOrdNum,
-          hisPatientId: patientId,
-          hisClinicCode: clinicCode,
-          total: orderSum,
-          orderInsType,
-        } = this.$page.data.query;
-        const { payAuthNo = '', authNo = '', medicalCardInstId = '', medicalCardId = '' } =
-          this.data;
-        const [err, result] = await prePayConfirm({
-          patientId,
-          clinicCode,
-          hisOrdNum,
-          orderSum,
-          payInsType: "1",
-          orderInsType,
-          payAuthNo,
-          authNo,
-          medicalCardInstId,
-          medicalCardId,
-        });
-        if (!err) {
-          // 预结算成功
-          const ybData = getYbParams(result);
-          const preConfirmInfo = Object.assign(result, ybData)
-          this.setData({
-            preConfirmInfo
-          }, resolve(preConfirmInfo));
-        }
-      })
-    },
+			// 发起支付
+			async onPay(e) {
+				const { medicareBinded = false } = e.target.dataset;
+				const { orderInsType, medInsFee, selfFee, payName, patName } =
+					this.$page.data.query;
+				const { order: oreder } = this.data;
+				let result = false;
+				const { invoiceNo = "" } = await this.handlePrePayConfirm();
+				try {
+					my.showLoading();
+					// 获取授权
+					await getSubscribeAuth();
 
-    // 查看更多
-    openForm() {
-      this.setData({
-        expand: !this.data.expand,
-      });
-    },
+					if (oreder.type === 1) {
+						result = await tradePay(
+							{
+								type: oreder.type,
+								idNum: oreder.outTradeNo,
+								depName: oreder.depName,
+							},
+							{
+								tradeType: "Appointment",
+							}
+						);
+					} else if (oreder.type === 2) {
+						// 充值
+						result = await tradePay(
+							{
+								type: oreder.type,
+								idNum: oreder.outTradeNo,
+								amount: oreder.amount,
+							},
+							{
+								tradeType: "Appointment",
+							}
+						);
+					} else {
+						// 门诊订单
+						const {
+							hisPatientId,
+							age,
+							sex,
+							orderId,
+							hisOrderNo,
+							amount,
+							deptName,
+							doctorName,
+							doctorCode,
+							total,
+							hisClinicCode,
+							name,
+							prescribeDate,
+						} = oreder;
+						result = await tradePay(
+							{
+								useBalance: !medicareBinded,
+								useMedicare: medicareBinded,
+								outTradeNo: oreder.outTradeNo,
+								hisPatientId,
+								age,
+								sex,
+								orderId,
+								hisOrderNo,
+								amount,
+								deptName,
+								doctorName,
+								doctorCode,
+								total,
+								hisClinicCode,
+								name,
+								prescribeDate,
+								// 新增参数
+								invoiceNo,
+								orderInsType,
+								totalFee: total,
+								payInsType: "1",
+								medInsFee,
+								selfFee,
+								payName,
+								patName,
+							},
+							{
+								tradeType: "Outpatient",
+							}
+						);
+					}
+				} catch (error) {
+					console.log("error ===>", error);
+				} finally {
+					my.hideLoading();
+				}
+				// 支付成功刷新页面
+				this.payDetail(this.$page.data.query);
+				if (result) {
+					// 支付成功后返回列表页
+					my.navigateBack();
+				}
+			},
 
-    medicareExpand() {
-      this.setData({
-        medicareExpand: !this.data.medicareExpand,
-      });
-    },
+			async onYbPay() {
+				const query = this.$page.data.query;
+				await getSubscribeAuth();
+				my.getAuthCode({
+					scopes: ["nhsamp", "auth_user"], // 主动授权:auth_user,静默授权:auth_base。或者其它scopes
+					success: (res) => {
+						if (res.authCode) {
+							history.push({
+								title: "确认支付",
+								query: Object.assign(query, { authCode: res.authCode }),
+								pageType: "hospital-payment-detail-yibao",
+							});
+						}
+					},
+				});
+			},
 
-    // 发起支付
-    async onPay(e) {
-      const { medicareBinded = false } = e.target.dataset;
-      const {
-        orderInsType,
-        medInsFee,
-        selfFee,
-        payName,
-        patName,
-      } = this.$page.data.query;
-      const { order: oreder } = this.data;
-      let result = false;
-      const { invoiceNo = '' } = await this.handlePrePayConfirm()
-      try {
-        my.showLoading();
-        // 获取授权
-        await getSubscribeAuth();
+			hrefTo() {
+				my.ap.navigateToAlipayPage({
+					path: "alipays://platformapi/startapp?appId=77700284&page=pages/medical/index?chInfo=YY_xiaochengxu",
+				});
+			},
 
-        if (oreder.type === 1) {
-          result = await tradePay(
-            {
-              type: oreder.type,
-              idNum: oreder.outTradeNo,
-              depName: oreder.depName,
-            },
-            {
-              tradeType: "Appointment",
-            }
-          );
-        } else if (oreder.type === 2) {
-          // 充值
-          result = await tradePay(
-            {
-              type: oreder.type,
-              idNum: oreder.outTradeNo,
-              amount: oreder.amount,
-            },
-            {
-              tradeType: "Appointment",
-            }
-          );
-        } else {
-          // 门诊订单
-          const {
-            hisPatientId,
-            age,
-            sex,
-            orderId,
-            hisOrderNo,
-            amount,
-            deptName,
-            doctorName,
-            doctorCode,
-            total,
-            hisClinicCode,
-            name,
-            prescribeDate,
-          } = oreder;
-          result = await tradePay(
-            {
-              useBalance: !medicareBinded,
-              useMedicare: medicareBinded,
-              outTradeNo: oreder.outTradeNo,
-              hisPatientId,
-              age,
-              sex,
-              orderId,
-              hisOrderNo,
-              amount,
-              deptName,
-              doctorName,
-              doctorCode,
-              total,
-              hisClinicCode,
-              name,
-              prescribeDate,
-              // 新增参数
-              invoiceNo,
-              orderInsType,
-              totalFee: total,
-              payInsType: "1",
-              medInsFee,
-              selfFee,
-              payName,
-              patName,
-            },
-            {
-              tradeType: "Outpatient",
-            }
-          );
-        }
-      } catch (error) {
-        console.log("error ===>", error);
-      } finally {
-        my.hideLoading();
-      }
-      // 支付成功刷新页面
-      this.payDetail(this.$page.data.query);
-      if (result) {
-        // 支付成功后返回列表页
-        my.navigateBack();
-      }
-    },
-
-    async onYbPay() {
-      const query = this.$page.data.query;
-      await getSubscribeAuth();
-      my.getAuthCode({
-        scopes: ["nhsamp", "auth_user"], // 主动授权:auth_user,静默授权:auth_base。或者其它scopes
-        success: (res) => {
-          if (res.authCode) {
-            history.push({
-              title: "确认支付",
-              query: Object.assign(query, { authCode: res.authCode }),
-              pageType: "hospital-payment-detail-yibao",
-            });
-          }
-        },
-      });
-    },
-
-    hrefTo() {
-      my.ap.navigateToAlipayPage({
-        path: "alipays://platformapi/startapp?appId=77700284&page=pages/medical/index?chInfo=YY_xiaochengxu",
-      });
-    },
-
-    toH5(e) {
-      const { url } = e.target.dataset;
-      history.toH5(url);
-    },
-  },
-}));
+			toH5(e) {
+				const { url } = e.target.dataset;
+				history.toH5(url);
+			},
+		},
+	})
+);
 
 function numFix(val) {
-  const num = val * 1;
-  return num.toFixed(2);
+	const num = val * 1;
+	return num.toFixed(2);
 }