Sfoglia il codice sorgente

移除多余的包

tianyunperfect 3 anni fa
parent
commit
bfad114d7b

+ 8 - 5
book-dao/src/main/resources/polar-mybatis-generator.xml

@@ -103,9 +103,9 @@
         <!--数据库连接配置 need to change-->
         <jdbcConnection
                 driverClass="com.mysql.cj.jdbc.Driver"
-                connectionURL="jdbc:mysql://121.41.100.198:3306/polardb?nullCatalogMeansCurrent=true&amp;serverTimezone=UTC"
-                userId="root"
-                password="root"/>
+                connectionURL="jdbc:mysql://rm-bp1978b18gyf7v7by.mysql.rds.aliyuncs.com:3306/polardb?nullCatalogMeansCurrent=true&amp;serverTimezone=UTC"
+                userId="test_cps"
+                password="oRt+rY(7x3&amp;kB#OQdit9"/>
 
         <!--指定自动生成的 POJO置于哪个包下 need to change -->
         <javaModelGenerator targetPackage="com.book.dao.polardb.entity"
@@ -133,8 +133,11 @@
         <!--        <table tableName="sun_user_collect"/>-->
         <!--        <table tableName="sun_order"/>-->
         <!--        <table tableName="sun_order_collect"/>-->
-        <table tableName="sun_user"></table>
-        <table tableName="sun_user_active"></table>
+        <!--<table tableName="sun_user"></table>-->
+        <!--<table tableName="sun_user_active"></table>-->
+        <table tableName="sun_static_order"></table>
+        <table tableName="sun_static_order_day"></table>
+        <table tableName="sun_static_order_day_channel"></table>
     </context>
 
 </generatorConfiguration>

+ 29 - 32
book-push/src/main/java/com/book/push/service/push/IntellectPushService.java

@@ -1,32 +1,29 @@
-package com.book.push.service.push;
-
-import com.sun.org.apache.bcel.internal.generic.PUSH;
-import me.chanjar.weixin.mp.bean.kefu.WxMpKefuMessage;
-
-/**
- * created in 2021/9/7
- * Project: book-store
- *
- * @author win7
- */
-
-public interface IntellectPushService {
-    public static final long TIME_AFTER_SUBSCRIBE = 6 * 60 * 60;
-    public static final long TIME_AFTER_SIGN = 10 * 60 * 60;
-//    public static final long TIME_AFTER_SIGN = 2* 60;
-    public static final long TIME_AFTER_NOSIGN = 24 * 60 * 60;
-    public static final long TIME_AFTER_READ =  7* 60 * 60;
-
-
-    void pushBySubscribe(Integer platformId, String appid, Long userId);
-
-    void pushBySign(Integer platformId, String appid, Long userId);
-
-    void pushByContinueRead(Integer platformId, String appid, Integer id);
-
-    void pushByNopay(Integer platformId, String appid, Integer id);
-
-    void pushByNoSign(Integer platformId, String appid, Long userId);
-
-
-}
+package com.book.push.service.push;
+
+/**
+ * created in 2021/9/7
+ * Project: book-store
+ *
+ * @author win7
+ */
+
+public interface IntellectPushService {
+    public static final long TIME_AFTER_SUBSCRIBE = 6 * 60 * 60;
+    public static final long TIME_AFTER_SIGN = 10 * 60 * 60;
+//    public static final long TIME_AFTER_SIGN = 2* 60;
+    public static final long TIME_AFTER_NOSIGN = 24 * 60 * 60;
+    public static final long TIME_AFTER_READ =  7* 60 * 60;
+
+
+    void pushBySubscribe(Integer platformId, String appid, Long userId);
+
+    void pushBySign(Integer platformId, String appid, Long userId);
+
+    void pushByContinueRead(Integer platformId, String appid, Integer id);
+
+    void pushByNopay(Integer platformId, String appid, Integer id);
+
+    void pushByNoSign(Integer platformId, String appid, Long userId);
+
+
+}

