<?php

namespace App\Models\marketing\mysql;

use Api\PhpUtils\Mysql\MysqlBase;

class ColonelDistributorPayInfo extends MysqlBase
{
    const TABLE_NAME = 'colonel_distributor_pay_info';
    const CONFIG_INDEX = 'marketing';
    const PRIMARY_KEY = 'pay_info_id';

    const TYPE_NEW_USER = 1;
    const TYPE_FINISH_TARGET = 2;
    const STATUS_NOT_USE = 0;
    const STATUS_USE = 1;


    public static $typeDesc = [
        self::TYPE_NEW_USER => "邀请新用户",
        self::TYPE_FINISH_TARGET => "完成目标单数",
    ];

    public static function getRecords(array $where, $column = '*')
    {
        return (array)self::select($column, $where);
    }

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

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

    public static function insertRecord($columns, $options = [])
    {
        return self::insert($columns, $options);
    }

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

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

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