49 lines
1.4 KiB
PHP
49 lines
1.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace app\adminapi\controller\finance;
|
|
|
|
use app\adminapi\controller\BaseAdminController;
|
|
use app\adminapi\logic\finance\DeptPerformanceTargetLogic;
|
|
use app\adminapi\validate\finance\DeptPerformanceTargetValidate;
|
|
|
|
/**
|
|
* 制定业绩:按部门、按自然月维护目标金额(元)
|
|
*
|
|
* - GET finance.dept_performance_target/monthMatrix
|
|
* - POST finance.dept_performance_target/batchSave
|
|
*/
|
|
class DeptPerformanceTargetController extends BaseAdminController
|
|
{
|
|
public function monthMatrix()
|
|
{
|
|
$params = (new DeptPerformanceTargetValidate())->goCheck('monthMatrix');
|
|
$ym = (string) $params['year_month'];
|
|
|
|
return $this->data(DeptPerformanceTargetLogic::monthMatrix($ym));
|
|
}
|
|
|
|
public function batchSave()
|
|
{
|
|
$params = (new DeptPerformanceTargetValidate())->post()->goCheck('batchSave');
|
|
$ym = (string) $params['year_month'];
|
|
$items = $params['items'] ?? [];
|
|
if (!is_array($items)) {
|
|
return $this->fail('目标数据格式错误');
|
|
}
|
|
|
|
$result = DeptPerformanceTargetLogic::batchSave(
|
|
$ym,
|
|
$items,
|
|
$this->adminId,
|
|
(string) ($this->adminInfo['name'] ?? '')
|
|
);
|
|
if ($result === false) {
|
|
return $this->fail(DeptPerformanceTargetLogic::getError());
|
|
}
|
|
|
|
return $this->success('保存成功', DeptPerformanceTargetLogic::monthMatrix($ym), 1, 1);
|
|
}
|
|
}
|