package com.yami.shop.platform.controller;

import com.yami.shop.bean.param.ItemQueryDto;
import com.yami.shop.bean.param.OrderDto;
import com.yami.shop.bean.param.StoreDto;
import com.yami.shop.bean.vo.GoodsItemPageVo;
import com.yami.shop.bean.vo.StoreDetailVo;
import com.yami.shop.bean.vo.StoreListVo;
import com.yami.shop.service.IQnhService;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import com.yami.shop.common.util.R;
/**
 * 千牛汇管理实现
 *
 * @author wy
 * @version 1.0.0
 * @since 2025-01-01
 */
@RestController
@RequestMapping("/qnh")
public class QnhController {

    @Resource
    private IQnhService qnhService;

    @ApiOperation("查询所有门店")
    @PostMapping("/getStores")
    public R<List<StoreListVo>> getStores(@RequestBody StoreDto dto) {
        return R.SUCCESS(qnhService.getStores(dto));
    }

    @ApiOperation("查询门店详情")
    @PostMapping("/queryStore")
    public R<StoreDetailVo> queryStore(@RequestParam("regionCode") String regionCode,
                                                          @RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
                                                          @RequestParam(value = "pageSize", defaultValue = "20") Integer pageSize) {
        return R.SUCCESS(qnhService.queryStore(regionCode, pageNo, pageSize));
    }

    @ApiOperation("查询门店商品列表")
    @PostMapping("/itemQuery")
    public R<GoodsItemPageVo> itemQuery(@RequestBody ItemQueryDto dto) {
        return R.SUCCESS(qnhService.itemQuery(dto));
    }

    @ApiOperation("下单")
    @PostMapping("/addOrder")
    public R<String> addOrder(@RequestBody OrderDto dto) {
        return R.SUCCESS(qnhService.addOrder(dto));
    }

    @ApiOperation("syncShop")
    @GetMapping("/syncShop")
    public R<Boolean> syncShop() {
        qnhService.syncShop(null);
        return R.SUCCESS(Boolean.TRUE);
    }

    @ApiOperation("syncGoods")
    @GetMapping("/syncGoods")
    public R<Boolean> syncGoods() {
        qnhService.syncGoods(null);
        return R.SUCCESS(Boolean.TRUE);
    }

    @ApiOperation("获取门店")
    @GetMapping("/getDetailShop")
    public R<Map<String,String>> getDetailShop(@RequestParam(value = "name", required = false) String name) {
        return R.SUCCESS(qnhService.getDetailShop(name));
    }
}
