|
|
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());
|
|
|
}
|
|
|
} |
...
|
...
|
|