From fdc172d33bf4d29b43d18a64992042d2b86fcfff Mon Sep 17 00:00:00 2001 From: xyiege Date: Sat, 29 Oct 2022 15:39:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E5=93=81=E8=B4=AD=E7=89=A9=E8=BD=A6?= =?UTF-8?q?=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../szwh/controller/api/GoodsController.java | 17 +++ .../cn/chjyj/szwh/service/GoodsService.java | 7 ++ .../szwh/service/impl/GoodsServiceImpl.java | 107 +++++++++++++++++- 3 files changed, 126 insertions(+), 5 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 d38023b..308d98a 100644 --- a/src/main/java/cn/chjyj/szwh/controller/api/GoodsController.java +++ b/src/main/java/cn/chjyj/szwh/controller/api/GoodsController.java @@ -4,6 +4,7 @@ import cn.chjyj.szwh.bean.Goods; import cn.chjyj.szwh.controller.BaseController; import cn.chjyj.szwh.service.GoodsService; import com.alibaba.fastjson2.JSONObject; +import javafx.beans.binding.ObjectBinding; import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -50,6 +51,22 @@ public class GoodsController extends BaseController { return jsonObject; } + @RequestMapping("/getShoppingCar") + public JSONObject getShoppingCar(HttpServletRequest request){ + long start = System.currentTimeMillis(); + String userIsli =request.getParameter("user_isli"); + String goodsIsli = request.getParameter("goods_isli"); + String useYears = request.getParameter("use_years"); + String appkey = request.getParameter("appkey"); + String timestamp = request.getParameter("timestamp"); + // + Map retmap =goodsService.getShoppingCar(userIsli); + jsonObject.put("code",200); + jsonObject.put("msg","成功"); + jsonObject.put("data",retmap); + return jsonObject; + } + /** * 手工导入商品信息 * post 方式提价 diff --git a/src/main/java/cn/chjyj/szwh/service/GoodsService.java b/src/main/java/cn/chjyj/szwh/service/GoodsService.java index 74b26c8..90f03c0 100644 --- a/src/main/java/cn/chjyj/szwh/service/GoodsService.java +++ b/src/main/java/cn/chjyj/szwh/service/GoodsService.java @@ -121,4 +121,11 @@ public interface GoodsService { * @return */ Map addShopCar(String userIsli,String goodsIsli,Integer userYears); + + /** + * 查询购物车 + * @param userIsli + * @return + */ + Map getShoppingCar(String userIsli); } 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 dcfa9a2..f1cf95c 100644 --- a/src/main/java/cn/chjyj/szwh/service/impl/GoodsServiceImpl.java +++ b/src/main/java/cn/chjyj/szwh/service/impl/GoodsServiceImpl.java @@ -18,7 +18,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.math.BigDecimal; import java.math.BigInteger; +import java.math.RoundingMode; import java.sql.Timestamp; import java.text.SimpleDateFormat; import java.util.*; @@ -43,6 +45,10 @@ public class GoodsServiceImpl implements GoodsService { private UserMapper userMapper; @Autowired private OrderMapper orderMapper; + @Autowired + private AccountRatioSettingMapper accountRatioSettingMapper; + @Autowired + private AccountRatioDetailMapper accountRatioDetailMapper; @Override public List getGoodsList(int page) { @@ -668,20 +674,111 @@ public class GoodsServiceImpl implements GoodsService { //object Object shopCar = RedisUtil.get(shopRedisKey); if(shopCar!=null){ - carjson =JSONObject.parseObject(shopCar.toString()); - String tmpGoodsIsli= carjson.getString("goods_islicode"); - if(goodsIsli.equals(tmpGoodsIsli)){ + JSONArray jsonArray =carjson.getJSONArray("data"); + // 检查goods_isli + List goodsIsliList =new ArrayList(); + for(int x=0;x getShoppingCar(String userIsli) { + Map retmap =new HashMap<>(); + String shopRedisKey="car_"+userIsli; + 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; + } + //fenpei + Map acrmap = new HashMap(); + acrmap.put("is_deleted",0); + acrmap.put("status",1); + List acrlist = accountRatioSettingMapper.getRatioSettingList(acrmap,0,1); + AccountRatioSetting accountRatioSetting = acrlist.get(0); + AccountRatioDetail accountRatioDetail =accountRatioDetailMapper.getAccRatioDetailByIdRole(accountRatioSetting.getId(),2); + + //goods information + for(int x=0;x goodsSource = goodsSourceMapper.getGoodsSourceByIsli(goods.getGoodsIslicode()); + retmap.put("source",goodsSource); + // + JSONObject userjson = SzwhApiUtils.getApiUser(userIsli); + Map umap = JSONObject.parseObject(userjson.getString("data")); + retmap.put("user",umap); + // + retmap.put("goods",goods); + } + + return retmap; + } + /** * query rank list *