Merge branch 'master' into order_yy

* master:
  1
  修改二维码
  提交微信小程序多次推送问题
  提交修改
  21
  no message
  提交代码
  提交代码
  提交代码
  1
  1

# Conflicts:
#	hai-bweb/src/main/java/com/bweb/controller/HighTestController.java
#	hai-cweb/src/main/java/com/cweb/controller/HighTestController.java
dev-discount
袁野 2 years ago
commit 8769b071cc
  1. 20
      hai-bweb/src/main/java/com/bweb/controller/HighMerchantStoreController.java
  2. 1
      hai-bweb/src/main/java/com/bweb/controller/HighTestController.java
  3. 1
      hai-cweb/src/main/java/com/cweb/controller/HighTestController.java
  4. 11
      hai-cweb/src/main/java/com/cweb/controller/HighUserController.java
  5. 46
      hai-cweb/src/main/java/com/cweb/controller/pay/CzOrderController.java
  6. 13
      hai-schedule/src/main/java/com/hai/schedule/HighGasSchedule.java
  7. 2
      hai-schedule/src/main/java/com/hai/schedule/HighOrderSchedule.java
  8. 39
      hai-service/src/main/java/com/hai/common/utils/WxUtils.java
  9. 53
      hai-service/src/main/java/com/hai/model/TextMessage.java
  10. 5
      hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java
  11. 2
      hai-service/src/main/java/com/hai/service/impl/OutRechargeOrderServiceImpl.java
  12. 85
      v1/src/main/java/com/v1/config/WeChatQrcodeUtils.java
  13. 58
      v1/src/main/java/com/v1/config/WxConfig.java
  14. 132
      v1/src/main/java/com/v1/controller/WxMsgController.java
  15. 2
      v1/src/main/resources/prod/config.properties

