|
|
|
@ -1,6 +1,5 @@ |
|
|
|
|
package com.v1.controller; |
|
|
|
|
|
|
|
|
|
import com.alibaba.druid.sql.visitor.functions.If; |
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
import com.hai.common.exception.ErrorCode; |
|
|
|
|
import com.hai.common.exception.ErrorHelp; |
|
|
|
@ -9,11 +8,9 @@ import com.hai.common.pay.util.IOUtil; |
|
|
|
|
import com.hai.common.pay.util.XmlUtil; |
|
|
|
|
import com.hai.common.utils.HttpsUtils; |
|
|
|
|
import com.hai.common.utils.ResponseMsgUtil; |
|
|
|
|
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.TextMessage; |
|
|
|
|
import com.hai.service.HighMerchantStoreService; |
|
|
|
|
import com.v1.config.SysConst; |
|
|
|
|
import com.v1.config.WeChatQrcodeUtils; |
|
|
|
@ -30,18 +27,11 @@ import org.springframework.web.bind.annotation.RequestMapping; |
|
|
|
|
import org.springframework.web.bind.annotation.RequestMethod; |
|
|
|
|
import org.springframework.web.bind.annotation.RequestParam; |
|
|
|
|
import org.springframework.web.bind.annotation.ResponseBody; |
|
|
|
|
import org.w3c.dom.Document; |
|
|
|
|
import org.w3c.dom.Element; |
|
|
|
|
import org.xml.sax.InputSource; |
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
|
import javax.xml.parsers.DocumentBuilder; |
|
|
|
|
import javax.xml.parsers.DocumentBuilderFactory; |
|
|
|
|
|
|
|
|
|
import java.io.BufferedOutputStream; |
|
|
|
|
import java.io.StringReader; |
|
|
|
|
import java.util.HashMap; |
|
|
|
|
import java.util.Map; |
|
|
|
|
import java.util.Objects; |
|
|
|
@ -64,7 +54,32 @@ public class WxMsgController { |
|
|
|
|
@Resource |
|
|
|
|
private HighMerchantStoreService merchantStoreService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// @RequestMapping(value = "/verifyWxToken", method = RequestMethod.GET)
|
|
|
|
|
// @ResponseBody
|
|
|
|
|
// @ApiOperation(value = "验证servlet")
|
|
|
|
|
// 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") |
|
|
|
@ -93,18 +108,18 @@ public class WxMsgController { |
|
|
|
|
String eventKey = map.get("EventKey"); |
|
|
|
|
String linkContent; |
|
|
|
|
String content = null; |
|
|
|
|
if (eventKey != null) { |
|
|
|
|
if (eventKey != null && eventKey.length() != 0) { |
|
|
|
|
JSONObject object = weChatQrcodeUtils.paramPars(eventKey); |
|
|
|
|
// type = 1 推广扫码 type = 2
|
|
|
|
|
if (Objects.equals(object.getString("qrscene_type"), "1")) { |
|
|
|
|
linkContent = "<a href='" + CommonSysConst.getSysConfig().getHsgDomainName() + "/hsgH5?accountId=0000010&key=&code=" + object.getString("code") + "'>点击注册</a>\n\n"; |
|
|
|
|
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 = "欢迎来到" + store.getStoreName() + "[哇][哇][哇]\n\n<a href='"+CommonSysConst.getSysConfig().getHsgDomainName()+"/hsgH5?accountId=000000&gasKey=" + object.getString("code") + "&staffCode='>点击这里一键加油</a>\n\n"; |
|
|
|
|
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"; |
|
|
|
|
linkContent = "<a href='" + CommonSysConst.getSysConfig().getHsgDomainName() + "/hsgH5'>点击查看更多优惠</a>\n\n"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
log.info("二维码参数:" + eventKey); |
|
|
|
@ -132,7 +147,7 @@ public class WxMsgController { |
|
|
|
|
"特意为您奉上" + |
|
|
|
|
"<a href='" + CommonSysConst.getSysConfig().getHsgDomainName() + "/hsgH5'>5张优惠券</a>" + |
|
|
|
|
",放在您的"+ |
|
|
|
|
"<a href='" + CommonSysConst.getSysConfig().getHsgDomainName() + "/hsgH5'>卡包</a>"+ |
|
|
|
|
"<a href='" + CommonSysConst.getSysConfig().getHsgDomainName() + "/hsgH5'>我的优惠券</a>"+ |
|
|
|
|
"里面,记得及时使用哦[爱心][爱心][爱心]\n\n" + |
|
|
|
|
"【如遇任何问题请致电客服:400-678-0738】" |
|
|
|
|
; |
|
|
|
@ -204,7 +219,10 @@ public class WxMsgController { |
|
|
|
|
@ApiOperation(value = "创建生成二维码") |
|
|
|
|
public ResponseData createQrcode(@RequestParam(name = "sceneId", required = false) String sceneId) { |
|
|
|
|
try { |
|
|
|
|
return ResponseMsgUtil.success(weChatQrcodeUtils.qrCodeCreateLastTicket(sceneId)); |
|
|
|
|
|
|
|
|
|
String ticket = weChatQrcodeUtils.qrCodeCreateLastTicket(sceneId).getTicket(); |
|
|
|
|
|
|
|
|
|
return ResponseMsgUtil.success(weChatQrcodeUtils.qrCodePictureUrl(ticket)); |
|
|
|
|
} catch (WxErrorException e) { |
|
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
|
} |
|
|
|
|