forked from YunaiV/yudao-cloud
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
mijiu
committed
Jul 25, 2020
1 parent
6465e5e
commit 4199687
Showing
13 changed files
with
734 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
...oject/pay-service-app/src/main/java/cn/iocoder/mall/payservice/PayServiceApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package cn.iocoder.mall.payservice; | ||
|
||
public class PayServiceApplication { | ||
} |
31 changes: 31 additions & 0 deletions
31
...-app/src/main/java/cn/iocoder/mall/payservice/convert/transaction/TransactionConvert.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |
101 changes: 101 additions & 0 deletions
101
.../main/java/cn/iocoder/mall/payservice/dal/mysql/dataobject/transaction/TransactionDO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
|
||
} |
19 changes: 19 additions & 0 deletions
19
.../main/java/cn/iocoder/mall/payservice/dal/mysql/mapper/transaction/TransactionMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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>()); | ||
} | ||
|
||
} |
4 changes: 4 additions & 0 deletions
4
...-app/src/main/java/cn/iocoder/mall/payservice/manager/transaction/TransactionManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package cn.iocoder.mall.payservice.manager.transaction; | ||
|
||
public class TransactionManager { | ||
} |
4 changes: 4 additions & 0 deletions
4
...vice-app/src/main/java/cn/iocoder/mall/payservice/rpc/transaction/TransactionRpcImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package cn.iocoder.mall.payservice.rpc.transaction; | ||
|
||
public class TransactionRpcImpl { | ||
} |
107 changes: 107 additions & 0 deletions
107
...-app/src/main/java/cn/iocoder/mall/payservice/service/transaction/TransactionService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
|
||
} |
Oops, something went wrong.