|
@@ -4,8 +4,6 @@ import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
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.common.core.exception.ServiceException;
|
|
import com.pj.current.dto.APPLoginUserInfo;
|
|
import com.pj.current.dto.APPLoginUserInfo;
|
|
import com.pj.current.satoken.StpAPPUserUtil;
|
|
import com.pj.current.satoken.StpAPPUserUtil;
|
|
@@ -13,6 +11,8 @@ import com.pj.enummj.DeleteStatus;
|
|
import com.pj.tb_goods_cart.dto.GoodsCartInfoDto;
|
|
import com.pj.tb_goods_cart.dto.GoodsCartInfoDto;
|
|
import com.pj.tb_goods_transit.TbGoodsTransit;
|
|
import com.pj.tb_goods_transit.TbGoodsTransit;
|
|
import com.pj.tb_goods_transit.TbGoodsTransitMapper;
|
|
import com.pj.tb_goods_transit.TbGoodsTransitMapper;
|
|
|
|
+import com.pj.tb_group.TbGroup;
|
|
|
|
+import com.pj.tb_group.TbGroupMapper;
|
|
import com.pj.utils.so.SoMap;
|
|
import com.pj.utils.so.SoMap;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -35,7 +35,7 @@ public class TbGoodsCartService extends ServiceImpl<TbGoodsCartMapper, TbGoodsCa
|
|
TbGoodsCartMapper tbGoodsCartMapper;
|
|
TbGoodsCartMapper tbGoodsCartMapper;
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
- private AdminInterface adminInterface;
|
|
|
|
|
|
+ private TbGroupMapper tbGroupMapper;
|
|
/** 已过审的商品 */
|
|
/** 已过审的商品 */
|
|
@Autowired
|
|
@Autowired
|
|
private TbGoodsTransitMapper tbGoodsTransitMapper;
|
|
private TbGoodsTransitMapper tbGoodsTransitMapper;
|
|
@@ -68,15 +68,14 @@ public class TbGoodsCartService extends ServiceImpl<TbGoodsCartMapper, TbGoodsCa
|
|
/** 添加商品进购物车 */
|
|
/** 添加商品进购物车 */
|
|
public AjaxJson addGoodsInShopCart(GoodsCartInfoDto goodsCartInfoDto){
|
|
public AjaxJson addGoodsInShopCart(GoodsCartInfoDto goodsCartInfoDto){
|
|
//检查登录 todo: 前端完成后需释放该检查登陆验证
|
|
//检查登录 todo: 前端完成后需释放该检查登陆验证
|
|
-// StpUserUtil.checkLogin();
|
|
|
|
- //验证购买者
|
|
|
|
- Long id = goodsCartInfoDto.getBuyUserId();
|
|
|
|
- //获取购买者对象
|
|
|
|
- AppUserDto appUser = adminInterface.getAppUserById(id);
|
|
|
|
- if(appUser == null || appUser.getId() == null)return AjaxJson.getError("购买者账号异常");
|
|
|
|
|
|
+ APPLoginUserInfo appUser = StpAPPUserUtil.getAPPLoginInfo();
|
|
|
|
+ if(appUser == null || appUser.getLoginId() == null)return AjaxJson.getError("购买者账号异常");
|
|
|
|
+ //判断当前用户是否为一级市场边民组长
|
|
|
|
+ int leader = tbGroupMapper.selectList(new LambdaQueryWrapper<TbGroup>().eq(TbGroup::getLeaderId, appUser.getLoginId())).size();
|
|
|
|
+ if(leader == 0)throw new ServiceException("您当前的身份不是互市组组长,无法添加购物车!");
|
|
//购物车查重
|
|
//购物车查重
|
|
int size = tbGoodsCartMapper.selectList(new LambdaQueryWrapper<TbGoodsCart>()
|
|
int size = tbGoodsCartMapper.selectList(new LambdaQueryWrapper<TbGoodsCart>()
|
|
- .eq(TbGoodsCart::getBuyUserId, id).eq(TbGoodsCart::getSaleGoodsInfoId,
|
|
|
|
|
|
+ .eq(TbGoodsCart::getBuyUserId, appUser.getLoginId()).eq(TbGoodsCart::getSaleGoodsInfoId,
|
|
goodsCartInfoDto.getSaleGoodsInfoId()).eq(TbGoodsCart::getDeleteStatus,
|
|
goodsCartInfoDto.getSaleGoodsInfoId()).eq(TbGoodsCart::getDeleteStatus,
|
|
DeleteStatus.DELETE_STATUS_ON.getCode())).size();
|
|
DeleteStatus.DELETE_STATUS_ON.getCode())).size();
|
|
if(size != 0)
|
|
if(size != 0)
|
|
@@ -101,8 +100,8 @@ public class TbGoodsCartService extends ServiceImpl<TbGoodsCartMapper, TbGoodsCa
|
|
//设置基本属性
|
|
//设置基本属性
|
|
tbGoodsCart.setCreateTime(new Date());
|
|
tbGoodsCart.setCreateTime(new Date());
|
|
tbGoodsCart.setDeleteStatus(DeleteStatus.DELETE_STATUS_ON.getCode());
|
|
tbGoodsCart.setDeleteStatus(DeleteStatus.DELETE_STATUS_ON.getCode());
|
|
- tbGoodsCart.setCreateBy(appUser.getId().toString());
|
|
|
|
- tbGoodsCart.setCreateName(appUser.getName());
|
|
|
|
|
|
+ tbGoodsCart.setCreateBy(appUser.getLoginId().toString());
|
|
|
|
+ tbGoodsCart.setCreateName(appUser.getLoginName());
|
|
//执行保存
|
|
//执行保存
|
|
int insert = tbGoodsCartMapper.insert(tbGoodsCart);
|
|
int insert = tbGoodsCartMapper.insert(tbGoodsCart);
|
|
//判断保存结果
|
|
//判断保存结果
|