Преглед на файлове

Merge branch 'master' into dev

zoujiajian преди 2 години
родител
ревизия
5b2f650bcd

+ 5 - 0
netflix-common/src/main/java/com/cyksj/common/constant/Constant.java

@@ -245,4 +245,9 @@ public interface Constant {
 	 * 获客链接 state 标识
 	 */
 	String ACQUISTION_LINK_STATE_KEY = "customer_";
+
+	/**
+	 * 获客链接 值班客服更新定时任务id
+	 */
+	Integer CORP_LINK_JOB_ID = 192;
 }

+ 13 - 6
netflix-dao/src/main/java/com/cyksj/model/dto/YhServiceDto.java

@@ -35,6 +35,8 @@ public class YhServiceDto {
 
 	private String secondEndTime;
 
+	private String sortTime;
+
 
 	@Getter
 	@Setter
@@ -52,14 +54,19 @@ public class YhServiceDto {
 	}
 
 	public Boolean isBetween(LocalTime currentTime) {
-		return (!currentTime.isBefore(LocalTime.parse(startTime)) && !currentTime.isAfter(LocalTime.parse(endTime)))
-				||
-				(!StrUtil.hasEmpty(secondStartTime, secondEndTime) && !currentTime.isBefore(LocalTime.parse(secondStartTime)) && !currentTime.isAfter(LocalTime.parse(secondEndTime)));
+		return (!LocalTime.parse(startTime).isAfter(currentTime) && LocalTime.parse(endTime).isAfter(currentTime))
+				|| (!StrUtil.hasEmpty(secondStartTime, secondEndTime) && !LocalTime.parse(secondStartTime).isAfter(currentTime) && LocalTime.parse(secondEndTime).isAfter(currentTime));
 	}
 
 	public Boolean isAfter(LocalTime currentTime) {
-		return (LocalTime.parse(startTime).isAfter(currentTime))
-				||
-				(!StrUtil.hasEmpty(secondStartTime) && (LocalTime.parse(secondStartTime).isAfter(currentTime)));
+		if (LocalTime.parse(startTime).isAfter(currentTime)) {
+			this.sortTime = startTime;
+			return true;
+		}
+		if ((!StrUtil.hasEmpty(secondStartTime) && (LocalTime.parse(secondStartTime).isAfter(currentTime)))) {
+			this.sortTime = secondStartTime;
+			return true;
+		}
+		return false;
 	}
 }

+ 2 - 0
netflix-dao/src/main/java/com/cyksj/model/entity/GroupsRelationIndependentRenew.java

@@ -19,4 +19,6 @@ public class GroupsRelationIndependentRenew extends BaseEntity{
 	private Boolean isRenew;
 
 	private String operator;
+
+	private Long orderId;
 }

+ 33 - 10
netflix-dao/src/main/java/com/cyksj/model/views/GroupsRelationIndependentView.java

@@ -17,18 +17,26 @@ import java.util.Date;
 
 @Getter
 @Setter
