浏览代码

[backend] Prix : mettre à jour le prix de ProductOrder des distributions futures lors de la modification de Product.

refactoring
Guillaume 4 年前
父节点
当前提交
4ca952bbed
共有 1 个文件被更改,包括 19 次插入4 次删除
  1. +19
    -4
      common/models/Distribution.php

+ 19
- 4
common/models/Distribution.php 查看文件

@@ -38,11 +38,10 @@

namespace common\models;

use common\helpers\GlobalParam;
use Yii;
use common\components\ActiveRecordCommon;
use common\helpers\GlobalParam;
use common\models\Order;
use common\models\Distribution;
use common\components\ActiveRecordCommon;

/**
* This is the model class for table "production".
@@ -317,9 +316,25 @@ class Distribution extends ActiveRecordCommon
if(isset($product->$fieldQuantityMax) && $product->$fieldQuantityMax > 0) {
$productDistribution->quantity_max = $product->$fieldQuantityMax ;
}

$productDistribution->save();

// update prices product order
$ordersArray = Order::searchAll([
'distribution.date' => $this->date,
'distribution.id_producer' => $this->id_producer
],
[
'conditions' => 'date_delete IS NULL AND origin != "user"'
]);
if($ordersArray) {
foreach($ordersArray as $order) {
foreach($order->productOrder as $productOrder) {
$productOrder->price = $product->price ;
$productOrder->save() ;
}
}
}

return $productDistribution;
}


正在加载...
取消
保存