From ddf3f19408fb311734218aaaa5edb49c5134b1eb Mon Sep 17 00:00:00 2001 From: puzhibing <393733352@qq.com> Date: 星期三, 08 一月 2025 21:14:36 +0800 Subject: [PATCH] 修改bug --- ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopController.java | 85 +++++++++++++++++++++++++++++++++++++++--- 1 files changed, 78 insertions(+), 7 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 859cc37..ee35476 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 @@ -11,10 +11,15 @@ import com.ruoyi.common.core.web.controller.BaseController; import com.ruoyi.common.security.service.TokenService; import com.ruoyi.common.security.utils.SecurityUtils; +import com.ruoyi.order.feignClient.OrderClient; import com.ruoyi.order.vo.VerifiableShopVo; +import com.ruoyi.other.api.domain.Goods; +import com.ruoyi.other.api.domain.GoodsShop; import com.ruoyi.other.api.domain.Shop; import com.ruoyi.other.api.domain.ShopScore; import com.ruoyi.other.mapper.ShopMapper; +import com.ruoyi.other.service.GoodsService; +import com.ruoyi.other.service.GoodsShopService; import com.ruoyi.other.service.ShopScoreService; import com.ruoyi.other.service.ShopService; import com.ruoyi.other.util.GeodesyUtil; @@ -69,6 +74,12 @@ private UserShopClient userShopClient; @Resource private AppUserShopClient appUserShopClient; + @Resource + private GoodsService goodsService; + @Resource + private GoodsShopService goodsShopService; + @Resource + private OrderClient orderClient; @@ -127,6 +138,7 @@ userShop.setUserId(sysUser.getUserId()); userShop.setShopId(shop.getId()); userShop.setRoleType(1); + userShop.setRoleId(2L); userShopClient.saveUserShop(userShop); } }else{ @@ -150,6 +162,7 @@ userShop.setUserId(userId); userShop.setShopId(shop.getId()); userShop.setRoleType(1); + userShop.setRoleId(2L); userShopClient.saveUserShop(userShop); } return R.ok(); @@ -169,7 +182,6 @@ Shop shop = shopService.getById(id); shop.setDelFlag(1); shopService.updateById(shop); - //获取门店的员工数据 UserShop userShop = new UserShop(); userShop.setShopId(shop.getId()); List<UserShop> data = userShopClient.getUserShop(userShop).getData(); @@ -179,16 +191,19 @@ sysUserClient.delShopUser(shop.getId(), 2); //修改小程序用户类型和门店数据 for (SysUser sysUser : sysUserList) { - String userName = sysUser.getUserName(); //通过电话号码查询小程序用户和门店关系数据 - AppUser appUser = appUserClient.getAppUserByPhone1(userName).getData(); + AppUser appUser = appUserClient.getAppUserByPhone1(sysUser.getUserName()).getData(); //需要先判断用户是否没有关联任何门店 List<AppUserShop> userShops = appUserShopClient.getAppUserShop(appUser.getId()).getData(); if(userShops.size() == 1 && userShops.get(0).getShopId().equals(shop.getId())){ appUser.setUserType(1); appUserClient.editAppUserById(appUser); } - + //删除用户门店关系表数据 + AppUserShop appUserShop = new AppUserShop(); + appUserShop.setAppUserId(appUser.getId()); + appUserShop.setShopId(shop.getId()); + appUserShopClient.delAppUserShop(appUserShop); } return R.ok(); } @@ -243,6 +258,7 @@ userShop.setUserId(sysUser.getUserId()); userShop.setShopId(shop.getId()); userShop.setRoleType(1); + userShop.setRoleId(2L); userShopClient.saveUserShop(userShop); } }else{ @@ -266,10 +282,27 @@ userShop.setUserId(userId); userShop.setShopId(shop.getId()); userShop.setRoleType(1); + userShop.setRoleId(2L); userShopClient.saveUserShop(userShop); } return R.ok(); } + + + @PutMapping("/freezingOrThawing") + @ApiOperation(value = "门店管理-冻结/解冻门店", tags = {"管理后台-门店管理"}) + public R freezingOrThawing(@RequestParam("id") Integer id, @RequestParam("status") Integer status){ + Shop shop = shopService.getById(id); + if(shop.getStatus().equals(status)){ + return R.fail("不能重复操作"); + } + shop.setStatus(status); + shopService.updateById(shop); + return R.ok(); + } + + + @GetMapping("/list") @ApiOperation(value = "门店列表", tags = {"管理后台-门店管理"}) @@ -371,6 +404,9 @@ @ApiOperation(value = "绑定门店", tags = {"小程序-个人中心"}) public R<Void> bindShop(@ApiParam("门店id") @RequestParam Integer shopId) { AppUser appUser = appUserClient.getAppUserById(SecurityUtils.getUserId()); + if(null != appUser.getShopId()){ + return R.fail("不能重复绑定门店"); + } appUser.setShopId(shopId); return appUserClient.editAppUserById(appUser); } @@ -406,7 +442,7 @@ @ResponseBody @PostMapping("/getShopByUserId") public R<List<Shop>> getShopByUserId(@RequestParam("id") Long id){ - List<Shop> list = shopService.lambdaQuery().eq(Shop::getAppUserId, id).list(); + List<Shop> list = shopService.lambdaQuery().eq(Shop::getAppUserId, id).eq(Shop::getDelFlag,0).list(); return R.ok(list); } @@ -443,6 +479,14 @@ @ApiOperation(value = "门店统计", tags = {"管理后台-首页统计"}) public R<ShopStatistics> shopStatistics(@ApiParam("门店id") Integer shopId) { ShopStatistics shopStatistics = shopMapper.getShopStatistics(shopId); + if(null == shopId){ + shopId = 0; + } + 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); } @@ -462,15 +506,31 @@ @ResponseBody @GetMapping("/getVerifiableShop") @ApiOperation(value = "获取可核销门店列表", tags = {"购物车-小程序"}) - public R<List<VerifiableShopVo>> getVerifiableShop(String longitude, String latitude){ + public R<List<VerifiableShopVo>> getVerifiableShop(String longitude, String latitude, Integer goodsId){ String city = TencentMapUtil.inverseGeographicalAnalysis(longitude, latitude, false); + if(null == city){ + city = "510100"; + } city = city.substring(0, 4) + "00"; - List<Shop> list = shopService.list(new LambdaQueryWrapper<Shop>().eq(Shop::getDelFlag, 0).eq(Shop::getCityCode, city)); + LambdaQueryWrapper<Shop> wrapper = new LambdaQueryWrapper<Shop>().eq(Shop::getDelFlag, 0).eq(Shop::getCityCode, city); + if(null != goodsId){ + Goods goods = goodsService.getById(goodsId); + if(1 == goods.getType() && 1 == goods.getAppointStore()){ + List<Integer> collect = goodsShopService.list(new LambdaQueryWrapper<GoodsShop>().eq(GoodsShop::getGoodsId, goods.getId())) + .stream().map(GoodsShop::getShopId).collect(Collectors.toList()); + if(collect.size() > 0){ + wrapper.in(Shop::getId, collect); + } + } + } + List<Shop> list = shopService.list(wrapper); List<VerifiableShopVo> verifiableShopVoList = new ArrayList<>(); for (Shop shop : list) { VerifiableShopVo vo = new VerifiableShopVo(); vo.setId(shop.getId()); vo.setName(shop.getName()); + vo.setAddress(shop.getAddress()); + vo.setHomePicture(shop.getHomePicture()); Double wgs84 = GeodesyUtil.getDistance(longitude + "," + latitude, shop.getLongitude() + "," + shop.getLatitude()).get("WGS84"); vo.setDistance(wgs84.longValue()); verifiableShopVoList.add(vo); @@ -514,5 +574,16 @@ shopService.saveWithdrawalAccount(saveWithdrawalAccount); return R.ok(); } + + + /** + * 获取所有门店 + * @return + */ + @PostMapping("/getAllShop") + public R<List<Shop>> getAllShop(){ + List<Shop> list = shopService.list(new LambdaQueryWrapper<Shop>().eq(Shop::getDelFlag, 0).eq(Shop::getStatus, 1)); + return R.ok(list); + } } -- Gitblit v1.7.1