kaick 1 год назад
Родитель
Сommit
b6d95478b4

+ 11 - 7
src/main/java/com/caimei365/tools/controller/BaseApi.java

@@ -1,18 +1,14 @@
 package com.caimei365.tools.controller;
 
 import com.caimei365.tools.model.ResponseJson;
-import com.caimei365.tools.service.CmBehaviorRecordService;
-import com.caimei365.tools.service.CmOrganValueSystemService;
-import com.caimei365.tools.service.CmRepurchaseFrequencyService;
-import com.caimei365.tools.service.CmVipCouponService;
+import com.caimei365.tools.service.*;
 import com.caimei365.tools.service.impl.SysUserServiceImpl;
+import io.swagger.annotations.ApiOperation;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.java.Log;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Value;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
 import java.io.IOException;
@@ -40,6 +36,8 @@ public class BaseApi {
     private CmVipCouponService cmVipCouponService;
     @Resource
     private SysUserServiceImpl sysUserService;
+    @Resource
+    private WeChatService weChatService;
 
     @Value(value = "${swagger.enabled}")
     private Boolean swaggerEnabled;
@@ -76,5 +74,11 @@ public class BaseApi {
         cmBehaviorRecordService.insertBehaviorUser();
     }
 */
+    @ApiOperation("获取小程序二维码图片")
+    @PostMapping("/wxacode")
+    public ResponseJson<String> generateWxacode(@RequestBody String params) throws Exception {
+        ResponseJson<String> result = weChatService.generateWxacode(params);
+        return result;
+    }
 }
 

+ 2 - 2
src/main/java/com/caimei365/tools/controller/MessageApi.java

@@ -38,7 +38,7 @@ public class MessageApi {
 
     @ApiOperation("综合消息工具测试")
     @GetMapping("/message/send/try")
-    public ResponseJson sendCommonMessagetry(Integer status) {
+    public ResponseJson sendCommonMessagetry(Integer status,String openId) {
         //    WECHAT_TEMPLATE_MESSAGE(1, "微信模板消息"),
         //    WEB_INSIDE_MESSAGE(2, "站内消息"),
         //    EMAILS(3, "邮件"),
@@ -67,7 +67,7 @@ public class MessageApi {
             keyWords.add("北京天安门广场");
             keyWords.add("2022-10-20");
             wechatTemplateMessage = wechatTemplateMessage.url("https://www.caimei365.com/").templateId("o1nMAIsHAFr0VOu0qEbI1rEFDS14hl40UXbt52I5row")
-                    .openId("o9nzn5wFDZ_WjNo1-SfhqbKNXr4A").appid("wxf3cd4ae0cdd11c36").pagePath("pages/seller/club/list?type=wechat")
+                    .openId(openId!=null?openId:"o9nzn5wFDZ_WjNo1-SfhqbKNXr4A").appid("wxf3cd4ae0cdd11c36").pagePath("pages/seller/club/list?type=wechat")
                     .keyWords(keyWords).first("你有一个新机构用户,请及时跟进").remark("点击查看详情,了解更多客户信息。");
             MqInfo messageLine = new MqInfo().topic("MessageLine").delay(3).async(0);
             messageModel = messageModel.code(MessageType.WECHAT_TEMPLATE_MESSAGE).info(wechatTemplateMessage).mqInfo(messageLine);

+ 13 - 4
src/main/java/com/caimei365/tools/mapper/BaseMapper.java

@@ -2,15 +2,13 @@ package com.caimei365.tools.mapper;
 
 import com.caimei365.tools.model.bo.CouponDateBo;
 import com.caimei365.tools.model.bo.HeheCouponBo;
-import com.caimei365.tools.model.po.LogisticsInfoPo;
-import com.caimei365.tools.model.po.SearchFrequencyVo;
-import com.caimei365.tools.model.po.SuperVipPo;
-import com.caimei365.tools.model.po.SysUser;
+import com.caimei365.tools.model.po.*;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.Date;
 import java.util.List;
+import java.util.Map;
 
 /**
  * Description
@@ -39,6 +37,8 @@ public interface BaseMapper {
 
     String findMobile(Integer userId);
 
+    Integer findSpUserId(Integer spId);
+
     /**
      * 获取时间到期且未下架的二手商品Id
      */
@@ -113,6 +113,10 @@ public interface BaseMapper {
 
     List<Integer> getRecommendKeyword(String date);
 
+    List<Map<String,Object>> getBehaviorRecordYesterday(String accessTime);
+
+    String getBehaviorRecordYesterdayPageLabel(@Param("spId") Integer spId,@Param("clubId") Integer clubId,@Param("accessTime")String accessTime);
+
     void updateRecommend(List<Integer> ids);
 
     SysUser findUserNameById(String id);
@@ -120,4 +124,9 @@ public interface BaseMapper {
     List<String> getRoleNamesByUserId(Integer id);
 
     void updateKeywordRecommend(Integer id);
+
+    List<ClubPo> getClubList(CmUserPo cmUserPo);
+
+    String getWechatOpenId(String unionId);
+
 }

+ 65 - 6
src/main/java/com/caimei365/tools/model/dto/message/InsideMessage.java

@@ -13,6 +13,8 @@ import java.io.Serializable;
 @Accessors(fluent = true)
 public class InsideMessage implements Serializable {
 
+    private static final long serialVersionUID = 1L;
+
     /**
      * 消息id
      */
@@ -112,16 +114,25 @@ public class InsideMessage implements Serializable {
      */
     private Integer productId;
 
+    /** 手机号 */
+    private String mobile;
+
+    /** 名称 */
+    private String name;
+
+    /** 用户名称 */
+    private String userName;
+
+    /** 前用户名称 */
+    private String superUserName;
+
+    /** 当前id */
+    private Integer thisId;
+
     /**
      * 供应商公司名称
      */
-    public String getReasonContent() {
-        return reasonContent;
-    }
 
-    public void setReasonContent(String reasonContent) {
-        this.reasonContent = reasonContent;
-    }
     private String shopName;
 
     public Integer getId() {
@@ -180,6 +191,14 @@ public class InsideMessage implements Serializable {
         this.content = content;
     }
 
+    public String getReasonContent() {
+        return reasonContent;
+    }
+
+    public void setReasonContent(String reasonContent) {
+        this.reasonContent = reasonContent;
+    }
+
     public String getTime() {
         return time;
     }
@@ -308,6 +327,46 @@ public class InsideMessage implements Serializable {
         this.productId = productId;
     }
 
+    public String getMobile() {
+        return mobile;
+    }
+
+    public void setMobile(String mobile) {
+        this.mobile = mobile;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getUserName() {
+        return userName;
+    }
+
+    public void setUserName(String userName) {
+        this.userName = userName;
+    }
+
+    public String getSuperUserName() {
+        return superUserName;
+    }
+
+    public void setSuperUserName(String superUserName) {
+        this.superUserName = superUserName;
+    }
+
+    public Integer getThisId() {
+        return thisId;
+    }
+
+    public void setThisId(Integer thisId) {
+        this.thisId = thisId;
+    }
+
     public String getShopName() {
         return shopName;
     }

+ 158 - 0
src/main/java/com/caimei365/tools/model/po/ClubPo.java

@@ -0,0 +1,158 @@
+package com.caimei365.tools.model.po;
+
+import java.util.Date;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import java.io.Serializable;
+import lombok.Data;
+import lombok.experimental.Accessors;
+import org.apache.ibatis.type.Alias;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import java.util.Date;
+
+/**
+ * 会所资料信息对象 club
+ *
+ * @author Kaick
+ * @date 2023-08-31
+ */
+@Accessors(chain  = true )
+@Data
+@Alias("ClubPo")
+public class ClubPo implements Serializable
+{
+    private static final long serialVersionUID = 1L;
+
+    /** 会所ID */
+    private String clubID;
+
+    /** 用户ID */
+    private Integer userID;
+
+    /** 会所名称 */
+    private String name;
+
+    /** 简称 */
+    private String sname;
+
+    /** logo */
+    private String logo;
+
+    /** 法人 */
+    private String legalPerson;
+
+    /** 省 */
+    private Integer provinceID;
+
+    /** 市 */
+    private Integer cityID;
+
+    /** 地址ID */
+    private Integer townID;
+
+    /** 拉会所上线的用户的cmBindId,以逗号结尾 */
+    private String flag;
+
+    /** 邀请者cmBindId */
+    private Integer inviterBindID;
+
+    /** 邀请者名称 */
+    private String inviterName;
+
+    /** 协销Id */
+    private Integer spID;
+
+    /** 协销经理Id */
+    private Integer mainServiceProviderID;
+
+    /** 扫描时间 */
+    private String scanTime;
+
+    /** 详细地址 */
+    private String address;
+
+    /** 联系人 */
+    private String linkMan;
+
+    /** 联系人身份:1老板,2采购,3运营,4其他 */
+    private Integer linkManIdentity;
+
+    /** 联系电话 */
+    private String contractPhone;
+
+    /** 联系手机 */
+    private String contractMobile;
+
+    /** 联系邮箱 */
+    private String contractEmail;
+
+    /** 传真 */
+    private String fax;
+
+    /** 公司简介 */
+    private String info;
+
+    /** 注册时间 */
+    private String addTime;
+
+    /** 审核时间 */
+    private String auditTime;
+
+    /** 审核备注 */
+    private String auditNote;
+
+    /** 状态 */
+    private Integer status;
+
+    /** 营业执照 */
+    private String businessLicenseImage;
+
+    /** 默认的创客 */
+    private Integer defaultServiceProviderID;
+
+    /** 创客更新时间 */
+    private String defaultServiceProviderUpdTime;
+
+    /** 主打项目 */
+    private String mainpro;
+
+    /** 扫描状态 0待扫描 1 已扫描 2已上线 */
+    private String scanFlag;
+
+    /** 门头照 */
+    private String headpic;
+
+    /** 最后更新时间 */
+    private String lastModify;
+
+    /** 最后查看订单时间(用于协销统计历史订单未查看数量) */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date lastCheckOrderDate;
+
+    /** 统一社会信用代码 */
+    private String socialCreditCode;
+
+    /** 一级分类为医美=1和生美=2 */
+    private String firstClubType;
+
+    /** 医美的二级分类为诊所=1、门诊=2、医院=3。  生美没有二级分类 */
+    private String secondClubType;
+
+    /** 若为医美分类下的门诊和医院则需要填写科室。 */
+    private String department;
+
+    /** 医美分类必须上传医疗执业许可证 */
+    private String medicalPracticeLicenseImg;
+
+    /** 审核人 */
+    private String checkMan;
+
+    /** $column.columnComment */
+    private Integer newDeal;
+
+    /** $column.columnComment */
+    private Integer empnum;
+
+}
+

+ 2 - 0
src/main/java/com/caimei365/tools/model/po/CmUserPo.java

@@ -1,6 +1,7 @@
 package com.caimei365.tools.model.po;
 
 import lombok.Data;
+import lombok.experimental.Accessors;
 
 import java.io.Serializable;
 
@@ -11,6 +12,7 @@ import java.io.Serializable;
  * @version 2017-10-10
  */
 @Data
+@Accessors(chain  = true )
 public class CmUserPo implements Serializable {
 
     private static final long serialVersionUID = 1L;

+ 37 - 1
src/main/java/com/caimei365/tools/service/WeChatService.java

@@ -1,12 +1,22 @@
 package com.caimei365.tools.service;
 import com.alibaba.fastjson.JSONObject;
+import com.caimei365.tools.model.ResponseJson;
+import com.caimei365.tools.utils.FastDfsUtil;
 import com.caimei365.tools.utils.RequestUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
+import javax.annotation.Resource;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
 import java.util.Map;
+import java.util.UUID;
+
+import static com.sun.jmx.snmp.EnumRowStatus.active;
 
 /**
  * Description
@@ -20,7 +30,10 @@ public class WeChatService {
 //    private String crmAppId;
 //    @Value("${wx.crm-app-secret}")
 //    private String crmAppSecret;
-
+    @Value("${caimei.imageDomain}")
+    private String imageDomain;
+    @Resource
+    private FastDfsUtil fastDfsUtil;
     protected Logger logger = LoggerFactory.getLogger(getClass());
 
     /**
@@ -407,4 +420,27 @@ public class WeChatService {
         }
     }
 
+    /**
+     * 根据accessToken生成小程序二维码
+     */
+    public ResponseJson<String> generateWxacode(String params) throws Exception {
+        String result1 = RequestUtil.sendGet("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=wxf3cd4ae0cdd11c36&secret=f5707c40c07adf0e2110c58ce6a4f4b3");
+        Map<String, Object> map = JSONObject.parseObject(result1, Map.class);
+        String access_token = (String) map.get("access_token");
+        String requestUrl = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=" + access_token;
+        ByteArrayInputStream inputStream = RequestUtil.sendPost(requestUrl, params);
+        try {
+            String fileUrl = null;
+            String url = fastDfsUtil.saveFile(inputStream);
+            fileUrl = imageDomain + "/" + url;
+            logger.info("【图片上传】>>>>>>>>>>>>>>>>上传成功:" + fileUrl);
+            return ResponseJson.success(fileUrl);
+        } catch (IOException e) {
+            logger.error("【图片上传】>>>>>>>>>>>>>>>>上传失败:" + e);
+            return ResponseJson.error("图片上传失败", null);
+        }
+    }
+
+
+
 }

+ 93 - 5
src/main/java/com/caimei365/tools/task/StatisticsTask.java

@@ -1,7 +1,19 @@
 package com.caimei365.tools.task;
 
+import com.alibaba.fastjson.JSONObject;
 import com.caimei365.tools.feign.CommodityFeign;
 import com.caimei365.tools.mapper.BaseMapper;
+import com.caimei365.tools.model.dto.message.InsideMessage;
+import com.caimei365.tools.model.dto.message.MessageModel;
+import com.caimei365.tools.model.dto.message.MqInfo;
+import com.caimei365.tools.model.dto.message.WechatTemplateMessage;
+import com.caimei365.tools.model.dto.message.enums.MessageType;
+import com.caimei365.tools.model.po.ClubPo;
+import com.caimei365.tools.model.po.CmUserPo;
+import com.caimei365.tools.service.MessageSender;
+import com.caimei365.tools.utils.RequestUtil;
+import com.caimei365.tools.utils.SmsUtil;
+import com.fasterxml.jackson.databind.ObjectMapper;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
@@ -14,9 +26,7 @@ import redis.clients.jedis.commands.JedisCommands;
 
 import javax.annotation.Resource;
 import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.Map;
+import java.util.*;
 
 /**
  * Description
@@ -32,9 +42,12 @@ public class StatisticsTask {
     @Resource
     private BaseMapper baseMapper;
     @Resource
-    private RedisTemplate<String,String> redisTemplate;
+    private RedisTemplate<String, String> redisTemplate;
     @Resource
     private CommodityFeign commodityFeign;
+
+    private final MessageSender messageSender;
+
     /**
      * 每天凌晨3点执行一次统计前一天商品访问量
      * <p>
@@ -74,7 +87,82 @@ public class StatisticsTask {
             }
             log.info(">>>>>>>>>>>【定时任务】统计前一天商品详情访问量,统计成功:" + result);
         } catch (Exception e) {
-            log.error(">>>>>>>>>>>【定时任务】统计前一天商品详情访问量失败:",e);
+            log.error(">>>>>>>>>>>【定时任务】统计前一天商品详情访问量失败:", e);
+        }
+    }
+
+    /**
+     * 每天早上9点半执行一次统计前一天针对机构访问商城形式的活跃行为
+     * <p>
+     * cron表达式语法:秒 分 小时 日 月 周
+     * 年可省略
+     * * 表示所有值。
+     * ? 表示不指定值。
+     */
+    @Scheduled(cron = "0 30 9 * * ?")
+    public void countSpClubViews() {
+        try {
+            // 获取昨天日期字符串
+            Calendar calendar = Calendar.getInstance();
+            calendar.setTime(new Date());
+            calendar.add(Calendar.DAY_OF_MONTH, -1);
+            String dateStr = new SimpleDateFormat("yyyy-MM-dd").format(calendar.getTime());
+            log.info(">>>>>>>>>>>【定时任务】统计前一天针对机构访问商城形式的活跃行为,统计日期(前一天):" + dateStr);
+            List<Map<String, Object>> behaviorRecordYesterday = baseMapper.getBehaviorRecordYesterday(dateStr);
+            for (Map<String, Object> map : behaviorRecordYesterday) {
+                Integer spId = (Integer) map.get("spId");
+                String name = (String) map.get("name");
+                Double count = (Double) map.get("count");
+                String pageLabel = baseMapper.getBehaviorRecordYesterdayPageLabel(spId, null, dateStr);
+                String openId = baseMapper.getWechatOpenId((String) map.get("unionId"));
+                //站内信
+                MessageModel<InsideMessage> insideMessageMessageModel = new MessageModel<>();
+                insideMessageMessageModel.code(MessageType.WEB_INSIDE_MESSAGE)
+                        .mqInfo(new MqInfo().topic("MessageLine").delay(3).async(0))
+                        .info(new InsideMessage()
+                                .userType(3)
+                                .messageType(3)
+                                .shopTieredType(7)
+                                .name(name)
+                                .content(pageLabel)
+                                .couponFee(count)
+                                .thisId(spId)
+                        );
+                messageSender.messageSend(insideMessageMessageModel);
+                //微信模板消息
+                ArrayList<String> keyWords = new ArrayList<>();
+                keyWords.add(name+"...等"+Integer.valueOf(String.valueOf(count))+"家机构客户");
+                keyWords.add(pageLabel);
+                keyWords.add(dateStr);
+                MessageModel<WechatTemplateMessage> wechatTemplateMessageMessageModel = new MessageModel<WechatTemplateMessage>()
+                        .code(MessageType.WECHAT_TEMPLATE_MESSAGE)
+                        .mqInfo(new MqInfo().topic("MessageLine").delay(3).async(0))
+                        .info(new WechatTemplateMessage()
+                                .first("")
+                                .openId(openId)
+                                .appid("wxf3cd4ae0cdd11c36")
+                                .templateId("Zd7ewJw9-bN-gIgra9flKW96W3YehikRPPkDXPfhmQ0")
+                                .keyWords(keyWords)
+                                .remark("为了更好给您服务,请及时联系采美客服!")
+                                .pagePath("pages/seller/club/list?type=wechat"));
+                messageSender.messageSend(wechatTemplateMessageMessageModel);
+            }
+            //访问商城形式的不活跃行为 短信推送
+            calendar.add(Calendar.DATE, -180);
+            String dateStr2 = new SimpleDateFormat("yyyy-MM-dd").format(calendar.getTime());
+            log.info(">>>>>>>>>>>【定时任务】统计前一天针对机构访问商城形式的不活跃行为,统计日期(180天前):" + dateStr2);
+            List<ClubPo> clubList = baseMapper.getClubList(new CmUserPo().setLoginTime(dateStr2));
+            for (ClubPo clubPo : clubList) {
+                if (null != clubPo.getSpID()) {
+                    String mobile = baseMapper.findMobile(baseMapper.findSpUserId(clubPo.getSpID()));
+                    if (StringUtils.isNotBlank(mobile)) {
+                        SmsUtil.sendSms(1, mobile, "【采美365】该机构客户已有6个月未在商城活跃,请及时跟进。机构名称【" + clubPo.getName() + "】,联系人【" + clubPo.getLinkMan() + "】,手机号【" + clubPo.getContractMobile() + "】。微信小程序微信小程序https://....comm,退订回T。");
+                    }
+                }
+            }
+            log.info(">>>>>>>>>>>【定时任务】统计前一天针对机构访问商城形式的活跃行为,统计成功");
+        } catch (Exception e) {
+            log.error(">>>>>>>>>>>【定时任务】统计前一天针对机构访问商城形式的活跃行为失败:", e);
         }
     }
 }

+ 40 - 0
src/main/java/com/caimei365/tools/utils/FastDfsUtil.java

@@ -5,11 +5,17 @@ import com.github.tobato.fastdfs.domain.proto.storage.DownloadByteArray;
 import com.github.tobato.fastdfs.service.FastFileStorageClient;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.FilenameUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
 
 import javax.annotation.Resource;
 import java.io.*;
+import java.util.UUID;
+
+import static com.sun.jmx.snmp.EnumRowStatus.active;
 
 /**
  * Description
@@ -19,6 +25,9 @@ import java.io.*;
  */
 @Component
 public class FastDfsUtil {
+    protected Logger logger = LoggerFactory.getLogger(getClass());
+    @Value("${spring.cloud.config.profile}")
+    private String profile;
     @Resource
     private FastFileStorageClient storageClient;
 
@@ -47,4 +56,35 @@ public class FastDfsUtil {
         outputStream.write(content);
         return true;
     }
+    /**
+     * 保存文件到FastDFS
+     */
+    public String saveFile(ByteArrayInputStream inputStream) throws IOException {
+        String randomStr = UUID.randomUUID().toString();
+        String name = ".jpeg";
+        // 图片暂存本地服务器路径
+        String filePath = "/mnt/newdatadrive/data/runtime/cloud-instance/server-tools/tempImage/";
+        if ("dev".equals(profile)){
+            filePath = "D:\\";
+        }
+        filePath += randomStr + name;
+        FileOutputStream outputStream = new FileOutputStream(filePath);
+        int i = 0;
+        byte[] buffer = new byte[200];
+        while ((i = inputStream.read(buffer)) != -1) {
+            outputStream.write(buffer, 0, i);
+        }
+        outputStream.flush();
+        outputStream.close();
+        inputStream.close();
+        // 临时图片
+        File tempFile = new File(filePath);
+        logger.info("【图片上传】>>>>>>>>>>>>>>>>图片临时路径:" + filePath);
+        String fileUrl = uploadFile(filePath);
+        // 删除临时图片
+        boolean delete = tempFile.delete();
+        logger.info("【图片上传】>>>>>>>>>>>>>>>>删除临时图片:" + delete);
+        return fileUrl;
+    }
+
 }

+ 33 - 0
src/main/java/com/caimei365/tools/utils/RequestUtil.java

@@ -1,5 +1,12 @@
 package com.caimei365.tools.utils;
 
+import org.apache.http.HttpEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.protocol.HttpContext;
 import org.springframework.util.StringUtils;
 
 import javax.net.ssl.HttpsURLConnection;
@@ -7,6 +14,8 @@ import javax.net.ssl.SSLContext;
 import javax.net.ssl.SSLSocketFactory;
 import javax.net.ssl.TrustManager;
 import java.io.*;
+import java.net.URI;
+import java.net.URISyntaxException;
 import java.net.URL;
 import java.net.URLConnection;
 import java.nio.charset.StandardCharsets;
@@ -184,5 +193,29 @@ public class RequestUtil {
         } catch (Exception ignored) {}
         return null;
     }
+    public static ByteArrayInputStream sendPost(String url, String params) throws URISyntaxException, IOException {
+        CloseableHttpClient client = HttpClients.createDefault();
+        HttpPost httpPost = new HttpPost();
+        httpPost.addHeader("Content-type","application/json;charset=UTF-8");
+        httpPost.setHeader("Accept","application/json");
+        URI uri = new URI(url);
+        httpPost.setURI(uri);
+        StringEntity entity = new StringEntity(params, "UTF-8");
+        httpPost.setEntity(entity);
+        CloseableHttpResponse response = client.execute(httpPost, (HttpContext) null);
+        HttpEntity responseEntity = response.getEntity();
+        InputStream inputStream = responseEntity.getContent();
+        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+        byte[] buffer = new byte[1024];
+        int len = 0;
+        while ((len = inputStream.read(buffer)) != -1) {
+            outputStream.write(buffer, 0, len);
+        }
+        inputStream.close();
+        ByteArrayInputStream byteInputStream = new ByteArrayInputStream(outputStream.toByteArray());
+        outputStream.flush();
+        outputStream.close();
+        return byteInputStream;
 
+    }
 }

+ 92 - 0
src/main/resources/mapper/BaseMapper.xml

@@ -44,6 +44,11 @@
         from user
         where userID = #{userid}
     </select>
+    <select id="findSpUserId" resultType="java.lang.Integer">
+        select userId
+        from serviceprovider
+        where serviceProviderID = #{spId}
+    </select>
     <select id="getMaturitySecondProductIds" resultType="java.lang.Integer">
         SELECT cshd.productID
         FROM cm_second_hand_detail cshd
@@ -196,6 +201,93 @@
         HAVING COUNT(keywordId) > 1
     </select>
 
+    <select id="getBehaviorRecordYesterday" resultType="java.util.HashMap">
+        SELECT c.spId,
+               b.accessTime,
+               c.name,
+               sp.unionId,
+               count(DISTINCT c.clubId) as count
+        FROM cm_behavior_record b
+        LEFT JOIN club c ON b.userID = c.userID
+        LEFT JOIN serviceprovider sp ON c.spID = sp.serviceProviderID
+        WHERE b.userId !=0
+          and b.pageType in (6, 8, 11)
+          and DATE (b.accessTime) = DATE (#{accessTime})
+        GROUP BY c.spId
+        ORDER BY count (c.clubId) DESC
+    </select>
+    <select id="getBehaviorRecordYesterdayPageLabel" resultType="string">
+        SELECT GROUP_CONCAT(a.pageLabel)
+        FROM (SELECT b.pageLabel
+              FROM cm_behavior_record b
+              LEFT JOIN club c ON b.userID = c.userID
+              WHERE b.userId !=0
+              and c.spId=#{spId}
+            <if test="clubId != null">
+                AND c.clubId =#{clubId}
+            </if>
+              and b.pageType in(6,8,11)
+              and  DATE(b.accessTime) = DATE(#{accessTime})
+              GROUP BY b.pageLabel LIMIT 10) as a
+    </select>
+    <select id="getWechatOpenId" resultType="string">
+        SELECT openid
+        FROM wechat_user
+        WHERE unionId =#{unionId}
+    </select>
+
+    <select id="getClubList" resultType="com.caimei365.tools.model.po.ClubPo">
+        select club.clubID,
+               club.userID,
+               club.name,
+               club.sname,
+               club.logo,
+               club.legalPerson,
+               club.provinceID,
+               club.cityID,
+               club.townID,
+               club.flag,
+               club.inviterBindID,
+               club.inviterName,
+               club.spID,
+               club.mainServiceProviderID,
+               club.scanTime,
+               club.address,
+               club.linkMan,
+               club.linkManIdentity,
+               club.contractPhone,
+               club.contractMobile,
+               club.contractEmail,
+               club.fax,
+               club.info,
+               club.addTime,
+               club.auditTime,
+               club.auditNote,
+               club.status,
+               club.businessLicenseImage,
+               club.defaultServiceProviderID,
+               club.defaultServiceProviderUpdTime,
+               club.mainpro,
+               club.scanFlag,
+               club.headpic,
+               club.lastModify,
+               club.lastCheckOrderDate,
+               club.socialCreditCode,
+               club.firstClubType,
+               club.secondClubType,
+               club.department,
+               club.medicalPracticeLicenseImg,
+               club.checkMan,
+               club.newDeal,
+               club.empnum
+        from club club
+        left join user u on club.userID = u.userID
+        where club.status=90
+        AND club.spId!=1342
+        AND DATE(u.loginTime) = DATE(#{loginTime})
+    </select>
+
+
     <update id="updateRecommend">
         update cm_user_search_frequency
         set recommendStatus = 1

+ 2 - 2
src/main/resources/mapper/MessageCenter.xml

@@ -10,10 +10,10 @@
     <insert id="sendInsideMessage">
         INSERT INTO message_center (shopID, clubID, orderID, userType, messageType, accountType, orderMessageType,
                                     couponMessageType, couponFee, content, time, saved, shopMessType,
-                                    shopTieredType, couponType, productID,reasonContent)
+                                    shopTieredType, couponType, productID,reasonContent,mobile,name,userName,superUserName,thisId)
         VALUES (#{shopId}, #{clubId}, #{orderId}, #{userType}, #{messageType}, #{accountType}, #{orderMessageType},
                 #{couponMessageType}, #{couponFee}, #{content}, now(), 0, #{shopMessType},
-                #{shopTieredType}, #{couponType}, #{productId}, #{reasonContent})
+                #{shopTieredType}, #{couponType}, #{productId}, #{reasonContent},#{mobile},#{name},#{userName},#{superUserName},#{thisId})
     </insert>
     <insert id="addNotification">
         INSERT INTO notification(theme, newTime, shopContent, porductID, shopID)