<?php

namespace  App\Http\Requests\OpenWork\Corp;

use App\Http\Requests\BaseRequest;
use Illuminate\Validation\Rule;

/**
 * 订单管理
 *
 * */
class LicenseClient extends BaseRequest
{

    /**
     *
     * @return  array
     */
    public  function  rules()
    {
        // 规则
        return [
            'buyer_userid'         => 'required',
            'corpid'              => 'required',
            'base_count'          => 'required|integer',
            'external_contact_count'  => 'required|integer',
            'months'              => 'required|integer|gt:0',
            'days'                => 'required|integer|gt:0',
            'account_list'        => 'required|array',
            'account_list.*.userid'  => 'required|string',
            'account_list.*.type'  => 'required|string',
            'order_id'      => 'required|string',
            'payer_userid' => 'required|string',
            'jobid' => 'required|string',
            'id' => 'required|integer',
        ];
    }

    // 场景列表
    protected   $scenes         = [
        'create'                      => ['corpid','base_count','external_contact_count','months'],
        'renew'                      => ['corpid','account_list'],
        'cancel'                      => ['corpid','order_id'],
        'use_balance_pay'             => ['corpid','order_id','payer_userid'],
        'get_order_info'              =>['order_id'],
        'create_renew_order'        =>['months','jobid'],
        'renew_account_info'         =>['corpid','id'],
        'renew_account_list'         =>['corpid'],
        'get_paycode_url'            =>['corpid','order_id'],
    ];

    /**
     *
     * @return  array
     */
    public  function  messages()
    {
        return [
            'corpid.required'     =>'授权方corpid不能为空',
            'buyer_userid.required'     =>'请输入购买者账号',
            'base_count.required'     =>'基础账号个数不能为空',
            'external_contact_count.required'     =>'互通账号个数不能为空',
            'months.required'     =>'月数不能为空',
            'days.required'     =>'天数不能为空',
            'account_list.required'     =>'请选择授权账号',
            'account_list.array'     =>'授权账号格式错误,必须是数组',
            'account_list.*.userid.required'     =>'授权账号不能为空',
            'account_list.*.type.required'     =>'授权账号类型不能为空',
            'order_id.required'     =>'订单号不能为空',
            'payer_userid.required'     =>'付款人账号不能为空',
            'jobid.required'     =>'任务工单号不能为空',
            'id.required'     =>'id不能为空',
        ];
    }
}
