package com.sckw.mine.controller;

import com.sckw.core.web.response.HttpResult;
import com.sckw.mine.entity.req.CompleteOrderParam;
import com.sckw.mine.entity.req.MineOrderPageListParam;
import com.sckw.mine.entity.req.MineAddParam;
import com.sckw.mine.service.MineService;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @desc:
 * @author: Lt
 * @date: 2024-05-24
 */
@RestController
@RequestMapping("/mine")
@RequiredArgsConstructor
public class MineController {

    @Autowired
    private MineService mineService;

    /**
    * @Description: 订单新增
    * @Author: Lt
    * @Date: 2024/5/27 15:21
    */
    @PostMapping(value = "/order/add")
    public HttpResult mineOrderAdd(@RequestBody @Valid MineAddParam mineAddParam) throws Exception {
        return HttpResult.ok(mineService.mineOrderAdd(mineAddParam));
    }

    /**
    * @Description: 分页查询
    * @Author: Lt
    * @Date: 2024/5/27 15:21
    */
    @PostMapping(value = "/order/pageList")
    public HttpResult pageList(@RequestBody MineOrderPageListParam param){
        return HttpResult.ok(mineService.pageList(param));
    }

    /**
     * @Description: 订单-详情
     * @Author: Lt
     * @Date: 2024/5/8 20:03
     */
    @GetMapping("/order/detail")
    public HttpResult detail(@RequestParam("orderId") String orderId)
    {
        return HttpResult.ok(mineService.detail(orderId));
    }

    /**
     * @Description: 订单列表状态统计
     * @Author: Lt
     * @Date: 2024/5/11 15:45
     */
    @GetMapping("/order/getStatusCountListInSingleQuery")
    public HttpResult getStatusCountListInSingleQuery()
    {
        return HttpResult.ok(mineService.getStatusCountListInSingleQuery());
    }

    /**
    * @Description: 流程
    * @Author: Lt
    * @Date: 2024/5/28 11:06
    */
    @GetMapping("/order/getActionTrackByMineOrderId")
    public HttpResult getActionTrackByMineOrderId(@RequestParam("orderId") String orderId)
    {
        return HttpResult.ok(mineService.getActionTrackByMineOrderId(orderId));
    }

    /**
     * @Description: 取消订单
     * @Author: Lt
     * @Date: 2024/5/28 11:06
     */
    @PostMapping ("/order/completeOrder")
    public HttpResult completeOrder(@RequestBody @Valid CompleteOrderParam completeOrderParam)
    {
        return HttpResult.ok(mineService.completeOrder(completeOrderParam));
    }

}
