2026-01-07 17:23:03 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace app\common\service;
|
|
|
|
|
|
|
|
|
|
use app\common\validate\InvRequisitionReturnValidate;
|
|
|
|
|
use app\common\traits\crud\CrudServiceTrait;
|
|
|
|
|
use app\common\model\InvRequisitionReturn;
|
2026-02-04 09:28:54 +08:00
|
|
|
use support\exception\BusinessException;
|
|
|
|
|
use support\Request;
|
2026-01-07 17:23:03 +08:00
|
|
|
|
|
|
|
|
class InvRequisitionReturnService
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
use CrudServiceTrait;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 指定当前要操作的模型
|
|
|
|
|
*/
|
|
|
|
|
protected string $modelClass = InvRequisitionReturn::class;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 验证器
|
|
|
|
|
*/
|
|
|
|
|
protected $validator = InvRequisitionReturnValidate::class;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取验证器
|
|
|
|
|
*/
|
|
|
|
|
public function getValidator()
|
|
|
|
|
{
|
|
|
|
|
return new $this->validator;
|
|
|
|
|
}
|
2026-02-04 09:28:54 +08:00
|
|
|
|
|
|
|
|
public function serviceReturnConfirm(Request$request)
|
|
|
|
|
{
|
|
|
|
|
$status = $request->post('status');
|
|
|
|
|
if(in_array($status,[1,2])){
|
|
|
|
|
throw new BusinessException("状态不正确");
|
|
|
|
|
}
|
|
|
|
|
$requisitionReturn = InvRequisitionReturn::where(['id' => $request['id']])->first();
|
|
|
|
|
if (!$requisitionReturn && $requisitionReturn->handler_id == $request->user->uid) {
|
|
|
|
|
$requisitionReturn->status = $status;
|
|
|
|
|
return $requisitionReturn->save();
|
|
|
|
|
}else{
|
|
|
|
|
throw new BusinessException("审核示例不正确或非物品管理员");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 构建查询配置
|
|
|
|
|
*
|
|
|
|
|
* @param Request $request
|
|
|
|
|
* @param string $scene
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
protected function buildQueryConfig(Request $request, string $scene = 'default'): array
|
|
|
|
|
{
|
|
|
|
|
$p = $request->all();
|
|
|
|
|
|
|
|
|
|
$config = [];
|
|
|
|
|
$config['model'] = $this->modelClass;
|
|
|
|
|
switch ($scene) {
|
|
|
|
|
case 'returnConfirm':
|
|
|
|
|
$config['where']['id'] = $p['requisition_item_return_id'];
|
|
|
|
|
break;
|
|
|
|
|
case 'index':
|
|
|
|
|
if(isset($p['status'])){
|
|
|
|
|
$config['where']['status'] = $p['status'];
|
|
|
|
|
}
|
|
|
|
|
$config['order']['id'] = 'desc';
|
|
|
|
|
break;
|
|
|
|
|
case 'show':
|
|
|
|
|
$config['where']['id'] = $p['id'];
|
|
|
|
|
break;
|
|
|
|
|
case 'store':
|
|
|
|
|
break;
|
|
|
|
|
case 'update':
|
|
|
|
|
$config['where']['id'] = $p['id'];
|
|
|
|
|
break;
|
|
|
|
|
case 'destroy':
|
|
|
|
|
$config['where']['id'] = $p['id'];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $config;
|
|
|
|
|
}
|
2026-01-07 17:23:03 +08:00
|
|
|
}
|