Przeglądaj źródła

Merge branch 'test-wks' into test

wks 1 rok temu
rodzic
commit
ed81309469

+ 0 - 16
src/main/java/com/ydtech/modules/admin/model/po/SysWechatCustomer.java

@@ -64,26 +64,10 @@ public class SysWechatCustomer implements Serializable {
      */
     @TableField("open_kf_id")
     private String openKfId;
-    /**
-     * 值班客服
-     */
-    @TableField(value = "duty_customer_id")
-    private long dutyCustomerId;
 
     @TableField(exist = false)
     private static final long serialVersionUID = 1L;
 
-    public SysWechatCustomer(long id, String nickname, String avatar, String userId, String receptionist, String receptionistId, String openKfId, long dutyCustomerId) {
-        this.id = id;
-        this.nickname = nickname;
-        this.avatar = avatar;
-        this.userId = userId;
-        this.receptionist = receptionist;
-        this.receptionistId = receptionistId;
-        this.openKfId = openKfId;
-        this.dutyCustomerId = dutyCustomerId;
-    }
-
     public SysWechatCustomer(SysWechatCustomerAddVo sysWechatCustomerAddVo) {
         this.nickname = sysWechatCustomerAddVo.getNickname();
         this.avatar = sysWechatCustomerAddVo.getAvatar();

+ 13 - 9
src/main/java/com/ydtech/modules/admin/model/po/SysWechatCustomerDuty.java

@@ -4,21 +4,21 @@ import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
-import java.io.Serializable;
-import java.time.LocalDateTime;
-import java.util.Date;
-
 import com.ydtech.modules.admin.model.vo.wechat.SysWechatCustomerDutyRulesVo;
 import com.ydtech.utils.DateTimeUtil;
 import lombok.AllArgsConstructor;
 import lombok.Data;
 import lombok.NoArgsConstructor;
 
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
 /**
  * 微信客服值班时间
+ *
  * @TableName sys_wechat_customer_duty
  */
-@TableName(value ="sys_wechat_customer_duty")
+@TableName(value = "sys_wechat_customer_duty")
 @AllArgsConstructor
 @NoArgsConstructor
 @Data
@@ -28,19 +28,21 @@ public class SysWechatCustomerDuty implements Serializable {
      */
     @TableId(value = "id", type = IdType.AUTO)
     private long id;
-
+    /**
+     * 值班客服
+     */
+    @TableField(value = "duty_customer_id")
+    private long dutyCustomerId;
     /**
      * 值班开始时间
      */
     @TableField(value = "start_time")
     private LocalDateTime startTime;
-
     /**
      * 值班结束时间
      */
     @TableField(value = "end_time")
     private LocalDateTime endTime;
-
     /**
      * 客服id
      */
@@ -51,9 +53,11 @@ public class SysWechatCustomerDuty implements Serializable {
     private static final long serialVersionUID = 1L;
 
 
-    public SysWechatCustomerDuty(long customerId, SysWechatCustomerDutyRulesVo.DutyDateTime dutyDateTime) {
+    public SysWechatCustomerDuty(long customerId, long dutyCustomerId, SysWechatCustomerDutyRulesVo.DutyDateTime dutyDateTime) {
         this.startTime = DateTimeUtil.parseLocalDateTime(dutyDateTime.getStartTime(), DateTimeUtil.DATETIME_PATTERN);
         this.endTime = DateTimeUtil.parseLocalDateTime(dutyDateTime.getEndTime(), DateTimeUtil.DATETIME_PATTERN);
         this.customerId = customerId;
+        this.dutyCustomerId = dutyCustomerId;
     }
+
 }

+ 35 - 3
src/main/java/com/ydtech/modules/admin/model/vo/wechat/SysWechatCustomerDutyRulesVo.java

@@ -1,15 +1,22 @@
 package com.ydtech.modules.admin.model.vo.wechat;
 
+import com.ydtech.modules.admin.model.po.SysWechatCustomerDuty;
+import com.ydtech.utils.DateTimeUtil;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
 import lombok.Data;
+import lombok.NoArgsConstructor;
 
 import javax.validation.constraints.NotBlank;
 import java.io.Serializable;
 import java.util.List;
+import java.util.stream.Collectors;
 
 @Data
 @ApiModel("值班规则配置")
+@AllArgsConstructor
+@NoArgsConstructor
 public class SysWechatCustomerDutyRulesVo implements Serializable {
 
     private static final long serialVersionUID = 5313784741514176124L;
@@ -18,13 +25,34 @@ public class SysWechatCustomerDutyRulesVo implements Serializable {
     private String customerId;
 
     @ApiModelProperty("值班客服")
-    private String dutyCustomerId;
+    private List<DutyCustomerDTO> dutyCustomerDTOS;
 
-    @ApiModelProperty("值班规则列表")
-    private List<DutyDateTime> dutyDateTimeList;
+    @Data
+    @ApiModel("值班客服")
+    @AllArgsConstructor
+    @NoArgsConstructor
+    public static class DutyCustomerDTO implements Serializable {
+
+        private static final long serialVersionUID = -6002812616686817550L;
+
+        @ApiModelProperty("值班客服")
+        @NotBlank(message = "值班客服不能为空")
+        private String dutyCustomerId;
+
+        @ApiModelProperty("值班规则列表")
+        private List<DutyDateTime> dutyDateTimeList;
+
+        public DutyCustomerDTO(Long dutyCustomerId, List<SysWechatCustomerDuty> sysWechatCustomerDuties) {
+            this.dutyCustomerId = dutyCustomerId.toString();
+            this.dutyDateTimeList = sysWechatCustomerDuties.stream().map(DutyDateTime::new).collect(Collectors.toList());
+        }
+
+    }
 
     @Data
     @ApiModel("值班时间")
+    @AllArgsConstructor
+    @NoArgsConstructor
     public static class DutyDateTime implements Serializable {
 
         private static final long serialVersionUID = -633472086045531848L;
@@ -37,6 +65,10 @@ public class SysWechatCustomerDutyRulesVo implements Serializable {
         @ApiModelProperty("结束时间")
         private String endTime;
 
+        public DutyDateTime(SysWechatCustomerDuty sysWechatCustomerDuty) {
+            this.startTime = DateTimeUtil.localDateTimetoString(sysWechatCustomerDuty.getStartTime());
+            this.endTime = DateTimeUtil.localDateTimetoString(sysWechatCustomerDuty.getEndTime());
+        }
     }
 
 }

+ 25 - 3
src/main/java/com/ydtech/modules/admin/model/vo/wechat/SysWechatCustomerVo.java

@@ -3,8 +3,12 @@ package com.ydtech.modules.admin.model.vo.wechat;
 import com.baomidou.mybatisplus.annotation.TableField;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
 import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.springframework.util.CollectionUtils;
 
+import java.util.ArrayList;
 import java.util.List;
 
 @Data
@@ -39,9 +43,27 @@ public class SysWechatCustomerVo {
     private String receptionistId;
 
     @ApiModelProperty("值班客服")
-    private String dutyCustomer;
+    private List<DutyCustomerDTO> dutyCustomerDTO;
 
-    @ApiModelProperty("值班时间")
-    private List<String> dutyDatetime;
+    @Data
+    @AllArgsConstructor
+    @NoArgsConstructor
+    @ApiModel("值班客服")
+    public static class DutyCustomerDTO {
+
+        @ApiModelProperty("值班客服")
+        private String dutyCustomer;
+
+        @ApiModelProperty("值班时间")
+        private List<String> dutyDatetime;
+
+    }
+
+    public List<DutyCustomerDTO> getDutyCustomerDTO() {
+        if(CollectionUtils.isEmpty(dutyCustomerDTO)){
+            dutyCustomerDTO = new ArrayList<>();
+        }
+        return dutyCustomerDTO;
+    }
 
 }

+ 8 - 0
src/main/java/com/ydtech/modules/admin/service/SysWechatCustomerDutyService.java

@@ -2,6 +2,7 @@ package com.ydtech.modules.admin.service;
 
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.ydtech.exception.SystemException;
 import com.ydtech.modules.admin.model.po.SysWechatCustomer;
 import com.ydtech.modules.admin.model.po.SysWechatCustomerDuty;
 import com.ydtech.modules.admin.model.vo.wechat.SysWechatCustomerDutyRulesVo;
@@ -32,4 +33,11 @@ public interface SysWechatCustomerDutyService extends IService<SysWechatCustomer
         return list(wr);
     }
 
+    default void isDutyCustomerId(Long customerId) {
+        List<SysWechatCustomerDuty> list = lambdaQuery().eq(SysWechatCustomerDuty::getDutyCustomerId, customerId).list();
+        if (!list.isEmpty()) {
+            throw new SystemException("此客服还在值班客服中配置,请删除后重试");
+        }
+    }
+
 }

+ 1 - 7
src/main/java/com/ydtech/modules/admin/service/SysWechatCustomerService.java

@@ -67,13 +67,7 @@ public interface SysWechatCustomerService extends BaseIService<SysWechatCustomer
         }
     }
 
-    default void isDutyCustomerId(Long customerId) {
-        List<SysWechatCustomer> list = lambdaQuery().eq(SysWechatCustomer::getDutyCustomerId, customerId).list();
-        if (!list.isEmpty()) {
-            throw new SystemException("此客服还在值班客服中配置,请删除后重试");
-        }
-    }
 
-    void getCacheCustomerId(SysWechatCustomer sysWechatCustomer);
+    SysWechatCustomer getCacheCustomerId(SysWechatCustomer sysWechatCustomer);
 
 }

+ 42 - 19
src/main/java/com/ydtech/modules/admin/service/impl/SysWechatCustomerBusinessServiceImpl.java

@@ -26,7 +26,6 @@ import me.chanjar.weixin.cp.bean.WxCpBaseResp;
 import me.chanjar.weixin.cp.bean.WxCpDepart;
 import me.chanjar.weixin.cp.bean.WxCpUser;
 import me.chanjar.weixin.cp.bean.kf.*;
-import org.springframework.data.redis.core.StringRedisTemplate;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 import org.springframework.util.ObjectUtils;
@@ -65,11 +64,10 @@ public class SysWechatCustomerBusinessServiceImpl implements SysWechatCustomerBu
                 .collect(Collectors.toList());
         Map<String, List<SysWechatCustomerDeptVo>> parentGroup = deptVos.stream()
                 .collect(Collectors.groupingBy(SysWechatCustomerDeptVo::getParentId));
-        Set<String> strings = parentGroup.keySet();
-
+        List<String> collect = deptVos.stream().map(SysWechatCustomerDeptVo::getDeptId).collect(Collectors.toList());
         deptVos.forEach(node -> node.setChildDept(parentGroup.getOrDefault(node.getDeptId(), Collections.emptyList())));
         return deptVos.stream()
-                .filter(node -> node.getParentId() != null && strings.contains(node.getDeptId()))
+                .filter(node -> node.getParentId() != null && !collect.contains(node.getParentId()))
                 .collect(Collectors.toList());
     }
 
@@ -100,12 +98,33 @@ public class SysWechatCustomerBusinessServiceImpl implements SysWechatCustomerBu
             // 设置值班时间
             sysWechatCustomerVoPageInfo.getList().forEach(sysWechatCustomerVo -> {
                 List<SysWechatCustomerDuty> sysWechatCustomerDuties = dutyMap.get(Long.valueOf(sysWechatCustomerVo.getId()));
-                if (!CollectionUtils.isEmpty(sysWechatCustomerDuties)) {
-                    List<String> collect = sysWechatCustomerDuties.stream()
+                if(CollectionUtils.isEmpty(sysWechatCustomerDuties)){
+                    return;
+                }
+
+                Map<Long, List<SysWechatCustomerDuty>> collect = sysWechatCustomerDuties.stream()
+                        .collect(Collectors.groupingBy(SysWechatCustomerDuty::getDutyCustomerId));
+
+                Map<Long, SysWechatCustomer> collect2 = sysWechatCustomerService.lambdaQuery()
+                        .in(SysWechatCustomer::getId, collect.keySet())
+                        .list()
+                        .stream()
+                        .collect(Collectors.toMap(SysWechatCustomer::getId, x -> x));
+
+                collect.keySet().forEach(sysWechatCustomerVoId -> {
+                    SysWechatCustomerVo.DutyCustomerDTO dutyCustomerDTO = new SysWechatCustomerVo.DutyCustomerDTO();
+                    List<SysWechatCustomerDuty> sysWechatCustomerDuties1 = collect.get(sysWechatCustomerVoId);
+                    List<String> collect1 = sysWechatCustomerDuties1.stream()
                             .map(x -> DateTimeUtil.startAndEndTimeFormatting(x.getStartTime(), x.getEndTime()))
                             .collect(Collectors.toList());
-                    sysWechatCustomerVo.setDutyDatetime(collect);
-                }
+                    SysWechatCustomer sysWechatCustomer = collect2.get(sysWechatCustomerVoId);
+                    if(!ObjectUtils.isEmpty(sysWechatCustomer)) {
+                        dutyCustomerDTO.setDutyCustomer(sysWechatCustomer.getNickname());
+                    }
+                    dutyCustomerDTO.setDutyDatetime(collect1);
+                    sysWechatCustomerVo.getDutyCustomerDTO().add(dutyCustomerDTO);
+                });
+
             });
         }
 
@@ -158,7 +177,7 @@ public class SysWechatCustomerBusinessServiceImpl implements SysWechatCustomerBu
     @Override
     public void deleteWechatCustomer(String customerId) throws WxErrorException {
         SysWechatCustomer sysWechatCustomer = sysWechatCustomerService.getByIdExist(customerId, "客服不存在");
-        sysWechatCustomerService.isDutyCustomerId(sysWechatCustomer.getId());
+        sysWechatCustomerDutyService.isDutyCustomerId(sysWechatCustomer.getId());
         WxCpKfAccountDel wxCpKfAccountDel = new WxCpKfAccountDel();
         wxCpKfAccountDel.setOpenKfid(sysWechatCustomer.getOpenKfId());
         WxCpBaseResp wxCpBaseResp;
@@ -172,7 +191,7 @@ public class SysWechatCustomerBusinessServiceImpl implements SysWechatCustomerBu
     @Override
     public void updateWechatCustomer(String customerId, SysWechatCustomerAddVo sysWechatCustomerAddVo) throws WxErrorException {
         SysWechatCustomer sysWechatCustomer = sysWechatCustomerService.getByIdExist(customerId, "客服不存在");
-        if(!sysWechatCustomer.getNickname().equals(sysWechatCustomerAddVo.getNickname())){
+        if (!sysWechatCustomer.getNickname().equals(sysWechatCustomerAddVo.getNickname())) {
             sysWechatCustomerService.isNicknameRepeat(sysWechatCustomerAddVo.getNickname());
         }
         WxCpKfAccountUpd wxCpKfAccountUpd = new WxCpKfAccountUpd();
@@ -221,13 +240,16 @@ public class SysWechatCustomerBusinessServiceImpl implements SysWechatCustomerBu
 
     @Override
     public String getWeChatCustomer(SysUser user) throws WxErrorException {
-        SysWechatCustomer sysWechatCustomer = sysWechatCustomerService.getByUserId(user.getLeaderId());
-        List<SysWechatCustomer> sysWechatCustomerList = sysWechatCustomerService.list();
-        List<Long> sysWechatCustomerIdList = sysWechatCustomerList.stream()
-                .map(SysWechatCustomer::getId)
-                .collect(Collectors.toList());
+        SysWechatCustomer sysWechatCustomer = null;
+        if(!ObjectUtils.isEmpty(user)){
+             sysWechatCustomer = sysWechatCustomerService.getByUserId(user.getLeaderId());
+        }
         if (ObjectUtils.isEmpty(sysWechatCustomer)) {
             // 获取最近一次的客服记录
+            List<SysWechatCustomer> sysWechatCustomerList = sysWechatCustomerService.list();
+            List<Long> sysWechatCustomerIdList = sysWechatCustomerList.stream()
+                    .map(SysWechatCustomer::getId)
+                    .collect(Collectors.toList());
             SysWechatCustomerRecording sysWechatCustomerRecording = sysWechatCustomerRecordingService.lambdaQuery()
                     .in(!sysWechatCustomerIdList.isEmpty(), SysWechatCustomerRecording::getCustomerId, sysWechatCustomerIdList)
                     .eq(SysWechatCustomerRecording::getUserId, user.getId())
@@ -235,14 +257,14 @@ public class SysWechatCustomerBusinessServiceImpl implements SysWechatCustomerBu
                     .last("limit 1")
                     .one();
             if (ObjectUtils.isEmpty(sysWechatCustomerRecording)) {
-                sysWechatCustomerService.getCacheCustomerId(sysWechatCustomer);
+                sysWechatCustomer = sysWechatCustomerService.getCacheCustomerId(sysWechatCustomer);
             } else {
                 // 使用上一次的客服
                 sysWechatCustomer = sysWechatCustomerService.lambdaQuery()
                         .eq(SysWechatCustomer::getId, sysWechatCustomerRecording.getCustomerId())
                         .one();
                 if (ObjectUtils.isEmpty(sysWechatCustomer)) {
-                    sysWechatCustomerService.getCacheCustomerId(sysWechatCustomer);
+                    sysWechatCustomer = sysWechatCustomerService.getCacheCustomerId(sysWechatCustomer);
                 }
             }
             SysWechatCustomerRecording customerRecording = new SysWechatCustomerRecording();
@@ -256,8 +278,9 @@ public class SysWechatCustomerBusinessServiceImpl implements SysWechatCustomerBu
                 .le(SysWechatCustomerDuty::getStartTime, LocalDateTime.now())
                 .ge(SysWechatCustomerDuty::getEndTime, LocalDateTime.now())
                 .list();
-        if (sysWechatCustomer.getDutyCustomerId() > 0 && list != null && !list.isEmpty()) {
-            sysWechatCustomer = sysWechatCustomerService.getById(sysWechatCustomer.getDutyCustomerId());
+        if (list != null && !list.isEmpty()) {
+            SysWechatCustomerDuty sysWechatCustomerDuty = list.get(0);
+            sysWechatCustomer = sysWechatCustomerService.getById(sysWechatCustomerDuty.getDutyCustomerId());
         }
 
         if (ObjectUtils.isEmpty(sysWechatCustomer)) {

+ 50 - 31
src/main/java/com/ydtech/modules/admin/service/impl/SysWechatCustomerServiceImpl.java

@@ -22,6 +22,7 @@ import org.springframework.util.ObjectUtils;
 import org.springframework.util.StringUtils;
 
 import java.util.List;
+import java.util.Map;
 import java.util.Optional;
 import java.util.stream.Collectors;
 
@@ -59,20 +60,15 @@ public class SysWechatCustomerServiceImpl extends ServiceImpl<SysWechatCustomerM
         List<SysWechatCustomerDuty> sysWechatCustomerDuties = sysWechatCustomerDutyService.getByCustomerId(customerId);
         SysWechatCustomerDutyRulesVo sysWechatCustomerDutyRulesVo = new SysWechatCustomerDutyRulesVo();
         sysWechatCustomerDutyRulesVo.setCustomerId(String.valueOf(customer.getId()));
-        if (customer.getDutyCustomerId() > 0) {
-            sysWechatCustomerDutyRulesVo.setDutyCustomerId(String.valueOf(customer.getDutyCustomerId()));
-        }else {
-            sysWechatCustomerDutyRulesVo.setDutyCustomerId(null);
-        }
-        List<SysWechatCustomerDutyRulesVo.DutyDateTime> collect = sysWechatCustomerDuties.stream()
-                .map(sysWechatCustomerDuty -> {
-                    SysWechatCustomerDutyRulesVo.DutyDateTime dutyDateTime = new SysWechatCustomerDutyRulesVo.DutyDateTime();
-                    dutyDateTime.setEndTime(DateTimeUtil.localDateTimetoString(sysWechatCustomerDuty.getEndTime()));
-                    dutyDateTime.setStartTime(DateTimeUtil.localDateTimetoString(sysWechatCustomerDuty.getStartTime()));
-                    return dutyDateTime;
-                })
+
+        Map<Long, List<SysWechatCustomerDuty>> listMap = sysWechatCustomerDuties.stream()
+                .collect(Collectors.groupingBy(SysWechatCustomerDuty::getDutyCustomerId));
+
+        List<SysWechatCustomerDutyRulesVo.DutyCustomerDTO> dutyCustomerDTOS = listMap.keySet()
+                .stream()
+                .map(x -> new SysWechatCustomerDutyRulesVo.DutyCustomerDTO(x, listMap.get(x)))
                 .collect(Collectors.toList());
-        sysWechatCustomerDutyRulesVo.setDutyDateTimeList(collect);
+        sysWechatCustomerDutyRulesVo.setDutyCustomerDTOS(dutyCustomerDTOS);
         return sysWechatCustomerDutyRulesVo;
     }
 
@@ -80,32 +76,54 @@ public class SysWechatCustomerServiceImpl extends ServiceImpl<SysWechatCustomerM
     @Transactional(rollbackFor = Exception.class)
     public void saveOrUpdateCustomerDutyRules(SysWechatCustomerDutyRulesVo sysWechatCustomerDutyRules) {
         SysWechatCustomer customer = getByIdExist(sysWechatCustomerDutyRules.getCustomerId(), "客服不存在");
-        SysWechatCustomer dutyCustomer = getByIdExist(sysWechatCustomerDutyRules.getDutyCustomerId(), "值班客服不存在");
-
-        Optional.ofNullable(sysWechatCustomerDutyRules.getDutyDateTimeList())
-                        .ifPresent(sysWechatCustomerDutyRulesList -> {
-                            sysWechatCustomerDutyRulesList.forEach(sysWechatCustomerDutyRule -> {
-                                if (DateTimeUtil.timeComparison(sysWechatCustomerDutyRule.getStartTime(), sysWechatCustomerDutyRule.getEndTime())) {
-                                    throw new SystemException("结束时间必须晚于开始时间");
-                                }
-                            });
+        // 前端传入的值班客服ID
+        List<String> dutyCustomerIdList = sysWechatCustomerDutyRules.getDutyCustomerDTOS()
+                .stream()
+                .map(SysWechatCustomerDutyRulesVo.DutyCustomerDTO::getDutyCustomerId)
+                .collect(Collectors.toList());
+        // 数据库查出来的客服列表
+        List<SysWechatCustomer> sysWechatCustomerList = lambdaQuery().in(SysWechatCustomer::getId, dutyCustomerIdList)
+                .list();
+        // 过滤不包含的列表
+        List<SysWechatCustomer> sysWechatCustomers = sysWechatCustomerList.stream()
+                .filter(sysWechatCustomer -> !dutyCustomerIdList.contains(String.valueOf(sysWechatCustomer.getId())))
+                .collect(Collectors.toList());
+
+        if (!sysWechatCustomers.isEmpty()) {
+            throw new SystemException("值班客服不存在");
+        }
+
+        sysWechatCustomerDutyRules.getDutyCustomerDTOS().forEach(sysWechatCustomer -> {
+            Optional.ofNullable(sysWechatCustomer.getDutyDateTimeList())
+                    .ifPresent(sysWechatCustomerDutyRulesList -> {
+                        sysWechatCustomerDutyRulesList.forEach(sysWechatCustomerDutyRule -> {
+                            if (DateTimeUtil.timeComparison(sysWechatCustomerDutyRule.getStartTime(), sysWechatCustomerDutyRule.getEndTime())) {
+                                throw new SystemException("结束时间必须晚于开始时间");
+                            }
                         });
+                    });
+        });
 
-        customer.setDutyCustomerId(dutyCustomer.getId());
-        updateById(customer);
-        // 清楚再删除
+        // 清除再删除
         sysWechatCustomerDutyService.clearCustomerDuty(String.valueOf(customer.getId()));
 
-        List<SysWechatCustomerDuty> collect = sysWechatCustomerDutyRules.getDutyDateTimeList()
+        List<SysWechatCustomerDuty> collect = sysWechatCustomerDutyRules.getDutyCustomerDTOS()
                 .stream()
-                .map(x -> new SysWechatCustomerDuty(customer.getId(), x))
+                .flatMap(dutyCustomerDTO -> {
+                    String dutyCustomerId = dutyCustomerDTO.getDutyCustomerId();
+                    return dutyCustomerDTO.getDutyDateTimeList().stream()
+                            .map(dutyDateTime -> new SysWechatCustomerDuty(customer.getId(), Long.parseLong(dutyCustomerId), dutyDateTime));
+
+                })
                 .collect(Collectors.toList());
+
         sysWechatCustomerDutyService.saveBatch(collect);
     }
 
     @Override
-    public void getCacheCustomerId(SysWechatCustomer sysWechatCustomer) {
-        String customerCache = redisTemplate.opsForValue().get("sys:wechat:customer");
+    public SysWechatCustomer getCacheCustomerId(SysWechatCustomer sysWechatCustomer) {
+        final String KEY = "sys:wechat:customer:";
+        String customerCache = redisTemplate.opsForValue().get(KEY);
         String s1 = Optional.ofNullable(customerCache)
                 .orElse("0");
         sysWechatCustomer = lambdaQuery()
@@ -115,12 +133,13 @@ public class SysWechatCustomerServiceImpl extends ServiceImpl<SysWechatCustomerM
                 .one();
 
         if (ObjectUtils.isEmpty(sysWechatCustomer)) {
-            sysWechatCustomer = lambdaQuery()
+             sysWechatCustomer = lambdaQuery()
                     .orderByAsc(SysWechatCustomer::getId)
                     .last("limit 1")
                     .one();
         }
-        redisTemplate.opsForValue().set("sys:wechat:customer", String.valueOf(sysWechatCustomer.getId()));
+        redisTemplate.opsForValue().set(KEY, String.valueOf(sysWechatCustomer.getId()));
+        return sysWechatCustomer;
     }
 }
 

+ 4 - 4
src/main/resources/application-test.yml

@@ -251,13 +251,13 @@ upload:
   url: ${netUrl}
   username: ''
 wechat:
-  # 微信客服
+  # 微信客服(测试)
   customer:
     corp-id: wwfe67d19509d43ec5
     #    secret: lbn1DU7VhqK3dG0XDciPDXf_AdSryne84nvRhtSEGLc
-    secret: 5M_5mGONe-t4xCPlwPU-EJt53GiWaUjtbJjY5CR-dgc
-    token: btgwGK2r
-    encoding-aes-key: eevs11QeInJYRysGYnC8gK68F4CGsedM1Dn1X79cPCs
+    secret: _tb5qC-MXxYFUEMaaTEb6D_RmQtadt3UUUuvdYcrklI
+    token: hGskYOrv1XnVFtooYsX8Q2PxN
+    encoding-aes-key: cYIzKkyIJQY6wFHUTtamtKiy2uxFynTZOx6VHnvC7vI
   open:
     properties:
       jzg:

+ 1 - 3
src/main/resources/mapper/modules/admin/SysWechatCustomerMapper.xml

@@ -29,12 +29,10 @@
         u.id as userId,
         c.department_id as departmentId,
         c.receptionist as receptionist,
-        c.receptionist_id as receptionistId,
-        swc.nickname as dutyCustomer
+        c.receptionist_id as receptionistId
         from sys_wechat_customer c
         left join sys_user u on u.id = c.user_id
         left join ins_upload_files f on f.id = c.avatar
-        left join sys_wechat_customer swc on swc.id = c.duty_customer_id
         <if test="nickname != null and nickname != ''">
             where c.nickname = #{nickname}
         </if>

+ 0 - 0
src/main/resources/mapper/SysWechatCustomerRecordingMapper.xml → src/main/resources/mapper/modules/admin/SysWechatCustomerRecordingMapper.xml