Browse Source

代理人openID

wujunjie 7 years ago
parent
commit
77a044aab1

+ 25 - 13
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PatientPrescriptionPayService.java

@ -1100,12 +1100,24 @@ public class PatientPrescriptionPayService extends BaseService {
//            易联众新增字段代支付v1.3.7
//            易联众新增字段代支付v1.3.7
            map.put("principalCardNo", ssc); //实际结算卡号( 默认为绑卡主体卡号)
            map.put("principalCardNo", ssc); //实际结算卡号( 默认为绑卡主体卡号)
            if (!patient.equals(repUid)) {
            if (!patient.equals(repUid)) {
                String principalCardNo = null;
                Patient person = patientDao.findByCode(repUid);
                Patient person = patientDao.findByCode(repUid);
                String repOpenId = person.getOpenid();
                BindCard repCard = onePayService.ownerCard(repOpenId);
                String repSsc = repCard.getAttachCardNo();
                map.put("principalCardNo", repSsc); //实际签约卡号( 默认为绑卡主体卡号)
                prescriptionPay.setPrincipalCardNo(repSsc);
                String repSsc = person.getSsc();
                List<BindCard> repCard = onePayService.bindCardList(openid);
                for (BindCard cards : repCard) {
                    String attachCardNo = cards.getAttachCardNo();
                    if (StringUtil.isNotEmpty(attachCardNo) && StringUtil.isNotEmpty(repSsc) && repSsc.equals(attachCardNo)) {
                        principalCardNo = repSsc;
                    }
                }
                if (StringUtils.isNotEmpty(principalCardNo)){
                    map.put("principalCardNo", principalCardNo); //实际签约卡号( 默认为绑卡主体卡号)
                    prescriptionPay.setPrincipalCardNo(principalCardNo);
                }else {
                    resultMap.put("status", "-4");
                    return resultMap;
                }
            }
            }
            params.put("requestContent", objectMapper.writeValueAsString(map));// 请求结构体
            params.put("requestContent", objectMapper.writeValueAsString(map));// 请求结构体
            logger.info("================================>" + "Before msBody");
            logger.info("================================>" + "Before msBody");
@ -1411,7 +1423,7 @@ public class PatientPrescriptionPayService extends BaseService {
        return result;
        return result;
    }
    }
    
    public String getSignFamilyPayResult(String outChargeNo, String accessToken, String appId, String appSecret) throws Exception {
    public String getSignFamilyPayResult(String outChargeNo, String accessToken, String appId, String appSecret) throws Exception {
        PayConfigura config = configuraDao.findWorkConfigura();
        PayConfigura config = configuraDao.findWorkConfigura();
        int flag = 0;
        int flag = 0;
@ -1423,7 +1435,7 @@ public class PatientPrescriptionPayService extends BaseService {
//      ***************************  测通流程 ***************************************
//      ***************************  测通流程 ***************************************
        OnepayDefaultClient onepayClient = new OnepayDefaultClient(config.getOnepayApi(), appId, appSecret, signType, encryptType);
        OnepayDefaultClient onepayClient = new OnepayDefaultClient(config.getOnepayApi(), appId, appSecret, signType, encryptType);
    
        try {
        try {
            RequestParams requestParams = new RequestParams();
            RequestParams requestParams = new RequestParams();
            requestParams.setAppId(appId);
            requestParams.setAppId(appId);
@ -1431,12 +1443,12 @@ public class PatientPrescriptionPayService extends BaseService {
            requestParams.setSignType(signType);
            requestParams.setSignType(signType);
            requestParams.setEncryptType(encryptType);
            requestParams.setEncryptType(encryptType);
            requestParams.setTransType(config.getChargeQueryType());
            requestParams.setTransType(config.getChargeQueryType());
        
            //业务参数
            //业务参数
            JSONObject params = new JSONObject();
            JSONObject params = new JSONObject();
            params.put("outChargeNo", outChargeNo);  //接入应用结算业务流水号
            params.put("outChargeNo", outChargeNo);  //接入应用结算业务流水号
            params.put("wxToken", accessToken);
            params.put("wxToken", accessToken);
        
            requestParams.setParam(params);
            requestParams.setParam(params);
            msgBody = JSON.toJSONString(requestParams);
            msgBody = JSON.toJSONString(requestParams);
@ -1444,13 +1456,13 @@ public class PatientPrescriptionPayService extends BaseService {
            //执行支付 返回原生返回值
            //执行支付 返回原生返回值
            ResponseParams<JSONObject> res = onepayClient.execute(requestParams);
            ResponseParams<JSONObject> res = onepayClient.execute(requestParams);
            response = JSON.toJSONString(res);
            response = JSON.toJSONString(res);
        
            if (OnepayDefaultClient.isSuccessful(res)) {
            if (OnepayDefaultClient.isSuccessful(res)) {
                //业务处理*******************
                //业务处理*******************
//                只返回业务出参
//                只返回业务出参
                flag = 1;
                flag = 1;
                result = JSON.toJSONString(res.getParam());
                result = JSON.toJSONString(res.getParam());
            
                logger.info("请求成功,返回参数: " + result);
                logger.info("请求成功,返回参数: " + result);
            } else {
            } else {
                isSuccess = false;
                isSuccess = false;
@ -1463,7 +1475,7 @@ public class PatientPrescriptionPayService extends BaseService {
            ex.printStackTrace(pw);
            ex.printStackTrace(pw);
            error = sw.toString();
            error = sw.toString();
        }
        }
    
        //type = 3易联众接口保存http日志
        //type = 3易联众接口保存http日志
        logger.info("api - " + config.getChargeQueryType());
        logger.info("api - " + config.getChargeQueryType());
        logger.info("request - " + msgBody);
        logger.info("request - " + msgBody);
@ -1473,7 +1485,7 @@ public class PatientPrescriptionPayService extends BaseService {
        if (!isSuccess) {
        if (!isSuccess) {
            throw new Exception(error);
            throw new Exception(error);
        }
        }
    
        return result;
        return result;
    }
    }
}
}

+ 20 - 7
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/weixin/wxpay/service/OnePayService.java

@ -25,6 +25,8 @@ import com.ylzinfo.onepay.sdk.OnepayDefaultClient;
import com.ylzinfo.onepay.sdk.domain.RequestParams;
import com.ylzinfo.onepay.sdk.domain.RequestParams;
import com.ylzinfo.onepay.sdk.domain.ResponseParams;
import com.ylzinfo.onepay.sdk.domain.ResponseParams;
import com.ylzinfo.onepay.sdk.utils.DateUtil;
import com.ylzinfo.onepay.sdk.utils.DateUtil;
import com.ylzinfo.onepay.sdk.utils.StringUtil;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
@ -130,7 +132,7 @@ public class OnePayService {
    /**
    /**
     * 查询绑卡信息(所有卡)
     * 查询绑卡信息(所有卡)
     */
     */
    private List<BindCard> bindCardList(String openid) throws Exception {
    public List<BindCard> bindCardList(String openid) throws Exception {
        Boolean isSuccess = true;
        Boolean isSuccess = true;
        String msgBody = "";
        String msgBody = "";
        String response = "";
        String response = "";
@ -322,12 +324,23 @@ public class OnePayService {
            map.put("principalCardNo", ssc); //实际签约卡号( 默认为绑卡主体卡号)
            map.put("principalCardNo", ssc); //实际签约卡号( 默认为绑卡主体卡号)
            charge.setPrincipalSsc(ssc);
            charge.setPrincipalSsc(ssc);
            if (!patient.equals(repUid)) {
            if (!patient.equals(repUid)) {
                Patient people = patientDao.findByCode(repUid);
                String repOpenId = people.getOpenid();
                BindCard repCard = ownerCard(repOpenId);
                String repSsc = repCard.getAttachCardNo();
                map.put("principalCardNo", repSsc); //实际签约卡号( 默认为绑卡主体卡号)
                charge.setPrincipalSsc(repSsc);
                String principalCardNo = null;
                Patient person = patientDao.findByCode(repUid);
                String repSsc = person.getSsc();
                List<BindCard> repCard = bindCardList(openid);
                for (BindCard cards : repCard) {
                    String attachCardNo = cards.getAttachCardNo();
                    if (StringUtil.isNotEmpty(attachCardNo) && StringUtil.isNotEmpty(repSsc) && repSsc.equals(attachCardNo)) {
                        principalCardNo = repSsc;
                    }
                }
                if (StringUtils.isNotEmpty(principalCardNo)){
                    map.put("principalCardNo", principalCardNo); //实际签约卡号( 默认为绑卡主体卡号)
                    charge.setPrincipalSsc(principalCardNo);
                }else {
                    return "-1";
                }
            }
            }
            params.put("requestContent", objectMapper.writeValueAsString(map));// 请求结构体
            params.put("requestContent", objectMapper.writeValueAsString(map));// 请求结构体

+ 5 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/prescription/PatientPrescriptionPayController.java

@ -92,6 +92,8 @@ public class PatientPrescriptionPayController extends WeixinBaseController {
                return error(-1, "续方居民信息挂号号或处方号不存在!");
                return error(-1, "续方居民信息挂号号或处方号不存在!");
            } else if ("-3".equals(result.get("status").toString())) {
            } else if ("-3".equals(result.get("status").toString())) {
                return error(-1, "您没有需要待结算的信息!");
                return error(-1, "您没有需要待结算的信息!");
            } else if ("-4".equals(result.get("status").toString())) {
                return error(-1, "附属卡未绑定!");
            } else {
            } else {
                return write(200, "支付成功!", "data", result);
                return write(200, "支付成功!", "data", result);
            }
            }
@ -117,9 +119,10 @@ public class PatientPrescriptionPayController extends WeixinBaseController {
            return error(-1, "获取失败!");
            return error(-1, "获取失败!");
        }
        }
    }
    }
    
    /**
    /**
     * 查询家庭签约支付结果
     * 查询家庭签约支付结果
     *
     * @return
     * @return
     */
     */
    @RequestMapping(value = "/getSignFamilyPayResult", method = RequestMethod.GET)
    @RequestMapping(value = "/getSignFamilyPayResult", method = RequestMethod.GET)
@ -133,7 +136,7 @@ public class PatientPrescriptionPayController extends WeixinBaseController {
            @ApiParam(value = "易联众app secret", name = "appSecret") String appSecret) throws Exception {
            @ApiParam(value = "易联众app secret", name = "appSecret") String appSecret) throws Exception {
        try {
        try {
            String accessToken = getAccessToken();
            String accessToken = getAccessToken();
            String result = payService.getSignFamilyPayResult(outChargeNo, accessToken,appId,appSecret);
            String result = payService.getSignFamilyPayResult(outChargeNo, accessToken, appId, appSecret);
            return write(200, "获取成功!", "data", result);
            return write(200, "获取成功!", "data", result);
        } catch (Exception e) {
        } catch (Exception e) {
            error(e);
            error(e);

+ 40 - 9
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/wx/OnePayController.java

@ -86,21 +86,48 @@ public class OnePayController extends WeixinBaseController {
    @ResponseBody
    @ResponseBody
    public String bindCard() throws Exception {
    public String bindCard() throws Exception {
        try {
        try {
            String repUid = getRepUID();
            JSONObject json = new JSONObject();
            String msg = null;
            String uid = getUID();
            String uid = getUID();
            String openid = getOpenid();
            String repUid = getRepUID();
            String patient = uid;
            Patient people = patientDao.findByCode(uid);
            String ssc = people.getSsc();
            String createType = "sicard";
            String createType = "sicard";
            if (!repUid.equals(uid)) {
            if (!repUid.equals(uid)) {
                patient = repUid;
                createType = "family";
                createType = "family";
                people = patientDao.findByCode(repUid);
                ssc = people.getSsc();
            }
            }
            Patient people = patientDao.findByCode(patient);
            String openid = people.getOpenid();
            BindCard bindCard = pay.bindCard(patient, openid);
            String sicardUrl = pay.createSicard(patient, openid, createType);
            if (bindCard != null) {
//            BindCard bindCard = pay.bindCard(patient, openid);
            List<BindCard> bindCard = pay.bindCardList(openid);
            String sicardUrl = pay.createSicard(uid, openid, createType);
            for (BindCard cards : bindCard) {
                String attachCardNo = cards.getAttachCardNo();
                if (StringUtil.isNotEmpty(attachCardNo) && StringUtil.isNotEmpty(ssc) && ssc.equals(attachCardNo)) {
                    String attachRelation = cards.getAttachRelation();
                    String attachIdType = cards.getAttachIdType();
                    String attachIdNo = cards.getAttachIdNo();
                    String attachName = cards.getAttachName();
                    json.put("attachRelation", attachRelation);
                    json.put("attachCardNo", attachCardNo);
                    json.put("attachIdType", attachIdType);
                    json.put("attachIdNo", attachIdNo);
                    json.put("attachName", attachName);
                    json.put("bindStatus", "000000");
                    json.put("sicardUrl", sicardUrl);
                    msg = "查询绑卡信息成功!";
                    return write(200, "", "data", json);
                } else {
                    json.put("sicardUrl", sicardUrl);
                    json.put("bindStatus", "030007");
                    msg = "生成电子社保卡成功!";
                }
            }
            return write(200, msg, "data", json);
            /*if (bindCard != null) {
                JSONObject json = new JSONObject(bindCard);
                JSONObject json = new JSONObject(bindCard);
                json.put("bindStatus", "000000");
                json.put("bindStatus", "000000");
                json.put("sicardUrl", sicardUrl);
                json.put("sicardUrl", sicardUrl);
@ -111,7 +138,8 @@ public class OnePayController extends WeixinBaseController {
                json.put("sicardUrl", sicardUrl);
                json.put("sicardUrl", sicardUrl);
                json.put("bindStatus", "030007");
                json.put("bindStatus", "030007");
                return write(200, "生成电子社保卡成功!", "data", json);
                return write(200, "生成电子社保卡成功!", "data", json);
            }
            }*/
        } catch (Exception e) {
        } catch (Exception e) {
            error(e);
            error(e);
            return write(-1, "查询电子社保卡失败!");
            return write(-1, "查询电子社保卡失败!");
@ -139,6 +167,9 @@ public class OnePayController extends WeixinBaseController {
            if (StringUtils.isNotEmpty(openId)) {
            if (StringUtils.isNotEmpty(openId)) {
                String settleNo = pay.charge(orgCode, chargeType, chargeRelation, totalAmount, patient, repUid, openId, getAccessToken());
                String settleNo = pay.charge(orgCode, chargeType, chargeRelation, totalAmount, patient, repUid, openId, getAccessToken());
                if ("-1".equals(settleNo)){
                    return write(-1, "附属卡未绑定!");
                }
                return write(200, "家庭医生签约支付成功!", "data", settleNo);
                return write(200, "家庭医生签约支付成功!", "data", settleNo);
            } else {
            } else {
                return write(-1, "openId为空!");
                return write(-1, "openId为空!");