<?php

namespace App\Models\goods\mysql;

use Api\PhpUtils\Mysql\MysqlBase;

/**
 * Class GoodsSpu
 * 商品spu信息
 * @package App\Models\goods\mysql
 */
class GoodsSpu extends MysqlBase
{
    const TABLE_NAME = 'goods_spu';
    const CONFIG_INDEX = 'goods';

    const TYPE_VIRTUAL = 1;//虚拟商品
    const TYPE_ENTITY = 2;//实体商品

    const SUB_TYPE_TO_SHOP = 1;//到店
    const SUB_TYPE_ONLINE = 2;//线上

    const SALE_TYPE_NO_COMBINATION = 1;//非组合商品（无套餐）
    const SALE_TYPE_COMBINATION = 2;//组合商品（有套餐）

    public static function getRecord($where, $colums = [])
    {
        if (empty($colums)) {
            $colums = '*';
        }
        return self::get($colums, $where);
    }

    public static function getRecordMaster($where, $colums = [])
    {
        if (empty($colums)) {
            $colums = '*';
        }
        return self::selectMaster($colums, $where);
    }

    public static function insertRecord($colums)
    {
        return self::insert($colums);
    }

    public static function updateRecord($colums, $where)
    {
        return self::update($colums, $where);
    }

    public static function save($data, $where = [])
    {
        if (empty($where)) {
            return self::insert($data);
        }
        return self::update($data, $where);
    }

    public static function deleteRecord($where)
    {
        return self::delete($where);
    }
}