diff --git a/pay-service-project/pay-service-app/pom.xml b/pay-service-project/pay-service-app/pom.xml index d8f64e4ba..76f058bfe 100644 --- a/pay-service-project/pay-service-app/pom.xml +++ b/pay-service-project/pay-service-app/pom.xml @@ -12,4 +12,61 @@ pay-service-app + + + + cn.iocoder.mall + mall-spring-boot-starter-dubbo + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + + + mysql + mysql-connector-java + + + + org.springframework + spring-tx + + + org.springframework + spring-jdbc + + + com.alibaba + druid-spring-boot-starter + + + + cn.iocoder.mall + mall-spring-boot-starter-mybatis + + + + + org.springframework.boot + spring-boot-starter-validation + + + + org.projectlombok + lombok + + + + org.mapstruct + mapstruct + + + org.mapstruct + mapstruct-jdk8 + + + \ No newline at end of file diff --git a/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/PayServiceApplication.java b/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/PayServiceApplication.java new file mode 100644 index 000000000..50cbfb19d --- /dev/null +++ b/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/PayServiceApplication.java @@ -0,0 +1,4 @@ +package cn.iocoder.mall.payservice; + +public class PayServiceApplication { +} diff --git a/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/convert/transaction/TransactionConvert.java b/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/convert/transaction/TransactionConvert.java new file mode 100644 index 000000000..c81576510 --- /dev/null +++ b/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/convert/transaction/TransactionConvert.java @@ -0,0 +1,31 @@ +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 convertList(List transactionDOs); + + PageResult convertPage(IPage transactionDOPage); + + TransactionDO convert(TransactionCreateBO createBO); + + TransactionBO convert(TransactionDO transactionDO); +} diff --git a/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/dal/mysql/dataobject/transaction/TransactionDO.java b/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/dal/mysql/dataobject/transaction/TransactionDO.java new file mode 100644 index 000000000..38eff9930 --- /dev/null +++ b/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/dal/mysql/dataobject/transaction/TransactionDO.java @@ -0,0 +1,101 @@ +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.*; + +/** +* pay_transaction +*/ +@TableName("transaction") +@Data +@EqualsAndHashCode(callSuper = true) +@Accessors(chain = true) +public class TransactionDO extends DeletableDO { + + /** + * 编号,自增 + */ + @TableId + 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; + +} diff --git a/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/dal/mysql/mapper/transaction/TransactionMapper.java b/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/dal/mysql/mapper/transaction/TransactionMapper.java new file mode 100644 index 000000000..7e472d993 --- /dev/null +++ b/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/dal/mysql/mapper/transaction/TransactionMapper.java @@ -0,0 +1,19 @@ +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 { + + default IPage selectPage(TransactionPageBO pageBO) { + return selectPage(new Page<>(pageBO.getPageNo(), pageBO.getPageSize()), + new QueryWrapperX()); + } + +} \ No newline at end of file diff --git a/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/manager/transaction/TransactionManager.java b/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/manager/transaction/TransactionManager.java new file mode 100644 index 000000000..92ebaf9c1 --- /dev/null +++ b/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/manager/transaction/TransactionManager.java @@ -0,0 +1,4 @@ +package cn.iocoder.mall.payservice.manager.transaction; + +public class TransactionManager { +} diff --git a/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/rpc/transaction/TransactionRpcImpl.java b/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/rpc/transaction/TransactionRpcImpl.java new file mode 100644 index 000000000..604bd8f59 --- /dev/null +++ b/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/rpc/transaction/TransactionRpcImpl.java @@ -0,0 +1,4 @@ +package cn.iocoder.mall.payservice.rpc.transaction; + +public class TransactionRpcImpl { +} diff --git a/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/service/transaction/TransactionService.java b/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/service/transaction/TransactionService.java new file mode 100644 index 000000000..e92996dc0 --- /dev/null +++ b/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/service/transaction/TransactionService.java @@ -0,0 +1,107 @@ +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 listTransactions(List transactionIds) { + List transactionDOs = transactionMapper.selectBatchIds(transactionIds); + return TransactionConvert.INSTANCE.convertList(transactionDOs); + } + + /** + * 获得pay_transaction分页 + * + * @param pageBO pay_transaction分页查询 + * @return pay_transaction分页结果 + */ + public PageResult pageTransaction(TransactionPageBO pageBO) { + IPage transactionDOPage = transactionMapper.selectPage(pageBO); + return TransactionConvert.INSTANCE.convertPage(transactionDOPage); + } + +} \ No newline at end of file diff --git a/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/service/transaction/bo/TransactionBO.java b/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/service/transaction/bo/TransactionBO.java new file mode 100644 index 000000000..5ed79e167 --- /dev/null +++ b/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/service/transaction/bo/TransactionBO.java @@ -0,0 +1,96 @@ +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; + +} \ No newline at end of file diff --git a/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/service/transaction/bo/TransactionCreateBO.java b/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/service/transaction/bo/TransactionCreateBO.java new file mode 100644 index 000000000..0940fdea7 --- /dev/null +++ b/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/service/transaction/bo/TransactionCreateBO.java @@ -0,0 +1,93 @@ +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; + +} \ No newline at end of file diff --git a/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/service/transaction/bo/TransactionPageBO.java b/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/service/transaction/bo/TransactionPageBO.java new file mode 100644 index 000000000..c9f0c4bae --- /dev/null +++ b/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/service/transaction/bo/TransactionPageBO.java @@ -0,0 +1,99 @@ +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; + +} \ No newline at end of file diff --git a/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/service/transaction/bo/TransactionUpdateBO.java b/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/service/transaction/bo/TransactionUpdateBO.java new file mode 100644 index 000000000..b4fc5fb3d --- /dev/null +++ b/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/service/transaction/bo/TransactionUpdateBO.java @@ -0,0 +1,98 @@ +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; + +} \ No newline at end of file diff --git a/pay-service-project/pom.xml b/pay-service-project/pom.xml index 0d5a515c7..f0c35da4b 100644 --- a/pay-service-project/pom.xml +++ b/pay-service-project/pom.xml @@ -17,4 +17,25 @@ pay-service-app + + + + + + cn.iocoder.mall + mall-dependencies + 1.0-SNAPSHOT + pom + import + + + + cn.iocoder.mall + common-framework + 1.0-SNAPSHOT + + + + + \ No newline at end of file