diff --git a/src/main/java/cn/chjyj/szwh/controller/api/GoodsController.java b/src/main/java/cn/chjyj/szwh/controller/api/GoodsController.java index e6ca599..d38023b 100644 --- a/src/main/java/cn/chjyj/szwh/controller/api/GoodsController.java +++ b/src/main/java/cn/chjyj/szwh/controller/api/GoodsController.java @@ -1,13 +1,8 @@ package cn.chjyj.szwh.controller.api; -import cn.chjyj.szwh.annotation.PassToken; import cn.chjyj.szwh.bean.Goods; import cn.chjyj.szwh.controller.BaseController; import cn.chjyj.szwh.service.GoodsService; -import cn.chjyj.szwh.utils.AjaxResult; -import cn.chjyj.szwh.utils.SzwhApiUtils; -import com.alibaba.fastjson2.JSON; -import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONObject; import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; @@ -39,9 +34,9 @@ public class GoodsController extends BaseController { @RequestMapping(value = "/addShoppingCar") public JSONObject addShoppingCar(HttpServletRequest request){ long start=System.currentTimeMillis(); - String userIsli = request.getParameter("user_isli"); - String goodsIsli = request.getParameter("goods_isli"); - String userYears= request.getParameter("user_years"); + String userIsli = request.getParameter("user_isli").trim(); + String goodsIsli = request.getParameter("goods_isli").trim(); + String userYears= request.getParameter("use_years").trim(); Integer uyears = StringUtils.isEmpty(userYears)?1:Integer.valueOf(userYears); // do add Map retmap =goodsService.addShopCar(userIsli,goodsIsli,uyears); @@ -50,7 +45,7 @@ public class GoodsController extends BaseController { // get msg jsonObject.put("code",retmap.get("code")); jsonObject.put("msg",retmap.get("msg")); - jsonObject.put("data",retmap); +// jsonObject.put("data",retmap); jsonObject.put("useTime",howUse); return jsonObject; } diff --git a/src/main/java/cn/chjyj/szwh/service/impl/GoodsServiceImpl.java b/src/main/java/cn/chjyj/szwh/service/impl/GoodsServiceImpl.java index a256e37..dcfa9a2 100644 --- a/src/main/java/cn/chjyj/szwh/service/impl/GoodsServiceImpl.java +++ b/src/main/java/cn/chjyj/szwh/service/impl/GoodsServiceImpl.java @@ -622,21 +622,25 @@ public class GoodsServiceImpl implements GoodsService { 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","您是标的的授权方,不可添加"); + }else { + 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("o.buy_islicode",userIsli); + ordmap.put("od.goods_islicode",goodsIsli); + ordmap.put("od.is_deleted",0); ordmap.put("ostatus_not",5); OrderDetailVo orderDetailVo= orderMapper.getOrderDetailVOByMap(ordmap); if(orderDetailVo!=null){ @@ -673,9 +677,9 @@ public class GoodsServiceImpl implements GoodsService { }else{ carjson.put("goods_islicode",goodsIsli); carjson.put("use_years",userYears); - RedisUtil.set(shopRedisKey,carjson); + RedisUtil.set(shopRedisKey,carjson.toJSONString()); } - return null; + return retmap; } /** diff --git a/src/main/resources/mapper/szwh/OrderMapper.xml b/src/main/resources/mapper/szwh/OrderMapper.xml index 253cca4..434ab3b 100644 --- a/src/main/resources/mapper/szwh/OrderMapper.xml +++ b/src/main/resources/mapper/szwh/OrderMapper.xml @@ -118,9 +118,8 @@ ${k} = #{v} - o.status ]]> #{v}; + o.status ]]> #{v} - diff --git a/src/main/resources/mapper/szwh/UserMapper.xml b/src/main/resources/mapper/szwh/UserMapper.xml index 2d928a7..ef2b5c1 100644 --- a/src/main/resources/mapper/szwh/UserMapper.xml +++ b/src/main/resources/mapper/szwh/UserMapper.xml @@ -22,18 +22,9 @@ )SELECT * FROM mu ORDER BY id DESC; - - - - - - - - -