|
|
@@ -4,6 +4,7 @@ import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
|
import cn.dev33.satoken.stp.StpUtil;
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.date.BetweenFormater;
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
@@ -49,6 +50,7 @@ import javax.validation.constraints.NotNull;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/*
|
|
|
*项目名: netflix
|
|
|
@@ -824,4 +826,77 @@ public class DistributeController {
|
|
|
});
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(search);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 商务分销当月渠道商以及历史渠道商在当月的数据
|
|
|
+ */
|
|
|
+ @GetMapping("/get/business/distribute/monthlyData")
|
|
|
+ public Result<List<BusinessDistributesMonthlyDataView>> getBusinessMonthlyData(String firstMonthDate, String secondMonthDate) {
|
|
|
+ long adminId = StpUtil.getLoginIdAsLong();
|
|
|
+ if (StrUtil.isEmpty(firstMonthDate)) {
|
|
|
+ firstMonthDate = DateUtil.beginOfMonth(DateTime.now()).toDateStr();
|
|
|
+ }
|
|
|
+ if (StrUtil.isEmpty(secondMonthDate)) {
|
|
|
+ secondMonthDate = DateUtil.offsetMonth(DateUtil.beginOfMonth(DateTime.now()), 1).toDateStr();
|
|
|
+ }
|
|
|
+ MapBuilder builder = MapUtils.flatBuilder(request.getParameterMap());
|
|
|
+ //是否是商务人员
|
|
|
+ Boolean isBusiness = userBusinessRateService.isBusiness(adminId);
|
|
|
+ if (isBusiness) {
|
|
|
+ builder.field(BusinessDistributesMonthlyDataView::getBusinessId, adminId);
|
|
|
+ }
|
|
|
+ builder.put("n", "(select nickname from cms_user where id = ud.business_id limit 1)");
|
|
|
+ //当月渠道本月数据
|
|
|
+ String time1Sql = StrUtil.EMPTY;
|
|
|
+ String time2Sql = StrUtil.EMPTY;
|
|
|
+ String time3Sql = StrUtil.EMPTY;
|
|
|
+ if (StrUtil.isNotBlank(firstMonthDate)) {
|
|
|
+ time1Sql += String.format(" and ud.business_bind_time >= '%s'", firstMonthDate);
|
|
|
+ time2Sql += String.format(" and us.created_time >= '%s'", firstMonthDate);
|
|
|
+ time3Sql += String.format(" and od.created_time >= '%s'", firstMonthDate);
|
|
|
+ }
|
|
|
+ if (StrUtil.isNotBlank(secondMonthDate)) {
|
|
|
+ time1Sql += String.format(" and ud.business_bind_time < '%s'", secondMonthDate);
|
|
|
+ time2Sql += String.format(" and us.created_time < '%s'", secondMonthDate);
|
|
|
+ time3Sql += String.format(" and od.created_time < '%s'", secondMonthDate);
|
|
|
+ }
|
|
|
+ if (StrUtil.isNotBlank(time1Sql)) {
|
|
|
+ builder.put("time1", time1Sql);
|
|
|
+ }
|
|
|
+ if (StrUtil.isNotBlank(time2Sql)) {
|
|
|
+ builder.put("time2", time2Sql);
|
|
|
+ }
|
|
|
+ if (StrUtil.isNotBlank(time3Sql)) {
|
|
|
+ builder.put("time3", time3Sql);
|
|
|
+ }
|
|
|
+ builder.put("type", 1);
|
|
|
+ List<BusinessDistributesMonthlyDataView> search = beanSearcher.searchAll(BusinessDistributesMonthlyDataView.class, builder.build());
|
|
|
+ //历史渠道 当月数据
|
|
|
+ time1Sql = StrUtil.EMPTY;
|
|
|
+ time2Sql = StrUtil.EMPTY;
|
|
|
+ time3Sql = StrUtil.EMPTY;
|
|
|
+ if (StrUtil.isNotBlank(firstMonthDate)) {
|
|
|
+ time1Sql += String.format(" and ud.business_bind_time < '%s'", firstMonthDate);
|
|
|
+ time2Sql += String.format(" and us.created_time >= '%s'", firstMonthDate);
|
|
|
+ time3Sql += String.format(" and od.created_time >= '%s'", firstMonthDate);
|
|
|
+ }
|
|
|
+ if (StrUtil.isNotBlank(secondMonthDate)) {
|
|
|
+ time2Sql += String.format(" and us.created_time < '%s'", secondMonthDate);
|
|
|
+ time3Sql += String.format(" and od.created_time < '%s'", secondMonthDate);
|
|
|
+ }
|
|
|
+ if (StrUtil.isNotBlank(time1Sql)) {
|
|
|
+ builder.put("time1", time1Sql);
|
|
|
+ }
|
|
|
+ if (StrUtil.isNotBlank(time2Sql)) {
|
|
|
+ builder.put("time2", time2Sql);
|
|
|
+ }
|
|
|
+ if (StrUtil.isNotBlank(time3Sql)) {
|
|
|
+ builder.put("time3", time3Sql);
|
|
|
+ }
|
|
|
+ builder.put("type", 2);
|
|
|
+ List<BusinessDistributesMonthlyDataView> search2 = beanSearcher.searchAll(BusinessDistributesMonthlyDataView.class, builder.build());
|
|
|
+ Collection<BusinessDistributesMonthlyDataView> businessDistributesDataViews = CollUtil.addAll(search, search2);
|
|
|
+ List<BusinessDistributesMonthlyDataView> collect = businessDistributesDataViews.stream().sorted(Comparator.comparing(BusinessDistributesMonthlyDataView::getBusinessId).thenComparing(BusinessDistributesMonthlyDataView::getType)).collect(Collectors.toList());
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(collect);
|
|
|
+ }
|
|
|
}
|