|
@@ -17,6 +17,7 @@ import com.ydd.module.service.IProfitsActivityService;
|
|
|
import com.ydd.module.service.IShopService;
|
|
|
import com.ydd.module.utils.CommonUtils;
|
|
|
import lombok.SneakyThrows;
|
|
|
+import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.apache.commons.compress.utils.Lists;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.commons.lang3.time.DateFormatUtils;
|
|
@@ -24,10 +25,7 @@ import org.apache.commons.lang3.time.DateUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -61,8 +59,11 @@ public class ProfitsActivityServiceImpl extends ServiceImpl<ProfitsActivityMappe
|
|
|
// 查询昨天有取消订单或者完成订单的商户
|
|
|
List<Merchant> merchantList = baseMapper.selectMerchantByDate(startTime, endTime);
|
|
|
List<Long> merchantIds = merchantList.stream().map(Merchant::getId).collect(Collectors.toList());
|
|
|
- List<Shop> shops = iShopService.getShopByMerchantIds(merchantIds);
|
|
|
- Map<Long, List<Shop>> shopMap = shops.stream().collect(Collectors.groupingBy(Shop::getMerchantId));
|
|
|
+ Map<Long, List<Shop>> shopMap = new HashMap<>();
|
|
|
+ if (CollectionUtils.isNotEmpty(merchantIds)) {
|
|
|
+ List<Shop> shops = iShopService.getShopByMerchantIds(merchantIds);
|
|
|
+ shopMap = shops.stream().collect(Collectors.groupingBy(Shop::getMerchantId));
|
|
|
+ }
|
|
|
for (Merchant merchant : merchantList) {
|
|
|
Long merchantId = merchant.getId();
|
|
|
ProfitsActivity profitsActivity = new ProfitsActivity();
|
|
@@ -73,11 +74,15 @@ public class ProfitsActivityServiceImpl extends ServiceImpl<ProfitsActivityMappe
|
|
|
profitsActivity.setMerchantId(merchantId);
|
|
|
// 查询商户昨天下单量(type: 4-> 完成,-1-> 取消)
|
|
|
List<Shop> shopList = shopMap.get(merchantId);
|
|
|
- List<Long> shopIds = shopList.stream().map(Shop::getId).collect(Collectors.toList());
|
|
|
- Integer completeNum = baseMapper.getOrderNumByShopIdsAndTime(shopIds, 4, startTime, endTime);
|
|
|
- Integer cancelNum = baseMapper.getOrderNumByShopIdsAndTime(shopIds, -1, startTime, endTime);
|
|
|
+ Integer completeNum = 0;
|
|
|
+ Integer cancelNum = 0;
|
|
|
+ if (CollectionUtils.isNotEmpty(shopList)) {
|
|
|
+ List<Long> shopIds = shopList.stream().map(Shop::getId).collect(Collectors.toList());
|
|
|
+ completeNum = baseMapper.getOrderNumByShopIdsAndTime(shopIds, 4, startTime, endTime);
|
|
|
+ cancelNum = baseMapper.getOrderNumByShopIdsAndTime(shopIds, -1, startTime, endTime);
|
|
|
// Integer completeNum = baseMapper.selectOrderNumByDate(merchantId, date, 4);
|
|
|
// Integer cancelNum = baseMapper.selectOrderNumByDate(merchantId, date, -1);
|
|
|
+ }
|
|
|
// 完成订单数
|
|
|
profitsActivity.setCompleteNum(completeNum);
|
|
|
// 取消订单数
|