| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- <?php
- namespace addons\BossAchievement\backend\controllers;
- use addons\Boss\common\enums\BossEnum;
- use addons\Boss\common\models\AddonsBoss;
- use addons\BossAchievement\common\logic\AchievementLogic;
- use addons\BossAchievement\common\models\BossAchievementMonth;
- use addons\BossAchievement\common\models\BossAchievementTeam;
- use common\enums\StatusEnum;
- use Yii;
- use common\controllers\AddonsController;
- /**
- * 业绩分红控制器
- *
- * Class AchievementController
- * @package addons\BossAchievement\backend\controllers
- */
- class AchievementController extends AddonsController
- {
- /**
- * @var string
- */
- // public $layout = "@addons/Boss/backend/views/layouts/main";
- public $enableCsrfValidation = false;
- /**
- * 业绩分红
- * @Author: lun
- * @DateTime: 2021/10/23 0023 10:14
- * @Copyright: copyright (c) 2021 广东七件事集团
- * @return mixed|void
- */
- public function actionIndex()
- {
- $retuest = Yii::$app->request;
- if ($retuest->isAjax) {
- if ($retuest->isPost) {
- $post = Yii::$app->request->post();
- $res = Yii::$app->services->validate->validate($post,[
- [['user_id','month','is_settlement'], 'integer'],
- ]);
- if($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- $where[] = ['=', 'mall_id', $this->mall_id];
- !empty($post['user_id']) && $where[] = ['=', 'user_id', $post['user_id']];
- !empty($post['month']) && $where[] = ['=', 'month', $post['month']];
- isset($post['is_settlement']) && $where[] = ['=', 'is_settlement', $post['is_settlement']];
- $where[] = ['=', 'status', StatusEnum::ENABLED];
- $order = 'id desc';
- $with = ['user'];
- $params = compact('where','order','with');
- $list = BossAchievementMonth::listPage($params);
- return $this->success('获取成功', $list);
- }
- }
- return $this->render($this->action->id);
- }
- /**
- * 结算测试
- * @Author: lun
- * @DateTime: 2022/7/12 0012 10:28
- * @Copyright: copyright (c) 2021 广东七件事集团
- */
- public function actionSettlement()
- {
- $retuest = Yii::$app->request;
- if ($retuest->isAjax) {
- if ($retuest->isPost) {
- $res = (new AchievementLogic())->settlement($this->mall_id, date('Ym', time()));
- if ($res === false) return $this->error('结算出错');
- return $this->success('结算成功');
- }
- }
- }
- /**
- * 清除本月业绩
- * @Author: lun
- * @DateTime: 2022/7/12 0012 10:46
- * @Copyright: copyright (c) 2021 广东七件事集团
- * @return mixed|void
- */
- public function actionClear()
- {
- $retuest = Yii::$app->request;
- if ($retuest->isAjax) {
- if ($retuest->isPost) {
- $month = date('Ym', time());
- // 团队本月数据改为未结算
- BossAchievementTeam::updateAll(['is_settlement' => StatusEnum::DISABLED], ['mall_id' => $this->mall_id, 'month' => $month, 'status' => StatusEnum::ENABLED]);
- // 已结算的本月董事改为未结算
- BossAchievementMonth::updateAll([
- 'is_settlement' => StatusEnum::DISABLED,
- 'bonus' => StatusEnum::DISABLED,
- 'settlement_money' => StatusEnum::DISABLED,
- 'settlement_num' => StatusEnum::DISABLED,
- 'standard_money' => StatusEnum::DISABLED,
- ], ['mall_id' => $this->mall_id, 'month' => $month, 'status' => StatusEnum::ENABLED]);
- return $this->success('清除成功');
- }
- }
- }
- }
|