package com.dk.mdm.controller.ivt.outBound;


import com.dk.common.model.pojo.PageList;
import com.dk.common.response.ResponseResultVO;
import com.dk.common.service.BaseService;
import com.dk.mdm.model.pojo.ivt.Outbound;
import com.dk.mdm.model.query.ivt.OutboundQuery;
import com.dk.mdm.model.query.sale.OrderQuery;
import com.dk.mdm.model.response.ivt.InboundResponse;
import com.dk.mdm.model.response.ivt.OutboundResponse;
import com.dk.mdm.model.response.sale.OrderResponse;
import com.dk.mdm.model.vo.ivt.OutboundVO;
import com.dk.mdm.service.ivt.outbound.OutboundSaleOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.Map;


@Api(tags = "销售出库单API接口")
@RestController
@RequestMapping("/ivt/outbound_sale_order")
public class OutboundSaleOrderController {

    public BaseService<Outbound> getService() {
        return outboundSaleOrderService;
    }

    @Autowired
    private OutboundSaleOrderService outboundSaleOrderService;

    /**
     * @desc :  销售出库新建
     * @date : 2024/3/18 15:22
     * @author : 寇珊珊
     */
    @ApiOperation(
            value = "销售出库新建",
            notes = "销售出库新建"
    )
    @PostMapping({"outbound_insert"})
    public ResponseResultVO<?> saleOrderOutboundInsert(@Valid @RequestBody OutboundVO outboundVO) {
        return outboundSaleOrderService.saleOrderOutboundInsert(outboundVO);
    }

    /**
     * @desc : 销售出库办理
     * @date : 2024/3/18 15:22
     * @author : 寇珊珊
     */
    @ApiOperation(
            value = "销售出库办理",
            notes = "销售出库办理"
    )
    @PostMapping({"handle_outbound"})
    public ResponseResultVO<?> saleOrderHandleOutbound(@Valid @RequestBody OutboundVO outboundVO) {
        return outboundSaleOrderService.saleOrderHandleOutbound(outboundVO);
    }

    /**
     * @desc : 销售出库撤销
     * @date : 2024/3/18 15:22
     * @author : 寇珊珊
     */
    @ApiOperation(
            value = "销售出库撤销",
            notes = "销售出库撤销"
    )
    @PostMapping({"sale_order_outbound_cancel"})
    public ResponseResultVO<?> saleOrderOutboundCancel(@Valid @RequestBody OutboundVO outboundVO) {
        return outboundSaleOrderService.saleOrderOutboundCancel(outboundVO);
    }

    /**
     * @desc   : 销售出库编辑
     * @date   : 2024/3/26 9:51
     * @author : 寇珊珊
     */
    @ApiOperation(
            value = "销售出库编辑",
            notes = "销售出库编辑"
    )
    @PostMapping({"outbound_update"})
    public ResponseResultVO<?> otherOutboundUpdate(@Valid @RequestBody OutboundVO outboundVO) {
        return outboundSaleOrderService.saleOutboundUpdate(outboundVO);
    }

    /**
     * @desc   : 销售出库作废
     * @date   : 2024/3/26 9:51
     * @author : 寇珊珊
     */
    @ApiOperation(
            value = "销售出库作废",
            notes = "销售出库作废"
    )
    @PostMapping({"repeal/{id}"})
    public ResponseResultVO<?> otherOutboundRepeal(@PathVariable String id) {
        return outboundSaleOrderService.saleOutboundRepeal(id);
    }

    /********************************************** 销售出库查询相关方法begin *************************************/
    /**
     * @desc : 一览页销售出库
     * @author : 付斌
     * @date : 2023/1/9 10:36
     */
    @ApiOperation(value = "分页、关联、条件查询", notes = "分页、关联、条件查询")
    @PostMapping({"list_by"})
    public ResponseResultVO<PageList<OutboundResponse>> selectByCond(@RequestBody OutboundQuery outboundQuery) {
        return outboundSaleOrderService.selectByCond(outboundQuery);
    }

