feat():添加禁用和启用接口

master
zhang chengzhi 2024-08-09 15:57:53 +08:00
parent 4e6cbfb409
commit b2c38d4c11
1 changed files with 16 additions and 23 deletions

View File

@ -7,12 +7,10 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.muyu.cloud.pay.domain.OrderPayCustomer;
import com.muyu.cloud.pay.domain.OrderPayInfo;
import com.muyu.cloud.pay.domain.req.CustomerListReq;
import com.muyu.cloud.pay.domain.resp.CustomerOrderPaySimpleResp;
import com.muyu.cloud.pay.domain.resp.CustomerResp;
import com.muyu.cloud.pay.mapper.OrderPayCustomerMapper;
import com.muyu.cloud.pay.service.OrderPayCustomerService;
import com.muyu.cloud.pay.service.OrderPayInfoService;
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.StringUtils;
@ -22,11 +20,8 @@ import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.rmi.ServerException;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
@ -70,7 +65,7 @@ public class OrderPayCustomerServiceImpl extends ServiceImpl<OrderPayCustomerMap
return orderPayCustomerList.stream()
.map(orderPayCustomer -> CustomerResp.customerBuild(
orderPayCustomer,
() -> orderPayService.selectOrderPayByAppAndLimit(orderPayCustomer.getAppCode(),5)
() -> orderPayService.selectOrderPayByAppAndLimit(orderPayCustomer.getAppCode(), 5)
.stream()
.map(OrderPayInfo::buildCustomerOrderPaySimpleResp)
.toList())
@ -96,7 +91,7 @@ public class OrderPayCustomerServiceImpl extends ServiceImpl<OrderPayCustomerMap
@Override //禁用客户
public void disable(Long orderCustomerId) {
this.settingStatus(orderCustomerId, SystemYesNo.NO.getCode());
this.settingStatus(orderCustomerId, SystemYesNo.NO.getCode());
}
@Override //启用客户
@ -104,9 +99,9 @@ this.settingStatus(orderCustomerId, SystemYesNo.NO.getCode());
this.settingStatus(orderCustomerId, SystemYesNo.YES.getCode());
}
public void settingStatus(Long orderCustomerId,String status){
public void settingStatus(Long orderCustomerId, String status) {
UpdateWrapper<OrderPayCustomer> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq("id",orderCustomerId).set("status",status);
updateWrapper.eq("id", orderCustomerId).set("status", status);
this.update(updateWrapper);
}
@ -116,22 +111,20 @@ this.settingStatus(orderCustomerId, SystemYesNo.NO.getCode());
String appCode = orderPayCustomer.getAppCode();
List<String> naocsServiceAllList = nacosServerService.naocsServiceAllList();
log.info("进行服务合法性判断:[{}-->{}]",appCode,naocsServiceAllList);
if (!naocsServiceAllList.contains(appCode)){
log.info("进行服务合法性判断:[{}-->{}]", appCode, naocsServiceAllList);
if (!naocsServiceAllList.contains(appCode)) {
throw new ServiceException("客户编码违法");
}
LambdaQueryWrapper<OrderPayCustomer> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(OrderPayCustomer::getAppCode,appCode);
queryWrapper.eq(OrderPayCustomer::getAppCode, appCode);
long isAppCodeOnly = this.count(queryWrapper);
log.info("进行服务code唯一性校验:[{}-{}]",appCode,isAppCodeOnly);
if (this.count(queryWrapper) >0){
log.info("进行服务code唯一性校验:[{}-{}]", appCode, isAppCodeOnly);
if (this.count(queryWrapper) > 0) {
throw new ServiceException("客户编码重复");
}
return super.save(orderPayCustomer);
}
}