Authored by mali

详情页支持视频

... ... @@ -45,6 +45,7 @@ public class DateUtil {
public final static String YYYY_MM_DD_DOT="yyyy.MM.dd";
public static final String yyyyMM = "yyyyMM";
public static final String MM_dd_yyyy_HH_mm_ssEx = "yyyy.MM.dd HH:mm";
private static final int[] dayArray =
new int[]{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
... ... @@ -76,6 +77,16 @@ public class DateUtil {
return sdf.format(c.getTime());
}
public static String getDateFormatEx(Integer time, String pattern)
{
if (time == null) {
return "";
}
SimpleDateFormat sdf=new SimpleDateFormat(pattern);
Calendar c=Calendar.getInstance();
c.setTimeInMillis((time.longValue()*1000));
return sdf.format(c.getTime());
}
/**
* 判断当前时间是否在 开始日期跟结束日期之间
... ...
... ... @@ -18,4 +18,5 @@ public interface QiniuLiveRecordMapper {
List<QiniuLiveRecord> selectByOrderCodes(@Param("orderCodes") List<Long> orderCodes);
List<QiniuLiveRecord> selectByProductId(@Param("productId")int productId);
}
... ...
... ... @@ -47,4 +47,12 @@
set status = #{status,jdbcType=INTEGER}
where persist_id = #{persistId,jdbcType=VARCHAR}
</update>
<select id="selectByProductId" resultMap="BaseResultMap">
select
order_code, end_time, vedio_file_url, storage_id
from qiniu_live_record
where productId = #{product_id, jdbcType=INTEGER}
and show_flag = 1 and status = 1 order by id DESC
</select>
</mapper>
\ No newline at end of file
... ...
package com.yohoufo.order.controller;
import com.yohobuy.ufo.model.order.common.TabType;
import com.yohobuy.ufo.model.order.resp.OrderVideoResp;
import com.yohobuy.ufo.model.order.vo.AddressInfo;
import com.yohoufo.common.ApiResponse;
import com.yohoufo.common.annotation.IgnoreSession;
import com.yohoufo.common.annotation.IgnoreSignature;
import com.yohoufo.order.model.request.UfoLiveNotifyResp;
import com.yohoufo.order.service.impl.QiniuLiveRecordService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
/**
* Created by li.ma on 2018/12/11.
... ... @@ -44,4 +48,18 @@ public class UfoLiveAvthumbController {
logger.info("[{}] method notifyAvthumb Notify out", req.getId());
response.getWriter().print("success");
}
/**
* 查询订单商品对应的订单鉴定视频
*
* @return
*/
@RequestMapping(params = "method=ufo.order.videos")
public ApiResponse buyerModifyAddress(@RequestParam("product_id") int productId){
logger.info("in ufo.order.videos, product_id {}.", productId);
List<OrderVideoResp> respList = qiniuLiveRecordService.queryOrderVideos(productId);
return new ApiResponse.ApiResponseBuilder().code(200).data(respList).message("查询成功").build();
}
}
... ...
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;
}
}
... ...
... ... @@ -3,3 +3,9 @@ ufo.product.defaultAuthHeadIcon=http://head.static.yhbimg.com/yhb-head/2018/12/2
#UFO用户的默认头像
ufo.product.defaultUserHeadIcon=http://head.static.yhbimg.com/yhb-head/2018/12/28/14/0160773bb87685aade796ea4f94e0587cf.png?imageView2/{mode}/w/{width}/h/{height}
#UFO propaganda video info
ufo.order.initVideo = http://flv01.static.yhbimg.com/ufo/live/mp4/9827059662848_1545892263.mp4
ufo.order.initVideoPic = http://img11.static.yhbimg.com/goodsimg/2018/12/28/17/01d30dbfc038ffffc2fc9506dcf9da164f.jpg
ufo.order.initVideoDesc = \u5ba3\u4f20\u89c6\u9891
ufo.order.initVideoTime = 1546272000
ufo.order.realDesc = \u9274\u5b9a\u7ed3\u679c\uff1a\u771f
... ...