+ 188 - 189
book-push/src/main/java/com/book/push/task/KefuTask.java

@@ -1,189 +1,188 @@
-package com.book.push.task;
-
-import com.book.dao.cps.entity.CustomMediaPush;
-import com.book.dao.cps.entity.CustomUrl;
-import com.book.dao.cps.pojo.AdminConfig;
-import com.book.dao.cps.pojo.Custom;
-import com.book.dao.cps.pojo.Ophost;
-import com.book.dao.cps.pojo.User;
-import com.book.dao.utils.DateUtils;
-import com.book.push.service.dao.*;
-import com.book.push.service.push.PushService;
-import com.book.push.service.push.vo.CustomMessage;
-import com.book.push.service.wx.WxThirdPartService;
-import com.book.push.utils.JsonUtils;
-import com.sun.corba.se.spi.ior.IdentifiableFactory;
-import lombok.extern.slf4j.Slf4j;
-import me.chanjar.weixin.mp.bean.kefu.WxMpKefuMessage;
-import me.chanjar.weixin.mp.builder.kefu.NewsBuilder;
-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.scheduling.annotation.Scheduled;
-import org.springframework.stereotype.Component;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.TimeUnit;
-
-/**
- * created in 2021/8/17
- * Project: book-store
- * 客服消息
- *
- * @author win7
- */
-
-@Component
-@Slf4j
-public class KefuTask {
-    @Autowired
-    private CustomService customService;
-    @Autowired
-    private AdminConfigService adminConfigService;
-    @Autowired
-    private WxThirdPartService wxThirdPartService;
-    @Autowired
-    private UserService userService;
-    @Autowired
-    private PushService pushService;
-    @Autowired
-    private CustomUrlService customUrlService;
-    @Autowired
-    private CustomMediaPushService customMediaPushService;
-    @Autowired
-    private OpHostService opHostService;
-
-    @Scheduled(fixedRate = 1000 * 60 * 10)
-    public void run() {
-        Integer now = DateUtils.getNow();
-        Integer to = now + (1000 * 60 * 10);
-        List<Custom> customs = customService.selectListBetweenSendTime(now, to);
-        for (Custom custom : customs) {
-
-            System.out.println("kefu-task...");
-            Integer sendtime = custom.getSendtime();
-            Integer delay = sendtime - DateUtils.getNow();
-
-            Integer customId = custom.getId();
-            Integer customMediaPushId = custom.getCustomMediaPushId();
-            CustomMediaPush customMediaPush = customMediaPushService.selectById(customMediaPushId);
-            CustomUrl customUrl = customUrlService.selectByCustomId(customId);
-
-
-            Integer adminId = custom.getAdminId();
-            AdminConfig adminConfig = adminConfigService.selectByAdminId(adminId);
-            String appid = adminConfig.getAppid();
-            Integer platformId = adminConfig.getPlatformId();
-            Ophost ophost = opHostService.selectById(adminConfig.getOphostId());
-
-            String userJsonStr = custom.getUserJson().toString();
-            userJsonStr = userJsonStr.substring(1, userJsonStr.length() - 1).replace("\\", "");
-            Custom.UserJson userJson = JsonUtils.getObject(userJsonStr, Custom.UserJson.class);
-            List<User> userList = getListByjson(userJson, adminId);
-
-            List<WxMpKefuMessage> messageList = new ArrayList<>();
-
-            log.info("检测到客服消息:消息id:{},符合条件的人数:{}",custom.getId(),userList.size());
-            for (User user : userList) {
-
-                if ("0".equals(custom.getMessageType())) {
-                    String messageJson = custom.getMessageJson().toString().replace("\\", "");
-                    messageJson = messageJson.replace("\\", "").substring(1, messageJson.length() - 1);
-
-                   Custom.MessageJson[] messageJsons = JsonUtils.getArray(messageJson, Custom.MessageJson.class);
-                    NewsBuilder newsBuilder = new NewsBuilder().toUser(user.getOpenid());
-                    for (Custom.MessageJson message : messageJsons) {
-                        WxMpKefuMessage.WxArticle wxArticle = new WxMpKefuMessage.WxArticle();
-                        wxArticle.setTitle(message.getTitle());
-                        wxArticle.setPicUrl(message.getImage());
-                        wxArticle.setDescription(message.getDescription());
-                        String url = message.getUrl()==null?"":message.getUrl().replace("{$ophost}",ophost.getHost());
-                        wxArticle.setUrl(url);
-                        newsBuilder.addArticle(wxArticle);
-
-                    }
-                    WxMpKefuMessage kefuMessage = newsBuilder.build();
-                    messageList.add(kefuMessage);
-                } else {
-                    if (StringUtils.isNotEmpty(custom.getMessageText())){
-                        String text = custom.getMessageText();
-
-                            text = text.replace("{$ophost}",ophost.getHost());
-                        WxMpKefuMessage build = new TextBuilder().toUser(user.getOpenid()).content(text).build();
-                        messageList.add(build);
-                    }
-
-
-                }
-            }
-
-
-            custom.setSendNum(messageList.size());
-            WxOpenService wxOpenService = wxThirdPartService.getWxOpenServiceByPlatFormId(platformId);
-            WxOpenMpService wxMpService = wxOpenService.getWxOpenComponentService().getWxMpServiceByAppid(adminConfig.getAppid());
-            CustomMessage customMessage = new CustomMessage();
-            customMessage.setCustom(custom);
-            customMessage.setMessageList(messageList);
-            customMessage.setCustomService(customService);
-
-            pushService.addCustomMessagePushTask(wxMpService, customMessage, delay, TimeUnit.SECONDS);
-
-
-        }
-    }
-
-    private List<User> getListByjson(Custom.UserJson userJson, Integer channelId) {
-        // "{\"sex\":-1,\"tag\":-1,\"consume\":-1,\"kandian\":-1,\"subscribe_time\":-1,\"all\":\"0\"}"
-//        "{\"sex\":2,\"mobile_system\":2,\"tag\":8,\"consume\":4,\"kandian\":2,\"subscribe_time\":7,\"all\":\"0\"}"
-
-        Map map = new HashMap<>();
-        map.put("channel_id", channelId);
-        if (!"1".equals(userJson.getAll())) {
-            if (userJson.getKandian() == 1) {
-                map.put("kandian_max", "500");
-            } else if (userJson.getKandian() == 2) {
-                map.put("kandian_max", "2000");
-            } else if (userJson.getKandian() == 3) {
-                map.put("kandian_min", "2000");
-            }
-
-            if (userJson.getSex() != -1) {
-                map.put("sex", userJson.getSex());
-            }
-            if (userJson.getConsume() == 1) {
-                map.put("is_pay", "0");
-            } else if (userJson.getConsume() == 4) {
-                map.put("is_pay", "1");
-            }
-            if (userJson.getTag() != -1) {
-                map.put("tag", userJson.getTag());
-            }
-            if (userJson.getSubscribe_time() != -1) {
-                int subscribeTime = -1;
-                if (userJson.getSubscribe_time() == 6) {
-                    subscribeTime = DateUtils.getNow() - 12 * 60 * 60;
-                } else if (userJson.getSubscribe_time() == 7) {
-                    subscribeTime = DateUtils.getNow() - 24 * 60 * 60;
-                } else if (userJson.getSubscribe_time() == 8) {
-                    subscribeTime = DateUtils.getNow() - 48 * 60 * 60;
-                } else if (userJson.getSubscribe_time() == 9) {
-                    subscribeTime = DateUtils.getNow() - 7 * 24 * 60 * 60;
-                } else if (userJson.getSubscribe_time() == 10) {
-                    subscribeTime = DateUtils.getNow() - 15 * 24 * 60 * 60;
-                }
-                map.put("subscribe_time", subscribeTime);
-            }
-
-        }
-        List<User> users = userService.selectListByPushMap(map);
-        return users;
-
-    }
-
-
-}
+package com.book.push.task;
+
+import com.book.dao.cps.entity.CustomMediaPush;
+import com.book.dao.cps.entity.CustomUrl;
+import com.book.dao.cps.pojo.AdminConfig;
+import com.book.dao.cps.pojo.Custom;
+import com.book.dao.cps.pojo.Ophost;
+import com.book.dao.cps.pojo.User;
+import com.book.dao.utils.DateUtils;
+import com.book.push.service.dao.*;
+import com.book.push.service.push.PushService;
+import com.book.push.service.push.vo.CustomMessage;
+import com.book.push.service.wx.WxThirdPartService;
+import com.book.push.utils.JsonUtils;
+import lombok.extern.slf4j.Slf4j;
+import me.chanjar.weixin.mp.bean.kefu.WxMpKefuMessage;
+import me.chanjar.weixin.mp.builder.kefu.NewsBuilder;
+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.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * created in 2021/8/17
+ * Project: book-store
+ * 客服消息
+ *
+ * @author win7
+ */
+
+@Component
+@Slf4j
+public class KefuTask {
+    @Autowired
+    private CustomService customService;
+    @Autowired
+    private AdminConfigService adminConfigService;
+    @Autowired
+    private WxThirdPartService wxThirdPartService;
+    @Autowired
+    private UserService userService;
+    @Autowired
+    private PushService pushService;
+    @Autowired
+    private CustomUrlService customUrlService;
+    @Autowired
+    private CustomMediaPushService customMediaPushService;
+    @Autowired
+    private OpHostService opHostService;
+
+    @Scheduled(fixedRate = 1000 * 60 * 10)
+    public void run() {
+        Integer now = DateUtils.getNow();
+        Integer to = now + (1000 * 60 * 10);
+        List<Custom> customs = customService.selectListBetweenSendTime(now, to);
+        for (Custom custom : customs) {
+
+            System.out.println("kefu-task...");
+            Integer sendtime = custom.getSendtime();
+            Integer delay = sendtime - DateUtils.getNow();
+
+            Integer customId = custom.getId();
+            Integer customMediaPushId = custom.getCustomMediaPushId();
+            CustomMediaPush customMediaPush = customMediaPushService.selectById(customMediaPushId);
+            CustomUrl customUrl = customUrlService.selectByCustomId(customId);
+
+
+            Integer adminId = custom.getAdminId();
+            AdminConfig adminConfig = adminConfigService.selectByAdminId(adminId);
+            String appid = adminConfig.getAppid();
+            Integer platformId = adminConfig.getPlatformId();
+            Ophost ophost = opHostService.selectById(adminConfig.getOphostId());
+
+            String userJsonStr = custom.getUserJson().toString();
+            userJsonStr = userJsonStr.substring(1, userJsonStr.length() - 1).replace("\\", "");
+            Custom.UserJson userJson = JsonUtils.getObject(userJsonStr, Custom.UserJson.class);
+            List<User> userList = getListByjson(userJson, adminId);
+
+            List<WxMpKefuMessage> messageList = new ArrayList<>();
+
+            log.info("检测到客服消息:消息id:{},符合条件的人数:{}",custom.getId(),userList.size());
+            for (User user : userList) {
+
+                if ("0".equals(custom.getMessageType())) {
+                    String messageJson = custom.getMessageJson().toString().replace("\\", "");
+                    messageJson = messageJson.replace("\\", "").substring(1, messageJson.length() - 1);
+
+                   Custom.MessageJson[] messageJsons = JsonUtils.getArray(messageJson, Custom.MessageJson.class);
+                    NewsBuilder newsBuilder = new NewsBuilder().toUser(user.getOpenid());
+                    for (Custom.MessageJson message : messageJsons) {
+                        WxMpKefuMessage.WxArticle wxArticle = new WxMpKefuMessage.WxArticle();
+                        wxArticle.setTitle(message.getTitle());
+                        wxArticle.setPicUrl(message.getImage());
+                        wxArticle.setDescription(message.getDescription());
+                        String url = message.getUrl()==null?"":message.getUrl().replace("{$ophost}",ophost.getHost());
+                        wxArticle.setUrl(url);
+                        newsBuilder.addArticle(wxArticle);
+
+                    }
+                    WxMpKefuMessage kefuMessage = newsBuilder.build();
+                    messageList.add(kefuMessage);
+                } else {
+                    if (StringUtils.isNotEmpty(custom.getMessageText())){
+                        String text = custom.getMessageText();
+
+                            text = text.replace("{$ophost}",ophost.getHost());
+                        WxMpKefuMessage build = new TextBuilder().toUser(user.getOpenid()).content(text).build();
+                        messageList.add(build);
+                    }
+
+
+                }
+            }
+
+
+            custom.setSendNum(messageList.size());
+            WxOpenService wxOpenService = wxThirdPartService.getWxOpenServiceByPlatFormId(platformId);
+            WxOpenMpService wxMpService = wxOpenService.getWxOpenComponentService().getWxMpServiceByAppid(adminConfig.getAppid());
+            CustomMessage customMessage = new CustomMessage();
+            customMessage.setCustom(custom);
+            customMessage.setMessageList(messageList);
+            customMessage.setCustomService(customService);
+
+            pushService.addCustomMessagePushTask(wxMpService, customMessage, delay, TimeUnit.SECONDS);
+
+
+        }
+    }
+
+    private List<User> getListByjson(Custom.UserJson userJson, Integer channelId) {
+        // "{\"sex\":-1,\"tag\":-1,\"consume\":-1,\"kandian\":-1,\"subscribe_time\":-1,\"all\":\"0\"}"
+//        "{\"sex\":2,\"mobile_system\":2,\"tag\":8,\"consume\":4,\"kandian\":2,\"subscribe_time\":7,\"all\":\"0\"}"
+
+        Map map = new HashMap<>();
+        map.put("channel_id", channelId);
+        if (!"1".equals(userJson.getAll())) {
+            if (userJson.getKandian() == 1) {
+                map.put("kandian_max", "500");
+            } else if (userJson.getKandian() == 2) {
+                map.put("kandian_max", "2000");
+            } else if (userJson.getKandian() == 3) {
+                map.put("kandian_min", "2000");
+            }
+
+            if (userJson.getSex() != -1) {
+                map.put("sex", userJson.getSex());
+            }
+            if (userJson.getConsume() == 1) {
+                map.put("is_pay", "0");
+            } else if (userJson.getConsume() == 4) {
+                map.put("is_pay", "1");
+            }
+            if (userJson.getTag() != -1) {
+                map.put("tag", userJson.getTag());
+            }
+            if (userJson.getSubscribe_time() != -1) {
+                int subscribeTime = -1;
+                if (userJson.getSubscribe_time() == 6) {
+                    subscribeTime = DateUtils.getNow() - 12 * 60 * 60;
+                } else if (userJson.getSubscribe_time() == 7) {
+                    subscribeTime = DateUtils.getNow() - 24 * 60 * 60;
+                } else if (userJson.getSubscribe_time() == 8) {
+                    subscribeTime = DateUtils.getNow() - 48 * 60 * 60;
+                } else if (userJson.getSubscribe_time() == 9) {
+                    subscribeTime = DateUtils.getNow() - 7 * 24 * 60 * 60;
+                } else if (userJson.getSubscribe_time() == 10) {
+                    subscribeTime = DateUtils.getNow() - 15 * 24 * 60 * 60;
+                }
+                map.put("subscribe_time", subscribeTime);
+            }
+
+        }
+        List<User> users = userService.selectListByPushMap(map);
+        return users;
+
+    }
+
+
+}