-@SearchBean(tables = "groups_relation gr inner join groups_trips gt on gt.id = gr.groups_id" +
-		" inner join account a on a.id = gt.account_id" +
-		" inner join user u on u.id = gr.user_id",
+@SearchBean(tables = "order_don o inner join groups_relation gr on gr.id = o.relation_id and gr.user_id = o.user_id" +
+		" left join groups_relation_independent_renew gnr on gnr.order_id = o.id" +
+		" inner join user u on u.id = gr.user_id" +
+		" left join goods_don_sku sku on sku.id = o.sku_id" +
+		" left join goods_don g on g.id = o.goods_id",
 		where = ":condition:")
 public class GroupsRelationIndependentView {
 	@DbField("gr.id")
 	private Long relationId;
 
-	@DbField("a.account")
+	@DbField("gr.groups_id")
+	private Long groupsId;
+
+	@DbField("o.id")
+	private Long orderId;
+
+	@DbIgnore
 	private String account;
 
-	@DbField("a.password")
+	@DbIgnore
 	private String password;
 
 	@DbField("gr.user_id")
@@ -43,12 +51,27 @@ public class GroupsRelationIndependentView {
 	@DbField("gr.expiry_time")
 	private Date expiryTime;
 
-	@DbField("a.expiry_time")
+	@DbIgnore
 	private Date accountExpiryTime;
 
-	@DbIgnore
-	private Boolean isRenew = false;
+	@DbField("ifnull(gnr.is_renew,false)")
+	private Boolean isRenew;
 
-	@DbIgnore
-	private Integer numOfRenew;
+	@DbField("ifnull(o.pay_time,o.created_time)")
+	private Date submitTime;
+
+	@DbField("g.id")
+	private Long goodsId;
+
+	@DbField("sku.id")
+	private Long skuId;
+
+	@DbField("g.title")
+	private String title;
+
+	@DbField("sku.spec_val")
+	private String specVal;
+
+	@DbField("if(gnr.is_renew,gnr.update_time,null)")
+	private Date updateTime;
 }

+ 2 - 2
netflix-dao/src/main/resources/mapper/UserDistributeMapper.xml

@@ -4,8 +4,8 @@
 
     <select id="count" resultType="java.lang.Integer">
         select count(*)
-        from distribute_waiting_send_points
-        where shared_id = #{userId}
+        from distribute_waiting_send_points dw left join order_don o on o.id = dw.order_id
+        where dw.shared_id = #{userId} and o.is_distribute is true
     </select>
 
     <select id="countUserNum" resultType="java.lang.Integer">

+ 20 - 0
netflix-service/src/main/java/com/cyksj/service/corp/impl/CorpCustomerAcquisitionLinkServiceImpl.java

@@ -4,6 +4,7 @@ import cn.hutool.core.util.StrUtil;
 import cn.hutool.json.JSONUtil;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.cyksj.common.constant.Constant;
 import com.cyksj.common.exception.BusinessRuntimeException;
 import com.cyksj.mapper.corp.CorpCustomerAcquisitionLinkMapper;
 import com.cyksj.mapper.corp.CorpCustomerAcquisitionLinkPopularizeMapper;
@@ -15,9 +16,12 @@ import com.cyksj.model.request.corp.link.WxCpLinkAddResp;
 import com.cyksj.model.request.corp.link.WxCpLinkUpd;
 import com.cyksj.service.corp.CorpCustomerAcquisitionLinkService;
 import com.cyksj.service.corp.WxCorpOps;
+import com.cyksj.xxljob.XxlJobInfo;
+import com.cyksj.xxljob.XxlJobUtil;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.Optional;
 
@@ -35,6 +39,7 @@ public class CorpCustomerAcquisitionLinkServiceImpl extends ServiceImpl<CorpCust
     private final CorpCustomerAcquisitionLinkPopularizeMapper corpCustomerAcquisitionLinkPopularizeMapper;
 
     @Override
+    @Transactional(rollbackFor = Throwable.class)
     public void add(CorpCustomerAcquisitionLink corpCustomerAcquisitionLink) throws Exception {
         WxCpLinkAdd wxCpLinkAdd = new WxCpLinkAdd();
         wxCpLinkAdd.setLinkName(corpCustomerAcquisitionLink.getLinkName());
@@ -48,11 +53,17 @@ public class CorpCustomerAcquisitionLinkServiceImpl extends ServiceImpl<CorpCust
 
         corpCustomerAcquisitionLink.setChooseDutyUsers(corpCustomerAcquisitionLink.getUserList());
         this.save(corpCustomerAcquisitionLink);
+
+        if (corpCustomerAcquisitionLink.getIsDuty() != null && corpCustomerAcquisitionLink.getIsDuty()) {
+            handleCorpLinkSchedulerJob();
+        }
     }
 
     @Override
+    @Transactional(rollbackFor = Throwable.class)
     public void up(CorpCustomerAcquisitionLink corpCustomerAcquisitionLink) throws Exception {
         CorpCustomerAcquisitionLink link = getById(corpCustomerAcquisitionLink.getId());
+        String oldUserList = link.getUserList();
         link.setLinkName(corpCustomerAcquisitionLink.getLinkName());
         link.setUserList(corpCustomerAcquisitionLink.getUserList());
 
@@ -79,6 +90,10 @@ public class CorpCustomerAcquisitionLinkServiceImpl extends ServiceImpl<CorpCust
         }
 
         this.updateById(corpCustomerAcquisitionLink);
+
+        if (corpCustomerAcquisitionLink.getIsDuty() != null && corpCustomerAcquisitionLink.getIsDuty() && !StrUtil.equals(oldUserList, corpCustomerAcquisitionLink.getUserList())) {
+            handleCorpLinkSchedulerJob();
+        }
     }
 
     @Override
@@ -98,4 +113,9 @@ public class CorpCustomerAcquisitionLinkServiceImpl extends ServiceImpl<CorpCust
         WxCpLinkAddResp wxCpLinkAddResp = corpOps.customerAcquisitionDeleteLink(null, wxCpLinkUpd);
         removeById(id);
     }
