<?php

use App\Base\Base;
use \Validate\GoodsTccValidate;
use \App\Services\tcc\TccService;


class TccController extends Base
{
    /**
     * 下单商品 tcc try
     * @throws \App\Exception\custom\ParamException
     */
    public function place_an_order_tryAction()
    {
        (new GoodsTccValidate())->validate();

        $res = TccService::placeAnOrderTry($this->params["goods_sku_id"], $this->params["t_id"]);
        $this->success(["result"=>$res]);
    }

    /**
     * 下单商品 tcc confirm
     * @throws \App\Exception\custom\ParamException
     */
    public function place_an_order_confirmAction()
    {
        (new GoodsTccValidate())->validate();

        $res = TccService::placeAnOrderConfirm($this->params["goods_sku_id"], $this->params["t_id"]);
        $this->success(["result"=>$res]);
    }

    /**
     * 下单商品 tcc cancel
     * @throws \App\Exception\custom\ParamException
     */
    public function place_an_order_cancelAction()
    {
        (new GoodsTccValidate())->validate();

        $res = TccService::placeAnOrderCancel($this->params["goods_sku_id"], $this->params["t_id"]);
        $this->success(["result"=>$res]);
    }

    /**
     * 取消订单单 商品tcc try
     * @throws \App\Exception\custom\ParamException
     */
    public function cancel_order_tryAction()
    {
        (new GoodsTccValidate())->validate();

        $res = TccService::cancelOrderTry($this->params["goods_sku_id"], $this->params["t_id"]);
        $this->success(["result"=>$res]);
    }

    /**
     * 取消订单单 商品tcc confirm
     * @throws \App\Exception\custom\ParamException
     */
    public function cancel_order_confirmAction()
    {
        (new GoodsTccValidate())->validate();

        $res = TccService::cancelOrderConfirm($this->params["goods_sku_id"], $this->params["t_id"]);
        $this->success(["result"=>$res]);
    }

    /**
     * 取消订单单 商品tcc cancel
     * @throws \App\Exception\custom\ParamException
     */
    public function cancel_order_cancelAction()
    {
        (new GoodsTccValidate())->validate();

        $res = TccService::cancelOrderCancel($this->params["goods_sku_id"], $this->params["t_id"]);
        $this->success(["result"=>$res]);
    }

    /**
     * 判断当前tcc是否执行完成
     * @throws \App\Exception\custom\ParamException
     */
    public function tcc_is_finishAction()
    {
        (new GoodsTccValidate())->validate();

        $res = TccService::tccIsFinish($this->params["goods_sku_id"], $this->params["t_id"]);
        $this->success(["result"=>$res]);
    }
}