package com.fjhx.victoriatourist.controller.jd;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.victoriatourist.entity.jd.dto.JdOrderDto;
import com.fjhx.victoriatourist.entity.jd.dto.JdOrderSelectDto;
import com.fjhx.victoriatourist.entity.jd.po.JdOrder;
import com.fjhx.victoriatourist.entity.jd.vo.JdOrderVo;
import com.fjhx.victoriatourist.entity.stock.dto.StockTransferDto;
import com.fjhx.victoriatourist.service.jd.JdOrderService;
import com.ruoyi.common.core.domain.BaseSelectDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;


/**
 * <p>
 * 京东订单 前端控制器
 * </p>
 *
 * @author
 * @since 2023-04-20
 */
@RestController
@RequestMapping("/jdOrder")
public class JdOrderController {

    @Autowired
    private JdOrderService jdOrderService;

    /**
     * 京东订单分页
     */
    @PostMapping("/page")
    public Page<JdOrderVo> page(@RequestBody JdOrderSelectDto dto) {
        return jdOrderService.getPage(dto);
    }

    /**
     * 京东订单接收分页
     */
    @PostMapping("/receivePage")
    public Page<JdOrderVo> receivePage(@RequestBody JdOrderSelectDto dto) {
        return jdOrderService.receivePage(dto);
    }

    /**
     * 京东订单明细
     */
    @PostMapping("/detail")
    public JdOrderVo detail(@RequestBody BaseSelectDto dto) {
        return jdOrderService.detail(dto.getId());
    }

    /**
     * 京东订单新增
     */
    @PostMapping("/add")
    public void add(@Validated @RequestBody JdOrderDto jdOrderDto) {
        jdOrderService.add(jdOrderDto);
    }

    /**
     * 获取配送中心
     */
    @PostMapping("/getDistributionCenter")
    public List<String> getDistributionCenter() {
        return jdOrderService.getDistinctList(JdOrder::getDistributionCenter);
    }

    /**
     * excel导入
     */
    @PostMapping("/excelImport")
    public void excelImport(@RequestParam("file") MultipartFile file, @RequestParam("customerId") Long customerId) {
        jdOrderService.excelImport(file, customerId);
    }

    /**
     * 京东订单出库
     */
    @PostMapping("/outbound")
    public void outbound(@RequestBody JdOrderDto jdOrderDto) {
        jdOrderService.outbound(jdOrderDto);
    }

    /**
     * 京东订单接收
     */
    @PostMapping("/receive")
    public void outbound(@RequestBody StockTransferDto stockTransferDto) {
        jdOrderService.receive(stockTransferDto);
    }

}
