|
|
|
@ -1,9 +1,6 @@ |
|
|
|
package cn.chjyj.szwh.service.impl; |
|
|
|
|
|
|
|
import cn.chjyj.szwh.bean.Goods; |
|
|
|
import cn.chjyj.szwh.bean.GoodsDetail; |
|
|
|
import cn.chjyj.szwh.bean.GoodsSource; |
|
|
|
import cn.chjyj.szwh.bean.OperationLog; |
|
|
|
import cn.chjyj.szwh.bean.*; |
|
|
|
import cn.chjyj.szwh.constant.ChConstant; |
|
|
|
import cn.chjyj.szwh.exception.ChException; |
|
|
|
import cn.chjyj.szwh.mapper.*; |
|
|
|
@ -11,6 +8,7 @@ import cn.chjyj.szwh.service.GoodsService; |
|
|
|
import cn.chjyj.szwh.utils.*; |
|
|
|
import cn.chjyj.szwh.vo.GoodsDetailVo; |
|
|
|
import cn.chjyj.szwh.vo.GoodsListVo; |
|
|
|
import cn.chjyj.szwh.vo.OrderDetailVo; |
|
|
|
import com.alibaba.fastjson2.JSONArray; |
|
|
|
import com.alibaba.fastjson2.JSONObject; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
@ -41,6 +39,10 @@ public class GoodsServiceImpl implements GoodsService { |
|
|
|
// 节假日mapper
|
|
|
|
@Autowired |
|
|
|
private FestivalsMapper festivalsMapper; |
|
|
|
@Autowired |
|
|
|
private UserMapper userMapper; |
|
|
|
@Autowired |
|
|
|
private OrderMapper orderMapper; |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<Goods> getGoodsList(int page) { |
|
|
|
@ -611,6 +613,71 @@ public class GoodsServiceImpl implements GoodsService { |
|
|
|
return goodsMapper.updateGoods(gmap,gid); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Map<String, Object> addShopCar(String userIsli, String goodsIsli, Integer userYears) { |
|
|
|
Map<String,Object> retmap =new HashMap<>(); |
|
|
|
User user = userMapper.getUserByIsli(userIsli); |
|
|
|
// get current goods
|
|
|
|
Goods goods = goodsMapper.getGoodsFuelByIsLi(goodsIsli); |
|
|
|
if(goods==null){ |
|
|
|
retmap.put("code",400); |
|
|
|
retmap.put("msg","没有该标的"); |
|
|
|
} |
|
|
|
if(goods.getGoodsStatus()!=1){ |
|
|
|
retmap.put("code",400); |
|
|
|
retmap.put("msg","该标的现不在上架中"); |
|
|
|
} |
|
|
|
if(goods.getContractStatus()!=1){ |
|
|
|
retmap.put("code",400); |
|
|
|
retmap.put("msg","标的未申请合约关联,不可购买"); |
|
|
|
} |
|
|
|
if(goods.getUserIslicode() == userIsli){ |
|
|
|
retmap.put("code",400); |
|
|
|
retmap.put("msg","您是标的的授权方,不可添加"); |
|
|
|
} |
|
|
|
//
|
|
|
|
Map ordmap = new HashMap(); |
|
|
|
ordmap.put("ostatus_not",5); |
|
|
|
OrderDetailVo orderDetailVo= orderMapper.getOrderDetailVOByMap(ordmap); |
|
|
|
if(orderDetailVo!=null){ |
|
|
|
retmap.put("code",400); |
|
|
|
retmap.put("msg","该标的已有订单,添加购物车失败"); |
|
|
|
} |
|
|
|
// goods detail
|
|
|
|
GoodsDetail goodsDetail = goodsDetailMapper.getGoodsDetailBygid(goods.getGoodsDetailId()); |
|
|
|
if(goodsDetail.getStock()<=0 && goodsDetail.getGoodsEntrust() ==1){ |
|
|
|
retmap.put("code",400); |
|
|
|
retmap.put("msg","该标的已有订单,添加购物车失败"); |
|
|
|
} |
|
|
|
Date now=new Date(); |
|
|
|
if(goodsDetail.getContractualPeriod()==3){ |
|
|
|
if(goods.getContractualStartTime().compareTo(now)>0 |
|
|
|
|| goods.getContractualtimeEndTime().compareTo(now)<0 |
|
|
|
){ |
|
|
|
retmap.put("code",400); |
|
|
|
retmap.put("msg","标的委托已结束"); |
|
|
|
} |
|
|
|
} |
|
|
|
//shop car infomation
|
|
|
|
String shopRedisKey="car_"+userIsli; |
|
|
|
JSONObject carjson =new JSONObject(); |
|
|
|
//object
|
|
|
|
Object shopCar = RedisUtil.get(shopRedisKey); |
|
|
|
if(shopCar!=null){ |
|
|
|
carjson =JSONObject.parseObject(shopCar.toString()); |
|
|
|
String tmpGoodsIsli= carjson.getString("goods_islicode"); |
|
|
|
if(goodsIsli.equals(tmpGoodsIsli)){ |
|
|
|
retmap.put("code",400); |
|
|
|
retmap.put("msg","该标的已添加到购物车"); |
|
|
|
} |
|
|
|
}else{ |
|
|
|
carjson.put("goods_islicode",goodsIsli); |
|
|
|
carjson.put("use_years",userYears); |
|
|
|
RedisUtil.set(shopRedisKey,carjson); |
|
|
|
} |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* query rank list |
|
|
|
* |
|
|
|
|