Browse Source

客服消息测试
阳光数据接口

lijilei 3 năm trước cách đây
mục cha
commit
6239243c0e
26 tập tin đã thay đổi với 959 bổ sung52 xóa
  1. 2 0
      book-dao/src/main/java/com/book/dao/utils/DateUtils.java
  2. 8 0
      book-dao/src/main/java/com/book/dao/utils/TimeUtil.java
  3. 52 0
      book-push/src/main/java/com/book/push/controller/KefuTestController.java
  4. 52 50
      book-push/src/main/java/com/book/push/service/push/impl/IntellectPushServiceImpl.java
  5. 58 0
      book-server/src/main/java/com/book/server/config/SunTypeEnum.java
  6. 51 0
      book-server/src/main/java/com/book/server/controller/SunDataController.java
  7. 22 0
      book-server/src/main/java/com/book/server/service/SunDataService.java
  8. 164 0
      book-server/src/main/java/com/book/server/service/impl/SunDataServiceImpl.java
  9. 95 0
      book-server/src/main/java/com/book/server/task/SunDataTask.java
  10. 11 1
      book-server/src/main/java/com/book/server/utils/DataUtil.java
  11. 52 0
      book-server/src/main/java/com/book/server/utils/HttpTool.java
  12. 0 1
      book-server/src/main/java/com/book/server/utils/HttpUtils.java
  13. 16 0
      book-server/src/main/java/com/book/server/vo/SunNotifyRequest.java
  14. 25 0
      book-server/src/main/java/com/book/server/vo/SunRequest.java
  15. 22 0
      book-server/src/main/java/com/book/server/vo/SunResult.java
  16. 19 0
      book-server/src/main/java/com/book/server/vo/SunTypeActivity.java
  17. 23 0
      book-server/src/main/java/com/book/server/vo/SunTypeActivityCollect.java
  18. 19 0
      book-server/src/main/java/com/book/server/vo/SunTypeChannel.java
  19. 28 0
      book-server/src/main/java/com/book/server/vo/SunTypeCustomUrl.java
  20. 29 0
      book-server/src/main/java/com/book/server/vo/SunTypeCustomUrlCollect.java
  21. 29 0
      book-server/src/main/java/com/book/server/vo/SunTypeOrder.java
  22. 27 0
      book-server/src/main/java/com/book/server/vo/SunTypeReferral.java
  23. 21 0
      book-server/src/main/java/com/book/server/vo/SunTypeReferralCollect.java
  24. 64 0
      book-server/src/main/java/com/book/server/vo/SunTypeUser.java
  25. 21 0
      book-server/src/main/java/com/book/server/vo/SunTypeUserDayCollect.java
  26. 49 0
      book-server/src/test/java/com/book/server/controller/SunControllerTest.java

+ 2 - 0
book-dao/src/main/java/com/book/dao/utils/DateUtils.java

@@ -2,6 +2,7 @@ package com.book.dao.utils;
 
 import org.springframework.util.Assert;
 
+import java.text.SimpleDateFormat;
 import java.time.*;
 import java.time.format.DateTimeFormatter;
 import java.time.temporal.TemporalAdjusters;
@@ -142,4 +143,5 @@ public class DateUtils {
         System.out.println(getDateNow());
     }
 
+
 }

+ 8 - 0
book-dao/src/main/java/com/book/dao/utils/TimeUtil.java

@@ -330,4 +330,12 @@ public class TimeUtil {
             return null;
         }
     }
+
+	public static String getDateStrAfter(Integer value, int field,String format) {
+		Calendar calendar = Calendar.getInstance();
+		calendar.add(field,value);
+		Date time = calendar.getTime();
+		return new SimpleDateFormat(format).format(time);
+
+	}
 }

+ 52 - 0
book-push/src/main/java/com/book/push/controller/KefuTestController.java

@@ -0,0 +1,52 @@
+package com.book.push.controller;
+
+import com.book.dao.utils.TimeUtil;
+import com.book.push.service.wx.WxThirdPartService;
+import com.book.push.vo.result.Result;
+import lombok.extern.slf4j.Slf4j;
+import me.chanjar.weixin.mp.bean.kefu.WxMpKefuMessage;
+import me.chanjar.weixin.mp.builder.kefu.TextBuilder;
+import me.chanjar.weixin.open.api.WxOpenMpService;
+import me.chanjar.weixin.open.api.WxOpenService;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * created in 2021/9/28
+ * Project: book-store
+ * http://mp.esalary.com.cn/kefu/send?appid=wxe1271417b2ff5b1c&openid=ou1lt1YlMHsrUSm1FJ98PCd31yFI
+ * @author win7
+ */
+@Slf4j
+@RestController
+@RequestMapping("/kefu")
+public class KefuTestController {
+    @Autowired
+    private WxThirdPartService wxThirdPartService;
+
+    @GetMapping("/send")
+    public Result hello(@RequestParam String appid, @RequestParam String openid, @RequestParam(required = false) String msg) {
+        log.info("测试发送:", appid, openid);
+        if (StringUtils.isEmpty(msg)) {
+            msg = "测试发送客服消息:" + TimeUtil.getCurrentDate(TimeUtil.YYYY_M_DD_HH_MM_SS);
+        }
+        try {
+            WxMpKefuMessage build = new TextBuilder().toUser(openid).content(msg).build();
+            WxOpenService wxOpenService = wxThirdPartService.getWxOpenServiceByPlatFormId(7);
+            WxOpenMpService wxMpService = wxOpenService.getWxOpenComponentService().getWxMpServiceByAppid(appid);
+            wxMpService.getKefuService().sendKefuMessage(build);
+        } catch (Exception e) {
+            return Result.failure(99, e.getMessage());
+        }
+
+
+        return Result.success();
+
+
+    }
+
+}

