admin
2019-07-09 531d93708df8017e59830f15b41f3cc42d6126e6
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
package com.yeshi.fanli.service.impl.taobao;
 
import java.util.Date;
import java.util.List;
 
import javax.annotation.Resource;
 
import org.springframework.stereotype.Service;
 
import com.yeshi.fanli.dao.taobao.UserTLJBuyHistoryDao;
import com.yeshi.fanli.entity.taobao.UserTLJBuyHistory;
import com.yeshi.fanli.service.inter.taobao.UserTLJBuyHistoryService;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.TimeUtil;
 
@Service
public class UserTLJBuyHistoryServiceImpl implements UserTLJBuyHistoryService {
    @Resource
    private UserTLJBuyHistoryDao userTLJBuyHistoryDao;
 
    @Override
    public boolean canBuy(Long uid, Long auctionId) {
        if (uid == null || auctionId == null)
            return false;
        String day = TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd");
        List<UserTLJBuyHistory> list = userTLJBuyHistoryDao.listByDayAndUidAndAuctionId(uid, auctionId, day);
        if (list == null || list.size() < 3)
            return true;
        return false;
    }
 
    @Override
    public void addHistory(UserTLJBuyHistory history) throws Exception {
        if (history == null || history.getAuctionId() == null || history.getUid() == null)
            throw new Exception("信息不完整");
        if (history.getCreateTime() == null)
            history.setCreateTime(new Date());
        String day = TimeUtil.getGernalTime(history.getCreateTime().getTime(), "yyyy-MM-dd");
        history.setDay(day);
        history.setId(
                StringUtil.Md5(history.getAuctionId() + "-" + history.getUid() + "-" + System.currentTimeMillis()));
        userTLJBuyHistoryDao.save(history);
    }
 
}