<?php

namespace App\Models\goods\mysql;

use Api\PhpUtils\Mysql\MysqlBase;

/**
 * Class GoodsSku
 * 商品sku信息
 * @package App\Models\goods\mysql
 */
class GoodsSku extends MysqlBase
{
    const TABLE_NAME = '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;//已下架

    const RULE_REFUND_1 = 1;
    const RULE_REFUND_2 = 2;
    const RULE_REFUND_3 = 3;

    public static $ruleRefundList = [
        self::RULE_REFUND_1 => "到期自动退款",
        self::RULE_REFUND_2 => "购买后不允许退款",
        self::RULE_REFUND_3 => "到期后不退款",
    ];

    const RULE_DATE_TYPE_1 = 1;
    const RULE_DATE_TYPE_2 = 2;

    public static $ruleDataTypeList = [
        self::RULE_DATE_TYPE_1 => "周末、法定节假日通用",
        self::RULE_DATE_TYPE_2 => "仅工作日可用",
    ];

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

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

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

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