|
@@ -5,11 +5,13 @@ import com.alipay.api.domain.AlipayTradeQueryModel;
|
|
|
import com.alipay.api.request.AlipayCommerceMedicalAuthinfoAuthQueryRequest;
|
|
|
import com.alipay.api.response.AlipayCommerceMedicalAuthinfoAuthQueryResponse;
|
|
|
import com.alipay.api.response.AlipayTradeQueryResponse;
|
|
|
+import com.fasterxml.jackson.databind.JsonNode;
|
|
|
import com.ywt.alipaympapi.core.utils.*;
|
|
|
import com.ywt.alipaympapi.face.IPayFace;
|
|
|
import com.ywt.alipaympapi.face.impl.AlipayService;
|
|
|
import com.ywt.alipaympapi.models.Constants;
|
|
|
import com.ywt.alipaympapi.models.auth.AlipayMpCfg;
|
|
|
+import com.ywt.alipaympapi.models.enums.HospitalNameEnum;
|
|
|
import com.ywt.alipaympapi.models.enums.OutpatientOrderPayInsTypeEnum;
|
|
|
import com.ywt.alipaympapi.models.enums.PaymentStatusEnum;
|
|
|
import com.ywt.alipaympapi.models.enums.SexEnum;
|
|
@@ -628,7 +630,7 @@ public class IsvPayServiceImpl implements IsvPayService {
|
|
|
String userCardNo = resp.getIdNo();
|
|
|
if (StringHelper.isNullOrEmpty(userCardNo))
|
|
|
throw new AppMessageException("用户诊疗卡身份证信息为空");
|
|
|
- // 医保支付,先生成系统订单,然后继续使用腾讯医保接口下单
|
|
|
+ // 医保支付,先生成系统订单,然后继续使用支付宝接口下单
|
|
|
req = CreateOutpatientOrderRequest.newBuilder()
|
|
|
.setDeptCode("")
|
|
|
.setDeptName(deptName)
|
|
@@ -659,8 +661,53 @@ public class IsvPayServiceImpl implements IsvPayService {
|
|
|
}
|
|
|
orderNo = result.getValue();
|
|
|
orderId = getOrderIdByOrderNo(orderNo);
|
|
|
+ String medicalCardId = "";
|
|
|
+ String medicalCardInstId = "";
|
|
|
+ String medOrgOrd = "";
|
|
|
+ String payOrdId = "";
|
|
|
+ String payAuthNo = "";
|
|
|
+ JsonNode jn = JsonSerializer.readToNode(insUploadFeeResp);
|
|
|
+ if (jn != null) {
|
|
|
+ medicalCardId = Checker.getStringValue(jn.get("medicalCardId").asText());
|
|
|
+ medicalCardInstId = Checker.getStringValue(jn.get("medicalCardInstId").asText());
|
|
|
+ payAuthNo = Checker.getStringValue(jn.get("payAuthNo").asText());
|
|
|
+ String output = Checker.getStringValue(jn.get("output").asText(), "{}");
|
|
|
+ JsonNode jn2 = JsonSerializer.readToNode(output);
|
|
|
+ if (jn2 != null) {
|
|
|
+ JsonNode jn3 = jn2.get("data");
|
|
|
+ if (jn3 != null) {
|
|
|
+ medOrgOrd = Checker.getStringValue(jn3.get("medOrgOrd").asText());
|
|
|
+ payOrdId = Checker.getStringValue(jn3.get("payOrdId").asText());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
// 使用支付宝接口下单
|
|
|
- // TODO: 增加医保参数
|
|
|
+ // 增加医保参数
|
|
|
+ AlipayMpCfg cfg = BizUtil.getCfg(terminal);
|
|
|
+ HashMap<String, String> extMap = new HashMap<>();
|
|
|
+ JSONObject extendParams = new JSONObject();
|
|
|
+ extendParams.put("sys_service_provider_id", cfg.getIsvPid());
|
|
|
+ extendParams.put("IS_INSURANCE_PAY", "T"); //是否使用医保支付
|
|
|
+ extendParams.put("medical_card_inst_id", medicalCardInstId); //医保电子凭证机构号 获取线上医保业务授权接口返回medicalCardInstId参数。
|
|
|
+ extendParams.put("medical_card_id", medicalCardId); //医保电子凭证授权码 获取线上医保业务授权接口返回medicalCardId参数。
|
|
|
+ extendParams.put("medical_request_content", "");//医保参数透传体,没有需传空对象串
|
|
|
+
|
|
|
+ JSONObject medicalRequestExt =new JSONObject(); //医保扩展参数
|
|
|
+ medicalRequestExt.put("gmt_out_create", DateUtil.convertTimestampToDateString(new Date().getTime()));//医疗机构下单时间
|
|
|
+ medicalRequestExt.put("out_trade_no", medOrgOrd); //商户网站唯一订单号 医院订单号medOrgOrd
|
|
|
+ medicalRequestExt.put("serial_no", payOrdId); //移动支付中心订单号payOrdId
|
|
|
+ medicalRequestExt.put("bill_no", payOrdId); //移动支付中心订单号payOrdId
|
|
|
+ medicalRequestExt.put("industry", "HOSPITAL"); //行业标识
|
|
|
+ medicalRequestExt.put("org_no", cfg.getYbv2OrgCode()); //医药机构编号
|
|
|
+ medicalRequestExt.put("org_name", HospitalNameEnum.getDisplayName(hospitalId)); //医药机构名称
|
|
|
+ medicalRequestExt.put("pay_auth_no", payAuthNo); //移动支付中心返回授权编号 获取线上医保业务授权接口返回payAuthNo参数
|
|
|
+ medicalRequestExt.put("chinfo", "gjydzf"); //渠道标识
|
|
|
+ medicalRequestExt.put("scene", "TREATMENT"); //使用场景
|
|
|
+ medicalRequestExt.put("insurance_pay_scene", "OUTPATIENT");//医保结算场景
|
|
|
+ medicalRequestExt.put("payment_city_code", "440100");//医保结算地城市编码(国标)
|
|
|
+ extendParams.put("medical_request_ext", JSONObject.toJSONString(medicalRequestExt));
|
|
|
+ extMap.put("extend_params", JSONObject.toJSONString(extendParams));
|
|
|
+
|
|
|
CreateAlipayOrderResponse createPayInsOrderResponse = orderCenterServiceBlockingStub.createAlipayOrder(CreateAlipayOrderRequest.newBuilder()
|
|
|
.setBody("门诊缴费")
|
|
|
.setAlipayUid(request.getAlipayUid())
|
|
@@ -669,6 +716,7 @@ public class IsvPayServiceImpl implements IsvPayService {
|
|
|
.setAmount(request.getTotal())
|
|
|
.setUserId(userId)
|
|
|
.setTerminal(ContextHelper.getCurrentTerminalWrapped())
|
|
|
+ .putAllBizContent(extMap)
|
|
|
.build());
|
|
|
if (createPayInsOrderResponse.getCode() == ResultCode.SUCCEED_VALUE) {
|
|
|
data.setNeedPay(true);//设置是否需要支付宝自费支付
|
|
@@ -724,8 +772,7 @@ public class IsvPayServiceImpl implements IsvPayService {
|
|
|
// 预结算成功,自动取消之前生成的未支付订单,让前端可以重新创建订单
|
|
|
autoCancelPrevOrder(hisOrdNum);
|
|
|
PrePayConfirm p = response.getListList().get(0);
|
|
|
- String invoiceNo = p.getInvoiceNo();
|
|
|
- return invoiceNo;
|
|
|
+ return p.getInvoiceNo();
|
|
|
}
|
|
|
throw new AppMessageException("预结算:HIS 返回列表数据为空");
|
|
|
}
|
|
@@ -778,7 +825,7 @@ public class IsvPayServiceImpl implements IsvPayService {
|
|
|
* 获取医保支付授权
|
|
|
* <a href="https://opendocs.alipay.com/pre-open/02iqci#5.2.2%20%E6%8E%A5%E5%8F%A3%E8%AF%A6%E7%BB%86%E8%AF%B4%E6%98%8E">参考文档</a>
|
|
|
*/
|
|
|
- public GetPayAuthInfo getPayAuthNo(String appId, String alipayUid, String callUrl) {
|
|
|
+ public GetPayAuthInfo getPayAuthInfo(String appId, String alipayUid, String callUrl) {
|
|
|
GetPayAuthInfo getPayAuthInfo = new GetPayAuthInfo();
|
|
|
try {
|
|
|
// 换取 token
|
|
@@ -821,7 +868,7 @@ public class IsvPayServiceImpl implements IsvPayService {
|
|
|
System.out.println("错误返回:" + response.getSubMsg());
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
- log.error("IsvPayServiceImpl#getPayAuthNo(appId={} , alipayUid={} ):\n {}", appId, alipayUid, e.getMessage(), e);
|
|
|
+ log.error("IsvPayServiceImpl#getPayAuthInfo(appId={} , alipayUid={} ):\n {}", appId, alipayUid, e.getMessage(), e);
|
|
|
}
|
|
|
return getPayAuthInfo;
|
|
|
}
|