<?php

namespace App\Models\goods\mysql;

use Api\PhpUtils\Mysql\MysqlBase;

/**
 * Tcc
 * tcc操作记录
 * @package App\Models\goods\mysql
 */
class Tcc extends MysqlBase
{
    const TABLE_NAME = 'inventory_tcc_record';
    const CONFIG_INDEX = 'goods';

    const STATUS_TRY = 1;// try
    const STATUS_CONFIRM = 2;// confirm
    const STATUS_CANCEL = 3;// cancel

    const OPERATOR_RESULT_FAIL = 0;// 失败
    const OPERATOR_RESULT_SUCCESS = 1;// 成功

    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);
    }
}