feat():修复接口相关逻辑
parent
cd8aa37ca2
commit
099dc126f9
|
@ -124,5 +124,26 @@ public class OrderPayCustomerController {
|
|||
return Result.success(orderPayCustomerService.getById(orderCustomerId),"操作成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过Id禁用客户
|
||||
* @param orderCustomerId
|
||||
* @return
|
||||
*/
|
||||
public Result<String> disable(@PathVariable("orderCustomerId") Long orderCustomerId){
|
||||
this.orderPayCustomerService.disable(orderCustomerId);
|
||||
return Result.success(null,"操作成功");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 通过Id启用客户
|
||||
* @param orderCustomerId
|
||||
* @return
|
||||
*/
|
||||
public Result<String> enable(@PathVariable("orderCustomerId") Long orderCustomerId){
|
||||
this.orderPayCustomerService.enable(orderCustomerId);
|
||||
return Result.success(null,"操作成功");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -28,4 +28,24 @@ public interface OrderPayCustomerService extends IService<OrderPayCustomer> {
|
|||
* @return
|
||||
*/
|
||||
List<String> getCustomerAllList();
|
||||
|
||||
/**
|
||||
* 禁用客户
|
||||
* @param orderCustomerId
|
||||
*/
|
||||
void disable(Long orderCustomerId);
|
||||
|
||||
/**
|
||||
* 启用客户
|
||||
* @param orderCustomerId
|
||||
*/
|
||||
void enable(Long orderCustomerId);
|
||||
|
||||
|
||||
/**
|
||||
* 通过看客户ID设置客户状态
|
||||
* @param orderCustomerId
|
||||
* @param status
|
||||
*/
|
||||
void settingStatus(Long orderCustomerId,String status);
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.muyu.cloud.pay.service.impl;
|
|||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
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.dtflys.forest.Forest;
|
||||
import com.muyu.cloud.pay.domin.OrderPayCustomer;
|
||||
|
@ -13,7 +14,9 @@ import com.muyu.cloud.pay.mapper.OrderPayCustomerMapper;
|
|||
import com.muyu.cloud.pay.service.OrderPayCustomerService;
|
||||
import com.muyu.cloud.pay.service.OrderPayService;
|
||||
import com.muyu.common.core.enums.SysPayType;
|
||||
import com.muyu.common.core.enums.SystemYesNo;
|
||||
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.nacos.service.NacosServerService;
|
||||
import io.jsonwebtoken.lang.Strings;
|
||||
|
@ -21,8 +24,10 @@ import lombok.extern.log4j.Log4j2;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.rmi.ServerException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
|
@ -86,6 +91,66 @@ public class OrderPayCustomerServiceImpl extends ServiceImpl<OrderPayCustomerMap
|
|||
}
|
||||
|
||||
|
||||
@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.le(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
|
||||
*/
|
||||
@Override
|
||||
public void disable(Long orderCustomerId) {
|
||||
this.settingStatus(orderCustomerId, SystemYesNo.No.getCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* 启用客户
|
||||
* @param orderCustomerId
|
||||
*/
|
||||
@Override
|
||||
public void enable(Long orderCustomerId) {
|
||||
this.settingStatus(orderCustomerId, SystemYesNo.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 (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
|
||||
public boolean save(OrderPayCustomer orderPayCustomer){
|
||||
|
||||
|
|
Loading…
Reference in New Issue