@ -10,6 +10,7 @@ import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode; import com.hai.common.exception.SysCode;
import com.hai.common.security.SessionObject; import com.hai.common.security.SessionObject;
import com.hai.common.security.UserCenter; import com.hai.common.security.UserCenter;
import com.hai.common.utils.HttpsUtils;
import com.hai.common.utils.ResponseMsgUtil; import com.hai.common.utils.ResponseMsgUtil;
import com.hai.config.CommonSysConst; import com.hai.config.CommonSysConst;
import com.hai.entity.BsCompany; import com.hai.entity.BsCompany;
@ -363,5 +364,24 @@ public class HighMerchantStoreController {
} }
} }
@RequestMapping(value = "/getQrCode", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "生成推广二维码")
public ResponseData getQrCode(@RequestParam(name = "storeKey", required = false) String storeKey) {
try {
Map<String, Object> params = new HashMap<>();
params.put("type", "2");
params.put("code", storeKey);
return ResponseMsgUtil.success(HttpsUtils.doGet("https://hsg.dctpay.com/v1/wxMsg/createQrcode", params).getString("return_data"));
} catch (Exception e) {
log.error("HighOrderController --> getBackendToken() error!", e);
return ResponseMsgUtil.exception(e);
}
}
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -8,13 +8,12 @@ import com.hai.common.exception.ErrorCode;
import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode; import com.hai.common.exception.SysCode;
import com.hai.common.security.*; import com.hai.common.security.*;
import com.hai.common.utils.HttpsUtils;
import com.hai.common.utils.ImageUtils; import com.hai.common.utils.ImageUtils;
import com.hai.common.utils.RedisUtil; import com.hai.common.utils.RedisUtil;
import com.hai.common.utils.ResponseMsgUtil; import com.hai.common.utils.ResponseMsgUtil;
import com.hai.config.CommonConfig; import com.hai.config.CommonConfig;
import com.hai.entity.HighOrder;
import com.hai.entity.HighUser; import com.hai.entity.HighUser;
import com.hai.entity.HighUserCoupon;
import com.hai.entity.HighUserPayPassword; import com.hai.entity.HighUserPayPassword;
import com.hai.model.HighUserModel; import com.hai.model.HighUserModel;
import com.hai.model.ResponseData; import com.hai.model.ResponseData;
@ -22,7 +21,6 @@ import com.hai.service.*;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.poi.util.StringUtil;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -348,11 +346,12 @@ public class HighUserController {
SessionObject sessionObject = userCenter.getSessionObject(request); SessionObject sessionObject = userCenter.getSessionObject(request);
HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject(); HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject();
String path = ImageUtils.QrCodeImg(SysConst.getSysConfig().getQrCodeUrl() , userInfoModel.getHighUser().getId().intValue()); Map<String, Object> params = new HashMap<>();
CommonConfig.overlapImage(path , userInfoModel.getHighUser().getId().toString()); params.put("type", "1");
params.put("code", userInfoModel.getHighUser().getId());
return ResponseMsgUtil.success(HttpsUtils.doGet("https://hsg.dctpay.com/v1/wxMsg/createQrcode", params).getString("return_data"));
return ResponseMsgUtil.success(SysConst.getSysConfig().getImgUrl() + path);
} catch (Exception e) { } catch (Exception e) {
log.error("HighOrderController --> getBackendToken() error!", e); log.error("HighOrderController --> getBackendToken() error!", e);
return ResponseMsgUtil.exception(e); return ResponseMsgUtil.exception(e);

@ -121,16 +121,19 @@ public class CzOrderController {
// 判断是否充值成功 // 判断是否充值成功
if (dataObject.getInteger("status") == 3) { if (dataObject.getInteger("status") == 3) {
new Thread(() -> { if (rechargeOrder.getRechargeStatus() ==201) {
HighUser highUser = highUserService.findByUserId(rechargeOrder.getUserId()); new Thread(() -> {
WxMsgConfig.rechargedSuccess( HighUser highUser = highUserService.findByUserId(rechargeOrder.getUserId());
rechargeOrder.getRechargeContent() + "充值成功", WxMsgConfig.rechargedSuccess(
String.valueOf(rechargeOrder.getPayRealPrice()), rechargeOrder.getRechargeContent() + "充值成功",
rechargeOrder.getOrderNo(), String.valueOf(rechargeOrder.getPayRealPrice()),
rechargeOrder.getFinishTime(), rechargeOrder.getOrderNo(),
RechargePayType.getNameByType(rechargeOrder.getPayType()), rechargeOrder.getFinishTime(),
highUser.getOpenId()); RechargePayType.getNameByType(rechargeOrder.getPayType()),
}).start(); highUser.getOpenId());
}).start();
}
childOrder.setStatus(101); childOrder.setStatus(101);
rechargeOrder.setRechargeStatus(202); rechargeOrder.setRechargeStatus(202);
rechargeOrder.setPayStatus(100); rechargeOrder.setPayStatus(100);
@ -188,16 +191,19 @@ public class CzOrderController {
// 判断是否充值成功 // 判断是否充值成功
if (state == 1) { if (state == 1) {
new Thread(() -> {
HighUser highUser = highUserService.findByUserId(rechargeOrder.getUserId()); if (rechargeOrder.getRechargeStatus() ==201) {
WxMsgConfig.rechargedSuccess( new Thread(() -> {
rechargeOrder.getRechargeContent() + "充值成功", HighUser highUser = highUserService.findByUserId(rechargeOrder.getUserId());
String.valueOf(rechargeOrder.getPayRealPrice()), WxMsgConfig.rechargedSuccess(
rechargeOrder.getOrderNo(), rechargeOrder.getRechargeContent() + "充值成功",
rechargeOrder.getFinishTime(), String.valueOf(rechargeOrder.getPayRealPrice()),
RechargePayType.getNameByType(rechargeOrder.getPayType()), rechargeOrder.getOrderNo(),
highUser.getOpenId()); rechargeOrder.getFinishTime(),
}).start(); RechargePayType.getNameByType(rechargeOrder.getPayType()),
highUser.getOpenId());
}).start();
}
childOrder.setStatus(101); childOrder.setStatus(101);
rechargeOrder.setRechargeStatus(202); rechargeOrder.setRechargeStatus(202);
rechargeOrder.setPayStatus(100); rechargeOrder.setPayStatus(100);

@ -151,25 +151,16 @@ public class HighGasSchedule {
} }
} }
/* @Scheduled(cron = "0 1 0 * * ?") //每日凌晨12点01分执行一次 @Scheduled(cron = "10 0 0 * * ?") // 每日凌晨00:00:10执行一次
public void getJiaHaoYouAllStation() throws Exception { public void getJiaHaoYouAllStation() throws Exception {
gasService.getJiaHaoYouAllStation(); gasService.getJiaHaoYouAllStation();
} }
@Scheduled(cron = "0 1 0 * * ?") //每日凌晨12点01分执行一次 /* @Scheduled(cron = "0 1 0 * * ?") //每日凌晨12点01分执行一次
public void getJinZhuAllStation() throws Exception { public void getJinZhuAllStation() throws Exception {
gasService.getJinZhuAllStation(); gasService.getJinZhuAllStation();
}*/ }*/
@Scheduled(cron = "0 40 7 13 * ?")
public void getJinZhuAllStation() throws Exception {
HighMerchantStoreModel store = highMerchantStoreService.getMerchantStoreByKey("11052456");
if (store != null) {
store.setStatus(0);
highMerchantStoreService.updateMerchantStoreDetail(store);
}
}
/* @Scheduled(cron = "0 30 7 * * ?") //每日7点1分执行一次 /* @Scheduled(cron = "0 30 7 * * ?") //每日7点1分执行一次
public void refreshPriceOfficial() throws Exception { public void refreshPriceOfficial() throws Exception {
gasOilPriceOfficialService.refreshPriceOfficial(); gasOilPriceOfficialService.refreshPriceOfficial();

@ -101,7 +101,7 @@ public class HighOrderSchedule {
public void initRechargeOrder() { public void initRechargeOrder() {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("payStatus", String.valueOf(102)); map.put("payStatus", String.valueOf(102));
map.put("rechargeStatus", String.valueOf(204)); map.put("rechargeStatus", String.valueOf(205));
List<OutRechargeOrder> orderList = outRechargeOrderService.getListRechargeOrder(map); List<OutRechargeOrder> orderList = outRechargeOrderService.getListRechargeOrder(map);
if (orderList.size() > 0) { if (orderList.size() > 0) {
for (OutRechargeOrder order : orderList) { for (OutRechargeOrder order : orderList) {

@ -540,4 +540,43 @@ public class WxUtils {
} }
} }
/**
* 用SHA1算法生成安全签名
* @param data 数据
* @param key key
* @return 安全签名
* @throws Exception
*/
public static String getSHA1(final Map<String, Object> data, String key) throws Exception
{
try {
String[] array = new String[] { token, timestamp, nonce};
StringBuffer sb = new StringBuffer();
// 字符串排序
Arrays.sort(array);
for (int i = 0; i < 3; i++) {
sb.append(array[i]);
}
String str = sb.toString();
// SHA1签名生成
MessageDigest md = MessageDigest.getInstance("SHA-1");
md.update(str.getBytes());
byte[] digest = md.digest();
StringBuffer hexstr = new StringBuffer();
String shaHex = "";
for (int i = 0; i < digest.length; i++) {
shaHex = Integer.toHexString(digest[i] & 0xFF);
if (shaHex.length() < 2) {
hexstr.append(0);
}
hexstr.append(shaHex);
}
return hexstr.toString();
} catch (Exception e) {
e.printStackTrace();
throw new Exception(String.format("Invalid sign_type: %s"));
}
}
} }

@ -0,0 +1,53 @@
package com.hai.model;
/**
* @author sum1dream
*/
public class TextMessage {
private String toUserName;
private String fromUserName;
private String msgType;
private String content;
private Long createTime;
public String getToUserName() {
return toUserName;
}
public void setToUserName(String toUserName) {
this.toUserName = toUserName;
}
public String getFromUserName() {
return fromUserName;
}
public void setFromUserName(String fromUserName) {
this.fromUserName = fromUserName;
}
public String getMsgType() {
return msgType;
}
public void setMsgType(String msgType) {
this.msgType = msgType;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public Long getCreateTime() {
return createTime;
}
public void setCreateTime(Long createTime) {
this.createTime = createTime;
}
}

@ -75,9 +75,6 @@ public class HighOrderServiceImpl implements HighOrderService {
@Resource @Resource
private HighCouponCodeService highCouponCodeService; private HighCouponCodeService highCouponCodeService;
@Resource
private ApiProductService apiProductService;
@Resource @Resource
private HighCouponService highCouponService; private HighCouponService highCouponService;
@ -1919,7 +1916,6 @@ public class HighOrderServiceImpl implements HighOrderService {
return highOrderMapperExt.selectTest(); return highOrderMapperExt.selectTest();
} }
@Override @Override
public List<Map<String, Object>> getFinishGasOrder() { public List<Map<String, Object>> getFinishGasOrder() {
return highOrderMapper.selectFinishGasOrder(); return highOrderMapper.selectFinishGasOrder();
@ -1932,7 +1928,6 @@ public class HighOrderServiceImpl implements HighOrderService {
return highChildOrderMapper.selectByExample(example).get(0); return highChildOrderMapper.selectByExample(example).get(0);
} }
@Override @Override
public List<HighOrderModel> selectDiscountPackageOrderList(Map<String, Object> map) throws Exception { public List<HighOrderModel> selectDiscountPackageOrderList(Map<String, Object> map) throws Exception {

@ -975,7 +975,7 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
} }
if (childOrder.getStatus() == 103) { if (childOrder.getStatus() == 103) {
outRechargeOrder.setRechargeStatus(204); outRechargeOrder.setRechargeStatus(205);
} }
outRechargeOrderService.updateOrder(outRechargeOrder); outRechargeOrderService.updateOrder(outRechargeOrder);
System.out.println("话费定时任务 -> 需要重新充值:结束"); System.out.println("话费定时任务 -> 需要重新充值:结束");

@ -1,6 +1,8 @@
package com.v1.config; package com.v1.config;
import com.alibaba.fastjson.JSONObject;
import com.hai.model.TextMessage;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.mp.api.WxMpService; import me.chanjar.weixin.mp.api.WxMpService;
@ -8,8 +10,8 @@ import me.chanjar.weixin.mp.bean.result.WxMpQrCodeTicket;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.io.File; import java.io.File;
import java.util.Map;
/** /**
* @serviceName WeChatQrcodeUtils.java * @serviceName WeChatQrcodeUtils.java
@ -118,4 +120,85 @@ public class WeChatQrcodeUtils {
} }
/**
* 处理 subscribe 类型的event
*
* @param map
* @return
*/
public String handleEventSubscribe(Map<String, String> map) {
String resXmlStr = getReturnMsgSubscribe(map);
return resXmlStr;
}
/**
* @Author Sum1Dream
* @Name getReturnMsgSubscribe
* @Description // 处理文本
* @Date 16:34 2022/9/21
* @Param [decryptMap]
* @Return java.lang.String
*/
public String getReturnMsgSubscribe(Map<String, String> decryptMap) {
TextMessage textMessage = new TextMessage();
textMessage.setToUserName(decryptMap.get("FromUserName"));
textMessage.setFromUserName(decryptMap.get("ToUserName"));
textMessage.setCreateTime(System.currentTimeMillis());
textMessage.setMsgType("text");
textMessage.setContent(decryptMap.get("content"));
return getXmlString(textMessage);
}
/**
* @Author Sum1Dream
* @Name getXmlString
* @Description // 处理xml文件
* @Date 16:34 2022/9/21
* @Param [textMessage]
* @Return java.lang.String
*/
public String getXmlString(TextMessage textMessage) {
String xml = "";
if (textMessage != null) {
xml = "<xml>";
xml += "<ToUserName><![CDATA[";
xml += textMessage.getToUserName();
xml += "]]></ToUserName>";
xml += "<FromUserName><![CDATA[";
xml += textMessage.getFromUserName();
xml += "]]></FromUserName>";
xml += "<CreateTime>";
xml += textMessage.getCreateTime();
xml += "</CreateTime>";
xml += "<MsgType><![CDATA[";
xml += textMessage.getMsgType();
xml += "]]></MsgType>";
xml += "<Content><![CDATA[";
xml += textMessage.getContent();
xml += "]]></Content>";
xml += "</xml>";
}
return xml;
}
/**
* @Author Sum1Dream
* @Name paramPars
* @Description // 微信二维码参数解析
* @Date 13:50 2022/9/22
* @Param [param]
* @Return com.alibaba.fastjson.JSONObject
*/
public JSONObject paramPars(String param) {
String[] paramArray = param.split("&");
JSONObject object = new JSONObject();
for (String s : paramArray) {
String[] array = s.split("=");
object.put(array[0] , array[1]);
}
return object;
}
} }

@ -1,6 +1,7 @@
package com.v1.config; package com.v1.config;
import com.hai.config.CommonSysConst; import com.hai.config.CommonSysConst;
import com.hai.model.TextMessage;
import me.chanjar.weixin.mp.api.WxMpService; import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl; import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
import me.chanjar.weixin.mp.config.WxMpConfigStorage; import me.chanjar.weixin.mp.config.WxMpConfigStorage;
@ -8,6 +9,8 @@ import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import java.util.Map;
/** /**
* @serviceName .java * @serviceName .java
* @author Sum1Dream * @author Sum1Dream
@ -48,4 +51,59 @@ public class WxConfig {
wxMpService.setWxMpConfigStorage(wxMpConfigStorage()); wxMpService.setWxMpConfigStorage(wxMpConfigStorage());
return wxMpService; return wxMpService;
} }
/**
* 处理 subscribe 类型的event
*
* @param map
* @param userOpenId
* @return
*/
private String handleEventSubscribe(Map<String, String> map, String userOpenId) {
String resXmlStr = getReturnMsgSubscribe(map);
return resXmlStr;
}
public String getReturnMsgSubscribe(Map<String, String> decryptMap) {
TextMessage textMessage = new TextMessage();
textMessage.setToUserName(decryptMap.get("FromUserName"));
textMessage.setFromUserName(decryptMap.get("ToUserName"));
textMessage.setCreateTime(System.currentTimeMillis());
textMessage.setMsgType("text");
textMessage.setContent("你好,欢迎关注XXX!\n" +
"\n" +
"关注XXX。立即登录PC端网址 \n" +
" 即可完成注册!\n" +
"\n" +
"或," +
"<a href='https://hsgcs.dctpay.com/hsgH5?accountId=000000&gasKey=11000697&staffCode='>点击这里立即完成注册</a>");
return getXmlString(textMessage);
}
public String getXmlString(TextMessage textMessage) {
String xml = "";
if (textMessage != null) {
xml = "<xml>";
xml += "<ToUserName><![CDATA[";
xml += textMessage.getToUserName();
xml += "]]></ToUserName>";
xml += "<FromUserName><![CDATA[";
xml += textMessage.getFromUserName();
xml += "]]></FromUserName>";
xml += "<CreateTime>";
xml += textMessage.getCreateTime();
xml += "</CreateTime>";
xml += "<MsgType><![CDATA[";
xml += textMessage.getMsgType();
xml += "]]></MsgType>";
xml += "<Content><![CDATA[";
xml += textMessage.getContent();
xml += "]]></Content>";
xml += "</xml>";
}
return xml;
}
} }

