yujian
2020-06-29 ec60e757d358636dcac1589c44a66f3e276fe58c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package com.yeshi.fanli.service.impl.goods;
 
import java.util.List;
 
import javax.annotation.Resource;
 
import org.apache.commons.beanutils.PropertyUtils;
import org.springframework.stereotype.Service;
 
import com.yeshi.fanli.dao.goods.PullNewGoodsDao;
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.taobao.HaoDanKuApiUtil;
 
@Service
public class PullNewGoodsServiceImpl implements PullNewGoodsService {
    
    @Resource
    private PullNewGoodsDao pullNewGoodsDao;
    
    @Override
    public void saveGoods(PullNewGoods pullNewGoods) {
        if (pullNewGoods == null) {
            return;
        }
        pullNewGoodsDao.save(pullNewGoods);
    }
    
    @Override
    public List<PullNewGoods> listQuery(int start, int count) {
        return pullNewGoodsDao.listQuery(start, count);
    }
 
    @Override
    public long countQuery() {
        return pullNewGoodsDao.countQuery();
    }
    
    
    @Override
    public void updateGoods(HDKGoodsDetail goods) {
        if (goods == null)
            return;
        
        List<PullNewGoods> list = pullNewGoodsDao.getByItemid(goods.getItemid());
        if (list == null || list.size() == 0)
            return;
        
        // 佣金比例大于50%
        if (goods.getTkrates() == null || goods.getTkrates() < 50)
            return;
        // 是否存在券
        if (goods.getCouponmoney() == null || goods.getCouponmoney() <= 0)
            return;
        // 商品券后价大于9.9元
        if (goods.getItemendprice() == null || goods.getItemendprice() <= 9.9)
            return;
        
        PullNewGoods pullNewGoods = new PullNewGoods();
        try {
            PropertyUtils.copyProperties(pullNewGoods, goods);
        } catch (Exception e) {
            e.printStackTrace();
            return;
        }
        pullNewGoodsDao.save(pullNewGoods);
    }
    
    
    @Override
    public void deleteGoods(List<Long> list) {
        if (list == null || list.size() == 0)
            return;
        
        for (Long itemid: list) {
            pullNewGoodsDao.deleteByItemid(itemid);
        }
    }
    
}