|
|
package com.yohoufo.order.service.impl;
|
|
|
|
|
|
import com.google.common.base.Throwables;
|
|
|
import java.lang.reflect.Method;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Objects;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.google.common.collect.Maps;
|
|
|
import com.yoho.core.dal.datasource.annotation.Database;
|
|
|
import com.yohobuy.ufo.model.order.bo.ButtonShowBo;
|
|
|
import com.yohobuy.ufo.model.order.bo.DepositDetailBo;
|
|
|
import com.yohobuy.ufo.model.order.bo.DepositProductBo;
|
|
|
import com.yohobuy.ufo.model.order.constants.*;
|
|
|
import com.yohobuy.ufo.model.order.constants.DepositOrderStatusEnum;
|
|
|
import com.yohobuy.ufo.model.order.constants.DepositOutTypeEnum;
|
|
|
import com.yohobuy.ufo.model.order.constants.DepositSourceEnum;
|
|
|
import com.yohobuy.ufo.model.order.constants.DepositTypeEnum;
|
|
|
import com.yohobuy.ufo.model.order.constants.DepotType;
|
|
|
import com.yohobuy.ufo.model.order.constants.StorageDepositStatusEnum;
|
|
|
import com.yohobuy.ufo.model.order.req.UserDopositReq;
|
|
|
import com.yohobuy.ufo.model.order.resp.PageResp;
|
|
|
import com.yohoufo.common.ApiResponse;
|
|
|
import com.yohoufo.common.cache.ControllerCacheAop;
|
|
|
import com.yohoufo.common.caller.UfoServiceCaller;
|
|
|
import com.yohoufo.common.exception.UfoServiceException;
|
|
|
import com.yohoufo.common.helper.ImageUrlAssist;
|
|
|
import com.yohoufo.common.utils.DateUtil;
|
|
|
import com.yohoufo.dal.order.*;
|
|
|
import com.yohoufo.dal.order.model.*;
|
|
|
import com.yohoufo.dal.order.AppraiseOrderMapper;
|
|
|
import com.yohoufo.dal.order.AppraiseOrderStorageMapper;
|
|
|
import com.yohoufo.dal.order.BuyerOrderMapper;
|
|
|
import com.yohoufo.dal.order.SellerOrderGoodsMapper;
|
|
|
import com.yohoufo.dal.order.StorageDepositMapper;
|
|
|
import com.yohoufo.dal.order.model.AppraiseOrder;
|
|
|
import com.yohoufo.dal.order.model.AppraiseOrderStorage;
|
|
|
import com.yohoufo.dal.order.model.BuyerOrder;
|
|
|
import com.yohoufo.dal.order.model.SellerOrderGoods;
|
|
|
import com.yohoufo.dal.order.model.StorageDeposit;
|
|
|
import com.yohoufo.dal.order.model.StorageDepositCount;
|
|
|
import com.yohoufo.order.controller.DepositController;
|
|
|
import com.yohoufo.order.model.response.AppraiseAddressResp;
|
|
|
import com.yohoufo.order.service.DepositService;
|
...
|
...
|
@@ -25,16 +54,6 @@ import com.yohoufo.order.service.proxy.InBoxFacade; |
|
|
import com.yohoufo.order.service.proxy.ProductProxyService;
|
|
|
import com.yohoufo.order.service.seller.SkupService;
|
|
|
import com.yohoufo.order.utils.LoggerUtils;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.lang.reflect.Method;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
@Service
|
...
|
...
|
@@ -80,6 +99,8 @@ public class DepositServiceImpl implements DepositService { |
|
|
@Autowired
|
|
|
private AppraiseOrderStorageMapper appraiseOrderStorageMapper;
|
|
|
|
|
|
@Autowired
|
|
|
private AppraiseOrderMapper appraiseOrderMapper;
|
|
|
|
|
|
@Override
|
|
|
public PageResp<List<DepositProductBo>> queryUserDoposit(Integer uid, Integer page, Integer limit) {
|
...
|
...
|
@@ -748,4 +769,82 @@ public class DepositServiceImpl implements DepositService { |
|
|
|
|
|
return insert;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public JSONObject queryListByUidAndStorageId(UserDopositReq req) {
|
|
|
JSONObject result = new JSONObject();
|
|
|
int total = storageDepositMapper.selectUserValidDepositCnt(req.getUid(), req.getStorageId());
|
|
|
if(total == 0) {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
List<StorageDeposit> list = storageDepositMapper.selectUserValidDepositList(req.getUid(), req.getStorageId(), req.getPage(), req.getLimit());
|
|
|
|
|
|
Map<Integer, SellerOrderGoods> goodsMap = depositHelpService.getProductBySkuMap(Lists.newArrayList(req.getStorageId()));
|
|
|
SellerOrderGoods goods = goodsMap.get(req.getStorageId());
|
|
|
|
|
|
List<Long> orderCodeList = list.stream().map(StorageDeposit::getOrderCode).collect(Collectors.toList());
|
|
|
result.put("imageUrl", goods.getImageUrl());
|
|
|
result.put("productName", goods.getProductName());
|
|
|
result.put("sizeName", goods.getSizeName());
|
|
|
result.put("count", list.size());
|
|
|
result.put("list", convertDepositResp(list, orderCodeList));
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public int queryCntByUidAndStorageId(UserDopositReq req) {
|
|
|
|
|
|
return storageDepositMapper.selectUserValidDepositCnt(req.getUid(), req.getStorageId());
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public int updateDepositWaitToPick(Integer uid, String depositCode) {
|
|
|
int num = 0;
|
|
|
StorageDeposit deposit = storageDepositMapper.selectByDepositCode(uid, depositCode, Lists.newArrayList(StorageDepositStatusEnum.HAS_IN.getCode()));
|
|
|
if(null == deposit) {
|
|
|
return num;
|
|
|
}
|
|
|
LOGGER.info("updateDepositWaitToPick, uid is {}, depositCode is {}, old depositInfo is {}", uid, depositCode, deposit);
|
|
|
return storageDepositMapper.updateStorageStatus(deposit.getId(), StorageDepositStatusEnum.WAITING_OUT.getCode(), 0, DepositOutTypeEnum.OUTTYPE_DEPOSIT_CHANGE_TO_IN_STOCK.getCode(), uid);
|
|
|
}
|
|
|
|
|
|
private List<DepositDetailBo> convertDepositResp(List<StorageDeposit> list, List<Long> orderCodeList){
|
|
|
Map<Long, BigDecimal> orderCodePriceMap = Maps.newHashMap();
|
|
|
List<BuyerOrder> buyerOrderList = buyerOrderMapper.selectByOrderCodes(orderCodeList, null);
|
|
|
if(CollectionUtils.isNotEmpty(buyerOrderList)) {
|
|
|
orderCodePriceMap.putAll(buyerOrderList.stream().collect(Collectors.toMap(BuyerOrder::getOrderCode, BuyerOrder::getAmount)));
|
|
|
orderCodeList.removeAll(buyerOrderList.stream().map(BuyerOrder::getOrderCode).collect(Collectors.toList()));
|
|
|
}
|
|
|
if(CollectionUtils.isNotEmpty(orderCodeList)) {
|
|
|
List<AppraiseOrder> appraiseOrderList = appraiseOrderMapper.selectByOrderCodeList(orderCodeList);
|
|
|
if(CollectionUtils.isNotEmpty(appraiseOrderList)) {
|
|
|
orderCodePriceMap.putAll(appraiseOrderList.stream().collect(Collectors.toMap(AppraiseOrder::getOrderCode, AppraiseOrder::getAmount)));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
List<DepositDetailBo> resultList = Lists.newArrayList();
|
|
|
for(StorageDeposit item : list) {
|
|
|
DepositDetailBo resp = new DepositDetailBo();
|
|
|
resp.setDepositCode(item.getDepositCode());
|
|
|
resp.setOrderStatusStr(getOrderStatusStr(item.getOrderStatus()));
|
|
|
resp.setRemainDays(String.valueOf((item.getDepositEndTime() - DateUtil.getCurrentTimeSecond()) / 60*60*24));
|
|
|
resp.setPrice(null == orderCodePriceMap.get(item.getOrderCode()) ? "" : String.valueOf(orderCodePriceMap.get(item.getOrderCode()).intValue()));
|
|
|
resultList.add(resp);
|
|
|
}
|
|
|
|
|
|
return resultList;
|
|
|
}
|
|
|
|
|
|
private String getOrderStatusStr(Integer orderStatus) {
|
|
|
if(orderStatus.intValue() == 0) {
|
|
|
return "待上架";
|
|
|
}else if(orderStatus.intValue() == 1) {
|
|
|
return "出售中";
|
|
|
}else {
|
|
|
return StringUtils.EMPTY;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|