|
|
@@ -101,33 +101,43 @@ class BonusController extends BaseController {
|
|
|
* @return mixed
|
|
|
* @throws \yii\web\HttpException
|
|
|
*/
|
|
|
- public function actionSearch() {
|
|
|
+ public function actionTeams() {
|
|
|
$userId = \Yii::$app->user->id;
|
|
|
- // 查询此用户,月业绩
|
|
|
- //期数显示
|
|
|
- // 达标规则,小组底下有一个大于等于一万.或者个人情况里的合计大于等于一万
|
|
|
$period = Period::instance();
|
|
|
$periodNum = $period->getNowPeriodNum();
|
|
|
- $month = $period->getNowMonth();
|
|
|
+ $month = $period->getNowYearMonth();
|
|
|
+ // 判断是否是周日,并且是否是月结节点
|
|
|
+ // 判断是否是月节点
|
|
|
+ $isCalcMonth = $period->isCalcMonth($periodNum);
|
|
|
+ $w = date('w', time());
|
|
|
+ // if ($w != '0' || $isCalcMonth != 1) {
|
|
|
+ // return static::notice(['user' => [],'team'=>[]]);
|
|
|
+ // }
|
|
|
+
|
|
|
+ // 达标规则,小组底下有一个大于等于一万.或者个人情况里的合计大于等于一万
|
|
|
+ $month = '202203';
|
|
|
$data = PerfMonthPrepare::getMonthPerfPrepare($userId, $month);
|
|
|
// PV_PCS 个人业绩 PV_PSS 月新增团队业绩 PV_PSS_TOTAL月累计团队业绩
|
|
|
// 其中页面使用的是月新增团队业绩
|
|
|
// 获取用信息
|
|
|
$userInfo = User::getEnCodeInfo($userId);
|
|
|
- $user = [
|
|
|
+ $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 // 合计业绩
|
|
|
];
|
|
|
if (!empty($data)) {
|
|
|
- $user['user_perf'] = $data['PV_PCS'];
|
|
|
- $user['team_perf'] = $data['PV_PSS'];
|
|
|
- $user['total_perf'] = $data['PV_PCS']+$data['PV_PSS'];
|
|
|
- if ($user['total_perf'] >= 10000) {
|
|
|
- $user['perf_status'] = '1';
|
|
|
+ $user[0]['user_perf'] = Tool::formatPreparePerf($data['PV_PCS']);
|
|
|
+ $user[0]['team_perf'] = Tool::formatPreparePerf($data['PV_PSS']);
|
|
|
+ $user[0]['total_perf'] = Tool::formatPreparePerf($data['PV_PCS']+$data['PV_PSS']);
|
|
|
+ $userCheck = PerfMonthPrepare::checkPrepareStatus($user[0]['total_perf']);
|
|
|
+ if ($userCheck) {
|
|
|
+ $user[0]['perf_status'] = '1';
|
|
|
+ $user[0]['perf_status_name'] = '达标';
|
|
|
}
|
|
|
}
|
|
|
$teamInfo = [];
|
|
|
@@ -136,28 +146,38 @@ class BonusController extends BaseController {
|
|
|
$userStatusFlag = false;
|
|
|
if ($relation) {
|
|
|
// 循环一级开拓用户
|
|
|
- foreach($relation as $v) {
|
|
|
+ foreach($relation as $k=>$v) {
|
|
|
// 获取此用户预计算月业绩
|
|
|
$relationPerf = PerfMonthPrepare::getMonthPerfPrepare($v['USER_ID'], $month);
|
|
|
- $teamInfo[]['perf_status'] = $relationPerf['PV_PCS'] >= 10000 ? 1 : 0;
|
|
|
- if ($relationPerf['PV_PCS'] >= 10000) {
|
|
|
- $userStatusFlag = true;
|
|
|
- $teamInfo[]['number'] = '';
|
|
|
- $teamInfo[]['name'] = '';
|
|
|
- $teamInfo[]['user_perf'] = '';
|
|
|
- $teamInfo[]['team_perf'] = '';
|
|
|
- $teamInfo[]['total_perf'] = '';
|
|
|
+ if (empty($relationPerf)) {
|
|
|
+ $relationPerf['PV_PCS'] = 0;
|
|
|
+ $relationPerf['PV_PSS'] = 0;
|
|
|
+ }
|
|
|
+ $relationCheck = PerfMonthPrepare::checkPrepareStatus($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[]['number'] = $v['USER_NAME'];
|
|
|
- $teamInfo[]['name'] = $v['REAL_NAME'];
|
|
|
- $teamInfo[]['user_perf'] = $relationPerf['PV_PCS'];
|
|
|
- $teamInfo[]['team_perf'] = $relationPerf['PV_PSS'];
|
|
|
- $teamInfo[]['total_perf'] = $relationPerf['PV_PCS']+$relationPerf['PV_PSS'];
|
|
|
+ $teamInfo[$k]['number'] = $v['USER_NAME'];
|
|
|
+ $teamInfo[$k]['name'] = $v['REAL_NAME'];
|
|
|
+ $teamInfo[$k]['user_perf'] = Tool::formatPreparePerf($relationPerf['PV_PCS']);
|
|
|
+ $teamInfo[$k]['team_perf'] = Tool::formatPreparePerf($relationPerf['PV_PSS']);
|
|
|
+ $teamInfo[$k]['total_perf'] = Tool::formatPreparePerf($relationPerf['PV_PCS']+$relationPerf['PV_PSS']);
|
|
|
+ $teamInfo[$k]['perf_status'] = '0';
|
|
|
+ $teamInfo[$k]['perf_status_name'] = '不达标';
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if ($userStatusFlag === true) {
|
|
|
- $user['perf_status'] = 1;
|
|
|
+ $user[0]['perf_status'] = 1;
|
|
|
+ $user[0]['perf_status_name'] = '达标';
|
|
|
}
|
|
|
|
|
|
return static::notice(['user' => $user,'team'=>$teamInfo]);
|