| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R<Void> add(@RequestBody Shop shop){ |
| | | String phone = shop.getPhone(); |
| | | if (!shopService.cheUserByPhone(phone)) { |
| | | AppUser appUser = appUserClient.getAppUserByPhone1(phone).getData(); |
| | | if (appUser == null){ |
| | | return R.fail("该手机号未注册"); |
| | | } |
| | | AppUser appUser = appUserClient.getAppUserByPhone1(phone).getData(); |
| | | shop.setShopAllPoint(0); |
| | | shop.setLowerLevelSharePoint(0); |
| | | shop.setSharePoint(0); |
| | |
| | | userShop.setRoleId(2L); |
| | | userShopClient.saveUserShop(userShop); |
| | | } |
| | | |
| | | // 更换下级会员绑定门店 |
| | | R<List<AppUser>> lowerShopR = appUserClient.setLowerUserShop(appUser.getId(), shop.getId()); |
| | | if (R.isError(lowerShopR)){ |
| | | throw new RuntimeException("更换下级会员绑定门店失败"); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | @DeleteMapping("/deleteShop") |
| | | @ApiOperation(value = "删除门店", tags = {"管理后台-门店管理"}) |
| | | public R<Void> deleteShop(@ApiParam("门店id") @RequestParam("id") Integer id){ |
| | | List<Goods> list1 = goodsService.list(new LambdaQueryWrapper<Goods>().eq(Goods::getDelFlag, 0).eq(Goods::getAppointStore, 1).eq(Goods::getStatus, 2)); |
| | | if(list1.size() > 0){ |
| | | Set<Integer> collect1 = list1.stream().map(Goods::getId).collect(Collectors.toSet()); |
| | | long count = goodsShopService.count(new LambdaQueryWrapper<GoodsShop>().eq(GoodsShop::getShopId, id).in(GoodsShop::getGoodsId, collect1)); |
| | | if(0 < count){ |
| | | return R.fail("门店已被商品使用,不能删除"); |
| | | } |
| | | } |
| | | Shop shop = shopService.getById(id); |
| | | shop.setDelFlag(1); |
| | | shopService.updateById(shop); |