|
|
@@ -13,7 +13,6 @@ import com.txz.mall.dao.StoreOrderMapper;
|
|
|
import com.txz.mall.dao.StorePinkMapper;
|
|
|
import com.txz.mall.dubbo.client.CifRedEnvelopeDubboServiceClient;
|
|
|
import com.txz.mall.dubbo.client.CifUserDubboServiceClient;
|
|
|
-import com.txz.mall.enums.PinkOrderStatusEnum;
|
|
|
import com.txz.mall.model.*;
|
|
|
import com.txz.mall.service.*;
|
|
|
import com.txz.mall.util.I18nUtil;
|
|
|
@@ -26,12 +25,11 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.ObjectUtils;
|
|
|
import tk.mybatis.mapper.entity.Condition;
|
|
|
import tk.mybatis.mapper.entity.Example;
|
|
|
-import tk.mybatis.mapper.entity.SqlsCriteria;
|
|
|
import vo.StoreCombinationRankVO;
|
|
|
import vo.StoreOrderVO;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import java.text.SimpleDateFormat;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -44,7 +42,7 @@ import java.util.stream.Collectors;
|
|
|
@AllArgsConstructor
|
|
|
@Slf4j
|
|
|
public class OrderServiceBusinessImpl implements OrderServiceBusiness {
|
|
|
-
|
|
|
+
|
|
|
private final StoreOrderService storeOrderService;
|
|
|
private final StoreOrderInfoService storeOrderInfoService;
|
|
|
private final UserAddressService userAddressService;
|
|
|
@@ -56,34 +54,35 @@ public class OrderServiceBusinessImpl implements OrderServiceBusiness {
|
|
|
private final CifRedEnvelopeDubboServiceClient cifRedEnvelopeDubboServiceClient;
|
|
|
private final StoreOrderMapper storeOrderMapper;
|
|
|
private final StoreProductService storeProductService;
|
|
|
+
|
|
|
@Override
|
|
|
public StoreOrderVO orderDetail(Long id, String orderNo) {
|
|
|
StoreOrderVO vo = new StoreOrderVO();
|
|
|
-
|
|
|
-// if (!ObjectUtils.isEmpty(id)) {
|
|
|
-// storeOrder = storeOrderService.findById(id);
|
|
|
-// } else if (!ObjectUtils.isEmpty(orderNo)) {
|
|
|
+
|
|
|
+ // if (!ObjectUtils.isEmpty(id)) {
|
|
|
+ // storeOrder = storeOrderService.findById(id);
|
|
|
+ // } else if (!ObjectUtils.isEmpty(orderNo)) {
|
|
|
StoreOrder storeOrder = storeOrderService.findBy("orderId", orderNo);
|
|
|
- // }
|
|
|
-
|
|
|
+ // }
|
|
|
+
|
|
|
if (ObjectUtils.isEmpty(storeOrder)) {
|
|
|
throw new ServiceException(I18nUtil.get("order.does.not.exist.id") + orderNo);
|
|
|
}
|
|
|
- // id = storeOrder.getId();
|
|
|
+ // id = storeOrder.getId();
|
|
|
Condition infoCondition = new Condition(StoreOrderInfo.class);
|
|
|
Example.Criteria infoCriteria = infoCondition.createCriteria();
|
|
|
infoCriteria.andEqualTo("isDelete", 0);
|
|
|
- // infoCriteria.andEqualTo("orderId", storeOrder.getId());
|
|
|
-
|
|
|
+ // infoCriteria.andEqualTo("orderId", storeOrder.getId());
|
|
|
+
|
|
|
infoCriteria.andEqualTo("orderNo", orderNo);
|
|
|
List<StoreOrderInfo> infoList = storeOrderInfoService.findByCondition(infoCondition);
|
|
|
List<StoreOrderStatus> logList = storeOrderStatusService.getLogList(orderNo);
|
|
|
-
|
|
|
+
|
|
|
Condition storePinkCondition = new Condition(StorePink.class);
|
|
|
Example.Criteria storePinkCriteria = storePinkCondition.createCriteria();
|
|
|
storePinkCriteria.andEqualTo("isDelete", 0);
|
|
|
storePinkCriteria.andEqualTo("orderId", orderNo);
|
|
|
-
|
|
|
+
|
|
|
List<StorePink> byCondition = storePinkService.findByCondition(storePinkCondition);
|
|
|
if (!org.springframework.util.CollectionUtils.isEmpty(byCondition)) {
|
|
|
StorePink storePink = byCondition.get(0);
|
|
|
@@ -91,38 +90,62 @@ public class OrderServiceBusinessImpl implements OrderServiceBusiness {
|
|
|
}
|
|
|
// UserDTO user = userDubboServiceClient.getUser(storeOrder.getUid());
|
|
|
UserAddress userAddress = null;
|
|
|
- if(!ObjectUtils.isEmpty(storeOrder.getAddressId())){
|
|
|
+ if (!ObjectUtils.isEmpty(storeOrder.getAddressId())) {
|
|
|
userAddress = userAddressService.findById(storeOrder.getAddressId());
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
List<OrderParam> orderCodeList = new ArrayList<>();
|
|
|
OrderParam orderParam = new OrderParam();
|
|
|
orderParam.setOrderNo(storeOrder.getOrderId());
|
|
|
orderParam.setUserId(storeOrder.getUid());
|
|
|
orderCodeList.add(orderParam);
|
|
|
-
|
|
|
- Map<String, EarningsDTO> collect = new HashMap<>();
|
|
|
+
|
|
|
+ // Map<String, EarningsDTO> collect = new HashMap<>();
|
|
|
// 查询订单收益
|
|
|
- List<EarningsDTO> earningsByOrders = cifRedEnvelopeDubboServiceClient.getEarningsByOrders(orderCodeList);
|
|
|
- if (!org.springframework.util.CollectionUtils.isEmpty(earningsByOrders)) {
|
|
|
- collect = earningsByOrders.stream().filter(a -> !ObjectUtils.isEmpty(a)).collect(Collectors.toMap(EarningsDTO::getOrderNo, a -> a, (b, c) -> c));
|
|
|
-
|
|
|
+ List<EarningsDTO> earningsByOrders = cifRedEnvelopeDubboServiceClient.getEarningsInfoByOrders(orderCodeList);
|
|
|
+ // if (!org.springframework.util.CollectionUtils.isEmpty(earningsByOrders)) {
|
|
|
+ // collect = earningsByOrders.stream().filter(a -> !ObjectUtils.isEmpty(a)).collect(Collectors.toMap(EarningsDTO::getOrderNo, a -> a, (b, c) -> c));
|
|
|
+ //
|
|
|
+ // }
|
|
|
+
|
|
|
+ if (CollectionUtils.isNotEmpty(earningsByOrders)) {
|
|
|
+ // 收益
|
|
|
+ EarningsDTO brokerage = earningsByOrders.stream()
|
|
|
+ .filter(a -> a.getOrderNo().equals(storeOrder.getOrderId())
|
|
|
+ && a.getBizType().equals(5002)
|
|
|
+ )
|
|
|
+ .findFirst()
|
|
|
+ .orElse(null);
|
|
|
+ if (!ObjectUtils.isEmpty(brokerage)) {
|
|
|
+ vo.setBrokerage(brokerage.getEarnings());
|
|
|
+ }else{
|
|
|
+ vo.setBrokerage(BigDecimal.ZERO);
|
|
|
+ }
|
|
|
+ // 回收
|
|
|
+ EarningsDTO recycle = earningsByOrders.stream()
|
|
|
+ .filter(a -> a.getOrderNo().equals(storeOrder.getOrderId())
|
|
|
+ && a.getBizType().equals(5007)
|
|
|
+ )
|
|
|
+ .findFirst()
|
|
|
+ .orElse(null);
|
|
|
+ if (!ObjectUtils.isEmpty(recycle)) {
|
|
|
+ vo.setRecycleAmount(recycle.getEarnings());
|
|
|
+ } else {
|
|
|
+ vo.setRecycleAmount(BigDecimal.ZERO);
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
BeanUtils.copyProperties(storeOrder, vo);
|
|
|
- EarningsDTO earningsDTO = collect.get(storeOrder.getOrderId());
|
|
|
- if (!ObjectUtils.isEmpty(earningsDTO)) {
|
|
|
- vo.setBrokerage(earningsDTO.getEarnings());
|
|
|
- }
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
vo.setOrderInfoVO(infoList);
|
|
|
vo.setOrderAddressVO(userAddress);
|
|
|
vo.setOrderStatusVO(logList);
|
|
|
-
|
|
|
+
|
|
|
// vo.setUserVO(user);
|
|
|
return vo;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
//
|
|
|
// @Override
|
|
|
// public List<StoreCombinationRankVO> getRank() {
|
|
|
@@ -175,175 +198,175 @@ public class OrderServiceBusinessImpl implements OrderServiceBusiness {
|
|
|
// }
|
|
|
@Resource
|
|
|
private StorePinkMapper storePinkMapper;
|
|
|
-
|
|
|
+
|
|
|
@Override
|
|
|
public List<StoreCombinationRankVO> getRank() {
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
List<StoreCombinationRankVO> list = new ArrayList<>();
|
|
|
-// String key = "order:rank:";
|
|
|
-// boolean exists = redisUtil.hasKey("order:rank");
|
|
|
-// if (exists) {
|
|
|
-// String orderVoString = redisUtil.get(key).toString();
|
|
|
-// list = JSONObject.parseArray(orderVoString, StoreCombinationRankVO.class);
|
|
|
-// return list;
|
|
|
-// }
|
|
|
-
|
|
|
+ // String key = "order:rank:";
|
|
|
+ // boolean exists = redisUtil.hasKey("order:rank");
|
|
|
+ // if (exists) {
|
|
|
+ // String orderVoString = redisUtil.get(key).toString();
|
|
|
+ // list = JSONObject.parseArray(orderVoString, StoreCombinationRankVO.class);
|
|
|
+ // return list;
|
|
|
+ // }
|
|
|
+
|
|
|
Set<Long> isvalidProductIdList = new HashSet<>();
|
|
|
- //提取有效的参与活动的商品id
|
|
|
+ // 提取有效的参与活动的商品id
|
|
|
Condition storeCombinationCondition = new Condition(StoreCombination.class);
|
|
|
Example.Criteria StoreCombinationCriteria = storeCombinationCondition.createCriteria();
|
|
|
StoreCombinationCriteria.andEqualTo("isDelete", 0);
|
|
|
StoreCombinationCriteria.andEqualTo("isShow", 1);
|
|
|
List<StoreCombination> combinationList = storeCombinationService.findByCondition(storeCombinationCondition);
|
|
|
-
|
|
|
- if(!CollectionUtils.isEmpty(combinationList)){
|
|
|
- log.info("getRank.storeCombinationService.findByCondition"+JSONObject.toJSONString(combinationList));
|
|
|
+
|
|
|
+ if (!CollectionUtils.isEmpty(combinationList)) {
|
|
|
+ log.info("getRank.storeCombinationService.findByCondition" + JSONObject.toJSONString(combinationList));
|
|
|
List<Long> productIdList1 = combinationList.stream().map(StoreCombination::getProductId).collect(Collectors.toList());
|
|
|
isvalidProductIdList.addAll(productIdList1);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-// Condition storeProductondition = new Condition(StoreProduct.class);
|
|
|
-// Example.Criteria storeProductCriteria = storeProductondition.createCriteria();
|
|
|
-// storeProductCriteria.andEqualTo("isDelete", 0);
|
|
|
-// storeProductCriteria.andEqualTo("isShow", 1);
|
|
|
-// List<StoreProduct> storeProductList = storeProductService.findByCondition(storeProductondition);
|
|
|
-// if(!CollectionUtils.isEmpty(storeProductList)){
|
|
|
-// List<Long> productIdList2 = storeProductList.stream().map(StoreProduct::getId).collect(Collectors.toList());
|
|
|
-// isvalidProductIdList.addAll(productIdList2);
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
- if(!CollectionUtils.isEmpty(isvalidProductIdList)) {
|
|
|
- log.info("getRank.isvalidProductIdList"+JSONObject.toJSONString(isvalidProductIdList));
|
|
|
- Date date = new Date();
|
|
|
- Date date1 = DateUtils.addDays(date, -6);
|
|
|
- // List<Map<String, Object>> rank = storeOrderMapper.getRank(date1);
|
|
|
- List<Map<String, Object>> rank = storePinkMapper.getRank(date1,isvalidProductIdList);
|
|
|
-
|
|
|
-
|
|
|
- if (!CollectionUtils.isEmpty(rank)) {
|
|
|
- log.info("rank"+JSONObject.toJSONString(rank));
|
|
|
- Map<Long, Map<String, Object>> saleMap = rank.stream().collect(Collectors.toMap(a -> Long.valueOf(a.get("pid") + ""), a -> a, (b, c) -> c));
|
|
|
- List<Long> pidList = rank.stream().map(a -> Long.valueOf(a.get("pid") + "")).collect(Collectors.toList());
|
|
|
-
|
|
|
-// Condition storeCombinationCondition = new Condition(StoreCombination.class);
|
|
|
-// Example.Criteria storeCombinationCriteria = storeCombinationCondition.createCriteria();
|
|
|
-// storeCombinationCriteria.andIn("productId", pidList);
|
|
|
-// List<StoreCombination> combinationList = storeCombinationService.findByCondition(storeCombinationCondition);
|
|
|
- Map<Long, StoreCombination> storeCombinationMap = new HashMap<>();
|
|
|
- if (!CollectionUtils.isEmpty(combinationList)) {
|
|
|
- log.info("getRank.combinationList"+JSONObject.toJSONString(combinationList));
|
|
|
- storeCombinationMap = combinationList.stream().collect(Collectors.toMap(StoreCombination::getProductId, a -> a, (b, c) -> c));
|
|
|
- }
|
|
|
- for (Map<String, Object> stringObjectMap : rank) {
|
|
|
-
|
|
|
-
|
|
|
- Object pid = stringObjectMap.get("pid");
|
|
|
- Object num = stringObjectMap.get("num");
|
|
|
- log.info("getRank.pid"+JSONObject.toJSONString(pid));
|
|
|
- StoreCombination storeCombination = storeCombinationMap.get(Long.parseLong(pid + ""));
|
|
|
- log.info("getRank.storeCombination"+JSONObject.toJSONString(storeCombination));
|
|
|
- StoreCombinationRankVO rankVO = new StoreCombinationRankVO();
|
|
|
- rankVO.setProductId(storeCombination.getProductId());
|
|
|
- rankVO.setProductName(storeCombination.getProductName());
|
|
|
- rankVO.setSales(Integer.valueOf(num + ""));
|
|
|
- rankVO.setFicti(Integer.valueOf(num + ""));
|
|
|
- rankVO.setImage(storeCombination.getImage());
|
|
|
- rankVO.setPrice(storeCombination.getPrice());
|
|
|
- list.add(rankVO);
|
|
|
- }
|
|
|
-
|
|
|
- if (!CollectionUtils.isEmpty(list)) {
|
|
|
- log.info("getRank.list"+JSONObject.toJSONString(list));
|
|
|
- list = list.stream().sorted(Comparator.comparing(StoreCombinationRankVO::getSales).reversed()).collect(Collectors.toList());
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+ // Condition storeProductondition = new Condition(StoreProduct.class);
|
|
|
+ // Example.Criteria storeProductCriteria = storeProductondition.createCriteria();
|
|
|
+ // storeProductCriteria.andEqualTo("isDelete", 0);
|
|
|
+ // storeProductCriteria.andEqualTo("isShow", 1);
|
|
|
+ // List<StoreProduct> storeProductList = storeProductService.findByCondition(storeProductondition);
|
|
|
+ // if(!CollectionUtils.isEmpty(storeProductList)){
|
|
|
+ // List<Long> productIdList2 = storeProductList.stream().map(StoreProduct::getId).collect(Collectors.toList());
|
|
|
+ // isvalidProductIdList.addAll(productIdList2);
|
|
|
+ // }
|
|
|
+
|
|
|
+
|
|
|
+ if (!CollectionUtils.isEmpty(isvalidProductIdList)) {
|
|
|
+ log.info("getRank.isvalidProductIdList" + JSONObject.toJSONString(isvalidProductIdList));
|
|
|
+ Date date = new Date();
|
|
|
+ Date date1 = DateUtils.addDays(date, -6);
|
|
|
+ // List<Map<String, Object>> rank = storeOrderMapper.getRank(date1);
|
|
|
+ List<Map<String, Object>> rank = storePinkMapper.getRank(date1, isvalidProductIdList);
|
|
|
+
|
|
|
+
|
|
|
+ if (!CollectionUtils.isEmpty(rank)) {
|
|
|
+ log.info("rank" + JSONObject.toJSONString(rank));
|
|
|
+ Map<Long, Map<String, Object>> saleMap = rank.stream().collect(Collectors.toMap(a -> Long.valueOf(a.get("pid") + ""), a -> a, (b, c) -> c));
|
|
|
+ List<Long> pidList = rank.stream().map(a -> Long.valueOf(a.get("pid") + "")).collect(Collectors.toList());
|
|
|
+
|
|
|
+ // Condition storeCombinationCondition = new Condition(StoreCombination.class);
|
|
|
+ // Example.Criteria storeCombinationCriteria = storeCombinationCondition.createCriteria();
|
|
|
+ // storeCombinationCriteria.andIn("productId", pidList);
|
|
|
+ // List<StoreCombination> combinationList = storeCombinationService.findByCondition(storeCombinationCondition);
|
|
|
+ Map<Long, StoreCombination> storeCombinationMap = new HashMap<>();
|
|
|
+ if (!CollectionUtils.isEmpty(combinationList)) {
|
|
|
+ log.info("getRank.combinationList" + JSONObject.toJSONString(combinationList));
|
|
|
+ storeCombinationMap = combinationList.stream().collect(Collectors.toMap(StoreCombination::getProductId, a -> a, (b, c) -> c));
|
|
|
+ }
|
|
|
+ for (Map<String, Object> stringObjectMap : rank) {
|
|
|
+
|
|
|
+
|
|
|
+ Object pid = stringObjectMap.get("pid");
|
|
|
+ Object num = stringObjectMap.get("num");
|
|
|
+ log.info("getRank.pid" + JSONObject.toJSONString(pid));
|
|
|
+ StoreCombination storeCombination = storeCombinationMap.get(Long.parseLong(pid + ""));
|
|
|
+ log.info("getRank.storeCombination" + JSONObject.toJSONString(storeCombination));
|
|
|
+ StoreCombinationRankVO rankVO = new StoreCombinationRankVO();
|
|
|
+ rankVO.setProductId(storeCombination.getProductId());
|
|
|
+ rankVO.setProductName(storeCombination.getProductName());
|
|
|
+ rankVO.setSales(Integer.valueOf(num + ""));
|
|
|
+ rankVO.setFicti(Integer.valueOf(num + ""));
|
|
|
+ rankVO.setImage(storeCombination.getImage());
|
|
|
+ rankVO.setPrice(storeCombination.getPrice());
|
|
|
+ list.add(rankVO);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!CollectionUtils.isEmpty(list)) {
|
|
|
+ log.info("getRank.list" + JSONObject.toJSONString(list));
|
|
|
+ list = list.stream().sorted(Comparator.comparing(StoreCombinationRankVO::getSales).reversed()).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
// redisUtil.set(key, list);
|
|
|
return list;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
@Resource
|
|
|
private DailySalesSummaryOfProductsMapper dailySalesSummaryOfProductsMapper;
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 重构后的top7 先建立daily_sales_summary_table_of_products 每日凌晨通过定时任务汇总一次当天的各个商品的销量,,然后top7就汇总过去7天的数据即可
|
|
|
+ *
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
public List<StoreCombinationRankVO> getRankNew() {
|
|
|
List<StoreCombinationRankVO> list = new ArrayList<>();
|
|
|
-// String key = "order:rank:";
|
|
|
-// boolean exists = redisUtil.hasKey("order:rank");
|
|
|
-// if (exists) {
|
|
|
-// String orderVoString = redisUtil.get(key).toString();
|
|
|
-// list = JSONObject.parseArray(orderVoString, StoreCombinationRankVO.class);
|
|
|
-// return list;
|
|
|
-// }
|
|
|
-
|
|
|
+ // String key = "order:rank:";
|
|
|
+ // boolean exists = redisUtil.hasKey("order:rank");
|
|
|
+ // if (exists) {
|
|
|
+ // String orderVoString = redisUtil.get(key).toString();
|
|
|
+ // list = JSONObject.parseArray(orderVoString, StoreCombinationRankVO.class);
|
|
|
+ // return list;
|
|
|
+ // }
|
|
|
+
|
|
|
Set<Long> isvalidProductIdList = new HashSet<>();
|
|
|
- //提取有效的参与活动的商品id
|
|
|
+ // 提取有效的参与活动的商品id
|
|
|
Condition storeCombinationCondition = new Condition(StoreCombination.class);
|
|
|
Example.Criteria StoreCombinationCriteria = storeCombinationCondition.createCriteria();
|
|
|
StoreCombinationCriteria.andEqualTo("isDelete", 0);
|
|
|
StoreCombinationCriteria.andEqualTo("isShow", 1);
|
|
|
List<StoreCombination> combinationList = storeCombinationService.findByCondition(storeCombinationCondition);
|
|
|
-
|
|
|
- if(!CollectionUtils.isEmpty(combinationList)){
|
|
|
- log.info("getRank.storeCombinationService.findByCondition"+JSONObject.toJSONString(combinationList));
|
|
|
+
|
|
|
+ if (!CollectionUtils.isEmpty(combinationList)) {
|
|
|
+ log.info("getRank.storeCombinationService.findByCondition" + JSONObject.toJSONString(combinationList));
|
|
|
List<Long> productIdList1 = combinationList.stream().map(StoreCombination::getProductId).collect(Collectors.toList());
|
|
|
isvalidProductIdList.addAll(productIdList1);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-// Condition storeProductondition = new Condition(StoreProduct.class);
|
|
|
-// Example.Criteria storeProductCriteria = storeProductondition.createCriteria();
|
|
|
-// storeProductCriteria.andEqualTo("isDelete", 0);
|
|
|
-// storeProductCriteria.andEqualTo("isShow", 1);
|
|
|
-// List<StoreProduct> storeProductList = storeProductService.findByCondition(storeProductondition);
|
|
|
-// if(!CollectionUtils.isEmpty(storeProductList)){
|
|
|
-// List<Long> productIdList2 = storeProductList.stream().map(StoreProduct::getId).collect(Collectors.toList());
|
|
|
-// isvalidProductIdList.addAll(productIdList2);
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
- if(!CollectionUtils.isEmpty(isvalidProductIdList)) {
|
|
|
- log.info("getRank.isvalidProductIdList"+JSONObject.toJSONString(isvalidProductIdList));
|
|
|
+
|
|
|
+
|
|
|
+ // Condition storeProductondition = new Condition(StoreProduct.class);
|
|
|
+ // Example.Criteria storeProductCriteria = storeProductondition.createCriteria();
|
|
|
+ // storeProductCriteria.andEqualTo("isDelete", 0);
|
|
|
+ // storeProductCriteria.andEqualTo("isShow", 1);
|
|
|
+ // List<StoreProduct> storeProductList = storeProductService.findByCondition(storeProductondition);
|
|
|
+ // if(!CollectionUtils.isEmpty(storeProductList)){
|
|
|
+ // List<Long> productIdList2 = storeProductList.stream().map(StoreProduct::getId).collect(Collectors.toList());
|
|
|
+ // isvalidProductIdList.addAll(productIdList2);
|
|
|
+ // }
|
|
|
+
|
|
|
+
|
|
|
+ if (!CollectionUtils.isEmpty(isvalidProductIdList)) {
|
|
|
+ log.info("getRank.isvalidProductIdList" + JSONObject.toJSONString(isvalidProductIdList));
|
|
|
Date date = new Date();
|
|
|
Date date1 = DateUtils.addDays(date, -6);
|
|
|
// List<Map<String, Object>> rank = storeOrderMapper.getRank(date1);
|
|
|
- List<Map<String, Object>> rank = dailySalesSummaryOfProductsMapper.getRankNew(date1,isvalidProductIdList);
|
|
|
-
|
|
|
-
|
|
|
+ List<Map<String, Object>> rank = dailySalesSummaryOfProductsMapper.getRankNew(date1, isvalidProductIdList);
|
|
|
+
|
|
|
+
|
|
|
if (!CollectionUtils.isEmpty(rank)) {
|
|
|
- log.info("rank"+JSONObject.toJSONString(rank));
|
|
|
+ log.info("rank" + JSONObject.toJSONString(rank));
|
|
|
Map<Long, Map<String, Object>> saleMap = rank.stream().collect(Collectors.toMap(a -> Long.valueOf(a.get("pid") + ""), a -> a, (b, c) -> c));
|
|
|
List<Long> pidList = rank.stream().map(a -> Long.valueOf(a.get("pid") + "")).collect(Collectors.toList());
|
|
|
-
|
|
|
-// Condition storeCombinationCondition = new Condition(StoreCombination.class);
|
|
|
-// Example.Criteria storeCombinationCriteria = storeCombinationCondition.createCriteria();
|
|
|
-// storeCombinationCriteria.andIn("productId", pidList);
|
|
|
-// List<StoreCombination> combinationList = storeCombinationService.findByCondition(storeCombinationCondition);
|
|
|
+
|
|
|
+ // Condition storeCombinationCondition = new Condition(StoreCombination.class);
|
|
|
+ // Example.Criteria storeCombinationCriteria = storeCombinationCondition.createCriteria();
|
|
|
+ // storeCombinationCriteria.andIn("productId", pidList);
|
|
|
+ // List<StoreCombination> combinationList = storeCombinationService.findByCondition(storeCombinationCondition);
|
|
|
Map<Long, StoreCombination> storeCombinationMap = new HashMap<>();
|
|
|
if (!CollectionUtils.isEmpty(combinationList)) {
|
|
|
- log.info("getRank.combinationList"+JSONObject.toJSONString(combinationList));
|
|
|
+ log.info("getRank.combinationList" + JSONObject.toJSONString(combinationList));
|
|
|
storeCombinationMap = combinationList.stream().collect(Collectors.toMap(StoreCombination::getProductId, a -> a, (b, c) -> c));
|
|
|
}
|
|
|
for (Map<String, Object> stringObjectMap : rank) {
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
Object pid = stringObjectMap.get("pid");
|
|
|
Object num = stringObjectMap.get("num");
|
|
|
- log.info("getRank.pid"+JSONObject.toJSONString(pid));
|
|
|
+ log.info("getRank.pid" + JSONObject.toJSONString(pid));
|
|
|
StoreCombination storeCombination = storeCombinationMap.get(Long.parseLong(pid + ""));
|
|
|
- log.info("getRank.storeCombination"+JSONObject.toJSONString(storeCombination));
|
|
|
+ log.info("getRank.storeCombination" + JSONObject.toJSONString(storeCombination));
|
|
|
StoreCombinationRankVO rankVO = new StoreCombinationRankVO();
|
|
|
rankVO.setProductId(storeCombination.getProductId());
|
|
|
rankVO.setProductName(storeCombination.getProductName());
|
|
|
@@ -353,16 +376,16 @@ public class OrderServiceBusinessImpl implements OrderServiceBusiness {
|
|
|
rankVO.setPrice(storeCombination.getPrice());
|
|
|
list.add(rankVO);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if (!CollectionUtils.isEmpty(list)) {
|
|
|
- log.info("getRank.list"+JSONObject.toJSONString(list));
|
|
|
+ log.info("getRank.list" + JSONObject.toJSONString(list));
|
|
|
list = list.stream().sorted(Comparator.comparing(StoreCombinationRankVO::getSales).reversed()).collect(Collectors.toList());
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// redisUtil.set(key, list);
|
|
|
return list;
|
|
|
}
|