Commit 99047dbe by 徐高华

并发控制

parent 7e07f65b
......@@ -363,6 +363,7 @@ public class StaffClerkRelationServiceImpl implements StaffClerkRelationService
RedisUtil.lock(lockKey, 2L, TimeUnit.SECONDS, 2L);
StaffClerkRelationDTO dto = this.mapper.getByStaffAndClerk(staffClerkRelation.getStaffId(),staffClerkRelation.getClerkId()) ;
if(null != dto) {
RedisUtil.unlock(lockKey);
return dto.getStaffClerkRelationId() ;
}
mapper.insert(relation);
......
......@@ -20,6 +20,7 @@ import com.gic.haoban.manage.service.entity.fee.TabHaobanQywxFeeAccountStaff;
import com.gic.haoban.manage.service.pojo.bo.StaffListBO;
import com.gic.haoban.manage.service.service.StaffService;
import com.gic.haoban.manage.service.service.fee.HaobanQywxFeeAccountStaffService;
import com.gic.redis.data.util.RedisUtil;
import com.gic.wechat.api.dto.qywx.fee.AccountListDTO;
import com.gic.wechat.api.dto.qywx.fee.AccountListResponseDTO;
import com.gic.wechat.api.dto.qywx.fee.ActiveInfoUserResponseDTO;
......@@ -34,6 +35,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
@Service
......@@ -83,7 +85,15 @@ public class StaffServiceImpl implements StaffService {
}
tab.setStatusFlag(1);
tab.setAddNum(0);
String lockKey = "tabstaff:"+tab.getWxEnterpriseId()+tab.getWxUserId() ;
RedisUtil.lock(lockKey,2l, TimeUnit.SECONDS,2l);
TabHaobanStaff staff = this.mapper.selectByUserIdAndEnterpriseId(tab.getWxUserId(),tab.getWxEnterpriseId()) ;
if(null != staff) {
RedisUtil.unlock(lockKey);
return staff.getStaffId() ;
}
mapper.insertSelective(tab);
RedisUtil.unlock(lockKey);
return tab.getStaffId();
}
......
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