登录
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\logic;
|
||||
|
||||
use app\common\traits\crud\CrudLogicTrait;
|
||||
use app\common\model\VehVehicleSku;
|
||||
|
||||
class VehVehicleSkuLogic
|
||||
{
|
||||
use CrudLogicTrait;
|
||||
|
||||
/**
|
||||
* 指定当前要操作的模型
|
||||
*/
|
||||
protected string $modelClass = VehVehicleSku::class;
|
||||
|
||||
|
||||
/**
|
||||
* 指纹 = “稳定可复现的事实串”做 sha256
|
||||
* - 仅纳入稳定维度:品牌/车系/年款/能源/驱动/变速/车身 + 关键数值
|
||||
* - 不纳入营销名(trim/edition)、颜色文本等
|
||||
* - corp 维度:若你未来希望租户内去重,可传 $scopeCorp=true
|
||||
*/
|
||||
public static function fingerprintMake(array $sku, bool $scopeCorp = false): string
|
||||
{
|
||||
$norm = function ($v) {
|
||||
if ($v === null || $v === '') return '';
|
||||
if (is_float($v)) return rtrim(rtrim(number_format($v, 3, '.', ''), '0'), '.'); // 规范小数
|
||||
return (string)$v;
|
||||
};
|
||||
|
||||
$parts = [
|
||||
$scopeCorp ? ($sku['corp_id'] ?? 0) : '',
|
||||
|
||||
strtoupper($sku['brand_code'] ?? ''),
|
||||
strtoupper($sku['series_code'] ?? ''),
|
||||
(int)($sku['model_year'] ?? 0),
|
||||
strtoupper($sku['fuel_type_code'] ?? ''),
|
||||
strtoupper($sku['drive_type_code']?? ''),
|
||||
strtoupper($sku['transmission_code'] ?? ''),
|
||||
strtoupper($sku['body_type_code'] ?? ''),
|
||||
|
||||
$norm($sku['engine_disp_l'] ?? null),
|
||||
(int)($sku['engine_turbo'] ?? 0),
|
||||
$norm($sku['battery_kwh'] ?? null),
|
||||
(int)($sku['range_km'] ?? 0),
|
||||
|
||||
strtoupper($sku['range_std_code'] ?? ''),
|
||||
strtoupper($sku['emission_std_code'] ?? ''),
|
||||
];
|
||||
|
||||
$plain = implode('|', $parts);
|
||||
return hash('sha256', $plain);
|
||||
}
|
||||
|
||||
public function getList($data)
|
||||
{
|
||||
return VehVehicleSku::where($data)->orderBy('id','desc')->get(['id', 'sku_code', 'brand_code', 'brand_code', 'series_code', 'series_name', 'model_code', 'model_name', 'model_year', 'msrp']);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user