carver 1 рік тому
батько
коміт
dfb9818152

+ 153 - 0
README2.md

@@ -0,0 +1,153 @@
+.
+├── README.md
+├── README2.md
+├── ab_integration_info.txt
+├── antbuilder
+│   ├── core
+│   └── industry
+├── app.acss
+├── app.js
+├── app.json
+├── config.by.prod.json
+├── config.by.qa.json
+├── config.json
+├── custom
+│   ├── components
+│   ├── integration
+│   └── pages
+├── mini.project.json
+├── node_modules
+│   ├── @babel
+│   ├── @mas.io
+│   ├── @miniu
+│   ├── @web-io
+│   ├── @whale.io
+│   ├── ajv
+│   ├── alipay-style
+│   ├── ansi-regex
+│   ├── ansi-styles
+│   ├── antd-mini
+│   ├── applet-page-component
+│   ├── asn1
+│   ├── assert-plus
+│   ├── async-validator
+│   ├── asynckit
+│   ├── aws-sign2
+│   ├── aws4
+│   ├── bcrypt-pbkdf
+│   ├── camelcase
+│   ├── caseless
+│   ├── chinese-holidays
+│   ├── cliui
+│   ├── color-convert
+│   ├── color-name
+│   ├── combined-stream
+│   ├── core-util-is
+│   ├── cross-env
+│   ├── cross-spawn
+│   ├── dashdash
+│   ├── dayjs
+│   ├── decamelize
+│   ├── decode-uri-component
+│   ├── delayed-stream
+│   ├── dijkstrajs
+│   ├── domelementtype
+│   ├── domhandler
+│   ├── ecc-jsbn
+│   ├── emoji-regex
+│   ├── encode-utf8
+│   ├── entities
+│   ├── escalade
+│   ├── events
+│   ├── extend
+│   ├── extsprintf
+│   ├── fast-deep-equal
+│   ├── fast-json-stable-stringify
+│   ├── filter-obj
+│   ├── find-up
+│   ├── forever-agent
+│   ├── form-data
+│   ├── get-caller-file
+│   ├── getpass
+│   ├── har-schema
+│   ├── har-validator
+│   ├── herculex
+│   ├── http-signature
+│   ├── immer
+│   ├── immutability-helper
+│   ├── immutability-helper-enhanced
+│   ├── invariant
+│   ├── is-fullwidth-code-point
+│   ├── is-typedarray
+│   ├── isexe
+│   ├── isstream
+│   ├── js-tokens
+│   ├── jsbn
+│   ├── json-schema
+│   ├── json-schema-traverse
+│   ├── json-stringify-safe
+│   ├── jsprim
+│   ├── locate-path
+│   ├── lodash
+│   ├── loose-envify
+│   ├── mime-db
+│   ├── mime-types
+│   ├── mini-ali-ui
+│   ├── mini-ali-ui-rpx
+│   ├── mini-html-parser2
+│   ├── mini-types
+│   ├── moment
+│   ├── oauth-sign
+│   ├── p-limit
+│   ├── p-locate
+│   ├── p-try
+│   ├── path-exists
+│   ├── path-key
+│   ├── performance-now
+│   ├── pngjs
+│   ├── psl
+│   ├── punycode
+│   ├── qrcode
+│   ├── qs
+│   ├── query-string
+│   ├── ramda
+│   ├── regenerator-runtime
+│   ├── request
+│   ├── request-promise-core
+│   ├── request-promise-native
+│   ├── require-directory
+│   ├── require-main-filename
+│   ├── safe-buffer
+│   ├── safer-buffer
+│   ├── set-blocking
+│   ├── shebang-command
+│   ├── shebang-regex
+│   ├── split-on-first
+│   ├── sshpk
+│   ├── stealthy-require
+│   ├── strict-uri-encode
+│   ├── string-width
+│   ├── strip-ansi
+│   ├── tough-cookie
+│   ├── transliteration
+│   ├── tslib
+│   ├── tunnel-agent
+│   ├── tweetnacl
+│   ├── uri-js
+│   ├── uuid
+│   ├── verror
+│   ├── we-validator
+│   ├── which
+│   ├── which-module
+│   ├── wrap-ansi
+│   ├── y18n
+│   ├── yargs
+│   └── yargs-parser
+├── package-lock.json
+├── package.json
+├── pages
+│   ├── one
+│   └── web-view
+└── replaceEnv.js
+
+138 directories, 13 files

