Sfoglia il codice sorgente

删除客户员工间关系

xueyiming 6 mesi fa
parent
commit
3f1575830e

+ 5 - 9
we-com-server/src/main/java/com/tzld/piaoquan/wecom/job/WeComHistoryDataJob1.java

@@ -12,6 +12,7 @@ import com.tzld.piaoquan.wecom.model.po.*;
 import com.tzld.piaoquan.wecom.service.AccessTokenService;
 import com.tzld.piaoquan.wecom.service.HistoryMessageService;
 import com.tzld.piaoquan.wecom.service.MessageAttachmentService;
+import com.tzld.piaoquan.wecom.service.UserService;
 import com.tzld.piaoquan.wecom.utils.*;
 import com.tzld.piaoquan.wecom.utils.page.Page;
 import com.xxl.job.core.biz.model.ReturnT;
@@ -56,6 +57,9 @@ public class WeComHistoryDataJob1 {
     @Autowired
     private StaffWithUserMapper staffWithUserMapper;
 
+    @Autowired
+    private UserService userService;
+
 
     @XxlJob("saveHistoryMessageJob1")
     public ReturnT<String> selectHistoryMessageByDay(String param) {
@@ -289,15 +293,7 @@ public class WeComHistoryDataJob1 {
                 historyMessage.setCreateTime(new Date(createTime * 1000));
                 historyMessageList.add(historyMessage);
                 if (status == 2) {
-                    StaffWithUserExample example = new StaffWithUserExample();
-                    example.createCriteria().andUserIdEqualTo(userId).andStaffIdEqualTo(staff.getId());
-                    List<StaffWithUser> staffWithUserList = staffWithUserMapper.selectByExample(example);
-                    if (CollectionUtils.isEmpty(staffWithUserList)) {
-                        continue;
-                    }
-                    StaffWithUser staffWithUser = staffWithUserList.get(0);
-                    staffWithUser.setIsDelete(1);
-                    staffWithUserMapper.updateByPrimaryKeySelective(staffWithUser);
+                    userService.delStaffWithUser(userId, staff.getId(), createTime);
                 }
             }
         }

+ 20 - 0
we-com-server/src/main/java/com/tzld/piaoquan/wecom/service/Impl/UserServiceImpl.java

@@ -19,6 +19,7 @@ import org.springframework.util.CollectionUtils;
 
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 
 import static com.tzld.piaoquan.wecom.common.constant.WeComConstant.GET_WE_COM_EXTERNAL_CONTACT_GET;
@@ -155,10 +156,29 @@ public class UserServiceImpl implements UserService {
             return;
         }
         StaffWithUser staffWithUser = staffWithUserList.get(0);
+        staffWithUser.setDeleteTime(new Date());
         staffWithUser.setIsDelete(1);
         staffWithUserMapper.updateByPrimaryKeySelective(staffWithUser);
     }
 
+    @Override
+    public void delStaffWithUser(Long userId, Long staffId, Long deleteTime) {
+        if (userId == null || staffId == null) {
+            return;
+        }
+        StaffWithUserExample example = new StaffWithUserExample();
+        example.createCriteria().andStaffIdEqualTo(staffId).andUserIdEqualTo(userId);
+        List<StaffWithUser> staffWithUserList = staffWithUserMapper.selectByExample(example);
+        if (CollectionUtils.isEmpty(staffWithUserList) || staffWithUserList.get(0).getIsDelete() == 1) {
+            return;
+        }
+        StaffWithUser staffWithUser = staffWithUserList.get(0);
+        staffWithUser.setDeleteTime(new Date(deleteTime * 1000));
+        staffWithUser.setIsDelete(1);
+        staffWithUserMapper.updateByPrimaryKeySelective(staffWithUser);
+    }
+
+
     private Staff getStaff(String carrierId) {
         StaffExample example = new StaffExample();
         example.createCriteria().andCarrierIdEqualTo(carrierId);

+ 2 - 0
we-com-server/src/main/java/com/tzld/piaoquan/wecom/service/UserService.java

@@ -11,4 +11,6 @@ public interface UserService {
     void insertStaffWithUser(String externalUserId, Staff staff);
 
     void delStaffWithUser(String externalUserId, String staffUserId);
+
+    void delStaffWithUser(Long userId, Long staffId, Long deleteTime);
 }