浏览代码

fix 处理诊疗卡相关接口

DYH2020 2 年之前
父节点
当前提交
c073a9b487

+ 14 - 0
onemini-hospital-empty/src/main/java/com/ywt/alipaympapi/models/ConstantUrls.java

@@ -0,0 +1,14 @@
+package com.ywt.alipaympapi.models;
+
+/**
+ * @author DYH2020
+ * Created on 2022/09/07
+ */
+public class ConstantUrls {
+
+    /**
+     * 对应wapapi的 com.ywt.wapapi.web.controllers.taihe.RegisterController 类的建档接口
+     */
+    public static final String CREATE_MEDCARD = "/taihe/register/createMedCard";
+
+}

+ 17 - 1
onemini-hospital-empty/src/main/java/com/ywt/alipaympapi/service/AuthService.java

@@ -3,6 +3,7 @@ package com.ywt.alipaympapi.service;
 import com.ptc.board.citymsg.sdk.UserAccountApi;
 import com.ptc.board.citymsg.sdk.response.UserAccountInfo;
 import com.ywt.alipaympapi.core.exception.AppMessageException;
+import com.ywt.alipaympapi.models.Constants;
 import com.ywt.alipaympapi.models.auth.AlipayMpCfg;
 import com.ywt.alipaympapi.models.auth.GetAlipayUserInfoReq;
 import com.ywt.alipaympapi.models.auth.GetAlipayUserInfoResp;
