diff --git a/cloud-pay-common/pom.xml b/cloud-pay-common/pom.xml index 413711d..e52f5c7 100644 --- a/cloud-pay-common/pom.xml +++ b/cloud-pay-common/pom.xml @@ -20,15 +20,13 @@ + com.muyu cloud-common-core - - - diff --git a/cloud-pay-common/src/main/java/com/muyu/domain/OrderPayInfo.java b/cloud-pay-common/src/main/java/com/muyu/domain/OrderPayInfo.java new file mode 100644 index 0000000..b9daff2 --- /dev/null +++ b/cloud-pay-common/src/main/java/com/muyu/domain/OrderPayInfo.java @@ -0,0 +1,68 @@ +package com.muyu.domain; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.muyu.common.core.enums.SysPayType; +import com.muyu.common.core.enums.SystemYesNo; +import com.muyu.common.core.web.domain.BaseEntity; +import com.muyu.domain.resp.CustomerOrderPaySimpleResp; +import lombok.*; +import lombok.experimental.SuperBuilder; + +import java.math.BigDecimal; + +@EqualsAndHashCode(callSuper = true) +@Data +@AllArgsConstructor +@NoArgsConstructor +@SuperBuilder +@TableName(value = "order_pay_info",autoResultMap = true) +public class OrderPayInfo extends BaseEntity { + + /** + * 主键 + */ + @TableId(value = "id" , type = IdType.AUTO) + private String id; + /** + * 客户名称 + */ + private String appName; + /** + * 客户编号 + */ + private String appCode; + /** + * 客户单号 + */ + private String cusOrderNumber; + /** + * 支付单号 + */ + private String payOrderNumber; + /** + * 支付金额 + */ + private BigDecimal price; + /** + * 渠道商类型 + */ + private String channelType; + /** + * 渠道商单号 + */ + private String channelOrderNumber; + /** + * 支付单状态 + */ + private String status; + + public CustomerOrderPaySimpleResp buildCustomerOrderPaySimpleResp(){ + return CustomerOrderPaySimpleResp.builder() + .cusOrderNumber(this.cusOrderNumber) + .channelTypeName(SysPayType.getInfoByCode(this.channelType)) + .price(this.price).build(); + } + +} diff --git a/cloud-pay-common/src/main/java/com/muyu/domain/req/CustomerListReq.java b/cloud-pay-common/src/main/java/com/muyu/domain/req/CustomerListReq.java index 2d6c701..2696bab 100644 --- a/cloud-pay-common/src/main/java/com/muyu/domain/req/CustomerListReq.java +++ b/cloud-pay-common/src/main/java/com/muyu/domain/req/CustomerListReq.java @@ -41,4 +41,5 @@ public class CustomerListReq { + } diff --git a/cloud-pay-common/src/main/java/com/muyu/domain/resp/CustomerOrderPaySimpleResp.java b/cloud-pay-common/src/main/java/com/muyu/domain/resp/CustomerOrderPaySimpleResp.java new file mode 100644 index 0000000..87c5b63 --- /dev/null +++ b/cloud-pay-common/src/main/java/com/muyu/domain/resp/CustomerOrderPaySimpleResp.java @@ -0,0 +1,35 @@ +package com.muyu.domain.resp; + +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.math.BigDecimal; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +@Tag(name = "客户支付单",description = "客户支付单简略") +public class CustomerOrderPaySimpleResp { + + /** + * 客户单号 + */ + @Schema(title = "客户单号",type = "String" , defaultValue = "" ,description = "客户传入的支付单编号") + private String cusOrderNumber; + /** + * 支付金额 + */ + @Schema(title = "支付金额",type = "BigDecimal" , defaultValue = "13.13" ,description = "需要支付的金额") + private BigDecimal price; + /** + * 渠道商类型 + */ + @Schema(title = "支付渠道商",type = "String" , defaultValue = "支付宝" ,description = "所使用的渠道商") + private String channelTypeName; + +} diff --git a/cloud-pay-common/src/main/java/com/muyu/domain/resp/CustomerResp.java b/cloud-pay-common/src/main/java/com/muyu/domain/resp/CustomerResp.java index 4efdbf0..0fe4c59 100644 --- a/cloud-pay-common/src/main/java/com/muyu/domain/resp/CustomerResp.java +++ b/cloud-pay-common/src/main/java/com/muyu/domain/resp/CustomerResp.java @@ -12,9 +12,13 @@ import lombok.Data; import lombok.NoArgsConstructor; import java.util.Date; +import java.util.List; +import java.util.function.Function; +import java.util.function.Supplier; + -@Data @AllArgsConstructor +@Data @NoArgsConstructor @Builder @Tag(name = "客户信息相应对象",description = "负责客户信息查询结果") @@ -35,7 +39,7 @@ public class CustomerResp { /** * 服务/客户编号 */ - @Schema(defaultValue = "客户编码",type = "String" , description = "客户名称") + @Schema(defaultValue = "客户编码",type = "String" , description = "客户的编码") private String appCode; /** @@ -57,10 +61,15 @@ public class CustomerResp { @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date createTime; + + + private List orderPaySimpleRespList; + + /** * 返回结果 */ - public static CustomerResp customerBuild (OrderPayCustomer orderPayCustomer) { + public static CustomerResp customerBuild (OrderPayCustomer orderPayCustomer, Supplier> function) { return CustomerResp.builder() .id(orderPayCustomer.getId()) .appName(orderPayCustomer.getAppName()) @@ -68,6 +77,7 @@ public class CustomerResp { .status(orderPayCustomer.getStatus()) .createBy(orderPayCustomer.getCreateBy()) .createTime(orderPayCustomer.getCreateTime()) + .orderPaySimpleRespList(function.get()) .build(); } } diff --git a/cloud-pay-server/src/main/java/com/muyu/pay/MuYuPayApplication.java b/cloud-pay-server/src/main/java/com/muyu/pay/MuYuPayApplication.java index d1bd49c..f0adb95 100644 --- a/cloud-pay-server/src/main/java/com/muyu/pay/MuYuPayApplication.java +++ b/cloud-pay-server/src/main/java/com/muyu/pay/MuYuPayApplication.java @@ -2,17 +2,25 @@ package com.muyu.pay; import com.muyu.common.security.annotation.EnableCustomConfig; import com.muyu.common.security.annotation.EnableMyFeignClients; +import lombok.extern.log4j.Log4j2; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.ConfigurableApplicationContext; @EnableCustomConfig //@EnableCustomSwagger2 @EnableMyFeignClients @SpringBootApplication +@Log4j2 public class MuYuPayApplication { public static void main (String[] args) { - SpringApplication.run(MuYuPayApplication.class, args); + ConfigurableApplicationContext applicationContext = SpringApplication.run(MuYuPayApplication.class, args); + String[] beanDefinitionNames = applicationContext.getBeanFactory().getBeanDefinitionNames(); + for (String beanDefinitionName : beanDefinitionNames) { + log.info("beanDeNAME{}",beanDefinitionName); + } + } } diff --git a/cloud-pay-server/src/main/java/com/muyu/pay/controller/OrderPayCustomerController.java b/cloud-pay-server/src/main/java/com/muyu/pay/controller/OrderPayCustomerController.java index 9064a72..ecf7e05 100644 --- a/cloud-pay-server/src/main/java/com/muyu/pay/controller/OrderPayCustomerController.java +++ b/cloud-pay-server/src/main/java/com/muyu/pay/controller/OrderPayCustomerController.java @@ -1,30 +1,34 @@ package com.muyu.pay.controller; +import com.dtflys.forest.springboot.annotation.ForestScannerRegister; import com.muyu.common.core.domain.Result; import com.muyu.domain.OrderPayCustomer; import com.muyu.domain.req.CustomerListReq; import com.muyu.domain.resp.CustomerResp; import com.muyu.pay.service.OrderPayCustomerService; import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; import lombok.extern.log4j.Log4j2; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import java.util.List; @RestController @RequestMapping("/customer") @Log4j2 -@RequiredArgsConstructor @Tag(name = "客户控制层",description = "进行客户管理,查看等相关操作") public class OrderPayCustomerController { - private final OrderPayCustomerService orderPayCustomerService; + public OrderPayCustomerController (){ + log.info("扫描路径{}", ForestScannerRegister.getBasePackages()); + } + + @Autowired + private OrderPayCustomerService orderPayCustomerService; /** * 查询所有用户 @@ -36,4 +40,12 @@ public class OrderPayCustomerController { orderPayCustomerService.selectList(customerListReq) ); } + + + @GetMapping("/all") + @Operation(summary = "获取未接入的客户",description = "调用nacosAPI获取所有的微服务名称") + @Schema(description = "获取未接入的客户",defaultValue = "客户1,客户2",type = "List") + public Result> getCustomerAllList(){ + return Result.success(orderPayCustomerService.getCustomerAllList()); + } } diff --git a/cloud-pay-server/src/main/java/com/muyu/pay/mapper/OrderPayMapper.java b/cloud-pay-server/src/main/java/com/muyu/pay/mapper/OrderPayMapper.java new file mode 100644 index 0000000..0c9b081 --- /dev/null +++ b/cloud-pay-server/src/main/java/com/muyu/pay/mapper/OrderPayMapper.java @@ -0,0 +1,9 @@ +package com.muyu.pay.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.muyu.domain.OrderPayInfo; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface OrderPayMapper extends BaseMapper { +} diff --git a/cloud-pay-server/src/main/java/com/muyu/pay/service/OrderPayCustomerService.java b/cloud-pay-server/src/main/java/com/muyu/pay/service/OrderPayCustomerService.java index 6efd837..d492eeb 100644 --- a/cloud-pay-server/src/main/java/com/muyu/pay/service/OrderPayCustomerService.java +++ b/cloud-pay-server/src/main/java/com/muyu/pay/service/OrderPayCustomerService.java @@ -13,4 +13,6 @@ public interface OrderPayCustomerService extends IService { * 客户列表 */ public List selectList(CustomerListReq customerListReq); + + List getCustomerAllList(); } diff --git a/cloud-pay-server/src/main/java/com/muyu/pay/service/OrderPayService.java b/cloud-pay-server/src/main/java/com/muyu/pay/service/OrderPayService.java new file mode 100644 index 0000000..bdd8154 --- /dev/null +++ b/cloud-pay-server/src/main/java/com/muyu/pay/service/OrderPayService.java @@ -0,0 +1,10 @@ +package com.muyu.pay.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.muyu.domain.OrderPayInfo; + +import java.util.List; + +public interface OrderPayService extends IService { + List selectOrderPayByAppCodeAndLimit(String appCode, int limit); +} diff --git a/cloud-pay-server/src/main/java/com/muyu/pay/service/impl/OrderPayCustomerServiceImpl.java b/cloud-pay-server/src/main/java/com/muyu/pay/service/impl/OrderPayCustomerServiceImpl.java index d27f324..e546a50 100644 --- a/cloud-pay-server/src/main/java/com/muyu/pay/service/impl/OrderPayCustomerServiceImpl.java +++ b/cloud-pay-server/src/main/java/com/muyu/pay/service/impl/OrderPayCustomerServiceImpl.java @@ -3,23 +3,36 @@ package com.muyu.pay.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.muyu.common.core.utils.StringUtils; +import com.muyu.common.nacos.service.NacosServerService; import com.muyu.domain.OrderPayCustomer; +import com.muyu.domain.OrderPayInfo; import com.muyu.domain.req.CustomerListReq; +import com.muyu.domain.resp.CustomerOrderPaySimpleResp; import com.muyu.domain.resp.CustomerResp; import com.muyu.pay.controller.OrderPayCustomerController; import com.muyu.pay.mapper.OrderPayCustomerMapper; import com.muyu.pay.service.OrderPayCustomerService; +import com.muyu.pay.service.OrderPayService; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import javax.annotation.Resource; import java.util.ArrayList; import java.util.List; - +import java.util.Set; +import java.util.function.Function; +import java.util.stream.Collectors; @Service public class OrderPayCustomerServiceImpl extends ServiceImpl implements OrderPayCustomerService { + @Resource(type = OrderPayService.class) + private OrderPayService orderPayService; + + @Autowired + private NacosServerService nacosServerService; @Override public List selectList(CustomerListReq customerListReq) { @@ -38,7 +51,64 @@ public class OrderPayCustomerServiceImpl extends ServiceImpl orderPayCustomerList = this.list(queryWrapper); return orderPayCustomerList.stream() - .map(CustomerResp::customerBuild) + .map(orderPayCustomer -> CustomerResp.customerBuild( + orderPayCustomer, + () -> orderPayService.selectOrderPayByAppCodeAndLimit(orderPayCustomer.getAppCode(), 5) + .stream() + .map(OrderPayInfo::buildCustomerOrderPaySimpleResp) + .toList() + ) + ) + .toList(); + } + + @Override + public List getCustomerAllList() { + List nacosServerAllList = nacosServerService.nacosServiceAllList(); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.select(OrderPayCustomer::getAppCode); + List orderPayCustomerList = this.list(queryWrapper); + Set customerSet + = orderPayCustomerList.stream().map(OrderPayCustomer::getAppCode).collect(Collectors.toSet()); + return nacosServerAllList.stream() + .filter(nacosServer -> !customerSet.contains(nacosServer)) .toList(); } } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cloud-pay-server/src/main/java/com/muyu/pay/service/impl/OrderPayServiceImpl.java b/cloud-pay-server/src/main/java/com/muyu/pay/service/impl/OrderPayServiceImpl.java new file mode 100644 index 0000000..aad3173 --- /dev/null +++ b/cloud-pay-server/src/main/java/com/muyu/pay/service/impl/OrderPayServiceImpl.java @@ -0,0 +1,23 @@ +package com.muyu.pay.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.service.IService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.muyu.domain.OrderPayInfo; +import com.muyu.pay.mapper.OrderPayMapper; +import com.muyu.pay.service.OrderPayService; + +import java.util.List; + +public class OrderPayServiceImpl extends ServiceImplimplements OrderPayService { + + + @Override + public List selectOrderPayByAppCodeAndLimit(String appCode, int limit) { + LambdaQueryWrapper orderPayInfoLambdaQueryWrapper = new LambdaQueryWrapper<>(); + orderPayInfoLambdaQueryWrapper.eq(OrderPayInfo::getAppCode,appCode); + orderPayInfoLambdaQueryWrapper.orderBy(true,false,OrderPayInfo::getCreateTime); + orderPayInfoLambdaQueryWrapper.last("limit "+limit); + return this.list(orderPayInfoLambdaQueryWrapper); + } +} diff --git a/doc/sql/cloud-pay-init.sql b/doc/sql/cloud-pay-init.sql index 3bf8d27..a94c2e7 100644 --- a/doc/sql/cloud-pay-init.sql +++ b/doc/sql/cloud-pay-init.sql @@ -20,6 +20,7 @@ CREATE TABLE order_pay_info( `app_code` VARCHAR(16) COMMENT '客户编号' , `cus_order_number` VARCHAR(32) COMMENT '客户单号' , `pay_order_number` VARCHAR(32) COMMENT '支付单号' , + `price` DECIMAL(24,6) COMMENT '支付金额' , `channel_type` VARCHAR(32) COMMENT '渠道商类型' , `channel_order_number` VARCHAR(64) COMMENT '渠道商单号' , `status` VARCHAR(32) COMMENT '支付单状态;0:新建 1:待支付 2:支付中 3:支付成功 4:支付失败 5:支付失败' ,