quanwei
18 hours ago c441dea81bd86bdfb12dff35821fed51f4cc91c2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
 
namespace app\operations\controller\plus\shareholder;
 
use app\operations\controller\Controller;
use app\operations\model\plus\shareholder\Bonus as BonusModel;
use app\operations\model\plus\shareholder\Setting as SettingModel;
 
/**
 * 分红结算控制器
 */
class Bonus extends Controller
{
    /**
     * 结算列表
     */
    public function index($year = '', $month = '', $week = '')
    {
        $model = new BonusModel;
        $list = $model->getList($year, $month, $week);
        return $this->renderSuccess('', compact('list'));
    }
 
    /**
     * 新增结算
     */
    public function add()
    {
        $model = new BonusModel();
        if ($this->request->isGet()) {
            $config = SettingModel::getItem('basic');
            $detail = $model->getBonus();
            if(!$detail) {
                return $this->renderError($model->getError() ?: '无法进行结算操作');
            }
            $detail['total_rate'] = $config['total_rate'];
            $detail['bonus_type'] = $model->getBonusTypeAttr($config['bonus_type']);
            return $this->renderSuccess('', compact('detail'));
        }
        if ($model->add($this->postData())) {
            return $this->renderSuccess('操作成功');
        }
        return $this->renderError($model->getError() ?: '操作失败');
    }
 
}