@@ -24,7 +25,7 @@ public class AuthService {
     public GetAlipayUserInfoResp getAlipayUserInfo(GetAlipayUserInfoReq req) throws AppMessageException {
         GetAlipayUserInfoResp resp = new GetAlipayUserInfoResp();
         try {
-            UserAccountApi api = new UserAccountApi("https","ab-saas-api.alipay-eco.com", null, req.getSaasSecurityKey());
+            UserAccountApi api = new UserAccountApi("https", "ab-saas-api.alipay-eco.com", null, req.getSaasSecurityKey());
             UserAccountInfo userAccountInfo = api.queryUserInfo(req.getAppId(), req.getTicket());
             resp.setAlipayUid(userAccountInfo.getAlipayUid());
             resp.setAvatar(userAccountInfo.getAvatar());
@@ -50,4 +51,19 @@ public class AuthService {
         }
         throw new AppMessageException(String.format("Unsupported terminal %d", terminal));
     }
+
+    /**
+     * 根据 appId 得到 hospitalId
+     *
+     * @param appId 医院对应的appId,注: 一个医院可以用多个支付宝 appId
+     * @return 医院ID
+     * @throws AppMessageException
+     */
+    public int getHospitalIdByAppId(String appId) {
+        int hospitalId = Constants.HOSPITAL_ID_NFYYBYFY;
+        if ("2021003141662056".equals(appId)) {
+            hospitalId = Constants.HOSPITAL_ID_NFYYBYFY;
+        }
+        return hospitalId;
+    }
 }

+ 28 - 0
onemini-hospital-empty/src/main/java/com/ywt/alipaympapi/service/impl/IsvMedicCardServiceImpl.java

@@ -1,19 +1,47 @@
 package com.ywt.alipaympapi.service.impl;
 
+import com.ywt.alipaympapi.models.ConstantUrls;
+import com.ywt.alipaympapi.models.Constants;
+import com.ywt.alipaympapi.service.AuthService;
+import com.ywt.alipaympapi.web.common.RestCallerApiProvider;
 import com.ywt.model.PageVO;
 import com.ywt.request.card.*;
 import com.ywt.response.card.*;
 import com.ywt.alipaympapi.service.IsvMedicCardService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.HashMap;
 import java.util.List;
 
 @Service
 public class IsvMedicCardServiceImpl implements IsvMedicCardService {
+    private static Logger logger = LoggerFactory.getLogger(IsvMedicCardServiceImpl.class);
 
+    @Autowired
+    private RestCallerApiProvider restCallerApiProvider;
+
+    @Autowired
+    private AuthService authService;
 
     @Override
     public CreateOrBindCardResponseData createOrBindMedicCard(CreateOrBindCardRequest request) {
+        String appId = request.getAppId();              //医院小程序的AppId
+        String userId = request.getUserId();            //用户唯一id
+        Integer type = request.getType();               //标志新建or绑定操作; 0=新建 1=绑定
+        String cardNum = request.getCardNum();          //就诊卡卡号,仅绑定操作时有效
+        String name = request.getName();                //姓名
+        String sex = request.getSex();                  //性别; 男|女
+        String birthDay = request.getBirthDay();             //生日(yyyy-MM-dd)
+        String idCardNo = request.getIdCardNo();             //身份证号码
+        String phoneNumber = request.getPhoneNumber();       //手机号
+        String authCode = request.getAuthCode();             //验证码
+        String relationShip = request.getRelationShip();     //关系
+        String defaultCard = request.getDefaultCard();       //是否默认
+        int hospitalId = authService.getHospitalIdByAppId(appId);
+        // 复制 wapapi 的代码,然后调用 rpc
         return null;
     }
 

+ 91 - 0
onemini-hospital-empty/src/main/java/com/ywt/alipaympapi/web/common/RestCallerApiProvider.java

@@ -0,0 +1,91 @@
+package com.ywt.alipaympapi.web.common;
+
+import com.ywt.alipaympapi.core.utils.JsonSerializer;
+import com.ywt.rpc.core.HttpUtil;
+import com.ywt.rpc.core.RestCaller;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author daiyihua
+ * @create 2020-09-07 下午05:27
+ * @desc 调用 rest api抽出来的公共方法
+ **/
+@Service
+public class RestCallerApiProvider {
+
+    private Logger logger = LoggerFactory.getLogger(RestCallerApiProvider.class);
+
+    @Autowired
+    private RestCaller restCaller;
+
+    private static String wapApiServiceName = "com.ywt.WapApiService";
+
+    /**
+     * 通用 post 方法
+     *
+     * @param serverName 服务名
+     * @param path       路径
+     * @param map        参数
+     * @return {@link HttpUtil.Resp}
+     * @throws IOException                       io异常
+     * @throws RestCaller.ParamterEmptyException 自定义异常
+     */
+    private HttpUtil.Resp postCommon(String serverName, String path, Map<String, Object> map) throws IOException, RestCaller.ParamterEmptyException {
+
+        Map<String, String> headers = new HashMap<>(16);
+        headers.put("Content-Type", "application/json;charset=UTF-8");
+
+
+        return restCaller.post(serverName, path, JsonSerializer.toJson(map), headers);
+    }
+
+    /**
+     * 通用 get 方法
+     *
+     * @param serverName 服务名
+     * @param path       路径
+     * @param map        参数
+     * @return {@link HttpUtil.Resp}
+     * @throws IOException                       io异常
+     * @throws RestCaller.ParamterEmptyException 自定义异常
+     */
+    private HttpUtil.Resp getCommon(String serverName, String path, Map<String, String> map) throws IOException, RestCaller.ParamterEmptyException {
+        return restCaller.get(serverName, path, map);
+    }
+
+
+    /**
+     * post 方法调用 rest wapapi
+     *
+     * @param path 接口路径
+     * @param map  传参
+     * @return {@link HttpUtil.Resp}
+     * @throws IOException                       io异常
+     * @throws RestCaller.ParamterEmptyException 自定义异常
+     */
+    public HttpUtil.Resp postWapApi(String path, Map<String, Object> map) throws IOException, RestCaller.ParamterEmptyException {
+        return postCommon(wapApiServiceName, path, map);
+    }
+
+    /**
+     * get 方法调用 rest wapapi
+     *
+     * @param path 接口路径
+     * @param map  传参
+     * @return {@link HttpUtil.Resp}
+     * @throws IOException                       io异常
+     * @throws RestCaller.ParamterEmptyException 自定义异常
+     */
+    public HttpUtil.Resp getWapApi(String path, Map<String, String> map) throws IOException, RestCaller.ParamterEmptyException {
+        return getCommon(wapApiServiceName, path, map);
+    }
+
+
+}