Authored by mali

鉴定服务

@@ -31,4 +31,12 @@ public interface QiniuLiveRecordMapper { @@ -31,4 +31,12 @@ public interface QiniuLiveRecordMapper {
31 31
32 // 包含状态为0的,因为有可能是新的鉴定视频链接 32 // 包含状态为0的,因为有可能是新的鉴定视频链接
33 List<QiniuLiveRecord> selectByProductIdEx(@Param("productId")int productId); 33 List<QiniuLiveRecord> selectByProductIdEx(@Param("productId")int productId);
  34 +
  35 + /**
  36 + * 查询鉴定服务对应的鉴定视频
  37 + * @param stateIdx
  38 + * @param limit
  39 + * @return
  40 + */
  41 + List<QiniuLiveRecord> selectByPage(@Param("orderType")Integer orderType, @Param("stateIdx")int stateIdx, @Param("limit")Integer limit);
34 } 42 }
@@ -114,7 +114,7 @@ @@ -114,7 +114,7 @@
114 order_code, end_time, vedio_file_url, storage_id, status, video_url 114 order_code, end_time, vedio_file_url, storage_id, status, video_url
115 from qiniu_live_record 115 from qiniu_live_record
116 where product_id = #{productId, jdbcType=INTEGER} 116 where product_id = #{productId, jdbcType=INTEGER}
117 - and show_flag = 1 and status = 1 order by id DESC limit 20 117 + and show_flag = 1 and status = 1 and order_type = 0 order by id DESC limit 20
118 </select> 118 </select>
119 119
120 <select id="selectByProductIdEx" resultMap="BaseResultMap"> 120 <select id="selectByProductIdEx" resultMap="BaseResultMap">
@@ -122,6 +122,13 @@ @@ -122,6 +122,13 @@
122 order_code, end_time, vedio_file_url, storage_id, status, video_url 122 order_code, end_time, vedio_file_url, storage_id, status, video_url
123 from qiniu_live_record 123 from qiniu_live_record
124 where product_id = #{productId, jdbcType=INTEGER} 124 where product_id = #{productId, jdbcType=INTEGER}
125 - and show_flag = 1 order by id DESC limit 20 125 + and show_flag = 1 and order_type = 0 order by id DESC limit 20
  126 + </select>
  127 +
  128 + <select id="selectByPage" resultMap="BaseResultMap">
  129 + select
  130 + <include refid="Base_Column_List" />
  131 + from qiniu_live_record
  132 + where show_flag = 1 and order_type = #{orderType, jdbcType=INTEGER} AND video_url != '' order by id DESC limit #{stateIdx, jdbcType=INTEGER}, #{limit, jdbcType=INTEGER}
126 </select> 133 </select>
127 </mapper> 134 </mapper>
@@ -66,4 +66,24 @@ public class UfoLiveAvthumbController { @@ -66,4 +66,24 @@ public class UfoLiveAvthumbController {
66 66
67 return new ApiResponse.ApiResponseBuilder().code(200).data(respList).message("查询成功").build(); 67 return new ApiResponse.ApiResponseBuilder().code(200).data(respList).message("查询成功").build();
68 } 68 }
  69 +
  70 + /**
  71 + * 查询鉴定服务对应的视频列表
  72 + *
  73 + * http://java-yohoufo-fore.test3.ingress.dev.yohocorp.com/ufo-gateway/ufoLive/?method=ufo.order.videoList&page=1&limit=30
  74 + *
  75 + * @return
  76 + */
  77 + @RequestMapping(params = "method=ufo.order.videoList")
  78 + @IgnoreSession
  79 + @IgnoreSignature
  80 + @Cachable(expire = 180)
  81 + public ApiResponse queryVideoList(@RequestParam(value = "page", required = false, defaultValue = "1") Integer page
  82 + , @RequestParam(value = "limit", required = false, defaultValue = "30") Integer limit){
  83 + logger.info("in ufo.order.videoList, page {}. limit {}", page, limit);
  84 +
  85 + List<OrderVideoResp> respList = qiniuLiveRecordService.queryVideoList(page, limit);
  86 +
  87 + return new ApiResponse.ApiResponseBuilder().code(200).data(respList).message("查询成功").build();
  88 + }
69 } 89 }
1 package com.yohoufo.order.service.impl; 1 package com.yohoufo.order.service.impl;
2 2
3 import com.alibaba.fastjson.JSON; 3 import com.alibaba.fastjson.JSON;
  4 +import com.alibaba.fastjson.JSONArray;
  5 +import com.alibaba.fastjson.JSONObject;
4 import com.google.common.collect.Lists; 6 import com.google.common.collect.Lists;
5 import com.google.common.collect.Maps; 7 import com.google.common.collect.Maps;
6 import com.yoho.core.config.ConfigReader; 8 import com.yoho.core.config.ConfigReader;
7 import com.yohobuy.ufo.model.order.common.OrderStatus; 9 import com.yohobuy.ufo.model.order.common.OrderStatus;
8 import com.yohobuy.ufo.model.order.constants.QNliveConstants; 10 import com.yohobuy.ufo.model.order.constants.QNliveConstants;
  11 +import com.yohobuy.ufo.model.order.req.OrderTypeEnum;
