@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((getSeckillId() == null) ? 0 : getSeckillId().hashCode()); result = prime * result + ((getName() == null) ? 0 : getName().hashCode()); result = prime * result + ((getNumber() == null) ? 0 : getNumber().hashCode()); result = prime * result + ((getStartTime() == null) ? 0 : getStartTime().hashCode()); result = prime * result + ((getEndTime() == null) ? 0 : getEndTime().hashCode()); result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode()); result = prime * result + ((getGoodsId() == null) ? 0 : getGoodsId().hashCode()); result = prime * result + ((getPrice() == null) ? 0 : getPrice().hashCode()); result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode()); result = prime * result + ((getCreateUser() == null) ? 0 : getCreateUser().hashCode()); return result; } }
@Override public Exposer exportSeckillUrl(long seckillId) { //从redis中获取缓存秒杀信息 Seckill seckill = redisDao.getSeckill(seckillId); Date startTime = seckill.getStartTime(); Date endTime = seckill.getEndTime(); Date nowTime = new Date(); if (nowTime.getTime() < startTime.getTime() || nowTime.getTime() > endTime.getTime()) { return new Exposer(false, seckillId, nowTime.getTime(), startTime.getTime(), endTime.getTime()); } String md5 = MD5Util.getMD5(seckillId); return new Exposer(true, md5, seckillId); }
if (successKilled.getStatus() < 1) { Seckill seckill = extSeckillMapper.selectByPrimaryKey(seckillId); log.info("当前库存:{}", seckill.getNumber()); if (!SeckillStatusConstant.END.equals(seckill.getStatus()) && sendTopicTimes.getAndIncrement() == 0) { mqTask.sendSeckillSuccessTopic(seckillId, note); Seckill sendTopicResult = new Seckill(); sendTopicResult.setSeckillId(seckillId); sendTopicResult.setStatus(SeckillStatusConstant.END); extSeckillMapper.updateByPrimaryKeySelective(sendTopicResult); if (log.isDebugEnabled() && seckill.getNumber() <= 0) { log.debug("库存不足,无法继续秒杀!");
Goods goods = goodsDao.selectByPrimaryKey(seckill.getGoodsId()); String totalAmount = String.valueOf(seckill.getPrice()); String body = new StringBuffer("购买商品1件共").append(seckill.getPrice()) + "元"; GoodsDetail goods1 = GoodsDetail.newInstance(String.valueOf(seckill.getGoodsId()), goods.getName(), seckill.getPrice().intValue() * 100L, 1);
private String putSeckill(Seckill seckill) { Jedis jedis = jedisPool.getResource(); try { String key = "seckill:" + seckill.getSeckillId(); byte[] bytes = ProtostuffIOUtil.toByteArray(seckill, schema, LinkedBuffer.allocate(LinkedBuffer.DEFAULT_BUFFER_SIZE)); int timeout = 60; return jedis.setex(key.getBytes(), timeout, bytes); } finally { jedis.close(); } }
@Override public SeckillInfo getById(long seckillId) { Seckill seckill = extSeckillMapper.selectByPrimaryKey(seckillId); SeckillInfo seckillInfo = new SeckillInfo(); BeanUtils.copyProperties(seckill, seckillInfo); Goods goods = goodsMapper.selectByPrimaryKey(seckill.getGoodsId()); seckillInfo.setGoodsName(goods.getName()); return seckillInfo; }
synchronized (this) { Seckill seckill = extSeckillMapper.selectByPrimaryKey(seckillId); if (seckill.getNumber() > 0) { extSeckillMapper.reduceNumber(seckillId, new Date()); SuccessKilled record = new SuccessKilled();
@Override public boolean equals(Object that) { if (this == that) { return true; } if (that == null) { return false; } if (getClass() != that.getClass()) { return false; } Seckill other = (Seckill) that; return (this.getSeckillId() == null ? other.getSeckillId() == null : this.getSeckillId().equals(other.getSeckillId())) && (this.getName() == null ? other.getName() == null : this.getName().equals(other.getName())) && (this.getNumber() == null ? other.getNumber() == null : this.getNumber().equals(other.getNumber())) && (this.getStartTime() == null ? other.getStartTime() == null : this.getStartTime().equals(other.getStartTime())) && (this.getEndTime() == null ? other.getEndTime() == null : this.getEndTime().equals(other.getEndTime())) && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime())) && (this.getGoodsId() == null ? other.getGoodsId() == null : this.getGoodsId().equals(other.getGoodsId())) && (this.getPrice() == null ? other.getPrice() == null : this.getPrice().equals(other.getPrice())) && (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus())) && (this.getCreateUser() == null ? other.getCreateUser() == null : this.getCreateUser().equals(other.getCreateUser())); }