调整 pay-service-impl 的包,增加 biz 包

增加定时任务,使用 xxl-job
This commit is contained in:
YunaiV 2019-03-14 00:20:40 +08:00
parent 7d423c8ed2
commit 9d7af382ab
33 changed files with 146 additions and 68 deletions

View File

@ -1,12 +0,0 @@
package cn.iocoder.mall.pay.application.scheduler;
/**
* TODO
*/
public class PayNotifyAppJob {
// TODO 需要考虑下是基于 MQ 还是 Job
// TODO 通知频率
// TODO rpc 泛化回调
}

View File

@ -19,6 +19,7 @@
<dependency> <dependency>
<groupId>com.alibaba</groupId> <groupId>com.alibaba</groupId>
<artifactId>dubbo</artifactId> <artifactId>dubbo</artifactId>
<scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>cn.iocoder.mall</groupId> <groupId>cn.iocoder.mall</groupId>
@ -66,6 +67,12 @@
<type>jar</type> <type>jar</type>
</dependency> </dependency>
<dependency>
<groupId>com.xuxueli</groupId>
<artifactId>xxl-job-core</artifactId>
<version>2.0.1</version>
</dependency>
</dependencies> </dependencies>
<build> <build>

View File

@ -1,8 +1,8 @@
package cn.iocoder.mall.pay.client; package cn.iocoder.mall.pay.biz.client;
import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.pay.dataobject.PayTransactionDO; import cn.iocoder.mall.pay.biz.dataobject.PayTransactionDO;
import cn.iocoder.mall.pay.dataobject.PayTransactionExtensionDO; import cn.iocoder.mall.pay.biz.dataobject.PayTransactionExtensionDO;
import java.util.Map; import java.util.Map;

View File

@ -1,4 +1,4 @@
package cn.iocoder.mall.pay.client; package cn.iocoder.mall.pay.biz.client;
import cn.iocoder.mall.pay.api.constant.PayChannelEnum; import cn.iocoder.mall.pay.api.constant.PayChannelEnum;

View File

@ -1,8 +1,8 @@
package cn.iocoder.mall.pay.client; package cn.iocoder.mall.pay.biz.client;
import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.pay.dataobject.PayTransactionDO; import cn.iocoder.mall.pay.biz.dataobject.PayTransactionDO;
import cn.iocoder.mall.pay.dataobject.PayTransactionExtensionDO; import cn.iocoder.mall.pay.biz.dataobject.PayTransactionExtensionDO;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;

View File

@ -1,4 +1,4 @@
package cn.iocoder.mall.pay.client; package cn.iocoder.mall.pay.biz.client;
import java.util.Date; import java.util.Date;

View File

