|
@@ -3,12 +3,12 @@ package com.pj.tb_goods_cart;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.pj.api.client.admin.AdminInterface;
|
|
|
import com.pj.api.dto.AppUserDto;
|
|
|
import com.pj.common.core.exception.ServiceException;
|
|
|
import com.pj.current.dto.APPLoginUserInfo;
|
|
|
import com.pj.current.satoken.StpAPPUserUtil;
|
|
|
-import com.pj.current.satoken.StpUserUtil;
|
|
|
import com.pj.enummj.DeleteStatus;
|
|
|
import com.pj.tb_goods_cart.dto.GoodsCartInfoDto;
|
|
|
import com.pj.tb_goods_transit.TbGoodsTransit;
|
|
@@ -74,6 +74,13 @@ public class TbGoodsCartService extends ServiceImpl<TbGoodsCartMapper, TbGoodsCa
|
|
|
//获取购买者对象
|
|
|
AppUserDto appUser = adminInterface.getAppUserById(id);
|
|
|
if(appUser == null || appUser.getId() == null)return AjaxJson.getError("购买者账号异常");
|
|
|
+ //购物车查重
|
|
|
+ int size = tbGoodsCartMapper.selectList(new LambdaQueryWrapper<TbGoodsCart>()
|
|
|
+ .eq(TbGoodsCart::getBuyUserId, id).eq(TbGoodsCart::getSaleGoodsInfoId,
|
|
|
+ goodsCartInfoDto.getSaleGoodsInfoId()).eq(TbGoodsCart::getDeleteStatus,
|
|
|
+ DeleteStatus.DELETE_STATUS_ON.getCode())).size();
|
|
|
+ if(size != 0)
|
|
|
+ throw new ServiceException("当前商品已存在您的购物车中,请勿重复添加");
|
|
|
//获取商品对象
|
|
|
Long infoId = goodsCartInfoDto.getSaleGoodsInfoId();
|
|
|
TbGoodsTransit tbGoodsTransit = tbGoodsTransitMapper.selectById(infoId);
|
|
@@ -90,9 +97,7 @@ public class TbGoodsCartService extends ServiceImpl<TbGoodsCartMapper, TbGoodsCa
|
|
|
//当前商品的单位
|
|
|
tbGoodsCart.setGoodsUnit(tbGoodsTransit.getGoodsUnits());
|
|
|
//商品价格
|
|
|
- tbGoodsCart.setTotalPrice((goodsCartInfoDto.getBuyWeight() == null? tbGoodsCart.getBuyWeight() : goodsCartInfoDto.getBuyWeight())
|
|
|
- *
|
|
|
- (tbGoodsTransit.getPrice() == null? 0 : tbGoodsTransit.getPrice()));
|
|
|
+ tbGoodsCart.setTotalPrice(tbGoodsTransit.getPrice());
|
|
|
//设置基本属性
|
|
|
tbGoodsCart.setCreateTime(new Date());
|
|
|
tbGoodsCart.setDeleteStatus(DeleteStatus.DELETE_STATUS_ON.getCode());
|