|
|
@ -1,23 +1,30 @@ |
|
|
|
package com.v1.controller; |
|
|
|
package com.v1.controller; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
|
|
|
import com.google.zxing.BinaryBitmap; |
|
|
|
|
|
|
|
import com.google.zxing.DecodeHintType; |
|
|
|
|
|
|
|
import com.google.zxing.Result; |
|
|
|
|
|
|
|
import com.google.zxing.client.j2se.BufferedImageLuminanceSource; |
|
|
|
|
|
|
|
import com.google.zxing.common.HybridBinarizer; |
|
|
|
|
|
|
|
import com.google.zxing.qrcode.QRCodeReader; |
|
|
|
|
|
|
|
import com.hai.common.Base64Util; |
|
|
|
import com.hai.common.exception.ErrorCode; |
|
|
|
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.pay.util.IOUtil; |
|
|
|
import com.hai.common.pay.util.IOUtil; |
|
|
|
import com.hai.common.pay.util.XmlUtil; |
|
|
|
import com.hai.common.pay.util.XmlUtil; |
|
|
|
import com.hai.common.utils.HttpsUtils; |
|
|
|
import com.hai.common.security.AESEncodeUtil; |
|
|
|
import com.hai.common.utils.RedisUtil; |
|
|
|
import com.hai.common.utils.*; |
|
|
|
import com.hai.common.utils.ResponseMsgUtil; |
|
|
|
|
|
|
|
import com.hai.common.utils.WxUtils; |
|
|
|
|
|
|
|
import com.hai.config.CommonSysConst; |
|
|
|
import com.hai.config.CommonSysConst; |
|
|
|
|
|
|
|
import com.hai.config.WeChatQrcodeUtils; |
|
|
|
import com.hai.entity.HighUser; |
|
|
|
import com.hai.entity.HighUser; |
|
|
|
|
|
|
|
import com.hai.enum_type.WxQrCodeTypeEnum; |
|
|
|
import com.hai.model.HighMerchantStoreModel; |
|
|
|
import com.hai.model.HighMerchantStoreModel; |
|
|
|
import com.hai.model.ResponseData; |
|
|
|
import com.hai.model.ResponseData; |
|
|
|
import com.hai.service.HighMerchantStoreService; |
|
|
|
import com.hai.service.HighMerchantStoreService; |
|
|
|
import com.hai.service.HighUserService; |
|
|
|
import com.hai.service.HighUserService; |
|
|
|
import com.v1.config.SysConst; |
|
|
|
import com.v1.config.SysConst; |
|
|
|
import com.v1.config.WeChatQrcodeUtils; |
|
|
|
|
|
|
|
import io.swagger.annotations.Api; |
|
|
|
import io.swagger.annotations.Api; |
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
|
|
|
|
|
|
|
@ -27,24 +34,28 @@ import org.slf4j.LoggerFactory; |
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Controller; |
|
|
|
import org.springframework.stereotype.Controller; |
|
|
|
import org.springframework.web.bind.annotation.RequestMapping; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
import org.springframework.web.bind.annotation.RequestMethod; |
|
|
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestParam; |
|
|
|
|
|
|
|
import org.springframework.web.bind.annotation.ResponseBody; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import javax.annotation.Resource; |
|
|
|
|
|
|
|
import javax.imageio.ImageIO; |
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.awt.image.BufferedImage; |
|
|
|
|
|
|
|
import java.io.*; |
|
|
|
|
|
|
|
import java.net.HttpURLConnection; |
|
|
|
|
|
|
|
import java.net.URL; |
|
|
|
import java.util.*; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import static org.apache.catalina.manager.Constants.CHARSET; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @author sum1dream |
|
|
|
* @author sum1dream |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
@Controller |
|
|
|
@Controller |
|
|
|
@RequestMapping(value = "/wxMsg") |
|
|
|
@RequestMapping(value = "/wxMsg") |
|
|
|
@Api(value = "自建站接口") |
|
|
|
@Api(value = "微信") |
|
|
|
public class WxMsgController { |
|
|
|
public class WxMsgController { |
|
|
|
|
|
|
|
|
|
|
|
private static Logger log = LoggerFactory.getLogger(ThirdPartyController.class); |
|
|
|
private static Logger log = LoggerFactory.getLogger(ThirdPartyController.class); |
|
|
@ -97,10 +108,9 @@ public class WxMsgController { |
|
|
|
// 微信支付系统发送的数据(<![CDATA[product_001]]>格式)
|
|
|
|
// 微信支付系统发送的数据(<![CDATA[product_001]]>格式)
|
|
|
|
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"); |
|
|
|
|
|
|
|
Map<String,Object> mapQrCode = new HashMap<>(); |
|
|
|
// openId
|
|
|
|
// openId
|
|
|
|
String userOpenId = map.get("FromUserName"); |
|
|
|
String userOpenId = map.get("FromUserName"); |
|
|
|
// 微信账号
|
|
|
|
// 微信账号
|
|
|
@ -111,40 +121,109 @@ public class WxMsgController { |
|
|
|
String msgType = map.get("MsgType"); |
|
|
|
String msgType = map.get("MsgType"); |
|
|
|
// 二维码参数
|
|
|
|
// 二维码参数
|
|
|
|
String eventKey = map.get("EventKey"); |
|
|
|
String eventKey = map.get("EventKey"); |
|
|
|
|
|
|
|
log.info("二维码参数:" + eventKey); |
|
|
|
// 判断用户是否是新用户
|
|
|
|
// 判断用户是否是新用户
|
|
|
|
HighUser user = highUserService.findByOpenIdH5(userOpenId); |
|
|
|
HighUser user = highUserService.findByOpenIdH5(userOpenId); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String linkContent = ""; |
|
|
|
String linkContent = null; |
|
|
|
String newUserContent = ""; |
|
|
|
String newUserContent = null; |
|
|
|
String content = ""; |
|
|
|
String content = null; |
|
|
|
|
|
|
|
if (eventKey != null && eventKey.length() != 0) { |
|
|
|
if (eventKey != null && eventKey.length() != 0) { |
|
|
|
JSONObject object = weChatQrcodeUtils.paramPars(eventKey); |
|
|
|
JSONObject object = weChatQrcodeUtils.paramPars(eventKey); |
|
|
|
// type = 1 推广扫码 type = 2 商户门店 3:查看视频教程 4:支付扫码
|
|
|
|
// type = 1 推广扫码
|
|
|
|
if (Objects.equals(object.getString("qrscene_type"), "1") || Objects.equals(object.getString("type"), "1")) { |
|
|
|
if (Objects.equals(object.getString("qrscene_type"), WxQrCodeTypeEnum.type1.getType()) || Objects.equals(object.getString("type"), WxQrCodeTypeEnum.type1.getType())) { |
|
|
|
linkContent = "<a href='" + CommonSysConst.getSysConfig().getHsgDomainName() + "/hsgH5?accountId=0000010&key=&code=" + object.getString("code") + "'>点击查看更多优惠</a>\n\n"; |
|
|
|
// todo 推广扫码
|
|
|
|
} else if (Objects.equals(object.getString("qrscene_type"), "2") || Objects.equals(object.getString("type"), "2")){ |
|
|
|
} |
|
|
|
|
|
|
|
// type = 2 在线加油门店扫码
|
|
|
|
|
|
|
|
if (Objects.equals(object.getString("qrscene_type"), WxQrCodeTypeEnum.type2.getType()) || Objects.equals(object.getString("type"), WxQrCodeTypeEnum.type2.getType())){ |
|
|
|
// 商户门店
|
|
|
|
// 商户门店
|
|
|
|
HighMerchantStoreModel store = merchantStoreService.getMerchantStoreByKey(object.getString("code")); |
|
|
|
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"; |
|
|
|
linkContent = |
|
|
|
} else if (Objects.equals(object.getString("qrscene_type"), "3") || Objects.equals(object.getString("type"), "3")){ |
|
|
|
"<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"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 3:查看视频教程
|
|
|
|
|
|
|
|
if (Objects.equals(object.getString("qrscene_type"), WxQrCodeTypeEnum.type3.getType()) || Objects.equals(object.getString("type"), WxQrCodeTypeEnum.type3.getType())){ |
|
|
|
|
|
|
|
// 重庆
|
|
|
|
|
|
|
|
if ( Objects.equals(object.getString("code"), "1")) { |
|
|
|
|
|
|
|
linkContent = |
|
|
|
|
|
|
|
"加油优惠选我们,你的出行不再忧愁\uD83D\uDC97\n\n" |
|
|
|
|
|
|
|
+ "<a href='https://mp.weixin.qq.com/s/qKUny68yCU4_6jBdNb1OVg'>查看中石油操作流程</a>\n\n" |
|
|
|
|
|
|
|
+ "走得更远,看得更美的风景,加油添生活![太阳]\n\n" |
|
|
|
|
|
|
|
+ "好车要好油,优惠更加牛![發]\n\n"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 贵州
|
|
|
|
|
|
|
|
if (Objects.equals(object.getString("code"), "2")) { |
|
|
|
|
|
|
|
linkContent = |
|
|
|
|
|
|
|
"加满好油,一路畅游!✨✨\n\n" |
|
|
|
|
|
|
|
+ "<a href='https://mp.weixin.qq.com/s/qKUny68yCU4_6jBdNb1OVg'>查看中石化操作流程</a>\n\n" |
|
|
|
|
|
|
|
+ "用心为您着想,诚意为您服务。\uD83C\uDF39\n\n" |
|
|
|
|
|
|
|
+ "油客来自五湖四海,在这里祝您一路顺风。\n\n"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 4:支付码牌扫码
|
|
|
|
|
|
|
|
if (Objects.equals(object.getString("qrscene_type"), WxQrCodeTypeEnum.type4.getType()) || Objects.equals(object.getString("type"), WxQrCodeTypeEnum.type4.getType())){ |
|
|
|
|
|
|
|
// todo 支付扫码
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 5:扫码贵州中石化优惠券二维码
|
|
|
|
|
|
|
|
if (Objects.equals(object.getString("qrscene_type"), WxQrCodeTypeEnum.type5.getType()) || Objects.equals(object.getString("type"), WxQrCodeTypeEnum.type5.getType())){ |
|
|
|
|
|
|
|
mapQrCode.put("type", object.getString("encryptType")); |
|
|
|
|
|
|
|
// 二维码参数
|
|
|
|
|
|
|
|
mapQrCode.put("id", object.getString("code")); |
|
|
|
|
|
|
|
log.info("map参数:" + mapQrCode); |
|
|
|
|
|
|
|
// 商户门店
|
|
|
|
|
|
|
|
linkContent = |
|
|
|
|
|
|
|
"山高水远,相伴致远[爱心][爱心]\n\n" |
|
|
|
|
|
|
|
+ "<a href='" |
|
|
|
|
|
|
|
+ "https://hsgcs.dctpay.com" |
|
|
|
|
|
|
|
// + CommonSysConst.getSysConfig().getHsgDomainName()
|
|
|
|
|
|
|
|
+ "/hsgH5?accountId=0000011&key=&code=" |
|
|
|
|
|
|
|
+ Base64Util.encode(AESEncodeUtil.aesEncrypt(JSON.toJSONString(mapQrCode))) |
|
|
|
|
|
|
|
+ "'>领取中石化加油券</a>\n\n" |
|
|
|
|
|
|
|
+ "您追求实惠的折扣,我们追求高超的品质\uD83D\uDD16\n\n" |
|
|
|
|
|
|
|
+ "迎南来北往宾朋尊驾,[福]\n\n" |
|
|
|
|
|
|
|
+ "送平安顺遂诚意祝福![福]\n\n"; |
|
|
|
|
|
|
|
log.info("地址参数:" + linkContent); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 6:扫码重庆中石油优惠券二维码
|
|
|
|
|
|
|
|
if (Objects.equals(object.getString("qrscene_type"), WxQrCodeTypeEnum.type6.getType()) || Objects.equals(object.getString("type"), WxQrCodeTypeEnum.type6.getType())){ |
|
|
|
|
|
|
|
mapQrCode.put("type", object.getString("encryptType")); |
|
|
|
|
|
|
|
// 二维码参数
|
|
|
|
|
|
|
|
mapQrCode.put("id", object.getString("code")); |
|
|
|
|
|
|
|
log.info("map参数:" + mapQrCode); |
|
|
|
// 商户门店
|
|
|
|
// 商户门店
|
|
|
|
linkContent = "<a href='https://mp.weixin.qq.com/s/qKUny68yCU4_6jBdNb1OVg'>点击查看重庆中石油视频教程</a>" + |
|
|
|
linkContent = |
|
|
|
"[哇][哇][哇]\n\n<a href='https://mp.weixin.qq.com/s/qKUny68yCU4_6jBdNb1OVg'>点击查看贵州中石化视频教程</a>\n\n"; |
|
|
|
"加好油,添好运,我们更适意[礼物]\n\n" |
|
|
|
|
|
|
|
+ "<a href='" |
|
|
|
|
|
|
|
+ "https://hsgcs.dctpay.com" |
|
|
|
|
|
|
|
// + CommonSysConst.getSysConfig().getHsgDomainName()
|
|
|
|
|
|
|
|
+ "/hsgH5?accountId=0000011&key=&code=" |
|
|
|
|
|
|
|
+ Base64Util.encode(AESEncodeUtil.aesEncrypt(JSON.toJSONString(mapQrCode))) |
|
|
|
|
|
|
|
+ "'>领取中石油加油券</a>\n\n" |
|
|
|
|
|
|
|
+ "致力于质量与福利,赢得客户心。\n\n" |
|
|
|
|
|
|
|
+ "一路精彩,“油”我相伴!\uD83C\uDF1F\n\n"; |
|
|
|
|
|
|
|
log.info("地址参数:" + linkContent); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
linkContent = "<a href='" + CommonSysConst.getSysConfig().getHsgDomainName() + "/hsgH5'>点击查看更多优惠</a>\n\n"; |
|
|
|
linkContent = "<a href='" + CommonSysConst.getSysConfig().getHsgDomainName() + "/hsgH5'>点击查看更多优惠</a>\n\n"; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 判断是否是新用户
|
|
|
|
// 判断是否是新用户
|
|
|
|
if (user == null) { |
|
|
|
// if (user == null) {
|
|
|
|
newUserContent = "特意为您奉上" + |
|
|
|
// newUserContent = "特意为您奉上" +
|
|
|
|
"<a href='" + CommonSysConst.getSysConfig().getHsgDomainName() + "/hsgH5'>5张优惠券</a>" + |
|
|
|
// "<a href='" + CommonSysConst.getSysConfig().getHsgDomainName() + "/hsgH5'>5张优惠券</a>" +
|
|
|
|
",放在您的"+ |
|
|
|
// ",放在您的"+
|
|
|
|
"<a href='" + CommonSysConst.getSysConfig().getHsgDomainName() + "/hsgH5'>优惠券</a>"+ |
|
|
|
// "<a href='" + CommonSysConst.getSysConfig().getHsgDomainName() + "/hsgH5'>优惠券</a>"+
|
|
|
|
"里面,记得及时使用哦[爱心][爱心][爱心]\n\n"; |
|
|
|
// "里面,记得及时使用哦[爱心][爱心][爱心]\n\n";
|
|
|
|
} |
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
log.info("二维码参数:" + eventKey); |
|
|
|
log.info("二维码参数:" + eventKey); |
|
|
@ -163,29 +242,16 @@ public class WxMsgController { |
|
|
|
// 用户关注公众号
|
|
|
|
// 用户关注公众号
|
|
|
|
if ("subscribe".equals(event)) { |
|
|
|
if ("subscribe".equals(event)) { |
|
|
|
log.info("进入扫码关注流程:" + event); |
|
|
|
log.info("进入扫码关注流程:" + event); |
|
|
|
// todo 业务处理
|
|
|
|
|
|
|
|
content = |
|
|
|
content = |
|
|
|
"终于等到你,还好我没放弃[玫瑰][玫瑰][玫瑰]\n\n" + |
|
|
|
|
|
|
|
"您好,感谢关注嗨森逛商城!\n\n" + |
|
|
|
"您好,感谢关注嗨森逛商城!\n\n" + |
|
|
|
linkContent + |
|
|
|
linkContent + |
|
|
|
"在线等你来撩~[哇][哇][哇]\n\n" + newUserContent + |
|
|
|
"服务热线:400-023-6806" |
|
|
|
"【如遇任何问题请致电客服:400-678-0738】" |
|
|
|
|
|
|
|
; |
|
|
|
; |
|
|
|
// todo 业务处理
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
// 用户扫码进入公众号
|
|
|
|
// 用户扫码进入公众号
|
|
|
|
else if ("SCAN".equals(event)) { |
|
|
|
else if ("SCAN".equals(event)) { |
|
|
|
// todo 业务处理
|
|
|
|
content = linkContent + "服务热线:400-023-6806"; |
|
|
|
content = |
|
|
|
|
|
|
|
"油价很贵,诗和远方也很贵[可怜]\n\n" + |
|
|
|
|
|
|
|
"“一键加油”有”油“惠[红包][红包][红包]\n\n" + |
|
|
|
|
|
|
|
linkContent + |
|
|
|
|
|
|
|
"多重好礼为您助力\n\n" + |
|
|
|
|
|
|
|
"加油的时候少点心疼,踩油门的时候多点豪横![得意][得意][得意]\n\n" + |
|
|
|
|
|
|
|
"【如遇任何问题请致电客服:400-678-0738】" |
|
|
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}else if ("unsubscribe".equals(event)) { |
|
|
|
}else if ("unsubscribe".equals(event)) { |
|
|
|
// todo 取消关注 业务处理
|
|
|
|
// todo 取消关注 业务处理
|
|
|
@ -194,6 +260,7 @@ public class WxMsgController { |
|
|
|
String mapToXml = weChatQrcodeUtils.handleEventSubscribe(map); |
|
|
|
String mapToXml = weChatQrcodeUtils.handleEventSubscribe(map); |
|
|
|
response.setCharacterEncoding("UTF-8"); |
|
|
|
response.setCharacterEncoding("UTF-8"); |
|
|
|
response.getWriter().print(mapToXml); |
|
|
|
response.getWriter().print(mapToXml); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
// return null;
|
|
|
|
// return null;
|
|
|
@ -241,12 +308,38 @@ public class WxMsgController { |
|
|
|
@RequestParam(name = "code", required = false) String code) { |
|
|
|
@RequestParam(name = "code", required = false) String code) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
|
|
|
|
|
|
|
|
String sceneId = "type=" + type + "&code=" + code; |
|
|
|
String jsonData; |
|
|
|
|
|
|
|
String sceneId; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (Objects.equals(type, "5")) { |
|
|
|
|
|
|
|
jsonData = AESEncodeUtil.aesDecrypt(Base64Util.decode(code)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JSONObject jsonObject = JSON.parseObject(jsonData); |
|
|
|
|
|
|
|
Long id = jsonObject.getLong("id"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sceneId = "type=" + type + "&code=" + id; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
sceneId = "type=" + type + "&code=" + code; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
String ticket = weChatQrcodeUtils.qrCodeCreateLastTicket(sceneId).getTicket(); |
|
|
|
String ticket = weChatQrcodeUtils.qrCodeCreateLastTicket(sceneId).getTicket(); |
|
|
|
|
|
|
|
|
|
|
|
return ResponseMsgUtil.success(weChatQrcodeUtils.qrCodePictureUrl(ticket)); |
|
|
|
return ResponseMsgUtil.success(weChatQrcodeUtils.qrCodePictureUrl(ticket)); |
|
|
|
} catch (WxErrorException e) { |
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/qrCodeImgUrl", method = RequestMethod.GET) |
|
|
|
|
|
|
|
@ResponseBody |
|
|
|
|
|
|
|
@ApiOperation(value = "二维码地址解析") |
|
|
|
|
|
|
|
public ResponseData qrCodeImgUrl(@RequestParam(name = "type", required = false) String type, |
|
|
|
|
|
|
|
@RequestParam(name = "code", required = false) String code) { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ResponseMsgUtil.success(weChatQrcodeUtils.qrCodeImgUrl(type , code , "DISCOUNT")); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -361,4 +454,30 @@ public class WxMsgController { |
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/createMenu", method = RequestMethod.POST) |
|
|
|
|
|
|
|
@ResponseBody |
|
|
|
|
|
|
|
@ApiOperation(value = "创建菜单") |
|
|
|
|
|
|
|
public ResponseData createMenu(@RequestBody JSONObject object) { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
Map<String, Object> params = new HashMap<>(); |
|
|
|
|
|
|
|
params.put("appid", SysConst.getSysConfig().getWxH5AppId()); |
|
|
|
|
|
|
|
params.put("secret", SysConst.getSysConfig().getWxH5AppSecret()); |
|
|
|
|
|
|
|
params.put("grant_type", "client_credential"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JSONObject accessTokenObject = HttpsUtils.doGet("https://api.weixin.qq.com/cgi-bin/token", params); |
|
|
|
|
|
|
|
if (accessTokenObject == null) { |
|
|
|
|
|
|
|
log.error("getH5UserInfo error!", "获取微信access_token失败" ); |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "获取微信access_token失败"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JSONObject jsonObject = HttpsUtils.doPost("https://api.weixin.qq.com/cgi-bin/menu/create?access_token=" + accessTokenObject.getString("access_token"), object); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ResponseMsgUtil.success(jsonObject); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|