Authored by mali

转码补充订单的商品信息

package com.yoho.order.model;
import com.alibaba.fastjson.JSONObject;
public class QiniuLiveRecord {
private Integer id;
... ... @@ -160,4 +162,9 @@ public class QiniuLiveRecord {
public void setProductId(Integer productId) {
this.productId = productId;
}
@Override
public String toString() {
return JSONObject.toJSONString(this);
}
}
\ No newline at end of file
... ...
package com.yoho.ufo.order.service.event;
import com.google.common.collect.Lists;
import com.yoho.order.dal.QiniuLiveRecordMapper;
import com.yoho.order.dal.SellerOrderGoodsMapper;
import com.yoho.order.model.QiniuLiveRecord;
import com.yoho.order.model.SellerOrderGoods;
import com.yoho.ufo.util.DateUtil;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* Created by li.ma on 2018/12/18.
*/
@Component
public class LiveEventsListener implements ApplicationListener<QiniuLiveRecordEvent> {
private static final Logger LOGGER = LoggerFactory.getLogger(LiveEventsListener.class);
@Autowired
private SellerOrderGoodsMapper sellerOrderGoodsMapper;
@Autowired
private QiniuLiveRecordMapper qiniuLiveRecordMapper;
/**
* seller_order_code = #{sellerOrderCode,jdbcType=BIGINT},
update_time = #{updateTime,jdbcType=INTEGER},
storage_id = #{storageId,jdbcType=INTEGER},
goods_id = #{goodsId,jdbcType=INTEGER},
product_id = #{productId,jdbcType=INTEGER}
* @param event
*/
@Override
public void onApplicationEvent(QiniuLiveRecordEvent event) {
LOGGER.info("LiveEventsListener.onApplicationEvent method in. param is {}", event);
QiniuLiveRecord record = event.getRecord();
List<SellerOrderGoods> sellerOrderGoodses = sellerOrderGoodsMapper.selectByIds(Lists.newArrayList(record.getSkup()));
if (CollectionUtils.isEmpty(sellerOrderGoodses)) {
return;
}
SellerOrderGoods sellerOrderGoods = sellerOrderGoodses.get(0);
record.setSellerOrderCode(0L);
record.setUpdateTime(DateUtil.getCurrentTimeSeconds());
record.setStorageId(sellerOrderGoods.getStorageId());
record.setGoodsId(0);
record.setProductId(sellerOrderGoods.getProductId());
qiniuLiveRecordMapper.updateProductBySkup(record);
LOGGER.info("LiveEventsListener.onApplicationEvent method out. skup is {}", event.getRecord().getSkup());
}
}
... ...
package com.yoho.ufo.order.service.event;
import com.alibaba.fastjson.JSONObject;
import com.yoho.order.model.QiniuLiveRecord;
import org.springframework.context.ApplicationEvent;
/**
* Created by li.ma on 2018/12/18.
*/
public class QiniuLiveRecordEvent extends ApplicationEvent {
private QiniuLiveRecord record;
/**
* Create a new ApplicationEvent.
*
* @param source the object on which the event initially occurred (never {@code null})
*/
public QiniuLiveRecordEvent(QiniuLiveRecord record) {
super(record);
this.record = record;
}
public QiniuLiveRecord getRecord() {
return record;
}
public void setRecord(QiniuLiveRecord record) {
this.record = record;
}
@Override
public String toString() {
return JSONObject.toJSONString(this);
}
}
... ...
... ... @@ -15,6 +15,8 @@ import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Service;
import java.util.List;
... ... @@ -23,7 +25,7 @@ import java.util.List;
* Created by li.ma on 2018/12/13.
*/
@Service
public class UfoLiveService {
public class UfoLiveService implements ApplicationContextAware {
private static final Logger LOGGER = LoggerFactory.getLogger(UfoLiveService.class);
@Autowired
... ... @@ -32,6 +34,12 @@ public class UfoLiveService {
@Autowired
private QiniuLiveRecordMapper qiniuLiveRecordMapper;
private ApplicationContext context;
public void setApplicationContext(ApplicationContext applicationContext) {
this.context = applicationContext;
}
@Database(ForceMaster = true)
public void generateMp4(QNliveReq req) throws PlatformException {
LOGGER.info("method UfoLiveService.generateMp4 in, QNliveReq is {}", req);
... ... @@ -66,6 +74,8 @@ public class UfoLiveService {
record.setStatus(0);
record.setVedioFileUrl(fileName + ".mp4");
qiniuLiveRecordMapper.insert(record);
context.publishEvent(record); // 异步补充记录的卖家订单号,商品信息
}
public String queryMp4Vedio(QNliveReq req) throws PlatformException {
... ...