支付模块的表的调整
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
package cn.iocoder.mall.pay.convert;
|
||||
|
||||
import cn.iocoder.mall.pay.api.bo.PayTransactionBO;
|
||||
import cn.iocoder.mall.pay.api.dto.PayTransactionCreateDTO;
|
||||
import cn.iocoder.mall.pay.dataobject.PayTransactionDO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mappings;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface PayTransactionConvert {
|
||||
|
||||
PayTransactionConvert INSTANCE = Mappers.getMapper(PayTransactionConvert.class);
|
||||
|
||||
@Mappings({})
|
||||
PayTransactionDO convert(PayTransactionCreateDTO payTransactionCreateDTO);
|
||||
|
||||
@Mappings({})
|
||||
PayTransactionBO convert(PayTransactionDO payTransactionDO);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package cn.iocoder.mall.pay.dao;
|
||||
|
||||
import cn.iocoder.mall.pay.dataobject.PayAppDO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface PayAppMapper {
|
||||
|
||||
PayAppDO selectById(@Param("id") String id);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package cn.iocoder.mall.pay.dao;
|
||||
|
||||
import cn.iocoder.mall.pay.dataobject.PayTransactionDO;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface PayTransactionMapper {
|
||||
|
||||
void insert(PayTransactionDO entity);
|
||||
|
||||
}
|
||||
@@ -3,7 +3,7 @@ package cn.iocoder.mall.pay.dataobject;
|
||||
import cn.iocoder.common.framework.dataobject.BaseDO;
|
||||
|
||||
/**
|
||||
* TODO 支付应用(业务线)DO
|
||||
* 支付应用(业务线)DO
|
||||
*/
|
||||
public class PayAppDO extends BaseDO {
|
||||
|
||||
@@ -11,5 +11,53 @@ public class PayAppDO extends BaseDO {
|
||||
* 应用编号
|
||||
*/
|
||||
private String id;
|
||||
/**
|
||||
* 应用名
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 异步通知地址
|
||||
*/
|
||||
private String notifyUrl;
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public PayAppDO setId(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public PayAppDO setName(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getNotifyUrl() {
|
||||
return notifyUrl;
|
||||
}
|
||||
|
||||
public PayAppDO setNotifyUrl(String notifyUrl) {
|
||||
this.notifyUrl = notifyUrl;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public PayAppDO setStatus(Integer status) {
|
||||
this.status = status;
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package cn.iocoder.mall.pay.dataobject;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class PayNotifyAppLogDO {
|
||||
}
|
||||
@@ -2,6 +2,8 @@ package cn.iocoder.mall.pay.dataobject;
|
||||
|
||||
/**
|
||||
* TODO 重复支付的交易
|
||||
*
|
||||
* 可能不靠这个表,而是差错处理。
|
||||
*/
|
||||
public class PayRepeatTransactionDO {
|
||||
}
|
||||
|
||||
@@ -33,15 +33,6 @@ public class PayTransactionDO extends BaseDO {
|
||||
* 2. 每个 appId 下,orderId 唯一
|
||||
*/
|
||||
private String orderId;
|
||||
/**
|
||||
* 订单状态
|
||||
*
|
||||
* 0 : 等待支付
|
||||
* 1 : 待付款完成
|
||||
* 2 : 该笔交易已关闭 TODO 交易关闭,是不是订单系统触发
|
||||
* -1 : 支付失败 TODO 怎么触发
|
||||
*/
|
||||
private Integer orderStatus;
|
||||
/**
|
||||
* 订单商品名
|
||||
*/
|
||||
@@ -60,16 +51,38 @@ public class PayTransactionDO extends BaseDO {
|
||||
* TODO 暂时不考虑货币类型。
|
||||
*/
|
||||
private Integer price;
|
||||
/**
|
||||
* 订单状态
|
||||
*
|
||||
* @see cn.iocoder.mall.pay.api.constant.PayTransactionStatusEnum
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 交易过期时间
|
||||
*/
|
||||
private Integer expireTime;
|
||||
private Date expireTime;
|
||||
/**
|
||||
* 回调业务线完成时间
|
||||
*/
|
||||
private Date finishTime;
|
||||
|
||||
|
||||
// TODO return url
|
||||
// TODO notify url
|
||||
/**
|
||||
* 异步通知地址
|
||||
*/
|
||||
private String notifyUrl;
|
||||
|
||||
/**
|
||||
* 成功支付的交易拓展编号
|
||||
*
|
||||
* @see PayTransactionExtensionDO#getId()
|
||||
*/
|
||||
private Integer extensionId;
|
||||
/**
|
||||
* 支付成功的支付渠道
|
||||
*
|
||||
* @see cn.iocoder.mall.pay.api.constant.PayChannelEnum
|
||||
*/
|
||||
private Integer payChannel;
|
||||
/**
|
||||
@@ -123,12 +136,12 @@ public class PayTransactionDO extends BaseDO {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getOrderStatus() {
|
||||
return orderStatus;
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public PayTransactionDO setOrderStatus(Integer orderStatus) {
|
||||
this.orderStatus = orderStatus;
|
||||
public PayTransactionDO setStatus(Integer status) {
|
||||
this.status = status;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -150,15 +163,6 @@ public class PayTransactionDO extends BaseDO {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getExpireTime() {
|
||||
return expireTime;
|
||||
}
|
||||
|
||||
public PayTransactionDO setExpireTime(Integer expireTime) {
|
||||
this.expireTime = expireTime;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Date getPaymentTime() {
|
||||
return paymentTime;
|
||||
}
|
||||
@@ -212,4 +216,40 @@ public class PayTransactionDO extends BaseDO {
|
||||
this.orderMemo = orderMemo;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Date getExpireTime() {
|
||||
return expireTime;
|
||||
}
|
||||
|
||||
public PayTransactionDO setExpireTime(Date expireTime) {
|
||||
this.expireTime = expireTime;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Date getFinishTime() {
|
||||
return finishTime;
|
||||
}
|
||||
|
||||
public PayTransactionDO setFinishTime(Date finishTime) {
|
||||
this.finishTime = finishTime;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getExtensionId() {
|
||||
return extensionId;
|
||||
}
|
||||
|
||||
public PayTransactionDO setExtensionId(Integer extensionId) {
|
||||
this.extensionId = extensionId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getNotifyUrl() {
|
||||
return notifyUrl;
|
||||
}
|
||||
|
||||
public PayTransactionDO setNotifyUrl(String notifyUrl) {
|
||||
this.notifyUrl = notifyUrl;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -21,14 +21,10 @@ public class PayTransactionExtensionDO extends BaseDO {
|
||||
private Integer payChannel;
|
||||
/**
|
||||
* 生成传输给第三方的订单号
|
||||
*
|
||||
* 唯一索引
|
||||
*/
|
||||
private String transactionCode;
|
||||
/**
|
||||
* 发起调用的次数
|
||||
*
|
||||
* TODO 芋艿,需要去请教下
|
||||
*/
|
||||
private Integer callNum;
|
||||
/**
|
||||
* 扩展内容
|
||||
*
|
||||
@@ -39,6 +35,13 @@ public class PayTransactionExtensionDO extends BaseDO {
|
||||
* 发起交易的 IP
|
||||
*/
|
||||
private String createIp;
|
||||
/**
|
||||
* 状态
|
||||
*
|
||||
* @see cn.iocoder.mall.pay.api.constant.PayTransactionStatusEnum
|
||||
* 注意,只包含上述枚举的 WAITTING 和 SUCCESS
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
@@ -76,15 +79,6 @@ public class PayTransactionExtensionDO extends BaseDO {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getCallNum() {
|
||||
return callNum;
|
||||
}
|
||||
|
||||
public PayTransactionExtensionDO setCallNum(Integer callNum) {
|
||||
this.callNum = callNum;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getExtensionData() {
|
||||
return extensionData;
|
||||
}
|
||||
@@ -103,4 +97,13 @@ public class PayTransactionExtensionDO extends BaseDO {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public PayTransactionExtensionDO setStatus(Integer status) {
|
||||
this.status = status;
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package cn.iocoder.mall.pay.dataobject;
|
||||
|
||||
import cn.iocoder.common.framework.dataobject.BaseDO;
|
||||
|
||||
/**
|
||||
* 支付交易通知 App 的日志 DO
|
||||
*
|
||||
* 通过该表,记录通知 App 时,产生的日志
|
||||
*/
|
||||
public class PayTransactionNotifyLogDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 日志编号,自增
|
||||
*/
|
||||
private Integer id;
|
||||
/**
|
||||
* 请求参数
|
||||
*/
|
||||
private String request;
|
||||
/**
|
||||
* 响应结果
|
||||
*/
|
||||
private String response;
|
||||
/**
|
||||
* 状态
|
||||
*
|
||||
* @see cn.iocoder.mall.pay.api.constant.PayTransactionNotifyStatusEnum
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public PayTransactionNotifyLogDO setId(Integer id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getRequest() {
|
||||
return request;
|
||||
}
|
||||
|
||||
public PayTransactionNotifyLogDO setRequest(String request) {
|
||||
this.request = request;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getResponse() {
|
||||
return response;
|
||||
}
|
||||
|
||||
public PayTransactionNotifyLogDO setResponse(String response) {
|
||||
this.response = response;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public PayTransactionNotifyLogDO setStatus(Integer status) {
|
||||
this.status = status;
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
package cn.iocoder.mall.pay.dataobject;
|
||||
|
||||
import cn.iocoder.common.framework.dataobject.BaseDO;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 支付交易通知 App 的任务 DO
|
||||
*/
|
||||
public class PayTransactionNotifyTaskDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 编号,自增
|
||||
*/
|
||||
private Integer id;
|
||||
/**
|
||||
* 交易编号
|
||||
*
|
||||
* {@link PayTransactionDO#getId()}
|
||||
*/
|
||||
private Integer transactionId;
|
||||
/**
|
||||
* 交易拓展编号
|
||||
*
|
||||
* {@link PayTransactionExtensionDO#getId()}
|
||||
*/
|
||||
private Integer transactionExtensionId;
|
||||
/**
|
||||
* 应用编号
|
||||
*/
|
||||
private String appId;
|
||||
/**
|
||||
* 应用订单编号
|
||||
*/
|
||||
private String orderId;
|
||||
/**
|
||||
* 通知状态
|
||||
*
|
||||
* @see cn.iocoder.mall.pay.api.constant.PayTransactionNotifyStatusEnum
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 最后一次通知时间
|
||||
*/
|
||||
private Date lastNotifyTime;
|
||||
/**
|
||||
* 当前通知次数
|
||||
*/
|
||||
private Integer notifyTimes;
|
||||
/**
|
||||
* 最大可通知次数
|
||||
*/
|
||||
private Integer maxNotifyTimes;
|
||||
|
||||
// TODO notify url
|
||||
|
||||
|
||||
public Integer getTransactionId() {
|
||||
return transactionId;
|
||||
}
|
||||
|
||||
public PayTransactionNotifyTaskDO setTransactionId(Integer transactionId) {
|
||||
this.transactionId = transactionId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getAppId() {
|
||||
return appId;
|
||||
}
|
||||
|
||||
public PayTransactionNotifyTaskDO setAppId(String appId) {
|
||||
this.appId = appId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getOrderId() {
|
||||
return orderId;
|
||||
}
|
||||
|
||||
public PayTransactionNotifyTaskDO setOrderId(String orderId) {
|
||||
this.orderId = orderId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public PayTransactionNotifyTaskDO setStatus(Integer status) {
|
||||
this.status = status;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Date getLastNotifyTime() {
|
||||
return lastNotifyTime;
|
||||
}
|
||||
|
||||
public PayTransactionNotifyTaskDO setLastNotifyTime(Date lastNotifyTime) {
|
||||
this.lastNotifyTime = lastNotifyTime;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getNotifyTimes() {
|
||||
return notifyTimes;
|
||||
}
|
||||
|
||||
public PayTransactionNotifyTaskDO setNotifyTimes(Integer notifyTimes) {
|
||||
this.notifyTimes = notifyTimes;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getMaxNotifyTimes() {
|
||||
return maxNotifyTimes;
|
||||
}
|
||||
|
||||
public PayTransactionNotifyTaskDO setMaxNotifyTimes(Integer maxNotifyTimes) {
|
||||
this.maxNotifyTimes = maxNotifyTimes;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public PayTransactionNotifyTaskDO setId(Integer id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getTransactionExtensionId() {
|
||||
return transactionExtensionId;
|
||||
}
|
||||
|
||||
public PayTransactionNotifyTaskDO setTransactionExtensionId(Integer transactionExtensionId) {
|
||||
this.transactionExtensionId = transactionExtensionId;
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package cn.iocoder.mall.pay.scheduler;
|
||||
|
||||
/**
|
||||
* TODO
|
||||
*/
|
||||
public class PayNotifyAppJob {
|
||||
|
||||
// TODO 需要考虑下是基于 MQ 还是 Job
|
||||
// TODO 通知频率
|
||||
// TODO rpc 泛化回调
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package cn.iocoder.mall.pay.service;
|
||||
|
||||
import cn.iocoder.common.framework.constant.CommonStatusEnum;
|
||||
import cn.iocoder.common.framework.util.ServiceExceptionUtil;
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.pay.api.constant.PayErrorCodeEnum;
|
||||
import cn.iocoder.mall.pay.dao.PayAppMapper;
|
||||
import cn.iocoder.mall.pay.dataobject.PayAppDO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class PayAppServiceImpl {
|
||||
|
||||
@Autowired
|
||||
private PayAppMapper payAppMapper;
|
||||
|
||||
public CommonResult<PayAppDO> validPayApp(String appId) {
|
||||
PayAppDO payAppDO = payAppMapper.selectById(appId);
|
||||
// 校验是否存在
|
||||
if (payAppDO == null) {
|
||||
return ServiceExceptionUtil.error(PayErrorCodeEnum.PAY_APP_NOT_FOUND.getCode());
|
||||
}
|
||||
// 校验是否禁用
|
||||
if (CommonStatusEnum.DISABLE.getValue().equals(payAppDO.getStatus())) {
|
||||
return ServiceExceptionUtil.error(PayErrorCodeEnum.PAY_APP_IS_DISABLE.getCode());
|
||||
}
|
||||
return CommonResult.success(payAppDO);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,9 +1,44 @@
|
||||
package cn.iocoder.mall.pay.service;
|
||||
|
||||
import cn.iocoder.mall.pay.api.PayService;
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.pay.api.PayTransactionService;
|
||||
import cn.iocoder.mall.pay.api.bo.PayTransactionBO;
|
||||
import cn.iocoder.mall.pay.api.dto.PayTransactionCreateDTO;
|
||||
import cn.iocoder.mall.pay.dao.PayTransactionMapper;
|
||||
import cn.iocoder.mall.pay.dataobject.PayAppDO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@com.alibaba.dubbo.config.annotation.Service(validation = "true")
|
||||
public class PayServiceImpl implements PayService {
|
||||
}
|
||||
public class PayServiceImpl implements PayTransactionService {
|
||||
|
||||
@Autowired
|
||||
private PayTransactionMapper payTransactionMapper;
|
||||
@Autowired
|
||||
private PayAppServiceImpl payAppService;
|
||||
|
||||
@Override
|
||||
public CommonResult<PayTransactionBO> createTransaction(PayTransactionCreateDTO payTransactionCreateDTO) {
|
||||
// 校验 App
|
||||
CommonResult<PayAppDO> appResult = payAppService.validPayApp(payTransactionCreateDTO.getAppId());
|
||||
if (appResult.isError()) {
|
||||
return CommonResult.error(appResult);
|
||||
}
|
||||
// 插入 PayTransactionDO
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult submitTransaction() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult cancelTransaction() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?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">
|
||||
<mapper namespace="cn.iocoder.mall.pay.dao.PayAppMapper">
|
||||
|
||||
<sql id="FIELDS">
|
||||
id, name, status, create_time
|
||||
</sql>
|
||||
|
||||
<!--<insert id="insert" parameterType="RoleDO" useGeneratedKeys="true" keyColumn="id" keyProperty="id">-->
|
||||
<!--INSERT INTO role (-->
|
||||
<!--name, create_time, deleted-->
|
||||
<!--) VALUES (-->
|
||||
<!--#{name}, #{createTime}, #{deleted}-->
|
||||
<!--)-->
|
||||
<!--</insert>-->
|
||||
|
||||
<!--<update id="update" parameterType="RoleDO">-->
|
||||
<!--UPDATE role-->
|
||||
<!--<set>-->
|
||||
<!--<if test="name != null">-->
|
||||
<!--, name = #{name}-->
|
||||
<!--</if>-->
|
||||
<!--<if test="deleted != null">-->
|
||||
<!--, deleted = #{deleted}-->
|
||||
<!--</if>-->
|
||||
<!--</set>-->
|
||||
<!--WHERE id = #{id}-->
|
||||
<!--</update>-->
|
||||
|
||||
<select id="selectById" parameterType="Integer" resultType="PayAppDO">
|
||||
SELECT
|
||||
<include refid="FIELDS"/>
|
||||
FROM app
|
||||
WHERE id = #{id}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user