package com.kym.admin.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.kym.common.R;
import com.kym.common.annotation.SysLog;
import com.kym.common.controller.IController;
import com.kym.entity.WashDevice;
import com.kym.entity.queryParams.WashOrderQueryParams;
import com.kym.service.WashOrderService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 洗车订单表 后台控制器
 * </p>
 *
 * @author skyline
 * @since 2024-09-11
 */
@RestController
@RequestMapping("/washOrder")
public class WashOrderController extends IController {

    private final WashOrderService washOrderService;

    public WashOrderController(WashOrderService washOrderService) {
        this.washOrderService = washOrderService;
    }


    /**
     * 获取订单列表
     *
     * @param query
     * @return
     */
    @SaCheckPermission("washOrder.list")
    @PostMapping(value = "/list")
    R<?> list(@RequestBody WashOrderQueryParams query) {
        return resp(() -> washOrderService.list(query));
    }


    /**
     * 获取订单详情
     * 注意：此接口接收订单号（orderId），而不是主键ID
     *
     * @param orderId 订单号
     * @return 订单详情
     */
    @SaCheckPermission("washOrder.list")
    @SysLog("详情")
    @GetMapping("detail/{orderId}")
    R<?> detail(@PathVariable String orderId) {
        return R.success(washOrderService.detail(orderId));
    }

    /**
     * 强制结算订单（订单维度）
     *
     * @param orderId 订单号
     */
    @SaCheckPermission("washOrder.modify")
    @SysLog("强制结算")
    @PostMapping("/forceSettle/{orderId}")
    R<?> forceSettle(@PathVariable String orderId) {
        washOrderService.forceSettleOrder(orderId);
        return R.success();
    }


}
