Authored by mali

鉴定服务

... ... @@ -31,4 +31,12 @@ public interface QiniuLiveRecordMapper {
// 包含状态为0的,因为有可能是新的鉴定视频链接
List<QiniuLiveRecord> selectByProductIdEx(@Param("productId")int productId);
/**
* 查询鉴定服务对应的鉴定视频
* @param stateIdx
* @param limit
* @return
*/
List<QiniuLiveRecord> selectByPage(@Param("orderType")Integer orderType, @Param("stateIdx")int stateIdx, @Param("limit")Integer limit);
}
... ...
... ... @@ -114,7 +114,7 @@
order_code, end_time, vedio_file_url, storage_id, status, video_url
from qiniu_live_record
where product_id = #{productId, jdbcType=INTEGER}
and show_flag = 1 and status = 1 order by id DESC limit 20
and show_flag = 1 and status = 1 and order_type = 0 order by id DESC limit 20
</select>
<select id="selectByProductIdEx" resultMap="BaseResultMap">
... ... @@ -122,6 +122,13 @@
order_code, end_time, vedio_file_url, storage_id, status, video_url
from qiniu_live_record
where product_id = #{productId, jdbcType=INTEGER}
and show_flag = 1 order by id DESC limit 20
and show_flag = 1 and order_type = 0 order by id DESC limit 20
</select>
<select id="selectByPage" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from qiniu_live_record
where show_flag = 1 and order_type = #{orderType, jdbcType=INTEGER} AND video_url != '' order by id DESC limit #{stateIdx, jdbcType=INTEGER}, #{limit, jdbcType=INTEGER}
</select>
</mapper>
\ No newline at end of file
... ...
... ... @@ -66,4 +66,24 @@ public class UfoLiveAvthumbController {
return new ApiResponse.ApiResponseBuilder().code(200).data(respList).message("查询成功").build();
}
/**
* 查询鉴定服务对应的视频列表
*
* http://java-yohoufo-fore.test3.ingress.dev.yohocorp.com/ufo-gateway/ufoLive/?method=ufo.order.videoList&page=1&limit=30
*
* @return
*/
@RequestMapping(params = "method=ufo.order.videoList")
@IgnoreSession
@IgnoreSignature
@Cachable(expire = 180)
public ApiResponse queryVideoList(@RequestParam(value = "page", required = false, defaultValue = "1") Integer page
, @RequestParam(value = "limit", required = false, defaultValue = "30") Integer limit){
logger.info("in ufo.order.videoList, page {}. limit {}", page, limit);
List<OrderVideoResp> respList = qiniuLiveRecordService.queryVideoList(page, limit);
return new ApiResponse.ApiResponseBuilder().code(200).data(respList).message("查询成功").build();
}
}
... ...
package com.yohoufo.order.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
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.req.OrderTypeEnum;
import com.yohobuy.ufo.model.order.resp.OrderVideoResp;
import com.yohoufo.common.caller.UfoServiceCaller;
import com.yohoufo.common.constant.OrderConfigConstant;
import com.yohoufo.common.utils.DateUtil;
import com.yohoufo.common.utils.QiniuLiveUrlUtil;
... ... @@ -47,6 +51,9 @@ public class QiniuLiveRecordService {
@Autowired
private SellerOrderMapper sellerOrderMapper;
@Autowired
private UfoServiceCaller serviceCaller;
public void updateStatusByPersistId(String persistId, Integer code) {
if (Integer.valueOf(0).equals(code)) {
qiniuLiveRecordMapper.updateStatusByPersistId(persistId, 1); // 更新直播记录状态为已转码成功
... ... @@ -220,4 +227,71 @@ public class QiniuLiveRecordService {
orderVideoResp.setInitFlag(Boolean.TRUE);
resps.add(orderVideoResp);
}
/**
* 查询鉴定服务对应的视频列表
*
* @return
*/
public List<OrderVideoResp> queryVideoList(Integer page, Integer limit) {
List<QiniuLiveRecord> qiNiuLiveRecords = qiniuLiveRecordMapper.selectByPage(OrderTypeEnum.ORDERTYPE_APPRAISEORDER.getCode(), (page - 1) * limit, limit);
if (CollectionUtils.isEmpty(qiNiuLiveRecords)) {
return Lists.newArrayList();
}
List<Integer> productIdList = qiNiuLiveRecords.stream().map(QiniuLiveRecord::getProductId).collect(Collectors.toList());
// 根据商品Id 查询商品名称和图片
Map<Integer, OrderVideoResp> productInfoMap = getProductInfo(productIdList);
LOG.info("queryVideoList method in productIdList is {}, productInfoMap.keySet is {}", productIdList, productInfoMap.keySet());
List<OrderVideoResp> result = Lists.newArrayList();
qiNiuLiveRecords.stream().forEach(item -> {
OrderVideoResp resp = new OrderVideoResp();
OrderVideoResp orderVideoResp = productInfoMap.get(item.getProductId());
resp.setVideoUrl(item.getVideoUrl());
resp.setProductName(null == orderVideoResp ? "" : orderVideoResp.getProductName());
resp.setProductId(item.getProductId());
resp.setProductPicUrl(null == orderVideoResp ? "" : orderVideoResp.getProductPicUrl());
result.add(resp);
});
return result;
}
private Map<Integer,OrderVideoResp> getProductInfo(List<Integer> productIds) {
String product_id = StringUtils.join(productIds,",");
int type=7;
int limit = productIds == null ? 0 : productIds.size();
int page=1;
//调用商品接口返回商品list
com.yohoufo.common.ApiResponse productApiResponse = serviceCaller.call("ufo.product.search.list",
type,null, product_id,null
,null,null,null,null,null,null,null
,limit,page,"");
Map<Integer,OrderVideoResp> result = new HashMap<>();
if(productApiResponse != null && productApiResponse.getData() != null){
JSONObject jo=(JSONObject)productApiResponse.getData();
JSONArray product_list = jo.getJSONArray("product_list");
if (null != product_list) {
OrderVideoResp resp;
for (int i = 0; i < product_list.size(); i++) {
JSONObject product = (JSONObject)product_list.get(i);
resp = new OrderVideoResp();
resp.setProductName(product.getString("product_name"));
resp.setProductPicUrl(product.getString("default_images"));
result.put(product.getInteger("id"), resp);
}
}
}
return result;
}
}
... ...