Files
zyt/server/app/adminapi/controller/finance/DeptPerformanceTargetController.php
T
2026-05-11 17:49:38 +08:00

55 lines
1.6 KiB
PHP
Executable File

<?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, $this->adminId, $this->adminInfo));
}
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,
$this->adminInfo,
(string) ($this->adminInfo['name'] ?? '')
);
if ($result === false) {
return $this->fail(DeptPerformanceTargetLogic::getError());
}
return $this->success(
'保存成功',
DeptPerformanceTargetLogic::monthMatrix($ym, $this->adminId, $this->adminInfo),
1,
1
);
}
}