@ -9,8 +9,10 @@ import com.hai.common.pay.util.XmlUtil;
import com.hai.common.utils.HttpsUtils; import com.hai.common.utils.HttpsUtils;
import com.hai.common.utils.ResponseMsgUtil; import com.hai.common.utils.ResponseMsgUtil;
import com.hai.common.utils.WxUtils; import com.hai.common.utils.WxUtils;
import com.hai.config.CommonSysConst;
import com.hai.model.HighMerchantStoreModel;
import com.hai.model.ResponseData; import com.hai.model.ResponseData;
import com.hai.service.CommonService; import com.hai.service.HighMerchantStoreService;
import com.v1.config.SysConst; import com.v1.config.SysConst;
import com.v1.config.WeChatQrcodeUtils; import com.v1.config.WeChatQrcodeUtils;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
@ -29,9 +31,11 @@ import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import java.util.SortedMap; import java.util.SortedMap;
/** /**
@ -48,12 +52,39 @@ public class WxMsgController {
@Autowired @Autowired
private WeChatQrcodeUtils weChatQrcodeUtils; private WeChatQrcodeUtils weChatQrcodeUtils;
@Resource
private HighMerchantStoreService merchantStoreService;
@RequestMapping(value = "/verifyWxToken", method = RequestMethod.GET) @RequestMapping(value = "/verifyWxToken", method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ApiOperation(value = "验证servlet") @ApiOperation(value = "验证servlet")
public String verifyWxToken(HttpServletRequest request) { public String verifyWxToken(
@RequestParam(name = "signature", required = false) String signature,
@RequestParam(name = "timestamp", required = false) String timestamp,
@RequestParam(name = "nonce", required = false) String nonce,
@RequestParam(name = "echostr", required = false) String echostr
) {
try {
String signatureStr = WxUtils.getSHA1("RgAWdnR5oEOLBdyEjfr4" , timestamp , nonce);
log.info("signatureStr!!!!!" + signatureStr);
log.info("signature!!!!!" + signature);
if (signature.equals(signatureStr)) {
log.info("验证通过!!!!!");
return echostr;
}
log.info("验证失败!!!!!");
return null;
} catch (Exception e) {
return null;
}
}
@RequestMapping(value = "/verifyWxToken", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "验证servlet")
public void verifyWxToken(HttpServletRequest request , HttpServletResponse response) {
try { try {
log.info("进入公众号!!!!!!!"); log.info("进入公众号!!!!!!!");
@ -63,19 +94,96 @@ public class WxMsgController {
String notifyXml; String notifyXml;
notifyXml = IOUtil.inputStreamToString(request.getInputStream(), "UTF-8"); notifyXml = IOUtil.inputStreamToString(request.getInputStream(), "UTF-8");
log.info("微信支付系统发送的数据:" + notifyXml); log.info("微信系统发送的数据:" + notifyXml);
SortedMap<String, String> map = XmlUtil.parseXmlToTreeMap(notifyXml, "UTF-8"); SortedMap<String, String> map = XmlUtil.parseXmlToTreeMap(notifyXml, "UTF-8");
// openId
String userOpenId = map.get("FromUserName");
// 微信账号
String userName = map.get("ToUserName");
// 事件
String event = map.get("Event");
// 区分消息类型 // 区分消息类型
String msgType = map.get("MsgType"); String msgType = map.get("MsgType");
log.info("微信支付系统发送的数据:" + msgType); // 二维码参数
return null; String eventKey = map.get("EventKey");
String linkContent;
String content = null;
if (eventKey != null && eventKey.length() != 0) {
JSONObject object = weChatQrcodeUtils.paramPars(eventKey);
// type = 1 推广扫码 type = 2
if (Objects.equals(object.getString("qrscene_type"), "1") || Objects.equals(object.getString("type"), "1")) {
linkContent = "<a href='" + CommonSysConst.getSysConfig().getHsgDomainName() + "/hsgH5?accountId=0000010&key=&code=" + object.getString("code") + "'>点击查看更多优惠</a>\n\n";
} else {
// 商户门店
HighMerchantStoreModel store = merchantStoreService.getMerchantStoreByKey(object.getString("code"));
linkContent = "<a href='"+CommonSysConst.getSysConfig().getHsgDomainName()+"/hsgH5?accountId=000000&gasKey=" + object.getString("code") + "&staffCode='>欢迎来到" + store.getStoreName()+"</a>" + "[哇][哇][哇]\n\n<a href='"+CommonSysConst.getSysConfig().getHsgDomainName()+"/hsgH5?accountId=000000&gasKey=" + object.getString("code") + "&staffCode='>点击这里一键加油</a>\n\n";
}
} else {
linkContent = "<a href='" + CommonSysConst.getSysConfig().getHsgDomainName() + "/hsgH5'>点击查看更多优惠</a>\n\n";
}
log.info("二维码参数:" + eventKey);
// 普通消息
if ("text".equals(msgType)) {
// todo 处理文本消息
} else if ("image".equals(msgType)) {
// todo 处理图片消息
} else if ("voice".equals(msgType)) {
// todo 处理语音消息
} else if ("video".equals(msgType)) {
// todo 处理视频消息
}
// 事件推送消息
else if ("event".equals(msgType)) {
// 用户关注公众号
if ("subscribe".equals(event)) {
log.info("进入扫码关注流程:" + event);
// todo 业务处理
content =
"终于等到你,还好我没放弃[玫瑰][玫瑰][玫瑰]\n\n" +
"您好,感谢关注嗨森逛商城!\n\n" +
linkContent +
"在线等你来撩~[哇][哇][哇]\n\n" +
"特意为您奉上" +
"<a href='" + CommonSysConst.getSysConfig().getHsgDomainName() + "/hsgH5'>5张优惠券</a>" +
",放在您的"+
"<a href='" + CommonSysConst.getSysConfig().getHsgDomainName() + "/hsgH5'>优惠券</a>"+
"里面,记得及时使用哦[爱心][爱心][爱心]\n\n" +
"【如遇任何问题请致电客服:400-678-0738】"
;
// todo 业务处理
}
// 用户扫码进入公众号
else if ("SCAN".equals(event)) {
// todo 业务处理
content =
"油价很贵,诗和远方也很贵[可怜]\n\n" +
"“一键加油”有”油“惠[红包][红包][红包]\n\n" +
linkContent +
"多重好礼为您助力\n\n" +
"加油的时候少点心疼,踩油门的时候多点豪横![得意][得意][得意]\n\n" +
"【如遇任何问题请致电客服:400-678-0738】"
;
}else if ("unsubscribe".equals(event)) {
// todo 取消关注 业务处理
}
map.put("content" , content);
String mapToXml = weChatQrcodeUtils.handleEventSubscribe(map);
response.setCharacterEncoding("UTF-8");
response.getWriter().print(mapToXml);
}
} catch (Exception e) { } catch (Exception e) {
return null; // return null;
} }
} }
@RequestMapping(value = "/getWxToken", method = RequestMethod.POST) @RequestMapping(value = "/getWxToken", method = RequestMethod.POST)
@ResponseBody @ResponseBody
@ApiOperation(value = "获取微信token") @ApiOperation(value = "获取微信token")
@ -110,9 +218,15 @@ public class WxMsgController {
@RequestMapping(value = "/createQrcode", method = RequestMethod.GET) @RequestMapping(value = "/createQrcode", method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ApiOperation(value = "创建生成二维码") @ApiOperation(value = "创建生成二维码")
public ResponseData createQrcode(@RequestParam(name = "sceneId", required = false) Integer sceneId) { public ResponseData createQrcode(@RequestParam(name = "type", required = false) String type,
@RequestParam(name = "code", required = false) String code) {
try { try {
return ResponseMsgUtil.success(weChatQrcodeUtils.qrCodeCreateLastTicket(sceneId));
String sceneId = "type=" + type + "&code=" + code;
String ticket = weChatQrcodeUtils.qrCodeCreateLastTicket(sceneId).getTicket();
return ResponseMsgUtil.success(weChatQrcodeUtils.qrCodePictureUrl(ticket));
} catch (WxErrorException e) { } catch (WxErrorException e) {
return ResponseMsgUtil.exception(e); return ResponseMsgUtil.exception(e);
} }

@ -0,0 +1,2 @@
wxH5AppId=wxa075e8509802f826
wxH5AppSecret=0e606fc1378d35e359fcf3f15570b2c5
Loading…
Cancel
Save