Commit 7e07f65b by 徐高华

导购成员关系并发控制

parent 2879f1ed
......@@ -28,7 +28,10 @@ public interface TabHaobanStaffClerkRelationMapper {
List<StaffClerkRelationDTO> listByClerkIds(@Param("clerkIds") List<String> clerkIds, @Param("wxEnterpriseId") String wxEnterpriseId);
StaffClerkRelationDTO getOneByStoreIdAndStaffId(@Param("storeId") String storeId, @Param("staffId") String staffId);
StaffClerkRelationDTO getByStaffAndClerk(@Param("staffId") String staffId,@Param("clerkId") String clerkId) ;
int changeStatusByClerkId(@Param("clerkId") String clerkId, @Param("status") Integer status);
//无效接口删除
......
......@@ -8,10 +8,12 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import com.gic.commons.util.DateUtil;
import com.gic.haoban.manage.service.entity.*;
import com.gic.redis.data.util.RedisUtil;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
......@@ -355,8 +357,16 @@ public class StaffClerkRelationServiceImpl implements StaffClerkRelationService
staffClerkRelation.setStatusFlag(1);
staffClerkRelation.setOpenConcatFlag(1);
staffClerkRelation.setManageFlag(manageFlag == null ? 0 : manageFlag);
TabHaobanStaffClerkRelation relation = EntityUtil.changeEntityByJSON(TabHaobanStaffClerkRelation.class, staffClerkRelation);
String lockKey = "staffclerk:"+staffClerkRelation.getStaffId()+staffClerkRelation.getClerkId() ;
RedisUtil.lock(lockKey, 2L, TimeUnit.SECONDS, 2L);
StaffClerkRelationDTO dto = this.mapper.getByStaffAndClerk(staffClerkRelation.getStaffId(),staffClerkRelation.getClerkId()) ;
if(null != dto) {
return dto.getStaffClerkRelationId() ;
}
mapper.insert(relation);
RedisUtil.unlock(lockKey);
return uuid;
}
......
......@@ -166,7 +166,7 @@
</select>
<select id="listByWxEnterpriseId" resultType="String">
<select id="listByWxEnterpriseId" resultType="java.lang.String">
select a.staff_id
from tab_haoban_staff_clerk_relation a left join tab_haoban_staff b on a.staff_id = b.staff_id
where a.wx_enterprise_id = #{wxEnterpriseId,jdbcType=VARCHAR}
......@@ -461,4 +461,11 @@
a.staff_id
</select>
<select id="getByStaffAndClerk" resultType="com.gic.haoban.manage.api.dto.StaffClerkRelationDTO">
<include refid="leftJoinStaffSQL" />
where a.status_flag=1 and b.status_flag=1
and a.staff_id = #{staffId} and a.clerk_id = #{clerkId}
order by a.update_time desc limit 1
</select>
</mapper>
\ No newline at end of file
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