| | |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.core.exception.ServiceException; |
| | | import com.ruoyi.common.core.utils.DateUtils; |
| | | import com.ruoyi.goods.domain.dto.AppShoppingCartAddDto; |
| | | import com.ruoyi.goods.domain.dto.AppShoppingCartChangeDto; |
| | | import com.ruoyi.system.api.domain.poji.goods.Goods; |
| | | import com.ruoyi.goods.domain.pojo.goods.ShoppingCart; |
| | | import com.ruoyi.goods.domain.vo.AppShoppingCartVo; |
| | | import com.ruoyi.goods.mapper.goods.ShoppingCartMapper; |
| | |
| | | import com.ruoyi.goods.service.goods.ShoppingCartService; |
| | | import com.ruoyi.system.api.constant.AppErrorConstant; |
| | | import com.ruoyi.system.api.domain.dto.AppBaseBathDto; |
| | | import com.ruoyi.system.api.domain.poji.goods.Goods; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | shoppingCart.setGoodsId(appShoppingCartAddDto.getGoodsId()); |
| | | shoppingCart.setBuyNum(appShoppingCartAddDto.getBuyNum()); |
| | | shoppingCart.setDelFlag(0); |
| | | shoppingCart.setCreateTime(DateUtils.getNowDate()); |
| | | shoppingCart.setCreateTime(new Date()); |
| | | this.save(shoppingCart); |
| | | }else{ |
| | | shoppingCart.setBuyNum(shoppingCart.getBuyNum()+appShoppingCartAddDto.getBuyNum()); |
| | | shoppingCart.setUpdateTime(DateUtils.getNowDate()); |
| | | shoppingCart.setUpdateTime(new Date()); |
| | | this.saveOrUpdate(shoppingCart); |
| | | } |
| | | } |
| | |
| | | throw new ServiceException(AppErrorConstant.GOODS_DOWN); |
| | | } |
| | | shoppingCart.setBuyNum(appShoppingCartChangeDto.getBuyNum()); |
| | | shoppingCart.setUpdateTime(DateUtils.getNowDate()); |
| | | shoppingCart.setUpdateTime(new Date()); |
| | | this.saveOrUpdate(shoppingCart); |
| | | } |
| | | |
| | |
| | | shoppingCartMapper.deleteByUserIdAndGoodsId(userId,goodsId); |
| | | } |
| | | |
| | | /** |
| | | * @description 获取购物车数量 |
| | | * @author jqs |
| | | * @date 2023/7/24 15:07 |
| | | * @param userId |
| | | * @param shopId |
| | | * @return Integer |
| | | */ |
| | | @Override |
| | | public Integer countShoppingCart(Long userId, Long shopId){ |
| | | LambdaQueryWrapper<ShoppingCart> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(ShoppingCart::getDelFlag,0); |
| | | queryWrapper.eq(ShoppingCart::getShopId,shopId); |
| | | queryWrapper.eq(ShoppingCart::getUserId,userId); |
| | | return this.count(queryWrapper); |
| | | } |
| | | } |