Quellcode durchsuchen

易联众支付配置参数

wujunjie vor 7 Jahren
Ursprung
Commit
2bd2f2cbea

+ 138 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/ylz/PayConfigura.java

@ -0,0 +1,138 @@
package com.yihu.wlyy.entity.ylz;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
/**
 * 易联众支付相关配置参数
 * Created by Reece on 2017/9/9/009.
 */
@Entity
@Table(name = "ylz_pay_config")
public class PayConfigura extends IdEntity implements Serializable {
    //    基础配置参数
    private String onepayApi ;
    private String onepayAppId;
    private String onepayAppSecret;
    private int del; //配置状态 0无效 1有效
    //社保卡绑定及查询
    private String bindCardType;
    private String createSicardType;
    //家庭签约支付
    private String chargeType;
    private String chargeQueryType;
    private String receiveNotify;
    private String returnUrl;
    //续方长处方支付
    private String recipeChargeType;
    private String recipeReturnUrl;
    private String receiveRecipeNotify;
    public int getDel() {
        return del;
    }
    public void setDel(int del) {
        this.del = del;
    }
    public String getOnepayApi() {
        return onepayApi;
    }
    public void setOnepayApi(String onepayApi) {
        this.onepayApi = onepayApi;
    }
    public String getOnepayAppId() {
        return onepayAppId;
    }
    public void setOnepayAppId(String onepayAppId) {
        this.onepayAppId = onepayAppId;
    }
    public String getOnepayAppSecret() {
        return onepayAppSecret;
    }
    public void setOnepayAppSecret(String onepayAppSecret) {
        this.onepayAppSecret = onepayAppSecret;
    }
    public String getBindCardType() {
        return bindCardType;
    }
    public void setBindCardType(String bindCardType) {
        this.bindCardType = bindCardType;
    }
    public String getCreateSicardType() {
        return createSicardType;
    }
    public void setCreateSicardType(String createSicardType) {
        this.createSicardType = createSicardType;
    }
    public String getChargeType() {
        return chargeType;
    }
    public void setChargeType(String chargeType) {
        this.chargeType = chargeType;
    }
    public String getChargeQueryType() {
        return chargeQueryType;
    }
    public void setChargeQueryType(String chargeQueryType) {
        this.chargeQueryType = chargeQueryType;
    }
    public String getReceiveNotify() {
        return receiveNotify;
    }
    public void setReceiveNotify(String receiveNotify) {
        this.receiveNotify = receiveNotify;
    }
    public String getReturnUrl() {
        return returnUrl;
    }
    public void setReturnUrl(String returnUrl) {
        this.returnUrl = returnUrl;
    }
    public String getRecipeChargeType() {
        return recipeChargeType;
    }
    public void setRecipeChargeType(String recipeChargeType) {
        this.recipeChargeType = recipeChargeType;
    }
    public String getRecipeReturnUrl() {
        return recipeReturnUrl;
    }
    public void setRecipeReturnUrl(String recipeReturnUrl) {
        this.recipeReturnUrl = recipeReturnUrl;
    }
    public String getReceiveRecipeNotify() {
        return receiveRecipeNotify;
    }
    public void setReceiveRecipeNotify(String receiveRecipeNotify) {
        this.receiveRecipeNotify = receiveRecipeNotify;
    }
}

+ 17 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/ylz/PayConfiguraDao.java

@ -0,0 +1,17 @@
package com.yihu.wlyy.repository.ylz;
import com.yihu.wlyy.entity.ylz.PayConfigura;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Reece on 2017/9/9.
 */
public interface PayConfiguraDao extends PagingAndSortingRepository<PayConfigura, Long>, JpaSpecificationExecutor<PayConfigura> {
    //查询有效支付相关配置(只有一条有效记录)
    @Query("select t from PayConfigura t where t.del = 1 ")
    PayConfigura findWorkConfigura();
}

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

