7 | * 京东api 常量 8 | *9 | * 10 | * @Author xqyjjq walk_code@163.com 11 | * @Date 2019/2/26 16:35 12 | * @Since JDK 1.8 13 | */ 14 | public class JdApiConstans { 15 | // JD API 调用域名 16 | public static final String JD_DOMAIN = "https://router.jd.com/api"; 17 | // JD APP KEY 18 | public static final String JD_APP_KEY = "70da6acc5bf145ba9acb887ce5933d78"; 19 | // JD APP SERCET 20 | public static final String JD_APP_SERCET = "7141167921f34b1c9d9b204908cbf4b5"; 21 | // JD 联盟站点ID 22 | public static final String JD_WEB_SITE_ID = "1710858776"; 23 | 24 | } 25 | -------------------------------------------------------------------------------- /dodo-rebate-reobt-commons/src/main/java/com/dodo/project/rebate/rebot/commons/service/JdApiService.java: -------------------------------------------------------------------------------- 1 | package com.dodo.project.rebate.rebot.commons.service; 2 | 3 | import com.jd.open.api.sdk.JdException; 4 | import jd.union.open.promotion.common.get.response.UnionOpenPromotionCommonGetResponse; 5 | 6 | /* 7 | * JdApiService 8 | * 9 | *
10 | * JD相关api调用服务类 11 | *12 | * 13 | * @Author xqyjjq walk_code@163.com 14 | * @Date 2019/2/26 16:50 15 | * @Since JDK 1.8 16 | */ 17 | public interface JdApiService { 18 | 19 | /* 20 | * @Description: 获取通用推广链接 21 | * @Author: walk_code walk_code@163.com 22 | * @Param: [url] 23 | * @return: jd.union.open.promotion.common.get.response.UnionOpenPromotionCommonGetResponse 24 | * @Date: 2019/2/26 17:08 25 | */ 26 | UnionOpenPromotionCommonGetResponse getPromotionUrl(String url); 27 | } 28 | -------------------------------------------------------------------------------- /dodo-rebate-rebot-api/src/main/java/com/dodo/project/rebate/rebot/api/Application.java: -------------------------------------------------------------------------------- 1 | package com.dodo.project.rebate.rebot.api; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; 6 | import org.springframework.context.annotation.ComponentScan; 7 | 8 | /* 9 | * Application 10 | * 11 | *
12 | * 项目启动类 13 | *14 | * 15 | * @Author xqyjjq walk_code@163.comdodo--rebate-rebot-api 16 | * @Date 2019/2/20 13:50 17 | * @Since JDK 1.8 18 | */ 19 | @ComponentScan(basePackages = "com.dodo") 20 | @SpringBootApplication 21 | public class Application extends SpringBootServletInitializer { 22 | 23 | public static void main(String[] agrs) { 24 | SpringApplication.run(Application.class, agrs); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /dodo-rebate-reobt-commons/src/main/java/com/dodo/project/rebate/rebot/commons/bean/AppTypeWebviewsharedXmlBean.java: -------------------------------------------------------------------------------- 1 | package com.dodo.project.rebate.rebot.commons.bean; 2 | 3 | import javax.xml.bind.annotation.XmlAccessType; 4 | import javax.xml.bind.annotation.XmlAccessorType; 5 | import javax.xml.bind.annotation.XmlElement; 6 | 7 | /* 8 | * AppTypeWebviewsharedXmlBean 9 | * 10 | *
11 | * 微信消息类型为app, app msg webviewshared bean 12 | *13 | * 14 | * @Author xqyjjq walk_code@163.com 15 | * @Date 2019/2/27 17:58 16 | * @Since JDK 1.8 17 | */ 18 | @XmlAccessorType(XmlAccessType.FIELD) 19 | public class AppTypeWebviewsharedXmlBean { 20 | @XmlElement(name = "jsAppId") 21 | private String jsAppId; 22 | 23 | public String getJsAppId() { 24 | return jsAppId; 25 | } 26 | 27 | public void setJsAppId(String jsAppId) { 28 | this.jsAppId = jsAppId; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /dodo-rebate-reobt-commons/src/main/java/com/dodo/project/rebate/rebot/commons/enums/ECommercePlatformDomainEnum.java: -------------------------------------------------------------------------------- 1 | package com.dodo.project.rebate.rebot.commons.enums; 2 | 3 | /* 4 | * @Description: 电商平台domain enum 5 | * @Author: walk_code walk_code@163.com 6 | * @Param: 7 | * @return: 8 | * @Date: 2019/2/27 15:43 9 | */ 10 | public enum ECommercePlatformDomainEnum { 11 | JD("jd.com", "京东域名"); 12 | 13 | private String domainName; 14 | private String desc; 15 | 16 | ECommercePlatformDomainEnum(String domainName, String desc) { 17 | this.domainName = domainName; 18 | this.desc = desc; 19 | } 20 | 21 | public String getDomainName() { 22 | return domainName; 23 | } 24 | 25 | public void setDomainName(String domainName) { 26 | this.domainName = domainName; 27 | } 28 | 29 | public String getDesc() { 30 | return desc; 31 | } 32 | 33 | public void setDesc(String desc) { 34 | this.desc = desc; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 |
11 | * 微信消息类型为app, app info bean 12 | *13 | * 14 | * @Author xqyjjq walk_code@163.com 15 | * @Date 2019/2/27 17:40 16 | * @Since JDK 1.8 17 | */ 18 | @XmlAccessorType(XmlAccessType.FIELD) 19 | public class AppTypeAppInfoXmlBean { 20 | @XmlElement(name = "version") 21 | private int version; 22 | 23 | @XmlElement(name = "appname") 24 | private String appname; 25 | 26 | public int getVersion() { 27 | return version; 28 | } 29 | 30 | public void setVersion(int version) { 31 | this.version = version; 32 | } 33 | 34 | public String getAppname() { 35 | return appname; 36 | } 37 | 38 | public void setAppname(String appname) { 39 | this.appname = appname; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /dodo-rebate-rebot-api/src/main/java/com/dodo/project/rebate/rebot/api/base/AbstractRobotBaseController.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2013-2020,xqyjjq walk_code@163.com. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.dodo.project.rebate.rebot.api.base; 17 | 18 | 19 | import com.dodo.project.base.web.controller.AbstractController; 20 | 21 | /* 22 | * AbstractRobotBaseController.java 23 | * 24 | *
25 | * 自定义机器人基础控制器抽象类 26 | *27 | * 28 | * @author xqyjjq walk_code@163.com 29 | * @date 2018年12月12日 下午12:08:41 30 | * @since JDK 1.8 31 | */ 32 | public class AbstractRobotBaseController extends AbstractController { 33 | 34 | } 35 | -------------------------------------------------------------------------------- /dodo-rebate-rebot-dao/src/main/java/com/dodo/project/rebate/rebot/dao/system/model/base/BaseSystemUserGroupRole.java: -------------------------------------------------------------------------------- 1 | package com.dodo.project.rebate.rebot.dao.system.model.base; 2 | 3 | import com.jfinal.plugin.activerecord.Model; 4 | import com.jfinal.plugin.activerecord.IBean; 5 | 6 | /** 7 | * Generated by JFinal, do not modify this file. 8 | */ 9 | @SuppressWarnings("serial") 10 | public abstract class BaseSystemUserGroupRole
22 | * 机器名称枚举类 23 | *24 | * 25 | * @author xqyjjq walk_code@163.com 26 | * @date 2018年12月6日 下午4:52:12 27 | * @since JDK 1.8 28 | */ 29 | public enum RobotEnum { 30 | Robot_0x1("openId"); // openId 31 | private String value; 32 | 33 | RobotEnum(String value) { 34 | this.value = value; 35 | } 36 | 37 | public String getValue() { 38 | return value; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /dodo-rebate-reobt-commons/src/main/java/com/dodo/project/rebate/rebot/commons/service/CheckSendTimeService.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2013-2020,xqyjjq walk_code@163.com. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.dodo.project.rebate.rebot.commons.service; 17 | 18 | /* 19 | * @Description: 校验发送时间 20 | * @Author: walk_code walk_code@163.com 21 | * @Param: 22 | * @return: 23 | * @Date: 2019/2/20 14:14 24 | */ 25 | public interface CheckSendTimeService { 26 | /** 27 | * 28 | * checkSendTime
16 | * 公共系统配置 17 | *18 | * 19 | * @Author xqyjjq walk_code@163.com 20 | * @Date 2019/2/20 14:16 21 | * @Since JDK 1.8 22 | */ 23 | @Component 24 | public class CommonSystemConfiguration { 25 | private final static Logger logger = LoggerFactory.getLogger(CommonSystemConfiguration.class); 26 | 27 | @Resource 28 | private Environment env; 29 | 30 | /** 31 | * 32 | * isDebug
25 | * 线程辅助工具类 26 | *27 | * 28 | * @author cpthack 1044559878@qq.com 29 | * @date Dec 22, 2018 4:09:42 PM 30 | * @since JDK 1.8 31 | */ 32 | public class ThreadHelper { 33 | 34 | private final static Logger logger = LoggerFactory.getLogger(ThreadHelper.class); 35 | 36 | public static void sleep(long millis) { 37 | try { 38 | Thread.sleep(millis); 39 | } 40 | catch (Exception e) { 41 | logger.error("线程登录发生错误,当前线程:{}", Thread.currentThread().getName()); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /dodo-rebate-rebot-dao/src/main/java/com/dodo/project/rebate/rebot/dao/system/model/base/BaseSystemUserNotify.java: -------------------------------------------------------------------------------- 1 | package com.dodo.project.rebate.rebot.dao.system.model.base; 2 | 3 | import com.jfinal.plugin.activerecord.Model; 4 | import com.jfinal.plugin.activerecord.IBean; 5 | 6 | /** 7 | * Generated by JFinal, do not modify this file. 8 | */ 9 | @SuppressWarnings("serial") 10 | public abstract class BaseSystemUserNotify
8 | * Example:
9 | * public void configPlugin(Plugins me) {
10 | * ActiveRecordPlugin arp = new ActiveRecordPlugin(...);
11 | * SystemMappingKit.mapping(arp);
12 | * me.add(arp);
13 | * }
14 | *
15 | */
16 | public class SystemMappingKit {
17 |
18 | public static void mapping(ActiveRecordPlugin arp) {
19 | arp.addMapping("system_config", "id", SystemConfig.class);
20 | arp.addMapping("system_log", "id", SystemLog.class);
21 | arp.addMapping("system_menu", "id", SystemMenu.class);
22 | arp.addMapping("system_menu_node", "id", SystemMenuNode.class);
23 | arp.addMapping("system_notify", "id", SystemNotify.class);
24 | arp.addMapping("system_role", "id", SystemRole.class);
25 | arp.addMapping("system_role_menu_mapping", "id", SystemRoleMenuMapping.class);
26 | arp.addMapping("system_subscription", "id", SystemSubscription.class);
27 | arp.addMapping("system_subscription_config", "id", SystemSubscriptionConfig.class);
28 | arp.addMapping("system_user", "id", SystemUser.class);
29 | arp.addMapping("system_user_group", "id", SystemUserGroup.class);
30 | arp.addMapping("system_user_group_detail", "id", SystemUserGroupDetail.class);
31 | arp.addMapping("system_user_group_role", "id", SystemUserGroupRole.class);
32 | arp.addMapping("system_user_notify", "id", SystemUserNotify.class);
33 | }
34 | }
35 |
36 |
--------------------------------------------------------------------------------
/dodo-rebate-rebot-dao/pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 12 | * 微信消息类型为app,content内容为xml bean 13 | *14 | * 15 | * @Author xqyjjq walk_code@163.com 16 | * @Date 2019/2/27 17:25 17 | * @Since JDK 1.8 18 | */ 19 | @XmlRootElement(name = "msg") 20 | @XmlAccessorType(XmlAccessType.FIELD) 21 | public class AppTypeXmlBean { 22 | @XmlElement(name = "appmsg") 23 | private AppTypeAppMsgXmlBean appMsg; 24 | 25 | @XmlElement(name = "fromusername") 26 | private String fromusername; 27 | 28 | @XmlElement(name = "scene") 29 | private int scene; 30 | 31 | @XmlElement(name = "appinfo") 32 | private AppTypeAppInfoXmlBean appInfo; 33 | 34 | @XmlElement(name = "commenturl") 35 | private String commenturl; 36 | 37 | public String getFromusername() { 38 | return fromusername; 39 | } 40 | 41 | public void setFromusername(String fromusername) { 42 | this.fromusername = fromusername; 43 | } 44 | 45 | public int getScene() { 46 | return scene; 47 | } 48 | 49 | public void setScene(int scene) { 50 | this.scene = scene; 51 | } 52 | 53 | 54 | public String getCommenturl() { 55 | return commenturl; 56 | } 57 | 58 | public void setCommenturl(String commenturl) { 59 | this.commenturl = commenturl; 60 | } 61 | 62 | public AppTypeAppMsgXmlBean getAppMsg() { 63 | return appMsg; 64 | } 65 | 66 | public void setAppMsg(AppTypeAppMsgXmlBean appMsg) { 67 | this.appMsg = appMsg; 68 | } 69 | 70 | public AppTypeAppInfoXmlBean getAppInfo() { 71 | return appInfo; 72 | } 73 | 74 | public void setAppInfo(AppTypeAppInfoXmlBean appInfo) { 75 | this.appInfo = appInfo; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /dodo-rebate-rebot-dao/src/main/java/com/dodo/project/rebate/rebot/dao/system/model/base/BaseSystemRole.java: -------------------------------------------------------------------------------- 1 | package com.dodo.project.rebate.rebot.dao.system.model.base; 2 | 3 | import com.jfinal.plugin.activerecord.Model; 4 | import com.jfinal.plugin.activerecord.IBean; 5 | 6 | /** 7 | * Generated by JFinal, do not modify this file. 8 | */ 9 | @SuppressWarnings("serial") 10 | public abstract class BaseSystemRole
15 | * 系统数据库配置 16 | *17 | * 18 | * @Author xqyjjq walk_code@163.com 19 | * @Date 2018/11/2 17:24 20 | * @Since JDK 1.8 21 | */ 22 | /*@Configuration*/ 23 | public class SystemDbConfiguration extends AbstractBaseJfinalDbConfiguration { 24 | public static final String DB_CONFIG_NAME = "system"; 25 | 26 | @Value("${datasource.systemdb.url}") 27 | private String url; 28 | 29 | @Value("${datasource.systemdb.username}") 30 | private String username; 31 | 32 | @Value("${datasource.systemdb.password}") 33 | private String password; 34 | 35 | @Override 36 | protected DbConfigurationInfoBean configDbConfigurationInfoBean() { 37 | DbConfigurationInfoBean dbconfig = new DbConfigurationInfoBean(); 38 | dbconfig.setUserName(username); 39 | dbconfig.setConfigName(DB_CONFIG_NAME); 40 | dbconfig.setUrl(url); 41 | dbconfig.setPassword(password); 42 | 43 | return dbconfig; 44 | } 45 | 46 | /* 47 | * @Description: db配置初始化前配置db插件 48 | * @Author: walk_code walk_code@163.com 49 | * @Param: [] 50 | * @return: void 51 | * @Date: 2018/11/2 17:33 52 | */ 53 | @PostConstruct 54 | public void configAndStartDbPlugin() { 55 | this.configAndStartDbPlugin(SystemMappingKit.class); 56 | } 57 | 58 | /* 59 | * @Description: 注销db配置前停用db插件 60 | * @Author: walk_code walk_code@163.com 61 | * @Param: [] 62 | * @return: void 63 | * @Date: 2018/11/2 17:34 64 | */ 65 | @PreDestroy 66 | public void destory() { 67 | this.stopDbPlugin(); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /dodo-rebate-rebot-api/src/main/java/com/dodo/project/rebate/rebot/api/schedule/CheckLoginStatusManagerSchedule.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2013-2020,xqyjjq walk_code@163.com. 3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *
10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.dodo.project.rebate.rebot.api.schedule; 17 | 18 | import javax.annotation.Resource; 19 | 20 | import com.dodo.project.base.web.utils.DateHelper; 21 | import com.dodo.project.rebate.rebot.api.manager.CheckLoginStatusManager; 22 | import org.slf4j.Logger; 23 | import org.slf4j.LoggerFactory; 24 | import org.springframework.scheduling.annotation.EnableScheduling; 25 | import org.springframework.scheduling.annotation.Scheduled; 26 | import org.springframework.stereotype.Component; 27 | 28 | /* 29 | * CheckLoginStatusSchedule.java 30 | * 31 | *
32 | * 校验微信机器人是否在线 33 | *34 | * 35 | * @author xqyjjq walk_code@163.com 36 | * @date 2018年12月12日 上午11:13:02 37 | * @since JDK 1.8 38 | */ 39 | @EnableScheduling 40 | @Component 41 | public class CheckLoginStatusManagerSchedule { 42 | private final static Logger log = LoggerFactory.getLogger(CheckLoginStatusManagerSchedule.class); 43 | 44 | @Resource 45 | CheckLoginStatusManager checkLoginStatusManager; 46 | 47 | @Scheduled(cron = "${timer.checkLoginStatusManagerSchedule.check}") 48 | public void check() { 49 | log.debug("开始检测微信机器人登录状态-{}.", DateHelper.getCurrentDateStr()); 50 | try { 51 | checkLoginStatusManager.checkLoginStatus(); 52 | } catch (Exception e) { 53 | log.error("校验微信机器人是否在线发生错误:", e); 54 | } 55 | log.debug("完成检测微信机器人登录状态-{}.", DateHelper.getCurrentDateStr()); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /dodo-rebate-reobt-commons/src/main/java/com/dodo/project/rebate/rebot/commons/service/impl/JdApiServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.dodo.project.rebate.rebot.commons.service.impl; 2 | 3 | import com.dodo.project.rebate.rebot.commons.constans.JdApiConstans; 4 | import com.dodo.project.rebate.rebot.commons.service.JdApiService; 5 | import com.jd.open.api.sdk.DefaultJdClient; 6 | import com.jd.open.api.sdk.JdClient; 7 | import com.jd.open.api.sdk.JdException; 8 | import jd.union.open.order.query.response.UnionOpenOrderQueryResponse; 9 | import jd.union.open.promotion.common.get.request.PromotionCodeReq; 10 | import jd.union.open.promotion.common.get.request.UnionOpenPromotionCommonGetRequest; 11 | import jd.union.open.promotion.common.get.response.UnionOpenPromotionCommonGetResponse; 12 | import org.slf4j.Logger; 13 | import org.slf4j.LoggerFactory; 14 | import org.springframework.stereotype.Service; 15 | 16 | /* 17 | * JdApiServiceImpl 18 | * 19 | *
20 | * JD相关api调用服务类实现类 21 | *22 | * 23 | * @Author xqyjjq walk_code@163.com 24 | * @Date 2019/2/26 17:08 25 | * @Since JDK 1.8 26 | */ 27 | @Service 28 | public class JdApiServiceImpl implements JdApiService { 29 | public static final Logger log = LoggerFactory.getLogger(JdApiServiceImpl.class); 30 | 31 | @Override 32 | public UnionOpenPromotionCommonGetResponse getPromotionUrl(String url) { 33 | String serverUrl = JdApiConstans.JD_DOMAIN; 34 | String appKey = JdApiConstans.JD_APP_KEY; 35 | String appSecet = JdApiConstans.JD_APP_SERCET; 36 | String siteId = JdApiConstans.JD_WEB_SITE_ID; 37 | 38 | String accessToken = ""; 39 | JdClient client = new DefaultJdClient(serverUrl, accessToken, appKey, appSecet); 40 | 41 | UnionOpenPromotionCommonGetRequest request = new UnionOpenPromotionCommonGetRequest(); 42 | PromotionCodeReq promotionCodeReq = new PromotionCodeReq(); 43 | promotionCodeReq.setMaterialId(url); 44 | promotionCodeReq.setSiteId(siteId); 45 | request.setPromotionCodeReq(promotionCodeReq); 46 | try { 47 | return client.execute(request); 48 | } catch (JdException e) { 49 | log.error("调用京东联盟api失败:{}", e); 50 | } 51 | 52 | return null; 53 | } 54 | 55 | 56 | 57 | } 58 | -------------------------------------------------------------------------------- /dodo-rebate-rebot-dao/src/main/java/com/dodo/project/rebate/rebot/dao/system/model/base/BaseSystemConfig.java: -------------------------------------------------------------------------------- 1 | package com.dodo.project.rebate.rebot.dao.system.model.base; 2 | 3 | import com.jfinal.plugin.activerecord.Model; 4 | import com.jfinal.plugin.activerecord.IBean; 5 | 6 | /** 7 | * Generated by JFinal, do not modify this file. 8 | */ 9 | @SuppressWarnings("serial") 10 | public abstract class BaseSystemConfig
28 | * 文件下载辅助类 29 | *30 | * 31 | * @author xqyjjq walk_code@163.com 32 | * @date 2018年12月8日 上午11:13:35 33 | * @since JDK 1.8 34 | */ 35 | public class FileDownloaderHelper { 36 | 37 | public static String downloadFromUrl(String imagePath, String outputTempFilePath) throws IOException { 38 | InputStream is = null; 39 | FileOutputStream fos = null; 40 | URL url = new URL(imagePath); 41 | 42 | try { 43 | URLConnection urlConn = url.openConnection(); 44 | 45 | // 获取输入流 46 | is = urlConn.getInputStream(); 47 | fos = new FileOutputStream(outputTempFilePath); 48 | 49 | // 设置文件大小为4KB 50 | byte[] buffer = new byte[4096]; 51 | int length; 52 | 53 | // 写入到临时文件目录 54 | while ((length = is.read(buffer)) > 0) { 55 | fos.write(buffer, 0, length); 56 | } 57 | return outputTempFilePath; 58 | } 59 | finally { 60 | try { 61 | if (is != null) { 62 | is.close(); 63 | } 64 | } 65 | finally { 66 | if (fos != null) { 67 | fos.close(); 68 | } 69 | } 70 | } 71 | } 72 | 73 | public static void main(String[] args) throws Exception { 74 | // String result = downloadFromUrl(new 75 | // URL("https://i.loli.net/2018/12/08/5c0b37b32b89f.png"), "logo11w.png"); 76 | 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /dodo-rebate-reobt-commons/pom.xml: -------------------------------------------------------------------------------- 1 | 2 |
21 | * 生成system db model 22 | *23 | * 24 | * @Author xqyjjq walk_code@163.com 25 | * @Date 2018/11/2 17:35 26 | * @Since JDK 1.8 27 | */ 28 | public class JFinalORMGeneratorForSystem { 29 | private static final Logger logger = LoggerFactory.getLogger(JFinalORMGeneratorForSystem.class); 30 | // 配置文件名称 31 | private static final String PROFILE_NAME = "system-application.yml"; 32 | 33 | // 映射类名 34 | private static final String MAPPING_KEY_CLASS_NAME = "SystemMappingKit"; 35 | 36 | @ConfigurationProperties(prefix = "spring.system") 37 | public static DataSource getDataSource() throws Exception { 38 | Prop prop = PropKit.use(ResourceUtils.getFile(PROFILE_NAME).getPath()); 39 | logger.debug("获取配置文件路径中jdbcUrl={}", prop.get("url")); 40 | String url = prop.get("url"); 41 | String username = prop.get("username"); 42 | String passwrod = prop.get("password"); 43 | 44 | logger.debug("\n数据库admin=" + username + "\n" + "password=" + passwrod + "\n" + "url=" + url); 45 | DruidPlugin druidPlugin = new DruidPlugin(url, username, passwrod); 46 | druidPlugin.start(); 47 | 48 | return druidPlugin.getDataSource(); 49 | } 50 | 51 | public static void main(String[] args) throws Exception { 52 | // 当前包名 53 | String currentPackageName = JFinalORMGeneratorForSystem.class.getPackage().getName(); 54 | 55 | // 生成model包名 56 | String modelPackageName = currentPackageName + ".system.model"; 57 | 58 | // 生成base model包名 59 | String baseModelPackageName = modelPackageName + ".base"; 60 | 61 | // base model生成目录 62 | String baseModelOutputDir = PathKit.getWebRootPath() + "/src/main/java/" + baseModelPackageName.replace(".", "/"); 63 | 64 | // model生成目录 65 | String modelOutputDir = baseModelOutputDir + "/.."; 66 | 67 | Generator generator = new Generator(JFinalORMGeneratorForSystem.getDataSource(), baseModelPackageName, baseModelOutputDir, modelPackageName, modelOutputDir); 68 | // 设置表映射工具的类名 69 | generator.setMappingKitClassName(MAPPING_KEY_CLASS_NAME); 70 | // 设置数据库方言 71 | generator.setDialect(new MysqlDialect()); 72 | // 添加不需要生成的表名 73 | generator.addExcludedTable(""); 74 | // 设置是否在 Model 中生成 dao 对象 75 | generator.setGenerateDaoInModel(true); 76 | // 设置是否生成字典文件 77 | generator.setGenerateDataDictionary(false); 78 | // 设置需要被移除的表名前缀用于生成modelName。例如表名 "osc_user",移除前缀 "osc_"后生成的model名为 "User"而非 OscUser 79 | //generator.setRemovedTableNamePrefixes("system_"); 80 | generator.generate(); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /dodo-rebate-rebot-dao/src/main/java/com/dodo/project/rebate/rebot/dao/system/model/base/BaseSystemUser.java: -------------------------------------------------------------------------------- 1 | package com.dodo.project.rebate.rebot.dao.system.model.base; 2 | 3 | import com.jfinal.plugin.activerecord.Model; 4 | import com.jfinal.plugin.activerecord.IBean; 5 | 6 | /** 7 | * Generated by JFinal, do not modify this file. 8 | */ 9 | @SuppressWarnings("serial") 10 | public abstract class BaseSystemUser
4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *
10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.dodo.project.rebate.rebot.api.manager.service.impl; 17 | 18 | import com.dodo.project.rebate.rebot.api.manager.SendMessageManager; 19 | import com.dodo.project.rebate.rebot.api.manager.service.SendMessageService; 20 | import com.dodo.project.rebate.rebot.commons.bean.MassMessageBean; 21 | import com.dodo.project.rebate.rebot.commons.bean.ReceiveMessBean; 22 | import com.dodo.project.rebate.rebot.commons.enums.RobotEnum; 23 | import org.apache.commons.lang3.StringUtils; 24 | import org.slf4j.Logger; 25 | import org.slf4j.LoggerFactory; 26 | import org.springframework.stereotype.Service; 27 | 28 | import javax.annotation.Resource; 29 | 30 | /* 31 | * @Description: 发送信息业务服务类实现类 32 | * @Author: walk_code walk_code@163.com 33 | * @Param: 34 | * @return: 35 | * @Date: 2019/2/20 17:43 36 | */ 37 | @Service 38 | public class SendMessageServiceImpl implements SendMessageService { 39 | 40 | @Resource 41 | private SendMessageManager sendMessageManager; 42 | 43 | private static final Logger logger = LoggerFactory.getLogger(SendMessageServiceImpl.class); 44 | 45 | @Override 46 | public boolean sendMessage(MassMessageBean massMessageBean) { 47 | 48 | boolean isSuccess = false; 49 | 50 | if (StringUtils.isNotBlank(massMessageBean.getTextContent()) && StringUtils.isNotBlank(massMessageBean.getStudentName())) { 51 | String newContent = massMessageBean.getStudentName() + ",您好。" + massMessageBean.getTextContent(); 52 | massMessageBean.setTextContent(newContent); 53 | } 54 | 55 | boolean sendTextSuccess = true; 56 | if (StringUtils.isNoneBlank(massMessageBean.getTextContent())) { 57 | ReceiveMessBean receiveMessBean = new ReceiveMessBean(); 58 | receiveMessBean.setMessage(massMessageBean.getTextContent()); 59 | receiveMessBean.setRobot(RobotEnum.Robot_0x1.getValue()); 60 | receiveMessBean.setUserId(massMessageBean.getStudentId()); 61 | receiveMessBean.setUserType(1); 62 | receiveMessBean.setCreateTime(massMessageBean.getCreateTime()); 63 | sendTextSuccess = sendMessageManager.sendMessage(receiveMessBean); 64 | } 65 | 66 | isSuccess = sendTextSuccess; 67 | 68 | boolean sendImageSuccess = true; 69 | if (StringUtils.isNoneBlank(massMessageBean.getImgUrls())) { 70 | String[] images = massMessageBean.getImgUrls().split(","); 71 | for (String image : images) { 72 | ReceiveMessBean receiveMessBean = new ReceiveMessBean(); 73 | receiveMessBean.setImgUrl(image); 74 | receiveMessBean.setRobot(RobotEnum.Robot_0x1.getValue()); 75 | receiveMessBean.setUserId(massMessageBean.getStudentId()); 76 | receiveMessBean.setUserType(1); 77 | sendImageSuccess = sendMessageManager.sendMessage(receiveMessBean); 78 | isSuccess = isSuccess && sendImageSuccess; 79 | } 80 | } 81 | 82 | return isSuccess; 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /dodo-rebate-reobt-commons/src/main/java/com/dodo/project/rebate/rebot/commons/bean/AppTypeAppAttachXmlBean.java: -------------------------------------------------------------------------------- 1 | package com.dodo.project.rebate.rebot.commons.bean; 2 | 3 | import javax.xml.bind.annotation.XmlAccessType; 4 | import javax.xml.bind.annotation.XmlAccessorType; 5 | import javax.xml.bind.annotation.XmlElement; 6 | 7 | /* 8 | * AppTypeAppAttachXmlBean 9 | * 10 | *
11 | * 微信消息类型为app, app msg appattach bean 12 | *13 | * 14 | * @Author xqyjjq walk_code@163.com 15 | * @Date 2019/2/27 17:55 16 | * @Since JDK 1.8 17 | */ 18 | @XmlAccessorType(XmlAccessType.FIELD) 19 | public class AppTypeAppAttachXmlBean { 20 | @XmlElement(name = "totallen") 21 | private int totallen; 22 | 23 | @XmlElement(name = "attachid") 24 | private String attachid; 25 | 26 | @XmlElement(name = "emoticonmd5") 27 | private String emoticonmd5; 28 | 29 | @XmlElement(name = "fileext") 30 | private String fileext; 31 | 32 | @XmlElement(name = "cdnthumburl") 33 | private String cdnthumburl; 34 | 35 | @XmlElement(name = "cdnthumbmd5") 36 | private String cdnthumbmd5; 37 | 38 | @XmlElement(name = "cdnthumblength") 39 | private int cdnthumblength; 40 | 41 | @XmlElement(name = "cdnthumbwidth") 42 | private int cdnthumbwidth; 43 | 44 | @XmlElement(name = "cdnthumbheight") 45 | private int cdnthumbheight; 46 | 47 | @XmlElement(name = "cdnthumbaeskey") 48 | private String cdnthumbaeskey; 49 | 50 | @XmlElement(name = "aeskey") 51 | private String aeskey; 52 | 53 | @XmlElement(name = "encryver") 54 | private int encryver; 55 | 56 | @XmlElement(name = "filekey") 57 | private String filekey; 58 | 59 | public int getTotallen() { 60 | return totallen; 61 | } 62 | 63 | public void setTotallen(int totallen) { 64 | this.totallen = totallen; 65 | } 66 | 67 | public String getAttachid() { 68 | return attachid; 69 | } 70 | 71 | public void setAttachid(String attachid) { 72 | this.attachid = attachid; 73 | } 74 | 75 | public String getEmoticonmd5() { 76 | return emoticonmd5; 77 | } 78 | 79 | public void setEmoticonmd5(String emoticonmd5) { 80 | this.emoticonmd5 = emoticonmd5; 81 | } 82 | 83 | public String getFileext() { 84 | return fileext; 85 | } 86 | 87 | public void setFileext(String fileext) { 88 | this.fileext = fileext; 89 | } 90 | 91 | public String getCdnthumburl() { 92 | return cdnthumburl; 93 | } 94 | 95 | public void setCdnthumburl(String cdnthumburl) { 96 | this.cdnthumburl = cdnthumburl; 97 | } 98 | 99 | public String getCdnthumbmd5() { 100 | return cdnthumbmd5; 101 | } 102 | 103 | public void setCdnthumbmd5(String cdnthumbmd5) { 104 | this.cdnthumbmd5 = cdnthumbmd5; 105 | } 106 | 107 | public int getCdnthumblength() { 108 | return cdnthumblength; 109 | } 110 | 111 | public void setCdnthumblength(int cdnthumblength) { 112 | this.cdnthumblength = cdnthumblength; 113 | } 114 | 115 | public int getCdnthumbwidth() { 116 | return cdnthumbwidth; 117 | } 118 | 119 | public void setCdnthumbwidth(int cdnthumbwidth) { 120 | this.cdnthumbwidth = cdnthumbwidth; 121 | } 122 | 123 | public int getCdnthumbheight() { 124 | return cdnthumbheight; 125 | } 126 | 127 | public void setCdnthumbheight(int cdnthumbheight) { 128 | this.cdnthumbheight = cdnthumbheight; 129 | } 130 | 131 | public String getCdnthumbaeskey() { 132 | return cdnthumbaeskey; 133 | } 134 | 135 | public void setCdnthumbaeskey(String cdnthumbaeskey) { 136 | this.cdnthumbaeskey = cdnthumbaeskey; 137 | } 138 | 139 | public String getAeskey() { 140 | return aeskey; 141 | } 142 | 143 | public void setAeskey(String aeskey) { 144 | this.aeskey = aeskey; 145 | } 146 | 147 | public int getEncryver() { 148 | return encryver; 149 | } 150 | 151 | public void setEncryver(int encryver) { 152 | this.encryver = encryver; 153 | } 154 | 155 | public String getFilekey() { 156 | return filekey; 157 | } 158 | 159 | public void setFilekey(String filekey) { 160 | this.filekey = filekey; 161 | } 162 | } 163 | -------------------------------------------------------------------------------- /dodo-rebate-rebot-api/src/main/java/com/dodo/project/rebate/rebot/api/manager/SendMessageManager.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2013-2020,xqyjjq walk_code@163.com. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.dodo.project.rebate.rebot.api.manager; 17 | 18 | import java.util.HashMap; 19 | import java.util.Map; 20 | 21 | import javax.annotation.Resource; 22 | 23 | import com.dodo.project.rebate.rebot.api.manager.service.ItchatService; 24 | import com.dodo.project.rebate.rebot.commons.bean.ReceiveMessBean; 25 | import com.dodo.project.rebate.rebot.commons.enums.RobotEnum; 26 | import org.apache.commons.lang3.StringUtils; 27 | import org.slf4j.Logger; 28 | import org.slf4j.LoggerFactory; 29 | import org.springframework.stereotype.Service; 30 | 31 | /* 32 | * @Description: 发送消息管理器 33 | * @Author: walk_code walk_code@163.com 34 | * @Param: 35 | * @return: 36 | * @Date: 2019/2/20 17:45 37 | */ 38 | @Service 39 | public class SendMessageManager { 40 | 41 | public final static Logger logger = LoggerFactory.getLogger(SendMessageManager.class); 42 | 43 | @Resource 44 | private ItchatService itchatService; 45 | 46 | public boolean sendMessage(ReceiveMessBean receiveMessBean) { 47 | try { 48 | return sendMessageToGroup(receiveMessBean); 49 | } 50 | catch (Exception e) { 51 | logger.error("发送失败:{}", e); 52 | } 53 | return false; 54 | } 55 | 56 | /* 57 | * @Description: 获取所有robot名称 58 | * @Author: walk_code walk_code@163.com 59 | * @Param: [] 60 | * @return: java.util.Map
27 | * 接受消息管理类 28 | *29 | * 30 | * @Author xqyjjq walk_code@163.com 31 | * @Date 2019/2/26 18:27 32 | * @Since JDK 1.8 33 | */ 34 | @Service 35 | public class MessageDealManager implements IMsgHandlerFace { 36 | private static final Logger log = LoggerFactory.getLogger(MessageDealManager.class); 37 | 38 | @Resource 39 | private JdApiService jdApiService; 40 | 41 | @Override 42 | public String textMsgHandle(BaseMsg msg) { 43 | // MessageTools.webWxSendMsg(msg.getMsgType(), msg.getContent(), msg.getFromUserName()); 44 | // 不处理群消息 45 | log.info("收到信息text json数据:{}", JsonHelper.toJson(msg)); 46 | if (!msg.isGroupMsg()) { 47 | log.info("收到信息json数据:{}", JsonHelper.toJson(msg)); 48 | if (ValidatorHelper.validateUrl(msg.getContent())) { 49 | String url = msg.getContent(); 50 | String rebateUrl; 51 | if (ValidatorHelper.isJDUrl(url)) { 52 | UnionOpenPromotionCommonGetResponse response = jdApiService.getPromotionUrl(url); 53 | rebateUrl = response.getData().getClickURL(); 54 | } else { 55 | rebateUrl = "不支持非JD Url"; 56 | } 57 | 58 | MessageTools.sendMsgById(rebateUrl, msg.getFromUserName()); 59 | } 60 | } 61 | return null; 62 | } 63 | 64 | @Override 65 | public String picMsgHandle(BaseMsg msg) { 66 | return null; 67 | } 68 | 69 | @Override 70 | public String voiceMsgHandle(BaseMsg msg) { 71 | return null; 72 | } 73 | 74 | @Override 75 | public String viedoMsgHandle(BaseMsg msg) { 76 | return null; 77 | } 78 | 79 | @Override 80 | public String nameCardMsgHandle(BaseMsg msg) { 81 | return null; 82 | } 83 | 84 | @Override 85 | public void sysMsgHandle(BaseMsg msg) { 86 | 87 | } 88 | 89 | @Override 90 | public String verifyAddFriendMsgHandle(BaseMsg msg) { 91 | return null; 92 | } 93 | 94 | @Override 95 | public String mediaMsgHandle(BaseMsg msg) { 96 | log.info("获取消息类型:{}", msg.getMsgType()); 97 | // 不处理群信息 98 | if (!msg.isGroupMsg()) { 99 | log.info("收到信息media json数据:{}", JsonHelper.toJson(msg)); 100 | String content = StringEscapeUtils.unescapeXml(msg.getContent()); 101 | if (ValidatorHelper.isXml(content)) { 102 | AppTypeXmlBean bean = XmlHelper.xmlToObj(content, AppTypeXmlBean.class); 103 | AppTypeAppMsgXmlBean appMsgBean = bean.getAppMsg(); 104 | String url = appMsgBean.getUrl(); 105 | String rebateUrl = ""; 106 | if (ValidatorHelper.isJDUrl(url)) { 107 | UnionOpenPromotionCommonGetResponse response = jdApiService.getPromotionUrl(url); 108 | rebateUrl = response.getData().getClickURL(); 109 | // 设置返利链接至xml 110 | log.info("返利url:{}", rebateUrl); 111 | // appMsgBean.setTitle("请点击以下链接/n" + appMsgBean.getTitle()); 112 | // appMsgBean.setUrl(rebateUrl); 113 | // rebateUrl = XmlHelper.objToXml(bean); 114 | // log.info("转义后xml:{}", rebateUrl); 115 | // MessageTools.webWxSendMsg(MsgCodeEnum.MSGTYPE_MEDIA.getCode(), rebateUrl, "@c4dd8317b0b6a57b3bf7608ef29729ae7c8c19af0da4168da74848b9c392f944"); 116 | MessageTools.sendMsgById(rebateUrl, msg.getFromUserName()); 117 | } else { 118 | rebateUrl = "不支持非JD Url"; 119 | MessageTools.sendMsgById(rebateUrl, msg.getFromUserName()); 120 | } 121 | } 122 | } 123 | 124 | return null; 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /dodo-rebate-rebot-api/src/main/java/com/dodo/project/rebate/rebot/api/utils/ValidatorHelper.java: -------------------------------------------------------------------------------- 1 | package com.dodo.project.rebate.rebot.api.utils; 2 | 3 | import com.dodo.project.rebate.rebot.commons.enums.ECommercePlatformDomainEnum; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | import org.xml.sax.HandlerBase; 7 | import org.xml.sax.SAXException; 8 | import org.xml.sax.helpers.DefaultHandler; 9 | 10 | import javax.xml.parsers.ParserConfigurationException; 11 | import javax.xml.parsers.SAXParser; 12 | import javax.xml.parsers.SAXParserFactory; 13 | import java.io.ByteArrayInputStream; 14 | import java.io.InputStream; 15 | import java.io.UnsupportedEncodingException; 16 | import java.net.URI; 17 | import java.net.URISyntaxException; 18 | import java.net.URL; 19 | 20 | /* 21 | * ValidatorHelper 22 | * 23 | *
24 | * 常用相关验证 25 | *26 | * 27 | * @Author xqyjjq walk_code@163.com 28 | * @Date 2019/2/27 15:27 29 | * @Since JDK 1.8 30 | */ 31 | public class ValidatorHelper { 32 | public static Logger log = LoggerFactory.getLogger(ValidatorHelper.class); 33 | 34 | /* 35 | * @Description: 验证url是否合法 36 | * @Author: walk_code walk_code@163.com 37 | * @Param: [url] 38 | * @return: boolean 39 | * @Date: 2019/2/27 15:29 40 | */ 41 | public static boolean validateUrl(String url) { 42 | try { 43 | new URL(url).toURI(); 44 | return true; 45 | } catch (Exception e) { 46 | return false; 47 | } 48 | } 49 | 50 | /* 51 | * @Description: 校验url是否为jd商品url 52 | * @Author: walk_code walk_code@163.com 53 | * @Param: [url] 54 | * @return: boolean 55 | * @Date: 2019/2/27 15:31 56 | */ 57 | public static boolean isJDUrl(String url) { 58 | String domain = null; 59 | try { 60 | domain = getDomainName(url); 61 | } catch (URISyntaxException e) { 62 | log.error("无法访问url:{}", e); 63 | } 64 | 65 | if (domain.contains(ECommercePlatformDomainEnum.JD.getDomainName())) { 66 | return true; 67 | } else { 68 | return false; 69 | } 70 | } 71 | 72 | /* 73 | * @Description: 获取domain 74 | * @Author: walk_code walk_code@163.com 75 | * @Param: [url] 76 | * @return: java.lang.String 77 | * @Date: 2019/2/27 15:36 78 | */ 79 | public static String getDomainName(String url) throws URISyntaxException { 80 | URI uri = new URI(url); 81 | String domain = uri.getHost(); 82 | 83 | return domain.startsWith("www.") ? domain.substring(4) : domain; 84 | } 85 | 86 | /* 87 | * @Description: 校验字符串是否为xml 88 | * @Author: walk_code walk_code@163.com 89 | * @Param: [content] 90 | * @return: boolean 91 | * @Date: 2019/2/27 18:38 92 | */ 93 | public static boolean isXml(String content) { 94 | try { 95 | SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser(); 96 | InputStream stream = new ByteArrayInputStream(content.getBytes("UTF-8")); 97 | saxParser.parse(stream, new DefaultHandler()); 98 | } catch (Exception e) { 99 | log.error("XML解析失败:{}", e); 100 | return false; 101 | } 102 | 103 | return true; 104 | } 105 | 106 | public static void main(String[] args) { 107 | boolean result = isJDUrl("https://item.jd.com/31247994071.html?extension_id=eyJhZCI6IjE0NzYiLCJjaCI6IjIiLCJza3UiOiIzMTI0Nzk5NDA3MSIsInRzIjoiMTU1MTI1MzA3NSIsInVuaXFpZCI6IntcImNsaWNrX2lkXCI6XCJhMjM1YzhiOC02NWM0LTQzMzAtYmI5Mi1mNWFiODIwOTBiMmJcIixcIm1hdGVyaWFsX2lkXCI6XCIyNDYyNzkzMjZcIixcInBvc19pZFwiOlwiMTQ3NlwiLFwic2lkXCI6XCIzNzgwN2MyYi0zMjMyLTQyMzItODYzZi1kOTAyOTdmNTcxODFcIn0ifQ==&jd_pop=a235c8b8-65c4-4330-bb92-f5ab82090b2b&abt=0"); 108 | System.out.println(result); 109 | 110 | String xmlStr="\n" + "
18 | * xml工具类 19 | *20 | * 21 | * @Author xqyjjq walk_code@163.com 22 | * @Date 2019/2/27 16:44 23 | * @Since JDK 1.8 24 | */ 25 | public class XmlHelper { 26 | /* 27 | * @Description: xml字符串转bean 28 | * @Author: walk_code walk_code@163.com 29 | * @Param: [xml, tClass] 30 | * @return: T 31 | * @Date: 2019/2/27 16:46 32 | */ 33 | public static
11 | * 微信消息类型为app, app msg bean 12 | *13 | * 14 | * @Author xqyjjq walk_code@163.com 15 | * @Date 2019/2/27 17:35 16 | * @Since JDK 1.8 17 | */ 18 | @XmlAccessorType(XmlAccessType.FIELD) 19 | public class AppTypeAppMsgXmlBean { 20 | @XmlElement(name = "title") 21 | private String title; 22 | 23 | @XmlElement(name = "des") 24 | private String des; 25 | 26 | @XmlElement(name = "action") 27 | private String action; 28 | 29 | @XmlElement(name = "type") 30 | private int type; 31 | 32 | @XmlElement(name = "showtype") 33 | private int showtype; 34 | 35 | @XmlElement(name = "soundtype") 36 | private int soundtype; 37 | 38 | @XmlElement(name = "mediatagname") 39 | private String mediatagname; 40 | 41 | @XmlElement(name = "messageext") 42 | private String messageext; 43 | 44 | @XmlElement(name = "messageaction") 45 | private String messageaction; 46 | 47 | @XmlElement(name = "content") 48 | private String content; 49 | 50 | @XmlElement(name = "contentattr") 51 | private int contentattr; 52 | 53 | @XmlElement(name = "url") 54 | private String url; 55 | 56 | @XmlElement(name = "lowurl") 57 | private String lowurl; 58 | 59 | @XmlElement(name = "dataurl") 60 | private String dataurl; 61 | 62 | @XmlElement(name = "lowdataurl") 63 | private String lowdataurl; 64 | 65 | @XmlElement(name = "appattach") 66 | private AppTypeAppAttachXmlBean appattach; 67 | 68 | @XmlElement(name = "extinfo") 69 | private String extinfo; 70 | 71 | @XmlElement(name = "sourceusername") 72 | private String sourceusername; 73 | 74 | @XmlElement(name = "sourcedisplayname") 75 | private String sourcedisplayname; 76 | 77 | @XmlElement(name = "thumburl") 78 | private String thumburl; 79 | 80 | @XmlElement(name = "md5") 81 | private String md5; 82 | 83 | @XmlElement(name = "statextstr") 84 | private String statextstr; 85 | 86 | @XmlElement(name = "webviewshared") 87 | private AppTypeWebviewsharedXmlBean webviewshared; 88 | 89 | public String getTitle() { 90 | return title; 91 | } 92 | 93 | public void setTitle(String title) { 94 | this.title = title; 95 | } 96 | 97 | public String getDes() { 98 | return des; 99 | } 100 | 101 | public void setDes(String des) { 102 | this.des = des; 103 | } 104 | 105 | public String getAction() { 106 | return action; 107 | } 108 | 109 | public void setAction(String action) { 110 | this.action = action; 111 | } 112 | 113 | public int getType() { 114 | return type; 115 | } 116 | 117 | public void setType(int type) { 118 | this.type = type; 119 | } 120 | 121 | public int getShowtype() { 122 | return showtype; 123 | } 124 | 125 | public void setShowtype(int showtype) { 126 | this.showtype = showtype; 127 | } 128 | 129 | public int getSoundtype() { 130 | return soundtype; 131 | } 132 | 133 | public void setSoundtype(int soundtype) { 134 | this.soundtype = soundtype; 135 | } 136 | 137 | public String getMediatagname() { 138 | return mediatagname; 139 | } 140 | 141 | public void setMediatagname(String mediatagname) { 142 | this.mediatagname = mediatagname; 143 | } 144 | 145 | public String getMessageext() { 146 | return messageext; 147 | } 148 | 149 | public void setMessageext(String messageext) { 150 | this.messageext = messageext; 151 | } 152 | 153 | public String getMessageaction() { 154 | return messageaction; 155 | } 156 | 157 | public void setMessageaction(String messageaction) { 158 | this.messageaction = messageaction; 159 | } 160 | 161 | public String getContent() { 162 | return content; 163 | } 164 | 165 | public void setContent(String content) { 166 | this.content = content; 167 | } 168 | 169 | public int getContentattr() { 170 | return contentattr; 171 | } 172 | 173 | public void setContentattr(int contentattr) { 174 | this.contentattr = contentattr; 175 | } 176 | 177 | public String getUrl() { 178 | return url; 179 | } 180 | 181 | public void setUrl(String url) { 182 | this.url = url; 183 | } 184 | 185 | public String getLowurl() { 186 | return lowurl; 187 | } 188 | 189 | public void setLowurl(String lowurl) { 190 | this.lowurl = lowurl; 191 | } 192 | 193 | public String getDataurl() { 194 | return dataurl; 195 | } 196 | 197 | public void setDataurl(String dataurl) { 198 | this.dataurl = dataurl; 199 | } 200 | 201 | public String getLowdataurl() { 202 | return lowdataurl; 203 | } 204 | 205 | public void setLowdataurl(String lowdataurl) { 206 | this.lowdataurl = lowdataurl; 207 | } 208 | 209 | public AppTypeAppAttachXmlBean getAppattach() { 210 | return appattach; 211 | } 212 | 213 | public void setAppattach(AppTypeAppAttachXmlBean appattach) { 214 | this.appattach = appattach; 215 | } 216 | 217 | public String getExtinfo() { 218 | return extinfo; 219 | } 220 | 221 | public void setExtinfo(String extinfo) { 222 | this.extinfo = extinfo; 223 | } 224 | 225 | public String getSourceusername() { 226 | return sourceusername; 227 | } 228 | 229 | public void setSourceusername(String sourceusername) { 230 | this.sourceusername = sourceusername; 231 | } 232 | 233 | public String getSourcedisplayname() { 234 | return sourcedisplayname; 235 | } 236 | 237 | public void setSourcedisplayname(String sourcedisplayname) { 238 | this.sourcedisplayname = sourcedisplayname; 239 | } 240 | 241 | public String getThumburl() { 242 | return thumburl; 243 | } 244 | 245 | public void setThumburl(String thumburl) { 246 | this.thumburl = thumburl; 247 | } 248 | 249 | public String getMd5() { 250 | return md5; 251 | } 252 | 253 | public void setMd5(String md5) { 254 | this.md5 = md5; 255 | } 256 | 257 | public String getStatextstr() { 258 | return statextstr; 259 | } 260 | 261 | public void setStatextstr(String statextstr) { 262 | this.statextstr = statextstr; 263 | } 264 | 265 | public AppTypeWebviewsharedXmlBean getWebviewshared() { 266 | return webviewshared; 267 | } 268 | 269 | public void setWebviewshared(AppTypeWebviewsharedXmlBean webviewshared) { 270 | this.webviewshared = webviewshared; 271 | } 272 | } 273 | -------------------------------------------------------------------------------- /dodo-rebate-rebot-api/src/main/resources/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *
10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.dodo.project.rebate.rebot.api.controller; 17 | 18 | import javax.annotation.Resource; 19 | 20 | import com.alibaba.fastjson.JSONObject; 21 | import com.dodo.project.base.web.utils.JsonHelper; 22 | import com.dodo.project.rebate.rebot.api.base.AbstractRobotBaseController; 23 | import com.dodo.project.rebate.rebot.api.manager.MessageDealManager; 24 | import com.dodo.project.rebate.rebot.api.manager.service.ItchatService; 25 | import com.dodo.project.rebate.rebot.api.utils.ThreadHelper; 26 | import com.helen.robot.Wechat; 27 | import com.helen.robot.api.WechatTools; 28 | import com.helen.robot.core.MsgCenter; 29 | import org.apache.commons.lang3.RandomUtils; 30 | import org.apache.commons.lang3.StringUtils; 31 | import org.slf4j.Logger; 32 | import org.slf4j.LoggerFactory; 33 | import org.springframework.core.env.Environment; 34 | import org.springframework.http.MediaType; 35 | import org.springframework.http.ResponseEntity; 36 | import org.springframework.web.bind.annotation.RequestMapping; 37 | import org.springframework.web.bind.annotation.RestController; 38 | 39 | import com.helen.robot.api.MessageTools; 40 | 41 | import java.util.List; 42 | 43 | /* 44 | * LoginController.java 45 | * 46 | *
47 | * 登录控制器 48 | *49 | * 50 | * @author xqyjjq walk_code@163.com 51 | * @date 2018年12月12日 下午12:05:02 52 | * @since JDK 1.8 53 | */ 54 | @RestController 55 | public class IndexController extends AbstractRobotBaseController { 56 | @Resource 57 | private ItchatService itchatService; 58 | 59 | public static final Logger log = LoggerFactory.getLogger(IndexController.class); 60 | 61 | @RequestMapping(value = "/login") 62 | public void index() { 63 | // itchatService.startMsgCenterThread(); 64 | itchatService.testLog4jInServer(); 65 | renderJsp("/login/index"); 66 | } 67 | 68 | @RequestMapping(value = "/getWxLoginQrImageUrl") 69 | public ResponseEntity
4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.dodo.project.rebate.rebot.api.manager.service.impl;
17 |
18 | import java.io.File;
19 | import java.io.FileInputStream;
20 | import java.io.InputStream;
21 | import java.util.ArrayList;
22 | import java.util.Date;
23 | import java.util.HashMap;
24 | import java.util.HashSet;
25 | import java.util.Iterator;
26 | import java.util.List;
27 | import java.util.Map;
28 | import java.util.Set;
29 | import java.util.regex.Matcher;
30 |
31 | import com.dodo.project.base.exception.utils.AssertHelper;
32 | import com.dodo.project.base.web.utils.JsonHelper;
33 | import com.dodo.project.rebate.rebot.api.config.ItchatConfiguration;
34 | import com.dodo.project.rebate.rebot.api.manager.MessageDealManager;
35 | import com.dodo.project.rebate.rebot.api.manager.service.ItchatService;
36 | import com.dodo.project.rebate.rebot.api.utils.FileDownloaderHelper;
37 | import com.dodo.project.rebate.rebot.api.utils.ThreadHelper;
38 | import com.helen.robot.core.MsgCenter;
39 | import org.apache.commons.codec.digest.DigestUtils;
40 | import org.apache.commons.collections4.CollectionUtils;
41 | import org.apache.commons.io.FilenameUtils;
42 | import org.apache.commons.lang3.RandomUtils;
43 | import org.apache.http.Consts;
44 | import org.apache.http.HttpEntity;
45 | import org.apache.http.message.BasicNameValuePair;
46 | import org.apache.http.util.EntityUtils;
47 | import org.slf4j.Logger;
48 | import org.slf4j.LoggerFactory;
49 | import org.springframework.stereotype.Service;
50 |
51 | import com.alibaba.fastjson.JSON;
52 | import com.alibaba.fastjson.JSONArray;
53 | import com.alibaba.fastjson.JSONObject;
54 | import com.helen.robot.api.MessageTools;
55 | import com.helen.robot.api.WechatTools;
56 | import com.helen.robot.core.Core;
57 | import com.helen.robot.utils.Config;
58 | import com.helen.robot.utils.SleepUtils;
59 | import com.helen.robot.utils.enums.RetCodeEnum;
60 | import com.helen.robot.utils.enums.StorageLoginInfoEnum;
61 | import com.helen.robot.utils.enums.URLEnum;
62 | import com.helen.robot.utils.enums.parameters.BaseParaEnum;
63 | import com.helen.robot.utils.tools.CommonTools;
64 |
65 | import javax.annotation.Resource;
66 |
67 | /*
68 | * @Description: 微信机器人相关逻辑处理 - 具体实现类
69 | * @Author: walk_code walk_code@163.com
70 | * @Param:
71 | * @return:
72 | * @Date: 2019/2/20 14:02
73 | */
74 | @Service
75 | public class ItchatServiceImpl implements ItchatService {
76 |
77 | public final static Logger logger = LoggerFactory.getLogger(ItchatServiceImpl.class);
78 |
79 | private static final int MAX_REQUEST_TIME = 5;
80 |
81 | @Resource
82 | private MessageDealManager messageDealManager;
83 |
84 | @Override
85 | public boolean isWxAlive() {
86 | return Core.getInstance().isAlive();
87 | }
88 |
89 | @Override
90 | public String getUserIdByFuzzySearch(String searchText) {
91 | logger.info("搜索用户,搜索条件:{}", searchText);
92 | JSONObject jsonObject = getXXXIdByFuzzySearch(searchText, getContactList());
93 | if (jsonObject != null) {
94 | logger.info("匹配对应关键词[{}]的好友,好友昵称:{},好友UserName:{}", searchText, jsonObject.getString("NickName"), jsonObject.getString("UserName"));
95 | return jsonObject.getString("UserName");
96 | }
97 | logger.warn("匹配不到对应的关键词[{}]的好友.", searchText);
98 | return null;
99 | }
100 |
101 | @Override
102 | public String getGroupIdByFuzzySearch(String searchText) {
103 | JSONObject jsonObject = getXXXIdByFuzzySearch(searchText, getGroupList());
104 | if (jsonObject != null) {
105 | logger.info("匹配对应关键词[{}]的群,群昵称:{},群UserName:{}", searchText, jsonObject.getString("NickName"), jsonObject.getString("UserName"));
106 | return jsonObject.getString("UserName");
107 | }
108 | logger.warn("匹配不到对应的关键词[{}]的群.", searchText);
109 | return null;
110 | }
111 |
112 | @Override
113 | public JSONObject getXXXIdByFuzzySearch(String searchText, List
338 | *
339 | *
340 | * 获取消息 状态码
341 | *
342 | * @author xuxuan 1009466324@qq.com
343 | * @return Map