| | |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.util.*; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | import java.util.stream.Stream; |
| | | |
| | |
| | | if (CollectionUtils.isEmpty(goodsShopList)){ |
| | | throw new NullPointerException("请选择指定门店"); |
| | | } |
| | | for (GoodsShop goodsShop : goodsShopList) { |
| | | goodsShop.setGoodsId(goods.getId()); |
| | | goodsShop.setId(null); |
| | | } |
| | | goodsShopService.saveBatch(goodsShopList); |
| | | saveGoodsShopList(goodsShopList, goods.getId()); |
| | | } |
| | | |
| | | // 指定用户 |
| | | List<GoodsAppUser> goodsAppUserList = goods.getGoodsAppUserList(); |
| | | if (!CollectionUtils.isEmpty(goodsAppUserList)){ |
| | | for (GoodsAppUser goodsAppUser : goodsAppUserList) { |
| | | goodsAppUser.setId(null ); |
| | | goodsAppUser.setGoodsId(goods.getId()); |
| | | } |
| | | goodsAppUserService.saveBatch(goodsAppUserList); |
| | | saveGoodsAppUserList(goodsAppUserList, goods.getId()); |
| | | } |
| | | |
| | | // 会员价格配置 |
| | | List<GoodsVip> goodsVipList = goods.getGoodsVipList(); |
| | | for (GoodsVip goodsVip : goodsVipList) { |
| | | goodsVip.setId(null); |
| | | goodsVip.setGoodsId(goods.getId()); |
| | | } |
| | | goodsVipService.saveBatch(goodsVipList); |
| | | saveGoodsVipList(goodsVipList, goods.getId()); |
| | | |
| | | // 特殊地区售价设置 |
| | | List<GoodsArea> goodsAreaList = goods.getGoodsAreaList(); |
| | | if (!CollectionUtils.isEmpty(goodsAreaList)){ |
| | | saveGoodsAreaList(goodsAreaList, goods.getId()); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void updateManageGoods(Goods goods) { |
| | | goodsMapper.updateById(goods); |
| | | // 指定门店 |
| | | List<GoodsShop> goodsShopList = goods.getGoodsShopList(); |
| | | saveGoodsShopList(goodsShopList, goods.getId()); |
| | | |
| | | // 指定用户 |
| | | List<GoodsAppUser> goodsAppUserList = goods.getGoodsAppUserList(); |
| | | saveGoodsAppUserList(goodsAppUserList, goods.getId()); |
| | | |
| | | // 会员价格配置 |
| | | List<GoodsVip> goodsVipList = goods.getGoodsVipList(); |
| | | saveGoodsVipList(goodsVipList, goods.getId()); |
| | | |
| | | // 特殊地区售价设置 |
| | | List<GoodsArea> goodsAreaList = goods.getGoodsAreaList(); |
| | | saveGoodsAreaList(goodsAreaList, goods.getId()); |
| | | } |
| | | |
| | | private void saveGoodsAreaList(List<GoodsArea> goodsAreaList, Integer id) { |
| | | goodsAreaService.remove(new LambdaQueryWrapper<GoodsArea>() |
| | | .eq(GoodsArea::getGoodsId, id)); |
| | | if (!CollectionUtils.isEmpty(goodsAreaList)){ |
| | | for (GoodsArea goodsArea : goodsAreaList) { |
| | | List<GoodsArea> goodsAreaList1 = goodsArea.getGoodsAreaList(); |
| | | for (GoodsArea area : goodsAreaList1) { |
| | | area.setGoodsId(goods.getId()); |
| | | area.setGoodsId(id); |
| | | area.setProvince(goodsArea.getProvince()); |
| | | area.setCity(goodsArea.getCity()); |
| | | area.setDistricts(goodsArea.getDistricts()); |
| | |
| | | goodsAreaService.saveBatch(goodsAreaList1); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void updateManageGoods(Goods goods) { |
| | | goodsMapper.updateById(goods); |
| | | // 指定门店 |
| | | List<GoodsShop> goodsShopList = goods.getGoodsShopList(); |
| | | goodsShopService.updateBatchById(goodsShopList); |
| | | |
| | | // 指定用户 |
| | | List<GoodsAppUser> goodsAppUserList = goods.getGoodsAppUserList(); |
| | | goodsAppUserService.updateBatchById(goodsAppUserList); |
| | | |
| | | // 会员价格配置 |
| | | List<GoodsVip> goodsVipList = goods.getGoodsVipList(); |
| | | goodsVipService.updateBatchById(goodsVipList); |
| | | |
| | | // 特殊地区售价设置 |
| | | List<GoodsArea> goodsAreaList = goods.getGoodsAreaList(); |
| | | if (!CollectionUtils.isEmpty(goodsAreaList)){ |
| | | for (GoodsArea goodsArea : goodsAreaList) { |
| | | List<GoodsArea> goodsAreaList1 = goodsArea.getGoodsAreaList(); |
| | | for (GoodsArea area : goodsAreaList1) { |
| | | area.setGoodsId(goods.getId()); |
| | | area.setProvince(goodsArea.getProvince()); |
| | | area.setCity(goodsArea.getCity()); |
| | | area.setDistricts(goodsArea.getDistricts()); |
| | | area.setProvinceCode(goodsArea.getProvinceCode()); |
| | | area.setCityCode(goodsArea.getCityCode()); |
| | | area.setDistrictsCode(goodsArea.getDistrictsCode()); |
| | | private void saveGoodsVipList(List<GoodsVip> goodsVipList, Integer id) { |
| | | goodsVipService.remove(new LambdaQueryWrapper<GoodsVip>() |
| | | .eq(GoodsVip::getGoodsId, id)); |
| | | goodsVipService.saveBatch(goodsVipList); |
| | | } |
| | | goodsAreaService.updateBatchById(goodsAreaList1); |
| | | |
| | | private void saveGoodsAppUserList(List<GoodsAppUser> goodsAppUserList, Integer id) { |
| | | goodsAppUserService.remove(new LambdaQueryWrapper<GoodsAppUser>() |
| | | .eq(GoodsAppUser::getGoodsId, id)); |
| | | if (!CollectionUtils.isEmpty(goodsAppUserList)){ |
| | | for (GoodsAppUser goodsAppUser : goodsAppUserList) { |
| | | goodsAppUser.setId(null ); |
| | | goodsAppUser.setGoodsId(id); |
| | | } |
| | | } |
| | | goodsAppUserService.saveBatch(goodsAppUserList); |
| | | } |
| | | |
| | | private void saveGoodsShopList(List<GoodsShop> goodsShopList, Integer goodsId) { |
| | | goodsShopService.remove(new LambdaQueryWrapper<GoodsShop>() |
| | | .eq(GoodsShop::getGoodsId, goodsId)); |
| | | if (!CollectionUtils.isEmpty(goodsShopList)){ |
| | | for (GoodsShop goodsShop : goodsShopList) { |
| | | goodsShop.setGoodsId(goodsId); |
| | | goodsShop.setId(null); |
| | | } |
| | | } |
| | | goodsShopService.saveBatch(goodsShopList); |
| | | } |
| | | |
| | | @Override |