<?php

$status = array
(
    1 => '正常',
    2 => '申请退款中',
    3 => '已取消',
);

return array
(
    # 表名
    'name' => 'dh_order_goods',
    # 显示给用户看的名称
    'lang' => '订单商品表',
    'menu' => false,
    'status' => $status,
    # 数据结构
    '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',
        ),

        'shop_id'      => array
        (
            'type'      => 'int-11',
            'name'      => '门店名称',
            'default'   => '',
            'desc'      => '门店名称',
            'match'     => 'is_numeric',
        ),

        'mid'      => array
        (
            'type'      => 'int-11',
            'name'      => '代理商姓名/手机号',
            'default'   => '-1',
            'desc'      => '代理商',
            'match'     => 'is_string',
            'update'    => 'text',
        ),

        // 'shop_id'      => array
        // (
        //     'type'      => 'int-11',
        //     'name'      => '门店名称',
        //     'default'   => '',
        //     'desc'      => '门店名称',
        //     'match'     => 'is_numeric',
        // ),

        'goods_id'      => array
        (
            'type'      => 'int-11',
            'name'      => '商品名称',
            'default'   => '',
            'desc'      => '商品名称',
            'match'     => 'is_numeric',
            'list'      => 'Dever::load("goods/info-find#name", {goods_id})',
        ),

        'sku_id'      => array
        (
            'type'      => 'int-11',
            'name'      => 'sku_id',
            'default'   => '-1',
            'desc'      => 'sku_id',
            'match'     => 'is_numeric',
        ),

        'price'      => array
        (
            'type'      => 'varchar-50',
            'name'      => '单价',
            'default'   => '',
            'desc'      => '单价',
            'match'     => 'option',
            'update'    => 'text',
            'list'        => true,
        ),

        'num'        => array
        (
            'type'      => 'int-11',
            'name'      => '购买数量',
            'default'   => '',
            'desc'      => '购买数量',
            'match'     => 'is_numeric',
            'search'    => 'select',
            'list'        => true,
        ),

        'status'        => array
        (
            'type'      => 'int-11',
            'name'      => '状态',
            'default'   => '1',
            'desc'      => '状态',
            'match'     => 'is_numeric',
            //'update'  => 'select',
            'option'    => $status,
            'search'    => 'select',
            'list'      => true,
            'edit'      => true,
        ),

        '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})',
        ),
    ),

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

    'request' => array
    (
        # 获取单条数据
        'getIds' => array
        (
            # 匹配的正则或函数 选填项
            'option' => array
            (
                'uid' => 'yes',
                'shop_id' => 'yes',
                'order_id' => 'yes',
                'status' => 1,
                'state' => 1,
            ),
            'type' => 'all',
            'col' => '*|id',
        ),

        # 获取多条数据
        'getDataByIds' => array
        (
            # 匹配的正则或函数 选填项
            'option' => array
            (
                'ids' => array('yes-id', 'in'),
                'uid' => 'yes',
                'shop_id' => 'yes',
                'order_id' => 'yes',
                'state' => 1,
            ),
            'type' => 'all',
            'col' => '*',
        ),

        # 获取多条数据
        'getTotal' => array
        (
            # 匹配的正则或函数 选填项
            'option' => array
            (
                'order_id' => 'yes',
                'status' => array('yes', 'in'),
                'state' => 1,
            ),
            'type' => 'count',
            'col' => '*',
        ),

        # 获取订单数量
        'getOrderNum' => array
        (
            # 匹配的正则或函数 选填项
            'option' => array
            (
                'start' => array('yes-cdate', '>='),
                'end' => array('yes-cdate', '<='),
                'shop_id' => 'yes',
                'goods_id' => 'yes',
                'status' => 'yes',
                'state' => 1,
            ),
            'type' => 'count',
            'col' => '*',
        ),

        # 获取总金额
        'getCashNum' => array
        (
            # 匹配的正则或函数 选填项
            'option' => array
            (
                'start' => array('yes-cdate', '>='),
                'end' => array('yes-cdate', '<='),
                'shop_id' => 'yes',
                'goods_id' => 'yes',
                'status' => 'yes',
                'state' => 1,
            ),
            'type' => 'one',
            'col' => 'sum(price) as total',
        ),
    ),
);