|
@@ -3,6 +3,7 @@ package com.ywt.alipaympapi.web.controller;
|
|
|
import com.ywt.alipaympapi.core.utils.*;
|
|
|
import com.ywt.alipaympapi.models.BaseResponse;
|
|
|
import com.ywt.alipaympapi.models.BaseResponse2;
|
|
|
+import com.ywt.alipaympapi.models.auth.AlipayMpCfg;
|
|
|
import com.ywt.alipaympapi.models.enums.MedInsTypeEnum;
|
|
|
import com.ywt.alipaympapi.models.enums.MpTypeEnum;
|
|
|
import com.ywt.alipaympapi.models.enums.OutpatientOrderPayInsTypeEnum;
|
|
@@ -51,14 +52,31 @@ public class OutpatientController {
|
|
|
String endDate = Checker.getStringValue(reqData.getEndDate());
|
|
|
String clinicCode = Checker.getStringValue(reqData.getClinicCode());
|
|
|
String hisOrdNum = Checker.getStringValue(reqData.getHisOrdNum());
|
|
|
+ String callUrl = Checker.getStringValue(reqData.getCallUrl());
|
|
|
int orderSum = Checker.getIntegerValue(reqData.getOrderSum());
|
|
|
int payInsType = Checker.getIntegerValue(reqData.getPayInsType());
|
|
|
- int hospitalId = BizUtil.getHospitalIdByTerminalId(ContextHelper.getCurrentTerminalWrapped());
|
|
|
- String appId = Checker.getStringValue(reqData.getAppId());
|
|
|
+ int terminal = ContextHelper.getCurrentTerminalWrapped();
|
|
|
+ if (terminal <= 0) {
|
|
|
+ terminal = Checker.getIntegerValue(reqData.getTerminal());
|
|
|
+ }
|
|
|
+ int hospitalId = BizUtil.getHospitalIdByTerminalId(terminal);
|
|
|
+ int userId = ContextHelper.getCurrentUserIdWrapped();
|
|
|
+ if (userId <= 0) {
|
|
|
+ userId = Checker.getIntegerValue(reqData.getUserId());
|
|
|
+ }
|
|
|
+ String alipayUid = ContextHelper.getAlipayUidWrapped();
|
|
|
+ if (StringHelper.isNullOrEmpty(alipayUid)) {
|
|
|
+ alipayUid = Checker.getStringValue(reqData.getAlipayUid());
|
|
|
+ }
|
|
|
+ CheckUtil.ensureNotEmpty(alipayUid, "无法获取支付宝用户信息");
|
|
|
CheckUtil.ensureNotEmpty(patientId, "HIS 患者 id 不能为空");
|
|
|
CheckUtil.ensureNotEmpty(clinicCode, "就诊流水号不能为空");
|
|
|
CheckUtil.ensureNotEmpty(hisOrdNum, "HIS 订单号不能为空");
|
|
|
CheckUtil.ensureLargerThanZero(orderSum, "订单金额需大于 0");
|
|
|
+ CheckUtil.ensureLargerThanZero(userId, "无法获取用户信息");
|
|
|
+ CheckUtil.ensureLargerThanZero(terminal, "无法获取终端信息");
|
|
|
+ AlipayMpCfg cfg = BizUtil.getCfg(terminal);
|
|
|
+ String appId = cfg.getAppId();
|
|
|
CheckUtil.ensureNotEmpty(appId, "缺少 appId 参数");
|
|
|
PrePayConfirmRequest req = PrePayConfirmRequest.newBuilder()
|
|
|
.setCardNo(cardNo)
|
|
@@ -74,7 +92,7 @@ public class OutpatientController {
|
|
|
if (response.getCode() == ResultCode.SUCCEED_VALUE) {
|
|
|
if (!Checker.isNone(response.getListList())) {
|
|
|
// 预结算成功,自动取消之前生成的未支付订单,让前端可以重新创建订单
|
|
|
- autoCancelPrevOrder(hisOrdNum);
|
|
|
+ autoCancelPrevOrder(hisOrdNum, terminal);
|
|
|
PrePayConfirm p = response.getListList().get(0);
|
|
|
PrePayConfirmResp resp = new PrePayConfirmResp();
|
|
|
String invoiceNo = p.getInvoiceNo();
|
|
@@ -95,7 +113,7 @@ public class OutpatientController {
|
|
|
GetMedicalCardInfoByPatientIdRequest gResp = GetMedicalCardInfoByPatientIdRequest.newBuilder()
|
|
|
.setHisPatientId(patientId)
|
|
|
.setHospitalId(hospitalId)
|
|
|
- .setUserId(ContextHelper.getCurrentUserIdWrapped())
|
|
|
+ .setUserId(userId)
|
|
|
.build();
|
|
|
GetMedicalCardInfoByPatientIdResponse gmcResp = taiheOutpatientServiceBlockingStub.getMedicalCardInfoByPatientId(gResp);
|
|
|
if (gmcResp.getCode() != ResultCode.SUCCEED_VALUE) {
|
|
@@ -110,7 +128,7 @@ public class OutpatientController {
|
|
|
String authCode = reqData.getAuthCode();
|
|
|
CheckUtil.ensureNotEmpty(authCode, "授权码不能为空");
|
|
|
// 换取支付授权码
|
|
|
- GetPayAuthInfo payAuthInfo = isvPayService.getPayAuthInfo(appId, ContextHelper.getAlipayUidWrapped(), "");
|
|
|
+ GetPayAuthInfo payAuthInfo = isvPayService.getPayAuthInfo(appId, alipayUid, authCode, callUrl);
|
|
|
String authUrl = payAuthInfo.getAuthUrl(); // 当用户需要授权时,返回该参数,医药机构前端直接跳转该地址。
|
|
|
String payAuthNo = payAuthInfo.getPayAuthNo(); // 当用户已经授权支付时,直接返回该字段。线上支付授权编码。
|
|
|
String authNo = payAuthInfo.getAuthNo(); // 线上身份验证授权码,只能用户身份核验,不能用于支付业务。
|
|
@@ -188,8 +206,7 @@ public class OutpatientController {
|
|
|
return baseResponse.failed(BaseResponse2.APP_ERROR, "预结算:HIS 返回列表数据为空");
|
|
|
}
|
|
|
return baseResponse.failed(BaseResponse.APP_ERROR, response.getMsg());
|
|
|
- } catch (
|
|
|
- AppMessageException ame) {
|
|
|
+ } catch (AppMessageException ame) {
|
|
|
return baseResponse.failed(BaseResponse.PARAMETER_ERROR, ame.getMessage());
|
|
|
} catch (
|
|
|
Exception e) {
|
|
@@ -198,10 +215,10 @@ public class OutpatientController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void autoCancelPrevOrder(String hisOrderNo) {
|
|
|
+ private void autoCancelPrevOrder(String hisOrderNo, int terminal) {
|
|
|
GetOutpatientOrderByHisOrderNoRequest request = GetOutpatientOrderByHisOrderNoRequest.newBuilder()
|
|
|
.setHisOrderNo(hisOrderNo)
|
|
|
- .setHospitalId(BizUtil.getHospitalIdByTerminalId(ContextHelper.getCurrentTerminalWrapped()))
|
|
|
+ .setHospitalId(BizUtil.getHospitalIdByTerminalId(terminal))
|
|
|
.build();
|
|
|
GetOutpatientOrderByHisOrderNoResponse response = taiheOutpatientServiceBlockingStub.getOutpatientOrderByHisOrderNo(request);
|
|
|
if (response.getCode() == ResultCode.SUCCEED_VALUE) {
|