|
|
@@ -16,10 +16,7 @@ import com.cyksj.common.util.StringUtil;
|
|
|
import com.cyksj.dto.Result;
|
|
|
import com.cyksj.enums.BusinessType;
|
|
|
import com.cyksj.enums.GatewayResponse;
|
|
|
-import com.cyksj.mapper.DistributeGoodsSkuAlertMapper;
|
|
|
-import com.cyksj.mapper.GoodsDonMapper;
|
|
|
-import com.cyksj.mapper.GoodsDonSkuMapper;
|
|
|
-import com.cyksj.mapper.UserMapper;
|
|
|
+import com.cyksj.mapper.*;
|
|
|
import com.cyksj.mapper.manage.cms.CmsUserMapper;
|
|
|
import com.cyksj.mapper.manage.coupon.CouponDistributePopularizeMapper;
|
|
|
import com.cyksj.mapper.manage.distribute.*;
|
|
|
@@ -54,7 +51,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|
|
import java.util.concurrent.atomic.AtomicBoolean;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
-/*
|
|
|
+/** 分销管理
|
|
|
*项目名: netflix
|
|
|
*文件名: DistributeController
|
|
|
*创建者: JavaZou
|
|
|
@@ -112,6 +109,12 @@ public class DistributeController {
|
|
|
|
|
|
private final UserDistributeBusinessGeneralRateMapper businessGeneralRateMapper;
|
|
|
|
|
|
+ private final OrderDonMapper orderDonMapper;
|
|
|
+
|
|
|
+ private final UserDistributeTargetAlertMapper targetAlertMapper;
|
|
|
+
|
|
|
+ private final UserDistributeTargetAlertRecordMapper targetAlertRecordMapper;
|
|
|
+
|
|
|
/**
|
|
|
* 添加固定推广者
|
|
|
*/
|
|
|
@@ -172,9 +175,46 @@ public class DistributeController {
|
|
|
.orderBy(UserSkuDistributeView::getGoodsId).asc()
|
|
|
.build());
|
|
|
rateDetailView.setSkuRates(skuRates);
|
|
|
+
|
|
|
+ List<CouponDistributePopularizeDetailView> distributePopularizes = beanSearcher.searchAll(CouponDistributePopularizeDetailView.class, MapUtils.builder()
|
|
|
+ .field(CouponDistributePopularizeDetailView::getDistributeId, id)
|
|
|
+ .build());
|
|
|
+ rateDetailView.setCouponRelates(distributePopularizes);
|
|
|
+
|
|
|
+ List<UserDistributeTargetAlert> targets = targetAlertMapper.selectList(Wrappers.lambdaQuery(UserDistributeTargetAlert.class)
|
|
|
+ .eq(UserDistributeTargetAlert::getDistributeId, id));
|
|
|
+ rateDetailView.setTargets(targets);
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(rateDetailView);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 固定渠道平台分销详情 趋势图
|
|
|
+ */
|
|
|
+ @GetMapping("/get/distribute/plat/brokenLine/{sharedId}")
|
|
|
+ public Result<BrokenLineObjView> getDsPlatBrokenLine(@PathVariable Long sharedId, Long firstDate, Long lastDate) {
|
|
|
+ String first = null;
|
|
|
+ String end = null;
|
|
|
+ if (firstDate != null) {
|
|
|
+ first = DateUtil.format(DateTime.of(firstDate), "yyyy-MM-dd");
|
|
|
+ }
|
|
|
+ if (lastDate != null) {
|
|
|
+ end = DateUtil.format(DateTime.of(lastDate), "yyyy-MM-dd");
|
|
|
+ }
|
|
|
+ BrokenLineObjView brokenLineObjView = Optional.ofNullable(orderDonMapper.selectDsPlatBrokenLineMoney(sharedId, first, end))
|
|
|
+ .orElse(new BrokenLineObjView());
|
|
|
+
|
|
|
+ if (brokenLineObjView != null) {
|
|
|
+ List<DistributePlatOrderDonBrokenLineView> views = beanSearcher.searchAll(DistributePlatOrderDonBrokenLineView.class, MapUtils.builder()
|
|
|
+ .field(DistributePlatOrderDonBrokenLineView::getDate, first, end).op(Operator.Between)
|
|
|
+ .put("sid", String.format("where shared_id = %s", sharedId))
|
|
|
+ .orderBy(DistributePlatOrderDonBrokenLineView::getDate).asc()
|
|
|
+ .build());
|
|
|
+ Map<Long, List<DistributePlatOrderDonBrokenLineView>> goodsMap = views.stream().collect(Collectors.groupingBy(DistributePlatOrderDonBrokenLineView::getGoodsId));
|
|
|
+ brokenLineObjView.setDsGoodsData(goodsMap);
|
|
|
+ }
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(brokenLineObjView);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 固定推广者列表
|
|
|
*/
|
|
|
@@ -907,7 +947,7 @@ public class DistributeController {
|
|
|
if (isBusiness) {
|
|
|
builder.field(BusinessDistributesMonthlyDataView::getBusinessId, adminId);
|
|
|
}
|
|
|
- builder.put("n", "(select nickname from cms_user where id = ud.business_id limit 1)");
|
|
|
+ builder.put("n", "(select nickname from cms_user where id = ur.business_id limit 1)");
|
|
|
//当月渠道本月数据
|
|
|
String time1Sql = StrUtil.EMPTY;
|
|
|
String time2Sql = StrUtil.EMPTY;
|
|
|
@@ -932,6 +972,7 @@ public class DistributeController {
|
|
|
builder.put("time3", time3Sql);
|
|
|
}
|
|
|
builder.put("type", 1);
|
|
|
+ builder.put("sorted", 0);
|
|
|
List<BusinessDistributesMonthlyDataView> search = beanSearcher.searchAll(BusinessDistributesMonthlyDataView.class, builder.build());
|
|
|
//历史渠道 当月数据
|
|
|
time1Sql = StrUtil.EMPTY;
|
|
|
@@ -956,9 +997,39 @@ public class DistributeController {
|
|
|
builder.put("time3", time3Sql);
|
|
|
}
|
|
|
builder.put("type", 2);
|
|
|
+ builder.put("sorted", 99);
|
|
|
+
|
|
|
List<BusinessDistributesMonthlyDataView> search2 = 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 between '%s' and '%s'", DateUtil.offsetMonth(DateUtil.parse(firstMonthDate, "yyyy-MM-dd"), -1), 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", 3);
|
|
|
+ builder.put("sorted", 1);
|
|
|
+ //上个月渠道在本月历史数据
|
|
|
+ List<BusinessDistributesMonthlyDataView> search3 = 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());
|
|
|
+ businessDistributesDataViews = CollUtil.addAll(businessDistributesDataViews, search3);
|
|
|
+ List<BusinessDistributesMonthlyDataView> collect = businessDistributesDataViews.stream().sorted(Comparator.comparing(BusinessDistributesMonthlyDataView::getBusinessId).thenComparing(BusinessDistributesMonthlyDataView::getSorted)).collect(Collectors.toList());
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(collect);
|
|
|
}
|
|
|
|
|
|
@@ -1049,4 +1120,28 @@ public class DistributeController {
|
|
|
Integer count = distributeGoodsSkuAlertMapper.selectCountByCondition();
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(count > 0 ? true : false);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 渠道预警列表
|
|
|
+ */
|
|
|
+ @GetMapping("/get/target/alert/list")
|
|
|
+ public Result<SearchResult<UserDistributeTargetAlertView>> getTargetAlertList() {
|
|
|
+ SearchResult<UserDistributeTargetAlertView> search = beanSearcher.search(UserDistributeTargetAlertView.class, MapUtils.flatBuilder(request.getParameterMap())
|
|
|
+ .orderBy(UserDistributeTargetAlertView::getId).desc()
|
|
|
+ .build());
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(search);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 跟进渠道预警
|
|
|
+ */
|
|
|
+ @PutMapping("/update/target/alert/status/{id}")
|
|
|
+ public Result<String> updateTargetAlertStatus(@PathVariable Long id) {
|
|
|
+ UserDistributeTargetAlertRecord record = targetAlertRecordMapper.selectById(id);
|
|
|
+ if (record != null && !record.getStatus()) {
|
|
|
+ record.setStatus(true);
|
|
|
+ targetAlertRecordMapper.updateById(record);
|
|
|
+ }
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
+ }
|
|
|
}
|