|
|
@@ -2,6 +2,9 @@
|
|
|
|
|
|
namespace common\models\forms;
|
|
|
|
|
|
+use backendApi\modules\v1\models\Admin;
|
|
|
+use backendApi\modules\v1\models\AdminCountry;
|
|
|
+use backendApi\modules\v1\models\AdminRole;
|
|
|
use common\components\Model;
|
|
|
use common\helpers\Cache;
|
|
|
use common\helpers\Date;
|
|
|
@@ -735,11 +738,34 @@ class WithdrawForm extends Model {
|
|
|
*
|
|
|
* @throws \yii\db\Exception
|
|
|
*/
|
|
|
- public function batchWithdraw($limit, $start){
|
|
|
+ public function batchWithdraw($limit, $start, $params){
|
|
|
$config = Cache::getSystemConfig();
|
|
|
$minAmount = $config['manualWithdrawMinAmount']['VALUE'];
|
|
|
+
|
|
|
+ $condition = '';
|
|
|
+ $adminRoleId = Admin::getRoleIdById($params['handleUserId']);
|
|
|
+ $isSuper = AdminRole::isSuperAdmin($adminRoleId);
|
|
|
+ if (!$isSuper) {
|
|
|
+ $adminCountry = AdminCountry::getCountry($params['handleUserId']);
|
|
|
+ $quotedAdminCountry = array_map(function($item) {
|
|
|
+ return "'" . addslashes($item) . "'";
|
|
|
+ }, $adminCountry);
|
|
|
+
|
|
|
+ $condition .= " AND U.COUNTRY_ID IN (" . implode(',', $quotedAdminCountry) . ")";
|
|
|
+ }
|
|
|
+
|
|
|
// 查找有奖金的用户
|
|
|
- $allData = UserBonus::find()->select('USER_ID, USER_NAME, ID_CARD, BONUS')->from(UserBonus::tableName().' AS UB')->join('LEFT JOIN', User::tableName().' AS U','UB.USER_ID = U.ID')->where("BONUS>$minAmount")->offset(0)->limit($limit)->orderBy('U.ID')->asArray()->all();
|
|
|
+ $allData = UserBonus::find()
|
|
|
+ ->select('USER_ID, USER_NAME, ID_CARD, BONUS')
|
|
|
+ ->from(UserBonus::tableName().' AS UB')
|
|
|
+ ->join('INNER JOIN', User::tableName() . ' AS U','UB.USER_ID = U.ID ' . $condition)
|
|
|
+ ->where("BONUS>$minAmount")
|
|
|
+ ->offset(0)
|
|
|
+ ->limit($limit)
|
|
|
+ ->orderBy('U.ID')
|
|
|
+ ->asArray()
|
|
|
+ ->all();
|
|
|
+
|
|
|
if($allData){
|
|
|
foreach ($allData as $data){
|
|
|
$db = \Yii::$app->db;
|
|
|
@@ -787,7 +813,7 @@ class WithdrawForm extends Model {
|
|
|
unset($allData);
|
|
|
$start = $start + $limit;
|
|
|
|
|
|
- return self::batchWithdraw($limit, $start);
|
|
|
+ return self::batchWithdraw($limit, $start, $params);
|
|
|
}
|
|
|
return true;
|
|
|
}
|