|
|
@@ -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,95 @@ 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();
|
|
|
+ // 判断此业绩期是否已经完成生成了预计算业绩单,生成完毕才能看到
|
|
|
+ $isPerfed = Period::checkPerf($periodNum);
|
|
|
+ if (!$isPerfed) {
|
|
|
+ return static::notice(['user' => [],'team'=>[]]);
|
|
|
+ }
|
|
|
+ // 判断当前时间,是否临近封期,否则隐藏
|
|
|
+ $nowTs = time();
|
|
|
+ $currentPeriodEnd = Period::getEndTime($periodNum);
|
|
|
+ if ($nowTs + 432000 <= $currentPeriodEnd || $currentPeriodEnd < $nowTs) {
|
|
|
+ return static::notice(['user' => [],'team'=>[]]);
|
|
|
+ }
|
|
|
+ $userInfo = User::getEnCodeInfo($userId);
|
|
|
+ $data = PerfMonth::fetchMonthPerf($month, $userId);
|
|
|
+ $user[0] = [
|
|
|
+ 'number' => $userInfo['USER_NAME'],
|
|
|
+ 'name' => $userInfo['REAL_NAME'],
|
|
|
+ 'user_perf' => 0, // 个人业绩
|
|
|
+ 'team_perf' => 0, // 团队新增累计业绩
|
|
|
+ 'total_perf' => 0, // 合计业绩
|
|
|
+ 'perf_status' => '0', // 0 未达标 1为已达标
|
|
|
+ 'perf_status_name' => 'Fail',
|
|
|
+ ];
|
|
|
+ if (!empty($data)) {
|
|
|
+ $userCheck = PerfMonth::checkStatus($data['PV_PCS']+$data['PV_PSS']);
|
|
|
+ $user[0]['user_perf'] = $data['PV_PCS'];
|
|
|
+ $user[0]['team_perf'] = $data['PV_PSS'];
|
|
|
+ $user[0]['total_perf'] = $data['PV_PCS']+$data['PV_PSS'];
|
|
|
+ $user[0]['perf_status'] = $userCheck ? '1' : $user[0]['perf_status'];
|
|
|
+ $user[0]['perf_status_name'] = $userCheck ? 'Pass' : $user[0]['perf_status_name'];
|
|
|
+ }
|
|
|
+ $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::fetchMonthPerf($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'] = $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'] = '1';
|
|
|
+ $teamInfo[$k]['perf_status_name'] = 'Pass';
|
|
|
+ } 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'] = 'Fail';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ($userStatusFlag === true) {
|
|
|
+ $user[0]['perf_status'] = '1';
|
|
|
+ $user[0]['perf_status_name'] = 'Pass';
|
|
|
+ }
|
|
|
+
|
|
|
+ return static::notice(['user' => $user,'team'=>$teamInfo,'calcAt' => $calcAt['CREATED_AT']]);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 交易记录
|
|
|
* @return mixed
|
|
|
@@ -326,19 +416,19 @@ class BonusController extends BaseController {
|
|
|
// if ($sysConfig['openVIP']['VALUE']) {
|
|
|
// $data[] = ['name' => 'VIP奖', 'value' => Tool::formatPrice($calcBonus['ORI_BONUS_VIP'])];
|
|
|
// }
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
// if ($sysConfig['openXF']['VALUE']) {
|
|
|
// $data[] = ['name' => '消费奖', 'value' => Tool::formatPrice($calcBonus['ORI_BONUS_XF'])];
|
|
|
// }
|
|
|
// if ($sysConfig['openYJ']['VALUE']) {
|
|
|
// $data[] = ['name' => '业绩奖', 'value' => Tool::formatPrice($calcBonus['ORI_BONUS_YJ'])];
|
|
|
// }
|
|
|
-
|
|
|
+
|
|
|
// if ($sysConfig['openGL']['VALUE']) {
|
|
|
// $data[] = ['name' => '管理奖', 'value' => Tool::formatPrice($calcBonus['ORI_BONUS_GL'])];
|
|
|
// }
|
|
|
-
|
|
|
+
|
|
|
// if ($sysConfig['openJXS']['VALUE']) {
|
|
|
// $data[] = ['name' => '团队成长奖', 'value' => Tool::formatPrice($calcBonus['ORI_BONUS_STANDARD'])];
|
|
|
// }
|
|
|
@@ -346,14 +436,14 @@ class BonusController extends BaseController {
|
|
|
// $data[] = ['name' => '零售奖', 'value' => Tool::formatPrice($calcBonus['BONUS_LS'])];
|
|
|
// }
|
|
|
// $data[]=['name'=>'责任业绩扣除','value'=>Tool::formatPrice($calcBonus['DEDUCT_ZR'])];
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
// $data[]=['name'=>'总奖金','value'=>Tool::formatPrice($calcBonus['BONUS_TOTAL'])];
|
|
|
-
|
|
|
+
|
|
|
// if($sysConfig['openLX']['VALUE']) {
|
|
|
// $data[] = ['name' => '福利积分二', 'value' => Tool::formatPrice($calcBonus['BONUS_LX'])];
|
|
|
// }
|
|
|
-
|
|
|
+
|
|
|
// $data[]=['name'=>'四市场新增业绩','value'=>Tool::formatFrontPerf($calcBonus['PV_4L'])];
|
|
|
// $data[]=['name'=>'五市场新增业绩','value'=>Tool::formatFrontPerf($calcBonus['PV_5L'])];
|
|
|
// $data[]=['name'=>'虚拟市场新增业绩','value'=>Tool::formatFrontPerf($calcBonus['PV_LS_TOUCH'])];
|
|
|
@@ -1043,4 +1133,4 @@ class BonusController extends BaseController {
|
|
|
]);
|
|
|
return static::notice($data);
|
|
|
}
|
|
|
-}
|
|
|
+}
|