├── .gitignore ├── dodo-rebate-rebot-dao ├── .gitignore ├── dodo-rebate-rebot-dao.iml ├── src │ └── main │ │ ├── resources │ │ └── system-application.yml │ │ └── java │ │ └── com │ │ └── dodo │ │ └── project │ │ └── rebate │ │ └── rebot │ │ └── dao │ │ ├── system │ │ └── model │ │ │ ├── SystemLog.java │ │ │ ├── SystemMenu.java │ │ │ ├── SystemRole.java │ │ │ ├── SystemUser.java │ │ │ ├── SystemConfig.java │ │ │ ├── SystemNotify.java │ │ │ ├── SystemMenuNode.java │ │ │ ├── SystemUserGroup.java │ │ │ ├── SystemUserNotify.java │ │ │ ├── SystemSubscription.java │ │ │ ├── SystemUserGroupRole.java │ │ │ ├── SystemRoleMenuMapping.java │ │ │ ├── SystemUserGroupDetail.java │ │ │ ├── SystemSubscriptionConfig.java │ │ │ ├── base │ │ │ ├── BaseSystemRoleMenuMapping.java │ │ │ ├── BaseSystemSubscriptionConfig.java │ │ │ ├── BaseSystemUserGroupRole.java │ │ │ ├── BaseSystemUserGroupDetail.java │ │ │ ├── BaseSystemMenuNode.java │ │ │ ├── BaseSystemUserGroup.java │ │ │ ├── BaseSystemUserNotify.java │ │ │ ├── BaseSystemSubscription.java │ │ │ ├── BaseSystemLog.java │ │ │ ├── BaseSystemRole.java │ │ │ ├── BaseSystemNotify.java │ │ │ ├── BaseSystemConfig.java │ │ │ ├── BaseSystemMenu.java │ │ │ └── BaseSystemUser.java │ │ │ └── SystemMappingKit.java │ │ ├── config │ │ └── SystemDbConfiguration.java │ │ └── JFinalORMGeneratorForSystem.java └── pom.xml ├── dodo-rebate-rebot-api ├── .gitignore ├── src │ └── main │ │ ├── resources │ │ ├── application.yml │ │ ├── application-prod.yml │ │ ├── application-dev.yml │ │ └── log4j2.xml │ │ ├── java │ │ └── com │ │ │ └── dodo │ │ │ └── project │ │ │ └── rebate │ │ │ └── rebot │ │ │ └── api │ │ │ ├── Application.java │ │ │ ├── base │ │ │ └── AbstractRobotBaseController.java │ │ │ ├── config │ │ │ ├── ItchatConfiguration.java │ │ │ ├── CommonSystemConfiguration.java │ │ │ └── ScheduleExecutorConfiguration.java │ │ │ ├── manager │ │ │ ├── service │ │ │ │ ├── SendMessageService.java │ │ │ │ ├── impl │ │ │ │ │ ├── SendMessageServiceImpl.java │ │ │ │ │ └── ItchatServiceImpl.java │ │ │ │ └── ItchatService.java │ │ │ ├── CheckLoginStatusManager.java │ │ │ ├── SendMessageManager.java │ │ │ └── MessageDealManager.java │ │ │ ├── utils │ │ │ ├── ThreadHelper.java │ │ │ ├── FileDownloaderHelper.java │ │ │ ├── ValidatorHelper.java │ │ │ └── XmlHelper.java │ │ │ ├── schedule │ │ │ ├── CheckLoginStatusManagerSchedule.java │ │ │ └── RefreshWeixinInfoSchedule.java │ │ │ └── controller │ │ │ └── IndexController.java │ │ └── webapp │ │ └── WEB-INF │ │ └── admin │ │ └── login │ │ └── index.jsp └── pom.xml ├── dodo-rebate-reobt-commons ├── .gitignore ├── libs │ └── jd-cps-client-2.2.jar ├── src │ └── main │ │ └── java │ │ └── com │ │ └── dodo │ │ └── project │ │ └── rebate │ │ └── rebot │ │ └── commons │ │ ├── constans │ │ └── JdApiConstans.java │ │ ├── service │ │ ├── JdApiService.java │ │ ├── CheckSendTimeService.java │ │ └── impl │ │ │ ├── CheckSendTimeServiceImpl.java │ │ │ └── JdApiServiceImpl.java │ │ ├── bean │ │ ├── AppTypeWebviewsharedXmlBean.java │ │ ├── AppTypeAppInfoXmlBean.java │ │ ├── AppTypeXmlBean.java │ │ ├── ReceiveMessBean.java │ │ ├── MassMessageBean.java │ │ ├── AppTypeAppAttachXmlBean.java │ │ └── AppTypeAppMsgXmlBean.java │ │ └── enums │ │ ├── ECommercePlatformDomainEnum.java │ │ └── RobotEnum.java └── pom.xml └── pom.xml /.gitignore: -------------------------------------------------------------------------------- 1 | /.idea/ 2 | /logs/ 3 | *.iml 4 | /target -------------------------------------------------------------------------------- /dodo-rebate-rebot-dao/.gitignore: -------------------------------------------------------------------------------- 1 | /.idea/ 2 | *.iml -------------------------------------------------------------------------------- /dodo-rebate-rebot-api/.gitignore: -------------------------------------------------------------------------------- 1 | /.idea/ 2 | *.iml 3 | /target -------------------------------------------------------------------------------- /dodo-rebate-reobt-commons/.gitignore: -------------------------------------------------------------------------------- 1 | /.idea/ 2 | *.iml 3 | /target -------------------------------------------------------------------------------- /dodo-rebate-rebot-dao/dodo-rebate-rebot-dao.iml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /dodo-rebate-reobt-commons/libs/jd-cps-client-2.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Walk-Code/dodo-rebate-rebot/HEAD/dodo-rebate-reobt-commons/libs/jd-cps-client-2.2.jar -------------------------------------------------------------------------------- /dodo-rebate-rebot-api/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | profiles: 3 | active: dev 4 | mvc: 5 | view: 6 | prefix: /WEB-INF/admin/ 7 | suffix: .jsp -------------------------------------------------------------------------------- /dodo-rebate-rebot-dao/src/main/resources/system-application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | datasource: 3 | systemdb: 4 | url: jdbc:mysql://localhost:3306/system?zeroDateTimeBehavior=convertToNull&useUnicode=yes&characterEncoding=UTF-8&autoReconnect=true&allowMultiQueries=true 5 | username: root 6 | password: root -------------------------------------------------------------------------------- /dodo-rebate-rebot-dao/src/main/java/com/dodo/project/rebate/rebot/dao/system/model/SystemLog.java: -------------------------------------------------------------------------------- 1 | package com.dodo.project.rebate.rebot.dao.system.model; 2 | 3 | import com.dodo.project.rebate.rebot.dao.system.model.base.BaseSystemLog; 4 | 5 | /** 6 | * Generated by JFinal. 7 | */ 8 | @SuppressWarnings("serial") 9 | public class SystemLog extends BaseSystemLog { 10 | public static final SystemLog dao = new SystemLog().dao(); 11 | } 12 | -------------------------------------------------------------------------------- /dodo-rebate-rebot-dao/src/main/java/com/dodo/project/rebate/rebot/dao/system/model/SystemMenu.java: -------------------------------------------------------------------------------- 1 | package com.dodo.project.rebate.rebot.dao.system.model; 2 | 3 | import com.dodo.project.rebate.rebot.dao.system.model.base.BaseSystemMenu; 4 | 5 | /** 6 | * Generated by JFinal. 7 | */ 8 | @SuppressWarnings("serial") 9 | public class SystemMenu extends BaseSystemMenu { 10 | public static final SystemMenu dao = new SystemMenu().dao(); 11 | } 12 | -------------------------------------------------------------------------------- /dodo-rebate-rebot-dao/src/main/java/com/dodo/project/rebate/rebot/dao/system/model/SystemRole.java: -------------------------------------------------------------------------------- 1 | package com.dodo.project.rebate.rebot.dao.system.model; 2 | 3 | import com.dodo.project.rebate.rebot.dao.system.model.base.BaseSystemRole; 4 | 5 | /** 6 | * Generated by JFinal. 7 | */ 8 | @SuppressWarnings("serial") 9 | public class SystemRole extends BaseSystemRole { 10 | public static final SystemRole dao = new SystemRole().dao(); 11 | } 12 | -------------------------------------------------------------------------------- /dodo-rebate-rebot-dao/src/main/java/com/dodo/project/rebate/rebot/dao/system/model/SystemUser.java: -------------------------------------------------------------------------------- 1 | package com.dodo.project.rebate.rebot.dao.system.model; 2 | 3 | import com.dodo.project.rebate.rebot.dao.system.model.base.BaseSystemUser; 4 | 5 | /** 6 | * Generated by JFinal. 7 | */ 8 | @SuppressWarnings("serial") 9 | public class SystemUser extends BaseSystemUser { 10 | public static final SystemUser dao = new SystemUser().dao(); 11 | } 12 | -------------------------------------------------------------------------------- /dodo-rebate-rebot-dao/src/main/java/com/dodo/project/rebate/rebot/dao/system/model/SystemConfig.java: -------------------------------------------------------------------------------- 1 | package com.dodo.project.rebate.rebot.dao.system.model; 2 | 3 | import com.dodo.project.rebate.rebot.dao.system.model.base.BaseSystemConfig; 4 | 5 | /** 6 | * Generated by JFinal. 7 | */ 8 | @SuppressWarnings("serial") 9 | public class SystemConfig extends BaseSystemConfig { 10 | public static final SystemConfig dao = new SystemConfig().dao(); 11 | } 12 | -------------------------------------------------------------------------------- /dodo-rebate-rebot-dao/src/main/java/com/dodo/project/rebate/rebot/dao/system/model/SystemNotify.java: -------------------------------------------------------------------------------- 1 | package com.dodo.project.rebate.rebot.dao.system.model; 2 | 3 | import com.dodo.project.rebate.rebot.dao.system.model.base.BaseSystemNotify; 4 | 5 | /** 6 | * Generated by JFinal. 7 | */ 8 | @SuppressWarnings("serial") 9 | public class SystemNotify extends BaseSystemNotify { 10 | public static final SystemNotify dao = new SystemNotify().dao(); 11 | } 12 | -------------------------------------------------------------------------------- /dodo-rebate-rebot-dao/src/main/java/com/dodo/project/rebate/rebot/dao/system/model/SystemMenuNode.java: -------------------------------------------------------------------------------- 1 | package com.dodo.project.rebate.rebot.dao.system.model; 2 | 3 | import com.dodo.project.rebate.rebot.dao.system.model.base.BaseSystemMenuNode; 4 | 5 | /** 6 | * Generated by JFinal. 7 | */ 8 | @SuppressWarnings("serial") 9 | public class SystemMenuNode extends BaseSystemMenuNode { 10 | public static final SystemMenuNode dao = new SystemMenuNode().dao(); 11 | } 12 | -------------------------------------------------------------------------------- /dodo-rebate-rebot-dao/src/main/java/com/dodo/project/rebate/rebot/dao/system/model/SystemUserGroup.java: -------------------------------------------------------------------------------- 1 | package com.dodo.project.rebate.rebot.dao.system.model; 2 | 3 | import com.dodo.project.rebate.rebot.dao.system.model.base.BaseSystemUserGroup; 4 | 5 | /** 6 | * Generated by JFinal. 7 | */ 8 | @SuppressWarnings("serial") 9 | public class SystemUserGroup extends BaseSystemUserGroup { 10 | public static final SystemUserGroup dao = new SystemUserGroup().dao(); 11 | } 12 | -------------------------------------------------------------------------------- /dodo-rebate-rebot-dao/src/main/java/com/dodo/project/rebate/rebot/dao/system/model/SystemUserNotify.java: -------------------------------------------------------------------------------- 1 | package com.dodo.project.rebate.rebot.dao.system.model; 2 | 3 | import com.dodo.project.rebate.rebot.dao.system.model.base.BaseSystemUserNotify; 4 | 5 | /** 6 | * Generated by JFinal. 7 | */ 8 | @SuppressWarnings("serial") 9 | public class SystemUserNotify extends BaseSystemUserNotify { 10 | public static final SystemUserNotify dao = new SystemUserNotify().dao(); 11 | } 12 | -------------------------------------------------------------------------------- /dodo-rebate-rebot-dao/src/main/java/com/dodo/project/rebate/rebot/dao/system/model/SystemSubscription.java: -------------------------------------------------------------------------------- 1 | package com.dodo.project.rebate.rebot.dao.system.model; 2 | 3 | import com.dodo.project.rebate.rebot.dao.system.model.base.BaseSystemSubscription; 4 | 5 | /** 6 | * Generated by JFinal. 7 | */ 8 | @SuppressWarnings("serial") 9 | public class SystemSubscription extends BaseSystemSubscription { 10 | public static final SystemSubscription dao = new SystemSubscription().dao(); 11 | } 12 | -------------------------------------------------------------------------------- /dodo-rebate-rebot-dao/src/main/java/com/dodo/project/rebate/rebot/dao/system/model/SystemUserGroupRole.java: -------------------------------------------------------------------------------- 1 | package com.dodo.project.rebate.rebot.dao.system.model; 2 | 3 | import com.dodo.project.rebate.rebot.dao.system.model.base.BaseSystemUserGroupRole; 4 | 5 | /** 6 | * Generated by JFinal. 7 | */ 8 | @SuppressWarnings("serial") 9 | public class SystemUserGroupRole extends BaseSystemUserGroupRole { 10 | public static final SystemUserGroupRole dao = new SystemUserGroupRole().dao(); 11 | } 12 | -------------------------------------------------------------------------------- /dodo-rebate-rebot-dao/src/main/java/com/dodo/project/rebate/rebot/dao/system/model/SystemRoleMenuMapping.java: -------------------------------------------------------------------------------- 1 | package com.dodo.project.rebate.rebot.dao.system.model; 2 | 3 | import com.dodo.project.rebate.rebot.dao.system.model.base.BaseSystemRoleMenuMapping; 4 | 5 | /** 6 | * Generated by JFinal. 7 | */ 8 | @SuppressWarnings("serial") 9 | public class SystemRoleMenuMapping extends BaseSystemRoleMenuMapping { 10 | public static final SystemRoleMenuMapping dao = new SystemRoleMenuMapping().dao(); 11 | } 12 | -------------------------------------------------------------------------------- /dodo-rebate-rebot-dao/src/main/java/com/dodo/project/rebate/rebot/dao/system/model/SystemUserGroupDetail.java: -------------------------------------------------------------------------------- 1 | package com.dodo.project.rebate.rebot.dao.system.model; 2 | 3 | import com.dodo.project.rebate.rebot.dao.system.model.base.BaseSystemUserGroupDetail; 4 | 5 | /** 6 | * Generated by JFinal. 7 | */ 8 | @SuppressWarnings("serial") 9 | public class SystemUserGroupDetail extends BaseSystemUserGroupDetail { 10 | public static final SystemUserGroupDetail dao = new SystemUserGroupDetail().dao(); 11 | } 12 | -------------------------------------------------------------------------------- /dodo-rebate-rebot-dao/src/main/java/com/dodo/project/rebate/rebot/dao/system/model/SystemSubscriptionConfig.java: -------------------------------------------------------------------------------- 1 | package com.dodo.project.rebate.rebot.dao.system.model; 2 | 3 | import com.dodo.project.rebate.rebot.dao.system.model.base.BaseSystemSubscriptionConfig; 4 | 5 | /** 6 | * Generated by JFinal. 7 | */ 8 | @SuppressWarnings("serial") 9 | public class SystemSubscriptionConfig extends BaseSystemSubscriptionConfig { 10 | public static final SystemSubscriptionConfig dao = new SystemSubscriptionConfig().dao(); 11 | } 12 | -------------------------------------------------------------------------------- /dodo-rebate-reobt-commons/src/main/java/com/dodo/project/rebate/rebot/commons/constans/JdApiConstans.java: -------------------------------------------------------------------------------- 1 | package com.dodo.project.rebate.rebot.commons.constans; 2 | 3 | /* 4 | * JdApiConstans
5 | * 6 | *
 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 | 5 | 4.0.0 6 | 7 | 8 | com.dodo.project.base 9 | dodo-project-base 10 | 1.0-SNAPSHOT 11 | 12 | 13 | com.dodo.project.rebot 14 | dodo-rebate-rebot 15 | pom 16 | 1.0-SNAPSHOT 17 | 18 | dodo-rebate-rebot-api 19 | dodo-rebate-reobt-commons 20 | dodo-rebate-rebot-dao 21 | 22 | 23 | -------------------------------------------------------------------------------- /dodo-rebate-rebot-api/src/main/resources/application-prod.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8085 3 | 4 | #当前系统环境配置 5 | dodo: 6 | debug: 7 | false #为开启调试模式,支持本地相关测试代码的运行 8 | 9 | gateway: 10 | sdk: 11 | apiUrl: http://47.107.22.131 12 | appKey: yourAppkey 13 | appSecret: yourAppSecret 14 | retryTimes: 1 15 | 16 | sms: 17 | aliSmsAppKey: 23779228 18 | aliSmsAppSecret: 9d9788c22c9a4dbc8522fae7b97b15ae 19 | #微信机器人登录超时或者登录无效,发送短信的模板 20 | msg: 21 | phone: 18826410953 22 | reLoginCode: SMS_152542531 23 | 24 | spring: 25 | datasource: 26 | url: jdbc:mysql://localhost:3306/system?zeroDateTimeBehavior=convertToNull&useUnicode=yes&characterEncoding=UTF-8&autoReconnect=true&allowMultiQueries=true 27 | username: root 28 | password: root 29 | 30 | timer: 31 | # 每分钟校验机器人登录状态 32 | checkLoginStatusManagerSchedule: 33 | check: 0 */1 * * * ? 34 | # 刷新同步登录用户的信息 35 | refreshWeixinInfo: 36 | sync: 0 */2 * * * ? -------------------------------------------------------------------------------- /dodo-rebate-rebot-api/src/main/resources/application-dev.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8001 3 | 4 | #当前系统环境配置 5 | dodo: 6 | debug: 7 | true #为开启调试模式,支持本地相关测试代码的运行 8 | 9 | gateway: 10 | sdk: 11 | apiUrl: http://www.test.com:19093 12 | appKey: yourAppkey 13 | appSecret: yourAppSecret 14 | retryTimes: 1 15 | 16 | sms: 17 | aliSmsAppKey: 23779228 18 | aliSmsAppSecret: 9d9788c22c9a4dbc8522fae7b97b15ae 19 | #微信机器人登录超时或者登录无效,发送短信的模板 20 | msg: 21 | phone: 18826410953 22 | reLoginCode: SMS_152542531 23 | 24 | spring: 25 | datasource: 26 | url: jdbc:mysql://localhost:3306/system?zeroDateTimeBehavior=convertToNull&useUnicode=yes&characterEncoding=UTF-8&autoReconnect=true&allowMultiQueries=true 27 | username: root 28 | password: root 29 | 30 | timer: 31 | # 每分钟校验机器人登录状态 32 | checkLoginStatusManagerSchedule: 33 | check: 0 */100 * * * ? 34 | # 刷新同步登录用户的信息 35 | refreshWeixinInfo: 36 | sync: 0 */100 * * * ? 37 | 38 | -------------------------------------------------------------------------------- /dodo-rebate-rebot-dao/src/main/java/com/dodo/project/rebate/rebot/dao/system/model/base/BaseSystemRoleMenuMapping.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 BaseSystemRoleMenuMapping> extends Model implements IBean { 11 | 12 | public void setId(java.lang.Integer id) { 13 | set("id", id); 14 | } 15 | 16 | public java.lang.Integer getId() { 17 | return getInt("id"); 18 | } 19 | 20 | public void setRoleId(java.lang.Integer roleId) { 21 | set("role_id", roleId); 22 | } 23 | 24 | public java.lang.Integer getRoleId() { 25 | return getInt("role_id"); 26 | } 27 | 28 | public void setMenuId(java.lang.Integer menuId) { 29 | set("menu_id", menuId); 30 | } 31 | 32 | public java.lang.Integer getMenuId() { 33 | return getInt("menu_id"); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /dodo-rebate-rebot-dao/src/main/java/com/dodo/project/rebate/rebot/dao/system/model/base/BaseSystemSubscriptionConfig.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 BaseSystemSubscriptionConfig> extends Model implements IBean { 11 | 12 | public void setId(java.lang.Integer id) { 13 | set("id", id); 14 | } 15 | 16 | public java.lang.Integer getId() { 17 | return getInt("id"); 18 | } 19 | 20 | public void setUserId(java.lang.Integer userId) { 21 | set("user_id", userId); 22 | } 23 | 24 | public java.lang.Integer getUserId() { 25 | return getInt("user_id"); 26 | } 27 | 28 | public void setAction(java.lang.String action) { 29 | set("action", action); 30 | } 31 | 32 | public java.lang.String getAction() { 33 | return getStr("action"); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /dodo-rebate-reobt-commons/src/main/java/com/dodo/project/rebate/rebot/commons/bean/AppTypeAppInfoXmlBean.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 | * AppTypeAppInfoXmlBean
