|
|
@@ -1,5 +1,6 @@
|
|
|
package com.dk.mdm.service.mst;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.dk.common.exception.BaseBusinessException;
|
|
|
import com.dk.common.infrastructure.annotaiton.Pagination;
|
|
|
@@ -11,6 +12,9 @@ import com.dk.common.model.vo.core.StaffEntity;
|
|
|
import com.dk.common.response.ResponseCodeEnum;
|
|
|
import com.dk.common.response.ResponseResultUtil;
|
|
|
import com.dk.common.response.ResponseResultVO;
|
|
|
+import com.dk.common.util.HttpUtils;
|
|
|
+import com.dk.mdm.feign.UserFeign;
|
|
|
+import com.dk.mdm.infrastructure.config.Config;
|
|
|
import com.dk.mdm.infrastructure.convert.mst.CusFollowConvert;
|
|
|
import com.dk.mdm.infrastructure.convert.mst.MeasureReceiptConvert;
|
|
|
import com.dk.mdm.infrastructure.util.AuthUtils;
|
|
|
@@ -29,15 +33,18 @@ import com.dk.mdm.service.common.CommonService;
|
|
|
import com.xxl.job.core.context.XxlJobHelper;
|
|
|
import com.xxl.job.core.handler.annotation.XxlJob;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.ZoneOffset;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
|
+import java.util.stream.IntStream;
|
|
|
|
|
|
@Slf4j
|
|
|
@Service
|
|
|
@@ -89,6 +96,12 @@ public class CusFollowService extends BaseService<CusFollow> {
|
|
|
private XxlJobUtils xxlJobUtils;
|
|
|
|
|
|
@Autowired
|
|
|
+ private Config config;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private UserFeign userFeign;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
private MeasureReceiptConvert measureReceiptConvert;
|
|
|
|
|
|
/**
|
|
|
@@ -399,42 +412,46 @@ public class CusFollowService extends BaseService<CusFollow> {
|
|
|
if (followStaff != null) {
|
|
|
log.info("sendFollowMessage:{}", JSONObject.toJSONString(followStaff));
|
|
|
Customer customer = customerMapper.selectById(new CustomerQuery().setCusId(follow.getCusId()));
|
|
|
-
|
|
|
if (customer != null) {
|
|
|
- //设计师
|
|
|
- StaffResponse designUser = null;
|
|
|
- if (follow.getDesignStaff() != null) {
|
|
|
- designUser = staffMapper.selectById(follow.getDesignStaff());
|
|
|
- }
|
|
|
-
|
|
|
- // 添加跟进ID
|
|
|
- JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(customer));
|
|
|
- jsonObject.put("followId", follow.getFollowId());
|
|
|
-
|
|
|
-
|
|
|
String loginType = null;
|
|
|
- JSONObject list = null;
|
|
|
- //跟进followId先查询跟进数据
|
|
|
- CusFollow e = cusFollowMapper.selectById(follow.getFollowId());
|
|
|
- if (e != null) {
|
|
|
- if (Constant.BasicDataConstant.FOLLOW_STATUS_4.getValue().equals(e.getFollowStatus()) ||
|
|
|
- Constant.BasicDataConstant.FOLLOW_STATUS_5.getValue().equals(e.getFollowStatus())) {
|
|
|
-
|
|
|
- JSONObject followJs = JSONObject.parseObject(JSONObject.toJSONString(e));
|
|
|
- followJs.put("customerName", jsonObject.get("customerName"));
|
|
|
- followJs.put("customerPhone", jsonObject.get("customerPhone"));
|
|
|
- followJs.put("addressFull", jsonObject.get("addressFull"));
|
|
|
+ List<String> list = new ArrayList<>();
|
|
|
+ if (Constant.BasicDataConstant.FOLLOW_STATUS_4.getValue().equals(follow.getFollowStatus()) ||
|
|
|
+ Constant.BasicDataConstant.FOLLOW_STATUS_5.getValue().equals(follow.getFollowStatus())) {
|
|
|
+ list.add("您有客户需要跟进");
|
|
|
+ loginType = "8";
|
|
|
|
|
|
- list = followJs;
|
|
|
- loginType = "8";
|
|
|
+ } else if (Constant.BasicDataConstant.FOLLOW_STATUS_6.getValue().equals(follow.getFollowStatus())) {
|
|
|
+ list.add("您有客户需要量尺服务");
|
|
|
+ loginType = "1";
|
|
|
|
|
|
- } else if (Constant.BasicDataConstant.FOLLOW_STATUS_1.getValue().equals(e.getFollowStatus()) ||
|
|
|
- Constant.BasicDataConstant.FOLLOW_STATUS_2.getValue().equals(e.getFollowStatus()) ||
|
|
|
- Constant.BasicDataConstant.FOLLOW_STATUS_3.getValue().equals(e.getFollowStatus())) {
|
|
|
+ } else if (Constant.BasicDataConstant.FOLLOW_STATUS_2.getValue().equals(follow.getFollowStatus())) {
|
|
|
+ list.add("您有客户邀约进店");
|
|
|
+ loginType = "1";
|
|
|
|
|
|
- list = jsonObject;
|
|
|
- loginType = "1";
|
|
|
+ } else if (Constant.BasicDataConstant.FOLLOW_STATUS_3.getValue().equals(follow.getFollowStatus())) {
|
|
|
+ list.add("您有客户需要约尺服务");
|
|
|
+ loginType = "1";
|
|
|
|
|
|
+ }
|
|
|
+ list.add(customer.getCusName());
|
|
|
+ list.add(customer.getCusPhone());
|
|
|
+ // 查询跟进人的openid和publicOpenId
|
|
|
+ ResponseResultVO<?> resultVO = userFeign.getUser(followStaff.getWxUserId());
|
|
|
+ // 如果没有成功返回,状态设置为待审
|
|
|
+ if (resultVO.getCode() != ResponseCodeEnum.SUCCESS.getCode()) {
|
|
|
+ log.error("客户查询异常:为空{}", follow.getCusId());
|
|
|
+ return ResponseCodeEnum.SELECT_NULL.getMessage();
|
|
|
+ } else {
|
|
|
+ Map<String, Object> user = (Map<String, Object>) resultVO.getData();
|
|
|
+ if (user != null) {
|
|
|
+ // 发送消息
|
|
|
+ Map<String, Object> mapMessage = new HashMap<>();
|
|
|
+ mapMessage.put("loginType", loginType);
|
|
|
+ mapMessage.put("publicOpenId", user.get("publicOpenId"));
|
|
|
+ mapMessage.put("first", "客户跟进提醒");
|
|
|
+ mapMessage.put("keywordList", list);
|
|
|
+ mapMessage.put("remark", "客户跟进备注");
|
|
|
+ sendUniformMessage(mapMessage);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -451,6 +468,81 @@ public class CusFollowService extends BaseService<CusFollow> {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * @author : sh4wmoo
|
|
|
+ * @date : 2021-7-20 13:49
|
|
|
+ * @desc : iBOSS推送公众号消息卡片
|
|
|
+ */
|
|
|
+ public ResponseResultVO sendUniformMessage(Map<String, Object> map) {
|
|
|
+ log.info("推送参数:{}", JSON.toJSONString(map));
|
|
|
+
|
|
|
+ // 3.获取token 231011
|
|
|
+ String token = this.getWxPublicAccountToken(); //this.getToken();
|
|
|
+ log.info("当前token:{}", token);
|
|
|
+ // 4.发送模板卡片 230927 地址发生变化
|
|
|
+ ResponseResultVO<JSONObject> res = HttpUtils.post(config.getUniformSend() + token, new HashMap<String, Object>(4) {{
|
|
|
+
|
|
|
+// 新加POST数据示例如下 240712
|
|
|
+ put("touser", map.get("publicOpenId") + "");
|
|
|
+ put("template_id", config.getTemplateId());
|
|
|
+ put("miniprogram", new HashMap<String, Object>(4) {{
|
|
|
+ put("appid", config.getAppId());
|
|
|
+ //用户点击公众号推送消息跳转小程序单据详情页 orderType 里面存放json字符串数据
|
|
|
+ //判断InvoiceParam
|
|
|
+ if (map.containsKey("InvoiceParam")) {
|
|
|
+ put("pagepath", "pages/login/login?loginType=" + map.get("loginType").toString() + "&InvoiceParam=" + map.get("InvoiceParam").toString());
|
|
|
+ } else {
|
|
|
+ put("pagepath", "pages/login/login?loginType=" + map.get("loginType").toString());
|
|
|
+ }
|
|
|
+ }});
|
|
|
+ put("data", new HashMap<String, Object>(16) {{
|
|
|
+ put("first", new HashMap<String, Object>(4) {{
|
|
|
+ put("value", map.get("first").toString());
|
|
|
+ put("color", "#173177");
|
|
|
+ }});
|
|
|
+ List<String> keywordList = (List<String>) map.get("keywordList");
|
|
|
+ //lambda foreach 取下标
|
|
|
+ IntStream.range(0, keywordList.size()).forEach(i -> {
|
|
|
+ String keyIndex = "keyword" + (i + 1);
|
|
|
+ put(keyIndex, new HashMap<String, Object>(4) {{
|
|
|
+ put("value", keywordList.get(i));
|
|
|
+ put("color", "#173177");
|
|
|
+ }});
|
|
|
+ });
|
|
|
+ put("remark", new HashMap<String, Object>(4) {{
|
|
|
+ put("value", map.get("remark").toString());
|
|
|
+ put("color", "#173177");
|
|
|
+ }});
|
|
|
+ }});
|
|
|
+
|
|
|
+ }});
|
|
|
+ if (res.getCode() == ResponseCodeEnum.SUCCESS.getCode() && res.getData().getString("errcode").equals("0")) {
|
|
|
+ log.info("推送成功:{}");
|
|
|
+ return ResponseResultUtil.success();
|
|
|
+ } else {
|
|
|
+ log.error("推送失败:{}", res.getData().toJSONString());
|
|
|
+ return ResponseResultUtil.error(res.getData().toJSONString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @author : jyh
|
|
|
+ * @date : 2023-10-11 16:23
|
|
|
+ * @desc : 调用中控服务获取公众号的token
|
|
|
+ */
|
|
|
+ public String getWxPublicAccountToken() {
|
|
|
+ ResponseResultVO<JSONObject> res = HttpUtils.post(config.getWechatUrlToken(),
|
|
|
+ new HashMap() {{
|
|
|
+ put("appId", config.getWxPublicAccountAppId());
|
|
|
+ put("appSecret", config.getWxPublicAccountAppSecret());
|
|
|
+ }});
|
|
|
+ if (res.getCode() == 200 && JSON.parseObject(JSON.toJSONString(res.getData())).get("code").toString().equals("200")) {
|
|
|
+ return JSON.parseObject(JSON.toJSONString(res.getData())).get("data").toString();
|
|
|
+ } else {
|
|
|
+ throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), res.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* @desc : 发送跟进任务消息
|
|
|
* @author : 姜永辉
|
|
|
* @date : 2022-06-30 19:24
|