Browse Source

修正下单逻辑细节

master
xyiege 3 years ago
parent
commit
2c28da55ff
  1. 20
      src/main/java/cn/chjyj/szwh/service/impl/GoodsServiceImpl.java
  2. 3
      src/main/java/cn/chjyj/szwh/utils/SzCarUtils.java

20
src/main/java/cn/chjyj/szwh/service/impl/GoodsServiceImpl.java

@ -574,24 +574,28 @@ public class GoodsServiceImpl implements GoodsService {
@Override @Override
public Map<String, Object> addShopCar(String userIsli, String goodsIsli, Integer userYears) { public Map<String, Object> addShopCar(String userIsli, String goodsIsli, Integer userYears) {
Map<String, Object> retmap = new HashMap<>(); Map<String, Object> retmap = new HashMap<>();
User user = userMapper.getUserByIsli(userIsli); //User user = userMapper.getUserByIsli(userIsli);
// get current goods // get current goods
Goods goods = goodsMapper.getGoodsFuelByIsLi(goodsIsli); Goods goods = goodsMapper.getGoodsFuelByIsLi(goodsIsli);
if (goods == null) { if (goods == null) {
retmap.put("code", 400); retmap.put("code", 400);
retmap.put("msg", "没有该标的"); retmap.put("msg", "没有该标的");
return retmap;
} else { } else {
if (goods.getGoodsStatus() != 1) { if (goods.getGoodsStatus() != 1) {
retmap.put("code", 400); retmap.put("code", 400);
retmap.put("msg", "该标的现不在上架中"); retmap.put("msg", "该标的现不在上架中");
return retmap;
} }
if (goods.getContractStatus() != 1) { if (goods.getContractStatus() != 1) {
retmap.put("code", 400); retmap.put("code", 400);
retmap.put("msg", "标的未申请合约关联,不可购买"); retmap.put("msg", "标的未申请合约关联,不可购买");
return retmap;
} }
if (goods.getUserIslicode() == userIsli) { if (goods.getUserIslicode() == userIsli) {
retmap.put("code", 400); retmap.put("code", 400);
retmap.put("msg", "您是标的的授权方,不可添加"); retmap.put("msg", "您是标的的授权方,不可添加");
return retmap;
} }
} }
// //
@ -604,12 +608,19 @@ public class GoodsServiceImpl implements GoodsService {
if (orderDetailVo != null) { if (orderDetailVo != null) {
retmap.put("code", 400); retmap.put("code", 400);
retmap.put("msg", "该标的已有订单,添加购物车失败"); retmap.put("msg", "该标的已有订单,添加购物车失败");
return retmap;
} }
// goods detail // goods detail
GoodsDetail goodsDetail = goodsDetailMapper.getGoodsDetailBygid(goods.getGoodsDetailId()); GoodsDetail goodsDetail = goodsDetailMapper.getGoodsDetailBygid(goods.getGoodsDetailId());
if(goodsDetail==null){
retmap.put("code", 400);
retmap.put("msg", "该标的详情不存在,请检查标的编号");
return retmap;
}
if (goodsDetail.getStock() <= 0 && goodsDetail.getGoodsEntrust() == 1) { if (goodsDetail.getStock() <= 0 && goodsDetail.getGoodsEntrust() == 1) {
retmap.put("code", 400); retmap.put("code", 400);
retmap.put("msg", "该标的已有订单,添加购物车失败"); retmap.put("msg", "该标的已有订单,添加购物车失败");
return retmap;
} }
Date now = new Date(); Date now = new Date();
if (goodsDetail.getContractualPeriod() == 3) { if (goodsDetail.getContractualPeriod() == 3) {
@ -618,6 +629,7 @@ public class GoodsServiceImpl implements GoodsService {
) { ) {
retmap.put("code", 400); retmap.put("code", 400);
retmap.put("msg", "标的委托已结束"); retmap.put("msg", "标的委托已结束");
return retmap;
} }
} }
//shop car infomation //shop car infomation
@ -643,6 +655,9 @@ public class GoodsServiceImpl implements GoodsService {
retmap.put("code", 400); retmap.put("code", 400);
retmap.put("msg", "该标的已添加到购物车"); retmap.put("msg", "该标的已添加到购物车");
return retmap; return retmap;
}else{
cimap.put("goods_isli",goodsIsli);
cimap.put("use_years",userYears);
} }
} }
} }
@ -654,9 +669,6 @@ public class GoodsServiceImpl implements GoodsService {
} }
//购物车添加成功 //购物车添加成功
JSONObject retjson =SzCarUtils.addCart(shopRedisKey,userIsli,cimap); JSONObject retjson =SzCarUtils.addCart(shopRedisKey,userIsli,cimap);
// carjson.put("user_isli",userIsli);
// carjson.put("data",retjson);
// RedisUtil.set(shopRedisKey, carjson.toJSONString());
retmap.put("code", 200); retmap.put("code", 200);
retmap.put("msg", "成功"); retmap.put("msg", "成功");

3
src/main/java/cn/chjyj/szwh/utils/SzCarUtils.java

@ -28,8 +28,7 @@ public class SzCarUtils {
JSONArray jsonArray = shopCarJson.getJSONArray("data"); JSONArray jsonArray = shopCarJson.getJSONArray("data");
if (jsonArray != null) { if (jsonArray != null) {
for (int x = 0; x < jsonArray.size(); x++) { for (int x = 0; x < jsonArray.size(); x++) {
//carItem.add(jsonArray.getJSONObject(x)); carItem.add((JSONObject)jsonArray.get(x));
carItem.add(jsonArray.get(x));
} }
} }
} }

Loading…
Cancel
Save