9 | * 10 | *
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> extends Model implements IBean { 11 | 12 | public void setId(java.lang.Integer id) { 13 | set("id", id); 14 | } 15 | 16 | public java.lang.Integer getId() { 17 | return getInt("id"); 18 | } 19 | 20 | public void setUserGroupId(java.lang.Integer userGroupId) { 21 | set("user_group_id", userGroupId); 22 | } 23 | 24 | public java.lang.Integer getUserGroupId() { 25 | return getInt("user_group_id"); 26 | } 27 | 28 | public void setRoleId(java.lang.Integer roleId) { 29 | set("role_id", roleId); 30 | } 31 | 32 | public java.lang.Integer getRoleId() { 33 | return getInt("role_id"); 34 | } 35 | 36 | public void setCreateTime(java.util.Date createTime) { 37 | set("create_time", createTime); 38 | } 39 | 40 | public java.util.Date getCreateTime() { 41 | return get("create_time"); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /dodo-rebate-rebot-dao/src/main/java/com/dodo/project/rebate/rebot/dao/system/model/base/BaseSystemUserGroupDetail.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 BaseSystemUserGroupDetail> extends Model implements IBean { 11 | 12 | public void setId(java.lang.Integer id) { 13 | set("id", id); 14 | } 15 | 16 | public java.lang.Integer getId() { 17 | return getInt("id"); 18 | } 19 | 20 | public void setUserGroupId(java.lang.Integer userGroupId) { 21 | set("user_group_id", userGroupId); 22 | } 23 | 24 | public java.lang.Integer getUserGroupId() { 25 | return getInt("user_group_id"); 26 | } 27 | 28 | public void setUserId(java.lang.Integer userId) { 29 | set("user_id", userId); 30 | } 31 | 32 | public java.lang.Integer getUserId() { 33 | return getInt("user_id"); 34 | } 35 | 36 | public void setCreateTime(java.util.Date createTime) { 37 | set("create_time", createTime); 38 | } 39 | 40 | public java.util.Date getCreateTime() { 41 | return get("create_time"); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /dodo-rebate-reobt-commons/src/main/java/com/dodo/project/rebate/rebot/commons/enums/RobotEnum.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.enums; 17 | 18 | /** 19 | * RobotEnums.java
20 | * 21 | *
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
29 | *
30 | * 31 | * 校验发送时间不在00:00-06:00
32 | * 33 | * @author xqyjjq walk_code@163.com 34 | * @return boolean 35 | * 36 | */ 37 | boolean checkSendTime(); 38 | } 39 | -------------------------------------------------------------------------------- /dodo-rebate-rebot-api/src/main/java/com/dodo/project/rebate/rebot/api/config/ItchatConfiguration.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.config; 17 | 18 | /* 19 | * @Description: itchat配置类 20 | * @Author: walk_code walk_code@163.com 21 | * @Param: 22 | * @return: 23 | * @Date: 2019/2/20 14:03 24 | */ 25 | public class ItchatConfiguration { 26 | public final static String qcCodePath = System.getProperty("java.io.tmpdir"); 27 | // public final static String qcCodePath = "/helen-robot"; 28 | 29 | public final static String robotName = "jiaoxue"; 30 | 31 | public final static String domain = ""; // 待补充 32 | } 33 | -------------------------------------------------------------------------------- /dodo-rebate-rebot-api/src/main/java/com/dodo/project/rebate/rebot/api/manager/service/SendMessageService.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.service; 17 | 18 | import com.dodo.project.rebate.rebot.commons.bean.MassMessageBean; 19 | 20 | /* 21 | * @Description: 发送信息业务服务类 22 | * @Author: walk_code walk_code@163.com 23 | * @Param: 24 | * @return: 25 | * @Date: 2019/2/20 14:23 26 | */ 27 | public interface SendMessageService { 28 | 29 | /* 30 | * @Description: 发送信息 31 | * @Author: walk_code walk_code@163.com 32 | * @Param: [massMessageBean] 33 | * @return: boolean 34 | * @Date: 2019/2/20 14:23 35 | */ 36 | boolean sendMessage(MassMessageBean massMessageBean); 37 | } 38 | -------------------------------------------------------------------------------- /dodo-rebate-rebot-dao/src/main/java/com/dodo/project/rebate/rebot/dao/system/model/base/BaseSystemMenuNode.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 BaseSystemMenuNode> extends Model implements IBean { 11 | 12 | public void setId(java.lang.Integer id) { 13 | set("id", id); 14 | } 15 | 16 | public java.lang.Integer getId() { 17 | return getInt("id"); 18 | } 19 | 20 | public void setMenuId(java.lang.Integer menuId) { 21 | set("menu_id", menuId); 22 | } 23 | 24 | public java.lang.Integer getMenuId() { 25 | return getInt("menu_id"); 26 | } 27 | 28 | public void setIsMenu(java.lang.Boolean isMenu) { 29 | set("is_menu", isMenu); 30 | } 31 | 32 | public java.lang.Boolean getIsMenu() { 33 | return get("is_menu"); 34 | } 35 | 36 | public void setIsAuth(java.lang.Boolean isAuth) { 37 | set("is_auth", isAuth); 38 | } 39 | 40 | public java.lang.Boolean getIsAuth() { 41 | return get("is_auth"); 42 | } 43 | 44 | public void setCreateTime(java.util.Date createTime) { 45 | set("create_time", createTime); 46 | } 47 | 48 | public java.util.Date getCreateTime() { 49 | return get("create_time"); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /dodo-rebate-rebot-dao/src/main/java/com/dodo/project/rebate/rebot/dao/system/model/base/BaseSystemUserGroup.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 BaseSystemUserGroup> extends Model implements IBean { 11 | 12 | public void setId(java.lang.Integer id) { 13 | set("id", id); 14 | } 15 | 16 | public java.lang.Integer getId() { 17 | return getInt("id"); 18 | } 19 | 20 | public void setName(java.lang.String name) { 21 | set("name", name); 22 | } 23 | 24 | public java.lang.String getName() { 25 | return getStr("name"); 26 | } 27 | 28 | public void setRemark(java.lang.String remark) { 29 | set("remark", remark); 30 | } 31 | 32 | public java.lang.String getRemark() { 33 | return getStr("remark"); 34 | } 35 | 36 | public void setCreateTime(java.util.Date createTime) { 37 | set("create_time", createTime); 38 | } 39 | 40 | public java.util.Date getCreateTime() { 41 | return get("create_time"); 42 | } 43 | 44 | public void setUpdateTime(java.util.Date updateTime) { 45 | set("update_time", updateTime); 46 | } 47 | 48 | public java.util.Date getUpdateTime() { 49 | return get("update_time"); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /dodo-rebate-rebot-api/src/main/java/com/dodo/project/rebate/rebot/api/config/CommonSystemConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.dodo.project.rebate.rebot.api.config; 2 | 3 | import com.dodo.project.base.web.utils.TypeTransformHelper; 4 | import org.apache.commons.lang3.StringUtils; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | import org.springframework.core.env.Environment; 8 | import org.springframework.stereotype.Component; 9 | 10 | import javax.annotation.Resource; 11 | 12 | /* 13 | * CommonSystemConfiguration
14 | * 15 | *
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
33 | *
34 | * 35 | * 判断当前系统是否开启调试模式
36 | * 37 | * @author cpthack 1044559878@qq.com 38 | * @return boolean ture表示开启了调试模式 39 | * 40 | */ 41 | public boolean isDebug() { 42 | String isDebugToStr = env.getProperty("myServer.debug"); 43 | if (StringUtils.isNotBlank(isDebugToStr)) { 44 | return TypeTransformHelper.objToBoolean(isDebugToStr, false); 45 | } 46 | else { 47 | logger.warn("检测不到配置项[server.debug],将设置默认值:false."); 48 | } 49 | 50 | return false; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /dodo-rebate-rebot-api/src/main/java/com/dodo/project/rebate/rebot/api/utils/ThreadHelper.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2013-2020, cpthack 成佩涛 (1044559878@qq.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.utils; 17 | 18 | import org.slf4j.Logger; 19 | import org.slf4j.LoggerFactory; 20 | 21 | /** 22 | * ThreadHelper.java
23 | * 24 | *
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> extends Model implements IBean { 11 | 12 | public void setId(java.lang.Integer id) { 13 | set("id", id); 14 | } 15 | 16 | public java.lang.Integer getId() { 17 | return getInt("id"); 18 | } 19 | 20 | public void setIsRead(java.lang.Boolean isRead) { 21 | set("is_read", isRead); 22 | } 23 | 24 | public java.lang.Boolean getIsRead() { 25 | return get("is_read"); 26 | } 27 | 28 | public void setSystemUserId(java.lang.Integer systemUserId) { 29 | set("system_user_id", systemUserId); 30 | } 31 | 32 | public java.lang.Integer getSystemUserId() { 33 | return getInt("system_user_id"); 34 | } 35 | 36 | public void setNotifyId(java.lang.Integer notifyId) { 37 | set("notify_id", notifyId); 38 | } 39 | 40 | public java.lang.Integer getNotifyId() { 41 | return getInt("notify_id"); 42 | } 43 | 44 | public void setCreateTime(java.util.Date createTime) { 45 | set("create_time", createTime); 46 | } 47 | 48 | public java.util.Date getCreateTime() { 49 | return get("create_time"); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /dodo-rebate-rebot-api/src/main/java/com/dodo/project/rebate/rebot/api/config/ScheduleExecutorConfiguration.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2013-2020, cpthack 成佩涛 (1044559878@qq.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.config; 17 | 18 | import java.util.concurrent.Executor; 19 | 20 | import org.springframework.context.annotation.Bean; 21 | import org.springframework.context.annotation.Configuration; 22 | import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; 23 | 24 | /* 25 | * @Description: 定时任务相关配置器 26 | * @Author: walk_code walk_code@163.com 27 | * @Param: 28 | * @return: 29 | * @Date: 2019/2/20 13:58 30 | */ 31 | @Configuration 32 | public class ScheduleExecutorConfiguration { 33 | 34 | @Bean 35 | public Executor threadPoolTaskScheduler() { 36 | ThreadPoolTaskScheduler threadPoolTaskScheduler = new ThreadPoolTaskScheduler(); 37 | threadPoolTaskScheduler.setPoolSize(4); 38 | 39 | return threadPoolTaskScheduler; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /dodo-rebate-reobt-commons/src/main/java/com/dodo/project/rebate/rebot/commons/service/impl/CheckSendTimeServiceImpl.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.impl; 17 | 18 | import java.util.Calendar; 19 | 20 | import com.dodo.project.rebate.rebot.commons.service.CheckSendTimeService; 21 | import org.springframework.stereotype.Service; 22 | 23 | /* 24 | * @Description: 校验发送时间实现类 25 | * @Author: walk_code walk_code@163.com 26 | * @Param: 27 | * @return: 28 | * @Date: 2019/2/20 14:14 29 | */ 30 | @Service 31 | public class CheckSendTimeServiceImpl implements CheckSendTimeService { 32 | 33 | @Override 34 | public boolean checkSendTime() { 35 | Calendar c = Calendar.getInstance(); 36 | int timeOfDay = c.get(Calendar.HOUR_OF_DAY); 37 | if (timeOfDay >= 0 && timeOfDay < 7) { 38 | return false; 39 | } 40 | 41 | return true; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /dodo-rebate-rebot-dao/src/main/java/com/dodo/project/rebate/rebot/dao/system/model/SystemMappingKit.java: -------------------------------------------------------------------------------- 1 | package com.dodo.project.rebate.rebot.dao.system.model; 2 | 3 | import com.jfinal.plugin.activerecord.ActiveRecordPlugin; 4 | 5 | /** 6 | * Generated by JFinal, do not modify this file. 7 | *
 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 | 5 | 6 | dodo-rebate-rebot 7 | com.dodo.project.rebot 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | com.dodo.project.rebot 13 | dodo.rebate-rebot-dao 14 | 1.0-SNAPSHOT 15 | 系统基础组件dao层 16 | 17 | 18 | 19 | com.dodo.project.base.dao.jfinal 20 | dodo-project-base-dao-jfinal 21 | 1.0-SNAPSHOT 22 | 23 | 24 | 25 | 26 | org.springframework.boot 27 | spring-boot-starter-data-jpa 28 | 29 | 30 | 31 | 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-maven-plugin 36 | 37 | exec 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /dodo-rebate-rebot-dao/src/main/java/com/dodo/project/rebate/rebot/dao/system/model/base/BaseSystemSubscription.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 BaseSystemSubscription> extends Model implements IBean { 11 | 12 | public void setId(java.lang.Integer id) { 13 | set("id", id); 14 | } 15 | 16 | public java.lang.Integer getId() { 17 | return getInt("id"); 18 | } 19 | 20 | public void setTarget(java.lang.Integer target) { 21 | set("target", target); 22 | } 23 | 24 | public java.lang.Integer getTarget() { 25 | return getInt("target"); 26 | } 27 | 28 | public void setTargetType(java.lang.String targetType) { 29 | set("target_type", targetType); 30 | } 31 | 32 | public java.lang.String getTargetType() { 33 | return getStr("target_type"); 34 | } 35 | 36 | public void setAction(java.lang.String action) { 37 | set("action", action); 38 | } 39 | 40 | public java.lang.String getAction() { 41 | return getStr("action"); 42 | } 43 | 44 | public void setSystemUserId(java.lang.Integer systemUserId) { 45 | set("system_user_id", systemUserId); 46 | } 47 | 48 | public java.lang.Integer getSystemUserId() { 49 | return getInt("system_user_id"); 50 | } 51 | 52 | public void setCreateTime(java.util.Date createTime) { 53 | set("create_time", createTime); 54 | } 55 | 56 | public java.util.Date getCreateTime() { 57 | return get("create_time"); 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /dodo-rebate-rebot-dao/src/main/java/com/dodo/project/rebate/rebot/dao/system/model/base/BaseSystemLog.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 BaseSystemLog> extends Model implements IBean { 11 | 12 | public void setId(java.lang.Integer id) { 13 | set("id", id); 14 | } 15 | 16 | public java.lang.Integer getId() { 17 | return getInt("id"); 18 | } 19 | 20 | public void setIp(java.lang.String ip) { 21 | set("ip", ip); 22 | } 23 | 24 | public java.lang.String getIp() { 25 | return getStr("ip"); 26 | } 27 | 28 | public void setNode(java.lang.String node) { 29 | set("node", node); 30 | } 31 | 32 | public java.lang.String getNode() { 33 | return getStr("node"); 34 | } 35 | 36 | public void setUsername(java.lang.String username) { 37 | set("username", username); 38 | } 39 | 40 | public java.lang.String getUsername() { 41 | return getStr("username"); 42 | } 43 | 44 | public void setAction(java.lang.String action) { 45 | set("action", action); 46 | } 47 | 48 | public java.lang.String getAction() { 49 | return getStr("action"); 50 | } 51 | 52 | public void setContent(java.lang.String content) { 53 | set("content", content); 54 | } 55 | 56 | public java.lang.String getContent() { 57 | return getStr("content"); 58 | } 59 | 60 | public void setCreateTime(java.util.Date createTime) { 61 | set("create_time", createTime); 62 | } 63 | 64 | public java.util.Date getCreateTime() { 65 | return get("create_time"); 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /dodo-rebate-reobt-commons/src/main/java/com/dodo/project/rebate/rebot/commons/bean/AppTypeXmlBean.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 | import javax.xml.bind.annotation.XmlRootElement; 7 | 8 | /* 9 | * AppTypeXmlBean
10 | * 11 | *
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> extends Model implements IBean { 11 | 12 | public void setId(java.lang.Integer id) { 13 | set("id", id); 14 | } 15 | 16 | public java.lang.Integer getId() { 17 | return getInt("id"); 18 | } 19 | 20 | public void setTitle(java.lang.String title) { 21 | set("title", title); 22 | } 23 | 24 | public java.lang.String getTitle() { 25 | return getStr("title"); 26 | } 27 | 28 | public void setStatus(java.lang.Integer status) { 29 | set("status", status); 30 | } 31 | 32 | public java.lang.Integer getStatus() { 33 | return getInt("status"); 34 | } 35 | 36 | public void setSort(java.lang.Integer sort) { 37 | set("sort", sort); 38 | } 39 | 40 | public java.lang.Integer getSort() { 41 | return getInt("sort"); 42 | } 43 | 44 | public void setRemark(java.lang.String remark) { 45 | set("remark", remark); 46 | } 47 | 48 | public java.lang.String getRemark() { 49 | return getStr("remark"); 50 | } 51 | 52 | public void setCreateBy(java.math.BigInteger createBy) { 53 | set("create_by", createBy); 54 | } 55 | 56 | public java.math.BigInteger getCreateBy() { 57 | return get("create_by"); 58 | } 59 | 60 | public void setCreateTime(java.util.Date createTime) { 61 | set("create_time", createTime); 62 | } 63 | 64 | public java.util.Date getCreateTime() { 65 | return get("create_time"); 66 | } 67 | 68 | public void setUpdateTime(java.util.Date updateTime) { 69 | set("update_time", updateTime); 70 | } 71 | 72 | public java.util.Date getUpdateTime() { 73 | return get("update_time"); 74 | } 75 | 76 | } 77 | -------------------------------------------------------------------------------- /dodo-rebate-rebot-dao/src/main/java/com/dodo/project/rebate/rebot/dao/system/model/base/BaseSystemNotify.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 BaseSystemNotify> extends Model implements IBean { 11 | 12 | public void setId(java.lang.Integer id) { 13 | set("id", id); 14 | } 15 | 16 | public java.lang.Integer getId() { 17 | return getInt("id"); 18 | } 19 | 20 | public void setContent(java.lang.String content) { 21 | set("content", content); 22 | } 23 | 24 | public java.lang.String getContent() { 25 | return getStr("content"); 26 | } 27 | 28 | public void setType(java.lang.String type) { 29 | set("type", type); 30 | } 31 | 32 | public java.lang.String getType() { 33 | return getStr("type"); 34 | } 35 | 36 | public void setTarget(java.lang.Integer target) { 37 | set("target", target); 38 | } 39 | 40 | public java.lang.Integer getTarget() { 41 | return getInt("target"); 42 | } 43 | 44 | public void setTargetType(java.lang.String targetType) { 45 | set("target_type", targetType); 46 | } 47 | 48 | public java.lang.String getTargetType() { 49 | return getStr("target_type"); 50 | } 51 | 52 | public void setAction(java.lang.String action) { 53 | set("action", action); 54 | } 55 | 56 | public java.lang.String getAction() { 57 | return getStr("action"); 58 | } 59 | 60 | public void setSender(java.lang.Integer sender) { 61 | set("sender", sender); 62 | } 63 | 64 | public java.lang.Integer getSender() { 65 | return getInt("sender"); 66 | } 67 | 68 | public void setCreateTime(java.util.Date createTime) { 69 | set("create_time", createTime); 70 | } 71 | 72 | public java.util.Date getCreateTime() { 73 | return get("create_time"); 74 | } 75 | 76 | } 77 | -------------------------------------------------------------------------------- /dodo-rebate-rebot-dao/src/main/java/com/dodo/project/rebate/rebot/dao/config/SystemDbConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.dodo.project.rebate.rebot.dao.config; 2 | 3 | import com.dodo.project.base.dao.jfinal.base.AbstractBaseJfinalDbConfiguration; 4 | import com.dodo.project.base.dao.jfinal.config.DbConfigurationInfoBean; 5 | import com.dodo.project.rebate.rebot.dao.system.model.SystemMappingKit; 6 | import org.springframework.beans.factory.annotation.Value; 7 | 8 | import javax.annotation.PostConstruct; 9 | import javax.annotation.PreDestroy; 10 | 11 | /* 12 | * SystemDbConfiguration
13 | * 14 | *
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> extends Model implements IBean { 11 | 12 | public void setId(java.lang.Integer id) { 13 | set("id", id); 14 | } 15 | 16 | public java.lang.Integer getId() { 17 | return getInt("id"); 18 | } 19 | 20 | public void setAppName(java.lang.String appName) { 21 | set("app_name", appName); 22 | } 23 | 24 | public java.lang.String getAppName() { 25 | return getStr("app_name"); 26 | } 27 | 28 | public void setAppVersion(java.lang.String appVersion) { 29 | set("app_version", appVersion); 30 | } 31 | 32 | public java.lang.String getAppVersion() { 33 | return getStr("app_version"); 34 | } 35 | 36 | public void setSiteName(java.lang.String siteName) { 37 | set("site_name", siteName); 38 | } 39 | 40 | public java.lang.String getSiteName() { 41 | return getStr("site_name"); 42 | } 43 | 44 | public void setCopyRight(java.lang.String copyRight) { 45 | set("copy_right", copyRight); 46 | } 47 | 48 | public java.lang.String getCopyRight() { 49 | return getStr("copy_right"); 50 | } 51 | 52 | public void setBrowser(java.lang.String browser) { 53 | set("browser", browser); 54 | } 55 | 56 | public java.lang.String getBrowser() { 57 | return getStr("browser"); 58 | } 59 | 60 | public void setMiitbeian(java.lang.String miitbeian) { 61 | set("miitbeian", miitbeian); 62 | } 63 | 64 | public java.lang.String getMiitbeian() { 65 | return getStr("miitbeian"); 66 | } 67 | 68 | public void setCreateTime(java.util.Date createTime) { 69 | set("create_time", createTime); 70 | } 71 | 72 | public java.util.Date getCreateTime() { 73 | return get("create_time"); 74 | } 75 | 76 | public void setUpdateTime(java.util.Date updateTime) { 77 | set("update_time", updateTime); 78 | } 79 | 80 | public java.util.Date getUpdateTime() { 81 | return get("update_time"); 82 | } 83 | 84 | } 85 | -------------------------------------------------------------------------------- /dodo-rebate-rebot-api/src/main/java/com/dodo/project/rebate/rebot/api/schedule/RefreshWeixinInfoSchedule.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2013-2020, cpthack 成佩涛 (1044559878@qq.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.rebate.rebot.api.manager.service.ItchatService; 21 | import com.dodo.project.rebate.rebot.api.utils.ThreadHelper; 22 | import org.apache.commons.lang3.RandomUtils; 23 | import org.slf4j.Logger; 24 | import org.slf4j.LoggerFactory; 25 | import org.springframework.scheduling.annotation.EnableScheduling; 26 | import org.springframework.scheduling.annotation.Scheduled; 27 | import org.springframework.stereotype.Component; 28 | 29 | /* 30 | * @Description: 定期刷新同步登录用户信息 31 | * @Author: walk_code walk_code@163.com 32 | * @Param: 33 | * @return: 34 | * @Date: 2019/2/20 17:41 35 | */ 36 | @EnableScheduling 37 | @Component 38 | public class RefreshWeixinInfoSchedule { 39 | 40 | private final static Logger log = LoggerFactory.getLogger(RefreshWeixinInfoSchedule.class); 41 | 42 | @Resource 43 | private ItchatService itchatService; 44 | 45 | @Scheduled(cron = "${timer.refreshWeixinInfo.sync}") 46 | public void refresh() { 47 | if (!itchatService.isWxAlive()) { 48 | return; 49 | } 50 | // 增加请求随机性 51 | long sleepTimeMillis = RandomUtils.nextLong(1 * 1000, 10 * 1000); 52 | ThreadHelper.sleep(sleepTimeMillis); 53 | log.info("开始更新微信机器人通讯录信息.---延时{}毫秒", sleepTimeMillis); 54 | itchatService.refreshWxInfo(); 55 | log.info("完成更新微信机器人通讯录信息.---延时{}毫秒", sleepTimeMillis); 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /dodo-rebate-rebot-api/src/main/java/com/dodo/project/rebate/rebot/api/utils/FileDownloaderHelper.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.utils; 17 | 18 | import java.io.FileOutputStream; 19 | import java.io.IOException; 20 | import java.io.InputStream; 21 | import java.net.URL; 22 | import java.net.URLConnection; 23 | 24 | /** 25 | * FileDownloaderHelper.java
26 | * 27 | *
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 | 5 | 6 | dodo-rebate-rebot 7 | com.dodo.project.rebot 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | com.dodo.project.rebot.commons 13 | dodo-rebate-reobt-commons 14 | 1.0-SNAPSHOT 15 | 16 | 17 | jd-api 18 | jd-api 19 | 1.0 20 | system 21 | 22 | ${basedir}/libs/jd-cps-client-2.2.jar 23 | 24 | 25 | 26 | 27 | 28 | 55 | -------------------------------------------------------------------------------- /dodo-rebate-rebot-api/src/main/java/com/dodo/project/rebate/rebot/api/manager/CheckLoginStatusManager.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 javax.annotation.Resource; 19 | 20 | import com.dodo.project.rebate.rebot.api.config.CommonSystemConfiguration; 21 | import com.dodo.project.rebate.rebot.api.manager.service.ItchatService; 22 | import org.springframework.beans.factory.annotation.Autowired; 23 | import org.springframework.core.env.Environment; 24 | import org.springframework.stereotype.Service; 25 | 26 | import com.helen.robot.core.Core; 27 | 28 | /* 29 | * @Description: 管理微信机器人登录状态 30 | * @Author: walk_code walk_code@163.com 31 | * @Param: 32 | * @return: 33 | * @Date: 2019/2/20 14:09 34 | */ 35 | @Service 36 | public class CheckLoginStatusManager { 37 | 38 | @Resource 39 | private ItchatService itchatService; 40 | 41 | @Resource 42 | private Environment environment; 43 | 44 | @Autowired 45 | private CommonSystemConfiguration commonSystemConfiguration; 46 | 47 | /* 48 | * @Description: 校验微信在线状态,微信离线处理 49 | * @Author: walk_code walk_code@163.com 50 | * @Param: [] 51 | * @return: void 52 | * @Date: 2019/2/20 14:17 53 | */ 54 | public void checkLoginStatus() { 55 | Core core = Core.getInstance(); 56 | if (!core.isAlive()) { 57 | return; 58 | } 59 | boolean isLogout = itchatService.checkIsLogout(); 60 | if (isLogout) { 61 | // 改变登录状态 62 | core.setAlive(false); 63 | 64 | if (!commonSystemConfiguration.isDebug()) { 65 | // TODO 发送断线通知 66 | } 67 | } 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /dodo-rebate-reobt-commons/src/main/java/com/dodo/project/rebate/rebot/commons/bean/ReceiveMessBean.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.bean; 17 | 18 | /* 19 | * @Description: 接收调用方发送的信息 20 | * @Author: walk_code walk_code@163.com 21 | * @Param: 22 | * @return: 23 | * @Date: 2019/2/20 14:13 24 | */ 25 | public class ReceiveMessBean { 26 | private String robot; // 发送者名称 27 | 28 | private String userId; // 发送用户id 29 | 30 | private int userType; // 1-家长 2-教员 31 | 32 | private String message; // 发送信息 33 | 34 | private String imgUrl; // 发送图片url 35 | 36 | private long createTime; // 创建时间 37 | 38 | public String getRobot() { 39 | return robot; 40 | } 41 | 42 | public void setRobot(String robot) { 43 | this.robot = robot; 44 | } 45 | 46 | public String getUserId() { 47 | return userId; 48 | } 49 | 50 | public void setUserId(String userId) { 51 | this.userId = userId; 52 | } 53 | 54 | public int getUserType() { 55 | return userType; 56 | } 57 | 58 | public void setUserType(int userType) { 59 | this.userType = userType; 60 | } 61 | 62 | public String getMessage() { 63 | return message; 64 | } 65 | 66 | public void setMessage(String message) { 67 | this.message = message; 68 | } 69 | 70 | public String getImgUrl() { 71 | return imgUrl; 72 | } 73 | 74 | public void setImgUrl(String imgUrl) { 75 | this.imgUrl = imgUrl; 76 | } 77 | 78 | public long getCreateTime() { 79 | return createTime; 80 | } 81 | 82 | public void setCreateTime(long createTime) { 83 | this.createTime = createTime; 84 | } 85 | 86 | } 87 | -------------------------------------------------------------------------------- /dodo-rebate-reobt-commons/src/main/java/com/dodo/project/rebate/rebot/commons/bean/MassMessageBean.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.bean; 17 | 18 | /* 19 | * @Description: 群发消息bean 20 | * @Author: walk_code walk_code@163.com 21 | * @Param: 22 | * @return: 23 | * @Date: 2019/2/20 14:12 24 | */ 25 | public class MassMessageBean { 26 | private int id; 27 | 28 | private String textContent; 29 | 30 | private String imgUrls; 31 | 32 | private String studentId; 33 | 34 | private String studentName; 35 | 36 | private String gradeName; 37 | 38 | private long createTime; 39 | 40 | public String getTextContent() { 41 | return textContent; 42 | } 43 | 44 | public void setTextContent(String textContent) { 45 | this.textContent = textContent; 46 | } 47 | 48 | public String getImgUrls() { 49 | return imgUrls; 50 | } 51 | 52 | public void setImgUrls(String imgUrls) { 53 | this.imgUrls = imgUrls; 54 | } 55 | 56 | public String getStudentId() { 57 | return studentId; 58 | } 59 | 60 | public void setStudentId(String studentId) { 61 | this.studentId = studentId; 62 | } 63 | 64 | public String getStudentName() { 65 | return studentName; 66 | } 67 | 68 | public void setStudentName(String studentName) { 69 | this.studentName = studentName; 70 | } 71 | 72 | public String getGradeName() { 73 | return gradeName; 74 | } 75 | 76 | public void setGradeName(String gradeName) { 77 | this.gradeName = gradeName; 78 | } 79 | 80 | public int getId() { 81 | return id; 82 | } 83 | 84 | public void setId(int id) { 85 | this.id = id; 86 | } 87 | 88 | public long getCreateTime() { 89 | return createTime; 90 | } 91 | 92 | public void setCreateTime(long createTime) { 93 | this.createTime = createTime; 94 | } 95 | 96 | } 97 | -------------------------------------------------------------------------------- /dodo-rebate-rebot-dao/src/main/java/com/dodo/project/rebate/rebot/dao/system/model/base/BaseSystemMenu.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 BaseSystemMenu> extends Model implements IBean { 11 | 12 | public void setId(java.lang.Integer id) { 13 | set("id", id); 14 | } 15 | 16 | public java.lang.Integer getId() { 17 | return getInt("id"); 18 | } 19 | 20 | public void setPid(java.lang.Integer pid) { 21 | set("pid", pid); 22 | } 23 | 24 | public java.lang.Integer getPid() { 25 | return getInt("pid"); 26 | } 27 | 28 | public void setTitle(java.lang.String title) { 29 | set("title", title); 30 | } 31 | 32 | public java.lang.String getTitle() { 33 | return getStr("title"); 34 | } 35 | 36 | public void setIcon(java.lang.String icon) { 37 | set("icon", icon); 38 | } 39 | 40 | public java.lang.String getIcon() { 41 | return getStr("icon"); 42 | } 43 | 44 | public void setUrl(java.lang.String url) { 45 | set("url", url); 46 | } 47 | 48 | public java.lang.String getUrl() { 49 | return getStr("url"); 50 | } 51 | 52 | public void setParams(java.lang.String params) { 53 | set("params", params); 54 | } 55 | 56 | public java.lang.String getParams() { 57 | return getStr("params"); 58 | } 59 | 60 | public void setTarget(java.lang.String target) { 61 | set("target", target); 62 | } 63 | 64 | public java.lang.String getTarget() { 65 | return getStr("target"); 66 | } 67 | 68 | public void setSort(java.lang.Long sort) { 69 | set("sort", sort); 70 | } 71 | 72 | public java.lang.Long getSort() { 73 | return getLong("sort"); 74 | } 75 | 76 | public void setStatus(java.lang.Boolean status) { 77 | set("status", status); 78 | } 79 | 80 | public java.lang.Boolean getStatus() { 81 | return get("status"); 82 | } 83 | 84 | public void setCreateBy(java.math.BigInteger createBy) { 85 | set("create_by", createBy); 86 | } 87 | 88 | public java.math.BigInteger getCreateBy() { 89 | return get("create_by"); 90 | } 91 | 92 | public void setCreateTime(java.util.Date createTime) { 93 | set("create_time", createTime); 94 | } 95 | 96 | public java.util.Date getCreateTime() { 97 | return get("create_time"); 98 | } 99 | 100 | public void setUpdateTime(java.util.Date updateTime) { 101 | set("update_time", updateTime); 102 | } 103 | 104 | public java.util.Date getUpdateTime() { 105 | return get("update_time"); 106 | } 107 | 108 | } 109 | -------------------------------------------------------------------------------- /dodo-rebate-rebot-dao/src/main/java/com/dodo/project/rebate/rebot/dao/JFinalORMGeneratorForSystem.java: -------------------------------------------------------------------------------- 1 | package com.dodo.project.rebate.rebot.dao; 2 | 3 | import com.dodo.project.base.dao.jfinal.utils.JFinalORMConvertDTOHelper; 4 | import com.jfinal.kit.PathKit; 5 | import com.jfinal.kit.Prop; 6 | import com.jfinal.kit.PropKit; 7 | import com.jfinal.plugin.activerecord.dialect.MysqlDialect; 8 | import com.jfinal.plugin.activerecord.generator.Generator; 9 | import com.jfinal.plugin.druid.DruidPlugin; 10 | import org.slf4j.Logger; 11 | import org.slf4j.LoggerFactory; 12 | import org.springframework.boot.context.properties.ConfigurationProperties; 13 | import org.springframework.util.ResourceUtils; 14 | 15 | import javax.sql.DataSource; 16 | 17 | /* 18 | * JFinalORMGeneratorForSystem
19 | * 20 | *
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> extends Model implements IBean { 11 | 12 | public void setId(java.lang.Integer id) { 13 | set("id", id); 14 | } 15 | 16 | public java.lang.Integer getId() { 17 | return getInt("id"); 18 | } 19 | 20 | public void setUsername(java.lang.String username) { 21 | set("username", username); 22 | } 23 | 24 | public java.lang.String getUsername() { 25 | return getStr("username"); 26 | } 27 | 28 | public void setPassword(java.lang.String password) { 29 | set("password", password); 30 | } 31 | 32 | public java.lang.String getPassword() { 33 | return getStr("password"); 34 | } 35 | 36 | public void setQq(java.lang.String qq) { 37 | set("qq", qq); 38 | } 39 | 40 | public java.lang.String getQq() { 41 | return getStr("qq"); 42 | } 43 | 44 | public void setEmail(java.lang.String email) { 45 | set("email", email); 46 | } 47 | 48 | public java.lang.String getEmail() { 49 | return getStr("email"); 50 | } 51 | 52 | public void setPhone(java.lang.String phone) { 53 | set("phone", phone); 54 | } 55 | 56 | public java.lang.String getPhone() { 57 | return getStr("phone"); 58 | } 59 | 60 | public void setRemark(java.lang.String remark) { 61 | set("remark", remark); 62 | } 63 | 64 | public java.lang.String getRemark() { 65 | return getStr("remark"); 66 | } 67 | 68 | public void setLoginNum(java.math.BigInteger loginNum) { 69 | set("login_num", loginNum); 70 | } 71 | 72 | public java.math.BigInteger getLoginNum() { 73 | return get("login_num"); 74 | } 75 | 76 | public void setLoginAt(java.util.Date loginAt) { 77 | set("login_at", loginAt); 78 | } 79 | 80 | public java.util.Date getLoginAt() { 81 | return get("login_at"); 82 | } 83 | 84 | public void setStatus(java.lang.Integer status) { 85 | set("status", status); 86 | } 87 | 88 | public java.lang.Integer getStatus() { 89 | return getInt("status"); 90 | } 91 | 92 | public void setSystemUserGroupId(java.lang.String systemUserGroupId) { 93 | set("system_user_group_id", systemUserGroupId); 94 | } 95 | 96 | public java.lang.String getSystemUserGroupId() { 97 | return getStr("system_user_group_id"); 98 | } 99 | 100 | public void setIsDeleted(java.lang.Boolean isDeleted) { 101 | set("is_deleted", isDeleted); 102 | } 103 | 104 | public java.lang.Boolean getIsDeleted() { 105 | return get("is_deleted"); 106 | } 107 | 108 | public void setCreateBy(java.math.BigInteger createBy) { 109 | set("create_by", createBy); 110 | } 111 | 112 | public java.math.BigInteger getCreateBy() { 113 | return get("create_by"); 114 | } 115 | 116 | public void setCreateTime(java.util.Date createTime) { 117 | set("create_time", createTime); 118 | } 119 | 120 | public java.util.Date getCreateTime() { 121 | return get("create_time"); 122 | } 123 | 124 | public void setUpdateTime(java.util.Date updateTime) { 125 | set("update_time", updateTime); 126 | } 127 | 128 | public java.util.Date getUpdateTime() { 129 | return get("update_time"); 130 | } 131 | 132 | } 133 | -------------------------------------------------------------------------------- /dodo-rebate-rebot-api/src/main/java/com/dodo/project/rebate/rebot/api/manager/service/impl/SendMessageServiceImpl.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.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 61 | * @Date: 2019/2/20 17:46 62 | */ 63 | public Map getRobotList() { 64 | Map robotMap = new HashMap<>(); 65 | for (RobotEnum robotEnum : RobotEnum.values()) { 66 | robotMap.put(robotEnum.getValue(), robotEnum); 67 | } 68 | 69 | return robotMap; 70 | } 71 | 72 | /* 73 | * @Description: 发送信息到群 74 | * @Author: walk_code walk_code@163.com 75 | * @Param: [receiveMessBean] 76 | * @return: boolean 77 | * @Date: 2019/2/20 17:46 78 | */ 79 | private boolean sendMessageToGroup(ReceiveMessBean receiveMessBean) { 80 | /*String uniqueCacheKey = createUniqueCacheKey(receiveMessBean); 81 | String uniqueCacheValue = customizedCache.getObjToStr(uniqueCacheKey); 82 | if (StringUtils.isNotBlank(uniqueCacheValue)) { 83 | logger.warn("跳过已发送的消息,userId={},message={},imgUrl={}", receiveMessBean.getUserId(),receiveMessBean.getMessage(), receiveMessBean.getImgUrl()); 84 | return true; 85 | }*/ 86 | 87 | String groupId = itchatService.getGroupIdByFuzzySearch(receiveMessBean.getUserId()); 88 | 89 | if (StringUtils.isBlank(groupId)) { 90 | logger.warn("未找到符合的群:{}", receiveMessBean.getUserId()); 91 | return false; 92 | } 93 | 94 | logger.info("获取发送的groupId: {}", groupId); 95 | 96 | boolean isMsgSuccess = false; 97 | if (StringUtils.isNotBlank(receiveMessBean.getMessage())) { 98 | // 发送文本消息 99 | isMsgSuccess = itchatService.sendMsgById(receiveMessBean.getMessage(), groupId); 100 | } 101 | boolean isPicSuccess = false; 102 | if (StringUtils.isNoneBlank(receiveMessBean.getImgUrl())) { 103 | // 发送图片信息 104 | isPicSuccess = itchatService.sendXXXPicMsgById(groupId, receiveMessBean.getImgUrl()); 105 | } 106 | 107 | boolean isSuccess = isMsgSuccess || isPicSuccess; 108 | if (isSuccess) { 109 | // 将发送成功的消息缓存1天,避免重复发送. 110 | // customizedCache.set(uniqueCacheKey, receiveMessBean.getUserId(), 3600 * 24); 111 | } 112 | 113 | return isSuccess; 114 | } 115 | 116 | /*private String createUniqueCacheKey(ReceiveMessBean receiveMessBean) { 117 | String uniqueCacheKey = JsonHelper.toJson(receiveMessBean); 118 | uniqueCacheKey = Md5Helper.encrypt(uniqueCacheKey); 119 | return uniqueCacheKey; 120 | }*/ 121 | 122 | } 123 | -------------------------------------------------------------------------------- /dodo-rebate-rebot-api/src/main/java/com/dodo/project/rebate/rebot/api/manager/MessageDealManager.java: -------------------------------------------------------------------------------- 1 | package com.dodo.project.rebate.rebot.api.manager; 2 | 3 | import com.dodo.project.base.exception.utils.JsonHelper; 4 | import com.dodo.project.rebate.rebot.api.utils.ValidatorHelper; 5 | import com.dodo.project.rebate.rebot.api.utils.XmlHelper; 6 | import com.dodo.project.rebate.rebot.commons.bean.AppTypeAppMsgXmlBean; 7 | import com.dodo.project.rebate.rebot.commons.bean.AppTypeXmlBean; 8 | import com.dodo.project.rebate.rebot.commons.service.JdApiService; 9 | import com.helen.robot.api.MessageTools; 10 | import com.helen.robot.api.WechatTools; 11 | import com.helen.robot.beans.BaseMsg; 12 | import com.helen.robot.face.IMsgHandlerFace; 13 | import com.helen.robot.utils.enums.MsgCodeEnum; 14 | import com.helen.robot.utils.enums.MsgTypeEnum; 15 | import jd.union.open.promotion.common.get.response.UnionOpenPromotionCommonGetResponse; 16 | import org.apache.commons.text.StringEscapeUtils; 17 | import org.slf4j.Logger; 18 | import org.slf4j.LoggerFactory; 19 | import org.springframework.stereotype.Service; 20 | 21 | import javax.annotation.Resource; 22 | 23 | /* 24 | * MessageDealManager
25 | * 26 | *
 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" + "\n" + "\t\n" + "\t\t小米(MI)游戏本15.6英寸轻薄窄边框笔记本电脑(英特尔八代酷睿I5-8300H8G1T+256GSSDGTX10606G72%NTSC高色域FHD)深空灰\n" + "\t\t售价:¥6966.00\n" + "\t\t\n" + "\t\t5\n" + "\t\t0\n" + "\t\t0\n" + "\t\t\n" + "\t\t\n" + "\t\t\n" + "\t\t\n" + "\t\t0\n" + "\t\thttps://item.m.jd.com/product/100000165908.html?PTAG=17053.1.1&utm_source=weixin&utm_medium=weixin&utm_campaign=t_1000072672_17053_001\n" + "\t\t\n" + "\t\t\n" + "\t\t\n" + "\t\t\n" + "\t\t\t0\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\n" + "\t\t\n" + "\t\t\n" + "\t\t\n" + "\t\thttp://img14.360buyimg.com/n4/jfs/t1/24350/7/194/248202/5c07bf08E31e95048/5500d487160b3a6e.jpg\n" + "\t\t\n" + "\t\t\n" + "\t\t\n" + "\t\t\twxae3e8056daea8727\n" + "\t\t\n" + "\t\n" + "\t\n" + "\t0\n" + "\t\n" + "\t\t1\n" + "\t\t\n" + "\t\n" + "\t\n" + ""; 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /dodo-rebate-rebot-api/src/main/java/com/dodo/project/rebate/rebot/api/utils/XmlHelper.java: -------------------------------------------------------------------------------- 1 | package com.dodo.project.rebate.rebot.api.utils; 2 | 3 | import com.dodo.project.base.exception.utils.JsonHelper; 4 | import com.dodo.project.rebate.rebot.commons.bean.AppTypeXmlBean; 5 | import org.apache.poi.ss.formula.functions.T; 6 | 7 | import javax.xml.bind.JAXBContext; 8 | import javax.xml.bind.JAXBException; 9 | import javax.xml.bind.Marshaller; 10 | import javax.xml.bind.Unmarshaller; 11 | import java.io.StringReader; 12 | import java.io.StringWriter; 13 | 14 | /* 15 | * XmlHelper
16 | * 17 | *
 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 T xmlToObj(String xml, Class tClass) { 34 | T object = null; 35 | try { 36 | JAXBContext context = JAXBContext.newInstance(tClass); 37 | Unmarshaller unmarshaller = context.createUnmarshaller(); 38 | object = (T) unmarshaller.unmarshal(new StringReader(xml)); 39 | } catch (JAXBException e) { 40 | e.printStackTrace(); 41 | } 42 | 43 | return object; 44 | } 45 | 46 | /* 47 | * @Description: obj转xml 48 | * @Author: walk_code walk_code@163.com 49 | * @Param: [obj] 50 | * @return: java.lang.String 51 | * @Date: 2019/2/27 17:22 52 | */ 53 | public static String objToXml(Object obj) { 54 | return objToXml(obj, "UTF-8"); 55 | } 56 | 57 | /* 58 | * @Description: obj转xml 59 | * @Author: walk_code walk_code@163.com 60 | * @Param: [object, encoding] 61 | * @return: java.lang.String 62 | * @Date: 2019/2/27 17:19 63 | */ 64 | public static String objToXml(Object object, String encoding) { 65 | String result = null; 66 | try { 67 | JAXBContext context = JAXBContext.newInstance(object.getClass()); 68 | Marshaller marshaller = context.createMarshaller(); 69 | marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); 70 | marshaller.setProperty(Marshaller.JAXB_ENCODING, encoding); 71 | 72 | StringWriter writer = new StringWriter(); 73 | marshaller.marshal(object, writer); 74 | result = writer.toString(); 75 | } catch (Exception e) { 76 | e.printStackTrace(); 77 | } 78 | 79 | return result; 80 | } 81 | 82 | public static void main(String[] args) { 83 | StringBuilder xmlStr = new StringBuilder(); 84 | xmlStr.append(""); 85 | xmlStr.append(""); 86 | xmlStr.append("\t"); 87 | xmlStr.append("\t\t小米(MI)游戏本 15.6英寸轻薄窄边框笔记本电脑(英特尔八代酷睿I5-8300H 8G 1T+256G SSD GTX1060 6G 72%NTSC高色域 FHD)深空灰"); 88 | xmlStr.append("\t\t售价:¥6966.00"); 89 | xmlStr.append("\t\t"); 90 | xmlStr.append("\t\t5"); 91 | xmlStr.append("\t\t0"); 92 | xmlStr.append("\t\t0"); 93 | xmlStr.append("\t\t"); 94 | xmlStr.append("\t\t"); 95 | xmlStr.append("\t\t"); 96 | xmlStr.append("\t\t"); 97 | xmlStr.append("\t\t"); 98 | xmlStr.append("\t\t0"); 99 | xmlStr.append("\t\thttps://item.m.jd.com/product/100000165908.html?PTAG=17053.1.1&utm_source=weixin&utm_medium=weixin&utm_campaign=t_1000072672_17053_001"); 100 | xmlStr.append("\t\t"); 101 | xmlStr.append("\t\t"); 102 | xmlStr.append("\t\t"); 103 | xmlStr.append("\t\t"); 104 | xmlStr.append("\t\t0"); 105 | xmlStr.append("\t\t"); 106 | xmlStr.append("\t\t"); 107 | xmlStr.append("\t\t"); 108 | xmlStr.append("\t\t"); 109 | xmlStr.append("\t\t"); 110 | xmlStr.append("\t\t"); 111 | xmlStr.append("\t\t"); 112 | xmlStr.append("\t\t"); 113 | xmlStr.append("\t\t"); 114 | xmlStr.append("\t\thttp://img14.360buyimg.com/n4/jfs/t1/24350/7/194/248202/5c07bf08E31e95048/5500d487160b3a6e.jpg"); 115 | xmlStr.append("\t\t"); 116 | xmlStr.append("\t\t"); 117 | xmlStr.append("\t\t"); 118 | xmlStr.append("\t\twxae3e8056daea8727"); 119 | xmlStr.append("\t\t"); 120 | xmlStr.append("\t\t"); 121 | xmlStr.append("\t\t"); 122 | xmlStr.append("\t\t0"); 123 | xmlStr.append("\t\t"); 124 | xmlStr.append("\t\t1"); 125 | xmlStr.append("\t\t"); 126 | xmlStr.append("\t\t"); 127 | xmlStr.append("\t\t"); 128 | xmlStr.append("\t\t"); 129 | 130 | AppTypeXmlBean bean = XmlHelper.xmlToObj(xmlStr.toString().replaceAll("//s", ""), AppTypeXmlBean.class); 131 | 132 | System.out.println(JsonHelper.toJson(bean)); 133 | // System.out.println(XmlHelper.objToXml(bean)); 134 | // System.out.println(ValidatorHelper.isXml(xmlStr)); 135 | } 136 | } 137 | -------------------------------------------------------------------------------- /dodo-rebate-rebot-api/src/main/webapp/WEB-INF/admin/login/index.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8" %> 3 | 4 | 5 | 6 | 7 | 微信机器人操作页面 8 | 40 | 41 | 42 |
43 |

请用微信扫描下方登录二维码,如不能正常登录,请重新退出登录.刷新二维码

44 |

45 |

46 |

47 |

48 |

71 |

72 |
73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /dodo-rebate-rebot-api/src/main/java/com/dodo/project/rebate/rebot/api/manager/service/ItchatService.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2013-2020, cpthack 成佩涛 (1044559878@qq.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.service; 17 | 18 | import java.util.List; 19 | 20 | import com.alibaba.fastjson.JSONObject; 21 | import com.dodo.project.base.web.utils.JsonHelper; 22 | 23 | /* 24 | * @Description: 微信机器人相关逻辑处理 - 接口类 25 | * @Author: walk_code walk_code@163.com 26 | * @Param: 27 | * @return: 28 | * @Date: 2019/2/20 14:32 29 | */ 30 | public interface ItchatService { 31 | 32 | /* 33 | * @Description: 当前微信是否在线 34 | * @Author: walk_code walk_code@163.com 35 | * @Param: [] 36 | * @return: boolean 37 | * @Date: 2019/2/20 14:32 38 | */ 39 | boolean isWxAlive(); 40 | 41 | /* 42 | * @Description: 根据关键词模糊查询好友ID 43 | * @Author: walk_code walk_code@163.com 44 | * @Param: [searchText] 45 | * @return: java.lang.String 46 | * @Date: 2019/2/20 14:32 47 | */ 48 | String getUserIdByFuzzySearch(String searchText); 49 | 50 | /* 51 | * @Description: 根据关键词模糊查询群组ID 52 | * @Author: walk_code walk_code@163.com 53 | * @Param: [searchText] 54 | * @return: java.lang.String 55 | * @Date: 2019/2/20 14:33 56 | */ 57 | String getGroupIdByFuzzySearch(String searchText); 58 | 59 | /* 60 | * @Description: 根据关键词从数组中模糊查询符合的对象 61 | * @Author: walk_code walk_code@163.com 62 | * @Param: [searchText, list] 63 | * @return: com.alibaba.fastjson.JSONObject 64 | * @Date: 2019/2/20 14:33 65 | */ 66 | JSONObject getXXXIdByFuzzySearch(String searchText, List list); 67 | 68 | /* 69 | * @Description: 获取微信登录二维码字节流 70 | * @Author: walk_code walk_code@163.com 71 | * @Param: [] 72 | * @return: byte[] 73 | * @Date: 2019/2/20 14:33 74 | */ 75 | byte[] getLoginQcImageBytes(); 76 | 77 | /* 78 | * @Description: 微信注销登录 79 | * @Author: walk_code walk_code@163.com 80 | * @Param: [] 81 | * @return: boolean 82 | * @Date: 2019/2/20 14:33 83 | */ 84 | boolean wxLogout(); 85 | 86 | /* 87 | * @Description: 微信登录 88 | * @Author: walk_code walk_code@163.com 89 | * @Param: [] 90 | * @return: byte[] 91 | * @Date: 2019/2/20 14:33 92 | */ 93 | byte[] wxLogin(); 94 | 95 | /* 96 | * @Description: 根据ID发送文本类型消息 97 | * @Author: walk_code walk_code@163.com 98 | * @Param: [text, id] 99 | * @return: boolean 100 | * @Date: 2019/2/20 14:33 101 | */ 102 | boolean sendMsgById(String text, String id); 103 | 104 | /* 105 | * @Description: 根据ID发送XXX图片类型信息 106 | * @Author: walk_code walk_code@163.com 107 | * @Param: [id, filePath] 108 | * @return: boolean 109 | * @Date: 2019/2/20 14:34 110 | */ 111 | boolean sendXXXPicMsgById(String id, String filePath); 112 | 113 | /* 114 | * @Description: 根据ID发送远程图片类型消息 115 | * @Author: walk_code walk_code@163.com 116 | * @Param: [id, fileUrl] 117 | * @return: boolean 118 | * @Date: 2019/2/20 14:34 119 | */ 120 | boolean sendRomotePicMsgById(String id, String fileUrl); 121 | 122 | /* 123 | * @Description: 根据ID发送本地图片类型消息 124 | * @Author: walk_code walk_code@163.com 125 | * @Param: [id, filePath] 126 | * @return: boolean 127 | * @Date: 2019/2/20 14:34 128 | */ 129 | boolean sendLocalPicMsgById(String id, String filePath); 130 | 131 | /* 132 | * @Description: 获取群组数据列表 133 | * @Author: walk_code walk_code@163.com 134 | * @Param: [] 135 | * @return: java.util.List 136 | * @Date: 2019/2/20 14:34 137 | */ 138 | List getGroupList(); 139 | 140 | /* 141 | * @Description: 获取好友列数据列表 142 | * @Author: walk_code walk_code@163.com 143 | * @Param: [] 144 | * @return: java.util.List 145 | * @Date: 2019/2/20 14:34 146 | */ 147 | List getContactList(); 148 | 149 | /* 150 | * @Description: 刷新微信相关信息 151 | * @Author: walk_code walk_code@163.com 152 | * @Param: [] 153 | * @return: boolean 154 | * @Date: 2019/2/20 14:38 155 | */ 156 | boolean refreshWxInfo(); 157 | 158 | /* 159 | * @Description: 检测是否退出登录状态 160 | * @Author: walk_code walk_code@163.com 161 | * @Param: [] 162 | * @return: boolean 163 | * @Date: 2019/2/20 14:52 164 | */ 165 | boolean checkIsLogout(); 166 | 167 | /* 168 | * @Description: 开启接受信息线程 169 | * @Author: walk_code walk_code@163.com 170 | * @Param: [] 171 | * @return: void 172 | * @Date: 2019/2/27 14:56 173 | */ 174 | void startMsgCenterThread(); 175 | 176 | /* 177 | * @Description: 获取用户名称通过昵称 178 | * @Author: walk_code walk_code@163.com 179 | * @Param: [nickName] 180 | * @return: java.lang.String 181 | * @Date: 2019/2/28 14:11 182 | */ 183 | String getUserNameByNickName(String nickName); 184 | 185 | /* 186 | * @Description: 测试log4j在服务类 187 | * @Author: walk_code walk_code@163.com 188 | * @Param: [] 189 | * @return: void 190 | * @Date: 2019/3/1 14:43 191 | */ 192 | void testLog4jInServer(); 193 | } 194 | -------------------------------------------------------------------------------- /dodo-rebate-rebot-api/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | dodo-rebate-rebot 7 | com.dodo.project.rebot 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | com.dodo.project.rebot-api 13 | dodo-rebate-rebot-api 14 | 15 | 1.0-SNAPSHOT 16 | 17 | 18 | 19 | 20 | org.springframework.boot 21 | spring-boot-starter-tomcat 22 | 23 | 24 | org.springframework.boot 25 | spring-boot-starter-tomcat 26 | 27 | 28 | 29 | 30 | 31 | org.apache.tomcat.embed 32 | tomcat-embed-jasper 33 | provided 34 | 35 | 36 | 37 | javax.servlet 38 | jstl 39 | 40 | 41 | javax.servlet 42 | javax.servlet-api 43 | 44 | 45 | 46 | 47 | 48 | com.dodo.project.base.web 49 | dodo-project-base-web 50 | 1.0-SNAPSHOT 51 | 52 | 53 | 54 | 55 | 56 | org.springframework.boot 57 | spring-boot-devtools 58 | 59 | 60 | 61 | 62 | org.springframework.boot 63 | spring-boot-properties-migrator 64 | runtime 65 | 66 | 67 | 68 | 69 | com.helen 70 | robot 71 | 0.0.1 72 | 73 | 74 | org.slf4j 75 | slf4j-api 76 | 77 | 78 | org.slf4j 79 | slf4j-log4j12 80 | 81 | 82 | log4j 83 | log4j 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | com.dodo.project.rebot.commons 92 | dodo-rebate-reobt-commons 93 | 1.0-SNAPSHOT 94 | 95 | 96 | 97 | 98 | 99 | org.springframework.boot 100 | spring-boot-starter 101 | 102 | 103 | org.springframework.boot 104 | spring-boot-starter-logging 105 | 106 | 107 | 108 | 109 | 110 | 111 | org.springframework.boot 112 | spring-boot-starter-log4j2 113 | 114 | 115 | 116 | org.apache.commons 117 | commons-text 118 | 1.6 119 | 120 | 121 | 122 | 123 | 124 | 125 | org.springframework.boot 126 | spring-boot-maven-plugin 127 | 128 | exec 129 | true 130 | 131 | 132 | 133 | 134 | org.apache.maven.plugins 135 | maven-surefire-plugin 136 | 137 | false 138 | 139 | 140 | 141 | 142 | -------------------------------------------------------------------------------- /dodo-rebate-reobt-commons/src/main/java/com/dodo/project/rebate/rebot/commons/bean/AppTypeAppMsgXmlBean.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 | * AppTypeAppMsgXmlBean
9 | * 10 | *
 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 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | logs 10 | 11 | 12 | logs 13 | 14 | ${date:yyyy-MM-dd} 15 | 16 | 17 | 18 | [HL] [%-5p %d{yyyy-MM-dd HH:mm:ss SSS}--%-r(ms)] %n[%l] %n[]-[]-%-m %n%n 19 | 20 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 79 | 80 | 81 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 121 | 122 | 128 | 129 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 149 | 150 | 151 | -------------------------------------------------------------------------------- /dodo-rebate-rebot-api/src/main/java/com/dodo/project/rebate/rebot/api/controller/IndexController.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.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 getWxLoginQrImageUrl() { 70 | return ResponseEntity.ok().contentType(MediaType.IMAGE_JPEG).body(itchatService.wxLogin()); 71 | } 72 | 73 | @RequestMapping(value = "/logout") 74 | public void logout() { 75 | boolean isSuccess = itchatService.wxLogout(); 76 | String responseContent = "

微信退出失败,请联系管理员!

"; 77 | if (isSuccess) { 78 | responseContent = "

微信退出成功!点此重新登录

"; 79 | } 80 | ThreadHelper.sleep(1000); 81 | 82 | renderHtml(responseContent); 83 | } 84 | 85 | @RequestMapping(value = "/checkLoginStatus") 86 | public void checkLoginStatus() { 87 | boolean isAlive = itchatService.isWxAlive(); 88 | if (isAlive) { 89 | String responseContent = "登录成功,好友数:[" + itchatService.getContactList().size() + "]"; 90 | responseContent += ",群组数:[" + itchatService.getGroupList().size() + "]"; 91 | 92 | responseSuccess(responseContent); 93 | } 94 | 95 | responseFailure("未登录."); 96 | } 97 | 98 | @RequestMapping(value = "/searchUser") 99 | public void searchUser() { 100 | int sentUserType = getParameterToInt("sentUserType"); 101 | String searchText = getParameter("searchText"); 102 | if (sentUserType == 1) {// 查询好友类型 103 | responseSuccess(itchatService.getXXXIdByFuzzySearch(searchText, itchatService.getContactList())); 104 | } else {// 查询群组类型 105 | responseSuccess(itchatService.getXXXIdByFuzzySearch(searchText, itchatService.getGroupList())); 106 | } 107 | } 108 | 109 | @RequestMapping(value = "/refreshWxInfo") 110 | public void refreshWxInfo() { 111 | itchatService.refreshWxInfo(); 112 | 113 | responseSuccess("更新通讯录成功."); 114 | } 115 | 116 | @RequestMapping(value = "/test/sfsfsdfsdfs") 117 | public void testSendUser() { 118 | String id = getParameter("sentUserId"); 119 | MessageTools.sendMsgById("test" + RandomUtils.nextDouble(), id); 120 | 121 | responseSuccess("发送成功."); 122 | } 123 | 124 | @RequestMapping(value = "/test/webWxSendInvite") 125 | public void webWxSendInvite() { 126 | String username = getParameter("username"); 127 | log.info("好友列表:{}", username); 128 | 129 | responseSuccess(WechatTools.getUserNameByNickName(username)); 130 | } 131 | 132 | @RequestMapping(value = "/test/sendMessageToUser") 133 | public void sendMessageToUser() { 134 | String uid = getParameter("uid"); 135 | String content = getParameter("content"); 136 | boolean sendSuccess = itchatService.sendMsgById(content, uid); 137 | 138 | responseSuccess(sendSuccess); 139 | } 140 | 141 | @RequestMapping(value = "/test/sendInviteByUserId") 142 | public void sendInviteByUserId(String nickName) { 143 | List list = itchatService.getContactList(); 144 | String toUserName = ""; 145 | toUserName = WechatTools.getUserNameByNickName(nickName); 146 | log.info("获取所有好友列表:{}", JsonHelper.toJson(list)); 147 | if (StringUtils.isEmpty(toUserName)) { 148 | for (JSONObject jsonObject : list) { 149 | if (jsonObject.toJSONString().contains(nickName)) { 150 | toUserName = jsonObject.getString("UserName"); 151 | } 152 | } 153 | } 154 | 155 | log.info(nickName + "的uid: {}", toUserName); 156 | boolean result = MessageTools.sendInviteByUserId(nickName); 157 | 158 | responseSuccess(result); 159 | } 160 | 161 | private static Integer i = 0; 162 | 163 | /*public static void main(String[] args) { 164 | Object object = new Object(); 165 | Thread threadA = new Thread(new PrintNumber(object)); 166 | Thread threadB = new Thread(new PrintNumber(object)); 167 | threadA.setName("奇数"); 168 | threadB.setName("偶数"); 169 | 170 | threadB.start(); 171 | threadA.start(); 172 | } 173 | 174 | static class PrintNumber implements Runnable { 175 | volatile static int i = 1; 176 | Object lock; 177 | 178 | PrintNumber(Object lock) { 179 | this.lock = lock; 180 | } 181 | 182 | @Override 183 | public void run() { 184 | while (i < 100) { 185 | synchronized (lock) { 186 | if (i % 2 != 0 && Thread.currentThread().getName().equals("奇数")) { 187 | System.out.println(Thread.currentThread().getName() + "-" + i); 188 | i++; 189 | try { 190 | lock.wait(); 191 | } catch (InterruptedException e) { 192 | e.printStackTrace(); 193 | } 194 | } 195 | } 196 | 197 | synchronized (lock) { 198 | if (i % 2 == 0 && Thread.currentThread().getName().equals("偶数")) { 199 | System.out.println(Thread.currentThread().getName() + "-" + i); 200 | i++; 201 | lock.notify(); 202 | } 203 | } 204 | } 205 | } 206 | }*/ 207 | } 208 | -------------------------------------------------------------------------------- /dodo-rebate-rebot-api/src/main/java/com/dodo/project/rebate/rebot/api/manager/service/impl/ItchatServiceImpl.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2013-2020, cpthack 成佩涛 (1044559878@qq.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.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 list) { 114 | for (JSONObject jsonObject : list) { 115 | if (jsonObject.getString("NickName").contains(searchText)) { 116 | return jsonObject; 117 | } 118 | if (jsonObject.getString("RemarkName").contains(searchText)) { 119 | return jsonObject; 120 | } 121 | } 122 | return null; 123 | } 124 | 125 | @Override 126 | public byte[] getLoginQcImageBytes() { 127 | byte[] data = null; 128 | String qcImageFilePath = ItchatConfiguration.qcCodePath + File.separator + "QR.jpg"; 129 | try (InputStream file = new FileInputStream(qcImageFilePath)) { 130 | int size = file.available(); 131 | data = new byte[size]; 132 | file.read(data); 133 | } catch (Exception e) { 134 | logger.error("获取微信登录二维码图片失败:", e); 135 | } 136 | return data; 137 | } 138 | 139 | @Override 140 | public boolean wxLogout() { 141 | try { 142 | WechatTools.logout(); 143 | Core.resetInstance(); 144 | // TODO 可以抽离成单独的定时任务周期性执行 145 | // 启动等待二维码扫描的接口 146 | Thread scanWxLoginThread = new Thread(new Runnable() { 147 | @Override 148 | public void run() { 149 | com.helen.robot.controller.LoginController login = new com.helen.robot.controller.LoginController(); 150 | login.login(ItchatConfiguration.qcCodePath); 151 | } 152 | }); 153 | scanWxLoginThread.setName("scanWxLoginThread-" + RandomUtils.nextDouble()); 154 | scanWxLoginThread.start(); 155 | return true; 156 | } catch (Exception e) { 157 | logger.error("微信退出登录失败:", e); 158 | } 159 | return false; 160 | } 161 | 162 | @Override 163 | public byte[] wxLogin() { 164 | // AssertHelper.isTrue(isWxAlive() == false, "目前微信已经在线,先退出再进行操作."); 165 | return getLoginQcImageBytes(); 166 | } 167 | 168 | @Override 169 | public boolean sendMsgById(String text, String id) { 170 | try { 171 | MessageTools.sendMsgById(text, id); 172 | return true; 173 | } catch (Exception e) { 174 | logger.error("发送普通文本消息发生错误:", e); 175 | } 176 | return false; 177 | } 178 | 179 | @Override 180 | public boolean sendXXXPicMsgById(String id, String filePath) { 181 | if (filePath.startsWith("http") || filePath.startsWith("https")) { 182 | return sendRomotePicMsgById(id, filePath); 183 | } 184 | return sendLocalPicMsgById(id, filePath); 185 | } 186 | 187 | @Override 188 | public boolean sendRomotePicMsgById(String id, String fileUrl) { 189 | // 下载网络图片至临时目录 190 | try { 191 | String ext = FilenameUtils.getExtension(fileUrl); 192 | 193 | String tempName = DigestUtils.md5Hex(fileUrl) + "." + ext; 194 | 195 | String tempDir = System.getProperty("java.io.tmpdir"); 196 | String outputTempFilePath = tempDir + "/" + tempName; 197 | logger.info("当前图片的fileUrl:{},下载后图片地址:{}", fileUrl, outputTempFilePath); 198 | File file = new File(outputTempFilePath); 199 | if (!file.exists()) {// 本地文件不存在时触发文件下载逻辑 200 | FileDownloaderHelper.downloadFromUrl(fileUrl, outputTempFilePath); 201 | } 202 | 203 | if (file.exists()) { 204 | return sendLocalPicMsgById(id, outputTempFilePath); 205 | } else { 206 | logger.warn("生成临时文件失败-无法发送,fileUrl路径:{},下载后图片地址:{}", fileUrl, outputTempFilePath); 207 | } 208 | } catch (Exception e) { 209 | logger.error("发送图片失败:{}", e); 210 | } 211 | return false; 212 | } 213 | 214 | @Override 215 | public boolean sendLocalPicMsgById(String id, String filePath) { 216 | try { 217 | ThreadHelper.sleep(RandomUtils.nextLong(300, 1500)); 218 | return MessageTools.sendPicMsgByUserId(id, filePath); 219 | } catch (Exception e) { 220 | logger.error("发送图片类型消息失败:", e); 221 | } 222 | return false; 223 | } 224 | 225 | @Override 226 | public List getGroupList() { 227 | return Core.getInstance().getGroupList(); 228 | } 229 | 230 | @Override 231 | public List getContactList() { 232 | return Core.getInstance().getContactList(); 233 | } 234 | 235 | @Override 236 | public boolean refreshWxInfo() { 237 | webWxInit(); 238 | webWxGetContact(); 239 | WebWxBatchGetContact(); 240 | Core core = Core.getInstance(); 241 | core.setGroupIdList(removeDuplicateDataOfString(core.getGroupIdList())); 242 | core.setGroupNickNameList(removeDuplicateDataOfString(core.getGroupNickNameList())); 243 | core.setContactList(removeDuplicateDataOfJSONObject(core.getContactList())); 244 | core.setGroupList(removeDuplicateDataOfJSONObject(core.getGroupList())); 245 | core.setMemberList(removeDuplicateDataOfJSONObject(core.getMemberList())); 246 | core.setPublicUsersList(removeDuplicateDataOfJSONObject(core.getPublicUsersList())); 247 | core.setSpecialUsersList(removeDuplicateDataOfJSONObject(core.getSpecialUsersList())); 248 | core.setMemberCount(core.getMemberList().size()); 249 | core.getMsgList().clear(); 250 | 251 | return true; 252 | } 253 | 254 | /* 255 | * @Description: 移除重复数据 256 | * @Author: walk_code walk_code@163.com 257 | * @Param: [list] 258 | * @return: java.util.List 259 | * @Date: 2019/2/26 18:00 260 | */ 261 | private List removeDuplicateDataOfJSONObject(List list) { 262 | if (CollectionUtils.isEmpty(list)) { 263 | return new ArrayList<>(); 264 | } 265 | Map map = new HashMap<>(); 266 | for (JSONObject jSONObject : list) { 267 | map.put(jSONObject.getString("NickName") + jSONObject.getString("RemarkName"), jSONObject); 268 | } 269 | 270 | return new ArrayList<>(map.values()); 271 | } 272 | 273 | /* 274 | * @Description: 移除重复数据 275 | * @Author: walk_code walk_code@163.com 276 | * @Param: [list] 277 | * @return: java.util.List 278 | * @Date: 2019/2/26 18:00 279 | */ 280 | private List removeDuplicateDataOfString(List list) { 281 | if (CollectionUtils.isEmpty(list)) { 282 | return new ArrayList<>(); 283 | } 284 | Set set = new HashSet<>(list); 285 | 286 | return new ArrayList<>(set); 287 | } 288 | 289 | @Override 290 | public boolean checkIsLogout() { 291 | boolean isLogout = false; 292 | Map resultMap = syncCheck(); 293 | String retcode = resultMap.get("retcode"); 294 | // String selector = resultMap.get("selector"); 295 | if (retcode.equals(RetCodeEnum.UNKOWN.getCode())) { 296 | logger.info(RetCodeEnum.UNKOWN.getType()); 297 | } else if (retcode.equals(RetCodeEnum.LOGIN_OUT.getCode())) { // 退出 298 | logger.info(RetCodeEnum.LOGIN_OUT.getType()); 299 | isLogout = true; 300 | } else if (retcode.equals(RetCodeEnum.LOGIN_OTHERWHERE.getCode())) { // 其它地方登陆 301 | logger.info(RetCodeEnum.LOGIN_OTHERWHERE.getType()); 302 | isLogout = true; 303 | } else if (retcode.equals(RetCodeEnum.MOBILE_LOGIN_OUT.getCode())) { // 移动端退出 304 | logger.info(RetCodeEnum.MOBILE_LOGIN_OUT.getType()); 305 | isLogout = true; 306 | } 307 | 308 | return isLogout; 309 | } 310 | 311 | @Override 312 | public void startMsgCenterThread() { 313 | new Thread(new Runnable() { 314 | @Override 315 | public void run() { 316 | MsgCenter.handleMsg(messageDealManager); 317 | } 318 | }).start(); 319 | } 320 | 321 | @Override 322 | public String getUserNameByNickName(String nickName) { 323 | // TODO 324 | return null; 325 | } 326 | 327 | @Override 328 | public void testLog4jInServer() { 329 | logger.info("测试日志输出: {}", "test"); 330 | logger.warn("测试日志输出: {}", "test"); 331 | logger.debug("测试日志输出: {}", "test"); 332 | logger.error("测试日志输出: {}", "test"); 333 | } 334 | 335 | /* 336 | * 337 | * syncCheck
338 | *
339 | * 340 | * 获取消息 状态码
341 | * 342 | * @author xuxuan 1009466324@qq.com 343 | * @return Map 344 | * 345 | */ 346 | private Map syncCheck() { 347 | Core core = Core.getInstance(); 348 | 349 | Map resultMap = new HashMap(); 350 | // 组装请求URL和参数 351 | String url = core.getLoginInfo().get(StorageLoginInfoEnum.syncUrl.getKey()) + URLEnum.SYNC_CHECK_URL.getUrl(); 352 | List params = new ArrayList(); 353 | for (BaseParaEnum baseRequest : BaseParaEnum.values()) { 354 | params.add(new BasicNameValuePair(baseRequest.para().toLowerCase(), core.getLoginInfo().get(baseRequest.value()).toString())); 355 | } 356 | params.add(new BasicNameValuePair("r", String.valueOf(new Date().getTime()))); 357 | params.add(new BasicNameValuePair("synckey", (String) core.getLoginInfo().get("synckey"))); 358 | params.add(new BasicNameValuePair("_", String.valueOf(new Date().getTime()))); 359 | SleepUtils.sleep(7); 360 | try { 361 | HttpEntity entity = core.getMyHttpClient().doGet(url, params, true, null); 362 | if (entity == null) { 363 | resultMap.put("retcode", "9999"); 364 | resultMap.put("selector", "9999"); 365 | return resultMap; 366 | } 367 | String text = EntityUtils.toString(entity); 368 | String regEx = "window.synccheck=\\{retcode:\"(\\d+)\",selector:\"(\\d+)\"\\}"; 369 | Matcher matcher = CommonTools.getMatcher(regEx, text); 370 | if (!matcher.find() || matcher.group(1).equals("2")) { 371 | logger.info(String.format("Unexpected sync check result: %s", text)); 372 | } else { 373 | resultMap.put("retcode", matcher.group(1)); 374 | resultMap.put("selector", matcher.group(2)); 375 | } 376 | } catch (Exception e) { 377 | e.printStackTrace(); 378 | } 379 | 380 | return resultMap; 381 | } 382 | 383 | /* 384 | * @Description: 微信初始化 385 | * @Author: walk_code walk_code@163.com 386 | * @Param: [] 387 | * @return: boolean 388 | * @Date: 2019/2/26 17:58 389 | */ 390 | private boolean webWxInit() { 391 | Core core = Core.getInstance(); 392 | core.setAlive(true); 393 | core.setLastNormalRetcodeTime(System.currentTimeMillis()); 394 | // 组装请求URL和参数 395 | String url = String.format(URLEnum.INIT_URL.getUrl(), core.getLoginInfo().get(StorageLoginInfoEnum.url.getKey()), String.valueOf(System.currentTimeMillis() / 3158L), core.getLoginInfo().get(StorageLoginInfoEnum.pass_ticket.getKey())); 396 | 397 | Map paramMap = core.getParamMap(); 398 | 399 | // 请求初始化接口 400 | HttpEntity entity = core.getMyHttpClient().doPost(url, JSON.toJSONString(paramMap)); 401 | try { 402 | String result = EntityUtils.toString(entity, Consts.UTF_8); 403 | JSONObject obj = JSON.parseObject(result); 404 | 405 | JSONObject user = obj.getJSONObject(StorageLoginInfoEnum.User.getKey()); 406 | JSONObject syncKey = obj.getJSONObject(StorageLoginInfoEnum.SyncKey.getKey()); 407 | 408 | core.getLoginInfo().put(StorageLoginInfoEnum.InviteStartCount.getKey(), obj.getInteger(StorageLoginInfoEnum.InviteStartCount.getKey())); 409 | core.getLoginInfo().put(StorageLoginInfoEnum.SyncKey.getKey(), syncKey); 410 | 411 | JSONArray syncArray = syncKey.getJSONArray("List"); 412 | StringBuilder sb = new StringBuilder(); 413 | for (int i = 0; i < syncArray.size(); i++) { 414 | sb.append(syncArray.getJSONObject(i).getString("Key") + "_" + syncArray.getJSONObject(i).getString("Val") + "|"); 415 | } 416 | // 1_661706053|2_661706420|3_661706415|1000_1494151022| 417 | String synckey = sb.toString(); 418 | 419 | // 1_661706053|2_661706420|3_661706415|1000_1494151022 420 | core.getLoginInfo().put(StorageLoginInfoEnum.synckey.getKey(), synckey.substring(0, synckey.length() - 1));// 1_656161336|2_656161626|3_656161313|11_656159955|13_656120033|201_1492273724|1000_1492265953|1001_1492250432|1004_1491805192 421 | core.setUserName(user.getString("UserName")); 422 | core.setNickName(user.getString("NickName")); 423 | core.setUserSelf(obj.getJSONObject("User")); 424 | 425 | String chatSet = obj.getString("ChatSet"); 426 | String[] chatSetArray = chatSet.split(","); 427 | for (int i = 0; i < chatSetArray.length; i++) { 428 | if (chatSetArray[i].indexOf("@@") != -1) { 429 | // 更新GroupIdList 430 | core.getGroupIdList().add(chatSetArray[i]); // 431 | } 432 | } 433 | JSONArray contactListArray = obj.getJSONArray("ContactList"); 434 | for (int i = 0; i < contactListArray.size(); i++) { 435 | JSONObject o = contactListArray.getJSONObject(i); 436 | if (o.getString("UserName").indexOf("@@") != -1) { 437 | core.getGroupIdList().add(o.getString("UserName")); // 438 | // 更新GroupIdList 439 | core.getGroupList().add(o); // 更新GroupList 440 | core.getGroupNickNameList().add(o.getString("NickName")); 441 | } 442 | } 443 | } catch (Exception e) { 444 | logger.error("微信初始化错误:", e); 445 | return false; 446 | } 447 | 448 | return true; 449 | } 450 | 451 | /* 452 | * @Description: 获取联系人 453 | * @Author: walk_code walk_code@163.com 454 | * @Param: [] 455 | * @return: void 456 | * @Date: 2019/2/26 17:58 457 | */ 458 | private void webWxGetContact() { 459 | Core core = Core.getInstance(); 460 | String url = String.format(URLEnum.WEB_WX_GET_CONTACT.getUrl(), core.getLoginInfo().get(StorageLoginInfoEnum.url.getKey())); 461 | Map paramMap = core.getParamMap(); 462 | HttpEntity entity = reRequest(url, paramMap); 463 | 464 | try { 465 | String result = EntityUtils.toString(entity, Consts.UTF_8); 466 | JSONObject fullFriendsJsonList = JSON.parseObject(result); 467 | // 查看seq是否为0,0表示好友列表已全部获取完毕,若大于0,则表示好友列表未获取完毕,当前的字节数(断点续传) 468 | long seq = 0; 469 | long currentTime = 0L; 470 | List params = new ArrayList(); 471 | if (fullFriendsJsonList.get("Seq") != null) { 472 | seq = fullFriendsJsonList.getLong("Seq"); 473 | currentTime = new Date().getTime(); 474 | } 475 | core.setMemberCount(fullFriendsJsonList.getInteger(StorageLoginInfoEnum.MemberCount.getKey())); 476 | JSONArray member = fullFriendsJsonList.getJSONArray(StorageLoginInfoEnum.MemberList.getKey()); 477 | // 循环获取seq直到为0,即获取全部好友列表 ==0:好友获取完毕 >0:好友未获取完毕,此时seq为已获取的字节数 478 | while (seq > 0) { 479 | // 设置seq传参 480 | params.add(new BasicNameValuePair("r", String.valueOf(currentTime))); 481 | params.add(new BasicNameValuePair("seq", String.valueOf(seq))); 482 | entity = core.getMyHttpClient().doGet(url, params, false, null); 483 | 484 | params.remove(new BasicNameValuePair("r", String.valueOf(currentTime))); 485 | params.remove(new BasicNameValuePair("seq", String.valueOf(seq))); 486 | 487 | result = EntityUtils.toString(entity, Consts.UTF_8); 488 | fullFriendsJsonList = JSON.parseObject(result); 489 | 490 | if (fullFriendsJsonList.get("Seq") != null) { 491 | seq = fullFriendsJsonList.getLong("Seq"); 492 | currentTime = new Date().getTime(); 493 | } 494 | 495 | // 累加好友列表 496 | member.addAll(fullFriendsJsonList.getJSONArray(StorageLoginInfoEnum.MemberList.getKey())); 497 | } 498 | core.setMemberCount(member.size()); 499 | for (Iterator iterator = member.iterator(); iterator.hasNext(); ) { 500 | JSONObject o = (JSONObject) iterator.next(); 501 | if ((o.getInteger("VerifyFlag") & 8) != 0) { // 公众号/服务号 502 | core.getPublicUsersList().add(o); 503 | } else if (Config.API_SPECIAL_USER.contains(o.getString("UserName"))) { // 特殊账号 504 | core.getSpecialUsersList().add(o); 505 | } else if (o.getString("UserName").indexOf("@@") != -1) { // 群聊 506 | core.getGroupNickNameList().add(o.getString("NickName")); 507 | core.getGroupIdList().add(o.getString("UserName")); 508 | core.getGroupList().add(o); 509 | } else if (o.getString("UserName").equals(core.getUserSelf().getString("UserName"))) { // 自己 510 | core.getContactList().remove(o); 511 | } else { // 普通联系人 512 | core.getContactList().add(o); 513 | } 514 | } 515 | 516 | return; 517 | } catch (Exception e) { 518 | logger.error("获取联系人发送错误:", e); 519 | } 520 | 521 | return; 522 | } 523 | 524 | /* 525 | * @Description: 获取微信联系人 526 | * @Author: walk_code walk_code@163.com 527 | * @Param: [] 528 | * @return: void 529 | * @Date: 2019/2/26 17:59 530 | */ 531 | private void WebWxBatchGetContact() { 532 | Core core = Core.getInstance(); 533 | 534 | String url = String.format(URLEnum.WEB_WX_BATCH_GET_CONTACT.getUrl(), core.getLoginInfo().get(StorageLoginInfoEnum.url.getKey()), new Date().getTime(), core.getLoginInfo().get(StorageLoginInfoEnum.pass_ticket.getKey())); 535 | Map paramMap = core.getParamMap(); 536 | paramMap.put("Count", core.getGroupIdList().size()); 537 | List> list = new ArrayList>(); 538 | for (int i = 0; i < core.getGroupIdList().size(); i++) { 539 | HashMap map = new HashMap(); 540 | map.put("UserName", core.getGroupIdList().get(i)); 541 | map.put("EncryChatRoomId", ""); 542 | list.add(map); 543 | } 544 | paramMap.put("List", list); 545 | HttpEntity entity = core.getMyHttpClient().doPost(url, JSON.toJSONString(paramMap)); 546 | try { 547 | String text = EntityUtils.toString(entity, Consts.UTF_8); 548 | JSONObject obj = JSON.parseObject(text); 549 | JSONArray contactList = obj.getJSONArray("ContactList"); 550 | for (int i = 0; i < contactList.size(); i++) { // 群好友 551 | if (contactList.getJSONObject(i).getString("UserName").indexOf("@@") > -1) { // 群 552 | core.getGroupNickNameList().add(contactList.getJSONObject(i).getString("NickName")); // 更新群昵称列表 553 | core.getGroupList().add(contactList.getJSONObject(i)); // 更新群信息(所有)列表 554 | core.getGroupMemeberMap().put(contactList.getJSONObject(i).getString("UserName"), contactList.getJSONObject(i).getJSONArray("MemberList")); // 更新群成员Map 555 | } 556 | } 557 | } catch (Exception e) { 558 | logger.error("批量获取联系人失败:", e); 559 | } 560 | } 561 | 562 | /* 563 | * @Description: 微信api重连 564 | * @Author: walk_code walk_code@163.com 565 | * @Param: [url, map] 566 | * @return: org.apache.http.HttpEntity 567 | * @Date: 2019/2/26 17:59 568 | */ 569 | private HttpEntity reRequest(String url, Map map) { 570 | HttpEntity entity = null; 571 | for (int i = 0; i < MAX_REQUEST_TIME; i++) { 572 | try { 573 | Core core = Core.getInstance(); 574 | Map paramMap = core.getParamMap(); 575 | entity = core.getMyHttpClient().doPost(url, JSON.toJSONString(paramMap)); 576 | 577 | if (null != entity) { 578 | return entity; 579 | } 580 | } catch (Exception e) { 581 | logger.info("请求参数:{}", JsonHelper.toJson(map) + " 请求url-" + url); 582 | logger.error("请求微信获取联系人接口失败:{}", e); 583 | } 584 | } 585 | 586 | return entity; 587 | } 588 | } 589 | --------------------------------------------------------------------------------