    /**
     * @desc : 一览页销售出库明细（货物、附件）
     * @author : 付斌
     * @date : 2024-03-07 16:36
     */
    @PostMapping({"select_outbound_info_by_id/{id}"})
    public ResponseResultVO<Map<String, Object>> selectOutboundInfoById(@PathVariable String id) {
        return outboundSaleOrderService.selectOutboundInfoById(id);
    }

    /**
     * @desc : 获取销售出库信息（编辑用）
     * @author : 付斌
     * @date : 2024-03-03 9:28
     */
    @ApiOperation(value = "编辑出库单", notes = "编辑出库单")
    @PostMapping({"get_outbound_for_update/{id}"})
    public ResponseResultVO<?> getOutboundForUpdate(@PathVariable String id) {
        return outboundSaleOrderService.getOutboundForUpdate(id);
    }

    /**
     * @desc : 获取销售出库信息（编辑用，适用于直接新建的出库单）
     * @author : 付斌
     * @date : 2024-03-03 9:28
     */
    @ApiOperation(value = "编辑出库单", notes = "编辑出库单")
    @PostMapping({"get_outbound_together_for_update/{id}"})
    public ResponseResultVO<?> getOutboundTogetherForUpdate(@PathVariable String id) {
        return outboundSaleOrderService.getOutboundTogetherForUpdate(id);
    }

    /**
     * @desc : 获取销售出库信息（新建退货用）
     * @author : 付斌
     * @date : 2024-03-03 9:28
     */
    @ApiOperation(value = "编辑出库单", notes = "编辑出库单")
    @PostMapping({"get_out_for_return/{id}"})
    public ResponseResultVO<?> getOutForReturn(@PathVariable String id) {
        return outboundSaleOrderService.getOutForReturn(id);
    }

    /**
     * @desc : 查询出库明细（货物、附件）
     * @author : 付斌
     * @date : 2024/3/6 10:36
     */
    @PostMapping({"/{id}"})
    public ResponseResultVO selectById(@PathVariable String id) {
        return outboundSaleOrderService.selectById(id);
    }
    /********************************************** 销售出库查询相关方法end *************************************/


//    /**
//     * @desc : 条件查询
//     * @date : 2024/3/18 15:23
//     * @author : 寇珊珊
//     */
//    @ApiOperation(value = "条件查询", notes = "条件查询")
//    @PostMapping({"list_by"})
//    public ResponseResultVO<PageList<InboundResponse>> selectByCond(@RequestBody OutboundQuery outboundQuery) {
//        return outboundSaleOrderService.selectByCond(outboundQuery);
//    }
//
//    /**
//     * @desc : 明细信息条件查询
//     * @date : 2024/3/18 15:23
//     * @author : 寇珊珊
//     */
//    @ApiOperation(value = "明细信息条件查询", notes = "明细信息条件查询")
//    @PostMapping({"select_item_info_by_id/{id}"})
//    public ResponseResultVO<Map<String, Object>> selectOutBoundSaleOrderItemInfoById(@PathVariable String id) {
//        return outboundSaleOrderService.selectOutBoundSaleOrderItemInfoById(id);
//    }
//    /**
//     * @desc : 获取单据信息（编辑用）
//     * @date : 2024/3/18 15:22
//     * @author : 寇珊珊
//     */
//    @ApiOperation(value = "获取单据信息（编辑用）", notes = "获取单据信息（编辑用）")
//    @PostMapping({"select_by_update/{id}"})
//    public ResponseResultVO<?> selectByUpdate(@PathVariable String id) {
//        return outboundSaleOrderService.selectByUpdate(id);
//    }
    /**
     * @desc : 条件查询(总单带明细)
     * @author : 于继渤
     * @date : 2023/1/9 10:36
     */
    @ApiOperation(value = "分页、关联、条件查询", notes = "分页、关联、条件查询")
    @PostMapping({"select_by_cond_detail"})
    public ResponseResultVO<PageList<OutboundResponse>> selectByCondDetail(@RequestBody OutboundQuery outboundQuery) {
        return outboundSaleOrderService.selectByCondDetail(outboundQuery);
    }
}
