| | |
| | | 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);
|
| | | }
|
| | |
|
| | | }
|
| | | 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 org.yeshi.utils.TimeUtil; |
| | | |
| | | |
| | | @Service |
| | | public class UserTLJBuyHistoryServiceImpl implements UserTLJBuyHistoryService { |
| | | @Resource |
| | | private UserTLJBuyHistoryDao userTLJBuyHistoryDao; |
| | | |
| | | @Override |
| | | public boolean canBuy(Long uid, String 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); |
| | | } |
| | | |
| | | } |