瀏覽代碼

Anthély : rappatriement clients depuis le compte Anthéli #793

refactoring
Guillaume Bourgeois 1 年之前
父節點
當前提交
2300a426e3
共有 1 個文件被更改,包括 14 次插入2 次删除
  1. +14
    -2
      backend/controllers/ProducerAdminController.php

+ 14
- 2
backend/controllers/ProducerAdminController.php 查看文件

@@ -130,7 +130,7 @@ class ProducerAdminController extends BackendController
}
}

public function actionUserTransfer($fromProducerId, $toProducerId)
public function actionUserTransfer($fromProducerId, $toProducerId, $withOrders = 1)
{
$fromProducerId = (int) $fromProducerId;
$toProducerId = (int) $toProducerId;
@@ -138,7 +138,19 @@ class ProducerAdminController extends BackendController
$usersArray = User::findBy(['id_producer' => $fromProducerId])->all();

foreach($usersArray as $user) {
Producer::addUser($user['user_id'], $toProducerId);
$idUser = $user['user_id'];

$countOrders = 0;
if($withOrders) {
$countOrders = Order::searchCount([
'id_user' => $idUser,
], ['conditions' => 'date_delete IS NULL']);
}

if(($withOrders && $countOrders) || !$withOrders) {
Producer::addUser($idUser, $toProducerId);
}

$count ++;
}


Loading…
取消
儲存