9 import com.yohobuy.ufo.model.order.resp.OrderVideoResp; 12 import com.yohobuy.ufo.model.order.resp.OrderVideoResp;
  13 +import com.yohoufo.common.caller.UfoServiceCaller;
10 import com.yohoufo.common.constant.OrderConfigConstant; 14 import com.yohoufo.common.constant.OrderConfigConstant;
11 import com.yohoufo.common.utils.DateUtil; 15 import com.yohoufo.common.utils.DateUtil;
12 import com.yohoufo.common.utils.QiniuLiveUrlUtil; 16 import com.yohoufo.common.utils.QiniuLiveUrlUtil;
@@ -47,6 +51,9 @@ public class QiniuLiveRecordService { @@ -47,6 +51,9 @@ public class QiniuLiveRecordService {
47 @Autowired 51 @Autowired
48 private SellerOrderMapper sellerOrderMapper; 52 private SellerOrderMapper sellerOrderMapper;
49 53
  54 + @Autowired
  55 + private UfoServiceCaller serviceCaller;
  56 +
50 public void updateStatusByPersistId(String persistId, Integer code) { 57 public void updateStatusByPersistId(String persistId, Integer code) {
51 if (Integer.valueOf(0).equals(code)) { 58 if (Integer.valueOf(0).equals(code)) {
52 qiniuLiveRecordMapper.updateStatusByPersistId(persistId, 1); // 更新直播记录状态为已转码成功 59 qiniuLiveRecordMapper.updateStatusByPersistId(persistId, 1); // 更新直播记录状态为已转码成功
@@ -220,4 +227,71 @@ public class QiniuLiveRecordService { @@ -220,4 +227,71 @@ public class QiniuLiveRecordService {
220 orderVideoResp.setInitFlag(Boolean.TRUE); 227 orderVideoResp.setInitFlag(Boolean.TRUE);
221 resps.add(orderVideoResp); 228 resps.add(orderVideoResp);
222 } 229 }
  230 +
  231 + /**
  232 + * 查询鉴定服务对应的视频列表
  233 + *
  234 + * @return
  235 + */
  236 + public List<OrderVideoResp> queryVideoList(Integer page, Integer limit) {
  237 + List<QiniuLiveRecord> qiNiuLiveRecords = qiniuLiveRecordMapper.selectByPage(OrderTypeEnum.ORDERTYPE_APPRAISEORDER.getCode(), (page - 1) * limit, limit);
  238 +
  239 + if (CollectionUtils.isEmpty(qiNiuLiveRecords)) {
  240 + return Lists.newArrayList();
  241 + }
  242 +
  243 + List<Integer> productIdList = qiNiuLiveRecords.stream().map(QiniuLiveRecord::getProductId).collect(Collectors.toList());
  244 +
  245 + // 根据商品Id 查询商品名称和图片
  246 + Map<Integer, OrderVideoResp> productInfoMap = getProductInfo(productIdList);
  247 +
  248 + LOG.info("queryVideoList method in productIdList is {}, productInfoMap.keySet is {}", productIdList, productInfoMap.keySet());
  249 +
  250 + List<OrderVideoResp> result = Lists.newArrayList();
  251 +
  252 + qiNiuLiveRecords.stream().forEach(item -> {
  253 + OrderVideoResp resp = new OrderVideoResp();
  254 +
  255 + OrderVideoResp orderVideoResp = productInfoMap.get(item.getProductId());
  256 + resp.setVideoUrl(item.getVideoUrl());
  257 + resp.setProductName(null == orderVideoResp ? "" : orderVideoResp.getProductName());
  258 + resp.setProductId(item.getProductId());
  259 + resp.setProductPicUrl(null == orderVideoResp ? "" : orderVideoResp.getProductPicUrl());
  260 + result.add(resp);
  261 + });
  262 +
  263 + return result;
  264 + }
  265 +
  266 + private Map<Integer,OrderVideoResp> getProductInfo(List<Integer> productIds) {
  267 + String product_id = StringUtils.join(productIds,",");
  268 + int type=7;
  269 + int limit = productIds == null ? 0 : productIds.size();
  270 + int page=1;
  271 +
  272 + //调用商品接口返回商品list
  273 + com.yohoufo.common.ApiResponse productApiResponse = serviceCaller.call("ufo.product.search.list",
  274 + type,null, product_id,null
  275 + ,null,null,null,null,null,null,null
  276 + ,limit,page,"");
  277 +
  278 + Map<Integer,OrderVideoResp> result = new HashMap<>();
  279 +
  280 + if(productApiResponse != null && productApiResponse.getData() != null){
  281 + JSONObject jo=(JSONObject)productApiResponse.getData();
  282 + JSONArray product_list = jo.getJSONArray("product_list");
  283 + if (null != product_list) {
  284 + OrderVideoResp resp;
  285 + for (int i = 0; i < product_list.size(); i++) {
  286 + JSONObject product = (JSONObject)product_list.get(i);
  287 + resp = new OrderVideoResp();
  288 + resp.setProductName(product.getString("product_name"));
  289 + resp.setProductPicUrl(product.getString("default_images"));
  290 + result.put(product.getInteger("id"), resp);
  291 + }
  292 + }
  293 + }
  294 +
  295 + return result;
  296 + }
223 } 297 }