Преглед на файлове

Merge branch 'dev'

prodstable
Guillaume Bourgeois преди 5 години
родител
ревизия
5d8771b8a4
променени са 2 файла, в които са добавени 19 реда и са изтрити 1 реда
  1. +5
    -1
      backend/controllers/SubscriptionController.php
  2. +14
    -0
      common/models/Subscription.php

+ 5
- 1
backend/controllers/SubscriptionController.php Целия файл

@@ -219,8 +219,12 @@ class SubscriptionController extends BackendController
*/
public function actionDelete($id)
{
$subscription = Subscription::searchOne([
'subscription.id' => $id
]) ;
$subscription->deleteOrdersIncomingDistributions() ;
$subscription->delete();
ProductSubscription::deleteAll(['id_subscription' => $id]);
Subscription::findOne($id)->delete();
Yii::$app->getSession()->setFlash('success', 'Abonnement supprimé');
return $this->redirect(['subscription/index']);
}

+ 14
- 0
common/models/Subscription.php Целия файл

@@ -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() ;
}

Loading…
Отказ
Запис