pull/3/MERGE
mijiu 2020-07-25 13:07:03 +08:00
parent 6465e5e30a
commit 41996876ca
13 changed files with 734 additions and 0 deletions

View File

@ -12,4 +12,61 @@
<artifactId>pay-service-app</artifactId>
<dependencies>
<!-- RPC 相关 -->
<dependency>
<groupId>cn.iocoder.mall</groupId>
<artifactId>mall-spring-boot-starter-dubbo</artifactId>
</dependency>
<!-- Registry 和 Config 相关 -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<!-- DB 相关 -->
<dependency>
<groupId>mysql</groupId>
<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>
</dependency>
<dependency>
<groupId>cn.iocoder.mall</groupId>
<artifactId>mall-spring-boot-starter-mybatis</artifactId>
</dependency>
<!-- 工具类相关 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId> <!-- use mapstruct-jdk8 for Java 8 or higher -->
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-jdk8</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,4 @@
package cn.iocoder.mall.payservice;
public class PayServiceApplication {
}

View File

@ -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<TransactionBO> convertList(List<TransactionDO> transactionDOs);
PageResult<TransactionBO> convertPage(IPage<TransactionDO> transactionDOPage);
TransactionDO convert(TransactionCreateBO createBO);
TransactionBO convert(TransactionDO transactionDO);
}

View File

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

View File

@ -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<TransactionDO> {
default IPage<TransactionDO> selectPage(TransactionPageBO pageBO) {
return selectPage(new Page<>(pageBO.getPageNo(), pageBO.getPageSize()),
new QueryWrapperX<TransactionDO>());
}
}

View File

@ -0,0 +1,4 @@
package cn.iocoder.mall.payservice.manager.transaction;
public class TransactionManager {
}

View File

@ -0,0 +1,4 @@
package cn.iocoder.mall.payservice.rpc.transaction;
public class TransactionRpcImpl {
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -17,4 +17,25 @@
<module>pay-service-app</module>
</modules>
<dependencyManagement>
<dependencies>
<!-- onemall 基础 bom 文件 -->
<dependency>
<groupId>cn.iocoder.mall</groupId>
<artifactId>mall-dependencies</artifactId>
<version>1.0-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>cn.iocoder.mall</groupId>
<artifactId>common-framework</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>