| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- <?php
- namespace addons\TeamData\common\models;
- use common\models\user\UserPartitionRelationship;
- /**
- * 商城UserPartitionRelationship
- * @package addons\TeamData\common\models
- */
- class MallUserPartitionRelationship extends UserPartitionRelationship
- {
- /**
- * 查询我的团队会员IDs
- *
- * @param integer $uid
- * @param string $keyword
- * @param string $search_type
- * @return array
- */
- public static function getChildIds(int $uid, string $keyword, $search_type)
- {
- $relationship = self::find()
- ->where(['user_id' => $uid])
- ->select(['tree', 'deep'])
- ->orderBy('part desc')
- ->one();
- if (empty($relationship)) return [];
- $model = self::find()->alias('upr')
- ->where(['like', 'upr.tree', "{$relationship->tree},%", false])
- ->andWhere(['<>', 'upr.user_id', $uid])
- ->select(['upr.user_id']);
-
- if ($keyword) {
- $model->join('left join', MallUser::tableName() . ' as u', 'u.id = upr.user_id');
- if ($search_type == 1) $model->andWhere(['=', 'u.id', $keyword]);
- if ($search_type == 2) $model->andWhere(['=', 'u.nickname', $keyword]);
- if ($search_type == 3) $model->andWhere(['=', 'u.mobile', $keyword]);
- }
- return $model->column();
- }
- }
|