支付模块的表的调整

This commit is contained in:
YunaiV 2019-03-12 20:07:40 +08:00
parent 0fa5326f0a
commit 354ea3b6c1
34 changed files with 1122 additions and 78 deletions

View File

@ -16,6 +16,7 @@
FROM admin a, admin_role ar FROM admin a, admin_role ar
WHERE a.id = #{adminId} WHERE a.id = #{adminId}
AND a.id = ar.admin_id AND a.id = ar.admin_id
AND ar.deleted = 0
</select> </select>
<update id="updateToDeletedByAdminId" parameterType="Integer"> <update id="updateToDeletedByAdminId" parameterType="Integer">

View File

@ -1 +0,0 @@
mvn clean package -am -DskipTests

View File

@ -1 +0,0 @@
mvn clean package -pl order/order-application -am -DskipTests

View File

@ -1 +0,0 @@
mvn clean package -pl product/product-application -am -DskipTests

View File

@ -0,0 +1,43 @@
package cn.iocoder.common.framework.constant;
/**
* 通用状态枚举
*/
public enum CommonStatusEnum {
ENABLE(1, "开启"),
DISABLE(2, "关闭");
/**
* 状态值
*/
private Integer value;
/**
* 状态名
*/
private String name;
CommonStatusEnum(Integer value, String name) {
this.value = value;
this.name = name;
}
public Integer getValue() {
return value;
}
public CommonStatusEnum setValue(Integer value) {
this.value = value;
return this;
}
public String getName() {
return name;
}
public CommonStatusEnum setName(String name) {
this.name = name;
return this;
}
}

View File

@ -18,4 +18,25 @@ public class HttpUtil {
return authorization.substring(index + 7).trim(); return authorization.substring(index + 7).trim();
} }
public static String getIp(HttpServletRequest request) {
// 基于 X-Forwarded-For 获得
String ip = request.getHeader("X-Forwarded-For");
if (!StringUtils.isEmpty(ip) && !"unKnown".equalsIgnoreCase(ip)) {
// 多次反向代理后会有多个ip值第一个 ip 才是真实 ip
int index = ip.indexOf(",");
if (index != -1) {
return ip.substring(0, index);
} else {
return ip;
}
}
// 基于 X-Real-IP 获得
ip = request.getHeader("X-Real-IP");
if (!StringUtils.isEmpty(ip) && !"unKnown".equalsIgnoreCase(ip)) {
return ip;
}
// 默认方式
return request.getRemoteAddr();
}
} }

View File

@ -1,15 +0,0 @@
package cn.iocoder.mall.pay.application.controller;
import cn.iocoder.mall.pay.api.PayService;
import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/pay")
public class PayController {
@Reference(validation = "true")
private PayService payService;
}

View File

@ -0,0 +1,46 @@
package cn.iocoder.mall.pay.application.controller.users;
import cn.iocoder.common.framework.util.HttpUtil;
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 com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.util.Date;
/**
* 示例 Controller
*/
@RestController
@RequestMapping("users/demo")
public class PayDemoController {
@Reference(validation = "true")
private PayTransactionService payTransactionService;
@PostMapping("/create_order")
public void createOrder(HttpServletRequest request) {
// 创建业务订单
// ...
// 调用支付服务创建交易订单
PayTransactionCreateDTO payTransactionCreateDTO = new PayTransactionCreateDTO()
.setAppId("1024")
.setCreateIp(HttpUtil.getIp(request))
.setOrderId("1")
.setOrderSubject("商品名" )
.setOrderDescription("商品描述")
.setOrderMemo("商品备注")
.setPrice(10)
.setExpireTime(new Date());
CommonResult<PayTransactionBO> result = payTransactionService.createTransaction(payTransactionCreateDTO);
Assert.isTrue(result.isSuccess(), "一定会成功的");
}
}

View File

