From 34ec63ac94b2b61bbdbc4b6a98a577efedbafda8 Mon Sep 17 00:00:00 2001
From: Pu Zhibing <393733352@qq.com>
Date: 星期四, 28 十一月 2024 13:41:23 +0800
Subject: [PATCH] 开发购物车列表

---
 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsServiceImpl.java |   72 +++++++++++++++++++++++++++++++++++-
 1 files changed, 70 insertions(+), 2 deletions(-)

diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsServiceImpl.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsServiceImpl.java
index eb17457..d5f42ee 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsServiceImpl.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsServiceImpl.java
@@ -1,14 +1,31 @@
 package com.ruoyi.other.service.impl;
 
+import cn.hutool.json.JSONArray;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.ruoyi.other.mapper.GoodsMapper;
+import com.ruoyi.common.core.utils.StringUtils;
+import com.ruoyi.common.core.utils.bean.BeanUtils;
+import com.ruoyi.common.security.service.TokenService;
 import com.ruoyi.other.api.domain.Goods;
+import com.ruoyi.other.api.domain.VipSetting;
+import com.ruoyi.other.enums.GoodsStatus;
+import com.ruoyi.other.mapper.GoodsAreaMapper;
+import com.ruoyi.other.mapper.GoodsMapper;
 import com.ruoyi.other.service.GoodsService;
+import com.ruoyi.other.service.GoodsVipService;
+import com.ruoyi.other.service.VipSettingService;
+import com.ruoyi.other.vo.GoodsVO;
+import com.ruoyi.system.api.model.LoginUser;
 import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
 
 /**
  * <p>
- *  服务实现类
+ * 服务实现类
  * </p>
  *
  * @author luodangjia
@@ -16,5 +33,56 @@
  */
 @Service
 public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements GoodsService {
+    @Resource
+    private GoodsMapper goodsMapper;
+    @Resource
+    private TokenService tokenService;
+    @Resource
+    private VipSettingService vipSettingService;
+    @Resource
+    private GoodsAreaMapper goodsAreaMapper;
+    @Resource
+    private GoodsVipService goodsVipService;
+
+    @Override
+    public List<GoodsVO> goodsList(Goods search) {
+        List<Goods> goodsList = this.list(new LambdaQueryWrapper<Goods>()
+                .eq(Goods::getStatus, GoodsStatus.UP)
+                .eq(Objects.nonNull(search.getGoodsCategoryId()) ,Goods::getGoodsCategoryId, search.getGoodsCategoryId())
+                .like(StringUtils.isNotEmpty(search.getName()), Goods::getName, search.getName()));
+
+        List<GoodsVO> result = new ArrayList<>();
+        for (Goods goods : goodsList) {
+            GoodsVO goodsVO = new GoodsVO();
+            BeanUtils.copyBeanProp(goodsVO, goods);
+            result.add(goodsVO);
+        }
+        return result;
+    }
+
+    @Override
+    public GoodsVO goodsDetail(Long goodsId) {
+        // TODO 根据会员等级计算价格、积分
+        LoginUser loginUserApplet = tokenService.getLoginUserApplet();
+        VipSetting vipSetting = vipSettingService.getVipSettingByUserId(loginUserApplet.getUserid());
+        // ...
+
+        Goods goods = this.getById(goodsId);
+        if (Objects.nonNull(goods)){
+            GoodsVO goodsVO = new GoodsVO();
+            BeanUtils.copyBeanProp(goodsVO, goods);
+            return goodsVO;
+        }
+        return new GoodsVO();
+    }
+
+    @Override
+    public List<Goods> getGoodsListByShopId(Integer shopId) {
+        LoginUser loginUserApplet = tokenService.getLoginUserApplet();
+        VipSetting vipSetting = vipSettingService.getVipSettingByUserId(loginUserApplet.getUserid());
+        JSONArray array = new JSONArray();
+        array.add(vipSetting.getId());
+        return goodsMapper.selectListByShopId(shopId,array.toString());
+    }
 
 }

--
Gitblit v1.7.1