...
|
...
|
@@ -6,7 +6,9 @@ import com.yoho.core.config.ConfigReader; |
|
|
import com.yohobuy.ufo.model.order.common.OrderStatus;
|
|
|
import com.yohobuy.ufo.model.order.constants.QNliveConstants;
|
|
|
import com.yohobuy.ufo.model.order.resp.OrderVideoResp;
|
|
|
import com.yohoufo.common.constant.OrderConfigConstant;
|
|
|
import com.yohoufo.common.utils.DateUtil;
|
|
|
import com.yohoufo.common.utils.QiniuLiveUrlUtil;
|
|
|
import com.yohoufo.dal.order.BuyerOrderMapper;
|
|
|
import com.yohoufo.dal.order.QiniuLiveRecordMapper;
|
|
|
import com.yohoufo.dal.order.model.BuyerOrder;
|
...
|
...
|
@@ -32,9 +34,6 @@ import java.util.stream.Collectors; |
|
|
public class QiniuLiveRecordService {
|
|
|
private final Logger LOG = LoggerFactory.getLogger(QiniuLiveRecordService.class);
|
|
|
|
|
|
public static final String LIVE_VIDEO_DOMAIN = QNliveConstants.LIVE_VIDEO_DOMAIN;
|
|
|
public static final String MP4_FILEKEY_PRE = QNliveConstants.MP4_FILEKEY_PRE; // mp4文件路径
|
|
|
|
|
|
@Autowired
|
|
|
private QiniuLiveRecordMapper qiniuLiveRecordMapper;
|
|
|
|
...
|
...
|
@@ -44,18 +43,8 @@ public class QiniuLiveRecordService { |
|
|
@Autowired
|
|
|
private ConfigReader configReader;
|
|
|
|
|
|
private static String makeLiveVideoUrl(String filename) {
|
|
|
if (StringUtils.isBlank(filename)) {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
if (filename.startsWith("http")) { // 如果数据库存放的是绝对路径,则直接返回
|
|
|
return filename;
|
|
|
}
|
|
|
|
|
|
return LIVE_VIDEO_DOMAIN + MP4_FILEKEY_PRE + filename;
|
|
|
}
|
|
|
|
|
|
@Autowired
|
|
|
OrderConfigConstant orderConfigConstant;
|
|
|
|
|
|
public void updateStatusByPersistId(String persistId, Integer code) {
|
|
|
if (Integer.valueOf(0).equals(code)) {
|
...
|
...
|
@@ -67,14 +56,27 @@ public class QiniuLiveRecordService { |
|
|
if (null == orderCode) {
|
|
|
return null;
|
|
|
}
|
|
|
QiniuLiveRecord qiniuLiveRecords = qiniuLiveRecordMapper.selectByOrderCode(orderCode);
|
|
|
QiniuLiveRecord qiniuLiveRecords;
|
|
|
if (orderConfigConstant.getVedioConfig()) {
|
|
|
LOG.info("method selectByOrderCodes in qiniuLiveRecordMapper.selectByOrderCode orderCode is {}", orderCode);
|
|
|
qiniuLiveRecords = qiniuLiveRecordMapper.selectByOrderCode(orderCode);
|
|
|
|
|
|
if (null == qiniuLiveRecords || StringUtils.isEmpty(qiniuLiveRecords.getVedioFileUrl())) {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
qiniuLiveRecords.setVedioFileUrl(makeLiveVideoUrl(qiniuLiveRecords.getVedioFileUrl()));
|
|
|
qiniuLiveRecords.setVedioFileUrl(QiniuLiveUrlUtil.makeLiveVideoUrl(qiniuLiveRecords.getVedioFileUrl()));
|
|
|
|
|
|
} else {
|
|
|
LOG.info("method selectByOrderCodes in qiniuLiveRecordMapper.selectByOrderCodeEx orderCode is {}", orderCode);
|
|
|
qiniuLiveRecords = qiniuLiveRecordMapper.selectByOrderCodeEx(orderCode);
|
|
|
|
|
|
if (null == qiniuLiveRecords || StringUtils.isEmpty(qiniuLiveRecords.getVedioFileUrl())) {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
qiniuLiveRecords.setVedioFileUrl(QiniuLiveUrlUtil.makeLiveVideoUrl(qiniuLiveRecords.getVideoUrl(), qiniuLiveRecords.getVedioFileUrl()));
|
|
|
}
|
|
|
return qiniuLiveRecords;
|
|
|
}
|
|
|
|
...
|
...
|
@@ -82,25 +84,58 @@ public class QiniuLiveRecordService { |
|
|
if (CollectionUtils.isEmpty(orderCodes)) {
|
|
|
return Maps.newHashMap();
|
|
|
}
|
|
|
|
|
|
if (orderConfigConstant.getVedioConfig()) {
|
|
|
LOG.info("method getAppraiseVideoUrl in qiniuLiveRecordMapper.selectByOrderCodes orderCodes is {}", orderCodes);
|
|
|
return qiniuLiveRecordMapper.selectByOrderCodes(orderCodes).stream()
|
|
|
.collect(Collectors.toMap(QiniuLiveRecord::getOrderCode,
|
|
|
e -> QiniuLiveRecordService.makeLiveVideoUrl(e.getVedioFileUrl()),
|
|
|
e -> QiniuLiveUrlUtil.makeLiveVideoUrl(e.getVedioFileUrl()),
|
|
|
(o, n) -> o));
|
|
|
} else {
|
|
|
LOG.info("method getAppraiseVideoUrl in qiniuLiveRecordMapper.selectByOrderCodesEx orderCodes is {}", orderCodes);
|
|
|
|
|
|
return qiniuLiveRecordMapper.selectByOrderCodesEx(orderCodes).stream()
|
|
|
.filter(item -> QiniuLiveUrlUtil.filterVideoValid(item.getVideoUrl(), item.getStatus()))
|
|
|
.collect(Collectors.toMap(QiniuLiveRecord::getOrderCode, e -> QiniuLiveUrlUtil.makeLiveVideoUrl(e.getVideoUrl(), e.getVedioFileUrl()),
|
|
|
(o, n) -> o));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public String getAppraiseVideoUrl(Long orderCode) {
|
|
|
if (orderConfigConstant.getVedioConfig()) {
|
|
|
LOG.info("method getAppraiseVideoUrl in qiniuLiveRecordMapper.selectByOrderCode orderCode is {}", orderCode);
|
|
|
|
|
|
return Optional.ofNullable(orderCode)
|
|
|
.map(qiniuLiveRecordMapper::selectByOrderCode)
|
|
|
.map(QiniuLiveRecord::getVedioFileUrl)
|
|
|
.map(QiniuLiveRecordService::makeLiveVideoUrl)
|
|
|
.map(QiniuLiveUrlUtil::makeLiveVideoUrl)
|
|
|
.orElse(null);
|
|
|
} else {
|
|
|
LOG.info("method getAppraiseVideoUrl in qiniuLiveRecordMapper.selectByOrderCodeEx orderCode is {}", orderCode);
|
|
|
|
|
|
QiniuLiveRecord qiniuLiveRecord = Optional.ofNullable(orderCode)
|
|
|
.map(qiniuLiveRecordMapper::selectByOrderCodeEx).orElse(null);
|
|
|
|
|
|
return null == qiniuLiveRecord ? null : QiniuLiveUrlUtil.makeLiveVideoUrl(qiniuLiveRecord.getVideoUrl(), qiniuLiveRecord.getVedioFileUrl());
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
public List<OrderVideoResp> queryOrderVideos(int productId) {
|
|
|
List<OrderVideoResp> resps = Lists.newArrayList();
|
|
|
queryInitVideo(resps);
|
|
|
|
|
|
List<QiniuLiveRecord> qiNiuLiveRecords = qiniuLiveRecordMapper.selectByProductId(productId);
|
|
|
List<QiniuLiveRecord> qiNiuLiveRecords;
|
|
|
if (orderConfigConstant.getVedioConfig()) {
|
|
|
LOG.info("mthod queryOrderVideos in qiniuLiveRecordMapper.selectByProductId productId is {}", productId);
|
|
|
qiNiuLiveRecords = qiniuLiveRecordMapper.selectByProductId(productId);
|
|
|
} else {
|
|
|
LOG.info("mthod queryOrderVideos in qiniuLiveRecordMapper.selectByProductIdEx productId is {}", productId);
|
|
|
qiNiuLiveRecords = qiniuLiveRecordMapper.selectByProductIdEx(productId).stream()
|
|
|
.filter(item -> QiniuLiveUrlUtil.filterVideoValid(item.getVideoUrl(), item.getStatus())).collect(Collectors.toList());
|
|
|
}
|
|
|
|
|
|
List<Long> orderCodeList = qiNiuLiveRecords.stream().map(QiniuLiveRecord::getOrderCode).collect(Collectors.toList());
|
|
|
if (CollectionUtils.isEmpty(orderCodeList) || !configReader.getBoolean("ufo.order.appressVideoShow", true)) {
|
|
|
return resps;
|
...
|
...
|
@@ -108,7 +143,7 @@ public class QiniuLiveRecordService { |
|
|
|
|
|
LOG.info("method queryOrderVideos in orderCodeList is {}, productId is {}", orderCodeList, productId);
|
|
|
|
|
|
Map<Long, QiniuLiveRecord> recordMap = qiNiuLiveRecords.stream().collect(Collectors.toMap(QiniuLiveRecord::getOrderCode, item -> item));
|
|
|
Map<Long, QiniuLiveRecord> recordMap = qiNiuLiveRecords.stream().collect(Collectors.toMap(QiniuLiveRecord::getOrderCode, item -> item, (a, b) -> a));
|
|
|
|
|
|
|
|
|
List<BuyerOrder> buyerOrders = buyerOrderMapper.selectByOrderCodes(orderCodeList, Lists.newArrayList(OrderStatus.WAITING_RECEIVE.getCode(),
|
...
|
...
|
@@ -125,7 +160,12 @@ public class QiniuLiveRecordService { |
|
|
orderVideoResp.setCreateTime(DateUtil.getDateFormatEx(qiniuLiveRecord.getEndTime(), DateUtil.MM_dd_yyyy_HH_mm_ssEx));
|
|
|
orderVideoResp.setDesc(configReader.getString("ufo.order.realDesc", "鉴定结果:真"));
|
|
|
orderVideoResp.setVideoPictureUrl(configReader.getString("ufo.order.realVideoPic", "http://img11.static.yhbimg.com/goodsimg/2019/01/25/15/01f6c0a2303cfa1957a34b9f8b17e7e746.png"));
|
|
|
orderVideoResp.setVideoUrl(makeLiveVideoUrl(qiniuLiveRecord.getVedioFileUrl()));
|
|
|
|
|
|
if (orderConfigConstant.getVedioConfig()) {
|
|
|
orderVideoResp.setVideoUrl(QiniuLiveUrlUtil.makeLiveVideoUrl(qiniuLiveRecord.getVedioFileUrl()));
|
|
|
} else {
|
|
|
orderVideoResp.setVideoUrl(QiniuLiveUrlUtil.makeLiveVideoUrl(qiniuLiveRecord.getVideoUrl(), qiniuLiveRecord.getVedioFileUrl()));
|
|
|
}
|
|
|
orderVideoResp.setInitFlag(Boolean.FALSE);
|
|
|
appraiseVideoList.add(orderVideoResp);
|
|
|
});
|
...
|
...
|
|