<?php

$audit = array
(
    1 => '审核通过',
    2 => '拒绝',
);

$status = array
(
    1 => '初审',
    2 => '终审',
    3 => '权益发放',
    4 => '已完成',
);

$type = array
(
    1 => '支付已确认',
    2 => '权益已确认发放',
    3 => '分润已确认发放',
    //4 => '期权已确认发放',
    5 => '代理合同已生成',
);

$cstatus = array
(
    1 => '不拆分',
    2 => '拆分',
);

$status_value = Dever::input('status', 1);
$audit_desc = '';
if ($status_value == 1) {
    $audit_desc = '需确认代理商信息无误则通过审核。审核通过后,需确认支付金额是否拆分。';
} elseif ($status_value == 2) {
    $audit_desc = '现行确认是否已到账,未确认到账时,无法发放权益等操作。';
}
$prize_type = array
(
    1 => '非赠送区域',
    2 => '赠送区域,会自动扣减已有名额',
);

return array
(
    # 表名
    'name' => 'order_process',
    # 显示给用户看的名称
    'lang' => '订单审核进度表',
    'menu' => false,
    'status' => $status,
    'start' => array
    (
        'insert' => 'agent/lib/manage.orderStartUpdate',
        'update' => 'agent/lib/manage.orderStartUpdate',
    ),
    'end' => array
    (
        'insert' => 'agent/lib/manage.orderUpdate',
        'update' => 'agent/lib/manage.orderUpdate',
    ),
    # 数据结构
    'struct' => array
    (
    
        'id'        => array
        (
            'type'      => 'int-11',
            'name'      => 'ID',
            'default'   => '',
            'desc'      => '',
            'match'     => 'is_numeric',
            'search'    => 'order',
            'update'    => 'hidden',
            //'list'        => true,
        ),

        'order_id'      => array
        (
            'type'      => 'int-11',
            'name'      => '订单表id',
            'default'   => '',
            'desc'      => '订单表id',
            'match'     => 'is_numeric',
            'update'    => 'hidden',
            'value'     => Dever::input('order_id', 1),
        ),

        'status'        => array
        (
            'type'      => 'int-11',
            'name'      => '状态',
            'default'   => '1',
            'desc'      => '状态',
            'match'     => 'is_numeric',
            'update'  	=> 'hidden',
            'option'    => $status,
            'search'    => 'select',
            'value'     => $status_value,
            'control'	=> 'status',
        ),

        'audit'        => array
        (
            'type'      => 'int-11',
            'name'      => '审核状态-' . $audit_desc,
            'default'   => '1',
            'desc'      => '审核状态',
            'match'     => 'is_numeric',
            'update'    => 'radio',
            'option'    => $audit,
            'search'    => 'select',
            'control'   => 'audit',
        ),

        'prize_type'      => array
        (
            'type'      => 'tinyint-1',
            'name'      => '是否赠送区域-当出现此选项时,代表代理商有免费赠送的区域名额,当选择赠送区域时,会自动扣减当前代理商已有的名额,并且会将实付金额强制改为0元',
            'default'   => '1',
            'desc'      => '是否赠送区域',
            'match'     => 'is_numeric',
            'update'    => 'radio',
            'option'    => $prize_type,
            'control'   => 'prize_type',
            'show'      => 'audit=1',
        ),

        'price'      => array
        (
            'type'      => 'decimal-11,2',
            'name'      => '实付金额',
            'default'   => '0',
            'desc'      => '金额',
            'match'     => 'option',
            'update'    => 'text',
            'const'     => Dever::input('price'),
            'list'      => true,
            'show'      => 'prize_type=1&audit=1',
        ),

        'cstatus'        => array
        (
            'type'      => 'tinyint-1',
            'name'      => '是否拆分代理费-选择拆分后,将代理费拆为代理费和软件服务费',
            'default'   => '1',
            'desc'      => '是否拆分代理费',
            'match'     => 'is_numeric',
            'update'    => 'radio',
            'option'    => $cstatus,
            'show'      => 'audit=1',
            'control'   => 'cstatus',
        ),

        'soft_price'      => array
        (
            'type'      => 'decimal-11,2',
            'name'      => '软件服务费',
            'default'   => '0',
            'desc'      => '金额',
            'match'     => 'option',
            'update'    => 'text',
            'const'     => Dever::input('soft_price', '0'),
            'show'      => 'cstatus=2',
        ),

        'option_price'      => array
        (
            'type'      => 'decimal-11,2',
            'name'      => '赠送期权价值',
            'default'   => '0',
            'desc'      => '金额',
            'match'     => 'option',
            'update'    => 'text',
            'const'     => Dever::input('option_price', '0'),
            'show'      => 'audit=1',
            'list'      => true,
        ),

        'desc'      => array
        (
            'type'      => 'varchar-400',
            'name'      => '备注',
            'default'   => '',
            'desc'      => '备注',
            'match'     => 'is_string',
            'update'    => 'textarea',
            'search'    => 'fulltext',
            'list'      => true,
            'show'		=> 'type=1,2&audit=2',
        ),

        'type'        => array
        (
            'type'      => 'varchar-400',
            'name'      => '权益发放情况',
            'default'   => '1',
            'desc'      => '权益发放情况',
            'match'     => 'option',
            'update'  	=> 'checkbox',
            'checkall'  => 1,
            'disabled'  => 1,
            'option'    => $type,
            'search'    => 'select',
            'show'		=> 'type=3',
        ),

        'admin'     => array
        (
            'type'      => 'int-11',
            'name'      => '操作人',
            'default'   => '',
            'match'     => 'is_numeric',
            'desc'      => '操作人',
            //'list'      => '"{admin}" > 0 ? Dever::load("manage/admin-find#username", {admin}) : "-"',
            'list_order'  => 8,
        ),

        'state'     => array
        (
            'type'      => 'tinyint-1',
            'name'      => '状态',
            'default'   => '1',
            'desc'      => '请选择状态',
            'match'     => 'is_numeric',
        ),
        
        'cdate'     => array
        (
            'type'      => 'int-11',
            'name'      => '创建时间',
            'match'     => array('is_numeric', time()),
            'desc'      => '',
            # 只有insert时才生效
            //'insert'    => true,
            'search'    => 'date',
            'list'      => 'date("Y-m-d H:i:s", {cdate})',
        ),
    ),

    'alter' => array
    (
        10 => array
        (
            array('update', 'price', 'price', 'decimal-11,2 0 实付金额'),
            array('update', 'soft_cash', 'soft_cash', 'decimal-11,2 0 软件服务费'),
            array('update', 'option_price', 'option_price', 'decimal-11,2 0 赠送期权价值'),
        ),
        'version' => 10,
    ),

    'manage' => array
    (
        'insert' => false,
        'delete' => false,
        'page_list' => 'order_process',
    ),

    'request' => array
    (
        'getData' => array
        (
            # 匹配的正则或函数 选填项
            'option' => array
            (
                'order_id' => 'yes',
                'state' => 1,
            ),
            'type' => 'all',
            'order' => array('status' => 'asc', 'cdate' => 'asc'),
            'col' => '*|status',
        ),
    ),
);