|
@@ -1,6 +1,7 @@
|
|
|
package com.iamberry.wechat.service.wechat;
|
|
|
|
|
|
import com.iamberry.app.tool.log.RatFWLogger;
|
|
|
+import com.iamberry.wechat.core.entity.channel.AttenStatistics;
|
|
|
import com.iamberry.wechat.core.entity.drp.PlaceInfo;
|
|
|
import com.iamberry.wechat.core.entity.member.Member;
|
|
|
import com.iamberry.wechat.core.entity.qrcode.Qrcode;
|
|
@@ -8,6 +9,7 @@ import com.iamberry.wechat.core.entity.qrcode.TemporaryQrcode;
|
|
|
import com.iamberry.wechat.core.entity.wx.*;
|
|
|
import com.iamberry.wechat.face.activity.ActivityService;
|
|
|
import com.iamberry.wechat.face.admin.SystemService;
|
|
|
+import com.iamberry.wechat.face.channel.AttenStatisticsService;
|
|
|
import com.iamberry.wechat.face.drp.PlaceInfoService;
|
|
|
import com.iamberry.wechat.face.home.HomeService;
|
|
|
import com.iamberry.wechat.face.machineNumber.MachineNumberService;
|
|
@@ -73,6 +75,9 @@ public class WeChatServiceImpl implements WeChatService {
|
|
|
private MachineNumberService machineNumberService;
|
|
|
@Autowired
|
|
|
private ActivityService activityService;
|
|
|
+ @Autowired
|
|
|
+ private AttenStatisticsService attenStatisticsService;
|
|
|
+
|
|
|
/**
|
|
|
* 处理微信发来的请求
|
|
|
* @param FromUserName
|
|
@@ -164,6 +169,12 @@ public class WeChatServiceImpl implements WeChatService {
|
|
|
String eventType = requestMap.get("Event");// 事件类型
|
|
|
String eventKey = requestMap.get("EventKey");
|
|
|
|
|
|
+ for(String s:requestMap.keySet()){
|
|
|
+ logger.info("===事件推送:" + s +"="+ requestMap.get(s));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // 事件列表:CLICK(点击自定义菜单)/subscribe(关注)/unsubscribe(取消关注)/SCAN(扫描二维码)/LOCATION(上报地理位置)
|
|
|
if(eventType.equals("SCAN")){
|
|
|
|
|
|
//扫描机器二维码返回跳转到完善信息页面
|
|
@@ -179,6 +190,12 @@ public class WeChatServiceImpl implements WeChatService {
|
|
|
return status.getCountext();
|
|
|
}
|
|
|
respContent = status.getCountext();
|
|
|
+ }else if(eventKey.indexOf(ResultInfo.barCodeMainChannelId) != -1){
|
|
|
+ Status status = bindingMainChannelId(requestMap, fromUserName,false);
|
|
|
+ if (status.isFlag()) {
|
|
|
+ return status.getCountext();
|
|
|
+ }
|
|
|
+ respContent = status.getCountext();
|
|
|
} else {
|
|
|
// 已关注用户扫描二维码事件
|
|
|
int flag = subUserScannQrcodeEvent(requestMap, fromUserName);
|
|
@@ -216,6 +233,12 @@ public class WeChatServiceImpl implements WeChatService {
|
|
|
return status.getCountext();
|
|
|
}
|
|
|
respContent = status.getCountext();
|
|
|
+ }else if(eventKey.indexOf(ResultInfo.barCodeMainChannelId) != -1){
|
|
|
+ Status status = bindingMainChannelId(requestMap, fromUserName,false);
|
|
|
+ if (status.isFlag()) {
|
|
|
+ return status.getCountext();
|
|
|
+ }
|
|
|
+ respContent = status.getCountext();
|
|
|
} else {
|
|
|
//未关注用户扫描二维码关注事件处理
|
|
|
Status status = scannQRcodeSub(requestMap, fromUserName);
|
|
@@ -279,7 +302,6 @@ public class WeChatServiceImpl implements WeChatService {
|
|
|
senceid = senceid.replaceAll(ResultInfo.barCodeActivity,"");//替换标识前的字符串
|
|
|
if(!isSubscription){
|
|
|
senceid = senceid.replaceAll(ResultInfo.barCode,"");//替换标识前的字符串
|
|
|
-
|
|
|
}
|
|
|
System.out.println("更改之后的值:"+senceid);
|
|
|
StringBuilder str = new StringBuilder();
|
|
@@ -305,6 +327,40 @@ public class WeChatServiceImpl implements WeChatService {
|
|
|
return status;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 渠道关注统计
|
|
|
+ * @param requestMap
|
|
|
+ */
|
|
|
+ public Status bindingMainChannelId(Map<String, String> requestMap, String fromUserName,Boolean isSubscription) {
|
|
|
+ Status status = new Status();
|
|
|
+ String senceid = requestMap.get("EventKey");//场景值
|
|
|
+
|
|
|
+ //Member member = refreshUserInfo(fromUserName);
|
|
|
+
|
|
|
+ System.out.println("更改之前的值:"+senceid);
|
|
|
+ senceid = senceid.replaceAll(ResultInfo.barCodeMainChannelId,"");//替换标识前的字符串
|
|
|
+ if(!isSubscription){
|
|
|
+ senceid = senceid.replaceAll(ResultInfo.barCode,"");//替换标识前的字符串
|
|
|
+ }
|
|
|
+ System.out.println("更改之后的值:"+senceid);
|
|
|
+
|
|
|
+ AttenStatistics attenStatistics = new AttenStatistics();
|
|
|
+ attenStatistics.setChannelType(1);
|
|
|
+ attenStatistics.setChannelId(Integer.valueOf(senceid));
|
|
|
+ attenStatistics.setAttenStatisticsOpenId(fromUserName);
|
|
|
+ attenStatistics.setAttenStatisticsStatus(1);
|
|
|
+ Integer flag = attenStatisticsService.save(attenStatistics);
|
|
|
+ if(flag > 0){
|
|
|
+ System.out.println("添加渠道"+ senceid +"统计成功,openid:"+ fromUserName);
|
|
|
+ }else{
|
|
|
+ System.out.println("添加渠道"+ senceid +"统计失败,openid:"+ fromUserName);
|
|
|
+ }
|
|
|
+ status.setCountext("");
|
|
|
+ status.setFlag(false);
|
|
|
+ return status;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 扫码进入赠送礼品信息页面(已关注)
|
|
|
* @param requestMap
|