feat(): 修复接口相关逻辑
parent
00dc5444aa
commit
e8792ab409
|
@ -116,4 +116,24 @@ public class OrderPayCustomerController {
|
||||||
public Result<OrderPayCustomer> findById(@PathVariable("orderCustomerId") Long orderCustomerId){
|
public Result<OrderPayCustomer> findById(@PathVariable("orderCustomerId") Long orderCustomerId){
|
||||||
return Result.success(orderPayCustomerService.getById(orderCustomerId), "操作成功");
|
return Result.success(orderPayCustomerService.getById(orderCustomerId), "操作成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过ID禁用客户
|
||||||
|
* @param orderCustomerId ID
|
||||||
|
* @return 禁用结果
|
||||||
|
*/
|
||||||
|
public Result<String> disable(@PathVariable("orderCustomerId") Long orderCustomerId){
|
||||||
|
this.orderPayCustomerService.disable(orderCustomerId);
|
||||||
|
return Result.success(null, "操作成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过ID启用客户
|
||||||
|
* @param orderCustomerId ID
|
||||||
|
* @return 启用结果
|
||||||
|
*/
|
||||||
|
public Result<String> enable(@PathVariable("orderCustomerId") Long orderCustomerId){
|
||||||
|
this.orderPayCustomerService.enable(orderCustomerId);
|
||||||
|
return Result.success(null, "操作成功");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,4 +27,23 @@ public interface OrderPayCustomerService extends IService<OrderPayCustomer> {
|
||||||
* @return 客户集合
|
* @return 客户集合
|
||||||
*/
|
*/
|
||||||
List<String> getCustomerAllList ();
|
List<String> getCustomerAllList ();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 禁用客户
|
||||||
|
* @param orderCustomerId 客户ID
|
||||||
|
*/
|
||||||
|
void disable (Long orderCustomerId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 启用客户
|
||||||
|
* @param orderCustomerId 客户ID
|
||||||
|
*/
|
||||||
|
void enable (Long orderCustomerId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过客户ID设置客户状态
|
||||||
|
* @param orderCustomerId ID
|
||||||
|
* @param status 状态 SysIsYesNo
|
||||||
|
*/
|
||||||
|
void settingStatus(Long orderCustomerId, String status);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.muyu.cloud.pay.service.impl;
|
package com.muyu.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.dtflys.forest.Forest;
|
import com.dtflys.forest.Forest;
|
||||||
import com.muyu.cloud.pay.domain.OrderPayCustomer;
|
import com.muyu.cloud.pay.domain.OrderPayCustomer;
|
||||||
|
@ -10,13 +11,17 @@ import com.muyu.cloud.pay.domain.resp.CustomerResp;
|
||||||
import com.muyu.cloud.pay.mapper.OrderPayCustomerMapper;
|
import com.muyu.cloud.pay.mapper.OrderPayCustomerMapper;
|
||||||
import com.muyu.cloud.pay.service.OrderPayCustomerService;
|
import com.muyu.cloud.pay.service.OrderPayCustomerService;
|
||||||
import com.muyu.cloud.pay.service.OrderPayService;
|
import com.muyu.cloud.pay.service.OrderPayService;
|
||||||
|
import com.muyu.common.core.enums.SystemYesNo;
|
||||||
import com.muyu.common.core.exception.ServiceException;
|
import com.muyu.common.core.exception.ServiceException;
|
||||||
|
import com.muyu.common.core.utils.DateUtils;
|
||||||
import com.muyu.common.core.utils.StringUtils;
|
import com.muyu.common.core.utils.StringUtils;
|
||||||
import com.muyu.common.nacos.service.NacosServerService;
|
import com.muyu.common.nacos.service.NacosServerService;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
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 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.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
@ -92,6 +97,65 @@ public class OrderPayCustomerServiceImpl
|
||||||
.toList();
|
.toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 禁用客户
|
||||||
|
*
|
||||||
|
* @param orderCustomerId 客户ID
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void disable (Long orderCustomerId) {
|
||||||
|
this.settingStatus(orderCustomerId, SystemYesNo.NO.getCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 启用客户
|
||||||
|
*
|
||||||
|
* @param orderCustomerId 客户ID
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void enable (Long orderCustomerId) {
|
||||||
|
this.settingStatus(orderCustomerId, SystemYesNo.YES.getCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过客户ID设置客户状态
|
||||||
|
* @param orderCustomerId ID
|
||||||
|
* @param status 状态 SysIsYesNo
|
||||||
|
*/
|
||||||
|
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 (!SystemYesNo.isCode(status)){
|
||||||
|
throw new ServiceException("设置状态值违法");
|
||||||
|
}
|
||||||
|
LambdaUpdateWrapper<OrderPayCustomer> updateWrapper = new LambdaUpdateWrapper<>();
|
||||||
|
updateWrapper.eq(OrderPayCustomer::getId, orderCustomerId);
|
||||||
|
updateWrapper.set(OrderPayCustomer::getStatus, status);
|
||||||
|
this.update(updateWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean save (OrderPayCustomer orderPayCustomer) {
|
public boolean save (OrderPayCustomer orderPayCustomer) {
|
||||||
String appCode = orderPayCustomer.getAppCode();
|
String appCode = orderPayCustomer.getAppCode();
|
||||||
|
|
Loading…
Reference in New Issue