|
|
@@ -2,44 +2,47 @@ package com.cyksj.web.controller.manage.statistics;
|
|
|
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import com.alibaba.excel.support.ExcelTypeEnum;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.cyksj.common.exception.BusinessRuntimeException;
|
|
|
import com.cyksj.dto.Result;
|
|
|
import com.cyksj.enums.GatewayResponse;
|
|
|
-import com.cyksj.mapper.stock.GoodsDonStockRecordMapper;
|
|
|
-import com.cyksj.model.entity.*;
|
|
|
-import com.cyksj.model.excel.ExcelAccountData;
|
|
|
-import com.cyksj.model.views.BackgroundDataView;
|
|
|
-import com.cyksj.model.views.ExpiredAccountDataView;
|
|
|
+import com.cyksj.mapper.CustomerServiceRenewOrderRecordMapper;
|
|
|
import com.cyksj.mapper.GroupsRelationMapper;
|
|
|
import com.cyksj.mapper.UserMapper;
|
|
|
import com.cyksj.mapper.manage.CustomerServiceEveryMonthDetailMapper;
|
|
|
import com.cyksj.mapper.manage.RealGoodsOrderHandleMapper;
|
|
|
import com.cyksj.mapper.manage.statistics.IncrExpiryTimeRecordMapper;
|
|
|
import com.cyksj.mapper.manage.statistics.StatisticsUserDataMapper;
|
|
|
+import com.cyksj.mapper.stock.GoodsDonStockRecordMapper;
|
|
|
+import com.cyksj.model.entity.*;
|
|
|
+import com.cyksj.model.excel.ExcelAccountData;
|
|
|
+import com.cyksj.model.request.BatchServiceReq;
|
|
|
import com.cyksj.model.request.RenewTimeUpReq;
|
|
|
import com.cyksj.model.views.*;
|
|
|
import com.cyksj.service.mange.statistics.StatisticsDataService;
|
|
|
-import com.cyksj.web.util.EasyExcelUtils;
|
|
|
import com.cyksj.task.OrderCustomerHandleScheduler;
|
|
|
+import com.cyksj.web.util.EasyExcelUtils;
|
|
|
import com.ejlchina.searcher.BeanSearcher;
|
|
|
import com.ejlchina.searcher.SearchResult;
|
|
|
import com.ejlchina.searcher.param.Operator;
|
|
|
+import com.ejlchina.searcher.util.MapBuilder;
|
|
|
import com.ejlchina.searcher.util.MapUtils;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
-import java.util.*;
|
|
|
-
|
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Optional;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/*
|
|
|
@@ -72,6 +75,8 @@ public class StatisticsDataController {
|
|
|
|
|
|
private final GoodsDonStockRecordMapper stockRecordMapper;
|
|
|
|
|
|
+ private final CustomerServiceRenewOrderRecordMapper customerServiceRenewOrderRecordMapper;
|
|
|
+
|
|
|
/**
|
|
|
* 查询统计数据
|
|
|
*/
|
|
|
@@ -85,16 +90,16 @@ public class StatisticsDataController {
|
|
|
* 有效子账号数列表
|
|
|
*/
|
|
|
@GetMapping("/expired/account")
|
|
|
- public Result<IPage<ExpiredAccountDataView>> getExpiredAccountView(Integer goodsId, String account, Boolean renewStatus, Boolean handleStatus, String cnAccount, String usAccount, Integer userId, Long startTime, Long endTime, @RequestParam(required = false, defaultValue = "1") Long start, @RequestParam(required = false, defaultValue = "10") Long limit) {
|
|
|
- return GatewayResponse.SUCCESS.newBuilder().toResult(statisticsDataService.getExpiredAccountView(goodsId, account, renewStatus, handleStatus, cnAccount, usAccount, userId, startTime, endTime, start, limit));
|
|
|
+ public Result<IPage<ExpiredAccountDataView>> getExpiredAccountView(Boolean isCorpWx, String customerService, Integer goodsId, String account, Boolean renewStatus, Boolean handleStatus, String cnAccount, String usAccount, Integer userId, Long startTime, Long endTime, @RequestParam(required = false, defaultValue = "1") Long start, @RequestParam(required = false, defaultValue = "10") Long limit) {
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(statisticsDataService.getExpiredAccountView(isCorpWx, customerService, goodsId, account, renewStatus, handleStatus, cnAccount, usAccount, userId, startTime, endTime, start, limit));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 导出有效子账号数
|
|
|
*/
|
|
|
@GetMapping("/export/account")
|
|
|
- public void exportAccount(Integer goodsId, String account, Boolean renewStatus, Boolean handleStatus, String cnAccount, String usAccount, Integer userId, Long startTime, Long endTime, HttpServletResponse response) {
|
|
|
- List<ExcelAccountData> expiredAccountView = statisticsDataService.getExpiredAccountViewNoPage(goodsId, account, renewStatus, handleStatus, cnAccount, usAccount, userId, startTime, endTime);
|
|
|
+ public void exportAccount(Boolean isCorpWx, String customerService, Integer goodsId, String account, Boolean renewStatus, Boolean handleStatus, String cnAccount, String usAccount, Integer userId, Long startTime, Long endTime, HttpServletResponse response) {
|
|
|
+ List<ExcelAccountData> expiredAccountView = statisticsDataService.getExpiredAccountViewNoPage(isCorpWx, customerService, goodsId, account, renewStatus, handleStatus, cnAccount, usAccount, userId, startTime, endTime);
|
|
|
EasyExcelUtils.createExcelStreamMutilByEasyExcel(response, ExcelAccountData.class, expiredAccountView, "有效子账号", "有效子账号", ExcelTypeEnum.XLSX, null);
|
|
|
}
|
|
|
|
|
|
@@ -194,11 +199,16 @@ public class StatisticsDataController {
|
|
|
DateTime now = DateTime.now();
|
|
|
DateTime begin = DateUtil.beginOfMonth(now);
|
|
|
String statisticsDate = DateUtil.format(now, "yyyy-MM");
|
|
|
- List<CustomerServiceHandleOrderToMonthView> toMonthDetail = realGoodsOrderHandleMapper.selectCustomerToMonthData(now, begin, OrderCustomerHandleScheduler.noOrderStatus, type);
|
|
|
StatisticsCustomerDataView customerDataView = new StatisticsCustomerDataView();
|
|
|
+ StatisticsCustomerServiceEveryMonthView toMonth = new StatisticsCustomerServiceEveryMonthView();
|
|
|
+ toMonth.setStatisticsData(statisticsDate);
|
|
|
+ List<CustomerServiceHandleOrderToMonthView> toMonthDetail;
|
|
|
+ if (type == 3) {
|
|
|
+ toMonthDetail = customerServiceRenewOrderRecordMapper.selectCustomerToMonthData(now, begin, type);
|
|
|
+ } else {
|
|
|
+ toMonthDetail = realGoodsOrderHandleMapper.selectCustomerToMonthData(now, begin, OrderCustomerHandleScheduler.noOrderStatus, type);
|
|
|
+ }
|
|
|
if (!toMonthDetail.isEmpty()) {
|
|
|
- StatisticsCustomerServiceEveryMonthView toMonth = new StatisticsCustomerServiceEveryMonthView();
|
|
|
- toMonth.setStatisticsData(statisticsDate);
|
|
|
toMonth.setDetails(toMonthDetail);
|
|
|
customerDataView.setToMonth(toMonth);
|
|
|
}
|
|
|
@@ -210,6 +220,45 @@ public class StatisticsDataController {
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(customerDataView);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 客服业绩订单明细
|
|
|
+ */
|
|
|
+ @GetMapping("/get/service/orders/detail")
|
|
|
+ public Result<CustomerServiceOrdersDetailView> getCustomerData(Integer type, String monthDate, String customerService, HttpServletRequest request) {
|
|
|
+ DateTime month = null;
|
|
|
+ if (StrUtil.isEmpty(monthDate)) {
|
|
|
+ month = DateTime.now();
|
|
|
+ } else {
|
|
|
+ month = DateUtil.parse(monthDate, "yyyy-MM-dd");
|
|
|
+ }
|
|
|
+ DateTime beginOfMonth = DateUtil.beginOfMonth(month);
|
|
|
+ DateTime endOfMonth = DateUtil.endOfMonth(month);
|
|
|
+ CustomerServiceOrdersDetailView view = new CustomerServiceOrdersDetailView();
|
|
|
+ if (type != 3) {
|
|
|
+ MapBuilder builder = MapUtils.flatBuilder(request.getParameterMap())
|
|
|
+ .field(ServiceOrdersDetailView::getRecordCreatedTime, beginOfMonth, endOfMonth).op(Operator.Between);
|
|
|
+ if (type == 1) {
|
|
|
+ builder.field(ServiceOrdersDetailView::getBeforeServiceName, customerService).op(Operator.Equal);
|
|
|
+ } else if (type == 2) {
|
|
|
+ builder.field(ServiceOrdersDetailView::getAfterServiceName, customerService).op(Operator.Equal);
|
|
|
+ }
|
|
|
+ builder.field(ServiceOrdersDetailView::getStatus, OrderCustomerHandleScheduler.noOrderStatus).op(Operator.NotIn);
|
|
|
+ SearchResult<ServiceOrdersDetailView> search = beanSearcher.search(ServiceOrdersDetailView.class, builder.build());
|
|
|
+ Number AppleTV = beanSearcher.searchCount(ServiceOrdersDetailView.class, builder.field(ServiceOrdersDetailView::getSpecVal, "Apple TV").op(Operator.Contain).build());
|
|
|
+ Number Chromecast = beanSearcher.searchCount(ServiceOrdersDetailView.class, builder.field(ServiceOrdersDetailView::getSpecVal, "Chromecast").op(Operator.Contain).build());
|
|
|
+ view.setAppleTV(AppleTV.intValue());
|
|
|
+ view.setChromecast(Chromecast.intValue());
|
|
|
+ view.setOrders(search.getTotalCount().intValue());
|
|
|
+ view.setResult(search);
|
|
|
+ } else {
|
|
|
+ SearchResult<ServiceRenewOrdersDetailView> search = beanSearcher.search(ServiceRenewOrdersDetailView.class, MapUtils.flatBuilder(request.getParameterMap())
|
|
|
+ .field(ServiceRenewOrdersDetailView::getCustomerService, customerService).op(Operator.Equal)
|
|
|
+ .field(ServiceRenewOrdersDetailView::getRecordCreatedTime, beginOfMonth, endOfMonth).op(Operator.Between).build());
|
|
|
+ view.setResult(search);
|
|
|
+ }
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(view);
|
|
|
+ }
|
|
|
+
|
|
|
@GetMapping("/get/stock")
|
|
|
public Result<List<StatisticsStockView>> getStock(HttpServletRequest request, @RequestParam(defaultValue = "0") Long startTime,@RequestParam(defaultValue = "0") Long endTime){
|
|
|
List<GoodsDonStock> goodsDonStocks = beanSearcher.searchAll(GoodsDonStock.class, MapUtils.flatBuilder(request.getParameterMap()).build());
|
|
|
@@ -279,4 +328,26 @@ public class StatisticsDataController {
|
|
|
EasyExcelUtils.createExcelStreamMutilByEasyExcel(response, StatisticsStockView.class, res, "库存统计", "库存统计", ExcelTypeEnum.XLSX, null);
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量分配客服
|
|
|
+ */
|
|
|
+ @PostMapping("/batch/service")
|
|
|
+ public Result<String> batchService(@RequestBody List<BatchServiceReq> batchServices) {
|
|
|
+ batchServices.forEach(service -> {
|
|
|
+ if (StrUtil.isEmpty(service.getCustomerService())) {
|
|
|
+ throw BusinessRuntimeException.getInstance("所分配客服不能为空");
|
|
|
+ }
|
|
|
+ GroupsRelation relation = groupsRelationMapper.selectById(service.getRelationId());
|
|
|
+ if (relation == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (StrUtil.isEmpty(relation.getCustomerService()) && relation.getUserId() != 0
|
|
|
+ && GroupsRelation.Status.validity == relation.getStatus()) {
|
|
|
+ relation.setCustomerService(service.getCustomerService());
|
|
|
+ groupsRelationMapper.updateById(relation);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult("分配客服成功");
|
|
|
+ }
|
|
|
}
|