@ -13,6 +13,7 @@ import com.yihu.wlyy.entity.organization.HospitalMapping;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.patient.prescription.*;
import com.yihu.wlyy.entity.ylz.PayConfigura;
import com.yihu.wlyy.entity.zydict.ZyPushLog;
import com.yihu.wlyy.repository.charge.ChargeDao;
import com.yihu.wlyy.repository.doctor.DoctorDao;
@ -22,11 +23,11 @@ import com.yihu.wlyy.repository.organization.HospitalMappingDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.prescription.*;
import com.yihu.wlyy.repository.ylz.PayConfiguraDao;
import com.yihu.wlyy.repository.zydict.ZyPushLogDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.third.httplog.LogService;
import com.yihu.wlyy.service.third.jw.JwPrescriptionService;
import com.yihu.wlyy.service.weixin.wxpay.common.Configure;
import com.yihu.wlyy.service.weixin.wxpay.model.BindCard;
import com.yihu.wlyy.service.weixin.wxpay.model.Charge;
import com.yihu.wlyy.service.weixin.wxpay.service.OnePayService;
@ -82,7 +83,7 @@ public class PatientPrescriptionPayService extends BaseService {
    //    引入实例
    @Autowired
    private Configure config;
    private PayConfiguraDao configuraDao;
    @Autowired
    private ObjectMapper objectMapper;
    @Autowired
@ -258,6 +259,7 @@ public class PatientPrescriptionPayService extends BaseService {
     * @return
     */
    public Map recipeReturnUrl(HttpServletRequest request, HttpServletResponse response, String accessToken) throws Exception {
        PayConfigura config = configuraDao.findWorkConfigura();
        Map resultMap = new HashMap();
        Prescription prescription = null;
        int flag = 0;
@ -431,6 +433,7 @@ public class PatientPrescriptionPayService extends BaseService {
     * @return
     */
    public String receiveRecipeNotify(HttpServletRequest request, HttpServletResponse response) throws Exception {
        PayConfigura config = configuraDao.findWorkConfigura();
        String result = null;
        Prescription prescription = null;
@ -642,6 +645,7 @@ public class PatientPrescriptionPayService extends BaseService {
     */
    @Transactional
    public Map charge(int type, String addressJson, String orgCode, String prescriptionCode, int totalAmount, String people, String accessToken, String returnUrl,String deliveryTime) throws Exception {
        PayConfigura config = configuraDao.findWorkConfigura();
        Map resultMap = new HashMap();
        Prescription prescription = null;
@ -807,7 +811,7 @@ public class PatientPrescriptionPayService extends BaseService {
                    //根据居民code查询团队长及所在团队待处理订单数量
                    String sql = "SELECT a.id teamCode,a.leader_code leaderCode,d.`name` leaderName " +
                            " FROM wlyy_sign_family t,wlyy_admin_team a,wlyy_doctor d " +
                            " WHERE t.admin_team_code=a.id AND d.code=a.leader_code " +
                            " WHERE t.`status`=1 AND t.admin_team_code=a.id AND d.code=a.leader_code " +
                            " AND t.patient=? ";
                    Map<String, Object> team = jdbcTemplate.queryForMap(sql, people);
                    logger.debug("================> get order amount!");
@ -1025,6 +1029,8 @@ public class PatientPrescriptionPayService extends BaseService {
     * 家庭医生签约支付查询
     */
    public String chargeQuery(String code, String accessToken) throws Exception {
        PayConfigura config = configuraDao.findWorkConfigura();
        int flag = 0;
        Boolean isSuccess = true;
        String msgBody = "";

+ 78 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/template/DoctorFeldsherTemplateService.java

@ -0,0 +1,78 @@
package com.yihu.wlyy.service.template;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import com.yihu.wlyy.wechat.util.WeiXinOpenIdUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
 * 医生助手相关模板消息
 * <p>
 * Created by Reece on 2017/9/7/007.
 */
public class DoctorFeldsherTemplateService extends BaseService {
    @Autowired
    private PushMsgTask pushMsgTask;
    @Autowired
    private WeiXinAccessTokenUtils weiXinAccessTokenUtils;
    @Autowired
    private PatientDao patientDao;
    @Autowired
    private WeiXinOpenIdUtils weiXinOpenIdUtils;
    private static final Logger logger = LoggerFactory.getLogger(DoctorFeldsherTemplateService.class);
    /**
     * 医生为居民设置监测方案后实时为居民推送信息变更通知消息提醒
     *
     * @param patient 居民code
     * @param url     带参数的跳转URL
     * @throws Exception
     */
    public void sendChangeTemplate(String patient, String url) throws Exception {
        Patient people = patientDao.findByCode(patient);
        String openId = people.getOpenid();
        String name = people.getName();
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        JSONArray jsonArray = null;
        JSONObject sendJson = new JSONObject();
        String first = name + "您好,您的家庭医生已为您设置了血糖(血压)监测方案,请按照方案及时测量及上传您的体征数据。";
        String remark = "您可使用详情查看方案内容";
        sendJson.put("keyword1", name);
        sendJson.put("keyword2", dateFormat.format(new Date()));
        sendJson.put("keyword3", "血糖(血压)监测方案");
        sendJson.put("first", first);
        sendJson.put("remark", remark);
        sendJson.put("url", url);//带参数的模板跳转链接
        pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 10, openId, name, sendJson);
        //发送代理人
        jsonArray = weiXinOpenIdUtils.getAgentOpenId(patient, openId);
        if (jsonArray != null && jsonArray.length() > 0) {
            for (int i = 0; i < jsonArray.length(); i++) {
                JSONObject j = jsonArray.getJSONObject(i);
                Patient member = (Patient) j.get("member");
                int start = url.indexOf("&toUser=");
                int end = url.indexOf("&", start + 1);
                String touser = url.substring(start, end);
                url = url.replace(touser, "&toUser=" + member.getCode());
                //name患者姓名
                sendJson.put("first", weiXinOpenIdUtils.getTitleMes(people, (int) j.get("relation"), name) + first);
                sendJson.put("url", url);
                pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 10, member.getOpenid(), name, sendJson);
            }
        }
        logger.info("sendJson: "+sendJson);
    }
}

+ 0 - 129
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/weixin/wxpay/common/Configure.java

@ -1,129 +0,0 @@
package com.yihu.wlyy.service.weixin.wxpay.common;
import org.springframework.context.annotation.Configuration;
/**
 * User: hzp
 * Date: 20170518
 * 这里放置各种配置数据
 */
@Configuration
public class Configure {
	/******************************* 易联众统一支付平台 ***********************************************************/
//	private String onepayApi = "http://120.42.37.94:1301/onepay-web/";
//	private String onepayAppId = "1BGKM1UHM03P7B2CA8C000005626EB0E";
//	private String onepayAppSecret = "1BGKM1UHM03I7B2CA8C00000AB682E9A";
//			开发环境应用信息
//	private String onepayApi = "https://xmhealth.ylzpay.com:8080/";
	private String onepayApi = "http://xmhealth.ylzpay.com:8070/";
	private String onepayAppId = "1BLF5SEGN00087165F0A000027362BE5";
	private String onepayAppSecret = "1BLF5SCBO01V3E78A8C00000F3A0FFE7";
	private String bindCardType = "onepay.sicard.bind.info";
	private String chargeType = "onepay.trade.medical.charge";
	private String chargeQueryType = "onepay.trade.medical.charge.query";
	private String createSicardType = "onepay.sicard.createurl";
//	易联众异步回调
	private String receiveNotify = "wlyy.onepay.receiveNotify";
	private String returnUrl = "wlyy.onepay.returnUrl";
//  长处方系列
	private String recipeChargeType = "onepay.trade.long.recipe.charge";
	private String recipeReturnUrl = "wlyy.patient.prescription.pay.recipeReturnUrl";
	private String receiveRecipeNotify = "wlyy.patient.prescription.pay.receiveRecipeNotify";
	public String getRecipeChargeType() {
		return recipeChargeType;
	}
	public void setRecipeChargeType(String recipeChargeType) {
		this.recipeChargeType = recipeChargeType;
	}
	public String getRecipeReturnUrl() {
		return recipeReturnUrl;
	}
	public void setRecipeReturnUrl(String recipeReturnUrl) {
		this.recipeReturnUrl = recipeReturnUrl;
	}
	public String getReceiveRecipeNotify() {
		return receiveRecipeNotify;
	}
	public void setReceiveRecipeNotify(String receiveRecipeNotify) {
		this.receiveRecipeNotify = receiveRecipeNotify;
	}
	public String getReturnUrl() {
		return returnUrl;
	}
	public void setReturnUrl(String returnUrl) {
		this.returnUrl = returnUrl;
	}
	public String getReceiveNotify() {
		return receiveNotify;
	}
	public void setReceiveNotify(String receiveNotify) {
		this.receiveNotify = receiveNotify;
	}
	public String getOnepayApi() {
		return onepayApi;
	}
	public String getOnepayAppId() {
		return onepayAppId;
	}
	public String getOnepayAppSecret() {
		return onepayAppSecret;
	}
	public String getBindCardType() {
		return bindCardType;
	}
	public String getChargeType() {
		return chargeType;
	}
	public String getChargeQueryType() {
		return chargeQueryType;
	}
	public String getCreateSicardType() {
		return createSicardType;
	}
	/******************* 微信社保支付配置 ******************************************/
	//这个就是自己要保管好的私有Key了(切记只能放在自己的后台代码里,不能放在任何可能被看到源代码的客户端程序中)
	// 每次自己Post数据给API的时候都要用这个key来对所有字段进行签名,生成的签名会放在Sign这个字段,API收到Post数据的时候也会用同样的签名算法对Post过来的数据进行签名和验证
	// 收到API的返回的时候也要用这个key来对返回的数据算下签名,跟API的Sign数据进行比较,如果值不一致,有可能数据被第三方给篡改
	private String key = "2935b54b53a957d9516c920a544f2537";
	//微信分配的公众号ID(开通公众号之后可以获取到)
	private String appID = "wxd03f859efdf0873d";
	public String getKey(){
		return key;
	}
	public String getAppid(){
		return appID;
	}
	//获取token地址
	public String TOKEN_API = "https://api.weixin.qq.com/payinsurance/gettoken";
	//挂号/诊间支付统一下单 API 接口
	public String ORDER_API = "https://api.weixin.qq.com/payinsurance/unifiedorder?access_token ACCESS_TOKEN";
}

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

@ -5,7 +5,6 @@ import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.entity.organization.HospitalMapping;
import com.yihu.wlyy.repository.organization.HospitalMappingDao;
import com.yihu.wlyy.service.third.httplog.LogService;
import com.yihu.wlyy.service.weixin.wxpay.common.Configure;
import com.ylzinfo.onepay.sdk.OnepayDefaultClient;
import com.ylzinfo.onepay.sdk.domain.RequestParams;
import com.ylzinfo.onepay.sdk.domain.ResponseParams;

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

@ -9,13 +9,14 @@ import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.organization.HospitalMapping;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.ylz.PayConfigura;
import com.yihu.wlyy.repository.charge.ChargeDao;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.organization.HospitalMappingDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.ylz.PayConfiguraDao;
import com.yihu.wlyy.service.third.httplog.LogService;
import com.yihu.wlyy.service.weixin.wxpay.common.Configure;
import com.yihu.wlyy.service.weixin.wxpay.model.BindCard;
import com.yihu.wlyy.service.weixin.wxpay.model.Charge;
import com.yihu.wlyy.util.SystemConf;
@ -24,7 +25,6 @@ import com.ylzinfo.onepay.sdk.OnepayDefaultClient;
import com.ylzinfo.onepay.sdk.domain.RequestParams;
import com.ylzinfo.onepay.sdk.domain.ResponseParams;
import com.ylzinfo.onepay.sdk.utils.DateUtil;
import io.swagger.models.auth.In;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -47,7 +47,7 @@ import java.util.*;
public class OnePayService {
    @Autowired
    private Configure config;
    private PayConfiguraDao configuraDao;
    @Autowired
    private LogService logService;
@ -137,6 +137,7 @@ public class OnePayService {
        String error = "";
        List<BindCard> result = new ArrayList<BindCard>();
        PayConfigura config = configuraDao.findWorkConfigura();
        String appId = config.getOnepayAppId();
        String appSecret = config.getOnepayAppSecret();
        OnepayDefaultClient onepayClient = new OnepayDefaultClient(config.getOnepayApi(), appId, appSecret, signType, encryptType);
@ -218,6 +219,7 @@ public class OnePayService {
        String result = "";
        String channel = "WX_MMP";   //  医保支付渠道
        String subject = "家庭医生签约支付";   //  订单名称
        PayConfigura config = configuraDao.findWorkConfigura();
        OnepayDefaultClient onepayClient = new OnepayDefaultClient(config.getOnepayApi(), appId, appSecret, signType, encryptType);
//     未真正完成支付以前预存储支付信息到wlyy_charge表
@ -373,6 +375,7 @@ public class OnePayService {
        String response = "";
        String error = "";
        String result = null;
        PayConfigura config = configuraDao.findWorkConfigura();
        WlyyCharge charge = chargeDao.findByCode(code);
        HospitalMapping hospitalMapping = hospitalMappingDao.findByCode(charge.getHospital());
@ -443,6 +446,7 @@ public class OnePayService {
        String response = "";
        String error = "";
        String result = "";
        PayConfigura config = configuraDao.findWorkConfigura();
        String appId = config.getOnepayAppId();
        String appSecret = config.getOnepayAppSecret();

+ 5 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/wx/OnePayController.java

@ -4,12 +4,13 @@ import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.entity.charge.WlyyCharge;
import com.yihu.wlyy.entity.organization.HospitalMapping;
import com.yihu.wlyy.entity.ylz.PayConfigura;
import com.yihu.wlyy.repository.charge.ChargeDao;
import com.yihu.wlyy.repository.organization.HospitalMappingDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.ylz.PayConfiguraDao;
import com.yihu.wlyy.service.third.httplog.LogService;
import com.yihu.wlyy.service.weixin.wxpay.common.Configure;
import com.yihu.wlyy.service.weixin.wxpay.model.BindCard;
import com.yihu.wlyy.service.weixin.wxpay.model.Charge;
import com.yihu.wlyy.service.weixin.wxpay.service.OnePayService;
@ -69,7 +70,7 @@ public class OnePayController extends WeixinBaseController {
    @Autowired
    LogService logService;
    @Autowired
    private Configure config;
    private PayConfiguraDao configuraDao;
    @Autowired
    private HospitalMappingDao mappingDao;
    @Autowired
@ -262,6 +263,7 @@ public class OnePayController extends WeixinBaseController {
     */
    @RequestMapping(value = "/returnUrl")
    public void returnUrl(HttpServletRequest request, HttpServletResponse response) throws IOException, PayException {
        PayConfigura config = configuraDao.findWorkConfigura();
        Boolean isSuccess = false;
        String error = "";
        String responses = "";
@ -347,6 +349,7 @@ public class OnePayController extends WeixinBaseController {
     */
    @RequestMapping(value = "/receiveNotify")
    public void receiveNotify(HttpServletRequest request, HttpServletResponse response) throws IOException, PayException {
        PayConfigura config = configuraDao.findWorkConfigura();
        Boolean isSuccess = false;
        String error = "";
        String responses = "";

+ 0 - 6
patient-co/patient-co-wlyy/src/main/resources/application-dev.yml

@ -82,12 +82,6 @@ images:
sign:
  check_upload: http://172.19.103.87:8011/wlyy_service
ylzpay:
  onepayApi: http://120.42.37.94:1301/onepay-web/
  onepayAppId: 1BGKM1UHM03P7B2CA8C000005626EB0E
  onepayAppSecret: 1BGKM1UHM03I7B2CA8C00000AB682E9A
express:
  sf_url: http://218.17.248.244:11080/bsp-oisp/sfexpressService
#  sf_url: https://bsp-ois.sit.sf-express.com:9443/bsp-ois/sfexpressServic

+ 0 - 8
patient-co/patient-co-wlyy/src/main/resources/application-prod.yml

@ -78,14 +78,6 @@ images:
sign:
  check_upload: http://59.61.92.90:8072/wlyy_service
ylzpay:
#  onepayApi: https://xmhealth.ylzpay.com:8080/
  onepayApi: http://xmhealth.ylzpay.com:8070/
  onepayAppId: 1BLF5SEGN00087165F0A000027362BE5
  onepayAppSecret: 1BLF5SCBO01V3E78A8C00000F3A0FFE7
express:
  sf_url: http://bsp-oisp.sf-express.com/bsp-oisp/sfexpressService

+ 0 - 6
patient-co/patient-co-wlyy/src/main/resources/application-test.yml

@ -77,12 +77,6 @@ images:
sign:
  check_upload: http://172.19.103.88:8011/wlyy_service
ylzpay:
  onepayApi: http://120.42.37.94:1301/onepay-web/
  onepayAppId: 1BGKM1UHM03P7B2CA8C000005626EB0E
  onepayAppSecret: 1BGKM1UHM03I7B2CA8C00000AB682E9A
express:
  sf_url: http://218.17.248.244:11080/bsp-oisp/sfexpressService
#  sf_url: https://bsp-ois.sit.sf-express.com:9443/bsp-ois/sfexpressServic