|
|
@@ -35,6 +35,7 @@ use common\models\FlowExchangePoints;
|
|
|
use common\models\ScoreMonth;
|
|
|
use common\models\UserBonus;
|
|
|
use common\models\UserWallet;
|
|
|
+use common\models\UserRelation;
|
|
|
use frontendApi\modules\v1\models\User;
|
|
|
|
|
|
class BonusController extends BaseController {
|
|
|
@@ -103,6 +104,75 @@ class BonusController extends BaseController {
|
|
|
return static::notice(['wallet' => $wallet,'dealSwitch'=>$dealSwitch]);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 团队查询
|
|
|
+ * @return mixed
|
|
|
+ * @throws \yii\web\HttpException
|
|
|
+ */
|
|
|
+ public function actionTeams() {
|
|
|
+ $userId = \Yii::$app->user->id;
|
|
|
+ $period = Period::instance();
|
|
|
+ $periodNum = $period->getNowPeriodNum();
|
|
|
+ $month = $period->getNowYearMonth();
|
|
|
+ $userInfo = User::getEnCodeInfo($userId);
|
|
|
+ $user[0] = [
|
|
|
+ 'number' => $userInfo['USER_NAME'],
|
|
|
+ 'name' => $userInfo['REAL_NAME'],
|
|
|
+ 'perf_status' => '0', // 0 未达标 1为已达标
|
|
|
+ 'perf_status_name' => '不达标',
|
|
|
+ 'user_perf' => 0, // 个人业绩
|
|
|
+ 'team_perf' => 0, // 团队新增累计业绩
|
|
|
+ 'total_perf' => 0 // 合计业绩
|
|
|
+ ];
|
|
|
+ $teamInfo = [];
|
|
|
+ $calcAt = PerfMonth::find()->select(['CREATED_AT'])->where('CALC_MONTH=:CALC_MONTH', ['CALC_MONTH'=>$month])->asArray()->one();
|
|
|
+
|
|
|
+ if(!$calcAt){
|
|
|
+ $periodStartTime = $period->nowPeriodArr['START_TIME'];
|
|
|
+ return static::notice(['user' => $user,'team'=>[],'calcAt' => $periodStartTime]);
|
|
|
+ }
|
|
|
+ // 查询此用户的推荐(开拓)团队一级信息
|
|
|
+ $relation = UserRelation::getChildrenWithDeepAndLayer($userId, 1, 1, $periodNum);
|
|
|
+ $userStatusFlag = false;
|
|
|
+ if ($relation) {
|
|
|
+ // 循环一级开拓用户
|
|
|
+ foreach($relation as $k=>$v) {
|
|
|
+ // 获取此用户预计算月业绩
|
|
|
+ $relationPerf = PerfMonth::getMonthPerf($month, $v['USER_ID']);
|
|
|
+ if (empty($relationPerf)) {
|
|
|
+ $relationPerf['PV_PCS'] = 0;
|
|
|
+ $relationPerf['PV_PSS'] = 0;
|
|
|
+ }
|
|
|
+ $relationCheck = PerfMonth::checkStatus($relationPerf['PV_PCS']+$relationPerf['PV_PSS']);
|
|
|
+ $teamInfo[]['perf_status'] = $relationCheck ? '1' : '0';
|
|
|
+ if ($relationCheck) {
|
|
|
+ $userStatusFlag = true; // 只要有一个达标,则个人就达标
|
|
|
+ $teamInfo[$k]['number'] = '';
|
|
|
+ $teamInfo[$k]['name'] = '';
|
|
|
+ $teamInfo[$k]['user_perf'] = '';
|
|
|
+ $teamInfo[$k]['team_perf'] = '';
|
|
|
+ $teamInfo[$k]['total_perf'] = '';
|
|
|
+ $teamInfo[$k]['perf_status'] = '1';
|
|
|
+ $teamInfo[$k]['perf_status_name'] = '达标';
|
|
|
+ } else {
|
|
|
+ $teamInfo[$k]['number'] = $v['USER_NAME'];
|
|
|
+ $teamInfo[$k]['name'] = $v['REAL_NAME'];
|
|
|
+ $teamInfo[$k]['user_perf'] = $relationPerf['PV_PCS'];
|
|
|
+ $teamInfo[$k]['team_perf'] = $relationPerf['PV_PSS'];
|
|
|
+ $teamInfo[$k]['total_perf'] = $relationPerf['PV_PCS']+$relationPerf['PV_PSS'];
|
|
|
+ $teamInfo[$k]['perf_status'] = '0';
|
|
|
+ $teamInfo[$k]['perf_status_name'] = '不达标';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ($userStatusFlag === true) {
|
|
|
+ $user[0]['perf_status'] = '1';
|
|
|
+ $user[0]['perf_status_name'] = '达标';
|
|
|
+ }
|
|
|
+
|
|
|
+ return static::notice(['user' => $user,'team'=>$teamInfo,'calcAt' => $calcAt['CREATED_AT']]);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 交易记录
|
|
|
* @return mixed
|