|
@@ -1,6 +1,7 @@
|
|
|
package com.miaxis.app.controller.wx;
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.miaxis.common.config.WxpayConfig;
|
|
@@ -9,6 +10,9 @@ import com.miaxis.common.core.domain.entity.UserInfo;
|
|
|
import com.miaxis.common.exception.CustomException;
|
|
|
import com.miaxis.common.utils.AesUtil;
|
|
|
import com.miaxis.extension.service.IWxExtensionIncomeService;
|
|
|
+import com.miaxis.feign.dto.WxGzhMini;
|
|
|
+import com.miaxis.feign.dto.WxMessageTemplate;
|
|
|
+import com.miaxis.feign.service.IWxSendService;
|
|
|
import com.miaxis.framework.web.service.TokenService;
|
|
|
import com.miaxis.user.service.IUserInfoService;
|
|
|
import com.miaxis.wx.domain.RefundRecord;
|
|
@@ -16,6 +20,7 @@ import com.miaxis.wx.domain.WxOrder;
|
|
|
import com.miaxis.wx.dto.WxNotifyReturnDTO;
|
|
|
import com.miaxis.wx.dto.WxpayNotifyDTO;
|
|
|
import com.miaxis.wx.service.IRefundRecordService;
|
|
|
+import com.miaxis.wx.service.IWxGzhService;
|
|
|
import com.miaxis.wx.service.IWxOrderService;
|
|
|
import com.wechat.pay.contrib.apache.httpclient.auth.AutoUpdateCertificatesVerifier;
|
|
|
import io.swagger.annotations.Api;
|
|
@@ -69,6 +74,11 @@ public class WxNotifyController {
|
|
|
@Autowired
|
|
|
private IWxExtensionIncomeService wxExtensionIncomeService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IWxSendService wxSendService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IWxGzhService wxGzhService;
|
|
|
|
|
|
|
|
|
|
|
@@ -245,6 +255,8 @@ public class WxNotifyController {
|
|
|
//// //刷新缓存中的数据
|
|
|
//// tokenService.refreshToken(loginUser);
|
|
|
|
|
|
+ //发送模板消息
|
|
|
+ messageTemplateSend(userinfo,wxOrder);
|
|
|
|
|
|
// 分成
|
|
|
wxExtensionIncomeService.addExtensionIncomeBySourceId(wxOrder.getOutTradeNo(),wxOrder.getOpenid(),wxOrder.getTotal());
|
|
@@ -260,8 +272,58 @@ public class WxNotifyController {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
+ * 发送模板信息
|
|
|
+ * @param userInfo 用户信息
|
|
|
+ * @param wxOrder 订单信息
|
|
|
+ */
|
|
|
+ private void messageTemplateSend(UserInfo userInfo,WxOrder wxOrder){
|
|
|
+
|
|
|
+ //获取tolen
|
|
|
+ String token = wxGzhService.getGzhToken();
|
|
|
+
|
|
|
+ WxMessageTemplate messageTemplate = new WxMessageTemplate();
|
|
|
+ messageTemplate.setTouser(userInfo.getOpenid());
|
|
|
+ messageTemplate.setTemplate_id("d1P87FFAAos_sHteTCA-slkFJesE8xkoDsRImVa58jc");
|
|
|
+ messageTemplate.setUrl("https://jpcj-h5.zzxcx.net");
|
|
|
+ WxGzhMini wxGzhMini = new WxGzhMini();
|
|
|
+ messageTemplate.setMiniprogram(wxGzhMini);
|
|
|
+
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ JSONObject first = new JSONObject();
|
|
|
+ JSONObject keyword1 = new JSONObject();
|
|
|
+ JSONObject keyword2 = new JSONObject();
|
|
|
+ JSONObject keyword3 = new JSONObject();
|
|
|
+ JSONObject keyword4 = new JSONObject();
|
|
|
+ JSONObject keyword5 = new JSONObject();
|
|
|
+ JSONObject remark = new JSONObject();
|
|
|
+ first.put("value","恭喜您开通金牌车教会员成功!");
|
|
|
+ first.put("color","#173177");
|
|
|
+ keyword1.put("value","VIP会员");
|
|
|
+ keyword1.put("color","#173177");
|
|
|
+ keyword2.put("value", userInfo.getNickName());
|
|
|
+ keyword2.put("color","#173177");
|
|
|
+ keyword3.put("value","支付成功");
|
|
|
+ keyword3.put("color","#173177");
|
|
|
+ keyword4.put("value",wxOrder.getTotal()/100);
|
|
|
+ keyword4.put("color","#173177");
|
|
|
+ keyword5.put("value",DateUtil.format(userInfo.getExpireTime(), "yyyy-MM-dd HH:mm"));
|
|
|
+ keyword5.put("color","#173177");
|
|
|
+ remark.put("value","即日起,即可想享受会员特权");
|
|
|
+ remark.put("color","#173177");
|
|
|
+ jsonObject.put("first",first);
|
|
|
+ jsonObject.put("keyword1",keyword1);
|
|
|
+ jsonObject.put("keyword2",keyword2);
|
|
|
+ jsonObject.put("keyword3",keyword3);
|
|
|
+ jsonObject.put("keyword4",keyword4);
|
|
|
+ jsonObject.put("keyword5",keyword5);
|
|
|
+ jsonObject.put("remark",remark);
|
|
|
+ messageTemplate.setData(jsonObject);
|
|
|
+ String result = wxSendService.messageTemplateSend(token,messageTemplate);
|
|
|
+ JSONObject parseObject = JSONObject.parseObject(result);
|
|
|
+ log.info("模板消息:[{}],响应信息:[{}]",messageTemplate,parseObject);
|
|
|
|
|
|
-
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|