From 630d5398d5a5b00c56537f1bc175d5e3ff6b70ae Mon Sep 17 00:00:00 2001 From: luofl <1442745593@qq.com> Date: 星期二, 25 二月 2025 11:56:13 +0800 Subject: [PATCH] 修改物流信息导入模板 --- ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopController.java | 181 ++++++++++++++++++++++++++++++++++++++------ 1 files changed, 155 insertions(+), 26 deletions(-) diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopController.java index dd8c7e6..438422a 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopController.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopController.java @@ -12,8 +12,10 @@ import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.web.controller.BaseController; import com.ruoyi.common.security.service.TokenService; +import com.ruoyi.common.security.utils.MD5Generator; import com.ruoyi.common.security.utils.SecurityUtils; import com.ruoyi.order.feignClient.OrderClient; +import com.ruoyi.order.vo.OrderSaleNum; import com.ruoyi.order.vo.VerifiableShopVo; import com.ruoyi.other.api.domain.*; import com.ruoyi.other.mapper.ShopMapper; @@ -173,7 +175,8 @@ user.setRoleType(2); user.setObjectId(shopId); user.setAppUserId(appUser.getId()); - user.setPassword(phone.substring(5)); + String s = MD5Generator.generateMD5(phone.substring(5)); + user.setPassword(s); user.setCreateTime(new Date()); Long userId = sysUserClient.saveShopUser(user).getData(); @@ -206,8 +209,11 @@ @GetMapping("/getDetailById") @ApiOperation(value = "门店详情", tags = {"管理后台-门店管理"}) public R<Shop> getDetailById(@RequestParam("id") Integer id){ - Shop byId = shopService.getById(id); - return R.ok(byId); + Shop shop = shopService.getById(id); + if (null != shop.getPid() && shop.getPid()==0){ + shop.setPid(null); + } + return R.ok(shop); } @DeleteMapping("/deleteShop") @@ -413,20 +419,52 @@ shop.setStatus(status); shopService.updateById(shop); //处理员工等数据 - UserShop userSh = new UserShop(); - userSh.setShopId(id); - List<UserShop> data = userShopClient.getUserShop(userSh).getData(); - for (UserShop datum : data) { - UserShop userShop = new UserShop(); - userShop.setUserId(datum.getUserId()); - List<UserShop> data1 = userShopClient.getUserShop(userShop).getData(); - long count = data1.stream().filter(s -> !s.getShopId().equals(id)).count(); - if(0 == count){ + if(status == 1){ + UserShop userSh = new UserShop(); + userSh.setShopId(id); + List<UserShop> data = userShopClient.getUserShop(userSh).getData(); + for (UserShop datum : data) { SysUser sysUser = sysUserClient.getSysUser(datum.getUserId()).getData(); - sysUser.setStatus(status == 1 ? "0" : "1"); + sysUser.setStatus("0"); sysUserClient.updateUser(sysUser); } + }else{ + //查询门店所有关联数据 + UserShop userSh = new UserShop(); + userSh.setShopId(id); + List<UserShop> data = userShopClient.getUserShop(userSh).getData(); + for (UserShop datum : data) { + //查询用户关联的其他店铺 + UserShop userShop = new UserShop(); + userShop.setUserId(datum.getUserId()); + List<UserShop> data1 = userShopClient.getUserShop(userShop).getData(); + List<UserShop> collect = data1.stream().filter(s -> !s.getShopId().equals(id)).collect(Collectors.toList()); + if(collect.size() == 0){ + //如果没有其他店铺,则将用户禁用 + SysUser sysUser = sysUserClient.getSysUser(datum.getUserId()).getData(); + sysUser.setStatus("1"); + sysUserClient.updateUser(sysUser); + }else{ + List<Integer> shopIds = collect.stream().map(UserShop::getShopId).collect(Collectors.toList()); + List<Shop> list = shopService.list(new LambdaQueryWrapper<Shop>().eq(Shop::getDelFlag, 0).eq(Shop::getStatus, 1) + .in(Shop::getId, shopIds)); + //如果用户关联的其他门店都禁用了,将用户禁用 + if(list.size() == 0){ + SysUser sysUser = sysUserClient.getSysUser(datum.getUserId()).getData(); + sysUser.setStatus("1"); + sysUserClient.updateUser(sysUser); + }else{ + //修改默认门店 + SysUser sysUser = sysUserClient.getSysUser(datum.getUserId()).getData(); + if(sysUser.getObjectId().equals(id)){ + sysUser.setObjectId(list.get(0).getId()); + sysUserClient.updateUser(sysUser); + } + } + } + } } + return R.ok(); } @@ -466,7 +504,8 @@ userShop.setRoleType(1); List<UserShop> data = userShopClient.getUserShop(userShop).getData(); SysUser userData = sysUserClient.getSysUser(data.get(0).getUserId()).getData(); - userData.setPassword(userData.getPhonenumber().substring(5)); + String s = MD5Generator.generateMD5(userData.getPhonenumber().substring(5)); + userData.setPassword(s); sysUserClient.resetPassword(userData); } return R.ok(); @@ -650,14 +689,35 @@ @ApiOperation(value = "门店统计", tags = {"管理后台-首页统计"}) public R<ShopStatistics> shopStatistics(@ApiParam("门店id") Integer shopId) { ShopStatistics shopStatistics = shopMapper.getShopStatistics(shopId); - if(null == shopId){ - shopId = 0; + List<Integer> shopIds; + + shopIds = shopService.list(new LambdaQueryWrapper<Shop>() + .eq(Shop::getDelFlag, 0) + .eq(shopId !=null,Shop::getId, shopId)) + .stream() + .map(Shop::getId) + .collect(Collectors.toList()); + + + if (CollectionUtils.isEmpty(shopIds)){ + shopStatistics.setTotalOrder(0); + shopStatistics.setServiceOrder(0); + shopStatistics.setGoodsOrder(0); + }else { + OrderSaleNum serviceOrderSaleNum = new OrderSaleNum(); + serviceOrderSaleNum.setShopIds(shopIds); + serviceOrderSaleNum.setType(1); + Integer serviceOrder = orderClient.getShopSaleNumByShopIds(serviceOrderSaleNum).getData(); + + OrderSaleNum goodsOrderSaleNum = new OrderSaleNum(); + goodsOrderSaleNum.setShopIds(shopIds); + goodsOrderSaleNum.setType(2); + Integer goodsOrder = orderClient.getShopSaleNumByShopIds(goodsOrderSaleNum).getData(); + + shopStatistics.setTotalOrder(serviceOrder + goodsOrder); + shopStatistics.setServiceOrder(serviceOrder); + shopStatistics.setGoodsOrder(goodsOrder); } - Integer serviceOrder = orderClient.getShopSaleNum(shopId, 1).getData(); - Integer goodsOrder = orderClient.getShopSaleNum(shopId, 2).getData(); - shopStatistics.setTotalOrder(serviceOrder + goodsOrder); - shopStatistics.setServiceOrder(serviceOrder); - shopStatistics.setGoodsOrder(goodsOrder); return R.ok(shopStatistics); } @@ -785,19 +845,88 @@ @GetMapping("/getShopStatistics") - public R<Map<String, BigDecimal> > getShopStatistics(){ - List<Shop> shopList = shopService.list(); + public R<Map<String, BigDecimal> > getShopStatistics(@RequestParam("shopId") Integer shopId){ + LambdaQueryWrapper<Shop> queryWrapper = new LambdaQueryWrapper<Shop>().eq(Shop::getDelFlag, 0).eq(Shop::getStatus, 1); + if(null != shopId && 0 != shopId){ + queryWrapper.eq(Shop::getId, shopId); + } + List<Shop> shopList = shopService.list(queryWrapper); BigDecimal serverGiveawayMoney = BigDecimal.ZERO; - BigDecimal lowerLevelGiveawayMoney = BigDecimal.ZERO; + BigDecimal giveawayMoney = BigDecimal.ZERO; for (Shop shop : shopList) { serverGiveawayMoney = serverGiveawayMoney.add(shop.getServerGiveawayMoney()); - lowerLevelGiveawayMoney = lowerLevelGiveawayMoney.add(shop.getLowerLevelGiveawayMoney()); + giveawayMoney = giveawayMoney.add(shop.getGiveawayMoney()); } Map<String, BigDecimal> map = new HashMap<>(); map.put("serverGiveawayMoney", serverGiveawayMoney); - map.put("lowerLevelGiveawayMoney", lowerLevelGiveawayMoney); + map.put("giveawayMoney", giveawayMoney); return R.ok(map); } + /** + * 获取指定用户的服务商 + * @param userId + * @return + */ + @GetMapping("/getServiceProvider") + public R<Shop> getServiceProvider(Long userId){ + List<AppUser> allSuperiors = getAllSuperiors(userId); + //当前绑定门店的店铺信息(服务商) + Shop serviceProvider = null; + for (AppUser allSuperior : allSuperiors) { + List<Shop> shopList = shopService.lambdaQuery().eq(Shop::getAppUserId, allSuperior.getId()).eq(Shop::getDelFlag,0).list(); + if (!CollectionUtils.isEmpty(shopList)){ + serviceProvider = shopList.get(0); + break; + } + } + return R.ok(serviceProvider); + } + + /** + * 获取指定用户的高级服务商 + * @return + */ + @GetMapping("/getSuperiorServiceProvider") + public R<Shop> getSuperiorServiceProvider(Long userId){ + List<AppUser> allSuperiors = getAllSuperiors(userId); + Long techerId = null; + for (AppUser allSuperior : allSuperiors) { + List<Shop> shopList = shopService.lambdaQuery().eq(Shop::getAppUserId, allSuperior.getId()).eq(Shop::getDelFlag,0).list(); + if (!CollectionUtils.isEmpty(shopList)){ + techerId = allSuperior.getId(); + break; + } + } + if (techerId == null){ + return R.fail("暂无高级服务商"); + } + List<AppUser> allSuperiors1 = getAllSuperiors(techerId); + for (AppUser allSuperior : allSuperiors1) { + List<Shop> shopList = shopService.lambdaQuery().eq(Shop::getAppUserId, allSuperior.getId()).eq(Shop::getDelFlag,0).list(); + if (!CollectionUtils.isEmpty(shopList)){ + return R.ok(shopList.get(0)); + } + } + return R.fail("暂无高级服务商"); + } + + + public List<AppUser> getAllSuperiors(Long userId) { + List<AppUser> allSuperiors = new ArrayList<>(); + + // 获取当前用户的直接上级 + AppUser currentUser = appUserClient.getAppUserById(userId); + if (currentUser != null && currentUser.getInviteUserId() != null) { + AppUser superior = appUserClient.getAppUserById(currentUser.getInviteUserId()); + if (superior != null) { + allSuperiors.add(superior); // 添加直接上级 + allSuperiors.addAll(getAllSuperiors(superior.getId())); // 递归添加上级的上级 + } + } + + return allSuperiors; + } + } -- Gitblit v1.7.1