Commit ac41b26d by fudahua

企业门店初始化

parent fc98fd5b
......@@ -362,18 +362,43 @@ public class WxEnterpriseRelatedApiServiceImpl implements WxEnterpriseRelatedApi
}
}
@Override
public ServiceResponse flushBindStoreByEnterpriseId(String enterpriseId, String wxEnterpriseId, String optStaffId, int channalCode) {
ServiceResponse resp = new ServiceResponse();
String key = FLUSH_HAOBAN_BIND_STORE + enterpriseId;
Object cache = RedisUtil.getCache(key);
if (null != cache) {
logger.info("已经有人在操作刷新,不能同步操作:{},{}", enterpriseId, optStaffId);
resp.setCode(2);
resp.setMessage("有正在执行,不能同时操作");
return resp;
}
RedisUtil.setCache(key, wxEnterpriseId, 120L, TimeUnit.SECONDS);
/**
* 校验是否有同时执行 刷新企业
*
* @param enterpriseId
* @param wxEnterpriseId
* @return
*/
private boolean checkFlush(String enterpriseId, String wxEnterpriseId) {
String key = FLUSH_HAOBAN_BIND_STORE + enterpriseId;
String lockKey = FLUSH_HAOBAN_BIND_STORE + "lock:" + enterpriseId;
Object cache = RedisUtil.getCache(key);
if (null != cache) {
logger.info("已经有人在操作刷新,不能同步操作:{}", enterpriseId);
return false;
}
RedisUtil.lock(lockKey, 2L);
cache = RedisUtil.getCache(key);
if (null == cache) {
RedisUtil.setCache(key, wxEnterpriseId, 120L, TimeUnit.SECONDS);
RedisUtil.unlock(lockKey);
return true;
} else {
RedisUtil.unlock(lockKey);
return false;
}
}
@Override
public ServiceResponse flushBindStoreByEnterpriseId(String enterpriseId, String wxEnterpriseId, String optStaffId, int channalCode) {
ServiceResponse resp = new ServiceResponse();
String key = FLUSH_HAOBAN_BIND_STORE + enterpriseId;
//校验是否有同时执行
if (!checkFlush(enterpriseId, wxEnterpriseId)) {
resp.setCode(2);
resp.setMessage("有正在执行,不能同时操作");
return resp;
}
logger.info("刷新绑定门店:eid:{},staffid:{}", enterpriseId, optStaffId);
List<TabStoreRange> groupInfoDTOS = storeRangeService.queryAllBindRangeByEnterpriseId(enterpriseId);
......
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