+ 52 - 50
book-push/src/main/java/com/book/push/service/push/impl/IntellectPushServiceImpl.java

@@ -74,14 +74,16 @@ public class IntellectPushServiceImpl implements IntellectPushService {
         AdminConfig adminConfig = adminConfigService.selectByAppid(appid);
         SignExample example = SignExample.newAndCreateCriteria().andUidEqualTo(user.getId().intValue()).andCreatedateEqualTo(TimeUtil.getCurrentIntDate(TimeUtil.YYYYMMDD_N)).example();
         Sign sign = signMapper.selectOneByExample(example);
-        if (sign == null) {
-            SignedRecommand signRecommand = signedRecommendService.selectRandom(user.getSex().toString());
-            bookId = signRecommand.getBookId();
-        } else {
+
+        //修改,关闭未签到推荐书库
+//        if (sign == null) {
+        SignedRecommand signRecommand = signedRecommendService.selectRandom(user.getSex().toString());
+        bookId = signRecommand.getBookId();
+     /*   } else {
             SignRecommand signRecommand = signRecommendService.selectRandom(user.getSex().toString());
             bookId = signRecommand.getBookId();
 
-        }
+        }*/
         ManageTitle manageTitle = manageTitleService.selectRandom(user.getSex().toString());
         ManageCover manageCover = manageCoverService.selectRandom("1", user.getSex().toString());
         WxMpKefuMessage.WxArticle wxArticle = new WxMpKefuMessage.WxArticle();
@@ -117,17 +119,17 @@ public class IntellectPushServiceImpl implements IntellectPushService {
         User user = userService.selectById(orders.getUserId());
         String msg = "亲,你上次看的书还在等着你呐~ 点击继续阅读%n>%s%n首冲50元即可畅读90万字,365元年份会员更可全年无线畅读。%n%n为了下次方便阅读,请置顶公众号";
         Long bookId = orders.getBookId();
-        if (bookId==null){
+        if (bookId == null) {
 
             UserRecentlyRead userRecentlyRead = userRecentReadService.selectLastByUserId(orders.getUserId());
-             bookId = userRecentlyRead.getBookId();
+            bookId = userRecentlyRead.getBookId();
         }
         AdminConfig adminConfig = adminConfigService.selectByAppid(appid);
 
-        String url =bookService.createBookUrl(bookId,adminConfig,user);
+        String url = bookService.createBookUrl(bookId, adminConfig, user);
         Book book = bookService.selectById(bookId);
-        String link = "<a href='"+url+"'>《"+book.getName()+"》</a>";
-        msg = String.format(msg,link);
+        String link = "<a href='" + url + "'>《" + book.getName() + "》</a>";
+        msg = String.format(msg, link);
         WxMpKefuMessage wxMpKefuMessage = new TextBuilder().toUser(user.getOpenid()).content(msg).build();
         return wxMpKefuMessage;
     }
@@ -142,21 +144,21 @@ public class IntellectPushServiceImpl implements IntellectPushService {
     @Override
     public void pushBySubscribe(Integer platformId, String appid, Long userId) {
         try {
-        Integer second = afterNow();
-        if (second > 0) {
-            redisService.set(redisService.getKeyListener().getKeyMpSubscribe(platformId, appid, userId), userId + "", second);
-            return;
-        }
-        WxMpKefuMessage signMessage = createSubscribeMessage(platformId, appid, userId);
+            Integer second = afterNow();
+            if (second > 0) {
+                redisService.set(redisService.getKeyListener().getKeyMpSubscribe(platformId, appid, userId), userId + "", second);
+                return;
+            }
+            WxMpKefuMessage signMessage = createSubscribeMessage(platformId, appid, userId);
 
 
-        WxOpenService wxOpenService = wxThirdPartService.getWxOpenServiceByPlatFormId(platformId);
-        WxOpenMpService wxMpService = wxOpenService.getWxOpenComponentService().getWxMpServiceByAppid(appid);
+            WxOpenService wxOpenService = wxThirdPartService.getWxOpenServiceByPlatFormId(platformId);
+            WxOpenMpService wxMpService = wxOpenService.getWxOpenComponentService().getWxMpServiceByAppid(appid);
 
             wxMpService.getKefuService().sendKefuMessage(signMessage);
         } catch (WxErrorException e) {
             e.printStackTrace();
-            log.error("签到智能推送失败",e);
+            log.error("签到智能推送失败", e);
         }
 
     }
@@ -164,21 +166,21 @@ public class IntellectPushServiceImpl implements IntellectPushService {
     @Override
     public void pushBySign(Integer platformId, String appid, Long userId) {
         try {
-        Integer second = afterNow();
-        if (second > 0) {
-            redisService.set(redisService.getKeyListener().getKeyMpSign(platformId, appid, userId), userId + "", second);
-            return;
-        }
-        WxMpKefuMessage signMessage = createSignMessage(platformId, appid, userId);
+            Integer second = afterNow();
+            if (second > 0) {
+                redisService.set(redisService.getKeyListener().getKeyMpSign(platformId, appid, userId), userId + "", second);
+                return;
+            }
+            WxMpKefuMessage signMessage = createSignMessage(platformId, appid, userId);
 
 
-        WxOpenService wxOpenService = wxThirdPartService.getWxOpenServiceByPlatFormId(platformId);
-        WxOpenMpService wxMpService = wxOpenService.getWxOpenComponentService().getWxMpServiceByAppid(appid);
+            WxOpenService wxOpenService = wxThirdPartService.getWxOpenServiceByPlatFormId(platformId);
+            WxOpenMpService wxMpService = wxOpenService.getWxOpenComponentService().getWxMpServiceByAppid(appid);
 
             wxMpService.getKefuService().sendKefuMessage(signMessage);
         } catch (WxErrorException e) {
             e.printStackTrace();
-            log.error("签到智能推送失败",e);
+            log.error("签到智能推送失败", e);
         }
 
 
@@ -188,21 +190,21 @@ public class IntellectPushServiceImpl implements IntellectPushService {
     @Override
     public void pushByContinueRead(Integer platformId, String appid, Integer id) {
         try {
-        Integer second = afterNow();
-        if (second > 0) {
-            redisService.set(redisService.getKeyListener().getKeyPrefixBookContinueRead(platformId, appid, id), id + "", second);
-            return;
-        }
-        WxMpKefuMessage signMessage = createContinueReadMessage(platformId, appid, id);
+            Integer second = afterNow();
+            if (second > 0) {
+                redisService.set(redisService.getKeyListener().getKeyPrefixBookContinueRead(platformId, appid, id), id + "", second);
+                return;
+            }
+            WxMpKefuMessage signMessage = createContinueReadMessage(platformId, appid, id);
 
 
-        WxOpenService wxOpenService = wxThirdPartService.getWxOpenServiceByPlatFormId(platformId);
-        WxOpenMpService wxMpService = wxOpenService.getWxOpenComponentService().getWxMpServiceByAppid(appid);
+            WxOpenService wxOpenService = wxThirdPartService.getWxOpenServiceByPlatFormId(platformId);
+            WxOpenMpService wxMpService = wxOpenService.getWxOpenComponentService().getWxMpServiceByAppid(appid);
 
             wxMpService.getKefuService().sendKefuMessage(signMessage);
         } catch (WxErrorException e) {
             e.printStackTrace();
-            log.error("继续阅读智能推送失败",e);
+            log.error("继续阅读智能推送失败", e);
         }
 
     }
@@ -210,35 +212,35 @@ public class IntellectPushServiceImpl implements IntellectPushService {
     @Override
     public void pushByNopay(Integer platformId, String appid, Integer id) {
         try {
-        WxMpKefuMessage signMessage = createNopayMessage(platformId, appid, id);
+            WxMpKefuMessage signMessage = createNopayMessage(platformId, appid, id);
 
-        WxOpenService wxOpenService = wxThirdPartService.getWxOpenServiceByPlatFormId(platformId);
-        WxOpenMpService wxMpService = wxOpenService.getWxOpenComponentService().getWxMpServiceByAppid(appid);
+            WxOpenService wxOpenService = wxThirdPartService.getWxOpenServiceByPlatFormId(platformId);
+            WxOpenMpService wxMpService = wxOpenService.getWxOpenComponentService().getWxMpServiceByAppid(appid);
 
             wxMpService.getKefuService().sendKefuMessage(signMessage);
         } catch (WxErrorException e) {
             e.printStackTrace();
-            log.error("未支付提醒智能推送失败",e);
+            log.error("未支付提醒智能推送失败", e);
         }
     }
 
     @Override
     public void pushByNoSign(Integer platformId, String appid, Long userId) {
         try {
-        Integer second = afterNow();
-        if (second > 0) {
-            redisService.set(redisService.getKeyListener().getKeyMpNosign(platformId, appid, userId), userId + "", second);
-            return;
-        }
-        WxMpKefuMessage signMessage = createNoSignMessage(platformId, appid, userId);
+            Integer second = afterNow();
+            if (second > 0) {
+                redisService.set(redisService.getKeyListener().getKeyMpNosign(platformId, appid, userId), userId + "", second);
+                return;
+            }
+            WxMpKefuMessage signMessage = createNoSignMessage(platformId, appid, userId);
 
-        WxOpenService wxOpenService = wxThirdPartService.getWxOpenServiceByPlatFormId(platformId);
-        WxOpenMpService wxMpService = wxOpenService.getWxOpenComponentService().getWxMpServiceByAppid(appid);
+            WxOpenService wxOpenService = wxThirdPartService.getWxOpenServiceByPlatFormId(platformId);
+            WxOpenMpService wxMpService = wxOpenService.getWxOpenComponentService().getWxMpServiceByAppid(appid);
 
             wxMpService.getKefuService().sendKefuMessage(signMessage);
         } catch (WxErrorException e) {
             e.printStackTrace();
-            log.error("未签到提醒智能推送失败",e);
+            log.error("未签到提醒智能推送失败", e);
         }
     }
 

+ 58 - 0
book-server/src/main/java/com/book/server/config/SunTypeEnum.java

@@ -0,0 +1,58 @@
+package com.book.server.config;
+
+/**
+ * created in 2021/9/28
+ * Project, book-store
+ *
+ * @author win7
+ */
+
+public enum SunTypeEnum {
+    user("user","/channeldata/data/user/list"),
+    user_active("user_active","/channeldata/data/user/activeList"),
+
+    user_collect("user_active","/channeldata/data/user/collect"),
+
+    user_day_collect("user_day_collect","/channeldata/data/user/dayCollect"),
+
+    channel("channel","/channeldata/data/account/list"),
+    order("order","/channeldata/data/orders/list"),
+
+    custom_url("custom_url","/channeldata/data/custom/urlCollect"),
+
+    custom_url_day_collect("custom_url_day_collect","/channeldata/data/custom/urlDayCollect"),
+
+    referral("referral","/channeldata/data/referral/list"),
+
+    referral_day_collect("referral_day_collect","/channeldata/data/referral/collect"),
+
+    activity("activity","/channeldata/data/activity/list"),
+
+    activity_collect("activity_collect","/channeldata/data/activity/collect"),
+
+    activity_day_collect("activity_day_collect","/channeldata/data/activity/dayCollect");
+
+    private String path;
+    private String name;
+
+   private SunTypeEnum(String name, String path) {
+       this.name = name;
+       this.path = path;
+    }
+
+    public String getPath() {
+        return path;
+    }
+
+    public void setPath(String path) {
+        this.path = path;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+}

+ 51 - 0
book-server/src/main/java/com/book/server/controller/SunDataController.java

@@ -0,0 +1,51 @@
+package com.book.server.controller;
+
+import com.book.server.common.entity.Result;
+import com.book.server.config.SunTypeEnum;
+import com.book.server.service.SunDataService;
+import com.book.server.vo.SunNotifyRequest;
+import com.book.server.vo.SunRequest;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.codec.digest.DigestUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.websocket.server.PathParam;
+import java.util.UUID;
+
+/**
+ * created in 2021/9/27
+ * Project: book-store
+ *
+ * @author win7
+ */
+@RestController
+@RequestMapping("/api/sun")
+@Slf4j
+public class SunDataController extends BaseController {
+@Autowired
+private SunDataService sunDataService;
+
+
+    @PostMapping("/getData/{type}")
+    public Result getData(@PathVariable("type") String type,@RequestBody SunRequest request) {
+        SunTypeEnum sunTypeEnum = SunTypeEnum.valueOf(type);
+      return   sunDataService.requestData(request,sunTypeEnum);
+
+    }
+    @PostMapping("/pullData")
+    public String pushData( SunNotifyRequest request) {
+        sunDataService.pullData(request);
+        String s = "{\"code\":200\",msg\":\"ok\"}";
+        return s;
+
+    }
+
+
+
+
+    public static void main(String[] args) {
+        System.out.println(UUID.randomUUID().toString());
+    }
+
+}

+ 22 - 0
book-server/src/main/java/com/book/server/service/SunDataService.java

@@ -0,0 +1,22 @@
+package com.book.server.service;
+
+import com.book.server.common.entity.Result;
+import com.book.server.config.SunTypeEnum;
+import com.book.server.vo.SunNotifyRequest;
+import com.book.server.vo.SunRequest;
+import com.book.server.vo.SunResult;
+
+/**
+ * created in 2021/9/28
+ * Project: book-store
+ *
+ * @author win7
+ */
+
+public interface SunDataService {
+
+    Result requestData(SunRequest request,SunTypeEnum sunTypeEnum);
+
+    void pullData(SunNotifyRequest request);
+
+}

+ 164 - 0
book-server/src/main/java/com/book/server/service/impl/SunDataServiceImpl.java

@@ -0,0 +1,164 @@
+package com.book.server.service.impl;
+
+import com.book.dao.utils.DateUtils;
+import com.book.server.common.entity.Result;
+import com.book.server.common.util.JsonUtils;
+import com.book.server.config.SunTypeEnum;
+import com.book.server.service.SunDataService;
+import com.book.server.utils.DataUtil;
+import com.book.server.utils.HttpTool;
+import com.book.server.utils.HttpUtils;
+import com.book.server.vo.*;
+import com.google.gson.Gson;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.codec.digest.DigestUtils;
+import org.springframework.stereotype.Service;
+
+import java.nio.charset.StandardCharsets;
+import java.util.*;
+
+/**
+ * created in 2021/9/28
+ * Project: book-store
+ *
+ * @author win7
+ */
+@Service
+@Slf4j
+public class SunDataServiceImpl implements SunDataService {
+    private static final String CLIENT_ID = "10005818";
+    private static final String TOKEN = "PKp2HD39ze3CdzizqH";
+    private static final String VIP_ID = "36637";
+    private static final String URL = "https://data.yifengaf.cn";
+
+
+    @Override
+    public Result requestData(SunRequest request, SunTypeEnum sunTypeEnum) {
+        try {
+
+            String url = URL + sunTypeEnum.getPath();
+            request.setClient_id(CLIENT_ID);
+//            request.setToken(TOKEN);
+            request.setNonce(UUID.randomUUID().toString().replace("-", ""));
+            request.setTimestamp(System.currentTimeMillis() + "");
+            request.setVip_id(VIP_ID);
+            String signaure = DigestUtils.sha1Hex(TOKEN + request.getTimestamp() + CLIENT_ID + request.getNonce());
+            request.setSignaure(signaure);
+
+            String jsonStr = JsonUtils.toJsonStr(request);
+            Map<String, Object> map = JsonUtils.getMap(jsonStr);
+            String s = DataUtil.map2form(map);
+
+            String result = HttpUtils.sendPost(url, s.getBytes(StandardCharsets.UTF_8));
+            log.info("请求" + sunTypeEnum.getName() + ":" + JsonUtils.toJsonStr(request));
+            log.info("响应" + sunTypeEnum.getName() + ":" + JsonUtils.toJsonStr(result));
+            SunResult object = JsonUtils.getObject(result, SunResult.class);
+            if (object != null && 0 == object.getError_code()) {
+                return Result.success();
+            } else {
+                return object == null ? Result.failure() : Result.failure(object.getError_code(), object.getError_msg());
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error("sun 获取数据异常:" + e.getMessage());
+        }
+        return Result.failure();
+    }
+
+    @Override
+    public void pullData(SunNotifyRequest request) {
+        try {
+
+
+            String type = request.getType();
+            String path = request.getPath();
+            Integer taskId = request.getTaskId();
+            String url = URL + path;
+            List<String> list = HttpTool.sendGet(url);
+            if (list == null || list.isEmpty()) {
+                log.error("读取sun文件为空");
+                return;
+            }
+            SunTypeEnum sunTypeEnum = SunTypeEnum.valueOf(type);
+
+            List result = new ArrayList();
+            StringBuilder sb = new StringBuilder();
+            for (int i = 0; i < list.size(); i++) {
+                String line = list.get(i);
+                switch (sunTypeEnum) {
+                    case user:
+
+                    case user_active:
+                        SunTypeUser sunTypeUser = JsonUtils.getObject(line, SunTypeUser.class);
+                        result.add(sunTypeUser);
+                        break;
+                    case user_collect:
+
+                    case user_day_collect:
+                        SunTypeUserDayCollect sunTypeUserDayCollect = JsonUtils.getObject(line, SunTypeUserDayCollect.class);
+                        result.add(sunTypeUserDayCollect);
+                        break;
+                    case channel:
+                        SunTypeChannel sunTypeChannel = JsonUtils.getObject(line, SunTypeChannel.class);
+                        result.add(sunTypeChannel);
+                        break;
+                    case order:
+                        SunTypeOrder sunTypeOrder = JsonUtils.getObject(line, SunTypeOrder.class);
+                        result.add(sunTypeOrder);
+                        break;
+                    case custom_url:
+                        SunTypeCustomUrl sunTypeCustomUrl = JsonUtils.getObject(line, SunTypeCustomUrl.class);
+                        result.add(sunTypeCustomUrl);
+                        break;
+                    case custom_url_day_collect:
+                        SunTypeCustomUrlCollect sunTypeCustomUrlCollect = JsonUtils.getObject(line, SunTypeCustomUrlCollect.class);
+                        result.add(sunTypeCustomUrlCollect);
+                        break;
+                    case referral:
+                        SunTypeReferral sunTypeReferral = JsonUtils.getObject(line, SunTypeReferral.class);
+                        result.add(sunTypeReferral);
+                        break;
+                    case referral_day_collect:
+                        SunTypeReferralCollect sunTypeReferralCollect = JsonUtils.getObject(line, SunTypeReferralCollect.class);
+                        result.add(sunTypeReferralCollect);
+                        break;
+                    case activity:
+                        SunTypeActivity sunTypeActivity = JsonUtils.getObject(line, SunTypeActivity.class);
+                        result.add(sunTypeActivity);
+                        break;
+                    case activity_collect:
+
+                    case activity_day_collect:
+                        SunTypeActivityCollect sunTypeActivityCollect = JsonUtils.getObject(line, SunTypeActivityCollect.class);
+                        result.add(sunTypeActivityCollect);
+                        break;
+                    default:
+                        break;
+                }
+
+                Map map = new Gson().fromJson(line, Map.class);
+
+                Set<String> set = map.keySet();
+                if (i == 0) {
+                    for (String key : set) {
+
+                        sb.append(key + ",");
+                    }
+
+                    sb.append("\n");
+                }
+                for (String key : set) {
+
+                    sb.append(map.get(key) + ",");
+                }
+                sb.append("\n");
+
+            }
+//        System.out.println(sb.toString());
+            log.info(sb.toString());
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error("sun解析数据出错:", e.getMessage());
+        }
+    }
+}

+ 95 - 0
book-server/src/main/java/com/book/server/task/SunDataTask.java

@@ -0,0 +1,95 @@
+package com.book.server.task;
+
+import com.book.dao.utils.DateUtils;
+import com.book.dao.utils.TimeUtil;
+import com.book.server.common.entity.Result;
+import com.book.server.config.SunTypeEnum;
+import com.book.server.service.SunDataService;
+import com.book.server.vo.SunRequest;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+import java.util.Calendar;
+
+/**
+ * created in 2021/9/28
+ * Project: book-store
+ *
+ * @author win7
+ */
+@Component
+@EnableScheduling
+@Slf4j
+public class SunDataTask {
+    public static final Integer FIX_DELAY_HOUR = 4;
+
+    @Autowired
+    private SunDataService sunDataService;
+    @Scheduled(cron = "0 0 */1 * * ?")
+    private void getData() {
+        log.info("定时拉取sun数据");
+        String timeFrom = TimeUtil.getDateStrAfter(-FIX_DELAY_HOUR, Calendar.HOUR_OF_DAY,TimeUtil.YYYY_M_DD_HH_MM_SS);
+        String timeNow = TimeUtil.getCurrentDate(TimeUtil.YYYY_M_DD_HH_MM_SS);
+        String dateNow = TimeUtil.getCurrentDate(TimeUtil.YYYYMMDD1);
+
+        String channelId = "";
+
+
+        for (SunTypeEnum sunTypeEnum : SunTypeEnum.values()) {
+            SunRequest request =new SunRequest();
+
+            switch (sunTypeEnum) {
+                case user:
+                    request.setStart_time(timeFrom);
+                    request.setEnd_time(timeNow);
+                    if (request.getIs_update() == null ) {
+                        request.setIs_update("1");
+                    }
+                    break;
+                case user_active:
+                    request.setSearch_date(dateNow);
+
+                    break;
+                case user_collect:
+                case user_day_collect:
+                    request.setStart_time(timeFrom);
+                    request.setEnd_time(timeNow);
+
+
+                    break;
+                case channel:
+                    request.setChannel_id(channelId);
+                    break;
+                case order:
+                    request.setIs_finish("1");
+                    break;
+                case custom_url:
+
+                case custom_url_day_collect:
+                case referral:
+                case referral_day_collect:
+                case activity:
+                    request.setStart_time(timeFrom);
+                    request.setEnd_time(timeNow);
+
+                    break;
+                case activity_collect:
+                    break;
+                case activity_day_collect:
+                    request.setStart_time(timeFrom);
+                    request.setEnd_time(timeNow);
+
+                    break;
+                default:
+                    break;
+
+            }
+
+            Result result = sunDataService.requestData(request, sunTypeEnum);
+
+        }
+    }
+}

+ 11 - 1
book-server/src/main/java/com/book/server/utils/DataUtil.java

@@ -30,7 +30,17 @@ public class DataUtil {
 	
 		return str;
 	}
-	
+	public static String map2form(Map<String, Object> map){
+		String str="";
+
+		for(String key:map.keySet()){
+			str=str+key+"="+String.valueOf(map.get(key))+"&";
+		}
+		str = str.substring(0,str.length()-1);
+
+		return str;
+	}
+
 	 public static String createLinkString(Map<String, String> params) {
 	        List<String> keys = new ArrayList<String>(params.keySet());
 	        Collections.sort(keys);

+ 52 - 0
book-server/src/main/java/com/book/server/utils/HttpTool.java

@@ -83,6 +83,58 @@ public class HttpTool {
         }
         return response.toString();
     }
+    public static List<String> sendGet(final String address) {
+        StringBuilder response = new StringBuilder();
+        List<String> list = new ArrayList();
+        HttpURLConnection connection = null;
+        InputStream in = null;
+        try {
+            // 创建一个URL对象并传入地址
+            URL url = new URL(address);
+            // 用地址打开连接通道
+            connection = (HttpURLConnection) url.openConnection();
+            // 设置请求方式为get
+            connection.setRequestMethod("GET");
+            // 设置连接超时为8秒
+            connection.setConnectTimeout(8000);
+            // 设置读取超时为8秒
+            connection.setReadTimeout(8000);
+            connection.setRequestProperty("Charset", "utf-8");
+            // 设置可取
+//			connection.setDoInput(true);
+//			// 设置可读
+//			connection.setDoOutput(true);
+//			// 得到输入流
+            in = connection.getInputStream();
+
+            // 创建高效流对象
+            BufferedReader reader = new BufferedReader(new InputStreamReader(in, StandardCharsets.UTF_8));
+            // 创建StringBuilder对象存储数据
+
+            String line;// 一次读取一行
+            while ((line = reader.readLine()) != null) {
+                response.append(line);// 得到的数据存入StringBuilder
+                list.add(line);
+            }
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            if (connection != null) {// 通道不为null
+                connection.disconnect();// 关闭通道
+            }
+            try {
+                if (in != null) {
+                    in.close();
+                }
+
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+//        return response.toString();
+        return list;
+    }
 
     /**
      * 向指定URL发送GET方法的请求

+ 0 - 1
book-server/src/main/java/com/book/server/utils/HttpUtils.java

@@ -346,7 +346,6 @@ public class HttpUtils {
 		        .setConnectTimeout(5000).setConnectionRequestTimeout(1000)  
 		        .setSocketTimeout(30000).build(); 
 		httpget.setConfig(requestConfig);
-		httpget.setHeader("Referer", "http://pay.zhangzhongzhifu.com");
 		String result = "";
 		CloseableHttpResponse resp =null;
 		try {

+ 16 - 0
book-server/src/main/java/com/book/server/vo/SunNotifyRequest.java

@@ -0,0 +1,16 @@
+package com.book.server.vo;
+
+import lombok.Data;
+
+/**
+ * created in 2021/9/28
+ * Project: book-store
+ *
+ * @author win7
+ */
+@Data
+public class SunNotifyRequest {
+    private String path;
+    private Integer taskId;
+    private String type;
+}

+ 25 - 0
book-server/src/main/java/com/book/server/vo/SunRequest.java

@@ -0,0 +1,25 @@
+package com.book.server.vo;
+
+import lombok.Data;
+
+/**
+ * created in 2021/9/27
+ * Project: book-store
+ *
+ * @author win7
+ */
+@Data
+public class SunRequest {
+    private String client_id;
+    private String token;
+    private String nonce;
+    private String timestamp;
+    private String signaure;
+    private String channel_id;
+    private String vip_id;
+    private String start_time;
+    private String end_time;
+    private String is_finish;
+    private String search_date;
+    private String is_update;
+}

+ 22 - 0
book-server/src/main/java/com/book/server/vo/SunResult.java

@@ -0,0 +1,22 @@
+package com.book.server.vo;
+
+import lombok.Data;
+
+/**
+ * created in 2021/9/27
+ * Project: book-store
+ *
+ * @author win7
+ */
+@Data
+public class SunResult {
+    private int error_code;
+    private String error_msg;
+    private Data data;
+
+    @lombok.Data
+    static class Data {
+        private int task_id;
+    }
+
+}

+ 19 - 0
book-server/src/main/java/com/book/server/vo/SunTypeActivity.java

@@ -0,0 +1,19 @@
+package com.book.server.vo;
+
+/**
+ * created in 2021/9/28
+ * Project: book-store
+ *
+ * @author win7
+ */
+
+public class SunTypeActivity {
+    private String id;//	int(10)	书单ID	唯一
+    private String name;//	string(60)	活动名称
+    private String copywriting;//	string(100)	活动文案
+    private String starttime;//	int(10)	活动开始时间
+    private String endtime;//	int(10)	活动结束时间
+    private String url;//	string(128)	活动链接
+    private String channel_id;//	int	渠道id
+    private String create_time;//	int(11)	活动创建时间
+}

+ 23 - 0
book-server/src/main/java/com/book/server/vo/SunTypeActivityCollect.java

@@ -0,0 +1,23 @@
+package com.book.server.vo;
+
+import lombok.Data;
+
+/**
+ * created in 2021/9/28
+ * Project: book-store
+ *
+ * @author win7
+ */
+@Data
+public class SunTypeActivityCollect {
+    private String id;//int(10)	书单ID	唯一
+    private String activity_id;//	int(10)	活动ID
+    private String channel_id;//	int	渠道ID
+    private String pv;//	int	访问pv
+    private String uv;//	int	uv
+    private String join_uv;//	int(10)	参加活动的uv
+    private String complete_uv;//	int(10)	完成活动的uv
+    private String complete_count;//	string(128)	参加活动的次数
+    private String orders_count;//	int	总支付次数
+    private String orders_money;//	int(11)	总支付金额
+}

+ 19 - 0
book-server/src/main/java/com/book/server/vo/SunTypeChannel.java

@@ -0,0 +1,19 @@
+package com.book.server.vo;
+
+import lombok.Data;
+
+/**
+ * created in 2021/9/28
+ * Project: book-store
+ *
+ * @author win7
+ */
+@Data
+public class SunTypeChannel {
+private String channel_id;//	渠道id
+private String app_id;//	公众号APPID
+private String wx_nickname;//	公众号昵称
+private String nickname;//	渠道商昵称
+private String username;//	渠道商账号
+private String domain;//	渠道业务域名
+}

+ 28 - 0
book-server/src/main/java/com/book/server/vo/SunTypeCustomUrl.java

@@ -0,0 +1,28 @@
+package com.book.server.vo;
+
+import lombok.Data;
+
+/**
+ * created in 2021/9/28
+ * Project: book-store
+ *
+ * @author win7
+ */
+@Data
+public class SunTypeCustomUrl {
+    private String custom_id;//	消息ID	唯一
+    private String channel_id;//	渠道ID
+    private String title;//	任务名称
+    private String idx;//	位置。微信图文的第几条链接
+    private String url;//	客服消息的消息url(每个位置的url不同)
+    private String push_type;//	链接类型	0外派 1内推
+    private String send_time;//	发送时间
+    private String send_num;//发送人数
+    private String recharge_orders;//	订单数量
+    private String uv;//	uv
+    private String recharge_money;//	总充值金额
+    private String ghid;//	公众号原始ID
+    private String authorizer_nickname;//	用户来源账号
+    private String authorizer_appid;//	公众号APPID
+    private String create_time;//
+}

+ 29 - 0
book-server/src/main/java/com/book/server/vo/SunTypeCustomUrlCollect.java

@@ -0,0 +1,29 @@
+package com.book.server.vo;
+
+import lombok.Data;
+
+/**
+ * created in 2021/9/28
+ * Project: book-store
+ *
+ * @author win7
+ */
+@Data
+public class SunTypeCustomUrlCollect {
+    private String custom_id;//	消息ID	唯一
+    private String channel_id;//	渠道ID
+    private String date;//	日期
+    private String title;//	任务名称
+    private String idx;//	位置。微信图文的第几条链接
+    private String push_type;//	链接类型	0外派 1内推
+    private String send_time;//	发送时间
+    private String send_num;//	发送人数
+    private String recharge_orders;//	订单数量
+    private String uv;//	uv
+    private String recharge_money;//	总充值金额
+    private String ghid;//公众号原始ID
+    private String authorizer_nickname;//	用户来源账号
+    private String authorizer_appid;//	公众号APPID
+    private String create_time;//
+
+}

+ 29 - 0
book-server/src/main/java/com/book/server/vo/SunTypeOrder.java

@@ -0,0 +1,29 @@
+package com.book.server.vo;
+
+import lombok.Data;
+
+/**
+ * created in 2021/9/28
+ * Project: book-store
+ *
+ * @author win7
+ */
+@Data
+public class SunTypeOrder {
+    private String merchant_id;//	商户单号	唯一
+    private String transaction_id;//	交易单号
+    private String type;//	订单类型,(书币充值, VIP充值)
+    private String money;//	总额
+    private String state;//	订单状态,(未完成 , 完成)
+    private String create_time;//	下单时间
+    private String finish_time;//	完成时间
+    private String book_name;//	书名
+    private String referral_url;//推广链接
+    private String user_id;//	用户id
+    private String channel_id;//	渠道id
+    private String subscribe_time;//	用戶关注时间
+    private String user_createtime;//	用户注册时间
+    private String openid;//	用户openid
+    private String ip;//	下单ip
+    private String user_agent;//	用户最近一次访问ua
+}

+ 27 - 0
book-server/src/main/java/com/book/server/vo/SunTypeReferral.java

@@ -0,0 +1,27 @@
+package com.book.server.vo;
+
+import lombok.Data;
+
+/**
+ * created in 2021/9/28
+ * Project: book-store
+ *
+ * @author win7
+ */
+@Data
+public class SunTypeReferral {
+    private String id;//	int(10)	推广链接ID	唯一
+    private String channel_id;//	int(10)	渠道ID
+    private String type;//int(10)	推广类型:1=阅读页推广,2=书城首页推广,3=落地页推广
+    private String name;//	varchar(100)	派单渠道名称
+    private String nickname;//string(50)	渠道昵称
+    private String username;//	string(20)	渠道用户名
+    private String source_url;//	string(255)	原文链接
+    private String money;//	decimal(10,2)	充值金额
+    private String orders_num;//	int(10)	订单数
+    private String uv;//	int(10)	阅读人数
+    private String entry_page;//	string(255)	入口页面
+    private String wx_nick_name;//	string(255)	公众号
+    private String createtime;//	int(10)	创建时间
+    private String push;//	int	内推外派:0=外派,1=内推
+}

+ 21 - 0
book-server/src/main/java/com/book/server/vo/SunTypeReferralCollect.java

@@ -0,0 +1,21 @@
+package com.book.server.vo;
+
+import lombok.Data;
+
+/**
+ * created in 2021/9/28
+ * Project: book-store
+ *
+ * @author win7
+ */
+@Data
+public class SunTypeReferralCollect {
+    private String referral_id;//	int(10)	推广链接ID	唯一
+    private String createdate;//	int(10)	统计日期
+    private String pv;//	int(10)
+    private String uv;//	int(10)	阅读人数
+    private String recharge_money;//	int	充值金额
+    private String orders_num;//	int	充值单数
+    private String follow;//	int	关注人数
+    private String incr_num;//	int	新增人数
+}

+ 64 - 0
book-server/src/main/java/com/book/server/vo/SunTypeUser.java

@@ -0,0 +1,64 @@
+package com.book.server.vo;
+
+import lombok.Data;
+
+/**
+ * created in 2021/9/28
+ * Project: book-store
+ *
+ * @author win7
+ */
+@Data
+public class SunTypeUser {
+    private String user_id;
+    //用户ID唯一;
+    private String nickname;
+    //用户昵称;
+    private String openid;
+    //微信openid;
+    private String mobile;
+    //手机号;
+    private String province;
+    //省份;
+    private String city;
+    //城市;
+    private String sex;
+    //状态值:未知,男性,女性;
+    private String is_subscribe;
+    //关注公众号状态:已关注,未关注;
+    private String operatetime;
+    //服务号交互时间(微信交互时间戳);
+    private String registertime;
+    //用户注册时间;
+    private String authorizer_nickname;
+    //公众号昵称;
+    private String authorizer_appid;
+    //公众号APPID;
+    private String subscribe_time;
+    //关注时间;
+    private String channel_id;
+    //所属渠道id;
+    private String vip_end_time;
+    //vip结束时间;
+    private String recharge_amount;
+    //充值金额;
+    private String recharge_num;
+    //充值次数;
+    private String first_pay;
+    //首冲金额
+    private String last_recharge_time;
+    //最近一次充值时间;
+    private String total_kandian;
+    //总数币;
+    private String kandian;
+    //剩余书币;
+    private String referral_id;
+    //推广链接ID,最近一次推广链接的ID;
+    private String referral_id_permanent;
+    //推广链接ID(原始ID);
+    private String register_ip;
+    //注册IP;
+    private String user_agent;
+    //UA
+
+}

+ 21 - 0
book-server/src/main/java/com/book/server/vo/SunTypeUserDayCollect.java

@@ -0,0 +1,21 @@
+package com.book.server.vo;
+
+import lombok.Data;
+
+/**
+ * created in 2021/9/28
+ * Project: book-store
+ *
+ * @author win7
+ */
+@Data
+public class SunTypeUserDayCollect {
+    private String hannel_id;//	渠道ID
+    private String increase;//	新增总人数
+    private String increase_fllow;//	新增已关数量
+    private String unfollow_num;//	取消关注人数
+    private String net_follow_num;//	净关注人数
+    private String increase_recharge;//	新增付费人数
+    private String day_recharge_user_count;//	日新增支付人数
+    private String day_recharge_user_money;//	日新增用户充值金额
+}

+ 49 - 0
book-server/src/test/java/com/book/server/controller/SunControllerTest.java

@@ -0,0 +1,49 @@
+package com.book.server.controller;
+
+import lombok.extern.slf4j.Slf4j;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.http.MediaType;
+import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.web.servlet.MockMvc;
+import org.springframework.test.web.servlet.MvcResult;
+import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
+import org.springframework.test.web.servlet.result.MockMvcResultHandlers;
+import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
+
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
+
+/**
+ * created in 2021/9/28
+ * Project: book-store
+ *
+ * @author win7
+ */
+@Slf4j
+@RunWith(SpringRunner.class)
+@SpringBootTest
+@AutoConfigureMockMvc
+public class SunControllerTest {
+    @Autowired
+    private MockMvc mockMvc;
+    @Autowired
+    private SunDataController sunDataController;
+
+    @Test
+    public void testAdd() throws Exception {
+        MockMvc mockMvc1 = mockMvc;
+        MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.post("/api/sun/secret/deciphering")
+                .accept(MediaType.APPLICATION_JSON)
+                .param("start_time", "2021-09-27 00:00:00")
+                .param("end_time", "2021-09-28 00:00:00"))
+                .andExpect(MockMvcResultMatchers.status().isOk())
+                .andDo(MockMvcResultHandlers.print())
+                .andReturn();
+
+
+        log.info(mvcResult.getResponse().getContentAsString());
+    }
+}