From 16da0ad1fda1dffa3019425a6887d38ed4217f44 Mon Sep 17 00:00:00 2001
From: wzy <wzy19931122ai@163.com>
Date: Sun, 10 Jan 2021 14:26:02 +0800
Subject: [PATCH] Merge branch 'api' into order_reform
---
zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/weixinUtil/WeixinServiceUtil.java | 62 +++
zq-erp/src/main/resources/templates/views/admin/shop/templateMsg-list.html | 1
zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/common/HttpsRequest2.java | 53 ++-
zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/common/Signature.java | 20
zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxCommonAction.java | 13
zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/protocol/payProtocol/JsApiPayReqData.java | 23
zq-erp/src/main/java/com/matrix/system/shopXcx/mqTask/templateMsg/AppointmentSuccess.java | 2
zq-erp/src/main/resources/config/application.properties | 2
zq-erp/src/main/resources/config/test/application.properties | 9
zq-erp/src/main/java/com/matrix/system/shopXcx/action/ShopRefundRecordAction.java | 8
zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/protocol/payComProtocol/JsApiPayComReqData.java | 6
zq-erp/src/main/java/com/matrix/component/rabbitmq/RabiitMqTemplate.java | 1
zq-erp/src/main/java/com/matrix/system/wechart/templateMsg/Task/TemplateMessageBulder.java | 19 +
zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/service/BaseService.java | 4
zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WxShopRefundRecordServiceImpl.java | 5
zq-erp/src/main/resources/mybatis/mapper/xcxShop/ShopWxtemplateMsgDao.xml | 30 +
zq-erp/src/main/java/com/matrix/system/wechart/templateMsg/MsgDemo3.java | 35 ++
zq-erp/src/main/resources/config/test/system.properties | 2
zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysProjServicesServiceImpl.java | 20 +
zq-erp/src/main/java/com/matrix/system/wechart/templateMsg/TemplateNameConstance.java | 15 +
zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysVipInfoServiceImpl.java | 1
zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WXShopOrderAction.java | 1
zq-erp/src/main/java/com/matrix/system/shopXcx/dao/ShopWxtemplateMsgDao.java | 2
zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/protocol/queryProtocol/ScanPayQueryReqData.java | 6
zq-erp/src/main/java/com/matrix/config/RabbitMqConfig.java | 8
zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/protocol/refundProtocol/RefundReqData.java | 8
/dev/null | 19 -
zq-erp/src/main/java/com/matrix/system/app/action/ApiServiceOrderAction.java | 2
zq-erp/src/main/java/com/matrix/system/shopXcx/bean/ShopWxtemplateMsg.java | 89 +++++-
zq-erp/src/main/java/com/matrix/system/wechart/templateMsg/Task/UniformMsgSentTask.java | 120 ++++++++
zq-erp/src/main/java/com/matrix/core/tools/rr/GlueFactory.java | 23 +
zq-erp/src/main/java/com/matrix/system/wechart/templateMsg/Task/messageBulderDemo/DefaultTemplateMessageBulder.java | 99 +++++++
zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/common/WechatConfigure.java | 19 -
zq-erp/src/main/java/com/matrix/system/common/constance/AppConstance.java | 44 +++
zq-erp/src/main/resources/config/db/increment/20210109.sql | 5
zq-erp/src/main/java/com/matrix/system/shopXcx/mqTask/VipCreateTask.java | 2
zq-erp/src/main/java/com/matrix/system/shopXcx/mqTask/MQTaskRouting.java | 6
zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/protocol/paramProtocol/BrandWCPayRequestData.java | 6
zq-erp/src/main/resources/config/lhx/system.properties | 3
39 files changed, 654 insertions(+), 139 deletions(-)
diff --git a/zq-erp/src/main/java/com/matrix/component/rabbitmq/RabiitMqTemplate.java b/zq-erp/src/main/java/com/matrix/component/rabbitmq/RabiitMqTemplate.java
index 89fea6d..bf51909 100644
--- a/zq-erp/src/main/java/com/matrix/component/rabbitmq/RabiitMqTemplate.java
+++ b/zq-erp/src/main/java/com/matrix/component/rabbitmq/RabiitMqTemplate.java
@@ -84,6 +84,7 @@
if (task != null) {
// 消息内容
if (StringUtils.isNotBlank(content)) {
+ LogUtil.info("本次发送消息task.getExchange()="+task.getExchange()+";routingKey="+routingKey+";content="+content);
channel.basicPublish(task.getExchange(), routingKey, false, null, content.getBytes());
} else {
LogUtil.info("本次发送空消息");
diff --git a/zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/common/HttpsRequest2.java b/zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/common/HttpsRequest2.java
index 12856ec..6f05de1 100644
--- a/zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/common/HttpsRequest2.java
+++ b/zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/common/HttpsRequest2.java
@@ -41,7 +41,7 @@
}
Logger log=Logger.getLogger(HttpRequest.class);
-
+
//表示请求器是否已经做了初始化工作
private boolean hasInit = false;
@@ -56,6 +56,10 @@
//HTTP请求器
private CloseableHttpClient httpClient;
+ //证书地址
+ private String certLocalPath;
+ //商户号
+ private String mchId;
public HttpsRequest2() throws UnrecoverableKeyException, KeyManagementException, NoSuchAlgorithmException, KeyStoreException, IOException {
init();
@@ -63,10 +67,10 @@
private void init() throws IOException, KeyStoreException, UnrecoverableKeyException, NoSuchAlgorithmException, KeyManagementException {
- KeyStore keyStore = KeyStore.getInstance("PKCS12");
- FileInputStream instream = new FileInputStream(new File(WechatConfigure.certLocalPath));//加载本地的证书进行https加密传输
+ KeyStore keyStore = KeyStore.getInstance("PKCS12");
+ FileInputStream instream = new FileInputStream(new File(certLocalPath));//加载本地的证书进行https加密传输
try {
- keyStore.load(instream,WechatConfigure.certPassword.toCharArray());//设置证书密码
+ keyStore.load(instream, mchId.toCharArray());//设置证书密码
} catch (CertificateException e) {
e.printStackTrace();
} catch (NoSuchAlgorithmException e) {
@@ -76,7 +80,7 @@
}
// Trust own CA and all self-signed certs
SSLContext sslcontext = SSLContexts.custom()
- .loadKeyMaterial(keyStore, WechatConfigure.certPassword.toCharArray())
+ .loadKeyMaterial(keyStore, mchId.toCharArray())
.build();
// Allow TLSv1 protocol only
SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(
@@ -85,11 +89,11 @@
null,
SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
-
- httpClient = HttpClients.custom()
+
+ httpClient = HttpClients.custom()
.setSSLSocketFactory(sslsf)
.build();
- // httpClient = HttpClients.custom().build();
+ // httpClient = HttpClients.custom().build();
//根据默认超时限制初始化requestConfig
requestConfig = RequestConfig.custom().setSocketTimeout(socketTimeout).setConnectTimeout(connectTimeout).build();
hasInit = true;
@@ -135,17 +139,17 @@
httpPost.setConfig(requestConfig);
log.info("executing request" + httpPost.getRequestLine());
-
+
try {
HttpResponse response = httpClient.execute(httpPost);
HttpEntity entity = response.getEntity();
result = EntityUtils.toString(entity, "UTF-8");
-
+
log.info("POST back date:" + httpPost.getRequestLine());
-
-
+
+
} catch (ConnectionPoolTimeoutException e) {
// log.e("http get throw ConnectionPoolTimeoutException(wait time out)");
@@ -157,7 +161,7 @@
// log.e("http get throw SocketTimeoutException");
} catch (Exception e) {
- e.printStackTrace();
+ e.printStackTrace();
// log.e("http get throw Exception");
} finally {
@@ -173,7 +177,7 @@
* @param socketTimeout 连接时长,默认10秒
*/
public void setSocketTimeout(int socketTimeout) {
- this.socketTimeout = socketTimeout;
+ this.socketTimeout = socketTimeout;
resetRequestConfig();
}
@@ -183,7 +187,7 @@
* @param connectTimeout 传输时长,默认30秒
*/
public void setConnectTimeout(int connectTimeout) {
- this.connectTimeout = connectTimeout;
+ this.connectTimeout = connectTimeout;
resetRequestConfig();
}
@@ -197,6 +201,23 @@
* @param requestConfig 设置HttpsRequest的请求器配置
*/
public void setRequestConfig(RequestConfig requestConfig) {
- this.requestConfig = requestConfig;
+ this.requestConfig = requestConfig;
+ }
+
+
+ public String getMchId() {
+ return mchId;
+ }
+
+ public void setMchId(String mchId) {
+ this.mchId = mchId;
+ }
+
+ public String getCertLocalPath() {
+ return certLocalPath;
+ }
+
+ public void setCertLocalPath(String certLocalPath) {
+ this.certLocalPath = certLocalPath;
}
}
diff --git a/zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/common/Signature.java b/zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/common/Signature.java
index 40300d5..c764cff 100644
--- a/zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/common/Signature.java
+++ b/zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/common/Signature.java
@@ -22,7 +22,7 @@
* @return 签名
* @throws IllegalAccessException
*/
- public static String getSign(Object o) throws IllegalAccessException {
+ public static String getSign(Object o,String paySecret) throws IllegalAccessException {
ArrayList<String> list = new ArrayList<String>();
Class<? extends Object> cls = o.getClass();
Field[] fields = cls.getDeclaredFields();
@@ -40,14 +40,14 @@
sb.append(arrayToSort[i]);
}
String result = sb.toString();
- result += "key=" + WechatConfigure.key;
+ result += "key=" +paySecret;
Util.log("Sign Before MD5:" + result);
result = MD5.MD5Encode(result).toUpperCase();
Util.log("Sign Result:" + result);
return result;
}
- public static String getSign(Map<String, Object> map) {
+ public static String getSign(Map<String, Object> map,String paySecret) {
ArrayList<String> list = new ArrayList<String>();
for (Map.Entry<String, Object> entry : map.entrySet()) {
if (entry.getValue() != "") {
@@ -62,7 +62,7 @@
sb.append(arrayToSort[i]);
}
String result = sb.toString();
- result += "key=" + WechatConfigure.key;
+ result += "key=" + paySecret;
Util.log("Sign Before MD5:" + result);
result = MD5.MD5Encode(result).toUpperCase();
Util.log("Sign Result:" + result);
@@ -79,13 +79,13 @@
* @throws IOException
* @throws SAXException
*/
- public static String getSignFromResponseString(String responseString)
+ public static String getSignFromResponseString(String responseString,String paySecret)
throws IOException, SAXException, ParserConfigurationException {
Map<String, Object> map = XMLParser.getMapFromXML(responseString);
// 清掉返回数据对象里面的Sign数据(不能把这个数据也加进去进行签名),然后用签名算法进行签名
map.put("sign", "");
// 将API返回的数据根据用签名算法进行计算新的签名,用来跟API返回的签名进行比较
- return Signature.getSign(map);
+ return Signature.getSign(map,paySecret);
}
/**
@@ -98,7 +98,7 @@
* @throws IOException
* @throws SAXException
*/
- public static boolean checkIsSignValidFromResponseString(String responseString)
+ public static boolean checkIsSignValidFromResponseString(String responseString,String paySecret)
throws ParserConfigurationException, IOException, SAXException {
Map<String, Object> map = XMLParser.getMapFromXML(responseString);
@@ -113,7 +113,7 @@
// 清掉返回数据对象里面的Sign数据(不能把这个数据也加进去进行签名),然后用签名算法进行签名
map.put("sign", "");
// 将API返回的数据根据用签名算法进行计算新的签名,用来跟API返回的签名进行比较
- String signForAPIResponse = Signature.getSign(map);
+ String signForAPIResponse = Signature.getSign(map,paySecret);
if (!signForAPIResponse.equals(signFromAPIResponse)) {
// 签名验不过,表示这个API返回的数据有可能已经被篡改了
@@ -124,9 +124,7 @@
return true;
}
- public static void main(String[] args) throws ParserConfigurationException, IOException, SAXException {
- System.out.println(checkIsSignValidFromResponseString("<xml><appid><![CDATA[wx13515a9204ea669d]]></appid><attach><![CDATA[35f7170585ad4f09b5109cc985b1eec0]]></attach><bank_type><![CDATA[CFT]]></bank_type><cash_fee><![CDATA[1]]></cash_fee><fee_type><![CDATA[CNY]]></fee_type><is_subscribe><![CDATA[N]]></is_subscribe><mch_id><![CDATA[1486409192]]></mch_id><nonce_str><![CDATA[elqhnr10vzaq0wgalf9njjyqwyd7gyr7]]></nonce_str><openid><![CDATA[o8x8E5lqmD9c5rdsjTQ9KWN4-H40]]></openid><out_trade_no><![CDATA[2018090610284198419]]></out_trade_no><result_code><![CDATA[SUCCESS]]></result_code><return_code><![CDATA[SUCCESS]]></return_code><sign><![CDATA[DD04172CDAA60F834163AF3F5B63BE3F]]></sign><time_end><![CDATA[20180906102853]]></time_end><total_fee>1</total_fee><trade_type><![CDATA[JSAPI]]></trade_type><transaction_id><![CDATA[4200000169201809067369627940]]></transaction_id></xml>"));
- }
+
/**
*
diff --git a/zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/common/WechatConfigure.java b/zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/common/WechatConfigure.java
index 30d2a22..0a37ebc 100644
--- a/zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/common/WechatConfigure.java
+++ b/zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/common/WechatConfigure.java
@@ -9,7 +9,7 @@
// 这个就是自己要保管好的私有Key了(切记只能放在自己的后台代码里,不能放在任何可能被看到源代码的客户端程序中)
// 每次自己Post数据给API的时候都要用这个key来对所有字段进行签名,生成的签名会放在Sign这个字段,API收到Post数据的时候也会用同样的签名算法对Post过来的数据进行签名和验证
// 收到API的返回的时候也要用这个key来对返回的数据算下签名,跟API的Sign数据进行比较,如果值不一致,有可能数据被第三方给篡改
- public static final String PAY_NOTIFY_URL="https://xcxhive2.jyymatrix.cc/wxCommon/wxpayCallback";
+
// 交易类型
public static final String TRADE_TYPE_JSAPI = "JSAPI";
public static final String TRADE_TYPE_NATIVE = "NATIVE";
@@ -17,28 +17,15 @@
public static final String SIGN_MD5 = "MD5";
//域名
-
- // 微信支付秘钥
- public static String key = "3hbNHPOSXx85rC0QEqvGgIHu1wduT4Qc";
-
- // 微信分配的公众号ID(开通公众号之后可以获取到)
- public static String appID = "wx3836ab3c1490ff29";
-
-
- // 微信支付分配的商户号ID(开通公众号的微信支付功能之后可以获取到)
- public static String mchID = "1573208361";
-
-
- public static String web_appID = "1486409192";
+
// 受理模式下给子商户分配的子商户号
public static String subMchID = "";
// HTTPS证书的本地路径
public static String certLocalPath = "/home/cert/apiclient_cert.p12";
- // HTTPS证书密码,默认密码等于商户号MCHID
- public static String certPassword = "1573208361";
+
// 是否使用异步线程的方式来上报API测速,默认为异步模式
public static boolean useThreadToDoReport = true;
diff --git a/zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/protocol/paramProtocol/BrandWCPayRequestData.java b/zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/protocol/paramProtocol/BrandWCPayRequestData.java
index c367bf3..b0c8126 100644
--- a/zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/protocol/paramProtocol/BrandWCPayRequestData.java
+++ b/zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/protocol/paramProtocol/BrandWCPayRequestData.java
@@ -25,16 +25,16 @@
private String signType = "";
private String paySign = "";
- public BrandWCPayRequestData(String prepay_id){
+ public BrandWCPayRequestData(String prepay_id,String appID,String paySecret){
//默认必须设置
- setAppId(WechatConfigure.appID);
+ setAppId(appID);
//随机字符串,不长于32 位
setNonceStr(RandomStringGenerator.getRandomStringByLength(32));
setTimeStamp(Long.toString(System.currentTimeMillis() / 1000L));
setPrepay_id("prepay_id="+prepay_id);
//根据API给的签名规则进行签名 【 必须要放在本方法的最后】
setSignType(WechatConfigure.SIGN_MD5);
- String sign = Signature.getSign(toMap());
+ String sign = Signature.getSign(toMap(),paySecret);
setPaySign(sign);//把签名数据设置到Sign这个属性中
}
diff --git a/zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/protocol/payComProtocol/JsApiPayComReqData.java b/zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/protocol/payComProtocol/JsApiPayComReqData.java
index 7313595..d38b928 100644
--- a/zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/protocol/payComProtocol/JsApiPayComReqData.java
+++ b/zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/protocol/payComProtocol/JsApiPayComReqData.java
@@ -70,16 +70,16 @@
* @param bankTrueName 收款号姓名
* @param bankCode 收款号开户行
*/
- public JsApiPayComReqData(String desc, String outTradeNo, int totalFee, String bankNo, String bankTrueName, String bankCode) {
+ public JsApiPayComReqData(String mchID,String paySecret ,String desc, String outTradeNo, int totalFee, String bankNo, String bankTrueName, String bankCode) {
//默认必须设置
- setMch_id(WechatConfigure.mchID);
+ setMch_id(mchID);
setDesc(desc);
setPartner_trade_no(outTradeNo);
setAmount(totalFee);
//随机字符串,不长于32 位
setNonce_str(RandomStringGenerator.getRandomStringByLength(32));
//根据API给的签名规则进行签名 【 必须要放在本方法的最后】
- String sign = Signature.getSign(toMap());
+ String sign = Signature.getSign(toMap(),paySecret);
setSign(sign);//把签名数据设置到Sign这个属性中
// setEnc_bank_no();
// setEnc_true_name();
diff --git a/zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/protocol/payProtocol/JsApiPayReqData.java b/zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/protocol/payProtocol/JsApiPayReqData.java
index 2dc5f1e..819f58a 100644
--- a/zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/protocol/payProtocol/JsApiPayReqData.java
+++ b/zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/protocol/payProtocol/JsApiPayReqData.java
@@ -32,8 +32,8 @@
/**
* 接收微信支付异步通知回调地址
*/
- private String notify_url = WechatConfigure.PAY_NOTIFY_URL;
private String trade_type = WechatConfigure.TRADE_TYPE_JSAPI;
+ private String notify_url ;
private String openid = "";
private String limit_pay = "";
private String spbill_create_ip = "";
@@ -47,7 +47,8 @@
public JsApiPayReqData() {
}
- /**
+ /**appID 收款应用id
+ * mchID 商户号
* @param authCode 这个是扫码终端设备从用户手机上扫取到的支付授权号,这个号是跟用户用来支付的银行卡绑定的,有效期是1分钟
* @param body 要支付的商品的描述信息,用户会在支付成功页面里看到这个信息
* @param attach 支付订单里面可以填的附加数据,API会将提交的这个附加数据原样返回
@@ -59,10 +60,11 @@
* @param timeExpire 订单失效时间,格式同上
* @param goodsTag 商品标记,微信平台配置的商品标记,用于优惠券或者满减使用
*/
- public JsApiPayReqData(String body,String outTradeNo,int totalFee,String spBillCreateIP,String openid,String attach){
+ public JsApiPayReqData(String appID, String mchID,String paySecret,String notify_url, String body,String outTradeNo,int totalFee,String spBillCreateIP,String openid,String attach){
//默认必须设置
- setAppid(WechatConfigure.appID);
- setMch_id(WechatConfigure.mchID);
+ setAppid(appID);
+ setMch_id(mchID);
+ setNotify_url(notify_url);
setBody(body);
setOut_trade_no(outTradeNo);
setTotal_fee(totalFee);
@@ -72,16 +74,17 @@
setNonce_str(RandomStringGenerator.getRandomStringByLength(32));
setOpenid(openid);
//根据API给的签名规则进行签名 【 必须要放在本方法的最后】
- String sign = Signature.getSign(toMap());
+ String sign = Signature.getSign(toMap(),paySecret);
setSign(sign);//把签名数据设置到Sign这个属性中
}
- public JsApiPayReqData(String body,String outTradeNo,int totalFee,String spBillCreateIP,String attach){
+ public JsApiPayReqData(String appID, String mchID,String paySecret,String notify_url,String body,String outTradeNo,int totalFee,String spBillCreateIP,String attach){
//默认必须设置
- setAppid(WechatConfigure.web_appID);
- setMch_id(WechatConfigure.mchID);
+ setAppid(appID);
+ setMch_id(mchID);
setBody(body);
+ setNotify_url(notify_url);
setOut_trade_no(outTradeNo);
setTotal_fee(totalFee);
setSpbill_create_ip(spBillCreateIP);
@@ -89,7 +92,7 @@
//随机字符串,不长于32 位
setNonce_str(RandomStringGenerator.getRandomStringByLength(32));
//根据API给的签名规则进行签名 【 必须要放在本方法的最后】
- String sign = Signature.getSign(toMap());
+ String sign = Signature.getSign(toMap(),paySecret);
setSign(sign);//把签名数据设置到Sign这个属性中
}
diff --git a/zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/protocol/queryProtocol/JsApiPayReqData.java b/zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/protocol/queryProtocol/JsApiPayReqData.java
deleted file mode 100644
index 8784f20..0000000
--- a/zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/protocol/queryProtocol/JsApiPayReqData.java
+++ /dev/null
@@ -1,295 +0,0 @@
-package com.matrix.component.wechat.externalInterface.protocol.queryProtocol;
-
-
-import com.matrix.component.wechat.externalInterface.common.RandomStringGenerator;
-import com.matrix.component.wechat.externalInterface.common.Signature;
-import com.matrix.component.wechat.externalInterface.common.WechatConfigure;
-
-import java.lang.reflect.Field;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- *
-* 预付订单请求参数
-* @author:姜友瑶
-* @date 2016年10月14日
- */
-public class JsApiPayReqData {
-
- //每个字段具体的意思请查看API文档
- private String appid = "";
- private String mch_id = "";
- private String device_info = "";
- private String nonce_str = "";
- private String sign = "";
- private String body = "";
- private String detail = "";
- private String attach = "";
- private String out_trade_no = "";
- private String fee_type = "";
- private int total_fee = 0;
- /**
- * 接收微信支付异步通知回调地址
- */
- private String notify_url = WechatConfigure.PAY_NOTIFY_URL;
- private String trade_type = WechatConfigure.TRADE_TYPE_JSAPI;
- private String openid = "";
- private String limit_pay = "";
- private String spbill_create_ip = "";
- private String product_id = "";
- private String time_start = "";
- private String time_expire = "";
- private String goods_tag = "";
- private String auth_code = "";
-
-
- public JsApiPayReqData() {
- }
-
- /**
- * @param authCode 这个是扫码终端设备从用户手机上扫取到的支付授权号,这个号是跟用户用来支付的银行卡绑定的,有效期是1分钟
- * @param body 要支付的商品的描述信息,用户会在支付成功页面里看到这个信息
- * @param attach 支付订单里面可以填的附加数据,API会将提交的这个附加数据原样返回
- * @param outTradeNo 商户系统内部的订单号,32个字符内可包含字母, 确保在商户系统唯一
- * @param totalFee 订单总金额,单位为“分”,只能整数
- * @param deviceInfo 商户自己定义的扫码支付终端设备号,方便追溯这笔交易发生在哪台终端设备上
- * @param spBillCreateIP 订单生成的机器IP
- * @param timeStart 订单生成时间, 格式为yyyyMMddHHmmss,如2009年12 月25 日9 点10 分10 秒表示为20091225091010。时区为GMT+8 beijing。该时间取自商户服务器
- * @param timeExpire 订单失效时间,格式同上
- * @param goodsTag 商品标记,微信平台配置的商品标记,用于优惠券或者满减使用
- */
- public JsApiPayReqData(String body,String outTradeNo,int totalFee,String spBillCreateIP,String openid,String attach){
- //默认必须设置
- setAppid(WechatConfigure.appID);
- setMch_id(WechatConfigure.mchID);
- setBody(body);
- setOut_trade_no(outTradeNo);
- setTotal_fee(totalFee);
- setSpbill_create_ip(spBillCreateIP);
- setAttach(attach);
- //随机字符串,不长于32 位
- setNonce_str(RandomStringGenerator.getRandomStringByLength(32));
- setOpenid(openid);
- //根据API给的签名规则进行签名 【 必须要放在本方法的最后】
- String sign = Signature.getSign(toMap());
- setSign(sign);//把签名数据设置到Sign这个属性中
-
- }
-
- public JsApiPayReqData(String body,String outTradeNo,int totalFee,String spBillCreateIP,String attach){
- //默认必须设置
- setAppid(WechatConfigure.web_appID);
- setMch_id(WechatConfigure.mchID);
- setBody(body);
- setOut_trade_no(outTradeNo);
- setTotal_fee(totalFee);
- setSpbill_create_ip(spBillCreateIP);
- setAttach(attach);
- //随机字符串,不长于32 位
- setNonce_str(RandomStringGenerator.getRandomStringByLength(32));
- //根据API给的签名规则进行签名 【 必须要放在本方法的最后】
- String sign = Signature.getSign(toMap());
- setSign(sign);//把签名数据设置到Sign这个属性中
- }
-
- public String getDetail() {
- return detail;
- }
-
- public void setDetail(String detail) {
- this.detail = detail;
- }
-
- public String getFee_type() {
- return fee_type;
- }
-
- public void setFee_type(String fee_type) {
- this.fee_type = fee_type;
- }
-
- public String getNotify_url() {
- return notify_url;
- }
-
- public void setNotify_url(String notify_url) {
- this.notify_url = notify_url;
- }
-
- public String getTrade_type() {
- return trade_type;
- }
-
- public void setTrade_type(String trade_type) {
- this.trade_type = trade_type;
- }
-
- public String getOpenid() {
- return openid;
- }
-
- public void setOpenid(String openid) {
- this.openid = openid;
- }
-
- public String getLimit_pay() {
- return limit_pay;
- }
-
- public void setLimit_pay(String limit_pay) {
- this.limit_pay = limit_pay;
- }
-
- public String getProduct_id() {
- return product_id;
- }
-
- public void setProduct_id(String product_id) {
- this.product_id = product_id;
- }
-
- public String getAppid() {
- return appid;
- }
-
- public void setAppid(String appid) {
- this.appid = appid;
- }
-
- public String getMch_id() {
- return mch_id;
- }
-
- public void setMch_id(String mch_id) {
- this.mch_id = mch_id;
- }
-
- public String getDevice_info() {
- return device_info;
- }
-
- public void setDevice_info(String device_info) {
- this.device_info = device_info;
- }
-
- public String getNonce_str() {
- return nonce_str;
- }
-
- public void setNonce_str(String nonce_str) {
- this.nonce_str = nonce_str;
- }
-
- public String getSign() {
- return sign;
- }
-
- public void setSign(String sign) {
- this.sign = sign;
- }
-
- public String getBody() {
- return body;
- }
-
- /**
- *
- * body最大长度128
- * @author:姜友瑶
- * @param body
- * 返回类型 void
- * @date 2016年10月13日
- */
- public void setBody(String body) {
-
- if(body.length()>128){
- body=body.substring(0, 128);
- }
- this.body = body;
- }
-
- public String getAttach() {
- return attach;
- }
-
- public void setAttach(String attach) {
- this.attach = attach;
- }
-
- public String getOut_trade_no() {
- return out_trade_no;
- }
-
- public void setOut_trade_no(String out_trade_no) {
- this.out_trade_no = out_trade_no;
- }
-
- public int getTotal_fee() {
- return total_fee;
- }
-
- public void setTotal_fee(int total_fee) {
- this.total_fee = total_fee;
- }
-
- public String getSpbill_create_ip() {
- return spbill_create_ip;
- }
-
- public void setSpbill_create_ip(String spbill_create_ip) {
- this.spbill_create_ip = spbill_create_ip;
- }
-
- public String getTime_start() {
- return time_start;
- }
-
- public void setTime_start(String time_start) {
- this.time_start = time_start;
- }
-
- public String getTime_expire() {
- return time_expire;
- }
-
- public void setTime_expire(String time_expire) {
- this.time_expire = time_expire;
- }
-
- public String getGoods_tag() {
- return goods_tag;
- }
-
- public void setGoods_tag(String goods_tag) {
- this.goods_tag = goods_tag;
- }
-
- public String getAuth_code() {
- return auth_code;
- }
-
- public void setAuth_code(String auth_code) {
- this.auth_code = auth_code;
- }
-
- public Map<String,Object> toMap(){
- Map<String,Object> map = new HashMap<String, Object>();
- Field[] fields = this.getClass().getDeclaredFields();
- for (Field field : fields) {
- Object obj;
- try {
- obj = field.get(this);
- if(obj!=null){
- map.put(field.getName(), obj);
- }
- } catch (IllegalArgumentException e) {
- e.printStackTrace();
- } catch (IllegalAccessException e) {
- e.printStackTrace();
- }
- }
- return map;
- }
-
-}
diff --git a/zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/protocol/queryProtocol/ScanPayQueryReqData.java b/zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/protocol/queryProtocol/ScanPayQueryReqData.java
index 42cc0c9..37855ba 100644
--- a/zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/protocol/queryProtocol/ScanPayQueryReqData.java
+++ b/zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/protocol/queryProtocol/ScanPayQueryReqData.java
@@ -37,10 +37,10 @@
//--------------------------------------------------------------------
//微信分配的公众号ID(开通公众号之后可以获取到)
- setAppid(WechatConfigure.appID);
+ //setAppid(WechatConfigure.appID);
//微信支付分配的商户号ID(开通公众号的微信支付功能之后可以获取到)
- setMch_id(WechatConfigure.mchID);
+ // setMch_id(WechatConfigure.mchID);
//transaction_id是微信系统为每一笔支付交易分配的订单号,通过这个订单号可以标识这笔交易,它由支付订单API支付成功时返回的数据里面获取到。
setTransaction_id(transactionID);
@@ -52,7 +52,7 @@
setNonce_str(RandomStringGenerator.getRandomStringByLength(32));
//根据API给的签名规则进行签名
- String sign = Signature.getSign(toMap());
+ //String sign = Signature.getSign(toMap());
setSign(sign);//把签名数据设置到Sign这个属性中
diff --git a/zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/protocol/refundProtocol/RefundReqData.java b/zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/protocol/refundProtocol/RefundReqData.java
index 6aa739c..adff5d8 100644
--- a/zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/protocol/refundProtocol/RefundReqData.java
+++ b/zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/protocol/refundProtocol/RefundReqData.java
@@ -40,13 +40,13 @@
* @param opUserID 操作员帐号, 默认为商户号
* @param refundFeeType 货币类型,符合ISO 4217标准的三位字母代码,默认为CNY(人民币)
*/
- public RefundReqData(String outTradeNo,String outRefundNo,int totalFee,int refundFee,String opUserID){
+ public RefundReqData(String mchID,String appID,String paySecret ,String outTradeNo,String outRefundNo,int totalFee,int refundFee,String opUserID){
//微信分配的公众号ID(开通公众号之后可以获取到)
- setAppid(WechatConfigure.appID);
+ setAppid(mchID);
//微信支付分配的商户号ID(开通公众号的微信支付功能之后可以获取到)
- setMch_id(WechatConfigure.mchID);
+ setMch_id(appID);
//transaction_id是微信系统为每一笔支付交易分配的订单号,通过这个订单号可以标识这笔交易,它由支付订单API支付成功时返回的数据里面获取到。
//setTransaction_id(transactionID);
@@ -69,7 +69,7 @@
setNonce_str(RandomStringGenerator.getRandomStringByLength(32));
//根据API给的签名规则进行签名
- String sign = Signature.getSign(toMap());
+ String sign = Signature.getSign(toMap(),paySecret);
setSign(sign);//把签名数据设置到Sign这个属性中
}
diff --git a/zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/protocol/rsaProtocal/JsApiRSAReqData.java b/zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/protocol/rsaProtocal/JsApiRSAReqData.java
deleted file mode 100644
index e694b90..0000000
--- a/zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/protocol/rsaProtocal/JsApiRSAReqData.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package com.matrix.component.wechat.externalInterface.protocol.rsaProtocal;
-
-
-import com.matrix.component.wechat.externalInterface.common.RandomStringGenerator;
-import com.matrix.component.wechat.externalInterface.common.Signature;
-import com.matrix.component.wechat.externalInterface.common.WechatConfigure;
-
-import java.lang.reflect.Field;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * 公钥请求类
- *
- * @author wzy
- */
-public class JsApiRSAReqData {
-
- private String mch_id;
- private String nonce_str;
- private String sign;
- private String sign_type;
-
-
- public JsApiRSAReqData() {
- this.mch_id = WechatConfigure.mchID;
- this.nonce_str = RandomStringGenerator.getRandomStringByLength(32);
- this.sign = Signature.getSign(toMap());
- this.sign_type = "MD5";
- }
-
- public Map<String, Object> toMap() {
- Map<String, Object> map = new HashMap<String, Object>();
- Field[] fields = this.getClass().getDeclaredFields();
- for (Field field : fields) {
- Object obj;
- try {
- obj = field.get(this);
- if (obj != null) {
- map.put(field.getName(), obj);
- }
- } catch (IllegalArgumentException e) {
- e.printStackTrace();
- } catch (IllegalAccessException e) {
- e.printStackTrace();
- }
- }
- return map;
- }
-}
diff --git a/zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/service/BaseService.java b/zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/service/BaseService.java
index 1b9620d..8f9a680 100644
--- a/zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/service/BaseService.java
+++ b/zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/service/BaseService.java
@@ -38,4 +38,8 @@
public void setServiceRequest(IServiceRequest request){
serviceRequest = request;
}
+
+ public IServiceRequest getServiceRequest() {
+ return serviceRequest;
+ }
}
diff --git a/zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/service/JsApiGetPublicKeyService.java b/zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/service/JsApiGetPublicKeyService.java
deleted file mode 100644
index 173f31f..0000000
--- a/zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/service/JsApiGetPublicKeyService.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package com.matrix.component.wechat.externalInterface.service;
-
-import com.matrix.component.wechat.externalInterface.common.WechatConfigure;
-import com.matrix.component.wechat.externalInterface.protocol.payComProtocol.JsApiPayComReqData;
-import com.matrix.component.wechat.externalInterface.protocol.rsaProtocal.JsApiRSAReqData;
-
-public class JsApiGetPublicKeyService extends BaseService {
-
- public JsApiGetPublicKeyService() throws ClassNotFoundException, IllegalAccessException, InstantiationException {
- super(WechatConfigure.PUBLIC_KEY_GET_API, WechatConfigure.HttpsRequestClassName2);
- }
-
- public String request(JsApiRSAReqData jsApiRSAReqData) throws Exception {
-
- String responseString = sendPost(jsApiRSAReqData);
-
- return responseString;
- }
-}
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 771333f..7a00022 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
@@ -1,5 +1,6 @@
package com.matrix.component.wechat.externalInterface.weixinUtil;
+import com.matrix.component.wechat.externalInterface.common.HttpsRequest2;
import com.matrix.core.exception.GlobleException;
import com.matrix.core.tools.LogUtil;
import com.matrix.core.tools.StringUtils;
@@ -18,7 +19,10 @@
import com.matrix.component.wechat.externalInterface.service.JsApiPayComService;
import com.matrix.component.wechat.externalInterface.service.RefundService;
import com.matrix.component.wechat.externalInterface.service.ScanPayQueryService;
+import com.matrix.system.common.bean.BusParameterSettings;
import com.matrix.system.common.constance.AppConstance;
+import com.matrix.system.common.dao.BusParameterSettingsDao;
+import com.matrix.system.common.interceptor.HostInterceptor;
import com.matrix.system.shopXcx.api.tools.WxShopOrderUtil;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
@@ -43,6 +47,13 @@
@Autowired
private WxShopOrderUtil wxShopOrderUtil;
+
+ @Autowired
+ BusParameterSettingsDao busParameterSettingsDao;
+
+
+
+
/**
* 支付"175.9.82.254"
@@ -62,7 +73,20 @@
// 创建微信支付预付接口
JsApiPayBusiness jsApiPayBusiness = new JsApiPayBusiness();
String idAddr = getIpAddr(WebUtil.getRequest());
- JsApiPayReqData jsApiPayReqData = new JsApiPayReqData(desc, outTradeNo, price, idAddr, openId, attach);
+
+ Long companyId=HostInterceptor.getCompanyId();
+
+ BusParameterSettings mchID = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.WECHARPAY_APPID, 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);
+
+ JsApiPayReqData jsApiPayReqData = new JsApiPayReqData(appId.getParamValue(),mchID.getParamValue(),
+ paySecret.getParamValue(),
+ notifyUrl.getParamValue(),
+ desc, outTradeNo, price, idAddr, openId, attach);
+
// 创建预付订单并返回请求结果
JsApiPayResData result = jsApiPayBusiness.createPrapareOrder(jsApiPayReqData);
// 把预付订单的信息存放在request域中
@@ -71,7 +95,7 @@
LogUtil.info("#---签名信息:return_msg = {}" , result.getReturn_msg());
if (result.getReturn_code().equals("SUCCESS")) {
// 请求成功, 构建BrandWCPayRequest发起支付需要的参数
- BrandWCPayRequestData payData = new BrandWCPayRequestData(result.getPrepay_id());
+ BrandWCPayRequestData payData = new BrandWCPayRequestData(result.getPrepay_id(),appId.getParamValue(),paySecret.getParamValue());
WebUtil.getRequest().setAttribute("payData", payData);
return payData;
}else{
@@ -115,7 +139,6 @@
* @param desc 描述
* @param outTradeNo 提现申请编号
* @param totalFee 提现金额(分)
- * @param spBillCreateIP 调用接口的IP
* @param openid
* @return
*/
@@ -125,7 +148,12 @@
try {
JsApiPayBusiness jsApiPayBusiness = new JsApiPayBusiness();
// TODO 企业付款
- JsApiPayComReqData jsApiPayComReqData=new JsApiPayComReqData("","",0,"","","");
+ Long companyId=HostInterceptor.getCompanyId();
+ BusParameterSettings mchID = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.WECHARPAY_APPID, companyId);
+ BusParameterSettings paySecret = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.WECHARPAY_SECRET, companyId);
+
+
+ JsApiPayComReqData jsApiPayComReqData=new JsApiPayComReqData(mchID.getParamValue(),paySecret.getParamValue(),"","",0,"","","");
JsApiPayComService jsApiPayComService=new JsApiPayComService();
result = jsApiPayBusiness.payComOrder(jsApiPayComService, jsApiPayComReqData);
LogUtil.info("#提现,企业付款到个人---result:{}",result);
@@ -155,15 +183,25 @@
int refundFee, String opUserID){
LogUtil.info("#---outTradeNo:{}#---outRefundNo:{}#---totalFee:{}#---refundFee:{}",
outTradeNo,outRefundNo,totalFee,refundFee);
+ BusParameterSettings mchID = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.WECHARPAY_APPID, HostInterceptor.getCompanyId());
if(opUserID==null){
- opUserID=WechatConfigure.mchID;
+ opUserID=mchID.getParamValue();
}
RefundResData result=null;
boolean flag=false;
try {
JsApiPayBusiness jsApiPayBusiness = new JsApiPayBusiness();
- RefundReqData refundReqData=new RefundReqData(outTradeNo, outRefundNo, totalFee, refundFee,opUserID);
+ Long companyId=HostInterceptor.getCompanyId();
+ BusParameterSettings paySecret = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.WECHARPAY_SECRET, companyId);
+ BusParameterSettings appId = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.WECHARPAY_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);
RefundService refundService=new RefundService();
+ HttpsRequest2 request2= (HttpsRequest2) refundService.getServiceRequest();
+ request2.setCertLocalPath(certLocalPath.getParamValue());
+ request2.setMchId(mchID.getParamValue());
+
result = jsApiPayBusiness.refundComOrder(refundService, refundReqData);
LogUtil.info("#退款,企业付款到个人---result:{}",result);
//如果返回余额不足时
@@ -191,12 +229,12 @@
* @return
*/
public String getIpAddr(HttpServletRequest request) {
- String ip = request.getHeader("x-forwarded-for");
- /* if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
- ip = request.getHeader("Proxy-Client-IP");
- }
- if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
- ip = request.getHeader("WL-Proxy-Client-IP");
+ String ip = request.getHeader("x-forwarded-for");
+ /* if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
+ ip = request.getHeader("Proxy-Client-IP");
+ }
+ if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
+ ip = request.getHeader("WL-Proxy-Client-IP");
} */
if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getRemoteAddr();
diff --git a/zq-erp/src/main/java/com/matrix/config/RabbitMqConfig.java b/zq-erp/src/main/java/com/matrix/config/RabbitMqConfig.java
index 6ff44d6..2effc80 100644
--- a/zq-erp/src/main/java/com/matrix/config/RabbitMqConfig.java
+++ b/zq-erp/src/main/java/com/matrix/config/RabbitMqConfig.java
@@ -5,6 +5,7 @@
import com.matrix.component.rabbitmq.RabiitMqTemplate;
import com.matrix.component.rabbitmq.RabiitMqTemplateFactory;
import com.matrix.system.shopXcx.mqTask.*;
+import com.matrix.system.wechart.templateMsg.Task.UniformMsgSentTask;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -48,6 +49,11 @@
return new TemplateMsgTask();
}
+ @Bean
+ UniformMsgSentTask UniformMsgSentTask(){
+ return new UniformMsgSentTask();
+ }
+
@Bean
OrderOutSotoreTask OrderOutSotoreTask(){
return new OrderOutSotoreTask();
@@ -67,10 +73,10 @@
//注册RabbitMq任务
taskList.add(new MqTask(MQ_EXCHANGE_A + evn, MQTaskRouting.CREATE_VIP + evn, MQTaskRouting.CREATE_VIP + evn, VipCreateTask()));
- taskList.add(new MqTask(MQ_EXCHANGE_A + "cf", MQTaskRouting.CREATE_VIP + evn, MQTaskRouting.CREATE_VIP + evn, null));
taskList.add(new MqTask(MQ_EXCHANGE_A + evn, MQTaskRouting.CREATE_ORDER + evn,MQTaskRouting.CREATE_ORDER + evn,OrderrCreateTask()));
taskList.add(new MqTask(MQ_EXCHANGE_A + evn, MQTaskRouting.SEND_TEMPLATE_MSG + evn,MQTaskRouting.SEND_TEMPLATE_MSG + evn, TemplateMsgTask()));
taskList.add(new MqTask(MQ_EXCHANGE_A + evn, MQTaskRouting.ORDER_OUT_SOTORE + evn,MQTaskRouting.ORDER_OUT_SOTORE + evn, OrderOutSotoreTask()));
+ taskList.add(new MqTask(MQ_EXCHANGE_A + evn, MQTaskRouting.SEND_UNIFORM_TEMPLATE_MSG + evn,MQTaskRouting.SEND_UNIFORM_TEMPLATE_MSG + evn, UniformMsgSentTask()));
rabiitMqTemplate.binding(taskList);
diff --git a/zq-erp/src/main/java/com/matrix/core/tools/rr/GlueFactory.java b/zq-erp/src/main/java/com/matrix/core/tools/rr/GlueFactory.java
index 5f0f32f..d46fe06 100644
--- a/zq-erp/src/main/java/com/matrix/core/tools/rr/GlueFactory.java
+++ b/zq-erp/src/main/java/com/matrix/core/tools/rr/GlueFactory.java
@@ -104,4 +104,27 @@
throw new IllegalArgumentException(">>>>>>>>>>> xxl-glue, loadNewInstance error, instance is null");
}
+
+ /**
+ * 根据字符串获取几个java实例
+ * @param codeSource
+ * @return
+ * @throws Exception
+ */
+ public Object loadInstance(String codeSource) throws Exception{
+ if (codeSource!=null && codeSource.trim().length()>0) {
+ Class<?> clazz = groovyClassLoader.parseClass(codeSource);
+ if (clazz != null) {
+ Object instance = clazz.newInstance();
+ if (instance!=null) {
+ this.injectService(instance);
+ return instance;
+ }
+ }
+ }
+ throw new IllegalArgumentException(">>>>>>>>>>> xxl-glue, loadNewInstance error, instance is null");
+ }
+
+
+
}
diff --git a/zq-erp/src/main/java/com/matrix/system/app/action/ApiServiceOrderAction.java b/zq-erp/src/main/java/com/matrix/system/app/action/ApiServiceOrderAction.java
index e0c59eb..59424ef 100644
--- a/zq-erp/src/main/java/com/matrix/system/app/action/ApiServiceOrderAction.java
+++ b/zq-erp/src/main/java/com/matrix/system/app/action/ApiServiceOrderAction.java
@@ -142,7 +142,7 @@
}
if (!vipInfo.getPassWord().equals(serviceOrderDto.getPassword())) {
- return AjaxResult.buildSuccessInstance("资金密码错误");
+ return AjaxResult.buildFailInstance("资金密码错误");
}
SysProjServices sysProjServices = new SysProjServices();
diff --git a/zq-erp/src/main/java/com/matrix/system/common/constance/AppConstance.java b/zq-erp/src/main/java/com/matrix/system/common/constance/AppConstance.java
index b971f6b..56216fc 100644
--- a/zq-erp/src/main/java/com/matrix/system/common/constance/AppConstance.java
+++ b/zq-erp/src/main/java/com/matrix/system/common/constance/AppConstance.java
@@ -589,4 +589,48 @@
public static final String QSFY = "QSFY";
+ /**
+ * 小程序APPID
+ */
+ public static final String MINIPROGRAM_APPID = "miniprogramAppid";
+ /**
+ * 小程序Secret
+ */
+ public static final String MINIPROGRAM_SECRET = "miniprogramSecret";
+ /**
+ * 公众号APPID
+ */
+ public static final String GZH_APPID = "gzhAppId";
+
+ /**
+ * 微信商户号
+ */
+ public static final String WECHARPAY_APPID = "wecharPayAppid";
+ /**
+ * 支付秘钥
+ */
+ public static final String WECHARPAY_SECRET = "wecharPaySecret";
+
+ /**
+ * 支付通知地址
+ */
+ public static final String WECHARPAY_NOTIFYURL = "wecharPaynotifyUrl";
+ /**
+ * 支付证书地址
+ */
+ public static final String WECHARPAY_CERTLOCAL_PATH = "certLocalPath";
+
+
+
+
+
+
+
+
+
+
+
+
+
+
}
diff --git a/zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysProjServicesServiceImpl.java b/zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysProjServicesServiceImpl.java
index 9749835..cfb58f7 100644
--- a/zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysProjServicesServiceImpl.java
+++ b/zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysProjServicesServiceImpl.java
@@ -1,5 +1,7 @@
package com.matrix.system.hive.service.imp;
+import com.alibaba.fastjson.JSONObject;
+import com.matrix.component.rabbitmq.RabiitMqTemplate;
import com.matrix.core.constance.MatrixConstance;
import com.matrix.core.exception.GlobleException;
import com.matrix.core.pojo.PaginationVO;
@@ -16,9 +18,11 @@
import com.matrix.system.hive.plugin.util.MoneyUtil;
import com.matrix.system.hive.pojo.MyBeauticianCount;
import com.matrix.system.hive.service.*;
+import com.matrix.system.shopXcx.mqTask.MQTaskRouting;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -97,6 +101,13 @@
WarehouseDao warehouseDao;
@Resource
private ShoppingGoodsService shoppingGoodsService;
+
+ @Autowired
+ private RabiitMqTemplate rabiitMqTemplate;
+
+ @Value("${evn}")
+ private String evn;
+
/**
* 新增服务单 jyy
@@ -561,10 +572,15 @@
if (!projServices.getState().equals(Dictionary.SERVICE_STATU_FWWC)) {
throw new GlobleException("该服务单状态为" + projServices.getState() + ",不可以进行当前操作!");
} else {
-
projServices.setState(Dictionary.SERVICE_STATU_FFJS);
projServices.setConsumeTime(new Date());
- return sysProjServicesDao.update(projServices);
+ int result=sysProjServicesDao.update(projServices);
+ //发送微信公众号提醒
+ JSONObject param=new JSONObject();
+ param.put("companyId",projServices.getCompanyId());
+ param.put("serviceId",projServices.getId());
+ rabiitMqTemplate.sendMsg(MQTaskRouting.SEND_UNIFORM_TEMPLATE_MSG+evn,param.toJSONString());
+ return result;
}
}
diff --git a/zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysVipInfoServiceImpl.java b/zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysVipInfoServiceImpl.java
index b9db73c..75f839a 100644
--- a/zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysVipInfoServiceImpl.java
+++ b/zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysVipInfoServiceImpl.java
@@ -575,6 +575,7 @@
vipInfoDetailVo.setBirthday(sysVipInfo.getBirthday1());
vipInfoDetailVo.setPassword(sysVipInfo.getPassWord());
vipInfoDetailVo.setPhoto(sysVipInfo.getPhoto());
+ vipInfoDetailVo.setVipNo(sysVipInfo.getVipNo());
List<SysVipLabel> labels = sysVipLabelDao.selectByVipId(sysVipInfo.getId());
vipInfoDetailVo.setLabels(labels);
diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/action/ShopRefundRecordAction.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/action/ShopRefundRecordAction.java
index 4b25528..c790239 100644
--- a/zq-erp/src/main/java/com/matrix/system/shopXcx/action/ShopRefundRecordAction.java
+++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/action/ShopRefundRecordAction.java
@@ -464,16 +464,14 @@
int reMoney = b1.multiply(bb).intValue();
LogUtil.info("退款退款金额{}", reMoney);
- //Double refundMoney = 0.1 * 100;
- //用户ID
- String userId = WechatConfigure.mchID;
+
if (isDebug) {
- boolean b = weixinServiceUtil.comRefund(orderNo, refundNo, 1, 1, userId);
+ boolean b = weixinServiceUtil.comRefund(orderNo, refundNo, 1, 1, null);
flag = b;
} else {
LogUtil.info("开始调用退款接口。。。退款编号为{}", refundNo);
- boolean b = weixinServiceUtil.comRefund(orderNo, refundNo, orMoney, reMoney, userId);
+ boolean b = weixinServiceUtil.comRefund(orderNo, refundNo, orMoney, reMoney, null);
flag = b;
}
diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WXShopOrderAction.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WXShopOrderAction.java
index d940ea1..54ca9f5 100644
--- a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WXShopOrderAction.java
+++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WXShopOrderAction.java
@@ -10,6 +10,7 @@
import com.matrix.core.pojo.AjaxResult;
import com.matrix.core.tools.StringUtils;
import com.matrix.system.common.constance.AppConstance;
+import com.matrix.system.common.interceptor.HostInterceptor;
import com.matrix.system.constance.Dictionary;
import com.matrix.system.hive.bean.ShoppingGoods;
import com.matrix.system.hive.dao.ShoppingGoodsDao;
diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxCommonAction.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxCommonAction.java
index 568c875..cb91885 100644
--- a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxCommonAction.java
+++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxCommonAction.java
@@ -7,7 +7,10 @@
import com.matrix.component.wechat.externalInterface.common.Signature;
import com.matrix.component.wechat.externalInterface.common.Util;
import com.matrix.component.wechat.externalInterface.protocol.queryProtocol.NotifyData;
+import com.matrix.system.common.bean.BusParameterSettings;
import com.matrix.system.common.constance.AppConstance;
+import com.matrix.system.common.dao.BusParameterSettingsDao;
+import com.matrix.system.common.interceptor.HostInterceptor;
import com.matrix.system.hive.bean.SysVipInfo;
import com.matrix.system.hive.dao.SysVipInfoDao;
import com.matrix.system.shopXcx.bean.ShopActivitiesGroupJoin;
@@ -75,6 +78,11 @@
@Autowired
private SysVipInfoDao sysVipInfoDao;
+ @Autowired
+ BusParameterSettingsDao busParameterSettingsDao;
+
+
+
@Value("${evn}")
private String evn;
/**
@@ -86,7 +94,7 @@
* @throws Exception
*/
@Transactional(rollbackFor = Exception.class)
- @RequestMapping(value = "/wxpayCallback")
+ @RequestMapping(value = "/wxapi/wxpayCallback")
public void payCallBack(HttpServletResponse response, HttpServletRequest request) throws IOException {
LogUtil.info("微信支付回调start....");
@@ -111,7 +119,8 @@
// 返回状态码 SUCCESS/FAIL
if (AppConstance.CODE_SUCCESS.equals(data.getReturn_code())) {
// 校验签名
- if (Signature.checkIsSignValidFromResponseString(notityXml.toString())) {
+ BusParameterSettings paySecret = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.WECHARPAY_SECRET, HostInterceptor.getCompanyId());
+ if (Signature.checkIsSignValidFromResponseString(notityXml.toString(),paySecret.getParamValue())) {
// 校验业务结果
if (AppConstance.CODE_SUCCESS.equals(data.getResult_code())) {
// 返回SUCCESS报文
diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WxShopRefundRecordServiceImpl.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WxShopRefundRecordServiceImpl.java
index 807ab9d..6030d3e 100644
--- a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WxShopRefundRecordServiceImpl.java
+++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WxShopRefundRecordServiceImpl.java
@@ -78,14 +78,13 @@
//Double refundMoney = 0.1 * 100;
//用户ID
- String userId = WechatConfigure.mchID;
if (isDebug) {
- boolean b = weixinServiceUtil.comRefund(orderNo, refundNo, 1, 1, userId);
+ boolean b = weixinServiceUtil.comRefund(orderNo, refundNo, 1, 1, null);
flag = b;
} else {
LogUtil.info("开始调用退款接口。。。退款编号为", refundNo);
- boolean b = weixinServiceUtil.comRefund(orderNo, refundNo, orMoney, reMoney, userId);
+ boolean b = weixinServiceUtil.comRefund(orderNo, refundNo, orMoney, reMoney, null);
flag = b;
}
diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/bean/ShopWxtemplateMsg.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/bean/ShopWxtemplateMsg.java
index 4c5e2d4..390f897 100644
--- a/zq-erp/src/main/java/com/matrix/system/shopXcx/bean/ShopWxtemplateMsg.java
+++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/bean/ShopWxtemplateMsg.java
@@ -40,8 +40,15 @@
*/
private Integer status;
+ /**
+ * 模板类型 1,公众号,2,小程序
+ */
+ private Integer tempType;
-
+ /**
+ * 取数模板类
+ */
+ private String templateClass;
/**
* 模板备注
@@ -86,24 +93,76 @@
}
}
- public void buildDicMap(Object value) {
- if (value != null) {
- STATUS[] statusArray = STATUS.values();
- for (STATUS s : statusArray) {
- if (s.getCode().equals(value)) {
- getDicMap().put("status", s.getName());
- }
- }
- }
- }
+ public enum TempType {
+
+ MP("公众号", 1),
+
+ APP("小程序", 2);
+
+ private TempType(String name, int code) {
+ this.name = name;
+ this.code = code;
+ }
+
+ private String name;
+ private Integer code;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Integer getCode() {
+ return code;
+ }
+
+ public void setCode(Integer code) {
+ this.code = code;
+ }
+ }
+
+
+
public void setStatus(Integer status) {
- buildDicMap(status);
-
- buildDicMap("status");
-
+ if (status != null) {
+ STATUS[] statusArray = STATUS.values();
+ for (STATUS s : statusArray) {
+ if (s.getCode().equals(status)) {
+ getDicMap().put("status", s.getName());
+ }
+ }
+ }
this.status = status;
}
+ public String getTemplateClass() {
+ return templateClass;
+ }
+
+ public void setTemplateClass(String templateClass) {
+
+ this.templateClass = templateClass;
+ }
+
+ public Integer getTempType() {
+
+ return tempType;
+ }
+
+ public void setTempType(Integer tempType) {
+ if (tempType != null) {
+ TempType[] statusArray = TempType.values();
+ for (TempType s : statusArray) {
+ if (s.getCode().equals(tempType)) {
+ getDicMap().put("tempType", s.getName());
+ }
+ }
+ }
+ this.tempType = tempType;
+ }
public Integer getId() {
return id;
diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/dao/ShopWxtemplateMsgDao.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/dao/ShopWxtemplateMsgDao.java
index 96f20f4..92b583b 100644
--- a/zq-erp/src/main/java/com/matrix/system/shopXcx/dao/ShopWxtemplateMsgDao.java
+++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/dao/ShopWxtemplateMsgDao.java
@@ -26,7 +26,7 @@
public int deleteById(Integer id);
- public ShopWxtemplateMsg selectByCode(Integer code);
+ public ShopWxtemplateMsg selectByCode(@Param("code") Integer code, @Param("companyId") Long companyId);
public int deleteByModel(@Param("record") ShopWxtemplateMsg shopWxtemplateMsg);
diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/mqTask/MQTaskRouting.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/mqTask/MQTaskRouting.java
index 68c94d1..861de97 100644
--- a/zq-erp/src/main/java/com/matrix/system/shopXcx/mqTask/MQTaskRouting.java
+++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/mqTask/MQTaskRouting.java
@@ -12,6 +12,12 @@
* 发送微信消息
*/
String SEND_TEMPLATE_MSG = "SEND_TEMPLATE_MSG";
+
+ /**
+ * 发送小程序统一模板消息
+ */
+ String SEND_UNIFORM_TEMPLATE_MSG = "SEND_UNIFORM_TEMPLATE_MSG";
+
/**
* 订单出库
*/
diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/mqTask/VipCreateTask.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/mqTask/VipCreateTask.java
index 5d59638..e650788 100644
--- a/zq-erp/src/main/java/com/matrix/system/shopXcx/mqTask/VipCreateTask.java
+++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/mqTask/VipCreateTask.java
@@ -48,7 +48,7 @@
} else {
SysVipInfo vipInfo = new SysVipInfo();
//在备注记下微商城的用户id
- vipInfo.setRemark(userInfo.getOpenId());
+ vipInfo.setOpenId(userInfo.getOpenId());
vipInfo.setAddr(userInfo.getProvince() + " " + userInfo.getCity());
vipInfo.setPhone(userInfo.getPhoneNumber());
if (userInfo.getGender() != null) {
diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/mqTask/templateMsg/AppointmentSuccess.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/mqTask/templateMsg/AppointmentSuccess.java
index 69ae1e6..3dbd6f4 100644
--- a/zq-erp/src/main/java/com/matrix/system/shopXcx/mqTask/templateMsg/AppointmentSuccess.java
+++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/mqTask/templateMsg/AppointmentSuccess.java
@@ -48,7 +48,7 @@
SysShopInfo shopInfo = shopInfoDao.selectById(onlinebooking.getShopId());
//获取模板id
- ShopWxtemplateMsg wxtemplateMsg = wxtemplateMsgDao.selectByCode(TemplateMsgType.APPOINTMENT_SUCCESS.getCode());
+ ShopWxtemplateMsg wxtemplateMsg = wxtemplateMsgDao.selectByCode(TemplateMsgType.APPOINTMENT_SUCCESS.getCode(), 17L);
String page = "pages/yuyue/yyInfo?id=" + orderId + "&model=1";
diff --git a/zq-erp/src/main/java/com/matrix/system/wechart/templateMsg/MsgDemo3.java b/zq-erp/src/main/java/com/matrix/system/wechart/templateMsg/MsgDemo3.java
new file mode 100644
index 0000000..5531bf7
--- /dev/null
+++ b/zq-erp/src/main/java/com/matrix/system/wechart/templateMsg/MsgDemo3.java
@@ -0,0 +1,35 @@
+package com.matrix.system.wechart.templateMsg;
+
+import com.alibaba.fastjson.JSONObject;
+import com.matrix.component.tools.HttpClientUtil;
+import com.matrix.core.pojo.AjaxResult;
+import com.matrix.system.hive.plugin.util.HttpUtils;
+import com.matrix.system.shopXcx.api.WeChatGzhApiTools;
+import com.matrix.system.wechart.templateMsg.Task.UniformMsgSentTask;
+import com.rabbitmq.client.Delivery;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import java.io.IOException;
+
+@Controller
+@RequestMapping(value = "test3")
+public class MsgDemo3 {
+
+
+ @Autowired
+ UniformMsgSentTask uniformMsgSentTask;
+
+ @RequestMapping("/template")
+ @ResponseBody
+ public AjaxResult template() throws IOException {
+
+ uniformMsgSentTask.handle(null,null);
+ return AjaxResult.buildSuccessInstance("1");
+
+ }
+
+
+}
diff --git a/zq-erp/src/main/java/com/matrix/system/wechart/templateMsg/Task/TemplateMessageBulder.java b/zq-erp/src/main/java/com/matrix/system/wechart/templateMsg/Task/TemplateMessageBulder.java
new file mode 100644
index 0000000..4c0bafa
--- /dev/null
+++ b/zq-erp/src/main/java/com/matrix/system/wechart/templateMsg/Task/TemplateMessageBulder.java
@@ -0,0 +1,19 @@
+package com.matrix.system.wechart.templateMsg.Task;
+
+import com.matrix.system.wechart.templateMsg.UniformMsgPojo;
+
+import java.util.Map;
+
+/**
+ * 动态构建消息主体内容
+ * @author jyy
+ *
+ */
+public interface TemplateMessageBulder {
+ /**
+ * * 返回的map中 如果包含错误消息用error属性来表示
+ * @param param
+ * @return
+ */
+ Map buildMsg(Map param);
+}
diff --git a/zq-erp/src/main/java/com/matrix/system/wechart/templateMsg/Task/UniformMsgSentTask.java b/zq-erp/src/main/java/com/matrix/system/wechart/templateMsg/Task/UniformMsgSentTask.java
new file mode 100644
index 0000000..7094fe9
--- /dev/null
+++ b/zq-erp/src/main/java/com/matrix/system/wechart/templateMsg/Task/UniformMsgSentTask.java
@@ -0,0 +1,120 @@
+package com.matrix.system.wechart.templateMsg.Task;
+
+
+import com.alibaba.fastjson.JSONObject;
+import com.matrix.biz.bean.BizUser;
+import com.matrix.biz.service.BizUserService;
+import com.matrix.component.tools.HttpClientUtil;
+import com.matrix.core.pojo.AjaxResult;
+import com.matrix.core.tools.LogUtil;
+import com.matrix.core.tools.rr.GlueFactory;
+import com.matrix.system.common.bean.BusParameterSettings;
+import com.matrix.system.common.constance.AppConstance;
+import com.matrix.system.common.dao.BusParameterSettingsDao;
+import com.matrix.system.constance.Dictionary;
+import com.matrix.system.hive.bean.SysProjServices;
+import com.matrix.system.hive.bean.SysVipInfo;
+import com.matrix.system.hive.dao.SysProjServicesDao;
+import com.matrix.system.hive.dao.SysShopInfoDao;
+import com.matrix.system.hive.dao.SysVipInfoDao;
+import com.matrix.system.shopXcx.api.WeChatGzhApiTools;
+import com.matrix.system.shopXcx.bean.ShopWxtemplateMsg;
+import com.matrix.system.shopXcx.dao.ShopWxtemplateMsgDao;
+import com.matrix.system.wechart.templateMsg.GzhTemplateMessagePojo;
+import com.matrix.system.wechart.templateMsg.TemplateNameConstance;
+import com.matrix.system.wechart.templateMsg.UniformMsgPojo;
+import com.rabbitmq.client.DeliverCallback;
+import com.rabbitmq.client.Delivery;
+import org.apache.commons.collections.map.HashedMap;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 小程序统一消息模板消息发送提醒
+ * @author jyy
+ */
+@Component
+public class UniformMsgSentTask implements DeliverCallback {
+
+ @Autowired
+ private ShopWxtemplateMsgDao shopWxtemplateMsgDao;
+
+ @Autowired
+ private BusParameterSettingsDao busParameterSettingsDao;
+
+ /**
+ * 发送模板消息需要传JSONO字符串作为格式
+ * 例如:{"companyId":17}
+ * companyId 是必须属性
+ * @param consumerTag
+ * @param message
+ * @throws IOException
+ */
+ @Override
+ public void handle(String consumerTag, Delivery message) throws IOException {
+ try {
+
+
+ String messages = new String(message.getBody(), "UTF-8");
+ JSONObject messageJsonParam=JSONObject.parseObject(messages);
+
+ if(!messageJsonParam.containsKey("companyId")){
+ LogUtil.error("小程序消息推送参数格式异常发送模板消息需要传JSONO字符串作为格式 例如:{\"companyId\":17} companyId 是必须属性");
+ return;
+ }
+
+ Long companyId = Long.parseLong( messageJsonParam.get("companyId").toString());
+
+ //获取公司微信配置参数
+ BusParameterSettings xcxAppId = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.MINIPROGRAM_APPID, companyId);
+ BusParameterSettings xcxSecret = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.MINIPROGRAM_SECRET, companyId);
+ BusParameterSettings gzhAppid = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.GZH_APPID, companyId);
+ //获取消息模板
+ ShopWxtemplateMsg template = shopWxtemplateMsgDao.selectByCode(TemplateNameConstance.GZH_YYTX,companyId);
+ //校验参数
+ if(xcxAppId==null||xcxSecret==null||gzhAppid==null||template==null){
+ LogUtil.error("小程序消息推送配置缺失xcxAppId="+xcxAppId+";xcxSecret="+xcxSecret+";gzhAppid="+gzhAppid+";template="+template);
+ return;
+ }
+
+ //获取模板动态构建类
+ TemplateMessageBulder templateMessageBulder = (TemplateMessageBulder) GlueFactory.getInstance().loadInstance(template.getTemplateClass());
+ //为模板动态类装备必要的参数
+ Map<String, Object> bulderParam = new HashedMap();
+ bulderParam.put("gzhAppid", gzhAppid.getParamValue());
+ bulderParam.put("template_id", template.getUuid());
+ bulderParam.put("messageJsonParam", messageJsonParam);
+
+
+ //调用模板计算出消息体
+ Map msgResult = templateMessageBulder.buildMsg(bulderParam);
+
+ if(msgResult.containsKey("error")){
+ //错误消息处理
+ LogUtil.error("模板消息发送失败:"+msgResult.get("error"));
+ return;
+ }else{
+ //正常返回消息
+ List msgList = (List) msgResult.get("msgList");
+ //获取acceToken
+ String ACCESS_TOKEN = WeChatGzhApiTools.getAccessToken(xcxAppId.getParamValue(), xcxSecret.getParamValue());
+ String url = "https://api.weixin.qq.com/cgi-bin/message/wxopen/template/uniform_send?access_token=ACCESS_TOKEN".replaceAll("ACCESS_TOKEN", ACCESS_TOKEN);
+ for (Object msg : msgList) {
+ UniformMsgPojo uniformMsgPojo = (UniformMsgPojo) msg;
+ //推送消息到微信
+ JSONObject result = HttpClientUtil.sendPostWithJson(url, JSONObject.toJSON(uniformMsgPojo).toString());
+ //微信返回值
+ LogUtil.debug("微信小程序模板消息推送结果:" + result.toString());
+ }
+ }
+
+ } catch (Exception e) {
+ LogUtil.error("消费者执行异常", e);
+ }
+
+ }
+}
diff --git a/zq-erp/src/main/java/com/matrix/system/wechart/templateMsg/Task/messageBulderDemo/DefaultTemplateMessageBulder.java b/zq-erp/src/main/java/com/matrix/system/wechart/templateMsg/Task/messageBulderDemo/DefaultTemplateMessageBulder.java
new file mode 100644
index 0000000..d917a1e
--- /dev/null
+++ b/zq-erp/src/main/java/com/matrix/system/wechart/templateMsg/Task/messageBulderDemo/DefaultTemplateMessageBulder.java
@@ -0,0 +1,99 @@
+package com.matrix.system.wechart.templateMsg.Task.messageBulderDemo;
+
+import com.alibaba.fastjson.JSONObject;
+import com.matrix.biz.bean.BizUser;
+import com.matrix.biz.dao.BizUserDao;
+import com.matrix.core.tools.DateUtil;
+import com.matrix.core.tools.StringUtils;
+import com.matrix.system.hive.bean.SysBeauticianState;
+import com.matrix.system.hive.bean.SysProjServices;
+import com.matrix.system.hive.bean.SysVipInfo;
+import com.matrix.system.hive.dao.SysBeauticianStateDao;
+import com.matrix.system.hive.dao.SysProjServicesDao;
+import com.matrix.system.hive.dao.SysVipInfoDao;
+import com.matrix.system.wechart.templateMsg.GzhTemplateMessagePojo;
+import com.matrix.system.wechart.templateMsg.Task.TemplateMessageBulder;
+import com.matrix.system.wechart.templateMsg.UniformMsgPojo;
+import io.swagger.models.auth.In;
+import org.apache.commons.collections.map.HashedMap;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 某个公司客户的定制消息模板
+ */
+@Component
+public class DefaultTemplateMessageBulder implements TemplateMessageBulder {
+
+ @Autowired
+ SysProjServicesDao projServicesDao;
+
+ @Autowired
+ SysVipInfoDao vipInfoDao;
+
+ @Autowired
+ private SysBeauticianStateDao beauticianStateDao;
+
+
+
+ @Override
+ public Map buildMsg(Map param) {
+
+ //返回参数
+ Map builParam=new HashedMap();
+
+
+ //获取基础公共参数
+ String gzhAppid= (String) param.get("gzhAppid");
+ String template_id= (String) param.get("template_id");
+ //触发点传送的json参数
+ JSONObject messageJsonParam= (JSONObject) param.get("messageJsonParam");
+
+ Long serviceId= (Long) messageJsonParam.get("serviceId");
+
+
+ //构建消息主体
+ SysProjServices sysProjServices = projServicesDao.selectById(serviceId);
+
+
+ //补充服务单扩展信息===============
+ List<SysBeauticianState> beauticianStateList = beauticianStateDao.selectBySerIds(sysProjServices.getId());
+
+ SysVipInfo vipInfo=vipInfoDao.selectById(sysProjServices.getVipId());
+ String touser= vipInfo.getOpenId();
+ if(StringUtils.isBlank(touser)){
+ builParam.put("error","未获取到"+vipInfo.getVipName()+"用户小程序openid");
+ return builParam;
+ }
+
+ String time= DateUtil.dateFormatStr(sysProjServices.getConsumeTime(),DateUtil.DATE_FORMAT_MM);
+ List msgList=new ArrayList();
+ //如果一个项目存在多个护理项目则发送多次消息
+ for (SysBeauticianState beauticianState:beauticianStateList){
+ UniformMsgPojo uniformMsgPojo=new UniformMsgPojo();
+ GzhTemplateMessagePojo messagePojo=new GzhTemplateMessagePojo();
+ uniformMsgPojo.setTouser(touser);
+ messagePojo.setTemplate_id(template_id);
+ messagePojo.setAppid(gzhAppid);
+
+
+ //个性参数设置
+ Integer suplerTimes= beauticianState.getProjUse().getSurplusCount();
+ messagePojo.setFirst("尊敬的:"+vipInfo.getVipName(),"#453454");
+ messagePojo.setKeyWord(beauticianState.getProjInfo().getName(),"#453454");
+ messagePojo.setKeyWord(time,"#453454");
+ messagePojo.setRemark("您的护理项目剩余"+suplerTimes+"次。","#453454");
+ uniformMsgPojo.setMp_template_msg(messagePojo);
+
+
+ msgList.add(uniformMsgPojo);
+ }
+
+ builParam.put("msgList",msgList);
+ return builParam;
+ }
+}
diff --git a/zq-erp/src/main/java/com/matrix/system/wechart/templateMsg/TemplateNameConstance.java b/zq-erp/src/main/java/com/matrix/system/wechart/templateMsg/TemplateNameConstance.java
new file mode 100644
index 0000000..d66a4f3
--- /dev/null
+++ b/zq-erp/src/main/java/com/matrix/system/wechart/templateMsg/TemplateNameConstance.java
@@ -0,0 +1,15 @@
+package com.matrix.system.wechart.templateMsg;
+
+/**
+ * 模板code定义常量
+ * @author jyy
+ */
+public interface TemplateNameConstance {
+
+ /**
+ * 公众号预约提醒
+ */
+ Integer GZH_YYTX=10000;
+
+
+}
diff --git a/zq-erp/src/main/resources/config/application.properties b/zq-erp/src/main/resources/config/application.properties
index 0cc9ddf..e14f492 100644
--- a/zq-erp/src/main/resources/config/application.properties
+++ b/zq-erp/src/main/resources/config/application.properties
@@ -1,4 +1,4 @@
-evn=dev
+evn=devbb
server.port=8080
diff --git a/zq-erp/src/main/resources/config/db/increment/20210109.sql b/zq-erp/src/main/resources/config/db/increment/20210109.sql
new file mode 100644
index 0000000..2f140ba
--- /dev/null
+++ b/zq-erp/src/main/resources/config/db/increment/20210109.sql
@@ -0,0 +1,5 @@
+ALTER TABLE `shop_wxtemplate_msg`
+ADD COLUMN `temp_type` int(2) NULL COMMENT ' 模板类型 1,公众号,2,小程序' AFTER `code`,
+ADD COLUMN `template_class` longtext NULL COMMENT '取数模板类' AFTER `temp_type`;
+
+
diff --git a/zq-erp/src/main/resources/config/lhx/system.properties b/zq-erp/src/main/resources/config/lhx/system.properties
index ffeb78d..d51c554 100644
--- a/zq-erp/src/main/resources/config/lhx/system.properties
+++ b/zq-erp/src/main/resources/config/lhx/system.properties
@@ -102,3 +102,6 @@
#hive仓库地址
hive.service=http://erp.hive.jyymatrix.cc/meidu-crm/
+
+gzh_appid=wx57e6335559bdbda6
+gzh_secret=ecb408af170e3890e6544290cad33760
diff --git a/zq-erp/src/main/resources/config/test/application.properties b/zq-erp/src/main/resources/config/test/application.properties
index 09b80d4..b5a6726 100644
--- a/zq-erp/src/main/resources/config/test/application.properties
+++ b/zq-erp/src/main/resources/config/test/application.properties
@@ -1,12 +1,13 @@
-evn=dev
+evn=tyytest
server.port=8080
#线上测试环境
-spring.datasource.username=chuhuan
-spring.datasource.password=chuhuan
-spring.datasource.url=jdbc:mysql://119.3.52.84:3306/hive_plus_test?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&allowMultiQueries=true&transformedBitIsBoolean=true&serverTimezone=GMT%2B8
+spring.datasource.username=ct_test
+spring.datasource.password=123456
+spring.datasource.url=jdbc:mysql://120.27.238.55:3306/hive_test?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&allowMultiQueries=true&transformedBitIsBoolean=true&serverTimezone=GMT%2B8
+
diff --git a/zq-erp/src/main/resources/config/test/system.properties b/zq-erp/src/main/resources/config/test/system.properties
index a6ae4c0..26d5253 100644
--- a/zq-erp/src/main/resources/config/test/system.properties
+++ b/zq-erp/src/main/resources/config/test/system.properties
@@ -1,5 +1,5 @@
#是否启用debug模式
-debug=true
+debug=false
# 日志文件保存地址
log_path=/mnt/hive/log-test
diff --git a/zq-erp/src/main/resources/mybatis/mapper/xcxShop/ShopWxtemplateMsgDao.xml b/zq-erp/src/main/resources/mybatis/mapper/xcxShop/ShopWxtemplateMsgDao.xml
index cb13505..e1aae99 100644
--- a/zq-erp/src/main/resources/mybatis/mapper/xcxShop/ShopWxtemplateMsgDao.xml
+++ b/zq-erp/src/main/resources/mybatis/mapper/xcxShop/ShopWxtemplateMsgDao.xml
@@ -16,6 +16,8 @@
<result property="remark" column="remark" />
<result property="companyId" column="company_id" />
<result property="code" column="code" />
+ <result property="tempType" column="temp_type" />
+ <result property="templateClass" column="template_class" />
</resultMap>
@@ -32,6 +34,8 @@
<result property="remark" column="remark" />
<result property="companyId" column="company_id" />
<result property="code" column="code" />
+ <result property="tempType" column="temp_type" />
+ <result property="templateClass" column="template_class" />
</resultMap>
<!-- 字段sql -->
@@ -46,7 +50,9 @@
status,
remark,
company_id,
- code
+ code,
+ temp_type,
+ template_class
</sql>
<!-- 属性sql -->
@@ -61,9 +67,10 @@
#{item.status},
#{item.remark},
#{item.companyId},
- #{item.code}
+ #{item.code},
+ #{item.tempType},
+ #{item.templateClass}
</sql>
-
<!-- where sql -->
<sql id="where_sql">
@@ -86,6 +93,12 @@
<if test="(record.companyId!=null and record.companyId!='') or (record.companyId!='' and record.companyId==0) ">
and company_id = #{record.companyId}
</if>
+
+ <if test="(record.tempType!=null and record.tempType!='') or (record.tempType!='' and record.tempType==0) ">
+ and tempType = #{record.tempType}
+ </if>
+
+
</if>
</sql>
@@ -140,6 +153,10 @@
<if test="_parameter.containsKey('code')">
code = #{code},
</if>
+ <if test="_parameter.containsKey('temp_type')">
+ temp_type = #{tempType},
+ </if>
+
</set>
WHERE id=#{id}
</update>
@@ -167,6 +184,11 @@
<if test="record.code != null and record.code != '' ">
code = #{record.code},
</if>
+
+ <if test="record.tempType != null and record.tempType != '' ">
+ temp_type = #{record.tempType},
+ </if>
+
</set>
WHERE id=#{record.id}
</update>
@@ -248,7 +270,7 @@
select
<include refid="columns" ></include>
from shop_wxtemplate_msg
- where code=#{code}
+ where code=#{code} and company_id=#{companyId}
</select>
diff --git a/zq-erp/src/main/resources/templates/views/admin/shop/templateMsg-list.html b/zq-erp/src/main/resources/templates/views/admin/shop/templateMsg-list.html
index f3c70ac..6bfb688 100644
--- a/zq-erp/src/main/resources/templates/views/admin/shop/templateMsg-list.html
+++ b/zq-erp/src/main/resources/templates/views/admin/shop/templateMsg-list.html
@@ -86,6 +86,7 @@
<th data-field="name">名称</th>
<th data-field="uuid">模板ID</th>
<th data-field="dicMap.status">是否启用</th>
+ <th data-field="dicMap.tempType">模板类型</th>
<th data-field="remark">备注</th>
</tr>
</thead>
--
Gitblit v1.9.1