Commit 80a45059 by 陶光胜

门店加锁

parent f04cdee7
......@@ -99,7 +99,6 @@ public class ClerkApiServiceImpl implements ClerkApiService {
try {
RedisUtil.lock("enterprise:clerk:position:" + clerkDTO.getStoreInfoId(), 3L, TimeUnit.SECONDS, 3L);
if (clerkService.isRepeatByClerkCode(clerkDTO.getStoreInfoId(), clerkDTO.getClerkCode(), clerkDTO.getClerkId())) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "门店下导购代码重复");
}
......@@ -107,6 +106,7 @@ public class ClerkApiServiceImpl implements ClerkApiService {
// 如果门店下已经存在有导购是店长, 并且当前导购是店长 则做替换
// 如果门店下没有导购是店长,将当前导购设置成店长
// 这里并发会出错 加个锁
RedisUtil.lock("enterprise:clerk:position:" + clerkDTO.getStoreInfoId(), 3L, TimeUnit.SECONDS, 3L);
TabClerk clerkLeader = clerkService.getClerkLeaderByStoreInfoId(clerkDTO.getEnterpriseId(), clerkDTO.getStoreInfoId());
if (clerkLeader != null) {
......
......@@ -183,21 +183,29 @@ public class StoreApiServiceImpl implements StoreApiService {
// 记录门店日志
saveAddLog(storeDTO);
} else {
ServiceResponse<StoreDTO> existStore = this.getStoreById(storeDTO.getEnterpriseId(), storeDTO.getStoreId());
storeDTO.setStoreInfoId(existStore.getResult().getStoreInfoId());
storeDTO.setStatus(existStore.getResult().getStatus());
Integer update = storeService.update(storeDTO);
if (update == 0) {
return ServiceResponse.failure(ErrorCode.NOTEXISTS.getCode(), ErrorCode.NOTEXISTS.getMsg());
}
// 记录门店日志
try {
saveUpdateLog(existStore.getResult(), storeDTO);
} catch (Exception e) {
logger.warn("门店编辑日志记录错误", e);
String lock = "lock:"+ storeDTO.getEnterpriseId() + ":" + storeDTO.getStoreId();
RedisUtil.lock(lock, 500l, TimeUnit.MILLISECONDS, 500l);
try{
ServiceResponse<StoreDTO> existStore = this.getStoreById(storeDTO.getEnterpriseId(), storeDTO.getStoreId());
storeDTO.setStoreInfoId(existStore.getResult().getStoreInfoId());
storeDTO.setStatus(existStore.getResult().getStatus());
Integer update = storeService.update(storeDTO);
if (update == 0) {
return ServiceResponse.failure(ErrorCode.NOTEXISTS.getCode(), ErrorCode.NOTEXISTS.getMsg());
}
// 记录门店日志
try {
saveUpdateLog(existStore.getResult(), storeDTO);
} catch (Exception e) {
logger.warn("门店编辑日志记录错误", e);
}
//修改门店同步到微盟
updateStoreToWm(storeDTO);
}catch (Exception e){
logger.warn("门店更新异常", e);
}finally {
RedisUtil.unlock(lock);
}
//修改门店同步到微盟
updateStoreToWm(storeDTO);
}
// 自定义属性
String error = storeExtendService.saveOrUpdate(storeDTO.getEnterpriseId(), storeDTO.getStoreInfoId(), storeDTO.getStoreExtendList());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment