Browse Source

Merge remote-tracking branch 'origin/test' into test

Qchen 1 year ago
parent
commit
968f8b6139
17 changed files with 283 additions and 104 deletions
  1. 4 2
      src/main/java/com/ydtech/modules/admin/controller/SysMenuController.java
  2. 0 16
      src/main/java/com/ydtech/modules/admin/model/po/SysWechatCustomer.java
  3. 13 9
      src/main/java/com/ydtech/modules/admin/model/po/SysWechatCustomerDuty.java
  4. 35 3
      src/main/java/com/ydtech/modules/admin/model/vo/wechat/SysWechatCustomerDutyRulesVo.java
  5. 25 3
      src/main/java/com/ydtech/modules/admin/model/vo/wechat/SysWechatCustomerVo.java
  6. 8 0
      src/main/java/com/ydtech/modules/admin/service/SysWechatCustomerDutyService.java
  7. 1 7
      src/main/java/com/ydtech/modules/admin/service/SysWechatCustomerService.java
  8. 42 19
      src/main/java/com/ydtech/modules/admin/service/impl/SysWechatCustomerBusinessServiceImpl.java
  9. 50 31
      src/main/java/com/ydtech/modules/admin/service/impl/SysWechatCustomerServiceImpl.java
  10. 6 0
      src/main/java/com/ydtech/modules/fnc/service/impl/InsFeeAuditServiceImpl.java
  11. 3 0
      src/main/java/com/ydtech/modules/ins/model/vo/QuoteRespVo.java
  12. 66 0
      src/main/java/com/ydtech/modules/order/controller/QuoteController.java
  13. 3 2
      src/main/java/com/ydtech/modules/order/controller/YongChengOrderApiController.java
  14. 22 5
      src/main/java/com/ydtech/modules/scheme/service/impl/PtlSchemeRulesServiceImpl.java
  15. 4 4
      src/main/resources/application-test.yml
  16. 1 3
      src/main/resources/mapper/modules/admin/SysWechatCustomerMapper.xml
  17. 0 0
      src/main/resources/mapper/modules/admin/SysWechatCustomerRecordingMapper.xml

+ 4 - 2
src/main/java/com/ydtech/modules/admin/controller/SysMenuController.java

@@ -5,6 +5,7 @@ import com.ydtech.modules.admin.model.SysMenu;
 import com.ydtech.modules.admin.model.SysMenuVo;
 import com.ydtech.modules.admin.model.SysRole;
 import com.ydtech.modules.admin.service.SysMenuService;
+import com.ydtech.modules.base.controller.BaseController;
 import com.ydtech.utils.StringUtils;
 import com.ydtech.core.page.HttpResult;
 import org.apache.commons.compress.utils.Lists;
@@ -23,7 +24,7 @@ import java.util.stream.Collectors;
  */
 @RestController
 @RequestMapping("menu")
-public class SysMenuController {
+public class SysMenuController extends BaseController {
 
     @Autowired
     private SysMenuService sysMenuService;
@@ -58,7 +59,8 @@ public class SysMenuController {
     //    @PreAuthorize("hasAuthority('sys:menu:view')")
     @GetMapping(value = "/findMenuTree")
     public HttpResult findMenuTree() {
-        return HttpResult.ok(sysMenuService.findTree(null, 0));
+
+        return HttpResult.ok(sysMenuService.findTree(getUserName(), 0));
     }
 
     @GetMapping(value = "v1/findMenuTree")

+ 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;
     }
 }
 

+ 6 - 0
src/main/java/com/ydtech/modules/fnc/service/impl/InsFeeAuditServiceImpl.java

@@ -56,6 +56,7 @@ import org.redisson.Redisson;
 import org.redisson.api.RLock;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -147,6 +148,9 @@ public class InsFeeAuditServiceImpl extends ServiceImpl<InsFeeAuditMapper, InsFe
     @Autowired
     private SysSwitchConfigService sysSwitchConfigService;
 
+    @Autowired
+    private RedisTemplate redisTemplate;
+
     public InsFeeAuditServiceImpl(FncInsAreaCompanyMapper insAreaCompanyMapper, InsOrdersMapper insOrdersMapper,
                                   InsDeptFeeService insDeptFeeService, EsmUserReferrerService esmUserReferrerService,
                                   SysUserService sysUserService, InsCommissionService insCommissionService,
@@ -426,6 +430,8 @@ public class InsFeeAuditServiceImpl extends ServiceImpl<InsFeeAuditMapper, InsFe
             if (isManagement(order.getUserid()) && sysSwitchConfigService.getBalanceExtractStatus()) {
                 dataServerService.sendLgDataServer(insOrderNo);
             }
+            // 审核完成之后 清空锁
+            redisTemplate.delete("FEE_AUDIT:"+insOrderNo);
         } catch (Exception e) {
             throw new SystemException("当前业务繁忙,请稍后重试");
         } finally {

+ 3 - 0
src/main/java/com/ydtech/modules/ins/model/vo/QuoteRespVo.java

@@ -71,6 +71,9 @@ public class QuoteRespVo {
     @ApiModelProperty("订单号")
     private String orderno;
 
+    @ApiModelProperty("订单状态")
+    private String orderstatus;
+
     @ApiModelProperty("是否真单交")
     private String iszdj;
 

+ 66 - 0
src/main/java/com/ydtech/modules/order/controller/QuoteController.java

@@ -3,6 +3,7 @@ package com.ydtech.modules.order.controller;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.fasterxml.jackson.core.JsonProcessingException;
 import com.ydtech.aop.request.RequestSingleParam;
 import com.ydtech.core.page.HttpResult;
 import com.ydtech.exception.SystemException;
@@ -275,9 +276,11 @@ public class QuoteController extends BaseController {
 //            quoteVo1.setAccidentalDrivingVo(javaObject);
 //            return pingAnOrderApiService.quote(quoteInfo, quoteVo1);
         }
+
         PtlAgreementAttribution byId = ptlAgreementAttributionService.getById(quoteVo.getAgreementId());
         if( respVo != null && !ObjectUtils.isEmpty( respVo.getData() )){
             respVo.getData().setApiType(byId.getApiType());
+            respVo.getData().setOrderstatus("0");
         }
         return respVo;
     }
@@ -338,4 +341,67 @@ public class QuoteController extends BaseController {
 
         return httpResult;
     }
+
+
+    @PostMapping(value = "batchOrderStatus")
+    public HttpResult batchOrderStatus(@RequestSingleParam("orderNos") List<String> orderNos) throws Exception {
+        List<InsAreaCompany> list = insAreaCompanyService.list(new LambdaQueryWrapper<InsAreaCompany>()
+                .in(InsAreaCompany::getId, orderNos));
+        list.forEach(item -> {
+            //如果是爬虫的 先调用爬虫的查询订单状态
+            if (Objects.isNull(item.getApiType()) || item.getApiType() == 2) {
+                try {
+                    insCrawlerOrderService.verifyPayment(item.getId());
+                }catch (Exception e){
+
+                }
+            }
+            if (item.getCompanyId().equals("AICS1000000") && item.getApiType() == 1) {
+                try {
+                    yongchengOrderApiService.callbackAnOrder(item.getId());
+                }catch (Exception e){
+
+                }
+            } else if (item.getCompanyId().equals("ZMBX1000000") && item.getApiType() == 1) {
+                try {
+                    zhongMeiOrderApiService.paymentEnquiry(item.getId());
+                }catch (Exception e){}
+            } else if (item.getCompanyId().equals("ZKIC1000000")) {
+                try {
+                    zijinOrderApiService.auditStatusQuery(item.getId());
+                }catch (Exception e){}
+            } else if (item.getCompanyId().equals("XDCX1000000")) {
+                try {
+                    guorenOrderApiService.pay(item.getId());
+                }catch (Exception e){}
+            } else if (item.getCompanyId().equals("YGBX1000000")) {
+                try {
+                    yangGuangOrderApiService.paymentCallback(item.getId());
+                } catch (JsonProcessingException e) {
+                    throw new RuntimeException(e);
+                }
+            } else if (item.getCompanyId().equals("HTIC1000000")) {
+                try {
+                    huaTaiOrderApiService.paymentEnquiry(item.getId());
+                }catch (Exception e){}
+            } else if (item.getCompanyId().equals("DJPC1000000")) {
+                try {
+                    daJiaOrderService.verifyPayment(item.getId());
+                }catch (Exception e){}
+            } else if (item.getCompanyId().equals("CHAC1000000")) {
+                try {
+                    chengTaiOrderApiService.getPayUrl(item.getId());
+                } catch (Exception e) {
+                    throw new RuntimeException(e);
+                }
+            } else if (item.getCompanyId().equals("BPIC1000000")) {
+                try {
+                    boHaiOrderApiService.auditStatusQuery(item.getId());
+                } catch (Exception e) {
+                    throw new RuntimeException(e);
+                }
+            }
+        });
+        return HttpResult.ok("查询成功");
+    }
 }

+ 3 - 2
src/main/java/com/ydtech/modules/order/controller/YongChengOrderApiController.java

@@ -63,8 +63,8 @@ public class YongChengOrderApiController {
     @ApiOperation(value = "永诚API方式 - 影像上传")
     @PostMapping(value = "/uploadImage")
     public HttpResult uploadImageApi(@RequestSingleParam(value = "companyId") String companyId) {
-        return yongchengOrderApiService.uploadImageApi(companyId);
-//        return HttpResult.ok("ok");
+//        return yongchengOrderApiService.uploadImageApi(companyId);
+        return HttpResult.ok("ok");
     }
 
     @ApiOperation(value = "永诚API方式 -电子保单")
@@ -115,6 +115,7 @@ public class YongChengOrderApiController {
 
         lqw.eq(InsAreaCompany::getOrderstatus, InsOrderStatusEnum.WAIT_PAY.getCode());
         lqw.gt(InsAreaCompany::getAudittime, LocalDate.now());
+        lqw.eq(InsAreaCompany::getId,suborderId);
         List<InsAreaCompany> list = insAreaCompanyService.list(lqw);
 
         list.forEach(yongchengOrderApiService::getPayUrlApi);

+ 22 - 5
src/main/java/com/ydtech/modules/scheme/service/impl/PtlSchemeRulesServiceImpl.java

@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ydtech.constants.enums.dict.insurance.EnergyType;
 import com.ydtech.exception.SystemException;
 import com.ydtech.modules.admin.service.SysUserService;
+import com.ydtech.modules.base.controller.BaseController;
 import com.ydtech.modules.protocol.entity.dto.PtlAgreementInsCompanyDto;
 import com.ydtech.modules.protocol.entity.dto.TaxSourceExcludeDto;
 import com.ydtech.modules.protocol.service.ITaxSourceExcludeService;
@@ -22,10 +23,9 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.StringUtils;
 
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
+import java.util.*;
+import java.util.function.Function;
+import java.util.function.Predicate;
 import java.util.stream.Collectors;
 
 /**
@@ -139,6 +139,11 @@ public class PtlSchemeRulesServiceImpl extends ServiceImpl<PtlSchemeRulesMapper,
         return rulesPage;
     }
 
+    public static <T> Predicate<T> distinctByKey(Function<? super T, Object> keyExtractor) {
+        Set<Object> seen = new HashSet<>();
+        return t -> seen.add(keyExtractor.apply(t)); // 如果id已存在则过滤
+    }
+
     /**
      * 根据规则过滤保险公司
      *
@@ -147,9 +152,20 @@ public class PtlSchemeRulesServiceImpl extends ServiceImpl<PtlSchemeRulesMapper,
      */
     @Override
     public List<PtlAgreementInsCompanyDto> ruleFilterCompany(String userId, RuleFilterVo ruleFilterVo) {
+        List<PtlAgreementInsCompanyDto> userAgreementInsCompany = new ArrayList<>();
+        if(!BaseController.getUserId().equals(userId)){
+
+            userAgreementInsCompany = taxSourceService.getAllAgreement(BaseController.getDeptId(),BaseController.getUserId());
+        }
         String deptId = sysUserService.getById(userId).getDeptId();
         //首先获取有权限的保险公司
         List<PtlAgreementInsCompanyDto> agreementInsCompany = taxSourceService.getAllAgreement(deptId, userId);
+        agreementInsCompany.addAll(userAgreementInsCompany);
+
+        agreementInsCompany = agreementInsCompany.stream()
+                .filter(distinctByKey(PtlAgreementInsCompanyDto::getId))  // 核心:按id去重
+                .collect(Collectors.toList());
+
         //用户可读取的所有保险公司id
         List<String> companyIds = agreementInsCompany.stream()
                 .map(PtlAgreementInsCompanyDto::getId)
@@ -176,6 +192,7 @@ public class PtlSchemeRulesServiceImpl extends ServiceImpl<PtlSchemeRulesMapper,
                 ruleFilterVo.getInsureInfo(),
                 null);
         //赛选规则
+        List<PtlAgreementInsCompanyDto> finalAgreementInsCompany = agreementInsCompany;
         userAllSchemeByCompanyIds.forEach(scheme -> {
             List<SchemeRuleResultVo> rulesVo = ptlSchemeRulesAttrLinkService.getSchemeRulesAttrLinks(scheme.getCompanyId(), ruleFilterVo.getProductId());
 
@@ -186,7 +203,7 @@ public class PtlSchemeRulesServiceImpl extends ServiceImpl<PtlSchemeRulesMapper,
                         ruleFilteringService.judgements(r.getAttrLinks(), rulesAttrList, ruleAttrMappingVoList)
                 );
                 if (allRulesPassed) {
-                    agreementInsCompany.stream()
+                    finalAgreementInsCompany.stream()
                             .filter(x -> x.getId().equals(scheme.getCompanyId()))
                             .forEach(item -> {
                                 if (ptlAgreementInsCompanyDtos.stream()

+ 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