Преглед изворни кода

[智价云] 多账户去重规则更新调整

tangyuanwang пре 4 часа
родитељ
комит
6a1ac97f53

+ 12 - 8
app/Models/Manager/Process/LowPriceGoods.php

@@ -114,14 +114,18 @@ class LowPriceGoods extends Model
     public function addLowPriceGoods($data, $is_import = false)
     {
         if ($is_import == false) {
-            $source_where[] = ['company_id', '=', $data['company_id']];
-            $source_where[] = ['source_id', '=', $data['source_id']];
-            $source_where[] = ['product_name', '=', $data['product_name']];
-            $source_where[] = ['product_specs', '=', $data['product_specs']];
-            $source_where[] = ['suggested_price', '=', $data['suggested_price']];
-            $source_where[] = ['product_brand', '=', $data['product_brand']];
-            $source_id_log = $this->where($source_where)->count();
-            if ($source_id_log > 0) {
+            //去重规则:品牌方公司ID+店铺公司名称+店铺名称+品牌名称+商品名称+规格+盒数(针对采集)
+            $source_where[] = ['company_id', '=', $data['company_id']]; //品牌方公司ID
+            $source_where[] = ['company_name', '=', $data['company_name']]; //店铺公司名称
+            $source_where[] = ['store_name', '=', $data['store_name']]; //店铺名称
+            $source_where[] = ['product_brand', '=', $data['product_brand']]; //品牌名称
+            $source_where[] = ['product_name', '=', $data['product_name']]; //商品名称
+            $source_where[] = ['product_specs', '=', $data['product_specs']]; //规格
+            $source_id_log = $this->where($source_where)->select(['id', 'online_posting_price'])->first();
+            if (!empty($source_id_log)) {
+                if ($source_id_log->online_posting_price > $data['online_posting_price']) {
+                    $this->where('id', $source_id_log->id)->update(['online_posting_price' => $data['online_posting_price'], 'source_id' => $data['source_id']]);
+                }
                 return true;
             }
         }

+ 7 - 5
app/Models/Manager/Process/ViolationProduct.php

@@ -110,11 +110,13 @@ class ViolationProduct extends Model
     public function addViolationProduct($data, $is_import = false)
     {
         if ($is_import == false) {
-            $source_where[] = ['company_id', '=', $data['company_id']];
-            $source_where[] = ['source_id', '=', $data['source_id']];
-            $source_where[] = ['product_name', '=', $data['product_name']];
-            $source_where[] = ['product_specs', '=', $data['product_specs']];
-            $source_where[] = ['product_brand', '=', $data['product_brand']];
+            //去重规则:品牌方公司ID+店铺公司名称+店铺名称+品牌名称+商品名称+规格+盒数(针对采集)
+            $source_where[] = ['company_id', '=', $data['company_id']]; //品牌方公司ID
+            $source_where[] = ['company_name', '=', $data['company_name']]; //店铺公司名称
+            $source_where[] = ['store_name', '=', $data['store_name']]; //店铺名称
+            $source_where[] = ['product_brand', '=', $data['product_brand']]; //品牌名称
+            $source_where[] = ['product_name', '=', $data['product_name']]; //商品名称
+            $source_where[] = ['product_specs', '=', $data['product_specs']]; //规格
             $source_id_log = $this->where($source_where)->count();
             if ($source_id_log > 0) {
                 return true;