2025-01-21 15:48:03 +08:00

61 lines
1.5 KiB
PHP

<?php
namespace app\common\model\system_store;
use app\common\model\BaseModel;
use Illuminate\Support\Facades\Log;
use think\model\concern\SoftDelete;
use Throwable;
/**
* 门店列表模型
* Class SystemStore
* @package app\common\model\system_store
*/
class SystemStore extends BaseModel
{
use SoftDelete;
protected $name = 'system_store';
protected $deleteTime = 'delete_time';
// 不生成该表的日志
public $doNotRecordLog = true;
public static function onBeforeWrite($data)
{
try {
$where = $data->getWhere();
if($data){
$find = self::where($where)->field(array_keys($data->toArray()))->find();
if($find){
channelLog(array_merge($find->toArray(),$where),'system_store','更新前');
}
}
} catch (Throwable $e) {
Log::error('system_store:' . $e->getMessage());
}
}
public static function onAfterWrite($data){
try{
channelLog($data->toArray(),'system_store','更新后');
}catch(Throwable $e){
Log::error('system_store:'.$e->getMessage());
}
}
public static function isActivityStore($storeId)
{
return in_array($storeId, [5]);
}
/**
* 是否自营门店
* @param $storeId
* @return bool
*/
public static function isSelfOperate($storeId): bool
{
return !in_array($storeId, [21, 22, 15, 7]);
}
}