diff --git a/cloud-pay-common/pom.xml b/cloud-pay-common/pom.xml index bace182..dd968ea 100644 --- a/cloud-pay-common/pom.xml +++ b/cloud-pay-common/pom.xml @@ -10,6 +10,7 @@ cloud-pay-common + 1.0.0 @@ -19,10 +20,22 @@ + com.muyu cloud-common-core - + + \ No newline at end of file diff --git a/cloud-pay-common/src/main/java/com/muyu/Main.java b/cloud-pay-common/src/main/java/com/muyu/Main.java deleted file mode 100644 index 1d4ae3f..0000000 --- a/cloud-pay-common/src/main/java/com/muyu/Main.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.muyu; - -/** - * @Classname ${NAME} - * @Description TODO - * @Date 2024/8/4 上午11:21 - * @Created by 杨旭飞 - */ -public class Main { - public static void main(String[] args) { - System.out.println("Hello world!"); - } -} \ No newline at end of file diff --git a/cloud-pay-common/src/main/java/com/muyu/pay/domain/OrderPayCustomer.java b/cloud-pay-common/src/main/java/com/muyu/pay/domain/OrderPayCustomer.java new file mode 100644 index 0000000..da05ccc --- /dev/null +++ b/cloud-pay-common/src/main/java/com/muyu/pay/domain/OrderPayCustomer.java @@ -0,0 +1,49 @@ +package com.muyu.pay.domain; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.muyu.common.core.web.domain.BaseEntity; +import lombok.*; +import lombok.experimental.SuperBuilder; + +/** + * @Classname OrderPayCustomer + * @Description TODO + * @Date 2024/8/8 下午4:05 + * @Created by 杨旭飞 + */ +@Data +@SuperBuilder +@NoArgsConstructor +@AllArgsConstructor +@EqualsAndHashCode(callSuper = true) +@TableName(value = "order_pay_customer", autoResultMap = true) +public class OrderPayCustomer extends BaseEntity { + + /** + * 主键 + */ + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + /** + * 服务/客户名称 + */ + private String appName; + + /** + * 服务/客户编码 + */ + private String appCode; + + /** + * 服务/客户描述 + */ + private String appDesc; + + /** + * 状态 + */ + private String status; +} diff --git a/cloud-pay-common/src/main/java/com/muyu/pay/domain/OrderPayInfo.java b/cloud-pay-common/src/main/java/com/muyu/pay/domain/OrderPayInfo.java new file mode 100644 index 0000000..1b909a4 --- /dev/null +++ b/cloud-pay-common/src/main/java/com/muyu/pay/domain/OrderPayInfo.java @@ -0,0 +1,83 @@ +package com.muyu.pay.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.web.domain.BaseEntity; +import com.muyu.pay.domain.resp.CustomerOrderPaySimpleResp; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import lombok.experimental.SuperBuilder; +import java.math.BigDecimal; + +/** + * @Classname OrderPayInfo + * @Description TODO + * @Date 2024/8/8 下午4:08 + * @Created by 杨旭飞 + */ +@Data +@SuperBuilder +@NoArgsConstructor +@AllArgsConstructor +@EqualsAndHashCode(callSuper = true) +@TableName(value = "order_pay_info", autoResultMap = true) +public class OrderPayInfo extends BaseEntity { + + /** + * 主键 + */ + @TableId(value = "id", type = IdType.AUTO) + private Long 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/pay/domain/req/CustomerListReq.java b/cloud-pay-common/src/main/java/com/muyu/pay/domain/req/CustomerListReq.java new file mode 100644 index 0000000..4e80fa3 --- /dev/null +++ b/cloud-pay-common/src/main/java/com/muyu/pay/domain/req/CustomerListReq.java @@ -0,0 +1,42 @@ +package com.muyu.pay.domain.req; + +import com.muyu.common.core.validation.custom.IsSystemYesNo; +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; + +/** + * @Classname OrderPayCustomer + * @Description TODO + * @Date 2024/8/8 下午4:17 + * @Created by 杨旭飞 + */ +@Tag(name = "客户列表请求对象") +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class CustomerListReq { + + /** + * 服务/客户名称 + */ + @Schema(type = "String", defaultValue = "客户名称1", description = "客户名称,为微服务中文名称") + private String appName; + + /** + * 服务/客户编码 + */ + @Schema(defaultValue = "customer_code", type = "String", description = "客户名称,为微服务名称") + private String appCode; + + /** + * 状态 - sys_yes_no + */ + @Schema(type = "String", defaultValue = "Y", description = "客户状态,Y是开启,N关闭") + @IsSystemYesNo + private String status; +} diff --git a/cloud-pay-common/src/main/java/com/muyu/pay/domain/resp/CustomerOrderPaySimpleResp.java b/cloud-pay-common/src/main/java/com/muyu/pay/domain/resp/CustomerOrderPaySimpleResp.java new file mode 100644 index 0000000..70e70eb --- /dev/null +++ b/cloud-pay-common/src/main/java/com/muyu/pay/domain/resp/CustomerOrderPaySimpleResp.java @@ -0,0 +1,40 @@ +package com.muyu.pay.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; + +/** + * @Author: zi run + * @Date 2024/8/5 1:07 + * @Description 客户支付单简略返回实体 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Tag(name = "客户支付单", description = "客户支付单简略信息") +public class CustomerOrderPaySimpleResp { + + /** + * 客户单号 + */ + @Schema(name = "客户单号", type = "String", defaultValue = "ORDER1A2B3C4D5E6F", description = "客户传入的支付信息") + private String cusOrderNumber; + + /** + * 支付金额 + */ + @Schema(name = "支付金额", type = "BigDecimal", defaultValue = "27.56", description = "客户传入的支付金额") + private BigDecimal price; + + /** + * 渠道商类型 + */ + @Schema(name = "支付渠道商", type = "String", defaultValue = "支付宝", description = "用户支付的时候选择的渠道商") + private String channelTypeName; +} diff --git a/cloud-pay-common/src/main/java/com/muyu/pay/domain/resp/CustomerResp.java b/cloud-pay-common/src/main/java/com/muyu/pay/domain/resp/CustomerResp.java new file mode 100644 index 0000000..21d64e3 --- /dev/null +++ b/cloud-pay-common/src/main/java/com/muyu/pay/domain/resp/CustomerResp.java @@ -0,0 +1,79 @@ +package com.muyu.pay.domain.resp; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.muyu.pay.domain.OrderPayCustomer; +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.util.Date; +import java.util.List; +import java.util.function.Supplier; + +/** + * @Author: zi run + * @Date 2024/8/4 16:27 + * @Description 客户集合返回值 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Tag(name = "客户信息响应对象", description = "负责客户信息查询的响应结果") +public class CustomerResp { + + /** + * 主键 + */ + @Schema(description = "客户ID", defaultValue = "1", type = "Long") + private Long id; + + /** + * 服务/客户名称 + */ + @Schema(description = "客户名称", defaultValue = "商品服务", type = "String") + private String appName; + + /** + * 服务/客户编码 + */ + @Schema(description = "客户编码", defaultValue = "cloud_order", type = "String") + private String appCode; + + /** + * 状态 + */ + @Schema(description = "客户状态,同数据字典-系统是否", defaultValue = "Y", type = "String") + private String status; + + @Schema(description = "创建人", defaultValue = "muyu", type = "String") + private String createBy; + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @Schema(description = "创建时间", defaultValue = "2024-08-04 19:11:14", type = "Date") + private Date createTime; + + /** + * 客户最近5条支付单 + */ + private List orderPaySimpleRespList; + + /** + * 数据库对象构建为返回结果对象 + * @param orderPayCustomer 数据对象 + * @return 视图对象 + */ + public static CustomerResp customerBuild(OrderPayCustomer orderPayCustomer, Supplier> function) { + return CustomerResp.builder() + .id(orderPayCustomer.getId()) + .appName(orderPayCustomer.getAppName()) + .appCode(orderPayCustomer.getAppCode()) + .status(orderPayCustomer.getStatus()) + .createBy(orderPayCustomer.getCreateBy()) + .createTime(orderPayCustomer.getCreateTime()) + .orderPaySimpleRespList(function.get()) + .build(); + } +} diff --git a/cloud-pay-common/src/main/resources/banner.txt b/cloud-pay-common/src/main/resources/banner.txt new file mode 100644 index 0000000..0dd5eee --- /dev/null +++ b/cloud-pay-common/src/main/resources/banner.txt @@ -0,0 +1,2 @@ +Spring Boot Version: ${spring-boot.version} +Spring Application Name: ${spring.application.name} diff --git a/cloud-pay-common/src/main/resources/bootstrap.yml b/cloud-pay-common/src/main/resources/bootstrap.yml new file mode 100644 index 0000000..c00631c --- /dev/null +++ b/cloud-pay-common/src/main/resources/bootstrap.yml @@ -0,0 +1,53 @@ +# Tomcat +server: + port: 9701 + +# nacos线上地址 +nacos: + addr: 114.55.172.217:8848 + user-name: nacos + password: nacos + namespace: muyu-cloud + +# Spring +spring: + main: + allow-bean-definition-overriding: true + application: + # 应用名称 + name: cloud-pay + profiles: + # 环境配置 + active: dev + cloud: + nacos: + discovery: + # 服务注册地址 + server-addr: ${nacos.addr} + # nacos用户名 + username: ${nacos.user-name} + # nacos密码 + password: ${nacos.password} + # 命名空间 + namespace: ${nacos.namespace} + config: + # 服务注册地址 + server-addr: ${nacos.addr} + # nacos用户名 + username: ${nacos.user-name} + # nacos密码 + password: ${nacos.password} + # 命名空间 + namespace: ${nacos.namespace} + # 配置文件格式 + file-extension: yml + # 共享配置 + shared-configs: + # 系统共享配置 + - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} + # 系统环境Config共享配置 + - application-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} + # xxl-job 配置文件 + - application-xxl-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} + # rabbit 配置文件 + - application-rabbit-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} \ No newline at end of file diff --git a/cloud-pay-common/src/main/resources/logback/dev.xml b/cloud-pay-common/src/main/resources/logback/dev.xml new file mode 100644 index 0000000..a0e16b0 --- /dev/null +++ b/cloud-pay-common/src/main/resources/logback/dev.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + ${log.pattern} + + + + + + ${log.path}/info.log + + + + ${log.path}/info.%d{yyyy-MM-dd}.log + + 60 + + + ${log.pattern} + + + + INFO + + ACCEPT + + DENY + + + + + ${log.path}/error.log + + + + ${log.path}/error.%d{yyyy-MM-dd}.log + + 60 + + + ${log.pattern} + + + + ERROR + + ACCEPT + + DENY + + + + + + + + + + + + + + + + + + diff --git a/cloud-pay-common/src/main/resources/logback/prod.xml b/cloud-pay-common/src/main/resources/logback/prod.xml new file mode 100644 index 0000000..afd0098 --- /dev/null +++ b/cloud-pay-common/src/main/resources/logback/prod.xml @@ -0,0 +1,81 @@ + + + + + + + + + + + + ${log.sky.pattern} + + + + + + ${log.path}/info.log + + + + ${log.path}/info.%d{yyyy-MM-dd}.log + + 60 + + + + + INFO + + ACCEPT + + DENY + + + + + ${log.path}/error.log + + + + ${log.path}/error.%d{yyyy-MM-dd}.log + + 60 + + + + + ERROR + + ACCEPT + + DENY + + + + + + + + ${log.sky.pattern} + + + + + + + + + + + + + + + + + + + + diff --git a/cloud-pay-common/src/main/resources/logback/test.xml b/cloud-pay-common/src/main/resources/logback/test.xml new file mode 100644 index 0000000..6594919 --- /dev/null +++ b/cloud-pay-common/src/main/resources/logback/test.xml @@ -0,0 +1,81 @@ + + + + + + + + + + + + ${log.sky.pattern} + + + + + + ${log.path}/info.log + + + + ${log.path}/info.%d{yyyy-MM-dd}.log + + 60 + + + + + INFO + + ACCEPT + + DENY + + + + + ${log.path}/error.log + + + + ${log.path}/error.%d{yyyy-MM-dd}.log + + 60 + + + + + ERROR + + ACCEPT + + DENY + + + + + + + + ${log.sky.pattern} + + + + + + + + + + + + + + + + + + + + diff --git a/cloud-pay-server/pom.xml b/cloud-pay-server/pom.xml index 2940514..a380aae 100644 --- a/cloud-pay-server/pom.xml +++ b/cloud-pay-server/pom.xml @@ -7,7 +7,7 @@ com.muyu cloud-pay - 1.0.0 + 1.0.1 @@ -87,6 +87,16 @@ com.muyu cloud-common-rabbit + + com.muyu + cloud-pay-common + + + + + com.muyu + cloud-common-nacos-remote + diff --git a/cloud-pay-server/src/main/java/com/muyu/cloud/pay/controller/TestController.java b/cloud-pay-server/src/main/java/com/muyu/cloud/pay/controller/TestController.java deleted file mode 100644 index a02cf46..0000000 --- a/cloud-pay-server/src/main/java/com/muyu/cloud/pay/controller/TestController.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.muyu.cloud.pay.controller; - -import com.muyu.common.core.domain.Result; -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; - - - -/** - * @Classname TestController - * @Description TODO - * @Date 2024/8/5 下午8:37 - * @Created by 杨旭飞 - */ -@RequestMapping("/test") -@RestController -public class TestController { - @PostMapping - public Result post(){ - return Result.success("测试Post成功"); - } - - @GetMapping - public Result get(){ - return Result.success("测试Get成功"); - } -} diff --git a/cloud-pay-server/src/main/java/com/muyu/cloud/pay/MuYuPayApplication.java b/cloud-pay-server/src/main/java/com/muyu/pay/CloudPayApplication.java similarity index 52% rename from cloud-pay-server/src/main/java/com/muyu/cloud/pay/MuYuPayApplication.java rename to cloud-pay-server/src/main/java/com/muyu/pay/CloudPayApplication.java index a99fa2a..b3d5700 100644 --- a/cloud-pay-server/src/main/java/com/muyu/cloud/pay/MuYuPayApplication.java +++ b/cloud-pay-server/src/main/java/com/muyu/pay/CloudPayApplication.java @@ -1,22 +1,24 @@ -package com.muyu.cloud.pay; +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; /** - * @Classname MuYuPayApplication + * @Classname CloudPayApplication * @Description TODO - * @Date 2024/8/5 下午8:33 + * @Date 2024/8/8 下午1:11 * @Created by 杨旭飞 */ +@Log4j2 @EnableCustomConfig -//@EnableCustomSwagger2 @EnableMyFeignClients @SpringBootApplication -public class MuYuPayApplication { - public static void main (String[] args) { - SpringApplication.run(MuYuPayApplication.class, args); +public class CloudPayApplication { + public static void main(String[] args) { + SpringApplication.run(CloudPayApplication.class, args); } } diff --git a/cloud-pay-server/src/main/java/com/muyu/pay/MySpringApplicationRunListener.java b/cloud-pay-server/src/main/java/com/muyu/pay/MySpringApplicationRunListener.java new file mode 100644 index 0000000..0e3cb87 --- /dev/null +++ b/cloud-pay-server/src/main/java/com/muyu/pay/MySpringApplicationRunListener.java @@ -0,0 +1,58 @@ +package com.muyu.pay; + +import lombok.extern.log4j.Log4j2; +import org.springframework.boot.ConfigurableBootstrapContext; +import org.springframework.boot.SpringApplicationRunListener; +import org.springframework.context.ConfigurableApplicationContext; +import org.springframework.core.env.ConfigurableEnvironment; +import java.time.Duration; + + +/** + * @Classname MySpringApplicationRunListener + * @Description TODO + * @Date 2024/8/8 下午2:02 + * @Created by 杨旭飞 + */ +@Log4j2 +public class MySpringApplicationRunListener implements SpringApplicationRunListener { + + public MySpringApplicationRunListener() { + log.info("MySpringApplicationRunListener"); + } + + @Override + public void starting(ConfigurableBootstrapContext bootstrapContext) { + log.info("执行:{}", "starting"); + } + + @Override + public void environmentPrepared(ConfigurableBootstrapContext bootstrapContext, ConfigurableEnvironment environment) { + log.info("执行:{}", "environmentPrepared"); + } + + @Override + public void contextPrepared(ConfigurableApplicationContext context) { + log.info("执行:{}", "contextPrepared"); + } + + @Override + public void contextLoaded(ConfigurableApplicationContext context) { + log.info("执行:{}", "contextLoaded"); + } + + @Override + public void started(ConfigurableApplicationContext context, Duration timeTaken) { + log.info("执行:{}", "started"); + } + + @Override + public void ready(ConfigurableApplicationContext context, Duration timeTaken) { + log.info("执行:{}", "ready"); + } + + @Override + public void failed(ConfigurableApplicationContext context, Throwable exception) { + log.info("执行:{}", "failed"); + } +} 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 new file mode 100644 index 0000000..355fcd1 --- /dev/null +++ b/cloud-pay-server/src/main/java/com/muyu/pay/controller/OrderPayCustomerController.java @@ -0,0 +1,66 @@ +package com.muyu.pay.controller; + +import com.dtflys.forest.springboot.annotation.ForestScannerRegister; +import com.muyu.common.core.domain.Result; +import com.muyu.pay.domain.req.CustomerListReq; +import com.muyu.pay.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.*; +import java.util.List; + +/** + * @Classname OrderPayCustomerController + * @Description TODO + * @Date 2024/8/8 下午8:00 + * @Created by 杨旭飞 + */ +@Log4j2 +@RestController +@RequestMapping("/customer") +@Tag(name = "客户控制层", description = "进行客户管理、查看等相关操作") +public class OrderPayCustomerController { + + public OrderPayCustomerController() { + log.info("forest扫描路径:{}", ForestScannerRegister.getBasePackages()); + } + + /** + * 客户业务层 + */ + @Autowired + private OrderPayCustomerService orderPayCustomerService; + + /** + * 查询所有的客户 + * @param customerListReq 客户列表请求参数 + * @return 客户列表 + */ + @RequestMapping(path = "/list", method = RequestMethod.POST) + @Operation(summary = "查看客户", description = "根据客户的名称、编码、是否开启等可以进行客户的筛选") + public Result> selectList( + @Validated @RequestBody CustomerListReq customerListReq) { + return Result.success( + orderPayCustomerService.selectList(customerListReq) + ); + } + + /** + * 获取所有客户的列表 + * @return 客户集合 + */ + @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/OrderPayCustomerMapper.java b/cloud-pay-server/src/main/java/com/muyu/pay/mapper/OrderPayCustomerMapper.java new file mode 100644 index 0000000..4e80b81 --- /dev/null +++ b/cloud-pay-server/src/main/java/com/muyu/pay/mapper/OrderPayCustomerMapper.java @@ -0,0 +1,15 @@ +package com.muyu.pay.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.muyu.pay.domain.OrderPayCustomer; +import org.apache.ibatis.annotations.Mapper; + +/** + * @Classname OrderPayCustomerMapper + * @Description TODO + * @Date 2024/8/8 下午8:06 + * @Created by 杨旭飞 + */ +@Mapper +public interface OrderPayCustomerMapper extends BaseMapper { +} 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..a361f48 --- /dev/null +++ b/cloud-pay-server/src/main/java/com/muyu/pay/mapper/OrderPayMapper.java @@ -0,0 +1,15 @@ +package com.muyu.pay.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.muyu.pay.domain.OrderPayInfo; +import org.apache.ibatis.annotations.Mapper; + +/** + * @Classname OrderPayMapper + * @Description TODO + * @Date 2024/8/8 下午8:17 + * @Created by 杨旭飞 + */ +@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 new file mode 100644 index 0000000..2ad41fb --- /dev/null +++ b/cloud-pay-server/src/main/java/com/muyu/pay/service/OrderPayCustomerService.java @@ -0,0 +1,29 @@ +package com.muyu.pay.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.muyu.pay.domain.OrderPayCustomer; +import com.muyu.pay.domain.req.CustomerListReq; +import com.muyu.pay.domain.resp.CustomerResp; +import java.util.List; + +/** + * @Classname OrderPayCustomerService + * @Description TODO + * @Date 2024/8/8 下午9:09 + * @Created by 杨旭飞 + */ +public interface OrderPayCustomerService extends IService { + + /** + * 查询客户集合 + * @param customerListReq 请求参数 + * @return 客户集合 + */ + public List selectList(CustomerListReq customerListReq); + + /** + * 获取所有的客户 + * @return 客户集合 + */ + 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..f431d0c --- /dev/null +++ b/cloud-pay-server/src/main/java/com/muyu/pay/service/OrderPayService.java @@ -0,0 +1,22 @@ +package com.muyu.pay.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.muyu.pay.domain.OrderPayInfo; +import java.util.List; + +/** + * @Classname OrderPayService + * @Description TODO + * @Date 2024/8/8 下午9:20 + * @Created by 杨旭飞 + */ +public interface OrderPayService extends IService { + + /** + * 根据客户code和分页限制查询结果 + * @param appCode 客户code + * @param limit 分页限制 + * @return 支付订单记录 + */ + 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 new file mode 100644 index 0000000..acd3972 --- /dev/null +++ b/cloud-pay-server/src/main/java/com/muyu/pay/service/impl/OrderPayCustomerServiceImpl.java @@ -0,0 +1,89 @@ +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.pay.domain.OrderPayCustomer; +import com.muyu.pay.domain.OrderPayInfo; +import com.muyu.pay.domain.req.CustomerListReq; +import com.muyu.pay.domain.resp.CustomerResp; +import com.muyu.pay.mapper.OrderPayCustomerMapper; +import com.muyu.pay.service.OrderPayCustomerService; +import com.muyu.pay.service.OrderPayService; +import lombok.extern.log4j.Log4j2; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + +/** + * @Classname OrderPayCustomerServiceImpl + * @Description TODO + * @Date 2024/8/9 上午9:09 + * @Created by 杨旭飞 + */ +@Log4j2 +@Service +public class OrderPayCustomerServiceImpl + extends ServiceImpl + implements OrderPayCustomerService { + + @Autowired + private OrderPayService orderPayService; + + @Autowired + private NacosServerService nacosServerService; + + /** + * 查询客户集合 + * @param customerListReq 请求参数 + * @return 客户集合 + */ + @Override + public List selectList(CustomerListReq customerListReq) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.like( + StringUtils.isEmpty(customerListReq.getAppName()), + OrderPayCustomer::getAppName, customerListReq.getAppName() + ); + queryWrapper.like( + StringUtils.isEmpty(customerListReq.getAppCode()), + OrderPayCustomer::getAppCode, customerListReq.getAppCode() + ); + queryWrapper.eq( + StringUtils.isEmpty(customerListReq.getStatus()), + OrderPayCustomer::getStatus, customerListReq.getStatus() + ); + List orderPayCustomerList = this.list(queryWrapper); + return orderPayCustomerList.stream() + .map(orderPayCustomer -> CustomerResp.customerBuild( + orderPayCustomer, + () -> orderPayService.selectOrderPayByAppCodeAndLimit(orderPayCustomer.getAppCode(), 5) + .stream() + .map(OrderPayInfo::buildCustomerOrderPaySimpleResp) + .toList() + ) + ) + .toList(); + } + + /** + * 获取所有的客户 + * @return 客户集合 + */ + @Override + public List getCustomerAllList() { + List nacosServerAllList = nacosServerService.nacosServerAllList(); + 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..189d323 --- /dev/null +++ b/cloud-pay-server/src/main/java/com/muyu/pay/service/impl/OrderPayServiceImpl.java @@ -0,0 +1,35 @@ +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.pay.domain.OrderPayInfo; +import com.muyu.pay.mapper.OrderPayMapper; +import com.muyu.pay.service.OrderPayService; +import org.springframework.stereotype.Service; +import java.util.List; + +/** + * @Classname OrderPayServiceImpl + * @Description TODO + * @Date 2024/8/9 下午9:09 + * @Created by 杨旭飞 + */ +@Service +public class OrderPayServiceImpl extends ServiceImpl implements OrderPayService { + + /** + * 根据客户code和分页限制查询结果 + * @param appCode 客户code + * @param limit 分页限制 + * @return 支付订单记录 + */ + @Override + public List selectOrderPayByAppCodeAndLimit(String appCode, int limit) { + LambdaQueryWrapper orderPayInfoQueryWrapper = new LambdaQueryWrapper<>(); + orderPayInfoQueryWrapper.eq(OrderPayInfo::getAppCode, appCode); + orderPayInfoQueryWrapper.orderBy(true, false, OrderPayInfo::getCreateTime); + orderPayInfoQueryWrapper.last("limit " + limit); + List orderPayInfoList = this.list(orderPayInfoQueryWrapper); + return this.list(orderPayInfoQueryWrapper); + } +} diff --git a/cloud-pay-server/src/main/resources/bootstrap.yml b/cloud-pay-server/src/main/resources/bootstrap.yml index 318ddcc..c00631c 100644 --- a/cloud-pay-server/src/main/resources/bootstrap.yml +++ b/cloud-pay-server/src/main/resources/bootstrap.yml @@ -4,10 +4,10 @@ server: # nacos线上地址 nacos: - addr: 10.28.29.211:8848 + addr: 114.55.172.217:8848 user-name: nacos password: nacos - namespace: cloud + namespace: muyu-cloud # Spring spring: @@ -50,5 +50,4 @@ spring: # xxl-job 配置文件 - application-xxl-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} # rabbit 配置文件 - - application-rabbit-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} - + - application-rabbit-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} \ No newline at end of file diff --git a/pom.xml b/pom.xml index 6a7de9f..ecba451 100644 --- a/pom.xml +++ b/pom.xml @@ -13,11 +13,12 @@ cloud-pay 1.0.1 pom + - cloud-pay-client - cloud-pay-common - cloud-pay-remote cloud-pay-server + cloud-pay-client + cloud-pay-remote + cloud-pay-common