|
@@ -18,6 +18,7 @@ import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.jetbrains.annotations.NotNull;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
@@ -28,14 +29,7 @@ import java.math.BigDecimal;
|
|
|
import java.rmi.MarshalledObject;
|
|
|
import java.text.ParsePosition;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.Collection;
|
|
|
-import java.util.Comparator;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.Optional;
|
|
|
+import java.util.*;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -147,29 +141,41 @@ public class OpenDouble11StaticsController extends BaseController {
|
|
|
.collect(Collectors.toMap(Organization::getId, Function.identity()));
|
|
|
orgIdMap.putAll(mapById);
|
|
|
}
|
|
|
- setQueryParam(query, configParam);
|
|
|
-
|
|
|
- List<Double11StaticWrapper.SaleAmountAndUser> saleAmount = studentPaymentOrderDao.saleStaticsByOrgId(query);
|
|
|
- Map<Integer, Double11StaticWrapper.SaleAmountAndUser> idDataMap = saleAmount.stream()
|
|
|
- .collect(Collectors.toMap(Double11StaticWrapper.SaleAmountAndUser::getOrganId, Function.identity()));
|
|
|
-
|
|
|
- List<Double11StaticWrapper.SaleAmountAndUser> result = orgIdMap.entrySet().stream()
|
|
|
- .map(next -> {
|
|
|
- if(idDataMap.containsKey(next.getKey())){
|
|
|
- Double11StaticWrapper.SaleAmountAndUser saleAmountAndUser = idDataMap.get(next.getKey());
|
|
|
- saleAmountAndUser.setOrganName(next.getValue().getName());
|
|
|
- return saleAmountAndUser;
|
|
|
- }
|
|
|
-
|
|
|
- Double11StaticWrapper.SaleAmountAndUser statics = new Double11StaticWrapper.SaleAmountAndUser();
|
|
|
- statics.setOrganId(next.getKey());
|
|
|
- statics.setOrganName(next.getValue().getName());
|
|
|
- statics.setActualAmount(new BigDecimal(0));
|
|
|
- statics.setBalancePaymentAmount(new BigDecimal(0));
|
|
|
- statics.setUserPurchaseNumber(0);
|
|
|
- return statics;
|
|
|
- }).collect(Collectors.toList());
|
|
|
+ List<Double11StaticWrapper.SaleAmountAndUser> result;
|
|
|
+ Integer saleStaticsType = query.getSaleStaticsType();
|
|
|
+ if (0 == saleStaticsType) { //将不同类型数据汇总
|
|
|
+ List<Double11StaticWrapper.SaleAmountAndUser> allResult = new ArrayList<>();
|
|
|
+ for (int i = 1; i <= 6; i++) {
|
|
|
+ query.setSaleStaticsType(i);
|
|
|
+ setQueryParam(query, configParam);
|
|
|
+ List<Double11StaticWrapper.SaleAmountAndUser> oneResult = queryOrgSaleAmount(query, orgIdMap);
|
|
|
+ allResult.addAll(oneResult);
|
|
|
+ }
|
|
|
+ Map<Integer, List<Double11StaticWrapper.SaleAmountAndUser>> groupByOrg = allResult.stream()
|
|
|
+ .collect(Collectors.groupingBy(Double11StaticWrapper.SaleAmountAndUser::getOrganId));
|
|
|
+ result = groupByOrg.entrySet().stream()
|
|
|
+ .map(entry -> {
|
|
|
+ Double11StaticWrapper.SaleAmountAndUser amount = new Double11StaticWrapper.SaleAmountAndUser();
|
|
|
+ amount.setOrganId(entry.getKey());
|
|
|
+ amount.setOrganName(orgIdMap.getOrDefault(entry.getKey(), new Organization()).getName());
|
|
|
+ Set<Integer> userIds = new HashSet<>();
|
|
|
+ for (Double11StaticWrapper.SaleAmountAndUser v : entry.getValue()) {
|
|
|
+ amount.setActualAmount(amount.getActualAmount().add(v.getActualAmount()));
|
|
|
+ amount.setBalancePaymentAmount(amount.getBalancePaymentAmount().add(v.getBalancePaymentAmount()));
|
|
|
+ String userId = v.getUserIds();
|
|
|
+ if (StringUtils.isNotEmpty(userId)) {
|
|
|
+ userIds.addAll(Arrays.stream(userId.split(",")).map(Integer::valueOf).collect(Collectors.toList()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ amount.setUserPurchaseNumber(userIds.size());
|
|
|
+ return amount;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ } else {
|
|
|
+ setQueryParam(query, configParam);
|
|
|
+ result = queryOrgSaleAmount(query, orgIdMap);
|
|
|
+ }
|
|
|
|
|
|
+ // 排序
|
|
|
String orderBy = Optional.ofNullable(query.getOrderBy()).orElse("saleAmount");
|
|
|
int asc = Optional.ofNullable(query.getAsc()).orElse(0);
|
|
|
if ("saleAmount".equals(orderBy)) {
|
|
@@ -192,6 +198,7 @@ public class OpenDouble11StaticsController extends BaseController {
|
|
|
return R.from(result);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
@ApiOperation(value = "2023双11销售统计详情", notes = "2023双11销售统计详情")
|
|
|
@GetMapping("/queryStudentPaymentOrder")
|
|
|
public R<PageInfo<Double11StaticWrapper.SaleStaticsStudent>> queryStudentPaymentOrder(Double11StaticWrapper.SaleStaticsStudentQuery query) {
|
|
@@ -256,12 +263,12 @@ public class OpenDouble11StaticsController extends BaseController {
|
|
|
|
|
|
if (saleStaticsType == 1) {
|
|
|
// 1V1
|
|
|
- query.setGroupType(GroupType.VIP);
|
|
|
+ query.setGroupType(GroupType.ACTIVITY);
|
|
|
query.setType(OrderTypeEnum.SMALL_CLASS_TO_BUY);
|
|
|
query.setActivityId(configParam.getV1());
|
|
|
} else if (saleStaticsType == 2) {
|
|
|
// 1v2
|
|
|
- query.setGroupType(GroupType.VIP);
|
|
|
+ query.setGroupType(GroupType.ACTIVITY);
|
|
|
query.setType(OrderTypeEnum.SMALL_CLASS_TO_BUY);
|
|
|
query.setActivityId(configParam.getV2());
|
|
|
} else if (saleStaticsType == 3) {
|
|
@@ -298,4 +305,28 @@ public class OpenDouble11StaticsController extends BaseController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private List<Double11StaticWrapper.SaleAmountAndUser> queryOrgSaleAmount(Double11StaticWrapper.SaleStaticsQuery query,
|
|
|
+ Map<Integer, Organization> orgIdMap) {
|
|
|
+ List<Double11StaticWrapper.SaleAmountAndUser> saleAmount = studentPaymentOrderDao.saleStaticsByOrgId(query);
|
|
|
+ Map<Integer, Double11StaticWrapper.SaleAmountAndUser> idDataMap = saleAmount.stream()
|
|
|
+ .collect(Collectors.toMap(Double11StaticWrapper.SaleAmountAndUser::getOrganId, Function.identity()));
|
|
|
+
|
|
|
+ return orgIdMap.entrySet().stream()
|
|
|
+ .map(next -> {
|
|
|
+ if (idDataMap.containsKey(next.getKey())) {
|
|
|
+ Double11StaticWrapper.SaleAmountAndUser saleAmountAndUser = idDataMap.get(next.getKey());
|
|
|
+ saleAmountAndUser.setOrganName(next.getValue().getName());
|
|
|
+ return saleAmountAndUser;
|
|
|
+ }
|
|
|
+
|
|
|
+ Double11StaticWrapper.SaleAmountAndUser statics = new Double11StaticWrapper.SaleAmountAndUser();
|
|
|
+ statics.setOrganId(next.getKey());
|
|
|
+ statics.setOrganName(next.getValue().getName());
|
|
|
+ statics.setActualAmount(new BigDecimal(0));
|
|
|
+ statics.setBalancePaymentAmount(new BigDecimal(0));
|
|
|
+ statics.setUserPurchaseNumber(0);
|
|
|
+ return statics;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
}
|