|
@@ -49,6 +49,7 @@ use common\models\User;
|
|
|
use common\models\UserBind;
|
|
use common\models\UserBind;
|
|
|
use common\models\UserBonus;
|
|
use common\models\UserBonus;
|
|
|
use common\models\UserInfo;
|
|
use common\models\UserInfo;
|
|
|
|
|
+use common\models\UserRelation;
|
|
|
use common\models\BaUserInfo;
|
|
use common\models\BaUserInfo;
|
|
|
use common\models\UserNetwork;
|
|
use common\models\UserNetwork;
|
|
|
use common\models\forms\DeclarationUpgradeForm;
|
|
use common\models\forms\DeclarationUpgradeForm;
|
|
@@ -154,20 +155,20 @@ class UserController extends BaseController {
|
|
|
*/
|
|
*/
|
|
|
public function actionNetworkStats() {
|
|
public function actionNetworkStats() {
|
|
|
$userId = Yii::$app->user->id;
|
|
$userId = Yii::$app->user->id;
|
|
|
- $networkInfo = UserNetwork::find()
|
|
|
|
|
- ->select(['LOCATION_TAG', 'TOP_DEEP'])
|
|
|
|
|
|
|
+ $relationInfo = UserRelation::find()
|
|
|
|
|
+ ->select(['TOP_DEEP'])
|
|
|
->where(['USER_ID' => $userId])
|
|
->where(['USER_ID' => $userId])
|
|
|
->asArray()
|
|
->asArray()
|
|
|
->one();
|
|
->one();
|
|
|
|
|
|
|
|
$descendants = [];
|
|
$descendants = [];
|
|
|
- if ($networkInfo) {
|
|
|
|
|
- $descendants = UserNetwork::find()
|
|
|
|
|
- ->alias('N')
|
|
|
|
|
- ->select(['N.USER_ID', 'N.PARENT_UID', 'N.TOP_DEEP'])
|
|
|
|
|
- ->innerJoin(User::tableName() . ' U', 'U.ID = N.USER_ID')
|
|
|
|
|
- ->where('N.LOCATION_TAG LIKE :LOCATION_TAG', [':LOCATION_TAG' => $networkInfo['LOCATION_TAG'] . '%'])
|
|
|
|
|
- ->andWhere(['>', 'N.TOP_DEEP', $networkInfo['TOP_DEEP']])
|
|
|
|
|
|
|
+ if ($relationInfo) {
|
|
|
|
|
+ $descendants = UserRelation::find()
|
|
|
|
|
+ ->alias('R')
|
|
|
|
|
+ ->select(['R.USER_ID', 'R.PARENT_UID', 'R.TOP_DEEP'])
|
|
|
|
|
+ ->innerJoin(User::tableName() . ' U', 'U.ID = R.USER_ID')
|
|
|
|
|
+ ->where('FIND_IN_SET(:USER_ID, R.PARENT_UIDS)', [':USER_ID' => $userId])
|
|
|
|
|
+ ->andWhere(['>', 'R.TOP_DEEP', $relationInfo['TOP_DEEP']])
|
|
|
->andWhere(['U.DELETED' => 0])
|
|
->andWhere(['U.DELETED' => 0])
|
|
|
->asArray()
|
|
->asArray()
|
|
|
->all();
|
|
->all();
|
|
@@ -181,13 +182,13 @@ class UserController extends BaseController {
|
|
|
$pcv += (float) OriginDecPv::find()->where(['USER_ID' => $userIds])->sum('DEC_PV');
|
|
$pcv += (float) OriginDecPv::find()->where(['USER_ID' => $userIds])->sum('DEC_PV');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- $maxDeep = $descendants ? max(array_column($descendants, 'TOP_DEEP')) : $networkInfo['TOP_DEEP'] ?? 0;
|
|
|
|
|
|
|
+ $maxDeep = $descendants ? max(array_column($descendants, 'TOP_DEEP')) : $relationInfo['TOP_DEEP'] ?? 0;
|
|
|
return static::notice([
|
|
return static::notice([
|
|
|
'DOWNLINE_COUNT' => count($descendants),
|
|
'DOWNLINE_COUNT' => count($descendants),
|
|
|
'DIRECT_DOWNLINE_COUNT' => count(array_filter($descendants, function ($downline) use ($userId) {
|
|
'DIRECT_DOWNLINE_COUNT' => count(array_filter($descendants, function ($downline) use ($userId) {
|
|
|
return $downline['PARENT_UID'] === $userId;
|
|
return $downline['PARENT_UID'] === $userId;
|
|
|
})),
|
|
})),
|
|
|
- 'MAX_DOWNLINE_DEEP' => max(0, (int) $maxDeep - (int) ($networkInfo['TOP_DEEP'] ?? 0)),
|
|
|
|
|
|
|
+ 'MAX_DOWNLINE_DEEP' => max(0, (int) $maxDeep - (int) ($relationInfo['TOP_DEEP'] ?? 0)),
|
|
|
'DOWNLINE_PCV' => $pcv,
|
|
'DOWNLINE_PCV' => $pcv,
|
|
|
]);
|
|
]);
|
|
|
}
|
|
}
|