|
@@ -13,10 +13,7 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.LinkedHashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* Description
|
|
@@ -39,6 +36,9 @@ public class MessageServiceImpl implements MessageService {
|
|
|
|
|
|
@Resource private MessageMapper messageMapper;
|
|
|
|
|
|
+ /**
|
|
|
+ * 协销不活跃机构
|
|
|
+ */
|
|
|
@Override
|
|
|
public void UnActiveMessage() {
|
|
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
@@ -81,7 +81,90 @@ public class MessageServiceImpl implements MessageService {
|
|
|
JSONObject miniProgram = new JSONObject();
|
|
|
miniProgram.put("appid", miniAppId);
|
|
|
// 跳转链接
|
|
|
- miniProgram.put("pagepath", "/pages/seller/club/club-inactive-list?serviceProviderId="+serviceprovider.getServiceProviderId());
|
|
|
+ miniProgram.put("pagepath", "/pages/seller/club/club-inactive-list?type=1&serviceProviderId="+serviceprovider.getServiceProviderId());
|
|
|
+ // 获取openId
|
|
|
+ String openid = messageMapper.getOpenidListByPermission(serviceprovider.getUnionId());
|
|
|
+
|
|
|
+ JSONObject json = new JSONObject(new LinkedHashMap());
|
|
|
+ json.put("touser", openid);
|
|
|
+ json.put("template_id", "xvOy9dwbCK-GeCUBnNV6XLzw_afavHBtT5wKgH_ZIpU");
|
|
|
+ json.put("url", "https://www.caimei365.com/");
|
|
|
+ json.put("miniprogram", miniProgram);
|
|
|
+ json.put("data", data);
|
|
|
+ // json 字符串
|
|
|
+ String jsonString = json.toJSONString();
|
|
|
+ log.info(">>>>>>>>推送微信模板消息:" + jsonString);
|
|
|
+ try {
|
|
|
+ String requestUrl = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + getAccessToken();
|
|
|
+ // 发送请求
|
|
|
+ String result = RequestUtil.httpRequest(requestUrl, "POST", jsonString);
|
|
|
+ log.info(">>>>>>>>推送结果:" + result);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.info("推送微信模板消息失败:" + e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 活跃机构发送模板消息
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void getBehaviorActiveInfo() {
|
|
|
+ Date date = new Date();
|
|
|
+ // 获取三天前日期
|
|
|
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ calendar.setTime(date);
|
|
|
+ calendar.add(Calendar.DAY_OF_MONTH, -3);
|
|
|
+ Date time = calendar.getTime();
|
|
|
+ String format = dateFormat.format(time);
|
|
|
+ // 协销信息
|
|
|
+ List<ServiceproviderPo> serviceInfo = messageMapper.getServiceInfo();
|
|
|
+ // 三天前活跃且填写咨询记录的机构
|
|
|
+ String newFormat = format + " 00:00:00";
|
|
|
+ List<Integer> remarkClub = messageMapper.getRemarkClub(newFormat);
|
|
|
+ for (ServiceproviderPo serviceprovider: serviceInfo) {
|
|
|
+ // 协销三天前活跃机构
|
|
|
+ List<ClubPo> activeClub = messageMapper.getBehaviorActiveInfo(format, serviceprovider.getServiceProviderId());
|
|
|
+ String clubName = "";
|
|
|
+ if (null != activeClub && activeClub.size() > 0) {
|
|
|
+ for (ClubPo club : activeClub) {
|
|
|
+ //三天前活跃,但是这三天没有填写过咨询记录
|
|
|
+ if (!remarkClub.contains(Integer.parseInt(club.getClubID()))) {
|
|
|
+ if (StringUtils.isNotBlank(club.getName())) {
|
|
|
+ clubName += club.getName() + " ";
|
|
|
+ } else if (StringUtils.isNotBlank(club.getLinkMan())) {
|
|
|
+ clubName += club.getLinkMan() + " ";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (clubName.length() > 10) {
|
|
|
+ String substring = clubName.substring(0, 9);
|
|
|
+ clubName = substring + "等" + activeClub.size() + "家机构";
|
|
|
+ }
|
|
|
+ JSONObject first = new JSONObject();
|
|
|
+ first.put("value", "客户咨询跟进提醒");
|
|
|
+ JSONObject keyword1 = new JSONObject();
|
|
|
+ keyword1.put("value", "活跃客户咨询记录填写提醒");
|
|
|
+ JSONObject keyword2 = new JSONObject();
|
|
|
+ keyword2.put("value", clubName);
|
|
|
+ JSONObject keyword3 = new JSONObject();
|
|
|
+ keyword3.put("value", StringUtils.isNotBlank(activeClub.get(0).getBehaviorTime()) ? activeClub.get(0).getBehaviorTime() : "");
|
|
|
+ JSONObject remark = new JSONObject();
|
|
|
+ remark.put("value", "点击查看详情,查看咨询记录详情。");
|
|
|
+
|
|
|
+ JSONObject data = new JSONObject();
|
|
|
+ data.put("first", first);
|
|
|
+ data.put("keyword1", keyword1);
|
|
|
+ data.put("keyword2", keyword2);
|
|
|
+ data.put("keyword3", keyword3);
|
|
|
+ data.put("remark", remark);
|
|
|
+
|
|
|
+ JSONObject miniProgram = new JSONObject();
|
|
|
+ miniProgram.put("appid", miniAppId);
|
|
|
+ // 跳转链接
|
|
|
+ miniProgram.put("pagepath", "/pages/seller/club/club-inactive-list?type=1&serviceProviderId="+serviceprovider.getServiceProviderId());
|
|
|
// 获取openId
|
|
|
String openid = messageMapper.getOpenidListByPermission(serviceprovider.getUnionId());
|
|
|
|