String lockKey = "company_pickup_config:" + getCustomerNo() + ":" + getCurrentAccount().getCountryCode();
RLock lock = redissonClient.getLock(lockKey);
if (!lock.tryLock(3, 10, TimeUnit.SECONDS)) {
throw new BusinessException("操作过于频繁,请稍后重试");
}
try {
//查询客户配置是否存在
CompanyPickupConfig companyPickupConfig = companyPickupConfigMapper.selectOneByExample(Example.builder(CompanyPickupConfig.class).where(
WeekendSqls.<CompanyPickupConfig>custom().andEqualTo(CompanyPickupConfig::getCustomerCode, getCustomerNo())
.andEqualTo(CompanyPickupConfig::getCountryCode, getCurrentAccount().getCountryCode())
).build());
if(Objects.nonNull(companyPickupConfig)){
companyPickupConfig.setStatus(status);
companyPickupConfig.setUpdateBy(getCurrentName());
companyPickupConfig.setUpdateTime(DateUtils.getCurrentDate());
companyPickupConfigMapper.updateByPrimaryKeySelective(companyPickupConfig);
}else{
add(status);
}
} finally {
lock.unlock();
}