<?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() ?: '操作失败');
|
}
|
|
}
|