Commit 226b827d by jinxin

关联导购加锁防止并发问题

parent 38a6a537
...@@ -170,12 +170,19 @@ public class StaffClerkRelationApiServiceImpl implements StaffClerkRelationApiSe ...@@ -170,12 +170,19 @@ public class StaffClerkRelationApiServiceImpl implements StaffClerkRelationApiSe
@Override @Override
public ServiceResponse bindStaffClerk(StaffClerkRelationDTO staffClerkRelationDTO, String optStaffId, int channelCode) { public ServiceResponse bindStaffClerk(StaffClerkRelationDTO staffClerkRelationDTO, String optStaffId, int channelCode) {
//加锁防止并发问题
String clerkId = staffClerkRelationDTO.getClerkId();
String storeId = staffClerkRelationDTO.getStoreId();
String key = "haoban_bind_staff:" + clerkId+":"+storeId;
RedisUtil.lock(key, 6L);
ServiceResponse resp = this.bindCheck(staffClerkRelationDTO, optStaffId, channelCode); ServiceResponse resp = this.bindCheck(staffClerkRelationDTO, optStaffId, channelCode);
if (resp != null && !resp.isSuccess()) { if (resp != null && !resp.isSuccess()) {
logger.error("不允许绑定:{}", resp.getMessage()); logger.error("不允许绑定:{}", resp.getMessage());
RedisUtil.unlock(key);
return resp; return resp;
} }
String relationId = staffClerkRelationService.bind(staffClerkRelationDTO, optStaffId, channelCode); String relationId = staffClerkRelationService.bind(staffClerkRelationDTO, optStaffId, channelCode);
RedisUtil.unlock(key);
return ServiceResponse.success(relationId); return ServiceResponse.success(relationId);
} }
......
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