master
陈思豪 2024-08-08 00:32:56 +08:00
parent 84470b8f8b
commit e168ef8906
13 changed files with 262 additions and 15 deletions

View File

@ -20,15 +20,13 @@
</properties>
<dependencies>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>cloud-common-core</artifactId>
</dependency>
</dependencies>
</project>

View File

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

View File

@ -41,4 +41,5 @@ public class CustomerListReq {
}

View File

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

View File

@ -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<CustomerOrderPaySimpleResp> orderPaySimpleRespList;
/**
*
*/
public static CustomerResp customerBuild (OrderPayCustomer orderPayCustomer) {
public static CustomerResp customerBuild (OrderPayCustomer orderPayCustomer, Supplier<List<CustomerOrderPaySimpleResp>> 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();
}
}

View File

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

View File

@ -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<List<String>> getCustomerAllList(){
return Result.success(orderPayCustomerService.getCustomerAllList());
}
}

View File

@ -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<OrderPayInfo> {
}

View File

@ -13,4 +13,6 @@ public interface OrderPayCustomerService extends IService<OrderPayCustomer> {
*
*/
public List<CustomerResp> selectList(CustomerListReq customerListReq);
List<String> getCustomerAllList();
}

View File

@ -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<OrderPayInfo> {
List<OrderPayInfo> selectOrderPayByAppCodeAndLimit(String appCode, int limit);
}

View File

@ -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<OrderPayCustomerMapper ,OrderPayCustomer>
implements OrderPayCustomerService {
@Resource(type = OrderPayService.class)
private OrderPayService orderPayService;
@Autowired
private NacosServerService nacosServerService;
@Override
public List<CustomerResp> selectList(CustomerListReq customerListReq) {
@ -38,7 +51,64 @@ public class OrderPayCustomerServiceImpl extends ServiceImpl<OrderPayCustomerMap
);
List<OrderPayCustomer> 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<String> getCustomerAllList() {
List<String> nacosServerAllList = nacosServerService.nacosServiceAllList();
LambdaQueryWrapper<OrderPayCustomer> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.select(OrderPayCustomer::getAppCode);
List<OrderPayCustomer> orderPayCustomerList = this.list(queryWrapper);
Set<String> customerSet
= orderPayCustomerList.stream().map(OrderPayCustomer::getAppCode).collect(Collectors.toSet());
return nacosServerAllList.stream()
.filter(nacosServer -> !customerSet.contains(nacosServer))
.toList();
}
}

View File

@ -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 ServiceImpl<OrderPayMapper, OrderPayInfo>implements OrderPayService {
@Override
public List<OrderPayInfo> selectOrderPayByAppCodeAndLimit(String appCode, int limit) {
LambdaQueryWrapper<OrderPayInfo> orderPayInfoLambdaQueryWrapper = new LambdaQueryWrapper<>();
orderPayInfoLambdaQueryWrapper.eq(OrderPayInfo::getAppCode,appCode);
orderPayInfoLambdaQueryWrapper.orderBy(true,false,OrderPayInfo::getCreateTime);
orderPayInfoLambdaQueryWrapper.last("limit "+limit);
return this.list(orderPayInfoLambdaQueryWrapper);
}
}

View File

@ -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支付失败' ,