|
|
package com.yohoufo.order.service.impl;
|
|
|
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.google.common.collect.Maps;
|
|
|
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.utils.DateUtil;
|
|
|
import com.yohoufo.dal.order.BuyerOrderMapper;
|
|
|
import com.yohoufo.dal.order.QiniuLiveRecordMapper;
|
|
|
import com.yohoufo.dal.order.model.BuyerOrder;
|
|
|
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 javax.annotation.Resource;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Optional;
|
...
|
...
|
@@ -26,7 +34,11 @@ public class QiniuLiveRecordService { |
|
|
@Autowired
|
|
|
private QiniuLiveRecordMapper qiniuLiveRecordMapper;
|
|
|
|
|
|
@Autowired
|
|
|
private BuyerOrderMapper buyerOrderMapper;
|
|
|
|
|
|
@Resource(name = "core-config-reader")
|
|
|
private ConfigReader configReader;
|
|
|
|
|
|
private static String makeLiveVideoUrl(String filename) {
|
|
|
if (StringUtils.isBlank(filename)) {
|
...
|
...
|
@@ -75,4 +87,44 @@ public class QiniuLiveRecordService { |
|
|
.orElse(null);
|
|
|
}
|
|
|
|
|
|
public List<OrderVideoResp> queryOrderVideos(int productId) {
|
|
|
List<OrderVideoResp> resps = Lists.newArrayList(queryInitVideo());
|
|
|
|
|
|
|
|
|
List<QiniuLiveRecord> qiNiuLiveRecords = qiniuLiveRecordMapper.selectByProductId(productId);
|
|
|
List<Long> orderCodeList = qiNiuLiveRecords.stream().map(QiniuLiveRecord::getOrderCode).collect(Collectors.toList());
|
|
|
if (CollectionUtils.isEmpty(orderCodeList)) {
|
|
|
return resps;
|
|
|
}
|
|
|
|
|
|
Map<Long, QiniuLiveRecord> recordMap = qiNiuLiveRecords.stream().collect(Collectors.toMap(QiniuLiveRecord::getOrderCode, item -> item));
|
|
|
|
|
|
|
|
|
List<BuyerOrder> buyerOrders = buyerOrderMapper.selectByOrderCodes(orderCodeList, Lists.newArrayList(OrderStatus.WAITING_RECEIVE.getCode(),
|
|
|
OrderStatus.DONE.getCode()));
|
|
|
|
|
|
buyerOrders.stream().forEach(item -> {
|
|
|
OrderVideoResp orderVideoResp = new OrderVideoResp();
|
|
|
QiniuLiveRecord qiniuLiveRecord = recordMap.get(item.getOrderCode());
|
|
|
orderVideoResp.setCreateTime(DateUtil.getDateFormatEx(qiniuLiveRecord.getEndTime(), DateUtil.MM_dd_yyyy_HH_mm_ssEx);
|
|
|
orderVideoResp.setDesc(configReader.getString("ufo.order.realDesc", "鉴定结果:真"));
|
|
|
orderVideoResp.setVideoUrl(makeLiveVideoUrl(qiniuLiveRecord.getVedioFileUrl()));
|
|
|
orderVideoResp.setInitFlag(Boolean.FALSE);
|
|
|
resps.add(orderVideoResp);
|
|
|
});
|
|
|
|
|
|
return resps;
|
|
|
}
|
|
|
|
|
|
// 查询宣传视频
|
|
|
private OrderVideoResp queryInitVideo() {
|
|
|
OrderVideoResp orderVideoResp = new OrderVideoResp();
|
|
|
|
|
|
orderVideoResp.setVideoUrl(configReader.getString("ufo.order.initVideo", "http://flv01.static.yhbimg.com/ufo/live/mp4/9827059662848_1545892263.mp4"));
|
|
|
orderVideoResp.setVideoPictureUrl(configReader.getString("ufo.order.initVideoPic", "http://img11.static.yhbimg.com/goodsimg/2018/12/28/17/01d30dbfc038ffffc2fc9506dcf9da164f.jpg"));
|
|
|
orderVideoResp.setCreateTime(DateUtil.getDateFormatEx(configReader.getInt("ufo.order.initVideoTime", 1546272000), DateUtil.MM_dd_yyyy_HH_mm_ssEx);
|
|
|
orderVideoResp.setDesc(configReader.getString("ufo.order.initVideoDesc", "宣传视频"));
|
|
|
orderVideoResp.setInitFlag(Boolean.TRUE);
|
|
|
return orderVideoResp;
|
|
|
}
|
|
|
} |
...
|
...
|
|