Authored by LUOXC

refactor

... ... @@ -41,7 +41,7 @@ public class BuyerOrderDetailService extends AbsOrderDetailService implements IO
BuyerOrderMetaMapper buyerOrderMetaMapper;
@Autowired
QiniuLiveRecordMapper qiniuLiveRecordMapper;
private QiniuLiveRecordService qiniuLiveRecordService;
... ... @@ -105,8 +105,7 @@ public class BuyerOrderDetailService extends AbsOrderDetailService implements IO
return Optional.ofNullable(buyerOrder)
.filter(e -> e.getStatus() == WAITING_RECEIVE.getCode() || e.getStatus() == DONE.getCode())
.map(BuyerOrder::getOrderCode)
.map(orderCode -> qiniuLiveRecordMapper.selectByOrderCode(orderCode))
.map(QiniuLiveRecord::getVedioFileUrl)
.map(orderCode -> qiniuLiveRecordService.getAppraiseVideoUrl(orderCode))
.orElse(null);
}
... ...
... ... @@ -9,18 +9,15 @@ import com.yohobuy.ufo.model.order.common.OrderListType;
import com.yohoufo.common.helper.ImageUrlAssist;
import com.yohoufo.dal.order.BuyerOrderGoodsMapper;
import com.yohoufo.dal.order.BuyerOrderMapper;
import com.yohoufo.dal.order.QiniuLiveRecordMapper;
import com.yohoufo.dal.order.SellerOrderGoodsMapper;
import com.yohoufo.dal.order.model.BuyerOrder;
import com.yohoufo.dal.order.model.BuyerOrderGoods;
import com.yohoufo.dal.order.model.QiniuLiveRecord;
import com.yohoufo.dal.order.model.SellerOrderGoods;
import com.yohoufo.order.model.request.OrderListRequest;
import com.yohoufo.order.service.AbsBuyerOrderViewService;
import com.yohoufo.order.service.IBuyerOrderMetaService;
import com.yohoufo.order.service.IOrderListService;
import org.apache.commons.collections.CollectionUtils;
import org.elasticsearch.common.collect.Lists;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -54,7 +51,7 @@ public class BuyerOrderListServiceImpl extends AbsOrderListService implements IO
IBuyerOrderMetaService buyerOrderMetaService;
@Autowired
private QiniuLiveRecordMapper qiniuLiveRecordMapper;
private QiniuLiveRecordService qiniuLiveRecordService;
/**
* 根据type获取 指定的状态
... ... @@ -114,8 +111,7 @@ public class BuyerOrderListServiceImpl extends AbsOrderListService implements IO
if (CollectionUtils.isEmpty(orderCodes)) {
return Maps.newHashMap();
}
return qiniuLiveRecordMapper.selectByOrderCodes(orderCodes).stream()
.collect(Collectors.toMap(QiniuLiveRecord::getOrderCode, QiniuLiveRecord::getVedioFileUrl, (o, n) -> o));
return qiniuLiveRecordService.getAppraiseVideoUrl(orderCodes);
}
@Override
... ...
package com.yohoufo.order.service.impl;
import com.google.common.collect.Maps;
import com.yohoufo.dal.order.QiniuLiveRecordMapper;
import com.yohoufo.dal.order.model.QiniuLiveRecord;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
/**
* Created by li.ma on 2018/12/14.
*/
@Service
public class QiniuLiveRecordService {
public static final String LIVE_VEDIO_DOMAIN = "http://flv01.static.yhbimg.com/";
public static final String LIVE_VIDEO_DOMAIN = "http://flv01.static.yhbimg.com/";
@Autowired
private QiniuLiveRecordMapper qiniuLiveRecordMapper;
private static String makeLiveVideoUrl(String filename) {
if (StringUtils.isBlank(filename)) {
return null;
}
return LIVE_VIDEO_DOMAIN + filename;
}
public void updateStatusByPersistId(String persistId, Integer code) {
if (Integer.valueOf(0).equals(code)) {
qiniuLiveRecordMapper.updateStatusByPersistId(persistId, 1); // 更新直播记录状态为已转码成功
... ... @@ -33,8 +50,27 @@ public class QiniuLiveRecordService {
return null;
}
qiniuLiveRecords.setVedioFileUrl(LIVE_VEDIO_DOMAIN + qiniuLiveRecords.getVedioFileUrl());
qiniuLiveRecords.setVedioFileUrl(makeLiveVideoUrl(qiniuLiveRecords.getVedioFileUrl()));
return qiniuLiveRecords;
}
public Map<Long, String> getAppraiseVideoUrl(List<Long> orderCodes) {
if (CollectionUtils.isEmpty(orderCodes)) {
return Maps.newHashMap();
}
return qiniuLiveRecordMapper.selectByOrderCodes(orderCodes).stream()
.collect(Collectors.toMap(QiniuLiveRecord::getOrderCode,
e -> QiniuLiveRecordService.makeLiveVideoUrl(e.getVedioFileUrl()),
(o, n) -> o));
}
public String getAppraiseVideoUrl(Long orderCode) {
return Optional.ofNullable(orderCode)
.map(qiniuLiveRecordMapper::selectByOrderCode)
.map(QiniuLiveRecord::getVedioFileUrl)
.map(QiniuLiveRecordService::makeLiveVideoUrl)
.orElse(null);
}
}
... ...
... ... @@ -92,7 +92,7 @@ public class SellerOrderDetailService extends AbsOrderDetailService implements I
private SellerOrderPrepareProcessor sellerOrderPrepareProcessor;
@Autowired
QiniuLiveRecordMapper qiniuLiveRecordMapper;
private QiniuLiveRecordService qiniuLiveRecordService;
private static List<SkupStatus> noNeedShowOrderCode = Arrays.asList(SkupStatus.CAN_NOT_SELL,SkupStatus.CAN_SELL,
SkupStatus.SELF_CANCEL_PAY, SkupStatus.TIMEOUT_CANCEL,
... ... @@ -207,8 +207,7 @@ public class SellerOrderDetailService extends AbsOrderDetailService implements I
return Optional.ofNullable(buyerOrder)
.filter(e -> e.getStatus() == WAITING_RECEIVE.getCode() || e.getStatus() == DONE.getCode())
.map(BuyerOrder::getOrderCode)
.map(orderCode -> qiniuLiveRecordMapper.selectByOrderCode(orderCode))
.map(QiniuLiveRecord::getVedioFileUrl)
.map(orderCode -> qiniuLiveRecordService.getAppraiseVideoUrl(orderCode))
.orElse(null);
}
... ...
... ... @@ -72,7 +72,7 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde
private SellerOrderPrepareProcessor sellerOrderPrepareProcessor;
@Autowired
private QiniuLiveRecordMapper qiniuLiveRecordMapper;
private QiniuLiveRecordService qiniuLiveRecordService;
public List<OrderListInfo> buildOrderList(List<SellerOrderGoods> sogList, SellerType sellerType){
sogList.stream().forEach(item -> {
... ... @@ -341,8 +341,7 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde
if (CollectionUtils.isEmpty(orderCodes)) {
return Maps.newHashMap();
}
return qiniuLiveRecordMapper.selectByOrderCodes(orderCodes).stream()
.collect(Collectors.toMap(QiniuLiveRecord::getOrderCode, QiniuLiveRecord::getVedioFileUrl, (o, n) -> o));
return qiniuLiveRecordService.getAppraiseVideoUrl(orderCodes);
}
@Override
... ...