+ 29 - 2
antbuilder/core/utils/ywtService.js

@@ -114,7 +114,11 @@ export async function prePayConfirm({
   orderSum,
   payInsType,
   orderInsType,
-  authCode, }) {
+  payAuthNo,
+  authNo,
+  medicalCardInstId,
+  medicalCardId
+}) {
   const [err, res] = await ywtRequest({
     url: "/outpatient/prePayConfirm",
     method: "post",
@@ -125,9 +129,32 @@ export async function prePayConfirm({
       orderSum,
       payInsType,
       orderInsType,
-      authCode,
+      payAuthNo,
+      authNo,
+      medicalCardInstId,
+      medicalCardId
     },
   });
   if (err || !res) return [err, null];
   return [null, res];
 }
+
+
+// 支付宝获取业务授权
+export async function getPayAuthInfo({
+  authCode,
+  callUrl,
+  reqBizNo
+}) {
+  const [err, res] = await ywtRequest({
+    url: "/outpatient/getPayAuthInfo",
+    method: "post",
+    data: {
+      authCode,
+      callUrl,
+      reqBizNo
+    },
+  });
+  if (err || !res) return [err, null];
+  return [null, res];
+}

+ 60 - 0
antbuilder/industry/README2.md

@@ -0,0 +1,60 @@
+.
+├── README2.md
+├── abMall
+│   ├── components
+│   ├── mas.config.json
+│   ├── pages
+│   ├── service
+│   └── utils
+├── b2bMiniPlugin
+│   ├── assets
+│   ├── components
+│   ├── mas.config.json
+│   ├── services
+│   ├── styles
+│   └── utils
+├── healthCard
+│   ├── components
+│   └── mas.config.json
+├── hospital
+│   ├── components
+│   ├── hooks
+│   ├── mas.config.json
+│   └── pages
+├── hospitalV2
+│   ├── components
+│   ├── hooks
+│   ├── mas.config.json
+│   ├── pages
+│   ├── service
+│   └── utils
+├── markingPlugin
+│   ├── components
+│   ├── mas.config.json
+│   ├── pages
+│   └── utils
+├── medicare
+│   ├── components
+│   ├── mas.config.json
+│   └── utils
+├── scanpass
+│   ├── components
+│   ├── mas.config.json
+│   └── pages
+├── scenicSpotTicket
+│   ├── components
+│   ├── mas.config.json
+│   ├── services
+│   └── utils
+├── smartcommunity
+│   ├── components
+│   ├── mas.config.json
+│   └── pages
+└── soldier
+    ├── components
+    ├── mas.config.json
+    ├── pages
+    ├── services
+    └── utils
+
+46 directories, 12 files

+ 4 - 0
antbuilder/industry/hospitalV2/components/hospital-payment-detail-yibao/index.acss

@@ -262,6 +262,10 @@
     border-radius: 24px;
   }
 
