From 732a8bee56808e7005c54fdedbf12c1d1b3223ae Mon Sep 17 00:00:00 2001 From: xyiege Date: Sat, 29 Oct 2022 20:43:43 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../szwh/controller/api/GoodsController.java | 6 ++-- .../cn/chjyj/szwh/service/GoodsService.java | 2 +- .../szwh/service/impl/GoodsServiceImpl.java | 28 ++++++++++++------- 3 files changed, 22 insertions(+), 14 deletions(-) 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 165ffb7..cb3f5a2 100644 --- a/src/main/java/cn/chjyj/szwh/controller/api/GoodsController.java +++ b/src/main/java/cn/chjyj/szwh/controller/api/GoodsController.java @@ -60,12 +60,12 @@ public class GoodsController extends BaseController { String appkey = request.getParameter("appkey"); String timestamp = request.getParameter("timestamp"); // - Map retmap =goodsService.getShoppingCar(userIsli); + List retlist =goodsService.getShoppingCar(userIsli); long end = System.currentTimeMillis(); long howUse = (end-start)/1000l; - jsonObject.put("code",200); + jsonObject.put("code","success"); jsonObject.put("msg","成功"); - jsonObject.put("data",retmap); + jsonObject.put("data",retlist); jsonObject.put("useTime",howUse); return jsonObject; } diff --git a/src/main/java/cn/chjyj/szwh/service/GoodsService.java b/src/main/java/cn/chjyj/szwh/service/GoodsService.java index 3c722ad..76a7e53 100644 --- a/src/main/java/cn/chjyj/szwh/service/GoodsService.java +++ b/src/main/java/cn/chjyj/szwh/service/GoodsService.java @@ -127,7 +127,7 @@ public interface GoodsService { * @param userIsli * @return */ - Map getShoppingCar(String userIsli); + List getShoppingCar(String userIsli); /** * del from use goods shop car 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 a6e7349..032dba6 100644 --- a/src/main/java/cn/chjyj/szwh/service/impl/GoodsServiceImpl.java +++ b/src/main/java/cn/chjyj/szwh/service/impl/GoodsServiceImpl.java @@ -533,6 +533,7 @@ public class GoodsServiceImpl implements GoodsService { @Override public List getTypeGoods(String type, String createtime, String goods_type) { + // 商品列表 List glist = new ArrayList<>(); String where = "";//查询条件 if ("1".equals(type)) { @@ -725,18 +726,20 @@ public class GoodsServiceImpl implements GoodsService { } @Override - public Map getShoppingCar(String userIsli) { - Map retmap = new HashMap<>(); + public List getShoppingCar(String userIsli) { + // wait for result + List retlist =new ArrayList(); + String shopRedisKey = "car_" + userIsli; + // get shopping car from redis Object shopCar = RedisUtil.get(shopRedisKey); JSONObject shopCarJson = JSONObject.parseObject(shopCar.toString()); JSONArray jsonArray = shopCarJson.getJSONArray("data"); - //JSONObject carjson =JSONObject.parseObject(shopCar.toString()); if (shopCar == null) { //null - return retmap; + return null; } - //fenpei + //分配比例 Map acrmap = new HashMap(); acrmap.put("is_deleted", 0); acrmap.put("status", 1); @@ -744,15 +747,18 @@ public class GoodsServiceImpl implements GoodsService { AccountRatioSetting accountRatioSetting = acrlist.get(0); AccountRatioDetail accountRatioDetail = accountRatioDetailMapper.getAccRatioDetailByIdRole(accountRatioSetting.getId(), 2); + //循环枚举 if (jsonArray.size() > 0) { //goods information - for (int x = 0; x < jsonArray.size(); x++) { + for (int x =0; x retmap = new HashMap<>(); JSONObject jsonObject = jsonArray.getJSONObject(x); String goodsIsli = jsonObject.getString("goods_isli"); - Goods goods = goodsMapper.getGoodsFuelByIsLi(goodsIsli); - // + //goods + Goods goods = goodsMapper.getGoodsByIsli(goodsIsli); + //goods detail GoodsDetail goodsDetail = goodsDetailMapper.getGoodsDetailBygid(goods.getGoodsDetailId()); - retmap.put("detial", goodsDetail); + retmap.put("detail", goodsDetail); // 计算服务费 Integer count = jsonObject.getInteger("use_years"); if (goodsDetail.getGoodsEntrust() == 1) { @@ -792,9 +798,11 @@ public class GoodsServiceImpl implements GoodsService { retmap.put("user", umap); // retmap.put("goods", goods); + // add retlist + retlist.add(retmap); } } - return retmap; + return retlist; } @Override