Commit bbce4e14 by 徐高华

限制商户绑定多个企微

parent b426ea21
......@@ -15,6 +15,8 @@ public interface StaffMapper {
TabHaobanStaff selectByPrimaryKey(String staffId);
TabHaobanStaff selectByPrimaryKeyNoStatus(String staffId);
int updateByPrimaryKeySelective(TabHaobanStaff record);
TabHaobanStaff selectByNationcodeAndPhoneNumber(@Param("wxEnterpriseId") String wxEnterpriseId, @Param("nationCode") String nationcode, @Param("phoneNumber") String phoneNumber);
......
......@@ -10,6 +10,8 @@ public interface WxEnterpriseRelatedMapper {
int deleteByEnterpriseId(String enterpriseId) ;
int deleteById(String id) ;
int insertSelective(TabHaobanWxEnterpriseRelated record);
TabHaobanWxEnterpriseRelated selectByPrimaryKey(String wxEnterpriseRelatedId);
......
......@@ -11,6 +11,7 @@ import com.gic.haoban.manage.api.service.HandoverOperationApiService;
import com.gic.haoban.manage.api.service.WxEnterpriseApiService;
import com.gic.haoban.manage.service.config.Config;
import com.gic.haoban.manage.service.dao.mapper.HandoverStaffMapper;
import com.gic.haoban.manage.service.dao.mapper.StaffMapper;
import com.gic.haoban.manage.service.entity.TabHandoverExternal;
import com.gic.haoban.manage.service.entity.TabHandoverStaff;
import com.gic.haoban.manage.service.entity.TabHandoverTransfer;
......@@ -60,6 +61,8 @@ public class HandoverOperationApiServiceImpl implements HandoverOperationApiServ
private WxEnterpriseApiService wxEnterpriseApiService;
@Autowired
private StaffService staffService;
@Autowired
private StaffMapper staffMapper ;
@Override
......@@ -167,7 +170,7 @@ public class HandoverOperationApiServiceImpl implements HandoverOperationApiServ
}
transfers.forEach(dto -> {
try {
TabHaobanStaff handover = staffService.selectById(dto.getHandoverStaffId());
TabHaobanStaff handover = staffMapper.selectByPrimaryKeyNoStatus(dto.getHandoverStaffId());
TabHaobanStaff takeover = staffService.selectById(dto.getTakeoverStaffId());
if(null == handover) {
logger.info("handover is null={}",dto.getHandoverStaffId());
......
......@@ -22,6 +22,7 @@ import com.gic.haoban.common.utils.UuidUtil;
import com.gic.haoban.manage.api.dto.*;
import com.gic.haoban.manage.api.enums.ChannelCodeEnum;
import com.gic.haoban.manage.api.service.WxEnterpriseRelatedApiService;
import com.gic.haoban.manage.service.dao.mapper.WxEnterpriseMapper;
import com.gic.haoban.manage.service.dao.mapper.WxEnterpriseRelatedMapper;
import com.gic.haoban.manage.service.entity.*;
import com.gic.haoban.manage.service.service.DepartmentService;
......@@ -54,6 +55,8 @@ public class WxEnterpriseRelatedApiServiceImpl implements WxEnterpriseRelatedApi
@Autowired
private WxEnterpriseRelatedMapper wxEnterpriseRelatedMapper;
@Autowired
private WxEnterpriseMapper wxEnterpriseMapper ;
@Autowired
private WxEnterpriseRelatedService wxEnterpriseRelatedService;
@Autowired
private StoreGroupService storeGroupService;
......@@ -191,12 +194,26 @@ public class WxEnterpriseRelatedApiServiceImpl implements WxEnterpriseRelatedApi
return details;
}
// @Override
// public List<EnterpriseDetailDTO> queryBindGicEnterpriseByTime(String seqTime) {
// List<TabHaobanWxEnterpriseRelated> list = wxEnterpriseRelatedMapper.listEnterpriseByTime(seqTime);
// List<EnterpriseDetailDTO> details = EntityUtil.changeEntityListByJSON(EnterpriseDetailDTO.class, list);
// return details;
// }
private String isBindMany(String enterpriseId , String wxEnterpriseId) {
List<TabHaobanWxEnterpriseRelated> list = this.wxEnterpriseRelatedMapper.listByEnterpriseId(enterpriseId) ;
List<String> bindNameList = new ArrayList<>() ;
if(CollectionUtils.isNotEmpty(list)) {
for(TabHaobanWxEnterpriseRelated item : list) {
TabHaobanWxEnterprise wxEnterprise = this.wxEnterpriseMapper.selectByPrimaryKey(item.getWxEnterpriseId()) ;
if(null == wxEnterprise || 0 == wxEnterprise.getStatusFlag()) {
this.wxEnterpriseRelatedMapper.deleteById(item.getWxEnterpriseRelatedId()) ;
} else {
if(!item.getWxEnterpriseId().equals(wxEnterpriseId)) {
bindNameList.add(wxEnterprise.getCorpName()) ;
}
}
}
if(CollectionUtils.isNotEmpty(bindNameList)) {
return bindNameList.stream().collect(Collectors.joining("、"));
}
}
return null ;
}
@Transactional(rollbackFor = Exception.class)
@Override
......@@ -220,6 +237,13 @@ public class WxEnterpriseRelatedApiServiceImpl implements WxEnterpriseRelatedApi
String wxEnterpriseId = detailDTO.getWxEnterpriseId();
//校验关联已经企业绑定
TabHaobanWxEnterpriseRelated tab = wxEnterpriseRelatedMapper.findOneByEIdAndWxEid(enterpriseId, wxEnterpriseId);
String bindMany = this.isBindMany(enterpriseId , wxEnterpriseId) ;
if(StringUtils.isNotBlank(bindMany)) {
logger.info("一GIC商户绑不能绑定多个");
resp.setCode(2);
resp.setMessage("商户不能绑多个企微("+bindMany+")");
return resp;
}
if (tab != null && (!tab.getWxEnterpriseRelatedId().equals(detailDTO.getWxEnterpriseRelatedId()))) {
logger.info("该企业已经被绑定过");
resp.setCode(2);
......
......@@ -45,6 +45,13 @@
where staff_id = #{staffId,jdbcType=VARCHAR} and status_flag = 1
</select>
<select id="selectByPrimaryKeyNoStatus" resultMap="BaseResultMap" parameterType="java.lang.String">
select
<include refid="Base_Column_List"/>
from tab_haoban_staff
where staff_id = #{staffId,jdbcType=VARCHAR}
</select>
<update id="delOtherStaffByWxUserId">
update tab_haoban_staff
......
......@@ -31,7 +31,10 @@
<update id="deleteByEnterpriseId">
update tab_haoban_wx_enterprise_related set status_flag = 0 , update_time=now() where enterprise_id=#{enterpriseId} and status_flag=1
</update>
<update id="deleteById">
update tab_haoban_wx_enterprise_related set status_flag = 0 , update_time=now() where wx_enterprise_related_id=#{id} and status_flag=1
</update>
<insert id="insertSelective" parameterType="com.gic.haoban.manage.service.entity.TabHaobanWxEnterpriseRelated">
insert into tab_haoban_wx_enterprise_related
......
......@@ -38,7 +38,7 @@ public class ChatTest {
@Test
public void test() {
this.handoverOperationApiService.dealQywxEnterpriseHandover("ca66a01b79474c40b3e7c7f93daf1a3b") ;
this.handoverOperationApiService.dealQywxEnterpriseHandoverMq("ca66a01b79474c40b3e7c7f93daf1a3b") ;
}
@Test
......
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