<?php

namespace App\Models\marketing\mysql;

use Api\PhpUtils\Mysql\MysqlBase;
use App\Services\marketing\MarketingService;

/**
 * 自提点
 * Class TakePlace
 * @package App\Models\marketing\mysql
 */
class TakePlace extends MysqlBase
{
    const TABLE_NAME = 'take_place';
    const CONFIG_INDEX = 'marketing';
    const PRIMARY_KEY = 'take_place_id';

    const STATUS_NORMAL = 0;    // 正常
    const STATUS_DELETE = 1;    // 删除

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

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

    public static function existTakePlaceName(string $takePlaceName) : bool
    {
        $exist = self::getRecord(['take_place_name' => $takePlaceName], ['take_place_id']);
        return !empty($exist);
    }

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