소스 검색

统一支付接口

hzp 7 년 전
부모
커밋
051cbff6fe

+ 25 - 26
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/weixin/wxpay/model/BindCard.java

@ -21,50 +21,49 @@ import java.io.StringWriter;
 * add by hzp at 20170524
 */
public class BindCard {
    private String cardNo;
    private String idType;
    private String idNo;
    private String userName;
    private String userId;
    private String attachCardNo;
    private String attachIdType;
    private String attachIdNo;
    private String attachName;
    private String attachRelation;   //01配偶 02父母 03子女  98本人 99未知
    public String getCardNo() {
        return cardNo;
    public String getAttachCardNo() {
        return attachCardNo;
    }
    public void setCardNo(String cardNo) {
        this.cardNo = cardNo;
    public void setAttachCardNo(String attachCardNo) {
        this.attachCardNo = attachCardNo;
    }
    public String getIdType() {
        return idType;
    public String getAttachIdType() {
        return attachIdType;
    }
    public void setIdType(String idType) {
        this.idType = idType;
    public void setAttachIdType(String attachIdType) {
        this.attachIdType = attachIdType;
    }
    public String getIdNo() {
        return idNo;
    public String getAttachIdNo() {
        return attachIdNo;
    }
    public void setIdNo(String idNo) {
        this.idNo = idNo;
    public void setAttachIdNo(String attachIdNo) {
        this.attachIdNo = attachIdNo;
    }
    public String getUserName() {
        return userName;
    public String getAttachName() {
        return attachName;
    }
    public void setUserName(String userName) {
        this.userName = userName;
    public void setAttachName(String attachName) {
        this.attachName = attachName;
    }
    public String getUserId() {
        return userId;
    public String getAttachRelation() {
        return attachRelation;
    }
    public void setUserId(String userId) {
        this.userId = userId;
    public void setAttachRelation(String attachRelation) {
        this.attachRelation = attachRelation;
    }
}

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

@ -2,6 +2,7 @@ package com.yihu.wlyy.service.weixin.wxpay.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.entity.charge.WlyyCharge;
import com.yihu.wlyy.entity.organization.HospitalMapping;
@ -56,23 +57,27 @@ public class OnePayService {
    PatientDao patientDao;
    /**
     *  查询绑卡信息
     *  查询绑卡信息(本人)
     */
    public BindCard bindCard(String patient,String openid)  throws Exception
    {
        BindCard card = bindCard(openid);
        BindCard card = ownerCard(openid);
        //更新患者信息
        if(card!=null)
        {
            Patient p = patientDao.findByCode(patient);
            p.setOpenid(openid);
            p.setSsc(card.getCardNo());
            if(card.getIdType()=="01")      //身份证
            p.setSsc(card.getAttachCardNo());
            if(card.getAttachIdType()=="01")      //身份证
            {
                p.setIdcard(card.getIdNo());
                p.setIdcard(card.getAttachIdNo());
            }
            p.setName(card.getUserName());
            if(!card.getAttachName().equals(p.getName()))
            {
                System.out.print("姓名不一致,姓名:"+p.getName()+"  社保姓名:"+card.getAttachName());
            }
            patientDao.save(p);
        }
@ -80,15 +85,38 @@ public class OnePayService {
    }
    /**
     * 查询绑卡信息
     * 查询绑卡信息(本人)
     */
    private BindCard ownerCard(String openid) throws Exception
    {
        BindCard re = null;
        List<BindCard> cardList = bindCardList(openid);
        //更新患者信息
        if(cardList!=null && cardList.size()>0)
        {
            for(BindCard card:cardList)
            {
                if("98".equals(card.getAttachRelation()))
                {
                    re = card;
                    break;
                }
            }
        }
        return re;
    }
    /**
     * 查询绑卡信息(所有卡)
     */
    private BindCard bindCard(String openid) throws Exception
    private List<BindCard> bindCardList(String openid) throws Exception
    {
        Boolean isSuccess = true;
        String msgBody = "";
        String response = "";
        String error = "";
        BindCard result = null;
        List<BindCard> result = new ArrayList<BindCard>();
        String appId = config.getOnepayAppId();
        String appSecret = config.getOnepayAppSecret();
@ -106,7 +134,7 @@ public class OnePayService {
            // 如医保绑卡信息请求参数
            JSONObject params = new JSONObject();
            params.put("openId", openid);
            params.put("accId", SystemConf.getInstance().getAppId());  //微信公众号开发者ID
            params.put("accId", SystemConf.getInstance().getAccId()); //微信公众号开发者ID
            requestParams.setParam(params);
            requestParams.setTransType(config.getBindCardType());
@ -116,11 +144,8 @@ public class OnePayService {
            // 如医保卡绑卡信息返回参数
            if (OnepayDefaultClient.isSuccessful(res)) {
                result = JSON.toJavaObject(res.getParam(), BindCard.class);
                //业务处理***********
                System.out.println("请求成功,返回参数:" + result.getCardNo() + "," +  result.getIdType() + "," + result.getIdNo() + "," + result.getUserName() + "," + result.getUserId());
                JavaType javaType = objectMapper.getTypeFactory().constructParametricType(List.class, BindCard.class);
                result = objectMapper.readValue(objectMapper.writeValueAsString(res.getParam().get("attachList")),javaType);
            }
            else {
                isSuccess = false;
@ -197,11 +222,11 @@ public class OnePayService {
            charge.setInsuranceAmount(insuranceAmount);  //  医保支付金额
            charge.setFeeDetail(feeDetail);  //  费用明细
            BindCard card= bindCard(openid);
            String name = card.getUserName();
            String ssc = card.getCardNo();
            String idType = card.getIdType();
            String idNo = card.getIdNo();
            BindCard card= ownerCard(openid);
            String name = card.getAttachName();
            String ssc = card.getAttachCardNo();
            String idType = card.getAttachIdType();
            String idNo = card.getAttachIdNo();
            charge.setName(name);
            charge.setIdType(idType);
            charge.setIdNo(idNo);
@ -372,7 +397,7 @@ public class OnePayService {
            // 如医保绑卡信息请求参数
            JSONObject params = new JSONObject();
            params.put("openId", openid);
            params.put("accId", SystemConf.getInstance().getAppId());  //微信公众号开发者ID
            params.put("accId", SystemConf.getInstance().getAccId());  //微信公众号开发者ID
            requestParams.setParam(params);
            requestParams.setTransType(config.getCreateSicardType());

+ 5 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/util/SystemConf.java

@ -280,6 +280,11 @@ public class SystemConf {
		}
		return temp;
	}
	public String getAccId(){
		String temp = getSystemProperties().getProperty("accId");
		return temp;
	}
	
	public String getAppSecret(){
		String temp = getSystemProperties().getProperty(appSecret);

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

@ -54,8 +54,8 @@ public class OnePayController extends WeixinBaseController {
    public String expensesStatus() throws Exception {
        try {
            //            获取居民个人信息  要根据签约code去查找签约扣费状态
            String userCode = getUID();
//            String userCode = "915cc456-5b1d-11e6-8344-fa163e8aee56";
//            String userCode = getUID();
            String userCode = "915cc456-5b1d-11e6-8344-fa163e8aee56";
            SignFamily signFamily = signFamilyDao.findPatientExpensesStatus(userCode);
            String expensesStatus = signFamily.getExpensesStatus();
            if ("0".equals(expensesStatus)){
@ -72,23 +72,25 @@ public class OnePayController extends WeixinBaseController {
        }
    }
    @RequestMapping(value = "createSicard", method = RequestMethod.POST)
    @ApiOperation("生成电子社保卡")
    @ResponseBody
    public String createSicard() throws Exception {
        try {
            String sicardUrl = pay.createSicard("0cc6e4562de2437ab2dbbf51a9fc3b49","oULM4xAj9sOsHJ95ttKYd_Fjh6Hc");//getUID(), getOpenid());
            return write(200, "生成电子社保卡成功!", "data", sicardUrl);
        } catch (Exception e) {
            return error(-1, e.getMessage());
        }
    }
    @RequestMapping(value = "bindCard", method = RequestMethod.POST)
    @ApiOperation("查询绑卡信息")
    @ResponseBody
    public String bindCard() throws Exception {
        try {
            //            获取居民个人信息
            String userCode = getUID();
            String openId = getOpenid();
            if (StringUtils.isNotEmpty(openId)) {
                BindCard bindCard = pay.bindCard(userCode, openId);
                return write(200, "查询绑卡信息成功!", "data", bindCard);
            } else {
                return write(-1, "openId为空!");
            }
//            BindCard bindCard = pay.bindCard("915cc456-5b1d-11e6-8344-fa163e8aee56","o4Ma2t5665rS7uNfA9EF-VnOJx30");         //ohNH9sh4uwuJCxIwcLJtGTX-BaSk  //o4Ma2t5665rS7uNfA9EF-VnOJx30      getUID()getOpenid()
//            BindCard bindCard = pay.bindCard("915cc456-5b1d-11e6-8344-fa163e8aee56","ohNH9sh4uwuJCxIwcLJtGTX-BaSk");         //ohNH9sh4uwuJCxIwcLJtGTX-BaSk  //o4Ma2t5665rS7uNfA9EF-VnOJx30      getUID()getOpenid()
//            return write(200, "查询绑卡信息成功!","data",bindCard);
            BindCard bindCard = pay.bindCard("0cc6e4562de2437ab2dbbf51a9fc3b49","oULM4xAj9sOsHJ95ttKYd_Fjh6Hc");//getUID(), getOpenid());      oULM4xAj9sOsHJ95ttKYd_Fjh6Hc
            return write(200, "查询绑卡信息成功!","data",bindCard);
        } catch (Exception e) {
            return error(-1, e.getMessage());
@ -115,8 +117,9 @@ public class OnePayController extends WeixinBaseController {
            @RequestParam String feeDetail) throws Exception {
        try {
            //            获取居民个人信息
            String userCode = getUID();
            String openId = getOpenid();
            /*String userCode = getUID();
            Patient patient = patientDao.findByCode(userCode);
            String openId = patient.getOpenid();
            if (StringUtils.isNotEmpty(openId)) {
                String settleNo = pay.charge(orgCode, chargeType, chargeRelation, totalAmount, selfpayAmount, insuranceAmount, feeDetail, userCode, openId);  //ohNH9sh4uwuJCxIwcLJtGTX-BaSk    getUID(),getOpenid()
//            更新签约表的缴费状态(begin字段),表示签约正式开始
@ -124,10 +127,9 @@ public class OnePayController extends WeixinBaseController {
                return write(200, "家庭医生签约支付成功!", "data", settleNo);
            } else {
                return write(-1, "openId为空!");
            }
//            String settleNo = pay.charge(orgCode, chargeType, chargeRelation, totalAmount, selfpayAmount, insuranceAmount, feeDetail, "915cc456-5b1d-11e6-8344-fa163e8aee56", "o4Ma2t5665rS7uNfA9EF-VnOJx30");  //ohNH9sh4uwuJCxIwcLJtGTX-BaSk    getUID(),getOpenid()
//            String settleNo = pay.charge(orgCode, chargeType, chargeRelation, totalAmount, selfpayAmount, insuranceAmount, feeDetail, "915cc456-5b1d-11e6-8344-fa163e8aee56", "ohNH9sh4uwuJCxIwcLJtGTX-BaSk");  //ohNH9sh4uwuJCxIwcLJtGTX-BaSk    getUID(),getOpenid()
//            return write(200, "家庭医生签约支付成功!", "data", settleNo);
            }*/
            String settleNo = pay.charge(orgCode, chargeType, chargeRelation, totalAmount, selfpayAmount, insuranceAmount, feeDetail,"0cc6e4562de2437ab2dbbf51a9fc3b49", "oULM4xAj9sOsHJ95ttKYd_Fjh6Hc");  //getUID(),getOpenid()
            return write(200, "家庭医生签约支付成功!", "data", settleNo);
        } catch (Exception e) {
            return error(-1, e.getMessage());
        }
@ -147,26 +149,7 @@ public class OnePayController extends WeixinBaseController {
        }
    }
    @RequestMapping(value = "createSicard", method = RequestMethod.POST)
    @ApiOperation("生成电子社保卡")
    @ResponseBody
    public String createSicard() throws Exception {
        try {
            //            获取居民个人信息
            String userCode = getUID();
            String openId = getOpenid();
            if (StringUtils.isNotEmpty(openId)) {
                String sicardUrl = pay.createSicard(userCode, openId);         //ohNH9sh4uwuJCxIwcLJtGTX-BaSk  //o4Ma2t5665rS7uNfA9EF-VnOJx30  getUID(),getOpenid()
                return write(200, "生成电子社保卡成功!", "data", sicardUrl);
            }else {
                return write(-1, "openId为空!");
            }
//            String sicardUrl = pay.createSicard("915cc456-5b1d-11e6-8344-fa163e8aee56", "o4Ma2t5665rS7uNfA9EF-VnOJx30");         //ohNH9sh4uwuJCxIwcLJtGTX-BaSk  //o4Ma2t5665rS7uNfA9EF-VnOJx30  getUID(),getOpenid()
//            return write(200, "生成电子社保卡成功!", "data", sicardUrl);
        } catch (Exception e) {
            return error(-1, e.getMessage());
        }
    }
    @RequestMapping(value = "chargeList", method = RequestMethod.POST)
@ -239,6 +222,7 @@ public class OnePayController extends WeixinBaseController {
        if (StringUtil.isEmpty(reqQueryString)) {
            throw new PayException("跳转参数为空");
        }
        Map<String, String> targetMap = null;
        try {

+ 1 - 0
patient-co-wlyy/src/main/resources/system.properties

@ -236,6 +236,7 @@ im_group_server=http://120.41.253.95:3000/api/v1/chats/gm
msg_push_server=http://120.41.253.95:3000/api/v1/chats/sm
# 微信基本配置
accId=gh_ffd64560fb21
appId=wxad04e9c4c5255acf
appSecret=ae77c48ccf1af5d07069f5153d1ac8d3
wechat_token=27eb3bb24f149a7760cf1bb154b08040