OrderAftersale.php 3.8 KB
<?php

namespace app\api\controller;

/**
 * 售后接口
 */
class OrderAftersale extends Base
{

    protected $noNeedLogin = [];
    protected $noNeedRight = ['*'];

    /**
     * @ApiWeigh    (99)
     * @ApiTitle    (售后列表)
     * @ApiSummary  (售后列表)
     * @ApiMethod   (GET)
     *
     * @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
     * @ApiParams (name=type, type=string, required=false, description="售后类型:all=全部")
     *
     * @ApiReturn()
     */
    public function index()
    {
        $params = $this->request->get();

        $this->success('售后列表', \addons\shopro\model\OrderAftersale::getList($params));
    }

    /**
     * @ApiWeigh    (97)
     * @ApiTitle    (详情)
     * @ApiSummary  (详情)
     * @ApiMethod   (GET)
     *
     * @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
     * @ApiParams (name=id, type=inter, required=true, description="售后ID")
     *
     * @ApiReturn()
     */
    public function detail()
    {
        $params = $this->request->get();

        $this->shoproValidate($params, get_class(), 'detail');

        $data = \addons\shopro\model\OrderAftersale::detail($params);
        // 处理售后时间
        foreach ($data['logs'] as $v){
            $v->createtime = date('Y-m-d H:i:s',$v->createtime);
        }

        $this->success('售后详情', $data);
    }

    /**
     * @ApiWeigh    (95)
     * @ApiTitle    (申请售后)
     * @ApiSummary  (申请售后)
     * @ApiMethod   (POST)
     *
     * @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
     * @ApiParams (name=type, type=string, required=true, description="类型:refund=退款,return=退货,other=其他")
     * @ApiParams (name=order_id, type=inter, required=true, description="订单ID")
     * @ApiParams (name=order_item_id, type=inter, required=true, description="订单商品ID")
     * @ApiParams (name=phone, type=string, required=true, description="联系方式")
     * @ApiParams (name=reason, type=string, required=false, description="售后原因")
     * @ApiParams (name=content, type=string, required=false, description="售后原因内容")
     * @ApiParams (name=images, type=string, required=false, description="售后图片,数组")
     *
     * @ApiReturn()
     */
    public function aftersale()
    {
        $params = $this->request->post();

        // 表单验证
        $this->shoproValidate($params, get_class(), 'aftersale');

        $this->success('申请成功', \addons\shopro\model\OrderAftersale::aftersale($params));
    }

    /**
     * @ApiWeigh    (93)
     * @ApiTitle    (取消售后单)
     * @ApiSummary  (取消售后单)
     * @ApiMethod   (POST)
     *
     * @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
     * @ApiParams (name=id, type=inter, required=true, description="售后ID")
     *
     * @ApiReturn()
     */
    public function cancel()
    {
        $params = $this->request->post();

        // 表单验证
        $this->shoproValidate($params, get_class(), 'cancel');

        $this->success('取消成功', \addons\shopro\model\OrderAftersale::operCancel($params));
    }

    /**
     * @ApiWeigh    (91)
     * @ApiTitle    (删除售后单)
     * @ApiSummary  (删除售后单)
     * @ApiMethod   (POST)
     *
     * @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
     * @ApiParams (name=id, type=inter, required=true, description="售后ID")
     *
     * @ApiReturn()
     */
    public function delete()
    {
        $params = $this->request->post();

        // 表单验证
        $this->shoproValidate($params, get_class(), 'delete');

        $this->success('删除成功', \addons\shopro\model\OrderAftersale::operDelete($params));
    }

}