@ -0,0 +1,22 @@
package cn.iocoder.mall.pay.application.controller.users;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.pay.api.PayTransactionService;
import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("users/transaction") // TODO 芋艿理论来说是用户无关的这里先酱紫先~
public class PayTransactionController {
@Reference(validation = "true")
private PayTransactionService payService;
@PostMapping("/submit") // TODO api 注释
public CommonResult submit() { // TODO 1. params 2. result
return null;
}
}

View File

@ -10,6 +10,14 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>pay-service-api</artifactId> <artifactId>pay-service-api</artifactId>
<dependencies>
<dependency>
<groupId>cn.iocoder.mall</groupId>
<artifactId>common-framework</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project> </project>

View File

@ -1,4 +0,0 @@
package cn.iocoder.mall.pay.api;
public interface PayService {
}

View File

@ -0,0 +1,15 @@
package cn.iocoder.mall.pay.api;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.pay.api.bo.PayTransactionBO;
import cn.iocoder.mall.pay.api.dto.PayTransactionCreateDTO;
public interface PayTransactionService {
CommonResult<PayTransactionBO> createTransaction(PayTransactionCreateDTO payTransactionCreateDTO);
CommonResult submitTransaction(); // TODO 1. params 2. result
CommonResult cancelTransaction(); // TODO 1. params 2. result
}

View File

@ -0,0 +1,242 @@
package cn.iocoder.mall.pay.api.bo;
import java.util.Date;
/**
* 支付交易 BO
*/
public class PayTransactionBO {
/**
* 编号自增
*/
private Integer id;
/**
* 应用编号
*/
private String appId;
/**
* 发起交易的 IP
*/
private String createIp;
/**
* 业务线的订单编号
*
* 1. 使用 String 的原因是业务线可能使用 String 做为编号
* 2. 每个 appId orderId 唯一
*/
private String orderId;
/**
* 订单商品名
*/
private String orderSubject;
/**
* 订单商品描述
*/
private String orderDescription;
/**
* 订单备注
*/
private String orderMemo;
/**
* 支付金额单位
*/
private Integer price;
/**
* 订单状态
*
* @see cn.iocoder.mall.pay.api.constant.PayTransactionStatusEnum
*/
private Integer status;
/**
* 交易过期时间
*/
private Date expireTime;
/**
* 回调业务线完成时间
*/
private Date finishTime;
/**
* 成功支付的交易拓展编号
*/
private Integer extensionId;
/**
* 支付成功的支付渠道
*
* @see cn.iocoder.mall.pay.api.constant.PayChannelEnum
*/
private Integer payChannel;
/**
* 第三方支付成功的时间
*/
private Date paymentTime;
/**
* 收到第三方系统通知的时间
*
* 一般情况下即第三方系统的异步通知
*/
private Date notifyTime;
/**
* 第三方的流水号
*/
private String tradeNo;
/**
* 创建时间
*/
private Date createTime;
public Integer getId() {
return id;
}
public PayTransactionBO setId(Integer id) {
this.id = id;
return this;
}
public String getAppId() {
return appId;
}
public PayTransactionBO setAppId(String appId) {
this.appId = appId;
return this;
}
public String getCreateIp() {
return createIp;
}
public PayTransactionBO setCreateIp(String createIp) {
this.createIp = createIp;
return this;
}
public String getOrderId() {
return orderId;
}
public PayTransactionBO setOrderId(String orderId) {
this.orderId = orderId;
return this;
}
public String getOrderSubject() {
return orderSubject;
}
public PayTransactionBO setOrderSubject(String orderSubject) {
this.orderSubject = orderSubject;
return this;
}
public String getOrderDescription() {
return orderDescription;
}
public PayTransactionBO setOrderDescription(String orderDescription) {
this.orderDescription = orderDescription;
return this;
}
public String getOrderMemo() {
return orderMemo;
}
public PayTransactionBO setOrderMemo(String orderMemo) {
this.orderMemo = orderMemo;
return this;
}
public Integer getPrice() {
return price;
}
public PayTransactionBO setPrice(Integer price) {
this.price = price;
return this;
}
public Integer getStatus() {
return status;
}
public PayTransactionBO setStatus(Integer status) {
this.status = status;
return this;
}
public Date getExpireTime() {
return expireTime;
}
public PayTransactionBO setExpireTime(Date expireTime) {
this.expireTime = expireTime;
return this;
}
public Date getFinishTime() {
return finishTime;
}
public PayTransactionBO setFinishTime(Date finishTime) {
this.finishTime = finishTime;
return this;
}
public Integer getExtensionId() {
return extensionId;
}
public PayTransactionBO setExtensionId(Integer extensionId) {
this.extensionId = extensionId;
return this;
}
public Integer getPayChannel() {
return payChannel;
}
public PayTransactionBO setPayChannel(Integer payChannel) {
this.payChannel = payChannel;
return this;
}
public Date getPaymentTime() {
return paymentTime;
}
public PayTransactionBO setPaymentTime(Date paymentTime) {
this.paymentTime = paymentTime;
return this;
}
public Date getNotifyTime() {
return notifyTime;
}
public PayTransactionBO setNotifyTime(Date notifyTime) {
this.notifyTime = notifyTime;
return this;
}
public String getTradeNo() {
return tradeNo;
}
public PayTransactionBO setTradeNo(String tradeNo) {
this.tradeNo = tradeNo;
return this;
}
public Date getCreateTime() {
return createTime;
}
public PayTransactionBO setCreateTime(Date createTime) {
this.createTime = createTime;
return this;
}
}

