|
@@ -3,14 +3,8 @@ package com.management.platform.controller;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
-import com.management.platform.entity.Custom;
|
|
|
-import com.management.platform.entity.MiniBindUser;
|
|
|
-import com.management.platform.entity.User;
|
|
|
-import com.management.platform.entity.WechatAccount;
|
|
|
-import com.management.platform.service.CustomService;
|
|
|
-import com.management.platform.service.MiniBindUserService;
|
|
|
-import com.management.platform.service.UserService;
|
|
|
-import com.management.platform.service.WechatAccountService;
|
|
|
+import com.management.platform.entity.*;
|
|
|
+import com.management.platform.service.*;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.codec.digest.DigestUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
@@ -53,6 +47,9 @@ public class WechatCallbackController {
|
|
|
@Resource
|
|
|
private WechatAccountService wechatAccountService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private BusinessOpportunityService businessOpportunityService;
|
|
|
+
|
|
|
@Value(value = "${wxqr.app_id}")
|
|
|
private String appId;
|
|
|
|
|
@@ -151,7 +148,17 @@ public class WechatCallbackController {
|
|
|
custom.setCompanyId(user != null ? user.getCompanyId() : null);
|
|
|
customService.save(custom);
|
|
|
log.info("新增客户成功");
|
|
|
+
|
|
|
+ BusinessOpportunity opportunity = new BusinessOpportunity();
|
|
|
+ opportunity.setCompanyId(user != null ? user.getCompanyId() : null);
|
|
|
+ opportunity.setIsDelete(0);
|
|
|
+ opportunity.setCreateTime(new Date());
|
|
|
+ opportunity.setInchargerId(miniBindUser.getUserId());
|
|
|
+ opportunity.setName("扫码关注客户:"+unionid);
|
|
|
+ businessOpportunityService.save(opportunity);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
}else {
|
|
|
log.info(unionid+":系统中已存在对应的客户");
|
|
|
}
|
|
@@ -166,7 +173,16 @@ public class WechatCallbackController {
|
|
|
|
|
|
private void handleUnsubscribe(String openId) {
|
|
|
// 实现用户取消关注的业务逻辑
|
|
|
- customService.remove(new QueryWrapper<Custom>().eq("custom_name", openId));
|
|
|
+// customService.remove(new QueryWrapper<Custom>().eq("custom_name", openId));
|
|
|
+ // 实现用户关注的业务逻辑
|
|
|
+ log.info("处理用户取消关注逻辑: {}", openId);
|
|
|
+ Map<String, Object> userInfo = getUserInfo(openId, null);
|
|
|
+ log.info("返回的userInfo信息==>"+userInfo.toString());
|
|
|
+ if (userInfo.get("unionid") != null) {
|
|
|
+ String unionid = (String) userInfo.get("unionid");
|
|
|
+ customService.remove(new QueryWrapper<Custom>().eq("custom_name", unionid));
|
|
|
+ businessOpportunityService.remove(new QueryWrapper<BusinessOpportunity>().like("name", unionid));
|
|
|
+ }
|
|
|
log.info("处理用户取消关注逻辑: {}", openId);
|
|
|
}
|
|
|
|