package com.yeshi.fanli.job.goods;
|
|
import java.util.List;
|
|
import javax.annotation.Resource;
|
|
import org.apache.commons.beanutils.PropertyUtils;
|
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.stereotype.Component;
|
|
import com.yeshi.fanli.dto.taobao.haodanku.HDKGoodsListResultDTO;
|
import com.yeshi.fanli.entity.goods.PullNewGoods;
|
import com.yeshi.fanli.entity.taobao.haodanku.HDKGoodsDetail;
|
import com.yeshi.fanli.service.inter.goods.PullNewGoodsService;
|
import com.yeshi.fanli.util.Constant;
|
import com.yeshi.fanli.util.taobao.HaoDanKuApiUtil;
|
|
@Component
|
public class PullNewGoodsJob {
|
|
@Resource
|
private PullNewGoodsService pullNewGoodsService;
|
|
/**
|
* 拉新商品
|
*/
|
@Scheduled(cron = "0 30 1 * * ? ")
|
private void addPullNewGoods() {
|
if (!Constant.IS_TASK) {
|
return;
|
}
|
|
Integer array[] = {1,2,3,4,5,6,7,8,9,10,11,12,15};
|
for (Integer catId: array) {
|
Integer minId = 1;
|
while (minId != null) {
|
HDKGoodsListResultDTO dto = HaoDanKuApiUtil.getInstance().getHighitems(minId, 100, catId);
|
if (dto == null || dto.getMinId() == null) {
|
break;
|
}
|
|
minId = dto.getMinId();
|
List<HDKGoodsDetail> goodsList = dto.getGoodsList();
|
if (goodsList == null || goodsList.size() == 0) {
|
break;
|
}
|
|
for (HDKGoodsDetail goods : goodsList) {
|
// 佣金比例大于50%
|
if (goods.getTkrates() == null || goods.getTkrates() < 50)
|
continue;
|
// 是否存在券
|
if (goods.getCouponmoney() == null || goods.getCouponmoney() <= 0)
|
continue;
|
// 商品券后价大于9.9元
|
if (goods.getItemendprice() == null || goods.getItemendprice() <= 9.9)
|
continue;
|
|
PullNewGoods pullNewGoods = new PullNewGoods();
|
try {
|
PropertyUtils.copyProperties(pullNewGoods, goods);
|
} catch (Exception e) {
|
e.printStackTrace();
|
continue;
|
}
|
pullNewGoodsService.saveGoods(pullNewGoods);
|
}
|
}
|
}
|
|
}
|
|
}
|