huliguo
2025-04-11 f103ac7bc4f2fbb20a0f2dd3ed97b0ac7fc5f46d
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopController.java
@@ -541,8 +541,8 @@
    @GetMapping("/shopDetail")
    @ApiOperation(value = "门店详情", tags = {"小程序-首页"})
    public R<ShopDetailVO> shopDetail(@ApiParam("门店id") @RequestParam Integer shopId,
                                      @ApiParam("经度") @RequestParam BigDecimal longitude,
                                      @ApiParam("纬度") @RequestParam BigDecimal latitude) {
                                      @ApiParam("经度") @RequestParam(required = false) BigDecimal longitude,
                                      @ApiParam("纬度") @RequestParam(required = false)  BigDecimal latitude) {
        return R.ok(shopService.getShopDetail(shopId, longitude, latitude));
    }
@@ -665,16 +665,22 @@
    @ResponseBody
    @GetMapping("/getSysUserShop")
    @ApiOperation(value = "获取可切换的门店列表", tags = {"门店后台-首页"})
    public R<List<VerifiableShopVo>> getSysUserShop(@ApiParam("经度") @RequestParam BigDecimal longitude,
                                                    @ApiParam("纬度") @RequestParam BigDecimal latitude){
    public R<List<VerifiableShopVo>> getSysUserShop(@ApiParam("经度") @RequestParam(required = false) BigDecimal longitude,
                                                    @ApiParam("纬度") @RequestParam(required = false) BigDecimal latitude){
        Long userid = tokenService.getLoginUser().getUserid();
        UserShop userShop = new UserShop();
        userShop.setUserId(userid);
        List<UserShop> data = userShopClient.getUserShop(userShop).getData();
        if (null == data || data.isEmpty()) {
            return R.ok();
        }
        List<Integer> collect = data.stream().map(UserShop::getShopId).collect(Collectors.toList());
        List<Shop> shops = shopService.list(new LambdaQueryWrapper<Shop>()
                .in(!CollectionUtils.isEmpty(collect),Shop::getId, collect)
                .eq(Shop::getDelFlag, 0).eq(Shop::getStatus, 1));
        if (shops == null || shops.isEmpty()) {
            return  R.ok();
        }
        List<VerifiableShopVo> list = new ArrayList<>();
        for (Shop shop : shops) {
            VerifiableShopVo vo = new VerifiableShopVo();
@@ -770,9 +776,8 @@
     */
    @PostMapping("/addGoods")
    @ApiOperation(value = "发布商品", tags = {"门店后台-商品管理"})
    public R<Void> addGoods(@RequestBody AddGoodsDTO addGoodsDTO) {
        shopService.addGoodsByShop(addGoodsDTO);
        return R.ok();
    public R<Integer> addGoods(@RequestBody AddGoodsDTO addGoodsDTO) {
        return R.ok( shopService.addGoodsByShop(addGoodsDTO));
    }
    /**
@@ -787,7 +792,6 @@
        }
        goodsService.update(new UpdateWrapper<Goods>()
                .setSql("status = CASE status WHEN 1 THEN 2 WHEN 2 THEN 1 ELSE status END")
                .set("update_time", LocalDateTime.now())
                .eq("id", goodsId));
        return R.ok();
    }
@@ -796,13 +800,15 @@
     * 删除商品
     */
    @DeleteMapping("/del/{goodsId}")
    @ApiOperation(value = "发布商品", tags = {"门店后台-商品管理"})
    public R<Void> addGoods(@PathVariable Integer goodsId) {
        Goods goods = goodsService.getById(goodsId);
    @ApiOperation(value = "删除商品", tags = {"门店后台-商品管理"})
    public R<Void> delGoods(@PathVariable Integer goodsId) {
        Goods goods = goodsService.getOne(new LambdaQueryWrapper<Goods>().eq(Goods::getId, goodsId)
                .eq(Goods::getStatus, 2).eq(Goods::getDelFlag,0));
        if (goods == null) {
            return R.fail("商品不存在");
        }
        goodsService.removeById(goodsId);
        goodsService.update(new LambdaUpdateWrapper<Goods>().eq(Goods::getId, goodsId).set(Goods::getDelFlag,1));
        return R.ok();
    }