Browse Source

代码更新

master
xyiege 4 years ago
parent
commit
2f0f251861
  1. 21
      src/main/java/cn/chjyj/szwh/bean/Goods.java
  2. 24
      src/main/java/cn/chjyj/szwh/service/impl/ShopCarServiceImpl.java

21
src/main/java/cn/chjyj/szwh/bean/Goods.java

@ -2,6 +2,7 @@ package cn.chjyj.szwh.bean;
import java.math.BigInteger;
import java.sql.Timestamp;
import java.util.Date;
/**
* 交易商品信息
@ -19,9 +20,9 @@ public class Goods {
private BigInteger clickCount;//点击量
private Integer isRecommend;//是否推荐;0:否;1:是
private Integer recommendSort;//推荐排序
private Timestamp createTime; //创建时间
private Timestamp updateTime;//修改时间
private Timestamp cancelTime;//撤销时间
private Date createTime; //创建时间
private Date updateTime;//修改时间
private Date cancelTime;//撤销时间
/**
* 商品状态开关
*/
@ -31,8 +32,8 @@ public class Goods {
private Integer applyOut;//是否申请下架;0:否;1:是
private Integer isDeleted;//删除状态;0:未删除;1:已删除
private Integer contractStatus;//是否申请合约关联;0:失败;1:成功
private Timestamp contractualStartTime;//委托开始时间
private Timestamp contractualtimeEndTime;//委托结束时间
private Date contractualStartTime;//委托开始时间
private Date contractualtimeEndTime;//委托结束时间
public Integer getId() {
return id;
@ -122,7 +123,7 @@ public class Goods {
this.recommendSort = recommendSort;
}
public Timestamp getCreateTime() {
public Date getCreateTime() {
return createTime;
}
@ -130,7 +131,7 @@ public class Goods {
this.createTime = createTime;
}
public Timestamp getUpdateTime() {
public Date getUpdateTime() {
return updateTime;
}
@ -138,7 +139,7 @@ public class Goods {
this.updateTime = updateTime;
}
public Timestamp getCancelTime() {
public Date getCancelTime() {
return cancelTime;
}
@ -194,7 +195,7 @@ public class Goods {
this.contractStatus = contractStatus;
}
public Timestamp getContractualStartTime() {
public Date getContractualStartTime() {
return contractualStartTime;
}
@ -202,7 +203,7 @@ public class Goods {
this.contractualStartTime = contractualStartTime;
}
public Timestamp getContractualtimeEndTime() {
public Date getContractualtimeEndTime() {
return contractualtimeEndTime;
}

24
src/main/java/cn/chjyj/szwh/service/impl/ShopCarServiceImpl.java

@ -1,20 +1,27 @@
package cn.chjyj.szwh.service.impl;
import cn.chjyj.szwh.bean.Goods;
import cn.chjyj.szwh.bean.GoodsDetail;
import cn.chjyj.szwh.bean.User;
import cn.chjyj.szwh.exception.ChException;
import cn.chjyj.szwh.mapper.GoodsDetailMapper;
import cn.chjyj.szwh.mapper.GoodsMapper;
import cn.chjyj.szwh.mapper.UserMapper;
import cn.chjyj.szwh.service.ShopCarService;
import cn.chjyj.szwh.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
@Service
public class ShopCarServiceImpl implements ShopCarService {
@Autowired
private UserMapper userMapper;
@Autowired
private GoodsMapper goodsMapper;
@Autowired
private GoodsDetailMapper goodsDetailMapper;
/**
* 添加到购物车
@ -48,7 +55,24 @@ public class ShopCarServiceImpl implements ShopCarService {
return 24;
}
// 检查订单是否存在
long curtimestamp= System.currentTimeMillis()/1000l;
// 检查商品库存
GoodsDetail goodsDetail = goodsDetailMapper.getGoodsDetailBygid(goods.getGoodsDetailsId());
if (goodsDetail!=null) {
if(goodsDetail.getStock()<0 && goodsDetail.getGoodsEntrust()==1){
// 标的库存为0,不可添加
return 25;
}
if(goodsDetail.getContractualPeriod()==3){
long sttime= DateUtils.dateToStamp(goods.getContractualStartTime().toString());//委托开始时间戳
long edtime= DateUtils.dateToStamp(goods.getContractualtimeEndTime().toString());//委托结束时间戳
if(sttime>curtimestamp && edtime<curtimestamp){
//标的委托已结束
return 26;
}
}
}
}
return 0;

Loading…
Cancel
Save