...
|
...
|
@@ -177,9 +177,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
|
}
|
|
|
|
|
|
public PageResponseBO<BuyerOrderResp> queryOrderList(BuyerOrderReq req) {
|
|
|
if(!checkAndBuildParam(req)) {
|
|
|
return null;
|
|
|
}
|
|
|
buildParam(req);
|
|
|
|
|
|
int total = buyerOrderMapper.selectTotalByCondition(req);
|
|
|
if(total == 0) {
|
...
|
...
|
@@ -239,7 +237,6 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
|
List<ExpressCompany> companyList = expressCompanyMapper.selectByIdList(expressCompanyIdList);
|
|
|
companyMap = companyList.stream().collect(Collectors.toMap(ExpressCompany::getId, ExpressCompany::getCompanyName));
|
|
|
}
|
|
|
|
|
|
List<BuyerOrderResp> respList = convertToResp(orderList, buyerGoodsMap, sellerOrderMap, sellerGoodsMap,expressRecordMap, platformExpressRecordMap, companyMap,skupProductCodeMap);
|
|
|
|
|
|
PageResponseBO<BuyerOrderResp> result=new PageResponseBO<>();
|
...
|
...
|
@@ -251,6 +248,59 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public PageResponseBO<BuyerOrderResp> queryByOrderCodeOrWaybillCode(String queryStr) {
|
|
|
if(StringUtils.isEmpty(queryStr)) {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
List<BuyerOrder> orderList = Lists.newArrayList();
|
|
|
//先按订单号来查
|
|
|
BuyerOrder order = buyerOrderMapper.selectByOrderCode(queryStr);
|
|
|
if(null == order){//再按卖家运单号来查
|
|
|
BuyerOrderReq req = new BuyerOrderReq();
|
|
|
req.setSellerWaybillCode(queryStr);
|
|
|
List<BuyerOrder> list = buyerOrderMapper.selectByCondition(req);
|
|
|
if(CollectionUtils.isEmpty(list)){
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
orderList.addAll(list);
|
|
|
}else{
|
|
|
orderList.add(order);
|
|
|
}
|
|
|
|
|
|
//查询buyer_order_goods
|
|
|
List<String> buyerOrderCodeList = orderList.stream().map(BuyerOrder::getOrderCode).collect(Collectors.toList());
|
|
|
List<BuyerOrderGoods> buyerGoodsList = buyerOrderGoodsMapper.selectByOrderCode(buyerOrderCodeList);
|
|
|
if(CollectionUtils.isEmpty(buyerGoodsList)) {
|
|
|
return null;
|
|
|
}
|
|
|
Map<String, BuyerOrderGoods> buyerGoodsMap = buyerGoodsList.stream().collect(Collectors.toMap(BuyerOrderGoods::getOrderCode, b->b));
|
|
|
|
|
|
//查询seller_order_goods
|
|
|
List<Integer> skupList = buyerGoodsList.stream().map(BuyerOrderGoods::getSkup).collect(Collectors.toList());
|
|
|
List<SellerOrderGoods> sellerGoodsList = sellerOrderGoodsMapper.selectByIds(skupList);
|
|
|
Map<Integer, SellerOrderGoods> sellerGoodsMap = sellerGoodsList.stream().collect(Collectors.toMap(SellerOrderGoods::getId, s->s));
|
|
|
|
|
|
//查询buyer_order_meta
|
|
|
List<BuyerOrderMeta> buyerOrderMetaList = buyerOrderMetaMapper.selectByBatchOrderCodeAndKey(buyerOrderCodeList, BUYER_ORDER_META_KEY_DELIVERY_ADDRESS);
|
|
|
Map<String, BuyerOrderMeta> buyerOrderMetaMap = buyerOrderMetaList.stream().collect(Collectors.toMap(BuyerOrderMeta::getOrderCode, b->b));
|
|
|
|
|
|
//查询卖家快递单号
|
|
|
List<ExpressRecord> expressRecordList =expressRecordMapper.selectByOrderCodeListAndType(buyerOrderCodeList, Lists.newArrayList(EXPRESS_TYPE_SELLER_TO_JUDGE));
|
|
|
Map<String, ExpressRecord> expressRecordMap = expressRecordList.stream().collect(Collectors.toMap(ExpressRecord::getOrderCode, e->e));
|
|
|
|
|
|
|
|
|
List<BuyerOrderResp> respList = convertToRespForQuery(orderList, buyerGoodsMap, sellerGoodsMap,expressRecordMap, buyerOrderMetaMap);
|
|
|
|
|
|
PageResponseBO<BuyerOrderResp> result=new PageResponseBO<>();
|
|
|
result.setList(respList);
|
|
|
result.setSize(respList.size());
|
|
|
result.setTotal(respList.size());
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public JSONObject updateOrderStatus(BuyerOrderReq req) {
|
|
|
if(null == req.getId() || null == req.getStatus()) {
|
|
|
return null;
|
...
|
...
|
@@ -783,6 +833,36 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
|
return respList;
|
|
|
}
|
|
|
|
|
|
private List<BuyerOrderResp> convertToRespForQuery(List<BuyerOrder> orderList, Map<String, BuyerOrderGoods> buyerGoodsMap,
|
|
|
Map<Integer, SellerOrderGoods> sellerGoodsMap, Map<String, ExpressRecord> expressInfoMap,
|
|
|
Map<String, BuyerOrderMeta> buyerOrderMetaMap){
|
|
|
List<BuyerOrderResp> respList = Lists.newArrayList();
|
|
|
for(BuyerOrder item : orderList) {
|
|
|
if(null == buyerGoodsMap.get(item.getOrderCode())) {
|
|
|
continue;
|
|
|
}
|
|
|
Integer skup = buyerGoodsMap.get(item.getOrderCode()).getSkup();
|
|
|
BuyerOrderResp resp = new BuyerOrderResp();
|
|
|
resp.setOrderCode(item.getOrderCode());
|
|
|
resp.setSellerWaybillCode(null == expressInfoMap.get(item.getOrderCode()) ? "" : expressInfoMap.get(item.getOrderCode()).getWaybillCode());
|
|
|
resp.setProductName(sellerGoodsMap.get(skup).getProductName());
|
|
|
resp.setProductImage(ImagesHelper.getImageAbsoluteUrl(sellerGoodsMap.get(skup).getImageUrl(), ImagesConstant.BUCKET_GOODS_IMG));
|
|
|
resp.setColorName(sellerGoodsMap.get(skup).getColorName());
|
|
|
resp.setSizeName(sellerGoodsMap.get(skup).getSizeName());
|
|
|
resp.setGoodsPrice(String.format("%.2f", buyerGoodsMap.get(item.getOrderCode()).getGoodsPrice().doubleValue()));
|
|
|
resp.setAmount(null == item.getAmount() ? null : String.format("%.2f", item.getAmount().doubleValue()));
|
|
|
JSONObject metaValue = JSONObject.parseObject(buyerOrderMetaMap.get(item.getOrderCode()).getMetaValue());
|
|
|
resp.setReceiveName(metaValue.getString("consignee"));
|
|
|
resp.setReceiveMobile(metaValue.getString("mobile"));
|
|
|
String receiveAddressCode = metaValue.getString("areaCode");
|
|
|
resp.setReceiveAddress(getAddressInfo(receiveAddressCode));
|
|
|
|
|
|
respList.add(resp);
|
|
|
}
|
|
|
|
|
|
return respList;
|
|
|
}
|
|
|
|
|
|
private List<Byte> getStatusListByNavStatus(Integer navStatus) {
|
|
|
switch(navStatus) {
|
|
|
case 1: return Lists.newArrayList(Constant.BUYER_ORDER_STATUS_BUYER_NOT_PAY.getByteVal());
|
...
|
...
|
@@ -803,7 +883,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
|
}
|
|
|
}
|
|
|
|
|
|
private boolean checkAndBuildParam(BuyerOrderReq req) {
|
|
|
private void buildParam(BuyerOrderReq req) {
|
|
|
if(StringUtils.isNotEmpty(req.getStatusStr())) {
|
|
|
req.setStatusList(convertStatus(req.getStatusStr()));
|
|
|
}
|
...
|
...
|
@@ -812,18 +892,6 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
|
req.setStatusList(getStatusListByNavStatus(req.getNavStatus()));
|
|
|
}
|
|
|
|
|
|
// if(StringUtils.isNotEmpty(req.getSellerWaybillCode())) {
|
|
|
// List<ExpressRecord> expressRecordList = expressoRecordMapper.selectByWaybillCode(req.getSellerWaybillCode());
|
|
|
// if(CollectionUtils.isEmpty(expressRecordList)) {
|
|
|
// return false;
|
|
|
// }else {
|
|
|
// List<String> buyerOrderCodeList = expressRecordList.stream().map(ExpressRecord::getOrderCode).collect(Collectors.toList());
|
|
|
// List<BuyerOrderGoods> buyerOrderGoodsList = buyerOrderGoodsMapper.selectByOrderCode(buyerOrderCodeList);
|
|
|
// List<Integer> skupList = buyerOrderGoodsList.stream().map(BuyerOrderGoods::getSkup).collect(Collectors.toList());
|
|
|
// req.setSkupList(skupList);
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
if(StringUtils.isNotEmpty(req.getMobile())) {
|
|
|
Integer uid = getUidByMobile(req.getMobile());
|
|
|
if(null != uid) {
|
...
|
...
|
@@ -831,8 +899,6 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
|
}
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
private List<Byte> convertStatus(String statusStr){
|
...
|
...
|
|