package com.kxs.store.biz.controller.kxsapp;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kxs.common.core.util.R;
import com.kxs.store.api.dto.kxsapp.storeOrder.*;
import com.kxs.store.api.model.KxsMachineApply;
import com.kxs.store.api.vo.kxsapp.storeOrder.OrderMonthTotalDetailVO;
import com.kxs.store.api.vo.kxsapp.storeOrder.StoreOrderListVO;
import com.kxs.store.api.vo.kxsapp.storeOrder.OrderMonthTotalVO;
import com.kxs.store.biz.service.KxsMachineApplyService;
import com.kxs.store.biz.service.KxsSendTotalService;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.web.bind.annotation.*;

/**
 * 仓库模块(StoreOrder)控制层
 *
 * @author 系统
 * @since 2024-01-08 11:15:03
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("storeOrder")
public class StoreOrderController {

    /**
     * 服务对象
     */
    private final KxsMachineApplyService kxsMachineApplyService;

    private final KxsSendTotalService kxsSendTotalService;


    /**
     * 订单管理-划拨
     *
     * @param param 实体对象
     * @return 订单管理-划拨
     */
    @PostMapping("/storeOrderTransferUser")
    public R storeOrderTransferUser(@Valid @RequestBody StoreOrderTransferUserDTO param) {

        return kxsMachineApplyService.storeOrderTransferUser(param);
    }

    /**
     * 订单管理-订单列表
     *
     * @param page 分页对象
     * @param param 查询实体
     * @return 订单管理-订单列表
     */
    @GetMapping("/storeOrderList")
    public R storeOrderList(@ParameterObject Page<StoreOrderListVO> page, @Valid @ParameterObject StoreOrderListDTO param) {

        return R.ok(kxsMachineApplyService.getByPage(page, param));
    }


    /**
     * 订单管理-未发货订单详情
     *
     * @param id 主键ID
     * @return 订单管理-未发货订单详情
     */
    @GetMapping("/storeOrderDetail")
    public R storeOrderDetail(@RequestParam("id") Integer id) {

        return R.ok(kxsMachineApplyService.storeOrderDetail(id));
    }



    /**
     * 订单管理-驳回订单
     *
     * @param param 实体对象
     * @return 订单管理-驳回订单
     */
    @PostMapping("/orderCancel")
    public R orderCancel(@RequestBody KxsMachineApply param) {

        return kxsMachineApplyService.orderCancel(param);
    }


    /**
     * 订单管理-发货统计
     *
     * @param page 分页对象
     * @param param 查询实体
     * @return 订单管理-发货统计
     */
    @GetMapping("/orderMonthTotal")
    public R orderMonthTotal(@ParameterObject Page<OrderMonthTotalVO> page, @Valid @ParameterObject OrderMonthTotalDTO param) {

        return R.ok(kxsSendTotalService.orderMonthTotal(page, param));
    }


    /**
     * 订单管理-发货统计明细
     *
     * @param page 分页对象
     * @return 订单管理-发货统计明细
     */
    @GetMapping("/orderMonthTotalDetail")
    public R orderMonthTotalDetail(@ParameterObject Page<OrderMonthTotalDetailVO> page, @Valid @ParameterObject OrderMonthTotalDetailDTO param) {

        return R.ok(kxsSendTotalService.orderMonthTotalDetail(page, param));
    }


}