+  .btn.disable {
+    background-color: #909399;
+  }
+
   .ft:before {
     content: '';
     position: absolute;

+ 7 - 7
antbuilder/industry/hospitalV2/components/hospital-payment-detail-yibao/index.axml

@@ -1,7 +1,7 @@
 <wrapper>
   <!-- 新页面 -->
   <View class="ybv2">
-    <View class="page-index" a:if="{{ canPay }}">
+    <View class="page-index">
       <View class="hd">
         <View class="info">
           <View class="info-hd">付款给</View>
@@ -16,16 +16,16 @@
         <View class="box">
           <View class="box-hd">
             <View class="box-hd-label">费用总额</View>
-            <View class="box-hd-value">{{isCulculate ? '核算中': "342.23元"}}</View>
+            <View class="box-hd-value">{{isCulculate ? '核算中': preConfirmInfo.feeSumamt || 0 + "元"}}</View>
           </View>
           <View class="box-bd">
             <View class="box-item">
               <View class="box-bd-label">医保基金支付</View>
-              <View class="box-bd-value">{{isCulculate ? '核算中': "342.23元"}}</View>
+              <View class="box-bd-value">{{isCulculate ? '核算中': preConfirmInfo.fundPay || 0 + "元"}}</View>
             </View>
             <View class="box-item">
               <View class="box-bd-label">个人帐户支付</View>
-              <View class="box-bd-value">{{isCulculate ? '核算中': "342.23元"}}</View>
+              <View class="box-bd-value">{{isCulculate ? '核算中': preConfirmInfo.psnAcctPay || 0 +  "元"}}</View>
             </View>
             <View class="box-item">
               <View class="box-bd-label">其他抵扣金额</View>
@@ -34,7 +34,7 @@
           </View>
           <View class="box-ft">
             <View class="box-ft-label">现金支付</View>
-            <View class="box-ft-value">{{isCulculate ? '核算中': "342.23元"}}</View>
+            <View class="box-ft-value">{{isCulculate ? '核算中': preConfirmInfo.ownPayAmt || 0 +  "元"}}</View>
           </View>
           <View
             class="box-append"
@@ -61,7 +61,7 @@
       <View class="ft">
         <View class="pay">
           <View class="pay-label">您还需支付:</View>
-          <View class="pay-value">{{isCulculate ? '核算中': "¥5823"}}</View>
+          <View class="pay-value">{{isCulculate ? '核算中': "¥" + (preConfirmInfo.ownPayAmt || "0")}}</View>
         </View>
         <View
           class="{{!canPay ? 'disable btn' : 'btn'}}"
@@ -120,6 +120,6 @@
         </View>
       </View>
     </View>
-    <View a:elif class="loading-page"></View>
+    <!-- <View a:elif class="loading-page"></View> -->
   </View>
 </wrapper>

+ 294 - 199
antbuilder/industry/hospitalV2/components/hospital-payment-detail-yibao/index.js

@@ -1,214 +1,298 @@
-import { getYbParams } from "./service";
+import qs from "qs";
+import { getYbParams, generateRandomFourDigitNumber } from "./service";
 import { tradePay } from "../../utils/tradePay";
-import { prePayConfirm } from "../../../../core/utils/ywtService";
+import {
+  prePayConfirm,
+  getPayAuthInfo,
+} from "../../../../core/utils/ywtService";
 import history from "../../utils/history";
-// import { reportApi, reportCmPV_YL } from "../../utils/cloudMonitorHelper";
-// import { getSubscribeAuth } from "../../../../core/utils/ywtService";
-// import { createSubscribe } from "applet-page-component";
-
-Component({
-  props: {},
-  data: {
-    authCode: undefined,
-    canPay: true,
-    prescriptionList: [
-
-    ],
-    actionsheetVisible: false,
-    isUserPersonalAccount: true,
-    isCulculate: false
-  },
-
-  didMount() {
-    this.getPayDetail(this.$page.data.query);
-    this.handlePrePayConfirm()
-  },
-
-  methods: {
-    saveSubscribe(ref) {
-      this.subscribe = ref;
-    },
+import { createSubscribe } from "applet-page-component";
 
-    async handlePrePayConfirm() {
-      my.showLoading({ mask: true });
-      try {
-        const { hisOrderNo: hisOrdNum, hisPatientId: patientId, hisClinicCode: clinicCode, authCode, total: orderSum, orderInsType } = this.$page.data.query
-        const [err, result] = await prePayConfirm({
-          patientId,
-          clinicCode,
-          hisOrdNum,
-          orderSum,
-          payInsType: '2',
-          orderInsType,
-          authCode,
-        })
-        if (!err) {
-          // 预结算成功
-          this.setData({
-          });
-        } else {
-          throw `${err}`
-        }
-      } catch (error) {
-        console.log('error ===>', error)
-      } finally {
-        my.hideLoading()
-      }
+Component(
+  createSubscribe({
+    onShow() {
+      this.init('onShow')
+    },
+  })({
+    props: {},
+    data: {
+      authCode: undefined,
+      canPay: false,
+      prescriptionList: [],
+      actionsheetVisible: false,
+      isUserPersonalAccount: true,
+      isCulculate: false,
+      preConfirmInfo: {}
     },
 
-    parseDetailItems(detailItems) {
-      const list = detailItems
-        ? JSON.parse(decodeURIComponent(detailItems || ""))
-        : [];
-      const newList = list.map((item) => {
-        return {
-          label: `${item.itemName}*${item.itemNum}`,
-          // subLabel: `${item.unit || ""}`,
-          value: `${item.amount || 0}元`,
-        };
-      });
-      return newList || [];
+    didMount() {
+      this.init('didMount')
     },
 
-    handleIsUserPersonalAccount(e) {
-      my.showLoading();
-      const _this = this
-      const { valuex } = e.currentTarget.dataset;
-      this.setData({
-        isUserPersonalAccount: valuex,
-        isCulculate: true
-      }, () => {
-        setTimeout(() => {
-          my.hideLoading()
-          _this.setData({
-            isCulculate: false
-          })
-        }, 3000)
-      })
+    didUnmount() {
+
     },
 
-    getPayDetail(query) {
-      console.log("query ==>", query);
-      let infoList = [];
-      if (query) {
-        infoList = [
-          {
-            title: "就诊信息",
-            list: [
-              // { label: "门诊类别", value: info.deptName },
-              { label: "门诊科室", value: query.deptName },
-              { label: "医生姓名", value: query.doctorName },
-              { label: "处方时间", value: query.prescribeDate },
-              {
-                label: "费用总额",
-                value: parseFloat(query.total / 100, 2) || 0 + "元",
-                highlight: true,
-              },
-            ],
-          },
-          {
-            title: "费用信息",
-            list: this.parseDetailItems(query.orderItems),
-          },
-        ];
-        this.setData({ prescriptionList: infoList });
-      }
-      return;
-      my.getAuthCode({
-        scopes: ["nhsamp", "auth_user"], // 主动授权:auth_user,静默授权:auth_base。或者其它scopes
-        success: (res) => {
-          if (res.authCode) {
-            // 认证成功
-            // 调用自己的服务端接口,让服务端进行后端的授权认证,并且利用session,需要解决跨域问题
-            my.request({
-              url: "https://isv.com/auth", // 该url是您自己的服务地址,实现的功能是服务端拿到authcode去开放平台进行token验证
-              data: {
-                authcode: res.authCode,
-              },
-              success: () => {
-                // 授权成功并且服务器端登录成功
-              },
-              fail: () => {
-                // 根据自己的业务场景来进行错误处理
-              },
+    methods: {
+
+      init(type) {
+        this.getPayDetail(this.$page.data.query);
+        this.hanldeGetPayAuthInfo(type);
+      },
+
+      saveSubscribe(ref) {
+        this.subscribe = ref;
+      },
+
+      async hanldeGetPayAuthInfo(type) {
+        const app = getApp();
+        const {
+          hisOrderNo: hisOrdNum,
+          authCode,
+          reqBizNo,
+        } = this.$page.data.query;
+        const _this = this
+        const ramdonNum = generateRandomFourDigitNumber();
+        const queryReqBizNo = reqBizNo || `${hisOrdNum}-${userId}-${ramdonNum}`;
+        const query = Object.assign(this.$page.data.query, { reqBizNo: queryReqBizNo })
+        const qsResult = `?${qs.stringify(query)}`;
+        const callUrl = encodeURIComponent(
+          `antbuilder/industry/hospitalV2/pages/page-no-pull/index${qsResult}`
+        );
+        const userId = app.globalData.ywtUserId || "";
+        if (type === 'onShow') {
+          my.getAuthCode({
+            scopes: ["nhsamp", "auth_user"], // 主动授权:auth_user,静默授权:auth_base。或者其它scopes
+            success: (res) => {
+              if (res.authCode) {
+                _this.requestGetPayAuthInfo(res.authCode, callUrl, queryReqBizNo)
+              }
+            },
+          });
+        } else {
+          this.requestGetPayAuthInfo(authCode, callUrl, queryReqBizNo)
+        }
+      },
+
+      async requestGetPayAuthInfo(authCode, callUrl, reqBizNo) {
+        const _this = this
+        const [err, result] = await getPayAuthInfo({
+          authCode,
+          callUrl,
+          reqBizNo,
+        });
+        if (!err) {
+          console.log("result ==>", result);
+          const { payAuthNo, authNo, medicalCardInstId, medicalCardId } =
+            result;
+          if (result.authNo) {
+            this.setData({
+              payAuthNo,
+              authNo,
+              medicalCardInstId,
+              medicalCardId,
+              isCulculate: true
+            }, () => {
+              _this.handlePrePayConfirm()
             });
+            return
           }
-        },
-      });
-    },
+          if (result.authUrl) {
+            my.ap.openURL({ url: result.authUrl });
+          }
+        }
+      },
 
-    // 查看更多
-    openForm() {
-      this.setData({
-        expand: !this.data.expand,
-      });
-    },
+      async handlePrePayConfirm() {
+        my.showLoading({ mask: true });
+        try {
+          const {
+            hisOrderNo: hisOrdNum,
+            hisPatientId: patientId,
+            hisClinicCode: clinicCode,
+            total: orderSum,
+            orderInsType,
+          } = this.$page.data.query;
+          const { payAuthNo, authNo, medicalCardInstId, medicalCardId } =
+            this.data;
 
-    medicareExpand() {
-      this.setData({
-        medicareExpand: !this.data.medicareExpand,
-      });
-    },
+          const [err, result] = await prePayConfirm({
+            patientId,
+            clinicCode,
+            hisOrdNum,
+            orderSum,
+            payInsType: "2",
+            orderInsType,
+            payAuthNo,
+            authNo,
+            medicalCardInstId,
+            medicalCardId,
+          });
+          if (!err) {
+            // 预结算成功
+            const ybData = getYbParams(result);
+            this.setData({
+              preConfirmInfo: Object.assign(result, ybData),
+              isCulculate: false,
+              canPay: true
+            });
+          } else {
+            throw `${err}`;
+          }
+        } catch (error) {
+          console.log("error ===>", error);
+        } finally {
+          my.hideLoading();
+        }
+      },
 
-    handleActionsheet() {
-      this.setData({
-        actionsheetVisible: !this.data.actionsheetVisible,
-      });
-    },
+      parseDetailItems(detailItems) {
+        const list = detailItems
+          ? JSON.parse(decodeURIComponent(detailItems || ""))
+          : [];
+        const newList = list.map((item) => {
+          return {
+            label: `${item.itemName}*${item.itemNum}`,
+            // subLabel: `${item.unit || ""}`,
+            value: `${item.amount || 0}元`,
+          };
+        });
+        return newList || [];
+      },
 
-    // 发起支付
-    async onPay(e) {
-      const { medicareBinded = false } = e.target.dataset;
-      const { order: oreder } = this.data;
-      let result = false;
-      try {
+      handleIsUserPersonalAccount(e) {
         my.showLoading();
+        const _this = this;
+        const { valuex } = e.currentTarget.dataset;
+        this.setData(
+          {
+            isUserPersonalAccount: valuex,
+            isCulculate: true,
+          },
+          () => {
+            setTimeout(() => {
+              my.hideLoading();
+              _this.setData({
+                isCulculate: false,
+              });
+            }, 3000);
+          }
+        );
+      },
 
-        if (oreder.type === 1) {
-          result = await tradePay(
+      getPayDetail(query) {
+        let infoList = [];
+        if (query) {
+          infoList = [
             {
-              type: oreder.type,
-              idNum: oreder.outTradeNo,
-              depName: oreder.depName,
+              title: "就诊信息",
+              list: [
+                // { label: "门诊类别", value: info.deptName },
+                { label: "门诊科室", value: query.deptName },
+                { label: "医生姓名", value: query.doctorName },
+                { label: "处方时间", value: query.prescribeDate },
+                {
+                  label: "费用总额",
+                  value: parseFloat(query.total / 100, 2) || 0 + "元",
+                  highlight: true,
+                },
+              ],
             },
             {
-              tradeType: "Appointment",
-            }
-          );
-        } else if (oreder.type === 2) {
-          // 充值
-          result = await tradePay(
-            {
-              type: oreder.type,
-              idNum: oreder.outTradeNo,
-              amount: oreder.amount,
+              title: "费用信息",
+              list: this.parseDetailItems(query.orderItems),
             },
-            {
-              tradeType: "Appointment",
-            }
-          );
-        } else {
+          ];
+          this.setData({ prescriptionList: infoList });
+        }
+      },
+
+      // 查看更多
+      openForm() {
+        this.setData({
+          expand: !this.data.expand,
+        });
+      },
+
+      medicareExpand() {
+        this.setData({
+          medicareExpand: !this.data.medicareExpand,
+        });
+      },
+
+      handleActionsheet() {
+        this.setData({
+          actionsheetVisible: !this.data.actionsheetVisible,
+        });
+      },
+
+      // 发起支付
+      async onPay(e) {
+        const { canPay } = this.data
+        if (!canPay) return
+        const {
+          hisPatientId,
+          age,
+          sex,
+          orderId,
+          hisOrderNo,
+          amount,
+          deptName,
+          doctorName,
+          doctorCode,
+          hisClinicCode,
+          total,
+          name,
+          orderInsType,
+          prescribeDate,
+          payInsType = '2',
+          consumeType = '0',
+          medInsFee,
+          selfFee,
+          payName,
+          patName,
+          outTradeNo
+        } = this.$page.data.query;
+        const { preConfirmInfo: { invoiceNo, insuAdmDr, insUploadFeeResp } } = this.data
+        console.log('this.$page.data.query ==>', this.$page.data.query)
+        let result = false;
+        console.log('requset data ==>', {
+          useBalance: false,
+          useMedicare: true,
+          outTradeNo,
+          hisPatientId,
+          age,
+          sex,
+          orderId,
+          hisOrderNo,
+          amount,
+          deptName,
+          doctorName,
+          doctorCode,
+          total,
+          hisClinicCode,
+          name,
+          prescribeDate,
+          orderInsType,
+          payInsType,
+          consumeType,
+          totalFee: total,
+          medInsFee,
+          selfFee,
+          payName,
+          patName,
+          invoiceNo,
+          insuAdmDr,
+          insUploadFeeResp
+        },)
+        try {
+          my.showLoading();
           // 门诊订单
-          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,
+              useBalance: false,
+              useMedicare: true,
+              outTradeNo,
               hisPatientId,
               age,
               sex,
@@ -222,22 +306,33 @@ Component({
               hisClinicCode,
               name,
               prescribeDate,
+              orderInsType,
+              payInsType,
+              consumeType,
+              totalFee: total,
+              medInsFee,
+              selfFee,
+              payName,
+              patName,
+              invoiceNo,
+              insuAdmDr,
+              insUploadFeeResp
             },
             {
               tradeType: "Outpatient",
             }
           );
+        } catch (error) {
+          console.log("error ===>", error);
+        } finally {
+          my.hideLoading();
+        }
+
+        if (result) {
+          // 支付成功后返回列表页
+          my.navigateBack();
         }
-      } catch (error) {
-        console.log("error ===>", error);
-      } finally {
-        my.hideLoading();
-      }
-
-      if (result) {
-        // 支付成功后返回列表页
-        my.navigateBack();
-      }
+      },
     },
-  },
-});
+  })
+);

+ 24 - 3
antbuilder/industry/hospitalV2/components/hospital-payment-detail-yibao/service.js

@@ -9,13 +9,14 @@ function payDetail(data) {
  * @param  {object} obj
  */
 function getYbParams(obj) {
-  if (!obj) return {};
+  if (!obj || !obj.insUploadFeeResp) return {};
   const list = obj.insUploadFeeResp.split(":");
   const params = {};
 
   // 总额:feeSumamt
   // 医保支付:fundPay
-  // 个人支付:ownPayAmt
+  // 个人支付:psnAcctPay
+  // 现金支付:ownPayAmt
 
   list.map((i, index) => {
     if (i.includes("feeSumamt")) {
@@ -62,12 +63,32 @@ function getYbParams(obj) {
         .replaceAll("{", "")
         .replaceAll("\\", "");
     }
+
+    if (i.includes("psnAcctPay")) {
+      let innerList = i.split(",");
+      let value = "";
+      if (innerList[0].includes("psnAcctPay")) {
+        value = innerList[1];
+      } else {
+        value = list[index + 1].split(",")[0];
+      }
+      params.psnAcctPay = value
+        .replaceAll('"', "")
+        .replaceAll("}", "")
+        .replaceAll("{", "")
+        .replaceAll("\\", "");
+    }
   });
 
   return params;
 }
 
+function generateRandomFourDigitNumber() {
+  return Math.floor(Math.random() * (9999 - 1000 + 1)) + 1000;
+}
+
 export default {
   payDetail,
-  getYbParams
+  getYbParams,
+  generateRandomFourDigitNumber
 };

+ 53 - 1
antbuilder/industry/hospitalV2/components/hospital-payment-detail/index.js

@@ -1,8 +1,9 @@
 import { payDetail } from "./service";
 import { tradePay } from "../../utils/tradePay";
 import history from "../../utils/history";
+import { getYbParams } from '../hospital-payment-detail-yibao/service'
 import { reportApi, reportCmPV_YL } from "../../utils/cloudMonitorHelper";
-import { getSubscribeAuth } from "../../../../core/utils/ywtService";
+import { getSubscribeAuth, prePayConfirm } from "../../../../core/utils/ywtService";
 import { createSubscribe } from "applet-page-component";
 
 Component(createSubscribe({
@@ -140,6 +141,40 @@ Component(createSubscribe({
       });
     },
 
+    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({
@@ -156,8 +191,16 @@ Component(createSubscribe({
     // 发起支付
     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();
         // 获取授权
@@ -221,6 +264,15 @@ Component(createSubscribe({
               hisClinicCode,
               name,
               prescribeDate,
+              // 新增参数
+              invoiceNo,
+              orderInsType,
+              totalFee: total,
+              payInsType: "1",
+              medInsFee,
+              selfFee,
+              payName,
+              patName,
             },
             {
               tradeType: "Outpatient",

+ 9 - 62
antbuilder/industry/hospitalV2/components/hospital-payment/index.js

@@ -156,7 +156,11 @@ Component(
 						hisClinicCode,
 						deptName,
 						orderItems,
-						orderInsType
+						orderInsType,
+						medInsFee,
+						selfFee,
+						payName,
+						patName
 					},
 				} = e.target.dataset;
 				history.push({
@@ -183,6 +187,10 @@ Component(
 						deptName,
 						orderInsType,
 						orderItems: encodeURIComponent(JSON.stringify(orderItems || "")),
+						medInsFee,
+						selfFee,
+						payName,
+						patName
 					},
 					pageType: "hospital-payment-detail",
 				});
@@ -191,67 +199,6 @@ Component(
 			// 付款
 			async onPayment(e) {
 				this.toDetail(e)
-				return
-				const { medicareBinded = false, item } = e.target.dataset; // 同意订阅消息后发起支付
-				try {
-					my.showLoading();
-					// 获取智能消息推送授权
-					await getSubscribeAuth();
-					// 挂号
-					if (item.type === 1) {
-						await tradePay(
-							{
-								type: item.type,
-								idNum: item.outTradeNo,
-								depName: item.depName,
-							},
-							{
-								tradeType: "Appointment",
-							}
-						);
-					} else if (item.type === 2) {
-						// 充值
-						await tradePay(
-							{
-								type: item.type,
-								idNum: item.outTradeNo,
-								amount: item.amount,
-							},
-							{
-								tradeType: "Appointment",
-							}
-						);
-					} else {
-						// 门诊订单
-						await tradePay(
-							{
-								useBalance: !medicareBinded,
-								useMedicare: medicareBinded,
-								outTradeNo: item.outTradeNo,
-								...item,
-							},
-							{
-								tradeType: "Outpatient",
-							}
-						);
-					}
-				} catch (error) {
-				} finally {
-					my.hideLoading();
-				}
-				this.scrollRef.refresh();
-				// 支付成功去订单详情页
-				this.toDetail({
-					target: {
-						dataset: {
-							outTradeNo: item.outTradeNo,
-							type: item.type ? item.type : 0,
-							...item,
-						},
-					},
-				}); // 发起消息订阅
-
-				// this.subscribe.subscribeMessage();
 			},
 		},
 	})

+ 24 - 0
antbuilder/industry/hospitalV2/utils/tradePay.js

@@ -45,6 +45,18 @@ function outpatient(params) {
 		hisClinicCode,
 		name,
 		prescribeDate,
+		// 医保2.0 新增参数
+		orderInsType,
+		payInsType,
+		consumeType,
+		totalFee,
+		medInsFee,
+		selfFee,
+		payName,
+		patName,
+		invoiceNo,
+		insuAdmDr,
+		insUploadFeeResp
 	} = params;
 	return tradeNoForOrder({
 		useBalance: params.useBalance,
@@ -66,6 +78,18 @@ function outpatient(params) {
 		hisClinicCode,
 		name,
 		prescribeDate,
+		// 医保2.0 新增参数
+		orderInsType,
+		payInsType,
+		consumeType,
+		totalFee,
+		medInsFee,
+		selfFee,
+		payName,
+		patName,
+		invoiceNo,
+		insuAdmDr,
+		insUploadFeeResp
 	}).then((tradeData) => {
 		if (tradeData.tradeNo) {
 			// 发起支付