<?php

namespace App\Models\goods\mysql;

use Api\PhpUtils\Mysql\MysqlBase;

/**
 * Tcc
 * tcc操作记录
 * @package App\Models\goods\mysql
 */
class Tcc extends MysqlBase
{
    const STATUS_T_SUCCESS = 1;
    const STATUS_C1_SUCCESS = 2;
    const STATUS_C2_SUCCESS = 3;

    const TABLE_NAME = 'inventory_tcc_record';
    const CONFIG_INDEX = 'goods';

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