diff --git a/daxpay-single/daxpay-single-service/src/main/java/org/dromara/daxpay/service/controller/allocation/AllocTransactionController.java b/daxpay-single/daxpay-single-service/src/main/java/org/dromara/daxpay/service/controller/allocation/AllocTransactionController.java new file mode 100644 index 000000000..41bba1691 --- /dev/null +++ b/daxpay-single/daxpay-single-service/src/main/java/org/dromara/daxpay/service/controller/allocation/AllocTransactionController.java @@ -0,0 +1,71 @@ +package org.dromara.daxpay.service.controller.allocation; + +import cn.bootx.platform.core.rest.Res; +import cn.bootx.platform.core.rest.param.PageParam; +import cn.bootx.platform.core.rest.result.PageResult; +import cn.bootx.platform.core.rest.result.Result; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.RequiredArgsConstructor; +import org.dromara.daxpay.core.param.allocation.transaction.AllocFinishParam; +import org.dromara.daxpay.core.result.allocation.transaction.AllocDetailResult; +import org.dromara.daxpay.core.result.allocation.transaction.AllocTransactionResult; +import org.dromara.daxpay.service.param.order.allocation.AllocOrderQuery; +import org.dromara.daxpay.service.service.allocation.AllocationService; +import org.dromara.daxpay.service.service.allocation.transaction.AllocQueryService; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +/** + * 分账订单控制器 + * @author xxm + * @since 2024/4/7 + */ +@Tag(name = "分账订单控制器") +@RestController +@RequestMapping("/allocation/transaction") +@RequiredArgsConstructor +public class AllocTransactionController { + + private final AllocQueryService queryService; + + private final AllocationService allocationService; + + @Operation(summary = "分页") + @GetMapping("/page") + public Result> page(PageParam pageParam, AllocOrderQuery param){ + return Res.ok(queryService.page(pageParam,param)); + } + + @Operation(summary = "分账明细列表") + @GetMapping("/detail/findAll") + public Result> findDetailsByOrderId(Long orderId){ + return Res.ok(queryService.findDetailsByOrderId(orderId)); + } + + @Operation(summary = "查询详情") + @GetMapping("/findById") + public Result findById(Long id){ + return Res.ok(queryService.findById(id)); + } + + @Operation(summary = "查询明细详情") + @GetMapping("/detail/findById") + public Result findDetailById(Long id){ + return Res.ok(queryService.findDetailById(id)); + } + + + @Operation(summary = "分账完结") + @PostMapping("/finish") + public Result finish(String allocNo){ + AllocFinishParam param = new AllocFinishParam(); + param.setAllocNo(allocNo); + allocationService.finish(param); + return Res.ok(); + } +} diff --git a/daxpay-single/daxpay-single-service/src/main/java/org/dromara/daxpay/service/dao/allocation/transaction/AllocTransactionManager.java b/daxpay-single/daxpay-single-service/src/main/java/org/dromara/daxpay/service/dao/allocation/transaction/AllocTransactionManager.java index 4a8f32258..a8e47974c 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/org/dromara/daxpay/service/dao/allocation/transaction/AllocTransactionManager.java +++ b/daxpay-single/daxpay-single-service/src/main/java/org/dromara/daxpay/service/dao/allocation/transaction/AllocTransactionManager.java @@ -1,10 +1,16 @@ package org.dromara.daxpay.service.dao.allocation.transaction; import cn.bootx.platform.common.mybatisplus.impl.BaseManager; +import cn.bootx.platform.common.mybatisplus.query.generator.QueryGenerator; +import cn.bootx.platform.common.mybatisplus.util.MpUtil; +import cn.bootx.platform.core.rest.param.PageParam; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.dromara.daxpay.service.common.entity.MchAppBaseEntity; import org.dromara.daxpay.service.entity.allocation.transaction.AllocTransaction; +import org.dromara.daxpay.service.param.order.allocation.AllocOrderQuery; import org.springframework.stereotype.Repository; import java.util.Optional; @@ -18,6 +24,16 @@ import java.util.Optional; @Repository @RequiredArgsConstructor public class AllocTransactionManager extends BaseManager { + + /** + * 分页 + */ + public Page page(PageParam pageParam, AllocOrderQuery param){ + Page mpPage = MpUtil.getMpPage(pageParam, AllocTransaction.class); + QueryWrapper generator = QueryGenerator.generator(param); + return this.page(mpPage, generator); + } + /** * 根据商户分账单号查询数据 */ diff --git a/daxpay-single/daxpay-single-service/src/main/java/org/dromara/daxpay/service/dao/allocation/transaction/AllocTransactionMapper.java b/daxpay-single/daxpay-single-service/src/main/java/org/dromara/daxpay/service/dao/allocation/transaction/AllocTransactionMapper.java index 4878b9c74..0f3934147 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/org/dromara/daxpay/service/dao/allocation/transaction/AllocTransactionMapper.java +++ b/daxpay-single/daxpay-single-service/src/main/java/org/dromara/daxpay/service/dao/allocation/transaction/AllocTransactionMapper.java @@ -1,13 +1,13 @@ package org.dromara.daxpay.service.dao.allocation.transaction; import com.github.yulichang.base.MPJBaseMapper; +import org.apache.ibatis.annotations.Mapper; import org.dromara.daxpay.service.entity.allocation.transaction.AllocTransaction; -import org.mapstruct.Mapper; -/** - * - * @author xxm - * @since 2024/11/14 +/** + * + * @author xxm + * @since 2024/11/14 */ @Mapper public interface AllocTransactionMapper extends MPJBaseMapper { diff --git a/daxpay-single/daxpay-single-service/src/main/java/org/dromara/daxpay/service/entity/allocation/transaction/AllocDetail.java b/daxpay-single/daxpay-single-service/src/main/java/org/dromara/daxpay/service/entity/allocation/transaction/AllocDetail.java index 27367cef9..07f9b2105 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/org/dromara/daxpay/service/entity/allocation/transaction/AllocDetail.java +++ b/daxpay-single/daxpay-single-service/src/main/java/org/dromara/daxpay/service/entity/allocation/transaction/AllocDetail.java @@ -1,11 +1,14 @@ package org.dromara.daxpay.service.entity.allocation.transaction; +import cn.bootx.platform.common.mybatisplus.function.ToResult; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; import org.dromara.daxpay.core.enums.AllocDetailResultEnum; import org.dromara.daxpay.core.enums.AllocReceiverTypeEnum; +import org.dromara.daxpay.core.result.allocation.transaction.AllocDetailResult; import org.dromara.daxpay.service.common.entity.MchAppBaseEntity; +import org.dromara.daxpay.service.convert.allocation.AllocTransactionConvert; import java.math.BigDecimal; import java.time.LocalDateTime; @@ -18,7 +21,7 @@ import java.time.LocalDateTime; @EqualsAndHashCode(callSuper = true) @Data @Accessors(chain = true) -public class AllocDetail extends MchAppBaseEntity { +public class AllocDetail extends MchAppBaseEntity implements ToResult { /** 分账订单ID */ private Long allocationId; @@ -61,4 +64,12 @@ public class AllocDetail extends MchAppBaseEntity { /** 分账完成时间 */ private LocalDateTime finishTime; + + /** + * 转换 + */ + @Override + public AllocDetailResult toResult() { + return AllocTransactionConvert.CONVERT.toResult(this); + } } diff --git a/daxpay-single/daxpay-single-service/src/main/java/org/dromara/daxpay/service/entity/allocation/transaction/AllocTransaction.java b/daxpay-single/daxpay-single-service/src/main/java/org/dromara/daxpay/service/entity/allocation/transaction/AllocTransaction.java index 3e2e5d691..b7b404284 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/org/dromara/daxpay/service/entity/allocation/transaction/AllocTransaction.java +++ b/daxpay-single/daxpay-single-service/src/main/java/org/dromara/daxpay/service/entity/allocation/transaction/AllocTransaction.java @@ -1,5 +1,6 @@ package org.dromara.daxpay.service.entity.allocation.transaction; +import cn.bootx.platform.common.mybatisplus.function.ToResult; import com.baomidou.mybatisplus.annotation.FieldStrategy; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; @@ -9,7 +10,9 @@ import lombok.experimental.Accessors; import org.dromara.daxpay.core.enums.AllocTransactionResultEnum; import org.dromara.daxpay.core.enums.AllocTransactionStatusEnum; import org.dromara.daxpay.core.enums.ChannelEnum; +import org.dromara.daxpay.core.result.allocation.transaction.AllocTransactionResult; import org.dromara.daxpay.service.common.entity.MchAppBaseEntity; +import org.dromara.daxpay.service.convert.allocation.AllocTransactionConvert; import java.math.BigDecimal; import java.time.LocalDateTime; @@ -23,7 +26,7 @@ import java.time.LocalDateTime; @Data @Accessors(chain = true) @TableName("pay_alloc_transaction") -public class AllocTransaction extends MchAppBaseEntity { +public class AllocTransaction extends MchAppBaseEntity implements ToResult { /** 分账单号 */ private String allocNo; @@ -98,4 +101,12 @@ public class AllocTransaction extends MchAppBaseEntity { /** 错误信息 */ private String errorMsg; + + /** + * 转换 + */ + @Override + public AllocTransactionResult toResult() { + return AllocTransactionConvert.CONVERT.toResult(this); + } } diff --git a/daxpay-single/daxpay-single-service/src/main/java/org/dromara/daxpay/service/service/allocation/transaction/AllocQueryService.java b/daxpay-single/daxpay-single-service/src/main/java/org/dromara/daxpay/service/service/allocation/transaction/AllocQueryService.java new file mode 100644 index 000000000..26accb554 --- /dev/null +++ b/daxpay-single/daxpay-single-service/src/main/java/org/dromara/daxpay/service/service/allocation/transaction/AllocQueryService.java @@ -0,0 +1,63 @@ +package org.dromara.daxpay.service.service.allocation.transaction; + +import cn.bootx.platform.common.mybatisplus.util.MpUtil; +import cn.bootx.platform.core.exception.DataNotExistException; +import cn.bootx.platform.core.rest.param.PageParam; +import cn.bootx.platform.core.rest.result.PageResult; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.dromara.daxpay.core.result.allocation.transaction.AllocDetailResult; +import org.dromara.daxpay.core.result.allocation.transaction.AllocTransactionResult; +import org.dromara.daxpay.service.dao.allocation.transaction.AllocDetailManager; +import org.dromara.daxpay.service.dao.allocation.transaction.AllocTransactionManager; +import org.dromara.daxpay.service.entity.allocation.transaction.AllocDetail; +import org.dromara.daxpay.service.entity.allocation.transaction.AllocTransaction; +import org.dromara.daxpay.service.param.order.allocation.AllocOrderQuery; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 分账订单查询服务类 + * @author xxm + * @since 2024/5/30 + */ +@Slf4j +@Service +@RequiredArgsConstructor +public class AllocQueryService { + + private final AllocDetailManager allocOrderDetailManager; + + private final AllocTransactionManager allocationOrderManager; + + /** + * 分页查询 + */ + public PageResult page(PageParam pageParam, AllocOrderQuery param){ + return MpUtil.toPageResult(allocationOrderManager.page(pageParam, param)); + } + + /** + * 查询详情 + */ + public AllocTransactionResult findById(Long id) { + return allocationOrderManager.findById(id).map(AllocTransaction::toResult).orElseThrow(() -> new DataNotExistException("分账订单不存在")); + } + + /** + * 查询订单明细列表 + */ + public List findDetailsByOrderId(Long orderId){ + return MpUtil.toListResult(allocOrderDetailManager.findAllByOrderId(orderId)); + } + + /** + * 查询订单明细详情 + */ + public AllocDetailResult findDetailById(Long id){ + return allocOrderDetailManager.findById(id).map(AllocDetail::toResult).orElseThrow(() -> new DataNotExistException("分账订单明细不存在")); + } + +} +