<?php
$api_id = Dever::input('set')['api_id'] ?? 0;
return array
(
    'source' => 'collect/api_service',
    'list' => array
    (
        'where' => array('api_id' => $api_id),
        'field'      => array
        (
            'id',
            //'name',
            'type',
            'uri',
        ),
        'data_button' => array
        (
            '编辑' => 'edit',
        ),
        'button' => array
        (
            //'新增' => 'add',
        ),
        'search' => array
        (
            //'name',
            'api_id' => 'hidden',
            'type',
        ),
    ),
    'update' => array
    (
        'tab' => array
        (
            '基本设置' => 'type,sign_col,uri,collect/api_service_uri',
            '请求参数' => 'method,post_method,collect/api_service_request_body,collect/api_service_request_header',
            '响应参数' => 'collect/api_service_response',
            '回调设置' => 'notify_type,notify_success,notify_error,collect/api_service_notify_code',
        ),
        'field'    => array
        (
            'name',
            'type' => array
            (
                'type' => 'radio',
                //'control' => true,
            ),
            'sign_col' => array
            (
                'desc' => '按顺序做加密，用+号隔开，为空则所有字段均参与加密，这里填写后，将替换规则中的加密参数',
            ),
            'uri',
            'collect/api_service_uri' => array
            (
                'name' => '接口地址生成',
                'where'  => array('api_service_id' => 'id'),
                'desc' => '如果需要动态生成接口地址，这里填写参数即可，同样支持变量',
            ),

            'method' => array
            (
                'type' => 'radio',
                'control' => true,
            ),
            'post_method' => array
            (
                'type' => 'radio',
                'show' => false,
            ),
            'collect/api_service_request_body' => array
            (
                'name' => '业务请求体',
                'where'  => array('api_service_id' => 'id'),
                'desc' => '[变量：timestamp毫秒时间戳，nonce随机值，appkey渠道的appkey， notify请求回调地址, order_num当前订单号，account当前账号，cash为当前面值，code渠道商品编码，支持函数，如果函数中需要添加变量，请用{}隔开，如{code}，请求头也支持此变量]',
            ),
            'collect/api_service_request_header' => array
            (
                'name' => '业务请求头',
                'where'  => array('api_service_id' => 'id'),
            ),

            'collect/api_service_response' => array
            (
                'name' => '业务响应参数',
                'desc' => '选填，也可以只填写重要响应参数',
                'where'  => array('api_service_id' => 'id'),
            ),

            'notify_type' => array
            (
                'type' => 'radio',
                'control' => true,
            ),
            'notify_success' => array
            (
                'desc' => '填写回调成功后，返回给渠道的信息',
            ),
            'notify_error' => array
            (
                'desc' => '填写回调失败后，返回给渠道的信息，如果填写500，则会返回HTTP Status Code 500，默认返回HTTP Status Code 200',
            ),
            'notify_sign_col' => array
            (
                'desc' => '回调签名参数，不填写则使用接口的回调签名参数',
            ),
            'collect/api_service_notify_code' => array
            (
                'name' => '回调状态码',
                'where'  => array('api_service_id' => 'id'),
            ),
        ),

        'control' => array
        (
            'post_method' => array
            (
                'method' => 2,
            ),
            'notify_success' => array
            (
                'notify_type' => 1,
            ),
            'notify_error' => array
            (
                'notify_type' => 1,
            ),
            'collect/api_service_notify_code' => array
            (
                'notify_type' => 1,
            ),
            /*
            'collect/api_service_notify' => array
            (
                'notify_type' => 1,
            ),*/
        ),
    ),
);