|
|
@@ -395,9 +395,23 @@ class Subscription extends ActiveRecordCommon |
|
|
|
$orders->params($params) ; |
|
|
|
|
|
|
|
$ordersArray = $orders->all() ; |
|
|
|
$configCredit = Producer::getConfig('credit') ; |
|
|
|
|
|
|
|
if($ordersArray && count($ordersArray)) { |
|
|
|
foreach($ordersArray as $order) { |
|
|
|
|
|
|
|
$theOrder = Order::searchOne(['id' => $order->id]) ; |
|
|
|
// remboursement de la commande |
|
|
|
if ($theOrder->id_user && $theOrder->getAmount(Order::AMOUNT_PAID) && $configCredit) { |
|
|
|
$theOrder->saveCreditHistory( |
|
|
|
CreditHistory::TYPE_REFUND, |
|
|
|
$theOrder->getAmount(Order::AMOUNT_PAID), |
|
|
|
$theOrder->distribution->id_producer, |
|
|
|
$theOrder->id_user, |
|
|
|
User::getCurrentId() |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
ProductOrder::deleteAll(['id_order' => $order->id]) ; |
|
|
|
$order->delete() ; |
|
|
|
} |