给租户增加启用禁用功能

This commit is contained in:
季圣华
2021-07-06 22:24:17 +08:00
parent a176f417e4
commit 1db9b94599
12 changed files with 1108 additions and 1263 deletions

View File

@@ -264,17 +264,22 @@ public class DepotHeadService {
}
}
}
/**删除单据子表数据*/
try {
depotItemMapperEx.batchDeleteDepotItemByDepotHeadIds(new Long[]{id});
//更新当前库存
List<DepotItem> list = depotItemService.getListByHeaderId(id);
for (DepotItem depotItem : list) {
Long tenantId = redisService.getTenantId(request);
depotItemService.updateCurrentStock(depotItem, tenantId);
//对于零售出库单据,更新会员的预收款信息
if (BusinessConstants.DEPOTHEAD_TYPE_OUT.equals(depotHead.getType())
&& BusinessConstants.SUB_TYPE_TRANSFER.equals(depotHead.getSubType())){
if(BusinessConstants.PAY_TYPE_PREPAID.equals(depotHead.getPayType())) {
if (depotHead.getOrganId() != null) {
supplierService.updateAdvanceIn(depotHead.getOrganId(), depotHead.getTotalPrice().abs());
}
}
} catch (Exception e) {
JshException.writeFail(logger, e);
}
/**删除单据子表数据*/
depotItemMapperEx.batchDeleteDepotItemByDepotHeadIds(new Long[]{id});
//更新当前库存
List<DepotItem> list = depotItemService.getListByHeaderId(id);
for (DepotItem depotItem : list) {
Long tenantId = redisService.getTenantId(request);
depotItemService.updateCurrentStock(depotItem, tenantId);
}
/**删除单据主表信息*/
batchDeleteDepotHeadByIds(id.toString());

View File

@@ -8,6 +8,7 @@ import com.jsh.erp.datasource.mappers.TenantMapper;
import com.jsh.erp.datasource.mappers.TenantMapperEx;
import com.jsh.erp.exception.BusinessRunTimeException;
import com.jsh.erp.exception.JshException;
import com.jsh.erp.service.log.LogService;
import com.jsh.erp.utils.StringUtil;
import com.jsh.erp.utils.Tools;
import org.slf4j.Logger;
@@ -15,6 +16,8 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
@@ -30,6 +33,9 @@ public class TenantService {
@Resource
private TenantMapperEx tenantMapperEx;
@Resource
private LogService logService;
@Value("${tenant.userNumLimit}")
private Integer userNumLimit;
@@ -161,4 +167,28 @@ public class TenantService {
}
return tenant;
}
public int batchSetStatus(Boolean status, String ids)throws Exception {
int result=0;
try{
String statusStr ="";
if(status) {
statusStr ="批量启用";
} else {
statusStr ="批量禁用";
}
logService.insertLog("用户",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(ids).append("-").append(statusStr).toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
List<Long> idList = StringUtil.strToLongList(ids);
Tenant tenant = new Tenant();
tenant.setEnabled(status);
TenantExample example = new TenantExample();
example.createCriteria().andIdIn(idList);
result = tenantMapper.updateByExampleSelective(tenant, example);
}catch(Exception e){
JshException.writeFail(logger, e);
}
return result;
}
}

View File

@@ -295,6 +295,11 @@ public class UserService {
if(list.get(0).getStatus()!=0) {
return ExceptionCodeConstants.UserExceptionCode.BLACK_USER;
}
Long tenantId = list.get(0).getTenantId();
Tenant tenant = tenantService.getTenantByTenantId(tenantId);
if(tenant!=null && tenant.getEnabled()!=null && !tenant.getEnabled()) {
return ExceptionCodeConstants.UserExceptionCode.BLACK_TENANT;
}
}
} catch (Exception e) {
logger.error(">>>>>>>>访问验证用户姓名是否存在后台信息异常", e);