View File

@ -3,7 +3,7 @@ package cn.iocoder.mall.pay.api.constant;
/** /**
* 支付通道 * 支付通道
*/ */
public enum PayChannel { public enum PayChannelEnum {
WEIXIN_APP(100, "wx", "微信 App 支付"), WEIXIN_APP(100, "wx", "微信 App 支付"),
WEIXIN_PUB(100, "wx", "微信 JS API 支付"), WEIXIN_PUB(100, "wx", "微信 JS API 支付"),
@ -23,7 +23,7 @@ public enum PayChannel {
*/ */
private String name; private String name;
PayChannel(Integer id, String code, String name) { PayChannelEnum(Integer id, String code, String name) {
this.id = id; this.id = id;
this.code = code; this.code = code;
this.name = name; this.name = name;
@ -40,4 +40,5 @@ public enum PayChannel {
public String getName() { public String getName() {
return name; return name;
} }
} }

View File

@ -7,7 +7,13 @@ package cn.iocoder.mall.pay.api.constant;
*/ */
public enum PayErrorCodeEnum { public enum PayErrorCodeEnum {
// ========== PAY 模块 ========== // ========== APP 模块 ==========
PAY_APP_NOT_FOUND(1004000000, "App 不存在"),
PAY_APP_IS_DISABLE(1004000001, "App 已经被禁用"),
// ========== TRANSACTION 模块 ==========
; ;
private final int code; private final int code;

View File

@ -0,0 +1,38 @@
package cn.iocoder.mall.pay.api.constant;
/**
* 支付交易通知状态枚举
*/
public enum PayTransactionNotifyStatusEnum {
WAITING(1, "等待通知"),
SUCCESS(2, "通知成功"),
FAILURE(3, "通知失败"), // 多次尝试彻底失败
REQUEST_SUCCESS(4, "请求成功,但是结果失败"),
REQUEST_FAILURE(5, "请求失败"),
;
/**
* 状态
*/
private Integer value;
/**
* 名字
*/
private String name;
PayTransactionNotifyStatusEnum(Integer value, String name) {
this.value = value;
this.name = name;
}
public Integer getValue() {
return value;
}
public String getName() {
return name;
}
}

View File

@ -0,0 +1,45 @@
package cn.iocoder.mall.pay.api.constant;
/**
* 支付交易状态枚举
*/
public enum PayTransactionStatusEnum {
WAITTING(1, "等待支付"),
SUCCESS(2, "支付成功"),
CANCEL(3, "取消支付"), // 例如说支付单超时
;
/**
* 状态
*/
private Integer value;
/**
* 名字
*/
private String name;
PayTransactionStatusEnum(Integer value, String name) {
this.value = value;
this.name = name;
}
public Integer getValue() {
return value;
}
public PayTransactionStatusEnum setValue(Integer value) {
this.value = value;
return this;
}
public String getName() {
return name;
}
public PayTransactionStatusEnum setName(String name) {
this.name = name;
return this;
}
}

View File

@ -0,0 +1,130 @@
package cn.iocoder.mall.pay.api.dto;
import javax.validation.constraints.DecimalMin;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.Date;
/**
* 支付交易创建 DTO
*/
public class PayTransactionCreateDTO {
/**
* 应用编号
*/
@NotEmpty(message = "应用编号不能为空")
private String appId;
/**
* 发起交易的 IP
*/
@NotEmpty(message = "IP 不能为空")
private String createIp;
/**
* 业务线的订单编号
*/
@NotEmpty(message = "订单号不能为空")
private String orderId;
/**
* 订单商品名
*/
@NotEmpty(message = "商品名不能为空")
@Size(max = 32, message = "商品名不能超过32")
private String orderSubject;
/**
* 订单商品描述
*/
@NotEmpty(message = "商品描述不能为空")
@Size(max = 128, message = "商品描述长度不能超过128")
private String orderDescription;
/**
* 订单备注
*/
@Size(max = 256, message = "商品描述长度不能超过256")
private String orderMemo;
/**
* 支付金额单位
*/
@NotNull(message = "金额不能为空")
@DecimalMin(value = "0", inclusive = false, message = "金额必须大于零")
private Integer price;
/**
* 交易过期时间
*/
@NotNull(message = "交易过期时间不能为空")
private Date expireTime;
public String getAppId() {
return appId;
}
public PayTransactionCreateDTO setAppId(String appId) {
this.appId = appId;
return this;
}
public String getCreateIp() {
return createIp;
}
public PayTransactionCreateDTO setCreateIp(String createIp) {
this.createIp = createIp;
return this;
}
public String getOrderId() {
return orderId;
}
public PayTransactionCreateDTO setOrderId(String orderId) {
this.orderId = orderId;
return this;
}
public String getOrderSubject() {
return orderSubject;
}
public PayTransactionCreateDTO setOrderSubject(String orderSubject) {
this.orderSubject = orderSubject;
return this;
}
public String getOrderDescription() {
return orderDescription;
}
public PayTransactionCreateDTO setOrderDescription(String orderDescription) {
this.orderDescription = orderDescription;
return this;
}
public String getOrderMemo() {
return orderMemo;
}
public PayTransactionCreateDTO setOrderMemo(String orderMemo) {
this.orderMemo = orderMemo;
return this;
}
public Integer getPrice() {
return price;
}
public PayTransactionCreateDTO setPrice(Integer price) {
this.price = price;
return this;
}
public Date getExpireTime() {
return expireTime;
}
public PayTransactionCreateDTO setExpireTime(Date expireTime) {
this.expireTime = expireTime;
return this;
}
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -3,7 +3,7 @@ package cn.iocoder.mall.pay.dataobject;
import cn.iocoder.common.framework.dataobject.BaseDO; import cn.iocoder.common.framework.dataobject.BaseDO;
/** /**
* TODO 支付应用业务线DO * 支付应用业务线DO
*/ */
public class PayAppDO extends BaseDO { public class PayAppDO extends BaseDO {
@ -11,5 +11,53 @@ public class PayAppDO extends BaseDO {
* 应用编号 * 应用编号
*/ */
private String id; 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;
}
} }

View File

@ -1,7 +0,0 @@
package cn.iocoder.mall.pay.dataobject;
/**
*
*/
public class PayNotifyAppLogDO {
}

View File

@ -2,6 +2,8 @@ package cn.iocoder.mall.pay.dataobject;
/** /**
* TODO 重复支付的交易 * TODO 重复支付的交易
*
* 可能不靠这个表而是差错处理
*/ */
public class PayRepeatTransactionDO { public class PayRepeatTransactionDO {
} }

View File

@ -33,15 +33,6 @@ public class PayTransactionDO extends BaseDO {
* 2. 每个 appId orderId 唯一 * 2. 每个 appId orderId 唯一
*/ */
private String orderId; private String orderId;
/**
* 订单状态
*
* 0 等待支付
* 1 待付款完成
* 2 该笔交易已关闭 TODO 交易关闭是不是订单系统触发
* -1 支付失败 TODO 怎么触发
*/
private Integer orderStatus;
/** /**
* 订单商品名 * 订单商品名
*/ */
@ -60,16 +51,38 @@ public class PayTransactionDO extends BaseDO {
* TODO 暂时不考虑货币类型 * TODO 暂时不考虑货币类型
*/ */
private Integer price; 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 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; private Integer payChannel;
/** /**
@ -123,12 +136,12 @@ public class PayTransactionDO extends BaseDO {
return this; return this;
} }
public Integer getOrderStatus() { public Integer getStatus() {
return orderStatus; return status;
} }
public PayTransactionDO setOrderStatus(Integer orderStatus) { public PayTransactionDO setStatus(Integer status) {
this.orderStatus = orderStatus; this.status = status;
return this; return this;
} }
@ -150,15 +163,6 @@ public class PayTransactionDO extends BaseDO {
return this; return this;
} }
public Integer getExpireTime() {
return expireTime;
}
public PayTransactionDO setExpireTime(Integer expireTime) {
this.expireTime = expireTime;
return this;
}
public Date getPaymentTime() { public Date getPaymentTime() {
return paymentTime; return paymentTime;
} }
@ -212,4 +216,40 @@ public class PayTransactionDO extends BaseDO {
this.orderMemo = orderMemo; this.orderMemo = orderMemo;
return this; 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;
}
} }

View File

@ -21,14 +21,10 @@ public class PayTransactionExtensionDO extends BaseDO {
private Integer payChannel; private Integer payChannel;
/** /**
* 生成传输给第三方的订单号 * 生成传输给第三方的订单号
*
* 唯一索引
*/ */
private String transactionCode; private String transactionCode;
/**
* 发起调用的次数
*
* TODO 芋艿需要去请教下
*/
private Integer callNum;
/** /**
* 扩展内容 * 扩展内容
* *
@ -39,6 +35,13 @@ public class PayTransactionExtensionDO extends BaseDO {
* 发起交易的 IP * 发起交易的 IP
*/ */
private String createIp; private String createIp;
/**
* 状态
*
* @see cn.iocoder.mall.pay.api.constant.PayTransactionStatusEnum
* 注意只包含上述枚举的 WAITTING SUCCESS
*/
private Integer status;
public Integer getId() { public Integer getId() {
return id; return id;
@ -76,15 +79,6 @@ public class PayTransactionExtensionDO extends BaseDO {
return this; return this;
} }
public Integer getCallNum() {
return callNum;
}
public PayTransactionExtensionDO setCallNum(Integer callNum) {
this.callNum = callNum;
return this;
}
public String getExtensionData() { public String getExtensionData() {
return extensionData; return extensionData;
} }
@ -103,4 +97,13 @@ public class PayTransactionExtensionDO extends BaseDO {
return this; return this;
} }
public Integer getStatus() {
return status;
}
public PayTransactionExtensionDO setStatus(Integer status) {
this.status = status;
return this;
}
} }

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

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

View File

@ -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);
}
}

View File

@ -1,9 +1,44 @@
package cn.iocoder.mall.pay.service; 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; import org.springframework.stereotype.Service;
@Service @Service
@com.alibaba.dubbo.config.annotation.Service(validation = "true") @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;
}
} }

View File

@ -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>

View File

@ -1,3 +0,0 @@
#!/usr/bin/env bash
sh build_admin.sh
scp admin/admin-application/target/admin-application-1.0-SNAPSHOT.jar runner@192.168.88.10:/work2/project/admin