yujian
2019-07-11 f7fc1e040ca7533b0bece2a02eb72dd3645ed4d0
Merge remote-tracking branch 'origin/master'

Conflicts:
fanli/src/main/java/com/yeshi/fanli/dao/taobao/UserTLJBuyHistoryDao.java
fanli/src/main/java/com/yeshi/fanli/entity/taobao/UserTLJBuyHistory.java
fanli/src/main/java/com/yeshi/fanli/service/impl/taobao/UserTLJBuyHistoryServiceImpl.java
3个文件已添加
167 ■■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/dao/taobao/UserTLJBuyHistoryDao.java 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/taobao/UserTLJBuyHistory.java 98 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/taobao/UserTLJBuyHistoryServiceImpl.java 46 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/taobao/UserTLJBuyHistoryDao.java
New file
@@ -0,0 +1,23 @@
package com.yeshi.fanli.dao.taobao;
import java.util.List;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Repository;
import com.yeshi.fanli.dao.MongodbBaseDao;
import com.yeshi.fanli.entity.taobao.UserTLJBuyHistory;
@Repository
public class UserTLJBuyHistoryDao extends MongodbBaseDao<UserTLJBuyHistory> {
    public List<UserTLJBuyHistory> listByDayAndUidAndAuctionId(Long uid, Long auctionId, String day) {
        Query query = new Query();
        query.addCriteria(Criteria.where("uid").is(uid).andOperator(Criteria.where("auctionId").is(auctionId),
                Criteria.where("day").is(day)));
        return mongoTemplate.find(query, UserTLJBuyHistory.class);
    }
}
fanli/src/main/java/com/yeshi/fanli/entity/taobao/UserTLJBuyHistory.java
New file
@@ -0,0 +1,98 @@
package com.yeshi.fanli.entity.taobao;
import java.util.Date;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;
/**
 * 淘礼金自购领取记录
 *
 * @author Administrator
 *
 *
 */
@Document(collection = "userTLJBuyHistory")
public class UserTLJBuyHistory {
    @Id
    @Field
    private String id;
    @Field
    @Indexed
    private Long uid;
    @Field
    @Indexed
    private Long auctionId;
    @Field
    @Indexed
    private String day;// 如:2019-01-01
    @Field
    private Date createTime;// 创建时间
    @Field
    private String rightsId;
    public String getRightsId() {
        return rightsId;
    }
    public void setRightsId(String rightsId) {
        this.rightsId = rightsId;
    }
    public UserTLJBuyHistory(String id, Long uid, Long auctionId, String day, String rightsId, Date createTime) {
        this.id = id;
        this.uid = uid;
        this.auctionId = auctionId;
        this.day = day;
        this.createTime = createTime;
        this.rightsId = rightsId;
    }
    public UserTLJBuyHistory() {
    }
    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    public Long getUid() {
        return uid;
    }
    public void setUid(Long uid) {
        this.uid = uid;
    }
    public Long getAuctionId() {
        return auctionId;
    }
    public void setAuctionId(Long auctionId) {
        this.auctionId = auctionId;
    }
    public String getDay() {
        return day;
    }
    public void setDay(String day) {
        this.day = day;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/taobao/UserTLJBuyHistoryServiceImpl.java
New file
@@ -0,0 +1,46 @@
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);
    }
}