Authored by mali

Merge branch 'hotfix_vedio' into gray

@@ -247,6 +247,9 @@ @@ -247,6 +247,9 @@
247 <artifactId>orika-core</artifactId> 247 <artifactId>orika-core</artifactId>
248 <version>1.5.2</version> 248 <version>1.5.2</version>
249 </dependency> 249 </dependency>
250 - 250 + <dependency>
  251 + <groupId>com.yoho.ufo.model</groupId>
  252 + <artifactId>order-ufo-model</artifactId>
  253 + </dependency>
251 </dependencies> 254 </dependencies>
252 </project> 255 </project>
  1 +package com.yohoufo.common.constant;
  2 +
  3 +import com.yoho.core.config.ConfigReader;
  4 +import org.springframework.beans.factory.annotation.Autowired;
  5 +import org.springframework.stereotype.Service;
  6 +
  7 +/**
  8 + * Created by li.ma on 2019/4/15.
  9 + */
  10 +@Service
  11 +public class OrderConfigConstant {
  12 + @Autowired
  13 + private ConfigReader configReader;
  14 +
  15 + /**
  16 + * 获取视频生成方式。true 老的七牛直播方式 false 则代表NVR方式
  17 + * @return
  18 + */
  19 + public boolean getVedioConfig() {
  20 + return configReader.getBoolean("ufo.Vedio.Config", true);
  21 + }
  22 +}
  1 +package com.yohoufo.common.utils;
  2 +
  3 +import com.yohobuy.ufo.model.order.constants.QNliveConstants;
  4 +import org.apache.commons.lang3.StringUtils;
  5 +
  6 +/**
  7 + * Created by li.ma on 2019/4/15.
  8 + */
  9 +public class QiniuLiveUrlUtil {
  10 + public static final String LIVE_VIDEO_DOMAIN = QNliveConstants.LIVE_VIDEO_DOMAIN;
  11 + public static final String MP4_FILEKEY_PRE = QNliveConstants.MP4_FILEKEY_PRE; // mp4文件路径
  12 +
  13 + public static String makeLiveVideoUrl(String filename) {
  14 + if (StringUtils.isBlank(filename)) {
  15 + return null;
  16 + }
  17 +
  18 + if (filename.startsWith("http")) { // 如果数据库存放的是绝对路径,则直接返回
  19 + return filename;
  20 + }
  21 +
  22 + return LIVE_VIDEO_DOMAIN + MP4_FILEKEY_PRE + filename;
  23 + }
  24 +
  25 +
  26 + public static String makeLiveVideoUrl(String videoName, String filename) {
  27 + if (StringUtils.isNotBlank(videoName)) { // 优先取新的鉴定视频链接
  28 + return videoName;
  29 + }
  30 +
  31 + return makeLiveVideoUrl(filename);
  32 + }
  33 +
  34 + public static boolean filterVideoValid(String videoName, Integer status) {
  35 + return StringUtils.isNotBlank(videoName) || 1 == status;
  36 + }
  37 +}
