puzhibing
2025-01-07 eb5d7885fa9e4bd20c0827eec9b4cdd48c47b509
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopController.java
@@ -12,14 +12,19 @@
import com.ruoyi.common.security.service.TokenService;
import com.ruoyi.common.security.utils.SecurityUtils;
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;
import com.ruoyi.other.util.tencentMap.TencentMapUtil;
import com.ruoyi.other.vo.NearbyShopVO;
import com.ruoyi.other.vo.SaveWithdrawalAccount;
import com.ruoyi.other.vo.ShopDetailVO;
import com.ruoyi.other.vo.ShopStatistics;
import com.ruoyi.system.api.domain.SysUser;
@@ -68,6 +73,10 @@
    private UserShopClient userShopClient;
    @Resource
    private AppUserShopClient appUserShopClient;
    @Resource
    private GoodsService goodsService;
    @Resource
    private GoodsShopService goodsShopService;
@@ -126,6 +135,7 @@
                userShop.setUserId(sysUser.getUserId());
                userShop.setShopId(shop.getId());
                userShop.setRoleType(1);
                userShop.setRoleId(2L);
                userShopClient.saveUserShop(userShop);
            }
        }else{
@@ -149,6 +159,7 @@
            userShop.setUserId(userId);
            userShop.setShopId(shop.getId());
            userShop.setRoleType(1);
            userShop.setRoleId(2L);
            userShopClient.saveUserShop(userShop);
        }
        return R.ok();
@@ -242,6 +253,7 @@
                userShop.setUserId(sysUser.getUserId());
                userShop.setShopId(shop.getId());
                userShop.setRoleType(1);
                userShop.setRoleId(2L);
                userShopClient.saveUserShop(userShop);
            }
        }else{
@@ -265,10 +277,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 = {"管理后台-门店管理"})
@@ -405,7 +434,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);
    }
    
@@ -461,15 +490,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);
@@ -504,5 +549,14 @@
        }
        return R.ok(list);
    }
    @PostMapping("/saveWithdrawalAccount")
    @ApiOperation(value = "保存提现账户", tags = {"门店后台-财务统计-提现明细"})
    public R saveWithdrawalAccount(SaveWithdrawalAccount saveWithdrawalAccount) {
        shopService.saveWithdrawalAccount(saveWithdrawalAccount);
        return R.ok();
    }
}