| | |
| | | package com.matrix.system.hive.service.imp; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import com.matrix.core.constance.MatrixConstance; |
| | | import com.matrix.core.exception.GlobleException; |
| | | import com.matrix.core.pojo.PaginationVO; |
| | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | |
| | | |
| | | /** |
| | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int add(ShoppingGoods shoppingGoods) { |
| | | SysUsers sysUsers = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY); |
| | | SysShopInfo shopInfo = shopInfoDao.selectById(sysUsers.getShopId()); |
| | | |
| | | |
| | | |
| | | if(shopInfo.getShopType()==SysShopInfo.SHOP_TYPE_ZONGBU){ |
| | |
| | | } |
| | | |
| | | shoppingGoods.setShopId(sysUsers.getShopId()); |
| | | // 校验去重 |
| | | if (serviceUtil.addCheckRepeatTowColumn("shopping_goods", |
| | | "code", shoppingGoods.getCode(), |
| | | "company_id", shoppingGoods.getCompanyId())) { |
| | | |
| | | //去重查询 |
| | | ShoppingGoods queryGoods=new ShoppingGoods(); |
| | | queryGoods.setCompanyId(shoppingGoods.getCompanyId()); |
| | | queryGoods.setCode(shoppingGoods.getCode()); |
| | | queryGoods.setIsDel(ShoppingGoods.NORMAL); |
| | | List<ShoppingGoods> oldGoods=shoppingGoodsDao.selectByModel(queryGoods); |
| | | if(CollUtil.isNotEmpty(oldGoods)){ |
| | | throw new GlobleException("编号" + shoppingGoods.getCode() + "重复"); |
| | | } |
| | | |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int remove(List<Long> list) { |
| | | SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY); |
| | | SysShopInfo zbShop = shopInfoDao.selectZbShop(user.getCompanyId()); |
| | | //非总部员工只能删除自己门店的产品 |
| | | if(user.getShopId()!=zbShop.getId()){ |
| | | //校验是否可以删除 |
| | | List<ShoppingGoods> dataList = shoppingGoodsDao.selectByIds(list); |
| | | List<ShoppingGoods> collect = dataList.stream().filter(goods -> !Objects.equals(user.getShopId(), goods.getShopId())).collect(Collectors.toList()); |
| | | if(CollUtil.isNotEmpty(collect)){ |
| | | throw new GlobleException("非总部员工只能删除自己门店的产品"); |
| | | } |
| | | } |
| | | return shoppingGoodsDao.deleteByIds(list); |
| | | |
| | | } |