<?php

namespace App\Models\goods\mysql;

use Api\PhpUtils\Mysql\MysqlBase;

/**
 * Class PindanGoodsSku
 * 拼单商品sku信息表
 * @package App\Models\goods\mysql
 */
class PindanGoodsSku extends MysqlBase
{
    const TABLE_NAME = 'pindan_goods_sku';
    const CONFIG_INDEX = 'goods';

    const STATUS_AUDIT = 0;//待审核
    const STATUS_PASS = 1;//审核通过
    const STATUS_REJECT = 2;//审核驳回

    const ONLINE_STATUS_NO_ONLINE = 0;//未上架
    const ONLINE_STATUS_ONLINE = 1;//已上架
    const ONLINE_STATUS_OFFLINE = 2;//已下架

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

    public static function getRecords($where, $columns = [])
    {
        if (empty($columns)) {
            $columns = '*';
        }
        return self::select($columns, $where);
    }

    public static function getRecordMaster($where, $columns = [])
    {
        if (empty($columns)) {
            $columns = '*';
        }
        return self::selectMaster($columns, $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);
    }

    public static function getCount($where, $columns = "*")
    {
        return self::count($columns, $where);
    }
}