|
@@ -88,6 +88,7 @@ public class HomeController extends BaseController {
|
|
|
return Result.success(map);
|
|
|
}
|
|
|
|
|
|
+ @BindAgent
|
|
|
@GetMapping("/dataInfo")
|
|
|
public Result dataInfo() {
|
|
|
SysUser user = getSysUser();
|
|
@@ -108,34 +109,43 @@ public class HomeController extends BaseController {
|
|
|
}
|
|
|
}
|
|
|
// List<Long> agentIds = iAgentService.listAgent(user.getAgentId());
|
|
|
- List<Long> merchantIds = iMerchantService.findMerchantIdByAgentId(agentIds);
|
|
|
List<Long> shopIds = Lists.newArrayList();
|
|
|
- if (CollectionUtils.isNotEmpty(merchantIds)) {
|
|
|
- shopIds = iShopService.findShopIdByMerchantId(merchantIds);
|
|
|
+ if (CollectionUtils.isNotEmpty(agentIds)) {
|
|
|
+ List<Long> merchantIds = iMerchantService.findMerchantIdByAgentId(agentIds);
|
|
|
+ if (CollectionUtils.isNotEmpty(merchantIds)) {
|
|
|
+ shopIds = iShopService.findShopIdByMerchantId(merchantIds);
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
for (int i = 1; i < 3; i++) {
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
String todayStartDate = DateUtils.parseToBeginTime(dft.format(new Date()));
|
|
|
- if (i == 2) {
|
|
|
- Date beginDate = new Date();
|
|
|
- Calendar date = Calendar.getInstance();
|
|
|
- date.setTime(beginDate);
|
|
|
- date.set(Calendar.DATE, date.get(Calendar.DATE) - 1);
|
|
|
- String yesStartDate = DateUtils.parseToBeginTime(dft.format(date.getTime()));
|
|
|
- String yesEndDate = DateUtils.parseToTomorrowBeginTime(dft.format(date.getTime()));
|
|
|
- map.put("commission", iProfitsAgentService.selectCommissionByAgentId(user.getAgentId(), yesStartDate, yesEndDate));
|
|
|
-
|
|
|
- map.put("agentNum", iAgentService.getSAgentNum(user.getAgentId().intValue(), todayStartDate));
|
|
|
- map.put("merchantNum", iMerchantService.getMerchantNum(user.getAgentId().intValue(), todayStartDate));
|
|
|
+ if (CollectionUtils.isNotEmpty(agentIds)) {
|
|
|
+ if (i == 2) {
|
|
|
+ Date beginDate = new Date();
|
|
|
+ Calendar date = Calendar.getInstance();
|
|
|
+ date.setTime(beginDate);
|
|
|
+ date.set(Calendar.DATE, date.get(Calendar.DATE) - 1);
|
|
|
+ String yesStartDate = DateUtils.parseToBeginTime(dft.format(date.getTime()));
|
|
|
+ String yesEndDate = DateUtils.parseToTomorrowBeginTime(dft.format(date.getTime()));
|
|
|
+ map.put("commission", iProfitsAgentService.selectCommissionByAgentId(agentIds, yesStartDate, yesEndDate));
|
|
|
+
|
|
|
+ map.put("agentNum", iAgentService.getSAgentNum(agentIds, todayStartDate));
|
|
|
+ map.put("merchantNum", iMerchantService.getMerchantNum(agentIds, todayStartDate));
|
|
|
+ } else {
|
|
|
+ List<Double> commissions = iProfitsDetailService.getProfitCommissionList(agentIds, null);
|
|
|
+ double commissionDouble = commissions.stream().collect(Collectors.summarizingDouble(value -> value)).getSum();
|
|
|
+ BigDecimal commission = BigDecimal.valueOf(commissionDouble).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ map.put("commission", commission);
|
|
|
+ map.put("agentNum", iAgentService.getSAgentNum(agentIds, null));
|
|
|
+ map.put("merchantNum", iMerchantService.getMerchantNum(agentIds, null));
|
|
|
+ }
|
|
|
} else {
|
|
|
-// BigDecimal commission = iProfitsDetailService.countBigDecimal(user.getAgentId(), null);
|
|
|
- List<Double> commissions = iProfitsDetailService.getProfitCommissionList(user.getAgentId(), null);
|
|
|
- double commissionDouble = commissions.stream().collect(Collectors.summarizingDouble(value -> value)).getSum();
|
|
|
- BigDecimal commission = BigDecimal.valueOf(commissionDouble).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
- map.put("commission", commission);
|
|
|
- map.put("agentNum", iAgentService.getSAgentNum(user.getAgentId().intValue(), null));
|
|
|
- map.put("merchantNum", iMerchantService.getMerchantNum(user.getAgentId().intValue(), null));
|
|
|
+ map.put("commission", BigDecimal.ZERO);
|
|
|
+ map.put("agentNum", BigDecimal.ZERO);
|
|
|
+ map.put("merchantNum", BigDecimal.ZERO);
|
|
|
}
|
|
|
+
|
|
|
if (agentIds.size() == ListSizeEnum.ZERO.getSize() || shopIds.size() == 0) {
|
|
|
map.put("orderNum", 0);
|
|
|
map.put("orderAmount", BigDecimal.ZERO);
|