+
+    public void handleCorpLinkSchedulerJob() throws Exception {
+        //立即执行客服值班定时任务
+        XxlJobUtil.executeMarkDynamicRuleTagJob(XxlJobInfo.getExecuteTaskInstance(Constant.CORP_LINK_JOB_ID, StrUtil.EMPTY).toString());
+    }
 }

+ 8 - 5
netflix-service/src/main/java/com/cyksj/service/corp/impl/CorpTagServiceImpl.java

@@ -365,11 +365,11 @@ public class CorpTagServiceImpl implements CorpTagService {
 		}
 		String[] tagIds = null;
 		String[] groupIds = null;
+		List<CorpTag> corpTags = null;
 		if (StrUtil.isNotEmpty(tagId)) {
-			List<CorpTag> corpTags = corpTagMapper.selectList(Wrappers.lambdaQuery(CorpTag.class)
+			corpTags = corpTagMapper.selectList(Wrappers.lambdaQuery(CorpTag.class)
 					.eq(CorpTag::getTagId, tagId));
 			tagIds = corpTags.stream().filter(tag -> StrUtil.isNotBlank(tag.getTagId())).map(CorpTag::getTagId).toArray(String[]::new);
-			groupIds = corpTags.stream().filter(tag -> StrUtil.isNotEmpty(tag.getGroupId())).map(CorpTag::getGroupId).toArray(String[]::new);
 		}
 
 		if (StrUtil.isNotEmpty(groupId)) {
@@ -386,9 +386,12 @@ public class CorpTagServiceImpl implements CorpTagService {
 		}
 		if (StrUtil.isNotBlank(tagId)) {
 			corpTagMapper.delete(Wrappers.lambdaQuery(CorpTag.class).eq(CorpTag::getTagId, tagId));
-			Integer count = corpTagMapper.selectCount(Wrappers.lambdaQuery(CorpTag.class).in(CorpTag::getGroupId, groupIds));
-			if (count == 0) {
-				corpTagGroupMapper.delete(Wrappers.lambdaQuery(CorpTagGroup.class).in(CorpTagGroup::getGroupId, groupIds));
+			if (CollUtil.isNotEmpty(corpTags)) {
+				groupIds = corpTags.stream().filter(tag -> StrUtil.isNotEmpty(tag.getGroupId())).map(CorpTag::getGroupId).toArray(String[]::new);
+				Integer count = corpTagMapper.selectCount(Wrappers.lambdaQuery(CorpTag.class).in(CorpTag::getGroupId, groupIds));
+				if (count == 0) {
+					corpTagGroupMapper.delete(Wrappers.lambdaQuery(CorpTagGroup.class).in(CorpTagGroup::getGroupId, groupIds));
+				}
 			}
 		}
 

+ 1 - 1
netflix-service/src/main/java/com/cyksj/service/sys/SysConfigChangeRecordService.java

@@ -10,5 +10,5 @@ import com.cyksj.model.entity.SysConfigChangeRecord;
  * 创建时间:2023/11/24 10:44
  */
 public interface SysConfigChangeRecordService extends IService<SysConfigChangeRecord> {
-	void changeRecord(Long adminId, String sysKey, String sysValue, String updateValue);
+	Boolean changeRecord(Long adminId, String sysKey, String sysValue, String updateValue) throws Exception;
 }

+ 3 - 1
netflix-service/src/main/java/com/cyksj/service/sys/impl/SysConfigChangeRecordServiceImpl.java

@@ -24,7 +24,7 @@ public class SysConfigChangeRecordServiceImpl extends ServiceImpl<SysConfigChang
 	private final CmsUserMapper cmsUserMapper;
 
 	@Override
-	public void changeRecord(Long adminId, String sysKey, String sysValue, String updateValue) {
+	public Boolean changeRecord(Long adminId, String sysKey, String sysValue, String updateValue) throws Exception {
 		//保存客服系统配置key前后更新数据
 		if (Constant.serviceKeys.contains(sysKey)) {
 			if (!StrUtil.equals(sysValue, updateValue)) {
@@ -35,7 +35,9 @@ public class SysConfigChangeRecordServiceImpl extends ServiceImpl<SysConfigChang
 				Optional.ofNullable(cmsUserMapper.selectById(adminId))
 						.ifPresent(cm -> sysConfigChangeRecord.setOperator(cm.getNickname()));
 				this.save(sysConfigChangeRecord);
+				return true;
 			}
 		}
+		return false;
 	}
 }

+ 5 - 3
netflix-service/src/main/java/com/cyksj/service/sys/impl/SysConfigServiceImpl.java

@@ -1,6 +1,7 @@
 package com.cyksj.service.sys.impl;
 
 import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -137,10 +138,11 @@ public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper,SysConfig>
 			if (CollUtil.isEmpty(collect)) {
 				// 如果没有下一个时间段,获取下一个工作时间段的开始时间
 				DayOfWeek nextWorkDay = getNextWorkDay(currentDayOfWeek);
-				List<YhServiceDto> nextServices = getDutyService(nextWorkDay, workday, saturday, sunday);
-				//获取下一天的早时
-				return List.of(nextServices.get(0));
+				collect = getDutyService(nextWorkDay, workday, saturday, sunday);
 			}
+			collect.sort(Comparator.comparing(e -> DateUtil.parse(e.getSortTime() == null ? e.getStartTime() : e.getSortTime(), "HH:mm")));
+			//获取下一天的早时
+			return List.of(collect.get(0));
 		}
 		return collect;
 	}

+ 1 - 0
netflix-web/src/main/java/com/cyksj/web/controller/manage/goods/CmsGoodsDonController.java

@@ -205,6 +205,7 @@ public class CmsGoodsDonController {
         } else {
             conditionSql = "(special_type is null or special_type != 'giftCard')";
         }
+        conditionSql += "  and exists (select id from goods_don_sku sku where sku.goods_id = g.id limit 1)";
         List<GoodsDon> goodsDons = beanSearcher.searchAll(GoodsDon.class, mapBuilder
                 .put("condition", conditionSql)
                 .field(GoodsDon::getDeleted, true)

+ 22 - 17
netflix-web/src/main/java/com/cyksj/web/controller/manage/group/CmsGroupRelationController.java

@@ -1,10 +1,12 @@
 package com.cyksj.web.controller.manage.group;
 
 import cn.dev33.satoken.stp.StpUtil;
+import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.date.DateTime;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.lang.Assert;
 import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.cyksj.common.annotation.Log;
 import com.cyksj.common.annotation.NoSubmit;
@@ -19,6 +21,7 @@ import com.cyksj.mapper.GroupsRelationMapper;
 import com.cyksj.mapper.OrderDonMapper;
 import com.cyksj.mapper.manage.cms.CmsUserMapper;
 import com.cyksj.model.entity.*;
+import com.cyksj.model.manage.views.AccountView;
 import com.cyksj.model.manage.views.GroupsRelationBackView;
 import com.cyksj.model.views.GroupsRelationIndependentView;
 import com.cyksj.model.views.GroupsRelationRechargeView;
@@ -37,6 +40,7 @@ import org.springframework.web.bind.annotation.*;
 import javax.servlet.http.HttpServletRequest;
 import java.util.List;
 import java.util.Optional;
+import java.util.stream.Collectors;
 
 /**
  * @author chan
@@ -167,29 +171,28 @@ public class CmsGroupRelationController {
      * Chat GPT独立规格续费 列表
      */
     @GetMapping("/get/chatGPT/independent/renew")
-    public Result<SearchResult<GroupsRelationIndependentView>> getIndependentRenew(Boolean isRenew) {
-        String condition = " sku_id in (select id from goods_don_sku sku where sku.goods_id = 18 and sku.num = 1)" +
-                " and exists (select id from order_don o where o.user_id = gr.user_id and o.relation_id = gr.id and o.status not in ('close','noPayment','refund') and o.order_type = 2 limit 1)";
-        if (isRenew != null) {
-            if (isRenew) {
-                condition += String.format(" and exists (select id from groups_relation_independent_renew gnr where gnr.user_id = gr.user_id and gnr.relation_id = gr.id and gnr.is_renew = 1 limit 1)");
-            } else {
-                condition += String.format(" and (select count(*) from groups_relation_independent_renew gnr where gnr.user_id = gr.user_id and gnr.relation_id = gr.id and gnr.is_renew = 1) = 0");
+    public Result<SearchResult<GroupsRelationIndependentView>> getIndependentRenew(String account) {
+        String condition = " sku_id in (select id from goods_don_sku sku where sku.goods_id in (18,26) and sku.num = 1)" +
+                " and o.status not in ('close','noPayment','refund') and o.order_type = 2";
+        if (StrUtil.isNotEmpty(account)) {
+            List<AccountView> dbAccounts = beanSearcher.searchAll(AccountView.class, MapUtils.builder().field(AccountView::getAccount, account).op(Operator.Contain).build());
+            if (CollUtil.isNotEmpty(dbAccounts)) {
+                String collect = dbAccounts.stream().map(e -> String.valueOf(e.getGroupsId())).collect(Collectors.joining(","));
+                condition += String.format(" and groups_id in (%s)", collect);
             }
         }
         SearchResult<GroupsRelationIndependentView> search = beanSearcher.search(GroupsRelationIndependentView.class, MapUtils.flatBuilder(request.getParameterMap())
                 .put("condition", condition)
+                .orderBy(GroupsRelationIndependentView::getIsRenew)
+                .orderBy(GroupsRelationIndependentView::getSubmitTime).desc()
                 .build());
         search.getDataList().forEach(e->{
-            Optional.ofNullable(groupsRelationIndependentRenewMapper.selectOne(Wrappers.lambdaQuery(GroupsRelationIndependentRenew.class).eq(GroupsRelationIndependentRenew::getUserId, e.getUserId())
-                    .eq(GroupsRelationIndependentRenew::getRelationId, e.getRelationId()).last("limit 1"))).ifPresent(data -> e.setIsRenew(data.getIsRenew()));
-            Number count = beanSearcher.searchCount(OrderDonRenewView.class, MapUtils.flatBuilder(request.getParameterMap())
-                    .field(OrderDonRenewView::getUserId, e.getUserId())
-                    .field(OrderDonRenewView::getRelationId, e.getRelationId())
-                    .field(OrderDonRenewView::getOrderType, 2)
-                    .field(OrderDonRenewView::getStatus, Constant.noOrderAllStatus).op(Operator.NotIn)
-                    .build());
-            e.setNumOfRenew(count.intValue());
+            GroupsTrips groupsTrips = beanSearcher.searchFirst(GroupsTrips.class, MapUtils.builder().field(GroupsTrips::getId, e.getGroupsId()).build());
+            if (groupsTrips != null) {
+                e.setAccount(groupsTrips.getAccount());
+                e.setPassword(groupsTrips.getPassword());
+                e.setAccountExpiryTime(e.getExpiryTime());
+            }
         });
         return GatewayResponse.SUCCESS.newBuilder().toResult(search);
     }
@@ -212,6 +215,8 @@ public class CmsGroupRelationController {
         if (cmsUser != null) {
             groupsRelationIndependentRenew.setOperator(cmsUser.getNickname());
         }
+        groupsRelationIndependentRenew.setOrderId(view.getOrderId());
+
         if (groupsRelationIndependentRenew.getId() == null) {
             groupsRelationIndependentRenew.setRelationId(relationId);
             groupsRelationIndependentRenew.setUserId(userId);

+ 10 - 1
netflix-web/src/main/java/com/cyksj/web/controller/sys/SysConfigController.java

@@ -22,8 +22,11 @@ import com.cyksj.model.views.HelpQuestionClassificationView;
 import com.cyksj.service.corp.CorpFollowService;
 import com.cyksj.service.sys.SysConfigChangeRecordService;
 import com.cyksj.service.sys.SysConfigService;
+import com.cyksj.xxljob.XxlJobInfo;
+import com.cyksj.xxljob.XxlJobUtil;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
 
 import java.math.BigDecimal;
@@ -70,6 +73,7 @@ public class SysConfigController {
 
 	@PutMapping("/update")
 	@Log(module = "系统设置/编辑配置", businessType = BusinessType.PUT, isSaveRequestData = true)
+	@Transactional(rollbackFor = Throwable.class)
 	public Result<SysConfig> update(@RequestBody SysConfig sysConfig) throws Exception {
 		long adminId = StpUtil.getLoginIdAsLong();
 		Long id = sysConfig.getId();
@@ -89,10 +93,15 @@ public class SysConfigController {
 			}
 		}
 
-		sysConfigChangeRecordService.changeRecord(adminId, sysConfig.getSysKey(), byId.getSysValue(), sysConfig.getSysValue());
+		Boolean isChanged = sysConfigChangeRecordService.changeRecord(adminId, sysConfig.getSysKey(), byId.getSysValue(), sysConfig.getSysValue());
 
 		sysConfigService.updateById(sysConfig);
 
+		if (isChanged) {
+			//立即执行客服值班定时任务
+			XxlJobUtil.executeMarkDynamicRuleTagJob(XxlJobInfo.getExecuteTaskInstance(Constant.CORP_LINK_JOB_ID, StrUtil.EMPTY).toString());
+		}
+
 		return GatewayResponse.SUCCESS.newBuilder().toResult(sysConfig);
 	}