@ -1,11 +1,11 @@
package cn.iocoder.mall.pay.config; package cn.iocoder.mall.pay.biz.config;
import org.mybatis.spring.annotation.MapperScan; import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement; import org.springframework.transaction.annotation.EnableTransactionManagement;
@Configuration @Configuration
@MapperScan("cn.iocoder.mall.pay.dao") // 扫描对应的 Mapper 接口 @MapperScan("cn.iocoder.mall.pay.biz.dao") // 扫描对应的 Mapper 接口
@EnableTransactionManagement(proxyTargetClass = true) // 启动事务管理为什么使用 proxyTargetClass 参数参见 https://blog.csdn.net/huang_550/article/details/76492600 @EnableTransactionManagement(proxyTargetClass = true) // 启动事务管理为什么使用 proxyTargetClass 参数参见 https://blog.csdn.net/huang_550/article/details/76492600
public class DatabaseConfiguration { public class DatabaseConfiguration {

View File

@ -1,4 +1,4 @@
package cn.iocoder.mall.pay.config; package cn.iocoder.mall.pay.biz.config;
import cn.iocoder.common.framework.util.ServiceExceptionUtil; import cn.iocoder.common.framework.util.ServiceExceptionUtil;
import cn.iocoder.mall.pay.api.constant.PayErrorCodeEnum; import cn.iocoder.mall.pay.api.constant.PayErrorCodeEnum;

View File

@ -0,0 +1,45 @@
package cn.iocoder.mall.pay.biz.config;
import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class XxlJobConfiguration {
private Logger logger = LoggerFactory.getLogger(XxlJobConfiguration.class);
@Value("${xxl.job.admin.addresses}")
private String adminAddresses;
@Value("${xxl.job.executor.appname}")
private String appName;
@Value("${xxl.job.executor.ip}")
private String ip;
@Value("${xxl.job.executor.port}")
private int port;
@Value("${xxl.job.accessToken}")
private String accessToken;
@Value("${xxl.job.executor.logpath}")
private String logPath;
@Value("${xxl.job.executor.logretentiondays}")
private int logRetentionDays;
@Bean(initMethod = "start", destroyMethod = "destroy")
public XxlJobSpringExecutor xxlJobExecutor() {
logger.info(">>>>>>>>>>> xxl-job config init.");
XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
xxlJobSpringExecutor.setAdminAddresses(adminAddresses);
xxlJobSpringExecutor.setAppName(appName);
xxlJobSpringExecutor.setIp(ip);
xxlJobSpringExecutor.setPort(port);
xxlJobSpringExecutor.setAccessToken(accessToken);
xxlJobSpringExecutor.setLogPath(logPath);
xxlJobSpringExecutor.setLogRetentionDays(logRetentionDays);
return xxlJobSpringExecutor;
}
}

View File

@ -1,10 +1,10 @@
package cn.iocoder.mall.pay.convert; package cn.iocoder.mall.pay.biz.convert;
import cn.iocoder.mall.pay.api.bo.PayTransactionBO; import cn.iocoder.mall.pay.api.bo.PayTransactionBO;
import cn.iocoder.mall.pay.api.dto.PayTransactionCreateDTO; import cn.iocoder.mall.pay.api.dto.PayTransactionCreateDTO;
import cn.iocoder.mall.pay.api.dto.PayTransactionSubmitDTO; import cn.iocoder.mall.pay.api.dto.PayTransactionSubmitDTO;
import cn.iocoder.mall.pay.dataobject.PayTransactionDO; import cn.iocoder.mall.pay.biz.dataobject.PayTransactionDO;
import cn.iocoder.mall.pay.dataobject.PayTransactionExtensionDO; import cn.iocoder.mall.pay.biz.dataobject.PayTransactionExtensionDO;
import org.mapstruct.Mapper; import org.mapstruct.Mapper;
import org.mapstruct.Mappings; import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers; import org.mapstruct.factory.Mappers;

View File

@ -1,6 +1,6 @@
package cn.iocoder.mall.pay.dao; package cn.iocoder.mall.pay.biz.dao;
import cn.iocoder.mall.pay.dataobject.PayAppDO; import cn.iocoder.mall.pay.biz.dataobject.PayAppDO;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;

View File

@ -1,6 +1,6 @@
package cn.iocoder.mall.pay.dao; package cn.iocoder.mall.pay.biz.dao;
import cn.iocoder.mall.pay.dataobject.PayTransactionExtensionDO; import cn.iocoder.mall.pay.biz.dataobject.PayTransactionExtensionDO;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;

View File

@ -1,6 +1,6 @@
package cn.iocoder.mall.pay.dao; package cn.iocoder.mall.pay.biz.dao;
import cn.iocoder.mall.pay.dataobject.PayTransactionDO; import cn.iocoder.mall.pay.biz.dataobject.PayTransactionDO;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;

View File

@ -1,6 +1,6 @@
package cn.iocoder.mall.pay.dao; package cn.iocoder.mall.pay.biz.dao;
import cn.iocoder.mall.pay.dataobject.PayTransactionNotifyTaskDO; import cn.iocoder.mall.pay.biz.dataobject.PayTransactionNotifyTaskDO;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
@Repository @Repository

View File

@ -1,4 +1,4 @@
package cn.iocoder.mall.pay.dataobject; package cn.iocoder.mall.pay.biz.dataobject;
import cn.iocoder.common.framework.dataobject.BaseDO; import cn.iocoder.common.framework.dataobject.BaseDO;

View File

@ -1,4 +1,4 @@
package cn.iocoder.mall.pay.dataobject; package cn.iocoder.mall.pay.biz.dataobject;
/** /**
* 交易日志 DO * 交易日志 DO

View File

@ -0,0 +1,4 @@
package cn.iocoder.mall.pay.biz.dataobject;
public class PayRefundDO {
}

View File

@ -1,4 +1,4 @@
package cn.iocoder.mall.pay.dataobject; package cn.iocoder.mall.pay.biz.dataobject;
/** /**
* TODO 重复支付的交易 * TODO 重复支付的交易

View File

@ -1,4 +1,4 @@
package cn.iocoder.mall.pay.dataobject; package cn.iocoder.mall.pay.biz.dataobject;
import cn.iocoder.common.framework.dataobject.BaseDO; import cn.iocoder.common.framework.dataobject.BaseDO;

View File

@ -1,4 +1,4 @@
package cn.iocoder.mall.pay.dataobject; package cn.iocoder.mall.pay.biz.dataobject;
import cn.iocoder.common.framework.dataobject.BaseDO; import cn.iocoder.common.framework.dataobject.BaseDO;

View File

@ -1,4 +1,4 @@
package cn.iocoder.mall.pay.dataobject; package cn.iocoder.mall.pay.biz.dataobject;
import cn.iocoder.common.framework.dataobject.BaseDO; import cn.iocoder.common.framework.dataobject.BaseDO;

View File

@ -1,4 +1,4 @@
package cn.iocoder.mall.pay.dataobject; package cn.iocoder.mall.pay.biz.dataobject;
import cn.iocoder.common.framework.dataobject.BaseDO; import cn.iocoder.common.framework.dataobject.BaseDO;

View File

@ -0,0 +1,25 @@
package cn.iocoder.mall.pay.biz.scheduler;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.IJobHandler;
import com.xxl.job.core.handler.annotation.JobHandler;
import org.springframework.stereotype.Component;
/**
* TODO
*/
@Component
@JobHandler(value = "payNotifyAppJob")
public class PayNotifyAppJob extends IJobHandler {
@Override
public ReturnT<String> execute(String param) throws Exception {
System.out.println("1");
return null;
}
// TODO 需要考虑下是基于 MQ 还是 Job
// TODO 通知频率
// TODO rpc 泛化回调
}

View File

@ -1,11 +1,11 @@
package cn.iocoder.mall.pay.service; package cn.iocoder.mall.pay.biz.service;
import cn.iocoder.common.framework.constant.CommonStatusEnum; import cn.iocoder.common.framework.constant.CommonStatusEnum;
import cn.iocoder.common.framework.util.ServiceExceptionUtil; import cn.iocoder.common.framework.util.ServiceExceptionUtil;
import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.pay.api.constant.PayErrorCodeEnum; import cn.iocoder.mall.pay.api.constant.PayErrorCodeEnum;
import cn.iocoder.mall.pay.dao.PayAppMapper; import cn.iocoder.mall.pay.biz.dao.PayAppMapper;
import cn.iocoder.mall.pay.dataobject.PayAppDO; import cn.iocoder.mall.pay.biz.dataobject.PayAppDO;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;

View File

@ -1,4 +1,4 @@
package cn.iocoder.mall.pay.service; package cn.iocoder.mall.pay.biz.service;
import cn.iocoder.mall.pay.api.PayDemoService; import cn.iocoder.mall.pay.api.PayDemoService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;

View File

@ -1,4 +1,4 @@
package cn.iocoder.mall.pay.service; package cn.iocoder.mall.pay.biz.service;
import cn.iocoder.common.framework.util.DateUtil; import cn.iocoder.common.framework.util.DateUtil;
import cn.iocoder.common.framework.util.MathUtil; import cn.iocoder.common.framework.util.MathUtil;
@ -12,17 +12,17 @@ import cn.iocoder.mall.pay.api.constant.PayTransactionNotifyStatusEnum;
import cn.iocoder.mall.pay.api.constant.PayTransactionStatusEnum; import cn.iocoder.mall.pay.api.constant.PayTransactionStatusEnum;
import cn.iocoder.mall.pay.api.dto.PayTransactionCreateDTO; import cn.iocoder.mall.pay.api.dto.PayTransactionCreateDTO;
import cn.iocoder.mall.pay.api.dto.PayTransactionSubmitDTO; import cn.iocoder.mall.pay.api.dto.PayTransactionSubmitDTO;
import cn.iocoder.mall.pay.client.AbstractPaySDK; import cn.iocoder.mall.pay.biz.client.AbstractPaySDK;
import cn.iocoder.mall.pay.client.PaySDKFactory; import cn.iocoder.mall.pay.biz.client.PaySDKFactory;
import cn.iocoder.mall.pay.client.TransactionPaySuccessBO; import cn.iocoder.mall.pay.biz.client.TransactionPaySuccessBO;
import cn.iocoder.mall.pay.convert.PayTransactionConvert; import cn.iocoder.mall.pay.biz.convert.PayTransactionConvert;
import cn.iocoder.mall.pay.dao.PayTransactionExtensionMapper; import cn.iocoder.mall.pay.biz.dao.PayTransactionExtensionMapper;
import cn.iocoder.mall.pay.dao.PayTransactionMapper; import cn.iocoder.mall.pay.biz.dao.PayTransactionMapper;
import cn.iocoder.mall.pay.dao.PayTransactionNotifyTaskMapper; import cn.iocoder.mall.pay.biz.dao.PayTransactionNotifyTaskMapper;
import cn.iocoder.mall.pay.dataobject.PayAppDO; import cn.iocoder.mall.pay.biz.dataobject.PayAppDO;
import cn.iocoder.mall.pay.dataobject.PayTransactionDO; import cn.iocoder.mall.pay.biz.dataobject.PayTransactionDO;
import cn.iocoder.mall.pay.dataobject.PayTransactionExtensionDO; import cn.iocoder.mall.pay.biz.dataobject.PayTransactionExtensionDO;
import cn.iocoder.mall.pay.dataobject.PayTransactionNotifyTaskDO; import cn.iocoder.mall.pay.biz.dataobject.PayTransactionNotifyTaskDO;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;

View File

@ -1,4 +0,0 @@
package cn.iocoder.mall.pay.dataobject;
public class PayRefundDO {
}

View File

@ -1 +0,0 @@
package cn.iocoder.mall.pay;

View File

@ -10,7 +10,7 @@ spring:
mybatis: mybatis:
config-location: classpath:mybatis-config.xml config-location: classpath:mybatis-config.xml
mapper-locations: classpath:mapper/*.xml mapper-locations: classpath:mapper/*.xml
type-aliases-package: cn.iocoder.mall.pay.dataobject type-aliases-package: cn.iocoder.mall.pay.biz.dataobject
# dubbo # dubbo
dubbo: dubbo:
@ -22,4 +22,18 @@ dubbo:
port: -1 port: -1
name: dubbo name: dubbo
scan: scan:
base-packages: cn.iocoder.mall.pay.service base-packages: cn.iocoder.mall.pay.biz.service
# xxl-job
xxl:
job:
admin:
addresses: http://127.0.0.1:8080/xxl-job-admin
executor:
appname: pay-job-executor
ip:
port: 0
logpath: /Users/yunai/logs/xxl-job/
logretentiondays: 1
accessToken:

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.mall.pay.dao.PayAppMapper"> <mapper namespace="cn.iocoder.mall.pay.biz.dao.PayAppMapper">
<sql id="FIELDS"> <sql id="FIELDS">
id, name, notify_url, status, create_time id, name, notify_url, status, create_time

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.mall.pay.dao.PayTransactionExtensionMapper"> <mapper namespace="cn.iocoder.mall.pay.biz.dao.PayTransactionExtensionMapper">
<sql id="FIELDS"> <sql id="FIELDS">
id, transaction_id, pay_channel, transaction_code, extension_data, id, transaction_id, pay_channel, transaction_code, extension_data,

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.mall.pay.dao.PayTransactionMapper"> <mapper namespace="cn.iocoder.mall.pay.biz.dao.PayTransactionMapper">
<sql id="FIELDS"> <sql id="FIELDS">
id, app_id, create_ip, order_id, order_subject, id, app_id, create_ip, order_id, order_subject,

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.mall.pay.dao.PayTransactionNotifyTaskMapper"> <mapper namespace="cn.iocoder.mall.pay.biz.dao.PayTransactionNotifyTaskMapper">
<sql id="FIELDS"> <sql id="FIELDS">
id, transaction_id, transaction_extension_id, app_id, order_id, id, transaction_id, transaction_extension_id, app_id, order_id,