Browse Source

比价脚本优化

wufeng 2 năm trước cách đây
mục cha
commit
d970a21521
1 tập tin đã thay đổi với 5 bổ sung2 xóa
  1. 5 2
      app/command/handleYzOrderData.php

+ 5 - 2
app/command/handleYzOrderData.php

@@ -40,9 +40,12 @@ class handleYzOrderData extends Command
                     ->where(['skuCode' => $c_data['skuCode'], 'is_del' => 0])
                     ->value('sale_price', 0);
 
-                if ($c_data['discount_price'] < $sale_price && $c_data['is_approved'] == '0') {
+                //实际支付价格除以数量,得出平均每件商品的价格,再比较
+                $discount_price = bcdiv((string)$c_data['discount_price'], (string)$c_data['num'], 2);
+
+                if ($discount_price < $sale_price && $c_data['is_approved'] == '0') {
                     Db::rollback();
-                    $this->callbackYz(['status' =>2, 'id' => $c_data['id'], 'reason' => '价格低于系统售价' . $sale_price]);
+                    $this->callbackYz(['status' => 2, 'id' => $c_data['id'], 'reason' => '价格低于系统售价' . $sale_price]);
                 }
 
                 $standing_book_data = [];