| | |
| | | @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); |
| | |
| | | shop.setDistrictCode(city); |
| | | shopService.save(shop); |
| | | |
| | | Integer shopId = shop.getId(); |
| | | |
| | | AppUserShop appUserShop = new AppUserShop(); |
| | | appUserShop.setAppUserId(appUser.getId()); |
| | | appUserShop.setShopId(shop.getId()); |
| | | appUserShop.setShopId(shopId); |
| | | R<Void> r = appUserClient.addAppUserShop(appUserShop); |
| | | if (R.isError(r)){ |
| | | throw new RuntimeException("添加失败"); |
| | |
| | | if(null != sysUser){ |
| | | UserShop userShop = new UserShop(); |
| | | userShop.setUserId(sysUser.getUserId()); |
| | | userShop.setShopId(shop.getId()); |
| | | userShop.setShopId(shopId); |
| | | userShop.setRoleType(1); |
| | | userShop.setNickName(sysUser.getNickName()); |
| | | List<UserShop> data = userShopClient.getUserShop(userShop).getData(); |
| | | if(null == data || data.size() == 0){ |
| | | userShop = new UserShop(); |
| | | userShop.setUserId(sysUser.getUserId()); |
| | | userShop.setShopId(shop.getId()); |
| | | userShop.setShopId(shopId); |
| | | userShop.setRoleType(1); |
| | | userShop.setRoleId(2L); |
| | | userShop.setCreateTime(LocalDateTime.now()); |
| | |
| | | user.setStatus("0"); |
| | | user.setDelFlag("0"); |
| | | user.setRoleType(2); |
| | | user.setObjectId(shop.getId()); |
| | | user.setObjectId(shopId); |
| | | user.setAppUserId(appUser.getId()); |
| | | user.setPassword(phone.substring(5)); |
| | | user.setCreateTime(new Date()); |
| | |
| | | |
| | | UserShop userShop = new UserShop(); |
| | | userShop.setUserId(userId); |
| | | userShop.setShopId(shop.getId()); |
| | | userShop.setShopId(shopId); |
| | | userShop.setRoleType(1); |
| | | userShop.setRoleId(2L); |
| | | userShopClient.saveUserShop(userShop); |
| | | } |
| | | |
| | | // 更换下级会员绑定门店 |
| | | R<List<AppUser>> lowerShopR = appUserClient.setLowerUserShop(appUser.getId(), shopId); |
| | | 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); |
| | |
| | | } |
| | | } |
| | | String city = TencentMapUtil.inverseGeographicalAnalysis(shop.getLongitude(), shop.getLatitude(), false); |
| | | if(!StringUtils.hasLength(city)){ |
| | | city = "510100"; |
| | | } |
| | | shop.setProvinceCode(city.substring(0, 2) + "0000"); |
| | | shop.setCityCode(city.substring(0, 4) + "00"); |
| | | shop.setDistrictCode(city); |
| | |
| | | return R.ok(new ArrayList<>()); |
| | | } |
| | | List<Integer> shopIds = appUserShopList.stream().map(AppUserShop::getShopId).collect(Collectors.toList()); |
| | | List<Shop> shopList = shopService.list(new LambdaQueryWrapper<Shop>().in(Shop::getId, shopIds).eq(Shop::getDelFlag, 0).eq(Shop::getStatus, 1)); |
| | | List<Shop> shopList = shopService.list(new LambdaQueryWrapper<Shop>().in(Shop::getId, shopIds).eq(Shop::getDelFlag, 0)); |
| | | long count = shopList.stream().filter(s -> s.getStatus() == 1).count(); |
| | | if(shopList.size() > 0 && count == 0){ |
| | | return R.fail("操作失败,当前门店已冻结"); |
| | | } |
| | | shopList = shopList.stream().filter(s -> s.getStatus() == 1).collect(Collectors.toList()); |
| | | if(null != appUser.getShopId()){ |
| | | Optional<Shop> first = shopList.stream().filter(s -> s.getId().equals(appUser.getShopId())).findFirst(); |
| | | if(first.isPresent()){ |
| | |
| | | return R.ok(list); |
| | | } |
| | | |
| | | @GetMapping("/getShopIdByName") |
| | | R<Set<Integer>> getShopIdByName(@RequestParam String shopName){ |
| | | /** |
| | | * 根据名称查询门店id |
| | | * @param shopName |
| | | * @return |
| | | */ |
| | | @PostMapping("/getShopIdByName") |
| | | public R<Set<Integer>> getShopIdByName(@RequestParam("shopName") String shopName){ |
| | | List<Shop> list = shopService.list(new LambdaQueryWrapper<Shop>() |
| | | .like(Shop::getName, shopName)); |
| | | return R.ok(list.stream().map(Shop::getId).collect(Collectors.toSet())); |
| | |
| | | userShop.setUserId(userid); |
| | | List<UserShop> data = userShopClient.getUserShop(userShop).getData(); |
| | | List<Integer> collect = data.stream().map(UserShop::getShopId).collect(Collectors.toList()); |
| | | List<Shop> shops = shopService.list(new LambdaQueryWrapper<Shop>().eq(Shop::getId, collect).eq(Shop::getDelFlag, 0).eq(Shop::getStatus, 1)); |
| | | List<Shop> shops = shopService.list(new LambdaQueryWrapper<Shop>() |
| | | .in(!CollectionUtils.isEmpty(collect),Shop::getId, collect) |
| | | .eq(Shop::getDelFlag, 0).eq(Shop::getStatus, 1)); |
| | | List<VerifiableShopVo> list = new ArrayList<>(); |
| | | for (Shop shop : shops) { |
| | | VerifiableShopVo vo = new VerifiableShopVo(); |