feat():增加接口
parent
6ed6d654ac
commit
42696a6f8e
|
@ -4,10 +4,13 @@ import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.bwie.cloud.pay.domain.req.OrderCustomerAddReq;
|
import com.bwie.cloud.pay.domain.req.OrderCustomerAddReq;
|
||||||
|
import com.bwie.cloud.pay.domain.req.OrderCustomerUpdReq;
|
||||||
import com.muyu.common.core.web.domain.BaseEntity;
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
import lombok.experimental.SuperBuilder;
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author:zhangzhihao
|
* @Author:zhangzhihao
|
||||||
* @name:OrderPayCustomer
|
* @name:OrderPayCustomer
|
||||||
|
@ -61,6 +64,15 @@ public class OrderPayCustomer extends BaseEntity {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static OrderPayCustomer updBuild(OrderCustomerUpdReq req, Supplier<Long> idSupplier){
|
||||||
|
return OrderPayCustomer.builder()
|
||||||
|
.id(idSupplier.get())
|
||||||
|
.appName(req.getAppName())
|
||||||
|
.appDesc(req.getAppDesc())
|
||||||
|
.status(req.getStatus())
|
||||||
|
.remark(req.getRemark())
|
||||||
|
.build();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
package com.bwie.cloud.pay.domain.req;
|
||||||
|
|
||||||
|
import com.muyu.common.core.validation.custom.IsSystemYseNo;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import jakarta.validation.constraints.NotEmpty;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:zhangzhihao
|
||||||
|
* @name:OrderCustomerUpdReq
|
||||||
|
* @Date:2024/8/7 16:20
|
||||||
|
* 不准抄代码,添加注释,清楚每一行代码意思
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class OrderCustomerUpdReq {
|
||||||
|
/**
|
||||||
|
* 服务/客户名称
|
||||||
|
*/
|
||||||
|
@NotEmpty(message = "服务客户名称不可为空")
|
||||||
|
@Schema(title = "服务/客户名称",type = "String",defaultValue = "会员服务",
|
||||||
|
description = "客户名称一般为微服务的中文名称,方便使用者进行区分",requiredProperties = {"appName"})
|
||||||
|
private String appName;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 服务/客户描述
|
||||||
|
*/
|
||||||
|
@Schema(title = "服务/客户描述",type = "String")
|
||||||
|
private String appDesc;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "客户状态不可为空")
|
||||||
|
@IsSystemYseNo
|
||||||
|
@Schema(title = "服务/客户开通状态",type = "String",defaultValue = "Y",description = "状态为Y和N,如果为Y用户可以使用支付接口,若为N顾客不可以使用支付接口类")
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 客户备注
|
||||||
|
*/
|
||||||
|
@Schema(title = "服务/客户备注",type = "String")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -3,6 +3,7 @@ package com.bwie.cloud.pay.controller;
|
||||||
import com.bwie.cloud.pay.domain.OrderPayCustomer;
|
import com.bwie.cloud.pay.domain.OrderPayCustomer;
|
||||||
import com.bwie.cloud.pay.domain.req.CustomerListReq;
|
import com.bwie.cloud.pay.domain.req.CustomerListReq;
|
||||||
import com.bwie.cloud.pay.domain.req.OrderCustomerAddReq;
|
import com.bwie.cloud.pay.domain.req.OrderCustomerAddReq;
|
||||||
|
import com.bwie.cloud.pay.domain.req.OrderCustomerUpdReq;
|
||||||
import com.bwie.cloud.pay.domain.resp.CustomerResp;
|
import com.bwie.cloud.pay.domain.resp.CustomerResp;
|
||||||
import com.bwie.cloud.pay.service.OrderPayCustomerService;
|
import com.bwie.cloud.pay.service.OrderPayCustomerService;
|
||||||
import com.muyu.common.core.domain.Result;
|
import com.muyu.common.core.domain.Result;
|
||||||
|
@ -40,7 +41,7 @@ public class OrderPayCustomerController {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@PostMapping("/list")
|
@PostMapping("/list")
|
||||||
@Operation(summary = "查看看护",description = "根据客户的名称,编码,是否开启等可以运行客户的筛选")
|
@Operation(summary = "查询所有的客户",description = "根据客户的名称,编码,是否开启等可以运行客户的筛选")
|
||||||
public Result<List<CustomerResp>> selectList(@Validated @RequestBody CustomerListReq customerListReq){
|
public Result<List<CustomerResp>> selectList(@Validated @RequestBody CustomerListReq customerListReq){
|
||||||
|
|
||||||
return Result.success(orderPayCustomerService.selectList(customerListReq));
|
return Result.success(orderPayCustomerService.selectList(customerListReq));
|
||||||
|
@ -68,4 +69,69 @@ public class OrderPayCustomerController {
|
||||||
return Result.success();
|
return Result.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改
|
||||||
|
* @param orderCustomerId
|
||||||
|
* @param orderCustomerUpdReq
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PutMapping("/{orderCustomerId}")
|
||||||
|
@Operation(summary = "客户信息修改",description = "通过ID修改客户信息")
|
||||||
|
public Result<String> update(
|
||||||
|
@Schema(title = "客户ID",type = "Long",defaultValue = "1",description = "修改客户信息需要依据的唯一条件")
|
||||||
|
@PathVariable("orderCustomerId") Long orderCustomerId,
|
||||||
|
@RequestBody @Validated OrderCustomerUpdReq orderCustomerUpdReq){
|
||||||
|
orderPayCustomerService.updateById(OrderPayCustomer.updBuild(orderCustomerUpdReq,()->orderCustomerId));
|
||||||
|
return Result.success(null,"操作成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过id删除客户
|
||||||
|
* @param orderCustomerId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@DeleteMapping("/{orderCustomerId}")
|
||||||
|
@Operation(summary = "客户信息删除",description = "通过ID删除客户信息")
|
||||||
|
public Result<String> delete(@PathVariable("orderCustomerId") Long orderCustomerId){
|
||||||
|
orderPayCustomerService.removeById(orderCustomerId);
|
||||||
|
return Result.success(null,"操作成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过id获取客户
|
||||||
|
* @param orderCustomerId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@DeleteMapping("/{orderCustomerId}")
|
||||||
|
@Operation(summary = "通过id获取客户信息",description = "通过id获取客户信息")
|
||||||
|
public Result<OrderPayCustomer> findById(@PathVariable("orderCustomerId") Long orderCustomerId){
|
||||||
|
|
||||||
|
return Result.success(orderPayCustomerService.getById(orderCustomerId),"操作成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过Id禁用客户
|
||||||
|
* @param orderCustomerId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/disable/{orderCustomerId}")
|
||||||
|
@Operation(summary = "通过ID禁用客户", description = "通过ID禁用客户,禁用之后禁止调用支付相关接口")
|
||||||
|
public Result<String> disable(@PathVariable("orderCustomerId") Long orderCustomerId){
|
||||||
|
this.orderPayCustomerService.disable(orderCustomerId);
|
||||||
|
return Result.success(null,"操作成功");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 通过Id启用客户
|
||||||
|
* @param orderCustomerId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/enable/{orderCustomerId}")
|
||||||
|
@Operation(summary = "通过ID启用客户", description = "通过ID启用客户,启用之后可以进行支付相关接口的调用")
|
||||||
|
public Result<String> enable(@PathVariable("orderCustomerId") Long orderCustomerId){
|
||||||
|
this.orderPayCustomerService.enable(orderCustomerId);
|
||||||
|
return Result.success(null,"操作成功");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,4 +23,22 @@ public interface OrderPayCustomerService extends IService<OrderPayCustomer> {
|
||||||
public List<CustomerResp> selectList(CustomerListReq customerListReq);
|
public List<CustomerResp> selectList(CustomerListReq customerListReq);
|
||||||
|
|
||||||
List<String> getCustomerAllList();
|
List<String> getCustomerAllList();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 禁用客户
|
||||||
|
* @param orderCustomerId
|
||||||
|
*/
|
||||||
|
void disable(Long orderCustomerId);
|
||||||
|
/**
|
||||||
|
* 启用客户
|
||||||
|
* @param orderCustomerId
|
||||||
|
*/
|
||||||
|
void enable(Long orderCustomerId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过客户ID设置客户状态
|
||||||
|
* @param orderCustomerId
|
||||||
|
* @param status
|
||||||
|
*/
|
||||||
|
public void settingStatus(Long orderCustomerId,String status);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.bwie.cloud.pay.service.impl;
|
package com.bwie.cloud.pay.service.impl;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.bwie.cloud.pay.domain.OrderPayCustomer;
|
import com.bwie.cloud.pay.domain.OrderPayCustomer;
|
||||||
import com.bwie.cloud.pay.domain.OrderPayInfo;
|
import com.bwie.cloud.pay.domain.OrderPayInfo;
|
||||||
|
@ -10,16 +11,19 @@ import com.bwie.cloud.pay.mapper.OrderPayCustomerMapper;
|
||||||
import com.bwie.cloud.pay.service.OrderPayCustomerService;
|
import com.bwie.cloud.pay.service.OrderPayCustomerService;
|
||||||
import com.bwie.cloud.pay.service.OrderPayService;
|
import com.bwie.cloud.pay.service.OrderPayService;
|
||||||
import com.bwie.nacos.service.NacosServeService;
|
import com.bwie.nacos.service.NacosServeService;
|
||||||
|
import com.muyu.common.core.enums.SystemYseNo;
|
||||||
|
import com.muyu.common.core.exception.ServiceException;
|
||||||
|
import com.muyu.common.core.utils.DateUtils;
|
||||||
|
import com.muyu.common.core.utils.StringUtils;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.ArrayList;
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -88,4 +92,80 @@ public class OrderPayCustomerServiceImpl
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean save(OrderPayCustomer orderPayCustomer) {
|
||||||
|
String appCode = orderPayCustomer.getAppCode();
|
||||||
|
|
||||||
|
List<String> nacosServerAllList = nacosServeService.nacosServerAllList();
|
||||||
|
if (!nacosServerAllList.contains(appCode)){
|
||||||
|
throw new ServiceException("客户编码违法");
|
||||||
|
}
|
||||||
|
LambdaQueryWrapper<OrderPayCustomer> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(OrderPayCustomer::getAppCode ,appCode);
|
||||||
|
if (this.count(queryWrapper)>0){
|
||||||
|
throw new ServiceException("客户编码重复");
|
||||||
|
}
|
||||||
|
return super.save(orderPayCustomer);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 禁用客户
|
||||||
|
* @param orderCustomerId
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void disable(Long orderCustomerId) {
|
||||||
|
this.settingStatus(orderCustomerId, SystemYseNo.NO.getCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 启用客户
|
||||||
|
* @param orderCustomerId
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void enable(Long orderCustomerId) {
|
||||||
|
this.settingStatus(orderCustomerId, SystemYseNo.YES.getCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过客户ID设置客户状态
|
||||||
|
* @param orderCustomerId
|
||||||
|
* @param status
|
||||||
|
*/
|
||||||
|
public void settingStatus(Long orderCustomerId,String status){
|
||||||
|
LambdaQueryWrapper<OrderPayCustomer> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(OrderPayCustomer::getId, orderCustomerId);
|
||||||
|
boolean isExists = this.exists(queryWrapper);
|
||||||
|
if (!isExists){
|
||||||
|
throw new ServiceException("操作客户不存在");
|
||||||
|
}
|
||||||
|
if (!SystemYseNo.isCode(status)){
|
||||||
|
throw new ServiceException("设置状态值违法");
|
||||||
|
}
|
||||||
|
LambdaUpdateWrapper<OrderPayCustomer> updateWrapper = new LambdaUpdateWrapper<>();
|
||||||
|
|
||||||
|
updateWrapper.eq(OrderPayCustomer::getId, orderCustomerId);
|
||||||
|
updateWrapper.set(OrderPayCustomer::getStatus, status);
|
||||||
|
this.update(updateWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean removeById (Serializable id) {
|
||||||
|
OrderPayCustomer orderPayCustomer = this.getById(id);
|
||||||
|
if (orderPayCustomer == null) {
|
||||||
|
throw new ServiceException("客户不存在");
|
||||||
|
}
|
||||||
|
LambdaQueryWrapper<OrderPayInfo> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(OrderPayInfo::getAppCode, orderPayCustomer.getAppCode());
|
||||||
|
queryWrapper.gt(OrderPayInfo::getCreateTime, DateUtils.addDays(new Date(), -7));
|
||||||
|
long count = orderPayService.count(queryWrapper);
|
||||||
|
if (count > 0) {
|
||||||
|
throw new ServiceException(
|
||||||
|
StringUtils.format("客户:[{}], 近七天还在使用, 不可删除", orderPayCustomer.getAppName())
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
return super.removeById(id);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue