From f96ad6ec73b3da7df5c08471f0d567d46fc767e8 Mon Sep 17 00:00:00 2001
From: jyy <935090232@qq.com>
Date: Fri, 09 Apr 2021 14:34:18 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/score_shop' into score_shop

---
 zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/weixinUtil/WeixinServiceUtil.java |   55 ++++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 42 insertions(+), 13 deletions(-)

diff --git a/zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/weixinUtil/WeixinServiceUtil.java b/zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/weixinUtil/WeixinServiceUtil.java
index 7a00022..cc168ab 100644
--- a/zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/weixinUtil/WeixinServiceUtil.java
+++ b/zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/weixinUtil/WeixinServiceUtil.java
@@ -25,6 +25,7 @@
 import com.matrix.system.common.interceptor.HostInterceptor;
 import com.matrix.system.shopXcx.api.tools.WxShopOrderUtil;
 import org.apache.log4j.Logger;
+import org.jetbrains.annotations.NotNull;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
@@ -69,16 +70,34 @@
 	 * @return 预支付订单返回的结果对象(该结果对象已封装),在H5页面使用该对象信息
 	 * @throws Exception
 	 */
-	public BrandWCPayRequestData createOrder(String desc,String outTradeNo, int price, String openId,String attach) throws Exception {
+	public BrandWCPayRequestData createOrder(String desc, String outTradeNo, int price, String openId, String attach) throws Exception {
+		Long companyId=HostInterceptor.getCompanyId();
+		BusParameterSettings notifyUrl = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.WECHARPAY_NOTIFYURL, companyId);
+		return buildBrandWCPayRequestData(desc, outTradeNo, price, openId, attach, notifyUrl);
+	}
+
+	/**
+	 * 创建充值订单
+	 */
+	public BrandWCPayRequestData createRechargeOrder(String desc, String outTradeNo, int price, String openId, String attach) throws Exception {
+		Long companyId=HostInterceptor.getCompanyId();
+		BusParameterSettings notifyUrl = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.WECHARPAY_RECHARGE_NOTIFYURL, companyId);
+		return buildBrandWCPayRequestData(desc, outTradeNo, price, openId, attach, notifyUrl);
+	}
+
+
+
+	@NotNull
+	private BrandWCPayRequestData buildBrandWCPayRequestData(String desc, String outTradeNo, int price, String openId, String attach, BusParameterSettings notifyUrl) throws Exception {
 		// 创建微信支付预付接口
 		JsApiPayBusiness jsApiPayBusiness = new JsApiPayBusiness();
 		String idAddr = getIpAddr(WebUtil.getRequest());
 
 		Long companyId=HostInterceptor.getCompanyId();
 
-		BusParameterSettings mchID = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.WECHARPAY_APPID, companyId);
+		BusParameterSettings mchID = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.WECHARPAY_MCHID, companyId);
 		BusParameterSettings paySecret = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.WECHARPAY_SECRET, companyId);
-		BusParameterSettings notifyUrl = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.WECHARPAY_NOTIFYURL, companyId);
+
 
 		BusParameterSettings appId = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.MINIPROGRAM_APPID, companyId);
 
@@ -102,10 +121,9 @@
 			LogUtil.error("创建微信支付订单失败msg={}",result.getReturn_msg());
 			throw new GlobleException("创建微信支付订单失败,请检查程序配置");
 		}
-
 	}
-	
-	
+
+
 	/**@Description 支付后,向微信发送请求、查询订单,看订单是否真的支付成功了
 	   @date 2017年6月27日
 	   @atuhor jiangyouyao
@@ -142,20 +160,31 @@
 	 * @param openid
 	 * @return
 	 */
-	public JsApiPayComResData comPay(String desc, String outTradeNo,int totalFee, String openid){
+	public JsApiPayComResData comPay(String desc, String outTradeNo,int totalFee, String openid,Long companyId){
 		JsApiPayComResData result=null;
-		//boolean flag=false;
 		try {
 			JsApiPayBusiness jsApiPayBusiness = new JsApiPayBusiness();
 			// TODO 企业付款
-			Long companyId=HostInterceptor.getCompanyId();
-			BusParameterSettings mchID = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.WECHARPAY_APPID, companyId);
+
+			BusParameterSettings mchID = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.WECHARPAY_MCHID, companyId);
+			BusParameterSettings appId = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.MINIPROGRAM_APPID, companyId);
 			BusParameterSettings paySecret = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.WECHARPAY_SECRET, companyId);
 
+			BusParameterSettings certLocalPath = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.WECHARPAY_CERTLOCAL_PATH, companyId);
 
-			JsApiPayComReqData jsApiPayComReqData=new JsApiPayComReqData(mchID.getParamValue(),paySecret.getParamValue(),"","",0,"","","");
+			JsApiPayComReqData jsApiPayComReqData=new JsApiPayComReqData(mchID.getParamValue(),
+					appId.getParamValue(),
+					paySecret.getParamValue(),
+					desc,outTradeNo,totalFee,openid,"NO_CHECK","");
 			JsApiPayComService jsApiPayComService=new JsApiPayComService();
+
+			HttpsRequest2 request2= (HttpsRequest2) jsApiPayComService.getServiceRequest();
+			request2.setCertLocalPath(certLocalPath.getParamValue());
+			request2.setMchId(mchID.getParamValue());
+
+
 			result = jsApiPayBusiness.payComOrder(jsApiPayComService, jsApiPayComReqData);
+
 			LogUtil.info("#提现,企业付款到个人---result:{}",result);
 			if (result.getResult_code().equals("SUCCESS")) {
 				return result;
@@ -183,7 +212,7 @@
 			int refundFee, String opUserID){
 		LogUtil.info("#---outTradeNo:{}#---outRefundNo:{}#---totalFee:{}#---refundFee:{}",
 				outTradeNo,outRefundNo,totalFee,refundFee);
-		BusParameterSettings mchID = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.WECHARPAY_APPID, HostInterceptor.getCompanyId());
+		BusParameterSettings mchID = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.WECHARPAY_MCHID, HostInterceptor.getCompanyId());
 		if(opUserID==null){
 			opUserID=mchID.getParamValue();
 		}
@@ -193,7 +222,7 @@
 			JsApiPayBusiness jsApiPayBusiness = new JsApiPayBusiness();
 			Long companyId=HostInterceptor.getCompanyId();
 			BusParameterSettings paySecret = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.WECHARPAY_SECRET, companyId);
-			BusParameterSettings appId = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.WECHARPAY_APPID, companyId);
+			BusParameterSettings appId = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.MINIPROGRAM_APPID, companyId);
 			BusParameterSettings certLocalPath = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.WECHARPAY_CERTLOCAL_PATH, companyId);
 
 			RefundReqData refundReqData=new RefundReqData(mchID.getParamValue(),appId.getParamValue(),paySecret.getParamValue(), outTradeNo, outRefundNo, totalFee, refundFee,opUserID);

--
Gitblit v1.9.1