@@ -15,8 +15,16 @@ public interface QiniuLiveRecordMapper { @@ -15,8 +15,16 @@ public interface QiniuLiveRecordMapper {
15 15
16 QiniuLiveRecord selectByOrderCode(@Param("orderCode") Long orderCode); 16 QiniuLiveRecord selectByOrderCode(@Param("orderCode") Long orderCode);
17 17
  18 + // 包含状态为0的,因为有可能是新的鉴定视频链接
  19 + QiniuLiveRecord selectByOrderCodeEx(@Param("orderCode") Long orderCode);
18 20
19 List<QiniuLiveRecord> selectByOrderCodes(@Param("orderCodes") List<Long> orderCodes); 21 List<QiniuLiveRecord> selectByOrderCodes(@Param("orderCodes") List<Long> orderCodes);
20 22
  23 + // 包含状态为0的,因为有可能是新的鉴定视频链接
  24 + List<QiniuLiveRecord> selectByOrderCodesEx(@Param("orderCodes") List<Long> orderCodes);
  25 +
21 List<QiniuLiveRecord> selectByProductId(@Param("productId")int productId); 26 List<QiniuLiveRecord> selectByProductId(@Param("productId")int productId);
  27 +
  28 + // 包含状态为0的,因为有可能是新的鉴定视频链接
  29 + List<QiniuLiveRecord> selectByProductIdEx(@Param("productId")int productId);
22 } 30 }
@@ -38,6 +38,7 @@ public class QiniuLiveRecord { @@ -38,6 +38,7 @@ public class QiniuLiveRecord {
38 38
39 private Integer showFlag; 39 private Integer showFlag;
40 40
  41 + private String videoUrl; // 新的鉴定视频生成的URL
41 42
42 public String getPersistId() { 43 public String getPersistId() {
43 return persistId; 44 return persistId;
@@ -167,6 +168,14 @@ public class QiniuLiveRecord { @@ -167,6 +168,14 @@ public class QiniuLiveRecord {
167 this.showFlag = showFlag; 168 this.showFlag = showFlag;
168 } 169 }
169 170
  171 + public void setVideoUrl(String videoUrl) {
  172 + this.videoUrl = videoUrl;
  173 + }
  174 +
  175 + public String getVideoUrl() {
  176 + return videoUrl;
  177 + }
  178 +
170 @Override 179 @Override
171 public String toString() { 180 public String toString() {
172 return JSONObject.toJSONString(this); 181 return JSONObject.toJSONString(this);
@@ -17,10 +17,11 @@ @@ -17,10 +17,11 @@
17 <result column="storage_id" property="storageId" jdbcType="INTEGER" /> 17 <result column="storage_id" property="storageId" jdbcType="INTEGER" />
18 <result column="goods_id" property="goodsId" jdbcType="INTEGER" /> 18 <result column="goods_id" property="goodsId" jdbcType="INTEGER" />
19 <result column="product_id" property="productId" jdbcType="INTEGER" /> 19 <result column="product_id" property="productId" jdbcType="INTEGER" />
  20 + <result column="video_url" property="videoUrl" jdbcType="VARCHAR" />
20 </resultMap> 21 </resultMap>
21 <sql id="Base_Column_List" > 22 <sql id="Base_Column_List" >
22 id, order_code, skup, seller_order_code, depot_no, start_time, end_time, persist_id, 23 id, order_code, skup, seller_order_code, depot_no, start_time, end_time, persist_id,
23 - vedio_file_url, create_time, update_time, status, storage_id, goods_id, product_id 24 + vedio_file_url, create_time, update_time, status, storage_id, goods_id, product_id, video_url
24 </sql> 25 </sql>
25 <select id="selectByOrderCode" resultMap="BaseResultMap" parameterType="java.lang.Long" > 26 <select id="selectByOrderCode" resultMap="BaseResultMap" parameterType="java.lang.Long" >
26 select 27 select
@@ -30,6 +31,14 @@ @@ -30,6 +31,14 @@
30 and show_flag = 1 and status = 1 order by id DESC limit 1 31 and show_flag = 1 and status = 1 order by id DESC limit 1
31 </select> 32 </select>
32 33
  34 + <select id="selectByOrderCodeEx" resultMap="BaseResultMap" parameterType="java.lang.Long" >
  35 + select
  36 + <include refid="Base_Column_List" />
  37 + from qiniu_live_record
  38 + where order_code = #{orderCode, jdbcType=BIGINT}
  39 + and show_flag = 1 and (status = 1 or video_url != '') order by id DESC limit 1
  40 + </select>
  41 +
33 42
34 <select id="selectByOrderCodes" resultMap="BaseResultMap"> 43 <select id="selectByOrderCodes" resultMap="BaseResultMap">
35 select 44 select
@@ -42,6 +51,17 @@ @@ -42,6 +51,17 @@
42 and show_flag = 1 and status = 1 order by id DESC 51 and show_flag = 1 and status = 1 order by id DESC
43 </select> 52 </select>
44 53
  54 + <select id="selectByOrderCodesEx" resultMap="BaseResultMap">
  55 + select
  56 + <include refid="Base_Column_List" />
  57 + from qiniu_live_record
  58 + where order_code in
  59 + <foreach collection="orderCodes" item="orderCode" open="(" separator="," close=")">
  60 + #{orderCode}
  61 + </foreach>
  62 + and show_flag = 1 order by id DESC
  63 + </select>
  64 +
45 <update id="updateStatusByPersistId"> 65 <update id="updateStatusByPersistId">
46 update qiniu_live_record 66 update qiniu_live_record
47 set status = #{status,jdbcType=INTEGER} 67 set status = #{status,jdbcType=INTEGER}
@@ -50,9 +70,17 @@ @@ -50,9 +70,17 @@
50 70
51 <select id="selectByProductId" resultMap="BaseResultMap"> 71 <select id="selectByProductId" resultMap="BaseResultMap">
52 select 72 select
53 - order_code, end_time, vedio_file_url, storage_id 73 + order_code, end_time, vedio_file_url, storage_id, status, video_url
54 from qiniu_live_record 74 from qiniu_live_record
55 where product_id = #{productId, jdbcType=INTEGER} 75 where product_id = #{productId, jdbcType=INTEGER}
56 and show_flag = 1 and status = 1 order by id DESC limit 10 76 and show_flag = 1 and status = 1 order by id DESC limit 10
57 </select> 77 </select>
  78 +
  79 + <select id="selectByProductIdEx" resultMap="BaseResultMap">
  80 + select
  81 + order_code, end_time, vedio_file_url, storage_id, status, video_url
  82 + from qiniu_live_record
  83 + where product_id = #{productId, jdbcType=INTEGER}
  84 + and show_flag = 1 order by id DESC limit 10
  85 + </select>
58 </mapper> 86 </mapper>
@@ -59,7 +59,7 @@ public class UfoLiveAvthumbController { @@ -59,7 +59,7 @@ public class UfoLiveAvthumbController {
59 @IgnoreSession 59 @IgnoreSession
60 @IgnoreSignature 60 @IgnoreSignature
61 @Cachable(expire = 180) 61 @Cachable(expire = 180)
62 - public ApiResponse buyerModifyAddress(@RequestParam("product_id") int productId){ 62 + public ApiResponse queryProductVideos(@RequestParam("product_id") int productId){
63 logger.info("in ufo.order.videos, product_id {}.", productId); 63 logger.info("in ufo.order.videos, product_id {}.", productId);
64 64
65 List<OrderVideoResp> respList = qiniuLiveRecordService.queryOrderVideos(productId); 65 List<OrderVideoResp> respList = qiniuLiveRecordService.queryOrderVideos(productId);
@@ -6,7 +6,9 @@ import com.yoho.core.config.ConfigReader; @@ -6,7 +6,9 @@ import com.yoho.core.config.ConfigReader;
6 import com.yohobuy.ufo.model.order.common.OrderStatus; 6 import com.yohobuy.ufo.model.order.common.OrderStatus;
7 import com.yohobuy.ufo.model.order.constants.QNliveConstants; 7 import com.yohobuy.ufo.model.order.constants.QNliveConstants;
8 import com.yohobuy.ufo.model.order.resp.OrderVideoResp; 8 import com.yohobuy.ufo.model.order.resp.OrderVideoResp;
  9 +import com.yohoufo.common.constant.OrderConfigConstant;
9 import com.yohoufo.common.utils.DateUtil; 10 import com.yohoufo.common.utils.DateUtil;
  11 +import com.yohoufo.common.utils.QiniuLiveUrlUtil;
10 import com.yohoufo.dal.order.BuyerOrderMapper; 12 import com.yohoufo.dal.order.BuyerOrderMapper;
11 import com.yohoufo.dal.order.QiniuLiveRecordMapper; 13 import com.yohoufo.dal.order.QiniuLiveRecordMapper;
12 import com.yohoufo.dal.order.model.BuyerOrder; 14 import com.yohoufo.dal.order.model.BuyerOrder;
@@ -32,9 +34,6 @@ import java.util.stream.Collectors; @@ -32,9 +34,6 @@ import java.util.stream.Collectors;
32 public class QiniuLiveRecordService { 34 public class QiniuLiveRecordService {
33 private final Logger LOG = LoggerFactory.getLogger(QiniuLiveRecordService.class); 35 private final Logger LOG = LoggerFactory.getLogger(QiniuLiveRecordService.class);
34 36
35 - public static final String LIVE_VIDEO_DOMAIN = QNliveConstants.LIVE_VIDEO_DOMAIN;  
36 - public static final String MP4_FILEKEY_PRE = QNliveConstants.MP4_FILEKEY_PRE; // mp4文件路径  
37 -  
38 @Autowired 37 @Autowired
39 private QiniuLiveRecordMapper qiniuLiveRecordMapper; 38 private QiniuLiveRecordMapper qiniuLiveRecordMapper;
40 39
@@ -44,18 +43,8 @@ public class QiniuLiveRecordService { @@ -44,18 +43,8 @@ public class QiniuLiveRecordService {
44 @Autowired 43 @Autowired
45 private ConfigReader configReader; 44 private ConfigReader configReader;
46 45
47 - private static String makeLiveVideoUrl(String filename) {  
48 - if (StringUtils.isBlank(filename)) {  
49 - return null;  
50 - }  
51 -  
52 - if (filename.startsWith("http")) { // 如果数据库存放的是绝对路径,则直接返回  
53 - return filename;  
54 - }  
55 -  
56 - return LIVE_VIDEO_DOMAIN + MP4_FILEKEY_PRE + filename;  
57 - }  
58 - 46 + @Autowired
  47 + OrderConfigConstant orderConfigConstant;
59 48
60 public void updateStatusByPersistId(String persistId, Integer code) { 49 public void updateStatusByPersistId(String persistId, Integer code) {
61 if (Integer.valueOf(0).equals(code)) { 50 if (Integer.valueOf(0).equals(code)) {
@@ -67,14 +56,27 @@ public class QiniuLiveRecordService { @@ -67,14 +56,27 @@ public class QiniuLiveRecordService {
67 if (null == orderCode) { 56 if (null == orderCode) {
68 return null; 57 return null;
69 } 58 }
70 - QiniuLiveRecord qiniuLiveRecords = qiniuLiveRecordMapper.selectByOrderCode(orderCode); 59 + QiniuLiveRecord qiniuLiveRecords;
  60 + if (orderConfigConstant.getVedioConfig()) {
  61 + LOG.info("method selectByOrderCodes in qiniuLiveRecordMapper.selectByOrderCode orderCode is {}", orderCode);
  62 + qiniuLiveRecords = qiniuLiveRecordMapper.selectByOrderCode(orderCode);
71 63
72 if (null == qiniuLiveRecords || StringUtils.isEmpty(qiniuLiveRecords.getVedioFileUrl())) { 64 if (null == qiniuLiveRecords || StringUtils.isEmpty(qiniuLiveRecords.getVedioFileUrl())) {
73 return null; 65 return null;
74 } 66 }
75 67
76 - qiniuLiveRecords.setVedioFileUrl(makeLiveVideoUrl(qiniuLiveRecords.getVedioFileUrl())); 68 + qiniuLiveRecords.setVedioFileUrl(QiniuLiveUrlUtil.makeLiveVideoUrl(qiniuLiveRecords.getVedioFileUrl()));
  69 +
  70 + } else {
  71 + LOG.info("method selectByOrderCodes in qiniuLiveRecordMapper.selectByOrderCodeEx orderCode is {}", orderCode);
  72 + qiniuLiveRecords = qiniuLiveRecordMapper.selectByOrderCodeEx(orderCode);
77 73
  74 + if (null == qiniuLiveRecords || StringUtils.isEmpty(qiniuLiveRecords.getVedioFileUrl())) {
  75 + return null;
  76 + }
  77 +
  78 + qiniuLiveRecords.setVedioFileUrl(QiniuLiveUrlUtil.makeLiveVideoUrl(qiniuLiveRecords.getVideoUrl(), qiniuLiveRecords.getVedioFileUrl()));
  79 + }
78 return qiniuLiveRecords; 80 return qiniuLiveRecords;
79 } 81 }
80 82
@@ -82,25 +84,58 @@ public class QiniuLiveRecordService { @@ -82,25 +84,58 @@ public class QiniuLiveRecordService {
82 if (CollectionUtils.isEmpty(orderCodes)) { 84 if (CollectionUtils.isEmpty(orderCodes)) {
83 return Maps.newHashMap(); 85 return Maps.newHashMap();
84 } 86 }
  87 +
  88 + if (orderConfigConstant.getVedioConfig()) {
  89 + LOG.info("method getAppraiseVideoUrl in qiniuLiveRecordMapper.selectByOrderCodes orderCodes is {}", orderCodes);
85 return qiniuLiveRecordMapper.selectByOrderCodes(orderCodes).stream() 90 return qiniuLiveRecordMapper.selectByOrderCodes(orderCodes).stream()
86 .collect(Collectors.toMap(QiniuLiveRecord::getOrderCode, 91 .collect(Collectors.toMap(QiniuLiveRecord::getOrderCode,
87 - e -> QiniuLiveRecordService.makeLiveVideoUrl(e.getVedioFileUrl()), 92 + e -> QiniuLiveUrlUtil.makeLiveVideoUrl(e.getVedioFileUrl()),
  93 + (o, n) -> o));
  94 + } else {
  95 + LOG.info("method getAppraiseVideoUrl in qiniuLiveRecordMapper.selectByOrderCodesEx orderCodes is {}", orderCodes);
  96 +
  97 + return qiniuLiveRecordMapper.selectByOrderCodesEx(orderCodes).stream()
  98 + .filter(item -> QiniuLiveUrlUtil.filterVideoValid(item.getVideoUrl(), item.getStatus()))
  99 + .collect(Collectors.toMap(QiniuLiveRecord::getOrderCode, e -> QiniuLiveUrlUtil.makeLiveVideoUrl(e.getVideoUrl(), e.getVedioFileUrl()),
88 (o, n) -> o)); 100 (o, n) -> o));
89 } 101 }
  102 + }
90 103
91 public String getAppraiseVideoUrl(Long orderCode) { 104 public String getAppraiseVideoUrl(Long orderCode) {
  105 + if (orderConfigConstant.getVedioConfig()) {
  106 + LOG.info("method getAppraiseVideoUrl in qiniuLiveRecordMapper.selectByOrderCode orderCode is {}", orderCode);
  107 +
92 return Optional.ofNullable(orderCode) 108 return Optional.ofNullable(orderCode)
93 .map(qiniuLiveRecordMapper::selectByOrderCode) 109 .map(qiniuLiveRecordMapper::selectByOrderCode)
94 .map(QiniuLiveRecord::getVedioFileUrl) 110 .map(QiniuLiveRecord::getVedioFileUrl)
95 - .map(QiniuLiveRecordService::makeLiveVideoUrl) 111 + .map(QiniuLiveUrlUtil::makeLiveVideoUrl)
96 .orElse(null); 112 .orElse(null);
  113 + } else {
  114 + LOG.info("method getAppraiseVideoUrl in qiniuLiveRecordMapper.selectByOrderCodeEx orderCode is {}", orderCode);
  115 +
  116 + QiniuLiveRecord qiniuLiveRecord = Optional.ofNullable(orderCode)
  117 + .map(qiniuLiveRecordMapper::selectByOrderCodeEx).orElse(null);
  118 +
  119 + return null == qiniuLiveRecord ? null : QiniuLiveUrlUtil.makeLiveVideoUrl(qiniuLiveRecord.getVideoUrl(), qiniuLiveRecord.getVedioFileUrl());
  120 + }
  121 +
  122 +
97 } 123 }
98 124
99 public List<OrderVideoResp> queryOrderVideos(int productId) { 125 public List<OrderVideoResp> queryOrderVideos(int productId) {
100 List<OrderVideoResp> resps = Lists.newArrayList(); 126 List<OrderVideoResp> resps = Lists.newArrayList();
101 queryInitVideo(resps); 127 queryInitVideo(resps);
102 128
103 - List<QiniuLiveRecord> qiNiuLiveRecords = qiniuLiveRecordMapper.selectByProductId(productId); 129 + List<QiniuLiveRecord> qiNiuLiveRecords;
  130 + if (orderConfigConstant.getVedioConfig()) {
  131 + LOG.info("mthod queryOrderVideos in qiniuLiveRecordMapper.selectByProductId productId is {}", productId);
  132 + qiNiuLiveRecords = qiniuLiveRecordMapper.selectByProductId(productId);
  133 + } else {
  134 + LOG.info("mthod queryOrderVideos in qiniuLiveRecordMapper.selectByProductIdEx productId is {}", productId);
  135 + qiNiuLiveRecords = qiniuLiveRecordMapper.selectByProductIdEx(productId).stream()
  136 + .filter(item -> QiniuLiveUrlUtil.filterVideoValid(item.getVideoUrl(), item.getStatus())).collect(Collectors.toList());
  137 + }
  138 +
104 List<Long> orderCodeList = qiNiuLiveRecords.stream().map(QiniuLiveRecord::getOrderCode).collect(Collectors.toList()); 139 List<Long> orderCodeList = qiNiuLiveRecords.stream().map(QiniuLiveRecord::getOrderCode).collect(Collectors.toList());
105 if (CollectionUtils.isEmpty(orderCodeList) || !configReader.getBoolean("ufo.order.appressVideoShow", true)) { 140 if (CollectionUtils.isEmpty(orderCodeList) || !configReader.getBoolean("ufo.order.appressVideoShow", true)) {
106 return resps; 141 return resps;
@@ -108,7 +143,7 @@ public class QiniuLiveRecordService { @@ -108,7 +143,7 @@ public class QiniuLiveRecordService {
108 143
109 LOG.info("method queryOrderVideos in orderCodeList is {}, productId is {}", orderCodeList, productId); 144 LOG.info("method queryOrderVideos in orderCodeList is {}, productId is {}", orderCodeList, productId);
110 145
111 - Map<Long, QiniuLiveRecord> recordMap = qiNiuLiveRecords.stream().collect(Collectors.toMap(QiniuLiveRecord::getOrderCode, item -> item)); 146 + Map<Long, QiniuLiveRecord> recordMap = qiNiuLiveRecords.stream().collect(Collectors.toMap(QiniuLiveRecord::getOrderCode, item -> item, (a, b) -> a));
112 147
113 148
114 List<BuyerOrder> buyerOrders = buyerOrderMapper.selectByOrderCodes(orderCodeList, Lists.newArrayList(OrderStatus.WAITING_RECEIVE.getCode(), 149 List<BuyerOrder> buyerOrders = buyerOrderMapper.selectByOrderCodes(orderCodeList, Lists.newArrayList(OrderStatus.WAITING_RECEIVE.getCode(),
@@ -125,7 +160,12 @@ public class QiniuLiveRecordService { @@ -125,7 +160,12 @@ public class QiniuLiveRecordService {
125 orderVideoResp.setCreateTime(DateUtil.getDateFormatEx(qiniuLiveRecord.getEndTime(), DateUtil.MM_dd_yyyy_HH_mm_ssEx)); 160 orderVideoResp.setCreateTime(DateUtil.getDateFormatEx(qiniuLiveRecord.getEndTime(), DateUtil.MM_dd_yyyy_HH_mm_ssEx));
126 orderVideoResp.setDesc(configReader.getString("ufo.order.realDesc", "鉴定结果:真")); 161 orderVideoResp.setDesc(configReader.getString("ufo.order.realDesc", "鉴定结果:真"));
127 orderVideoResp.setVideoPictureUrl(configReader.getString("ufo.order.realVideoPic", "http://img11.static.yhbimg.com/goodsimg/2019/01/25/15/01f6c0a2303cfa1957a34b9f8b17e7e746.png")); 162 orderVideoResp.setVideoPictureUrl(configReader.getString("ufo.order.realVideoPic", "http://img11.static.yhbimg.com/goodsimg/2019/01/25/15/01f6c0a2303cfa1957a34b9f8b17e7e746.png"));
128 - orderVideoResp.setVideoUrl(makeLiveVideoUrl(qiniuLiveRecord.getVedioFileUrl())); 163 +
  164 + if (orderConfigConstant.getVedioConfig()) {
  165 + orderVideoResp.setVideoUrl(QiniuLiveUrlUtil.makeLiveVideoUrl(qiniuLiveRecord.getVedioFileUrl()));
  166 + } else {
  167 + orderVideoResp.setVideoUrl(QiniuLiveUrlUtil.makeLiveVideoUrl(qiniuLiveRecord.getVideoUrl(), qiniuLiveRecord.getVedioFileUrl()));
  168 + }
129 orderVideoResp.setInitFlag(Boolean.FALSE); 169 orderVideoResp.setInitFlag(Boolean.FALSE);
130 appraiseVideoList.add(orderVideoResp); 170 appraiseVideoList.add(orderVideoResp);
131 }); 171 });
1 package com.yohoufo.product.service.impl; 1 package com.yohoufo.product.service.impl;
2 2
3 import java.text.SimpleDateFormat; 3 import java.text.SimpleDateFormat;
4 -import java.util.ArrayList;  
5 -import java.util.Collections;  
6 -import java.util.Comparator;  
7 -import java.util.Date;  
8 -import java.util.HashMap;  
9 -import java.util.List;  
10 -import java.util.Map; 4 +import java.util.*;
11 import java.util.stream.Collectors; 5 import java.util.stream.Collectors;
12 6
13 import javax.annotation.Resource; 7 import javax.annotation.Resource;
14 8
  9 +import com.yohoufo.common.constant.OrderConfigConstant;
  10 +import com.yohoufo.common.utils.QiniuLiveUrlUtil;
15 import org.apache.commons.collections.CollectionUtils; 11 import org.apache.commons.collections.CollectionUtils;
16 import org.apache.commons.collections.MapUtils; 12 import org.apache.commons.collections.MapUtils;
17 import org.apache.commons.lang3.StringUtils; 13 import org.apache.commons.lang3.StringUtils;
@@ -152,6 +148,9 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{ @@ -152,6 +148,9 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{
152 @Value("${ufo.nfc.syncBlockChain.url}") 148 @Value("${ufo.nfc.syncBlockChain.url}")
153 private String syncBlockChain_url; 149 private String syncBlockChain_url;
154 150
  151 + @Autowired
  152 + OrderConfigConstant orderConfigConstant;
  153 +
155 private static final String UIC_PROFILE_URL = "/profile/getProfile"; 154 private static final String UIC_PROFILE_URL = "/profile/getProfile";
156 155
157 public static final String DEFAULT_HEAD_IMG = "http://img11.static.yhbimg.com/yhb-img01/2016/07/05/13/017ec560b82c132ab2fdb22f7cf6f42b83.png?imageView/{mode}/w/{width}/h/{height}"; 156 public static final String DEFAULT_HEAD_IMG = "http://img11.static.yhbimg.com/yhb-img01/2016/07/05/13/017ec560b82c132ab2fdb22f7cf6f42b83.png?imageView/{mode}/w/{width}/h/{height}";
@@ -951,19 +950,21 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{ @@ -951,19 +950,21 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{
951 if (null == orderCode) { 950 if (null == orderCode) {
952 return null; 951 return null;
953 } 952 }
954 - QiniuLiveRecord qiniuLiveRecords = qiniuLiveRecordMapper.selectByOrderCode(orderCode);  
955 - if (null == qiniuLiveRecords || StringUtils.isEmpty(qiniuLiveRecords.getVedioFileUrl())) {  
956 - return null;  
957 - }  
958 - String filename = qiniuLiveRecords.getVedioFileUrl();  
959 - if (StringUtils.isBlank(filename)) {  
960 - return null;  
961 - }  
962 - if (filename.startsWith("http")) {  
963 - return filename; 953 +
  954 + if (orderConfigConstant.getVedioConfig()) {
  955 + logger.info("method getLiveVideoUrlByOrderCode in qiniuLiveRecordMapper.selectByOrderCode orderCode is {}", orderCode);
  956 +
  957 + return Optional.ofNullable(orderCode).map(qiniuLiveRecordMapper::selectByOrderCode)
  958 + .map(item -> QiniuLiveUrlUtil.makeLiveVideoUrl(item.getVedioFileUrl())).orElse(null);
  959 +
  960 + } else {
  961 + logger.info("method getLiveVideoUrlByOrderCode in qiniuLiveRecordMapper.selectByOrderCodeEx orderCode is {}", orderCode);
  962 +
  963 + QiniuLiveRecord qiniuLiveRecords = qiniuLiveRecordMapper.selectByOrderCodeEx(orderCode);
  964 +
  965 + return Optional.ofNullable(orderCode).map(qiniuLiveRecordMapper::selectByOrderCodeEx)
  966 + .map(item -> QiniuLiveUrlUtil.makeLiveVideoUrl(item.getVideoUrl(), item.getVedioFileUrl())).orElse(null);
964 } 967 }
965 - logger.info("getLiveVideoUrlByOrderCode success! orderCode={},filename={}", orderCode,filename);  
966 - return QNliveConstants.LIVE_VIDEO_DOMAIN + QNliveConstants.MP4_FILEKEY_PRE + filename;  
967 } 968 }
968 969
969 970