1. 迁移交易订单的查询接口
2. 支付服务,重新初始化结构
This commit is contained in:
@@ -12,14 +12,24 @@
|
||||
<artifactId>pay-service-api</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.mall</groupId>
|
||||
<artifactId>common-framework</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 工具类相关 -->
|
||||
<dependency>
|
||||
<groupId>javax.validation</groupId>
|
||||
<artifactId>validation-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-validator</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
</project>
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
package cn.iocoder.mall.payservice.enums;
|
||||
|
||||
import cn.iocoder.common.framework.core.IntArrayValuable;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 支付通道
|
||||
*/
|
||||
public enum PayChannelEnum implements IntArrayValuable {
|
||||
|
||||
WEIXIN_APP(100, "wx", "微信 App 支付"),
|
||||
WEIXIN_PUB(101, "wxjs", "微信 JS API 支付"),
|
||||
|
||||
ALIPAY(200, "alipay", "支付宝 App 支付"),
|
||||
|
||||
PINGXX(9999, "ping++", "ping++ 支付"),
|
||||
;
|
||||
|
||||
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(PayChannelEnum::getId).toArray();
|
||||
|
||||
/**
|
||||
* 渠道编号
|
||||
*/
|
||||
private Integer id;
|
||||
/**
|
||||
* 编码
|
||||
*/
|
||||
private String code;
|
||||
/**
|
||||
* 渠道名
|
||||
*/
|
||||
private String name;
|
||||
|
||||
PayChannelEnum(Integer id, String code, String name) {
|
||||
this.id = id;
|
||||
this.code = code;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] array() {
|
||||
return ARRAYS;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package cn.iocoder.mall.payservice.rpc.app;
|
||||
|
||||
/**
|
||||
* 支付应用 RPC 接口
|
||||
*/
|
||||
public interface PayAppRpc {
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package cn.iocoder.mall.payservice.rpc.app.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 支付应用 Response DTO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class PayAppRespDTO implements Serializable {
|
||||
|
||||
/**
|
||||
* 应用编号
|
||||
*/
|
||||
private String id;
|
||||
/**
|
||||
* 应用名
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 异步通知地址
|
||||
*/
|
||||
private String payNotifyUrl;
|
||||
/**
|
||||
* 退款异步通知地址
|
||||
*/
|
||||
private String refundNotifyUrl;
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
package cn.iocoder.mall.payservice.rpc;
|
||||
@@ -0,0 +1,10 @@
|
||||
package cn.iocoder.mall.payservice.rpc.transaction;
|
||||
|
||||
/**
|
||||
* 支付交易单 RPC 接口
|
||||
*/
|
||||
public interface PayTransactionRpc {
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package cn.iocoder.mall.payservice.rpc.transaction.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import javax.validation.constraints.DecimalMin;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 支付交易单创建 DTO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class PayTransactionCreateReqDTO implements Serializable {
|
||||
|
||||
/**
|
||||
* 应用编号
|
||||
*/
|
||||
@NotEmpty(message = "应用编号不能为空")
|
||||
private String appId;
|
||||
/**
|
||||
* 发起交易的 IP
|
||||
*/
|
||||
@NotEmpty(message = "IP 不能为空")
|
||||
private String createIp;
|
||||
|
||||
/**
|
||||
* 订单号
|
||||
*/
|
||||
@NotEmpty(message = "订单号不能为空")
|
||||
private String orderId;
|
||||
/**
|
||||
* 商品名
|
||||
*/
|
||||
@NotEmpty(message = "商品名不能为空")
|
||||
@Length(max = 32, message = "商品名不能超过32")
|
||||
private String orderSubject;
|
||||
/**
|
||||
* 订单商品描述
|
||||
*/
|
||||
@NotEmpty(message = "商品描述不能为空")
|
||||
@Length(max = 128, message = "商品描述长度不能超过128")
|
||||
private String orderDescription;
|
||||
/**
|
||||
* 订单商品备注
|
||||
*/
|
||||
@Length(max = 256, message = "商品备注长度不能超过256")
|
||||
private String orderMemo;
|
||||
/**
|
||||
* 支付金额,单位:分
|
||||
*/
|
||||
@NotNull(message = "金额不能为空")
|
||||
@DecimalMin(value = "0", inclusive = false, message = "金额必须大于零")
|
||||
private Integer price;
|
||||
|
||||
/**
|
||||
* 交易过期时间
|
||||
*/
|
||||
@NotNull(message = "交易过期时间不能为空")
|
||||
private Date expireTime;
|
||||
|
||||
}
|
||||
@@ -11,13 +11,26 @@
|
||||
|
||||
<artifactId>pay-service-app</artifactId>
|
||||
|
||||
|
||||
<dependencies>
|
||||
<!-- RPC 相关 -->
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.mall</groupId>
|
||||
<artifactId>mall-spring-boot-starter-dubbo</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<!-- 支付服务 -->
|
||||
<groupId>cn.iocoder.mall</groupId>
|
||||
<artifactId>product-service-api</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Web 相关 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId> <!-- 需要开启 Web 容器,因为 Actuator 需要使用到 -->
|
||||
</dependency>
|
||||
|
||||
<!-- Registry 和 Config 相关 -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
@@ -30,14 +43,6 @@
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-tx</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-jdbc</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid-spring-boot-starter</artifactId>
|
||||
@@ -48,6 +53,19 @@
|
||||
<artifactId>mall-spring-boot-starter-mybatis</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 监控相关 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Test 相关 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- 工具类相关 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
@@ -68,5 +86,23 @@
|
||||
<artifactId>mapstruct-jdk8</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.aspectj</groupId>
|
||||
<artifactId>aspectjweaver</artifactId>
|
||||
<version>1.9.6</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
||||
<build>
|
||||
<!-- 设置构建的 jar 包名 -->
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<!-- 使用 spring-boot-maven-plugin 插件打包 -->
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
|
||||
@@ -1,4 +1,13 @@
|
||||
package cn.iocoder.mall.payservice;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class PayServiceApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(PayServiceApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package cn.iocoder.mall.payservice.config;
|
||||
|
||||
import com.baomidou.mybatisplus.core.injector.DefaultSqlInjector;
|
||||
import com.baomidou.mybatisplus.core.injector.ISqlInjector;
|
||||
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
@Configuration
|
||||
@MapperScan("cn.iocoder.mall.payservice.dal.mysql.mapper") // 扫描对应的 Mapper 接口
|
||||
@EnableTransactionManagement(proxyTargetClass = true) // 启动事务管理。
|
||||
public class DatabaseConfiguration {
|
||||
|
||||
// 数据库连接池 Druid
|
||||
|
||||
@Bean
|
||||
public ISqlInjector sqlInjector() {
|
||||
return new DefaultSqlInjector(); // MyBatis Plus 逻辑删除
|
||||
}
|
||||
|
||||
@Bean
|
||||
public PaginationInterceptor paginationInterceptor() {
|
||||
return new PaginationInterceptor(); // MyBatis Plus 分页插件
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,31 +1,12 @@
|
||||
package cn.iocoder.mall.payservice.convert.transaction;
|
||||
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.payservice.dal.mysql.dataobject.transaction.TransactionDO;
|
||||
import cn.iocoder.mall.payservice.service.transaction.bo.TransactionBO;
|
||||
import cn.iocoder.mall.payservice.service.transaction.bo.TransactionCreateBO;
|
||||
import cn.iocoder.mall.payservice.service.transaction.bo.TransactionUpdateBO;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mappings;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface TransactionConvert {
|
||||
|
||||
TransactionConvert INSTANCE = Mappers.getMapper(TransactionConvert.class);
|
||||
|
||||
|
||||
|
||||
TransactionDO convert(TransactionUpdateBO updateBO);
|
||||
|
||||
List<TransactionBO> convertList(List<TransactionDO> transactionDOs);
|
||||
|
||||
PageResult<TransactionBO> convertPage(IPage<TransactionDO> transactionDOPage);
|
||||
|
||||
TransactionDO convert(TransactionCreateBO createBO);
|
||||
|
||||
TransactionBO convert(TransactionDO transactionDO);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package cn.iocoder.mall.payservice.dal.mysql.dataobject.app;
|
||||
|
||||
import cn.iocoder.mall.mybatis.core.dataobject.DeletableDO;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 支付应用
|
||||
*
|
||||
* 每个接入的业务都是一个应用,进行个性化的配置
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Accessors(chain = true)
|
||||
public class PayAppDO extends DeletableDO {
|
||||
|
||||
/**
|
||||
* 应用编号
|
||||
*/
|
||||
private String id;
|
||||
/**
|
||||
* 应用名
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 异步通知地址
|
||||
*/
|
||||
private String payNotifyUrl;
|
||||
/**
|
||||
* 退款异步通知地址
|
||||
*/
|
||||
private String refundNotifyUrl;
|
||||
/**
|
||||
* 状态
|
||||
*
|
||||
* 枚举 {@link cn.iocoder.common.framework.enums.CommonStatusEnum}
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
}
|
||||
@@ -1,20 +1,22 @@
|
||||
package cn.iocoder.mall.payservice.dal.mysql.dataobject.transaction;
|
||||
|
||||
import cn.iocoder.mall.mybatis.core.dataobject.BaseDO;
|
||||
import cn.iocoder.mall.mybatis.core.dataobject.DeletableDO;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.*;
|
||||
import lombok.experimental.*;
|
||||
import java.util.*;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* pay_transaction
|
||||
* 支付交易表
|
||||
*/
|
||||
@TableName("transaction")
|
||||
@TableName("pay_transaction")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Accessors(chain = true)
|
||||
public class TransactionDO extends DeletableDO {
|
||||
public class PayTransactionDO extends DeletableDO {
|
||||
|
||||
/**
|
||||
* 编号,自增
|
||||
@@ -0,0 +1,15 @@
|
||||
package cn.iocoder.mall.payservice.dal.mysql.mapper.transaction;
|
||||
|
||||
import cn.iocoder.mall.payservice.dal.mysql.dataobject.transaction.PayTransactionDO;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface PayTransactionMapper extends BaseMapper<PayTransactionDO> {
|
||||
|
||||
// default IPage<PayTransactionDO> selectPage(TransactionPageBO pageBO) {
|
||||
// return selectPage(new Page<>(pageBO.getPageNo(), pageBO.getPageSize()),
|
||||
// new QueryWrapperX<PayTransactionDO>());
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package cn.iocoder.mall.payservice.dal.mysql.mapper.transaction;
|
||||
|
||||
import cn.iocoder.mall.mybatis.core.query.QueryWrapperX;
|
||||
import cn.iocoder.mall.payservice.dal.mysql.dataobject.transaction.TransactionDO;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface TransactionMapper extends BaseMapper<TransactionDO> {
|
||||
|
||||
default IPage<TransactionDO> selectPage(TransactionPageBO pageBO) {
|
||||
return selectPage(new Page<>(pageBO.getPageNo(), pageBO.getPageSize()),
|
||||
new QueryWrapperX<TransactionDO>());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
package cn.iocoder.mall.payservice.manager.transaction;
|
||||
|
||||
public class TransactionManager {
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.iocoder.mall.payservice.rpc.transaction;
|
||||
|
||||
public class TransactionRpcImpl {
|
||||
public class PayTransactionRpcImpl {
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package cn.iocoder.mall.payservice.service.app;
|
||||
|
||||
/**
|
||||
* 支付应用 Service 接口
|
||||
*/
|
||||
public interface PayAppService {
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package cn.iocoder.mall.payservice.service.app.impl;
|
||||
|
||||
import cn.iocoder.mall.payservice.service.app.PayAppService;
|
||||
|
||||
/**
|
||||
* 支付应用 Service 实现类
|
||||
*/
|
||||
public class PayAppServiceImpl implements PayAppService {
|
||||
|
||||
|
||||
|
||||
// public PayAppDO validPayApp(String appId) {
|
||||
// PayAppDO payAppDO = payAppMapper.selectById(appId);
|
||||
// // 校验是否存在
|
||||
// if (payAppDO == null) {
|
||||
// throw ServiceExceptionUtil.exception(PayErrorCodeEnum.PAY_APP_NOT_FOUND.getCode());
|
||||
// }
|
||||
// // 校验是否禁用
|
||||
// if (CommonStatusEnum.DISABLE.getValue().equals(payAppDO.getStatus())) {
|
||||
// throw ServiceExceptionUtil.exception(PayErrorCodeEnum.PAY_APP_IS_DISABLE.getCode());
|
||||
// }
|
||||
// return payAppDO;
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package cn.iocoder.mall.payservice.service.transaction;
|
||||
|
||||
/**
|
||||
* 支付交易单 Service 接口
|
||||
*/
|
||||
public interface PayTransactionService {
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,107 +0,0 @@
|
||||
package cn.iocoder.mall.payservice.service.transaction;
|
||||
|
||||
import cn.iocoder.common.framework.exception.util.ServiceExceptionUtil;
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.payservice.convert.transaction.TransactionConvert;
|
||||
import cn.iocoder.mall.payservice.dal.mysql.dataobject.transaction.TransactionDO;
|
||||
import cn.iocoder.mall.payservice.dal.mysql.mapper.transaction.TransactionMapper;
|
||||
import cn.iocoder.mall.payservice.service.transaction.bo.TransactionBO;
|
||||
import cn.iocoder.mall.payservice.service.transaction.bo.TransactionCreateBO;
|
||||
import cn.iocoder.mall.payservice.service.transaction.bo.TransactionPageBO;
|
||||
import cn.iocoder.mall.payservice.service.transaction.bo.TransactionUpdateBO;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.validation.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* pay_transaction Service
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class TransactionService {
|
||||
|
||||
@Autowired
|
||||
private TransactionMapper transactionMapper;
|
||||
|
||||
/**
|
||||
* 创建pay_transaction
|
||||
*
|
||||
* @param createBO 创建pay_transaction BO
|
||||
* @return pay_transaction
|
||||
*/
|
||||
public TransactionBO createTransaction(@Valid TransactionCreateBO createBO) {
|
||||
// 插入到数据库
|
||||
TransactionDO transactionDO = TransactionConvert.INSTANCE.convert(createBO);
|
||||
transactionMapper.insert(transactionDO);
|
||||
// 返回
|
||||
return TransactionConvert.INSTANCE.convert(transactionDO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新pay_transaction
|
||||
*
|
||||
* @param updateBO 更新pay_transaction BO
|
||||
*/
|
||||
public void updateTransaction(@Valid TransactionUpdateBO updateBO) {
|
||||
// 校验更新的pay_transaction是否存在
|
||||
if (transactionMapper.selectById(updateBO.getId()) == null) {
|
||||
throw ServiceExceptionUtil.exception(AuthErrorCodeConstants.TRANSACTION_NOT_FOUND);
|
||||
}
|
||||
// 更新到数据库
|
||||
TransactionDO updateObject = TransactionConvert.INSTANCE.convert(updateBO);
|
||||
transactionMapper.updateById(updateObject);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除pay_transaction
|
||||
*
|
||||
* @param transactionId pay_transaction编号
|
||||
*/
|
||||
public void deleteTransaction(Integer transactionId) {
|
||||
// 校验删除的pay_transaction是否存在
|
||||
if (transactionMapper.selectById(transactionId) == null) {
|
||||
throw ServiceExceptionHelper.exception(AuthErrorCodeConstants.TRANSACTION_NOT_FOUND);
|
||||
}
|
||||
// 标记删除
|
||||
transactionMapper.deleteById(transactionId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得pay_transaction
|
||||
*
|
||||
* @param transactionId pay_transaction编号
|
||||
* @return pay_transaction
|
||||
*/
|
||||
public TransactionBO getTransaction(Integer transactionId) {
|
||||
TransactionDO transactionDO = transactionMapper.selectById(transactionId);
|
||||
return TransactionConvert.INSTANCE.convert(transactionDO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得pay_transaction列表
|
||||
*
|
||||
* @param transactionIds pay_transaction编号列表
|
||||
* @return pay_transaction列表
|
||||
*/
|
||||
public List<TransactionBO> listTransactions(List<Integer> transactionIds) {
|
||||
List<TransactionDO> transactionDOs = transactionMapper.selectBatchIds(transactionIds);
|
||||
return TransactionConvert.INSTANCE.convertList(transactionDOs);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得pay_transaction分页
|
||||
*
|
||||
* @param pageBO pay_transaction分页查询
|
||||
* @return pay_transaction分页结果
|
||||
*/
|
||||
public PageResult<TransactionBO> pageTransaction(TransactionPageBO pageBO) {
|
||||
IPage<TransactionDO> transactionDOPage = transactionMapper.selectPage(pageBO);
|
||||
return TransactionConvert.INSTANCE.convertPage(transactionDOPage);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
package cn.iocoder.mall.payservice.service.transaction.bo;
|
||||
|
||||
import lombok.*;
|
||||
import lombok.experimental.*;
|
||||
import io.swagger.annotations.*;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* pay_transaction BO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class TransactionBO {
|
||||
|
||||
/**
|
||||
* 编号,自增
|
||||
*/
|
||||
private Integer id;
|
||||
/**
|
||||
* 应用编号
|
||||
*/
|
||||
private String appId;
|
||||
/**
|
||||
* 发起交易的 IP
|
||||
*/
|
||||
private String createIp;
|
||||
/**
|
||||
* 业务线的订单编号
|
||||
*/
|
||||
private String orderId;
|
||||
/**
|
||||
* 订单商品名
|
||||
*/
|
||||
private String orderSubject;
|
||||
/**
|
||||
* 订单商品描述
|
||||
*/
|
||||
private String orderDescription;
|
||||
/**
|
||||
* 订单备注
|
||||
*/
|
||||
private String orderMemo;
|
||||
/**
|
||||
* 支付金额,单位:分。
|
||||
*/
|
||||
private Integer price;
|
||||
/**
|
||||
* 订单状态
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 交易过期时间
|
||||
*/
|
||||
private Date expireTime;
|
||||
/**
|
||||
* 回调业务线完成时间
|
||||
*/
|
||||
private Date finishTime;
|
||||
/**
|
||||
* 异步通知地址
|
||||
*/
|
||||
private String notifyUrl;
|
||||
/**
|
||||
* 成功支付的交易拓展编号
|
||||
*/
|
||||
private Integer extensionId;
|
||||
/**
|
||||
* 支付成功的支付渠道
|
||||
*/
|
||||
private Integer payChannel;
|
||||
/**
|
||||
* 第三方支付成功的时间
|
||||
*/
|
||||
private Date paymentTime;
|
||||
/**
|
||||
* 收到第三方系统通知的时间
|
||||
*/
|
||||
private Date notifyTime;
|
||||
/**
|
||||
* 第三方的流水号
|
||||
*/
|
||||
private String tradeNo;
|
||||
/**
|
||||
* 退款总金额
|
||||
*/
|
||||
private Integer refundTotal;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
/**
|
||||
* 最后更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
package cn.iocoder.mall.payservice.service.transaction.bo;
|
||||
|
||||
import lombok.*;
|
||||
import lombok.experimental.*;
|
||||
import io.swagger.annotations.*;
|
||||
import java.util.*;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
/**
|
||||
* pay_transaction创建 BO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class TransactionCreateBO {
|
||||
|
||||
/**
|
||||
* 应用编号
|
||||
*/
|
||||
@NotEmpty(message = "应用编号不能为空")
|
||||
private String appId;
|
||||
/**
|
||||
* 发起交易的 IP
|
||||
*/
|
||||
@NotEmpty(message = "发起交易的 IP不能为空")
|
||||
private String createIp;
|
||||
/**
|
||||
* 业务线的订单编号
|
||||
*/
|
||||
@NotEmpty(message = "业务线的订单编号不能为空")
|
||||
private String orderId;
|
||||
/**
|
||||
* 订单商品名
|
||||
*/
|
||||
@NotEmpty(message = "订单商品名不能为空")
|
||||
private String orderSubject;
|
||||
/**
|
||||
* 订单商品描述
|
||||
*/
|
||||
@NotEmpty(message = "订单商品描述不能为空")
|
||||
private String orderDescription;
|
||||
/**
|
||||
* 订单备注
|
||||
*/
|
||||
private String orderMemo;
|
||||
/**
|
||||
* 支付金额,单位:分。
|
||||
*/
|
||||
@NotNull(message = "支付金额,单位:分。不能为空")
|
||||
private Integer price;
|
||||
/**
|
||||
* 订单状态
|
||||
*/
|
||||
@NotNull(message = "订单状态不能为空")
|
||||
private Integer status;
|
||||
/**
|
||||
* 交易过期时间
|
||||
*/
|
||||
private Date expireTime;
|
||||
/**
|
||||
* 回调业务线完成时间
|
||||
*/
|
||||
private Date finishTime;
|
||||
/**
|
||||
* 异步通知地址
|
||||
*/
|
||||
@NotEmpty(message = "异步通知地址不能为空")
|
||||
private String notifyUrl;
|
||||
/**
|
||||
* 成功支付的交易拓展编号
|
||||
*/
|
||||
private Integer extensionId;
|
||||
/**
|
||||
* 支付成功的支付渠道
|
||||
*/
|
||||
private Integer payChannel;
|
||||
/**
|
||||
* 第三方支付成功的时间
|
||||
*/
|
||||
private Date paymentTime;
|
||||
/**
|
||||
* 收到第三方系统通知的时间
|
||||
*/
|
||||
private Date notifyTime;
|
||||
/**
|
||||
* 第三方的流水号
|
||||
*/
|
||||
private String tradeNo;
|
||||
/**
|
||||
* 退款总金额
|
||||
*/
|
||||
private Integer refundTotal;
|
||||
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
package cn.iocoder.mall.payservice.service.transaction.bo;
|
||||
|
||||
import cn.iocoder.common.framework.vo.PageParam;
|
||||
import lombok.*;
|
||||
import lombok.experimental.*;
|
||||
import io.swagger.annotations.*;
|
||||
import java.util.*;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
/**
|
||||
* pay_transaction分页 BO
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Accessors(chain = true)
|
||||
public class TransactionPageBO extends PageParam {
|
||||
|
||||
/**
|
||||
* 编号,自增
|
||||
*/
|
||||
private Integer id;
|
||||
/**
|
||||
* 应用编号
|
||||
*/
|
||||
private String appId;
|
||||
/**
|
||||
* 发起交易的 IP
|
||||
*/
|
||||
private String createIp;
|
||||
/**
|
||||
* 业务线的订单编号
|
||||
*/
|
||||
private String orderId;
|
||||
/**
|
||||
* 订单商品名
|
||||
*/
|
||||
private String orderSubject;
|
||||
/**
|
||||
* 订单商品描述
|
||||
*/
|
||||
private String orderDescription;
|
||||
/**
|
||||
* 订单备注
|
||||
*/
|
||||
private String orderMemo;
|
||||
/**
|
||||
* 支付金额,单位:分。
|
||||
*/
|
||||
private Integer price;
|
||||
/**
|
||||
* 订单状态
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 交易过期时间
|
||||
*/
|
||||
private Date expireTime;
|
||||
/**
|
||||
* 回调业务线完成时间
|
||||
*/
|
||||
private Date finishTime;
|
||||
/**
|
||||
* 异步通知地址
|
||||
*/
|
||||
private String notifyUrl;
|
||||
/**
|
||||
* 成功支付的交易拓展编号
|
||||
*/
|
||||
private Integer extensionId;
|
||||
/**
|
||||
* 支付成功的支付渠道
|
||||
*/
|
||||
private Integer payChannel;
|
||||
/**
|
||||
* 第三方支付成功的时间
|
||||
*/
|
||||
private Date paymentTime;
|
||||
/**
|
||||
* 收到第三方系统通知的时间
|
||||
*/
|
||||
private Date notifyTime;
|
||||
/**
|
||||
* 第三方的流水号
|
||||
*/
|
||||
private String tradeNo;
|
||||
/**
|
||||
* 退款总金额
|
||||
*/
|
||||
private Integer refundTotal;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
/**
|
||||
* 最后更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
}
|
||||
@@ -1,98 +0,0 @@
|
||||
package cn.iocoder.mall.payservice.service.transaction.bo;
|
||||
|
||||
import lombok.*;
|
||||
import lombok.experimental.*;
|
||||
import io.swagger.annotations.*;
|
||||
import java.util.*;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
/**
|
||||
* pay_transaction更新 BO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class TransactionUpdateBO {
|
||||
|
||||
/**
|
||||
* 编号,自增
|
||||
*/
|
||||
@NotNull(message = "编号,自增不能为空")
|
||||
private Integer id;
|
||||
/**
|
||||
* 应用编号
|
||||
*/
|
||||
@NotEmpty(message = "应用编号不能为空")
|
||||
private String appId;
|
||||
/**
|
||||
* 发起交易的 IP
|
||||
*/
|
||||
@NotEmpty(message = "发起交易的 IP不能为空")
|
||||
private String createIp;
|
||||
/**
|
||||
* 业务线的订单编号
|
||||
*/
|
||||
@NotEmpty(message = "业务线的订单编号不能为空")
|
||||
private String orderId;
|
||||
/**
|
||||
* 订单商品名
|
||||
*/
|
||||
@NotEmpty(message = "订单商品名不能为空")
|
||||
private String orderSubject;
|
||||
/**
|
||||
* 订单商品描述
|
||||
*/
|
||||
@NotEmpty(message = "订单商品描述不能为空")
|
||||
private String orderDescription;
|
||||
/**
|
||||
* 订单备注
|
||||
*/
|
||||
private String orderMemo;
|
||||
/**
|
||||
* 支付金额,单位:分。
|
||||
*/
|
||||
@NotNull(message = "支付金额,单位:分。不能为空")
|
||||
private Integer price;
|
||||
/**
|
||||
* 订单状态
|
||||
*/
|
||||
@NotNull(message = "订单状态不能为空")
|
||||
private Integer status;
|
||||
/**
|
||||
* 交易过期时间
|
||||
*/
|
||||
private Date expireTime;
|
||||
/**
|
||||
* 回调业务线完成时间
|
||||
*/
|
||||
private Date finishTime;
|
||||
/**
|
||||
* 异步通知地址
|
||||
*/
|
||||
@NotEmpty(message = "异步通知地址不能为空")
|
||||
private String notifyUrl;
|
||||
/**
|
||||
* 成功支付的交易拓展编号
|
||||
*/
|
||||
private Integer extensionId;
|
||||
/**
|
||||
* 支付成功的支付渠道
|
||||
*/
|
||||
private Integer payChannel;
|
||||
/**
|
||||
* 第三方支付成功的时间
|
||||
*/
|
||||
private Date paymentTime;
|
||||
/**
|
||||
* 收到第三方系统通知的时间
|
||||
*/
|
||||
private Date notifyTime;
|
||||
/**
|
||||
* 第三方的流水号
|
||||
*/
|
||||
private String tradeNo;
|
||||
/**
|
||||
* 退款总金额
|
||||
*/
|
||||
private Integer refundTotal;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package cn.iocoder.mall.payservice.service.transaction.impl;
|
||||
|
||||
import cn.iocoder.mall.payservice.dal.mysql.mapper.transaction.PayTransactionMapper;
|
||||
import cn.iocoder.mall.payservice.service.transaction.PayTransactionService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
/**
|
||||
* 支付交易单 Service 实现类
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class PayTransactionServiceImpl implements PayTransactionService {
|
||||
|
||||
@Autowired
|
||||
private PayTransactionMapper transactionMapper;
|
||||
|
||||
|
||||
|
||||
// /**
|
||||
// * 创建pay_transaction
|
||||
// *
|
||||
// * @param createBO 创建pay_transaction BO
|
||||
// * @return pay_transaction
|
||||
// */
|
||||
// public TransactionBO createTransaction(@Valid TransactionCreateBO createBO) {
|
||||
// // 插入到数据库
|
||||
// PayTransactionDO transactionDO = TransactionConvert.INSTANCE.convert(createBO);
|
||||
// transactionMapper.insert(transactionDO);
|
||||
// // 返回
|
||||
// return TransactionConvert.INSTANCE.convert(transactionDO);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 更新pay_transaction
|
||||
// *
|
||||
// * @param updateBO 更新pay_transaction BO
|
||||
// */
|
||||
// public void updateTransaction(@Valid TransactionUpdateBO updateBO) {
|
||||
// // 校验更新的pay_transaction是否存在
|
||||
// if (transactionMapper.selectById(updateBO.getId()) == null) {
|
||||
// throw ServiceExceptionUtil.exception(AuthErrorCodeConstants.TRANSACTION_NOT_FOUND);
|
||||
// }
|
||||
// // 更新到数据库
|
||||
// PayTransactionDO updateObject = TransactionConvert.INSTANCE.convert(updateBO);
|
||||
// transactionMapper.updateById(updateObject);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 删除pay_transaction
|
||||
// *
|
||||
// * @param transactionId pay_transaction编号
|
||||
// */
|
||||
// public void deleteTransaction(Integer transactionId) {
|
||||
// // 校验删除的pay_transaction是否存在
|
||||
// if (transactionMapper.selectById(transactionId) == null) {
|
||||
// throw ServiceExceptionHelper.exception(AuthErrorCodeConstants.TRANSACTION_NOT_FOUND);
|
||||
// }
|
||||
// // 标记删除
|
||||
// transactionMapper.deleteById(transactionId);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 获得pay_transaction
|
||||
// *
|
||||
// * @param transactionId pay_transaction编号
|
||||
// * @return pay_transaction
|
||||
// */
|
||||
// public TransactionBO getTransaction(Integer transactionId) {
|
||||
// PayTransactionDO transactionDO = transactionMapper.selectById(transactionId);
|
||||
// return TransactionConvert.INSTANCE.convert(transactionDO);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 获得pay_transaction列表
|
||||
// *
|
||||
// * @param transactionIds pay_transaction编号列表
|
||||
// * @return pay_transaction列表
|
||||
// */
|
||||
// public List<TransactionBO> listTransactions(List<Integer> transactionIds) {
|
||||
// List<PayTransactionDO> transactionDOs = transactionMapper.selectBatchIds(transactionIds);
|
||||
// return TransactionConvert.INSTANCE.convertList(transactionDOs);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 获得pay_transaction分页
|
||||
// *
|
||||
// * @param pageBO pay_transaction分页查询
|
||||
// * @return pay_transaction分页结果
|
||||
// */
|
||||
// public PageResult<TransactionBO> pageTransaction(TransactionPageBO pageBO) {
|
||||
// IPage<PayTransactionDO> transactionDOPage = transactionMapper.selectPage(pageBO);
|
||||
// return TransactionConvert.INSTANCE.convertPage(transactionDOPage);
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
spring:
|
||||
# 数据源配置项
|
||||
datasource:
|
||||
url: jdbc:mysql://400-infra.server.iocoder.cn:3306/mall_pay?useSSL=false&useUnicode=true&characterEncoding=UTF-8
|
||||
driver-class-name: com.mysql.jdbc.Driver
|
||||
username: root
|
||||
password: 3WLiVUBEwTbvAfsh
|
||||
# Spring Cloud 配置项
|
||||
cloud:
|
||||
nacos:
|
||||
# Spring Cloud Nacos Discovery 配置项
|
||||
discovery:
|
||||
server-addr: 400-infra.server.iocoder.cn:8848 # Nacos 服务器地址
|
||||
namespace: dev # Nacos 命名空间
|
||||
|
||||
# Dubbo 配置项
|
||||
dubbo:
|
||||
# Dubbo 注册中心
|
||||
registry:
|
||||
# address: spring-cloud://400-infra.server.iocoder.cn:8848 # 指定 Dubbo 服务注册中心的地址
|
||||
address: nacos://400-infra.server.iocoder.cn:8848?namespace=dev # 指定 Dubbo 服务注册中心的地址
|
||||
@@ -0,0 +1,24 @@
|
||||
spring:
|
||||
# 数据源配置项
|
||||
datasource:
|
||||
url: jdbc:mysql://400-infra.server.iocoder.cn:3306/mall_pay?useSSL=false&useUnicode=true&characterEncoding=UTF-8
|
||||
driver-class-name: com.mysql.jdbc.Driver
|
||||
username: root
|
||||
password: 3WLiVUBEwTbvAfsh
|
||||
# Spring Cloud 配置项
|
||||
cloud:
|
||||
nacos:
|
||||
# Spring Cloud Nacos Discovery 配置项
|
||||
discovery:
|
||||
server-addr: 400-infra.server.iocoder.cn:8848 # Nacos 服务器地址
|
||||
namespace: dev # Nacos 命名空间
|
||||
|
||||
# Dubbo 配置项
|
||||
dubbo:
|
||||
# Dubbo 注册中心
|
||||
registry:
|
||||
# address: spring-cloud://400-infra.server.iocoder.cn:8848 # 指定 Dubbo 服务注册中心的地址
|
||||
address: nacos://400-infra.server.iocoder.cn:8848?namespace=dev # 指定 Dubbo 服务注册中心的地址
|
||||
# Dubbo 服务提供者的配置
|
||||
provider:
|
||||
tag: ${DUBBO_TAG} # Dubbo 路由分组
|
||||
@@ -0,0 +1,64 @@
|
||||
spring:
|
||||
# Application 的配置项
|
||||
application:
|
||||
name: pay-service
|
||||
# Profile 的配置项
|
||||
profiles:
|
||||
active: local
|
||||
|
||||
# MyBatis Plus 配置项
|
||||
mybatis-plus:
|
||||
configuration:
|
||||
map-underscore-to-camel-case: true # 虽然默认为 true ,但是还是显示去指定下。
|
||||
global-config:
|
||||
db-config:
|
||||
id-type: auto
|
||||
logic-delete-value: 1 # 逻辑已删除值(默认为 1)
|
||||
logic-not-delete-value: 0 # 逻辑未删除值(默认为 0)
|
||||
mapper-locations: classpath*:mapper/*.xml
|
||||
type-aliases-package: cn.iocoder.mall.payservice.dal.mysql.dataobject
|
||||
|
||||
# Dubbo 配置项
|
||||
dubbo:
|
||||
# Spring Cloud Alibaba Dubbo 专属配置
|
||||
cloud:
|
||||
subscribed-services: '' # 设置订阅的应用列表,默认为 * 订阅所有应用
|
||||
# Dubbo 提供者的协议
|
||||
protocol:
|
||||
name: dubbo
|
||||
port: -1
|
||||
# Dubbo 提供服务的扫描基础包
|
||||
scan:
|
||||
base-packages: cn.iocoder.mall.payservice.rpc
|
||||
# Dubbo 服务提供者的配置
|
||||
provider:
|
||||
filter: -exception
|
||||
validation: true # 开启 Provider 参数校验
|
||||
version: 1.0.0 # 服务的版本号
|
||||
# Dubbo 服务消费者的配置
|
||||
consumer:
|
||||
ErrorCodeRpc:
|
||||
version: 1.0.0
|
||||
ProductSkuRpc:
|
||||
version: 1.0.0
|
||||
ProductSpuRpc:
|
||||
version: 1.0.0
|
||||
|
||||
# RocketMQ 配置项
|
||||
rocketmq:
|
||||
name-server: 400-infra.server.iocoder.cn:9876
|
||||
producer:
|
||||
group: ${spring.application.name}-producer-group
|
||||
|
||||
# Actuator 监控配置项
|
||||
management:
|
||||
server.port: 38089 # 独立端口,避免被暴露出去
|
||||
endpoints.web.exposure.include: '*' # 暴露所有监控端点
|
||||
server.port: ${management.server.port} # 设置使用 Actuator 的服务器端口,因为 RPC 服务不需要 Web 端口
|
||||
|
||||
# Mall 配置项
|
||||
mall:
|
||||
# 错误码配置项对应 ErrorCodeProperties 配置类
|
||||
error-code:
|
||||
group: ${spring.application.name}
|
||||
constants-class: cn.iocoder.mall.payservice.enums.PayErrorCodeConstants
|
||||
@@ -35,7 +35,13 @@
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 自身项目 -->
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.mall</groupId>
|
||||
<artifactId>pay-service-api</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
</project>
|
||||
</project>
|
||||
|
||||
Reference in New Issue
Block a user