]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
feat(ERP-292): модель — METHOD_LLM, llm_verdict поля и валидация
authorfomichev <vladimir.fomichev@erp-flowers.ru>
Thu, 30 Apr 2026 15:08:09 +0000 (18:08 +0300)
committerfomichev <vladimir.fomichev@erp-flowers.ru>
Thu, 30 Apr 2026 15:08:09 +0000 (18:08 +0300)
erp24/records/Products1cAutomarkPrediction.php

index 8ed27579c8ac209e2e901e629747c9e04ca5fb23..46b4637208fad6f99919f2e33a938cd6a1340ff3 100644 (file)
@@ -5,7 +5,6 @@ declare(strict_types=1);
 namespace yii_app\records;
 
 use yii\db\ActiveQuery;
-use yii_app\records\Products1c;
 
 /**
  * Предсказание авторазметки товара из 1С.
@@ -23,6 +22,9 @@ use yii_app\records\Products1c;
  * @property string      $method
  * @property int         $status
  * @property int|null    $approved_by
+ * @property string|null $llm_verdict
+ * @property string|null $llm_verified_at
+ * @property string|null $llm_comment
  * @property string      $created_at
  * @property string|null $updated_at
  */
@@ -34,6 +36,10 @@ class Products1cAutomarkPrediction extends \yii\db\ActiveRecord
 
     public const METHOD_RULE       = 'rule';
     public const METHOD_SIMILARITY = 'similarity';
+    public const METHOD_LLM        = 'llm';
+
+    public const LLM_VERDICT_APPROVED = 'approved';
+    public const LLM_VERDICT_REJECTED = 'rejected';
 
     public static function tableName(): string
     {
@@ -45,12 +51,15 @@ class Products1cAutomarkPrediction extends \yii\db\ActiveRecord
         return [
             [['product_id', 'confidence', 'method', 'status'], 'required'],
             [['product_id', 'category', 'subcategory', 'species', 'sort', 'type', 'color', 'method'], 'string', 'max' => 255],
+            [['llm_verdict', 'llm_comment'], 'string', 'max' => 500],
             [['size', 'status', 'approved_by'], 'integer'],
             [['confidence'], 'number', 'min' => 0, 'max' => 1],
-            [['method'], 'in', 'range' => [self::METHOD_RULE, self::METHOD_SIMILARITY]],
+            [['method'], 'in', 'range' => [self::METHOD_RULE, self::METHOD_SIMILARITY, self::METHOD_LLM]],
             [['status'], 'in', 'range' => [self::STATUS_PENDING, self::STATUS_APPROVED, self::STATUS_REJECTED]],
-            [['created_at', 'updated_at'], 'safe'],
-            [['category', 'subcategory', 'species', 'sort', 'type', 'color', 'approved_by', 'updated_at', 'size'], 'default', 'value' => null],
+            [['llm_verdict'], 'in', 'range' => [self::LLM_VERDICT_APPROVED, self::LLM_VERDICT_REJECTED], 'skipOnEmpty' => true],
+            [['created_at', 'updated_at', 'llm_verified_at'], 'safe'],
+            [['category', 'subcategory', 'species', 'sort', 'type', 'color', 'approved_by', 'updated_at', 'size',
+              'llm_verdict', 'llm_verified_at', 'llm_comment'], 'default', 'value' => null],
         ];
     }
 
@@ -69,6 +78,11 @@ class Products1cAutomarkPrediction extends \yii\db\ActiveRecord
         return $this->status === self::STATUS_REJECTED;
     }
 
+    public function isLlmVerified(): bool
+    {
+        return $this->llm_verdict !== null;
+    }
+
     public function getProduct(): ActiveQuery
     {
         return $this->hasOne(Products1c::class, ['id' => 'product_id']);