62 lines
1.4 KiB
PHP
62 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace app\common\service;
|
|
|
|
use app\common\validate\FinReceiptHisValidate;
|
|
use app\common\traits\crud\CrudServiceTrait;
|
|
use app\common\model\FinReceiptHis;
|
|
use support\exception\BusinessException;
|
|
use support\Request;
|
|
|
|
class FinReceiptHisService
|
|
{
|
|
|
|
use CrudServiceTrait;
|
|
|
|
/**
|
|
* 指定当前要操作的模型
|
|
*/
|
|
protected string $modelClass = FinReceiptHis::class;
|
|
|
|
/**
|
|
* 验证器
|
|
*/
|
|
protected $validator = FinReceiptHisValidate::class;
|
|
|
|
/**
|
|
* 获取验证器
|
|
*/
|
|
public function getValidator()
|
|
{
|
|
return new $this->validator;
|
|
}
|
|
|
|
/**
|
|
* 构建查询条件
|
|
*/
|
|
protected function buildQueryConfig(Request $request, string $scene = 'index'): array
|
|
{
|
|
$p = $request->all();
|
|
|
|
$config = [];
|
|
$config['model'] = $this->modelClass;
|
|
switch ($scene) {
|
|
case 'index':
|
|
if(empty($p['receipt_id'])){
|
|
throw new BusinessException('receipt_id不能为空');
|
|
}
|
|
// ====== ====== 排序 ====== ======
|
|
$config['order']['id'] = 'desc';
|
|
|
|
// ====== ====== 筛选 ====== ======
|
|
$config['where']['receipt_id'] = $p['receipt_id'];
|
|
|
|
break;
|
|
case 'show':
|
|
$config['where']['id'] = $p['id'];
|
|
break;
|
|
}
|
|
|
|
return $config;
|
|
}
|
|
} |