物品领用
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\common\service\InvItemService;
|
||||
|
||||
class InvItemController extends BaseController
|
||||
{
|
||||
use CrudControllerTrait;
|
||||
|
||||
protected $service;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->service = new InvItemService();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
// protected function indexFormat($data)
|
||||
// {
|
||||
// if (isset($data['created_at']))
|
||||
// $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
|
||||
// if (isset($data['updated_at']))
|
||||
// $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
|
||||
// return $data;
|
||||
// }
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\common\service\InvRequisitionService;
|
||||
use support\Request;
|
||||
|
||||
class InvRequisitionController extends BaseController
|
||||
{
|
||||
use CrudControllerTrait;
|
||||
|
||||
protected $service;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->service = new InvRequisitionService();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
// protected function indexFormat($data)
|
||||
// {
|
||||
// if (isset($data['created_at']))
|
||||
// $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
|
||||
// if (isset($data['updated_at']))
|
||||
// $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
|
||||
// return $data;
|
||||
// }
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
namespace app\common\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\common\service\InvRequisitionAttachmentService;
|
||||
|
||||
class InvRequisitionAttachmentController extends BaseController
|
||||
{
|
||||
use CrudControllerTrait;
|
||||
|
||||
protected $service;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->service = new InvRequisitionAttachmentService();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
// protected function indexFormat($data)
|
||||
// {
|
||||
// if (isset($data['created_at']))
|
||||
// $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
|
||||
// if (isset($data['updated_at']))
|
||||
// $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
|
||||
// return $data;
|
||||
// }
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
namespace app\common\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\common\service\InvRequisitionItemService;
|
||||
|
||||
class InvRequisitionItemController extends BaseController
|
||||
{
|
||||
use CrudControllerTrait;
|
||||
|
||||
protected $service;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->service = new InvRequisitionItemService();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
// protected function indexFormat($data)
|
||||
// {
|
||||
// if (isset($data['created_at']))
|
||||
// $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
|
||||
// if (isset($data['updated_at']))
|
||||
// $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
|
||||
// return $data;
|
||||
// }
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
namespace app\common\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\common\service\InvRequisitionItemReturnAttachmentService;
|
||||
|
||||
class InvRequisitionItemReturnAttachmentController extends BaseController
|
||||
{
|
||||
use CrudControllerTrait;
|
||||
|
||||
protected $service;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->service = new InvRequisitionItemReturnAttachmentService();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
// protected function indexFormat($data)
|
||||
// {
|
||||
// if (isset($data['created_at']))
|
||||
// $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
|
||||
// if (isset($data['updated_at']))
|
||||
// $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
|
||||
// return $data;
|
||||
// }
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
namespace app\common\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\common\service\InvRequisitionItemReturnService;
|
||||
|
||||
class InvRequisitionItemReturnController extends BaseController
|
||||
{
|
||||
use CrudControllerTrait;
|
||||
|
||||
protected $service;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->service = new InvRequisitionItemReturnService();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
// protected function indexFormat($data)
|
||||
// {
|
||||
// if (isset($data['created_at']))
|
||||
// $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
|
||||
// if (isset($data['updated_at']))
|
||||
// $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
|
||||
// return $data;
|
||||
// }
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\logic;
|
||||
|
||||
use app\common\traits\crud\CrudLogicTrait;
|
||||
use app\common\model\InvItem;
|
||||
|
||||
class InvItemLogic
|
||||
{
|
||||
use CrudLogicTrait;
|
||||
|
||||
/**
|
||||
* 指定当前要操作的模型
|
||||
*/
|
||||
protected string $modelClass = InvItem::class;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\logic;
|
||||
|
||||
use app\common\traits\crud\CrudLogicTrait;
|
||||
use app\common\model\InvRequisitionAttachment;
|
||||
|
||||
class InvRequisitionAttachmentLogic
|
||||
{
|
||||
use CrudLogicTrait;
|
||||
|
||||
/**
|
||||
* 指定当前要操作的模型
|
||||
*/
|
||||
protected string $modelClass = InvRequisitionAttachment::class;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\logic;
|
||||
|
||||
use app\common\traits\crud\CrudLogicTrait;
|
||||
use app\common\model\InvRequisitionItem;
|
||||
|
||||
class InvRequisitionItemLogic
|
||||
{
|
||||
use CrudLogicTrait;
|
||||
|
||||
/**
|
||||
* 指定当前要操作的模型
|
||||
*/
|
||||
protected string $modelClass = InvRequisitionItem::class;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\logic;
|
||||
|
||||
use app\common\traits\crud\CrudLogicTrait;
|
||||
use app\common\model\InvRequisitionItemReturnAttachment;
|
||||
|
||||
class InvRequisitionItemReturnAttachmentLogic
|
||||
{
|
||||
use CrudLogicTrait;
|
||||
|
||||
/**
|
||||
* 指定当前要操作的模型
|
||||
*/
|
||||
protected string $modelClass = InvRequisitionItemReturnAttachment::class;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\logic;
|
||||
|
||||
use app\common\traits\crud\CrudLogicTrait;
|
||||
use app\common\model\InvRequisitionItemReturn;
|
||||
|
||||
class InvRequisitionItemReturnLogic
|
||||
{
|
||||
use CrudLogicTrait;
|
||||
|
||||
/**
|
||||
* 指定当前要操作的模型
|
||||
*/
|
||||
protected string $modelClass = InvRequisitionItemReturn::class;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\logic;
|
||||
|
||||
use app\common\traits\crud\CrudLogicTrait;
|
||||
use app\common\model\InvRequisition;
|
||||
|
||||
class InvRequisitionLogic
|
||||
{
|
||||
use CrudLogicTrait;
|
||||
|
||||
/**
|
||||
* 指定当前要操作的模型
|
||||
*/
|
||||
protected string $modelClass = InvRequisition::class;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
use support\Model;
|
||||
|
||||
class InvItem extends Model
|
||||
{
|
||||
/**
|
||||
* The connection name for the model.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $connection = 'mysql';
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'inv_item';
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
/**
|
||||
* Indicates if the model should be timestamped.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $timestamps = true;
|
||||
|
||||
|
||||
protected $dateFormat = 'U';
|
||||
|
||||
/**
|
||||
* 允许自动填充模型字段
|
||||
*/
|
||||
protected $fillable = ['id', 'company_id', 'item_code', 'item_name',
|
||||
'category_id', 'spec_model', 'unit', 'is_consumable', 'stock_qty', 'manage_user_id', 'location', 'remark',
|
||||
'sort', 'status',
|
||||
'created_at', 'updated_at'];
|
||||
|
||||
/**
|
||||
* 不允许自动填充模型字段
|
||||
*/
|
||||
protected $guarded = [];
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
use support\Model;
|
||||
|
||||
class InvRequisition extends Model
|
||||
{
|
||||
/**
|
||||
* The connection name for the model.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $connection = 'mysql';
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'inv_requisition';
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
/**
|
||||
* Indicates if the model should be timestamped.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $timestamps = true;
|
||||
|
||||
|
||||
protected $dateFormat = 'U';
|
||||
|
||||
/**
|
||||
* 允许自动填充模型字段
|
||||
*/
|
||||
protected $fillable = ['id', 'order_no', 'applicant_company_id', 'dept_id', 'applicant_id', 'applicant_name', 'leader_id', 'manager_id', 'borrow_reason', 'use_start_date', 'use_end_date', 'status', 'is_returned', 'remark', 'created_at', 'updated_at'];
|
||||
|
||||
/**
|
||||
* 不允许自动填充模型字段
|
||||
*/
|
||||
protected $guarded = [];
|
||||
|
||||
|
||||
const STATUS_DRAFT = 0; // 草稿
|
||||
const STATUS_LEADER = 10; // 待直属上级审批
|
||||
const STATUS_MANAGE = 20; // 待管理员审批
|
||||
const STATUS_APPROVED = 30; // 已通过
|
||||
const STATUS_REJECTEDT = 40; // 已驳回
|
||||
const STATUS_CANCELED = 50; // 已取消
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
use support\Model;
|
||||
|
||||
class InvRequisitionAttachment extends Model
|
||||
{
|
||||
/**
|
||||
* The connection name for the model.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $connection = 'mysql';
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'inv_requisition_attachment';
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
/**
|
||||
* Indicates if the model should be timestamped.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $timestamps = true;
|
||||
|
||||
|
||||
protected $dateFormat = 'U';
|
||||
|
||||
/**
|
||||
* 允许自动填充模型字段
|
||||
*/
|
||||
protected $fillable = ['id', 'requisition_id', 'file_name', 'file_path', 'file_size', 'created_at', 'updated_at'];
|
||||
|
||||
/**
|
||||
* 不允许自动填充模型字段
|
||||
*/
|
||||
protected $guarded = [];
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
use support\Model;
|
||||
|
||||
class InvRequisitionItem extends Model
|
||||
{
|
||||
/**
|
||||
* The connection name for the model.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $connection = 'mysql';
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'inv_requisition_item';
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
/**
|
||||
* Indicates if the model should be timestamped.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $timestamps = true;
|
||||
|
||||
|
||||
protected $dateFormat = 'U';
|
||||
|
||||
/**
|
||||
* 允许自动填充模型字段
|
||||
*/
|
||||
protected $fillable = ['id', 'requisition_id', 'item_id', 'item_name_snap', 'spec_model_snap', 'unit_snap', 'is_consumable_snap', 'request_qty', 'approved_qty', 'returned_qty', 'is_finished', 'remark', 'created_at', 'updated_at'];
|
||||
|
||||
/**
|
||||
* 不允许自动填充模型字段
|
||||
*/
|
||||
protected $guarded = [];
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
use support\Model;
|
||||
|
||||
class InvRequisitionItemReturn extends Model
|
||||
{
|
||||
/**
|
||||
* The connection name for the model.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $connection = 'mysql';
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'inv_requisition_item_return';
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
/**
|
||||
* Indicates if the model should be timestamped.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $timestamps = true;
|
||||
|
||||
|
||||
protected $dateFormat = 'U';
|
||||
|
||||
/**
|
||||
* 允许自动填充模型字段
|
||||
*/
|
||||
protected $fillable = ['id', 'requisition_id', 'requisition_item_id', 'item_id', 'apply_user_id', 'apply_user_name', 'return_qty', 'status', 'handler_id', 'handler_name', 'return_status', 'apply_remark', 'handle_remark', 'return_at', 'created_at', 'updated_at'];
|
||||
|
||||
/**
|
||||
* 不允许自动填充模型字段
|
||||
*/
|
||||
protected $guarded = [];
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
use support\Model;
|
||||
|
||||
class InvRequisitionItemReturnAttachment extends Model
|
||||
{
|
||||
/**
|
||||
* The connection name for the model.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $connection = 'mysql';
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'inv_requisition_item_return_attachment';
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
/**
|
||||
* Indicates if the model should be timestamped.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $timestamps = true;
|
||||
|
||||
|
||||
protected $dateFormat = 'U';
|
||||
|
||||
/**
|
||||
* 允许自动填充模型字段
|
||||
*/
|
||||
protected $fillable = ['id', 'return_id', 'file_name', 'file_path', 'file_size', 'created_at', 'updated_at'];
|
||||
|
||||
/**
|
||||
* 不允许自动填充模型字段
|
||||
*/
|
||||
protected $guarded = [];
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\service;
|
||||
|
||||
use app\common\validate\InvItemValidate;
|
||||
use app\common\traits\crud\CrudServiceTrait;
|
||||
use app\common\model\InvItem;
|
||||
use support\Request;
|
||||
|
||||
class InvItemService
|
||||
{
|
||||
|
||||
use CrudServiceTrait;
|
||||
|
||||
/**
|
||||
* 指定当前要操作的模型
|
||||
*/
|
||||
protected string $modelClass = InvItem::class;
|
||||
|
||||
/**
|
||||
* 验证器
|
||||
*/
|
||||
protected $validator = InvItemValidate::class;
|
||||
|
||||
/**
|
||||
* 获取验证器
|
||||
*/
|
||||
public function getValidator()
|
||||
{
|
||||
return new $this->validator;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成 8-12 位的物品编码(默认10位)
|
||||
*
|
||||
* @param int $length 编码长度,默认为10(范围 8-12)
|
||||
* @return string 返回大写的字母数字组合编码
|
||||
*/
|
||||
private function generateItemCode($length = 10)
|
||||
{
|
||||
// 排除易混淆字符:0, O, o, 1, I, l
|
||||
$chars = '23456789ABCDEFGHJKLMNPQRSTUVWXYZ';
|
||||
$code = '';
|
||||
$maxIndex = strlen($chars) - 1;
|
||||
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
$code .= $chars[mt_rand(0, $maxIndex)];
|
||||
}
|
||||
|
||||
return $code;
|
||||
}
|
||||
|
||||
|
||||
public function beforeServiceStore($data, Request $request): array
|
||||
{
|
||||
$data['item_code'] = $this->generateItemCode();
|
||||
$data['category_id'] = 0;
|
||||
$data['spec_model'] = '';
|
||||
$data['unit'] = '件';
|
||||
$data['is_consumable'] = 0;
|
||||
$data['stock_qty'] = 1;
|
||||
$data['location'] = '';
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\service;
|
||||
|
||||
use app\common\validate\InvRequisitionAttachmentValidate;
|
||||
use app\common\traits\crud\CrudServiceTrait;
|
||||
use app\common\model\InvRequisitionAttachment;
|
||||
|
||||
class InvRequisitionAttachmentService
|
||||
{
|
||||
|
||||
use CrudServiceTrait;
|
||||
|
||||
/**
|
||||
* 指定当前要操作的模型
|
||||
*/
|
||||
protected string $modelClass = InvRequisitionAttachment::class;
|
||||
|
||||
/**
|
||||
* 验证器
|
||||
*/
|
||||
protected $validator = InvRequisitionAttachmentValidate::class;
|
||||
|
||||
/**
|
||||
* 获取验证器
|
||||
*/
|
||||
public function getValidator()
|
||||
{
|
||||
return new $this->validator;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\service;
|
||||
|
||||
use app\common\validate\InvRequisitionItemReturnAttachmentValidate;
|
||||
use app\common\traits\crud\CrudServiceTrait;
|
||||
use app\common\model\InvRequisitionItemReturnAttachment;
|
||||
|
||||
class InvRequisitionItemReturnAttachmentService
|
||||
{
|
||||
|
||||
use CrudServiceTrait;
|
||||
|
||||
/**
|
||||
* 指定当前要操作的模型
|
||||
*/
|
||||
protected string $modelClass = InvRequisitionItemReturnAttachment::class;
|
||||
|
||||
/**
|
||||
* 验证器
|
||||
*/
|
||||
protected $validator = InvRequisitionItemReturnAttachmentValidate::class;
|
||||
|
||||
/**
|
||||
* 获取验证器
|
||||
*/
|
||||
public function getValidator()
|
||||
{
|
||||
return new $this->validator;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,297 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\service;
|
||||
|
||||
use app\common\model\InvRequisitionItem;
|
||||
use app\common\validate\InvRequisitionItemReturnValidate;
|
||||
use app\common\traits\crud\CrudServiceTrait;
|
||||
use app\common\model\InvRequisitionItemReturn;
|
||||
use support\Request;
|
||||
use support\Db;
|
||||
use support\exception\BusinessException;
|
||||
use app\common\service\UserService;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use app\common\model\InvRequisitionItemReturnAttachment;
|
||||
|
||||
class InvRequisitionItemReturnService
|
||||
{
|
||||
|
||||
use CrudServiceTrait;
|
||||
|
||||
/**
|
||||
* 指定当前要操作的模型
|
||||
*/
|
||||
protected string $modelClass = InvRequisitionItemReturn::class;
|
||||
|
||||
/**
|
||||
* 验证器
|
||||
*/
|
||||
protected $validator = InvRequisitionItemReturnValidate::class;
|
||||
|
||||
/**
|
||||
* 获取验证器
|
||||
*/
|
||||
public function getValidator()
|
||||
{
|
||||
return new $this->validator;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将二维数组按指定 key 重组为关联数组,该 key 的值作为新数组的键,
|
||||
* 其余元素组成子数组作为值。
|
||||
*
|
||||
* @param array $array 原始二维数组
|
||||
* @param string $keyField 用作新键的字段名(如 'id')
|
||||
* @return array 重组后的数组
|
||||
*/
|
||||
private function groupArrayByKey($array, $keyField = 'id')
|
||||
{
|
||||
$result = [];
|
||||
foreach ($array as $item) {
|
||||
if (!isset($item[$keyField])) {
|
||||
continue; // 跳过没有该 key 的项
|
||||
}
|
||||
$key = $item[$keyField];
|
||||
// 移除用作键的字段
|
||||
unset($item[$keyField]);
|
||||
$result[$key] = $item;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 创建物品归还申请前置处理
|
||||
*
|
||||
* @param array $data 归还申请数据
|
||||
* @param Request $request 请求对象
|
||||
* @return array 处理后的数据
|
||||
*/
|
||||
public function beforeServiceStore($data, Request $request): array
|
||||
{
|
||||
try {
|
||||
// // 模拟数据
|
||||
// $data = [
|
||||
// [
|
||||
// 'requisition_item_id' => 9,
|
||||
// 'return_qty' => 1,
|
||||
// 'apply_remark' => '申请备注',
|
||||
// 'attachment' => [
|
||||
// [
|
||||
// 'original_name' => '附件1.jpg',
|
||||
// 'file_path' => '/uploads/2023/07/01/attachment1.jpg'
|
||||
// ],
|
||||
// [
|
||||
// 'original_name' => '附件2.jpg',
|
||||
// 'file_path' => '/uploads/2023/07/01/attachment2.jpg'
|
||||
// ]
|
||||
// ]
|
||||
// ]
|
||||
// ];
|
||||
|
||||
// 获取所有申请项ID
|
||||
$reqItemIds = array_column($data, 'requisition_item_id');
|
||||
|
||||
// 参数校验
|
||||
if (empty($reqItemIds)) {
|
||||
throw new BusinessException('未提供有效的申请项ID');
|
||||
}
|
||||
|
||||
// 将申请项按 ID 重组为关联数组
|
||||
$newReqItems = $this->groupArrayByKey($data, 'requisition_item_id');
|
||||
|
||||
// 获取申请项明细
|
||||
$reqItemsArr = InvRequisitionItem::whereIn('id', $reqItemIds)->get()->toArray();
|
||||
|
||||
// 检查是否获取到有效数据
|
||||
if (empty($reqItemsArr)) {
|
||||
throw new BusinessException('未找到对应的申请项');
|
||||
}
|
||||
|
||||
// 获取用户信息
|
||||
$userService = new UserService();
|
||||
$user = $userService->getUserInfo($request->user->uid, '');
|
||||
|
||||
$arr = [];
|
||||
foreach ($reqItemsArr as $reqItem) {
|
||||
$reqItemId = $reqItem['id'];
|
||||
|
||||
// 检查是否有对应的新申请项数据
|
||||
if (!isset($newReqItems[$reqItemId])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$arr[] = [
|
||||
'requisition_id' => $reqItem['requisition_id'],
|
||||
'requisition_item_id' => $reqItemId,
|
||||
'item_id' => $reqItem['item_id'],
|
||||
'apply_user_id' => $user['user']['id'],
|
||||
'apply_user_name' => $user['user']['name'],
|
||||
'return_qty' => $newReqItems[$reqItemId]['return_qty'],
|
||||
'apply_remark' => $newReqItems[$reqItemId]['apply_remark'] ?? '',
|
||||
'attachment' => $newReqItems[$reqItemId]['attachment'],
|
||||
'return_at' => time()
|
||||
];
|
||||
}
|
||||
|
||||
return $arr;
|
||||
} catch (BusinessException $e) {
|
||||
throw $e;
|
||||
} catch (\Throwable $th) {
|
||||
throw new BusinessException('创建物品归还申请失败:' . $th->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理物品申请
|
||||
*
|
||||
* @param Request $request
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
public function serviceStore(Request $request, array $data, string $scene = '')
|
||||
{
|
||||
try {
|
||||
// 关联表增加事务处理
|
||||
return Db::transaction(function () use ($request, $data) {
|
||||
$data = $this->preProcess('Store', $data, $request);
|
||||
$dl = $this->getDataLimitFromRequest($request);
|
||||
foreach ($data as $item) {
|
||||
$created = $this->logicCreate($item, $dl);
|
||||
$this->processRequisitionItemReturnAttachment($created, $item['attachment']);
|
||||
}
|
||||
return $this->postProcess('Store', $created);
|
||||
});
|
||||
} catch (\Throwable $e) {
|
||||
throw new BusinessException("创建物品申请失败:" . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 更新物品归还申请前置处理
|
||||
*
|
||||
* @param array $data 归还申请数据
|
||||
* @param Request $request 请求对象
|
||||
* @return array 处理后的数据
|
||||
*/
|
||||
public function beforeServiceUpdate($data, Request $request): array
|
||||
{
|
||||
// // 模拟数据
|
||||
// $data = [
|
||||
// 'id' => 1,
|
||||
// 'requisition_item_id' => 9,
|
||||
// 'return_qty' => 1,
|
||||
// 'apply_remark' => '申请备注22',
|
||||
// 'attachment' => [
|
||||
// [
|
||||
// 'original_name' => '附件1.jpg',
|
||||
// 'file_path' => '/uploads/2023/07/01/attachment1.jpg'
|
||||
// ],
|
||||
// [
|
||||
// 'original_name' => '附件2.jpg',
|
||||
// 'file_path' => '/uploads/2023/07/01/attachment2.jpg'
|
||||
// ],
|
||||
// [
|
||||
// 'original_name' => '附件3.jpg',
|
||||
// 'file_path' => '/uploads/2023/07/01/attachment3.jpg'
|
||||
// ]
|
||||
// ]
|
||||
// ];
|
||||
|
||||
$data['return_at'] = time();
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新物品归还申请
|
||||
*
|
||||
* @param Request $request
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
public function serviceUpdate(Request $request, array $data, string $scene = '')
|
||||
{
|
||||
try {
|
||||
// 关联表增加事务处理
|
||||
return Db::transaction(function () use ($request, $data) {
|
||||
$data = $this->preProcess('Update', $data, $request);
|
||||
$config = $this->buildQueryConfig($request, 'update');
|
||||
|
||||
$attachment = $data['attachment'];
|
||||
unset($data['attachment']);
|
||||
|
||||
$this->logicUpdateBy($config, $data);
|
||||
// 获取更新后的完整记录
|
||||
$updated = $this->logicShow($config);
|
||||
// 处理附件更新
|
||||
$this->processRequisitionItemReturnAttachment($updated, $attachment, true);
|
||||
return $this->postProcess('Update', $updated);
|
||||
});
|
||||
} catch (\Throwable $e) {
|
||||
throw new BusinessException("更新物品归还申请失败:" . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理物品申请附件
|
||||
*
|
||||
* @param Model $created
|
||||
* @param array $items
|
||||
* @param bool $isUpdate
|
||||
* @return void
|
||||
*/
|
||||
private function processRequisitionItemReturnAttachment(Model $created, array $attachment, bool $isUpdate = false): void
|
||||
{
|
||||
if ($isUpdate) {
|
||||
$this->clearRequisitionItemReturnAttachment($created->id);
|
||||
}
|
||||
|
||||
foreach ($attachment as $file) {
|
||||
$attachmentData = [
|
||||
'return_id' => $created->id,
|
||||
'file_name' => $file['original_name'],
|
||||
'file_path' => $file['file_path']
|
||||
];
|
||||
InvRequisitionItemReturnAttachment::create($attachmentData);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空物品申请附件
|
||||
*
|
||||
* @param int $returnId
|
||||
* @return void
|
||||
*/
|
||||
private function clearRequisitionItemReturnAttachment(int $returnId): void
|
||||
{
|
||||
InvRequisitionItemReturnAttachment::where('return_id', $returnId)->delete();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function returnConfirm(Request $request, array $data, string $scene = '')
|
||||
{
|
||||
try {
|
||||
|
||||
// 关联表增加事务处理
|
||||
return Db::transaction(function () use ($request, $data) {
|
||||
$data = $this->preProcess('Update', $data, $request);
|
||||
$config = $this->buildQueryConfig($request, 'update');
|
||||
|
||||
$attachment = $data['attachment'];
|
||||
unset($data['attachment']);
|
||||
|
||||
$this->logicUpdateBy($config, $data);
|
||||
// 获取更新后的完整记录
|
||||
$updated = $this->logicShow($config);
|
||||
// 处理附件更新
|
||||
$this->processRequisitionItemReturnAttachment($updated, $attachment, true);
|
||||
return $this->postProcess('Update', $updated);
|
||||
});
|
||||
|
||||
} catch (\Throwable $e) {
|
||||
throw new BusinessException("确认归还物品失败:" . $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\service;
|
||||
|
||||
use app\common\validate\InvRequisitionItemValidate;
|
||||
use app\common\traits\crud\CrudServiceTrait;
|
||||
use app\common\model\InvRequisitionItem;
|
||||
|
||||
class InvRequisitionItemService
|
||||
{
|
||||
|
||||
use CrudServiceTrait;
|
||||
|
||||
/**
|
||||
* 指定当前要操作的模型
|
||||
*/
|
||||
protected string $modelClass = InvRequisitionItem::class;
|
||||
|
||||
/**
|
||||
* 验证器
|
||||
*/
|
||||
protected $validator = InvRequisitionItemValidate::class;
|
||||
|
||||
/**
|
||||
* 获取验证器
|
||||
*/
|
||||
public function getValidator()
|
||||
{
|
||||
return new $this->validator;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,208 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\service;
|
||||
|
||||
use app\common\validate\InvRequisitionValidate;
|
||||
use app\common\traits\crud\CrudServiceTrait;
|
||||
use app\common\model\InvRequisition;
|
||||
use app\common\model\InvRequisitionAttachment;
|
||||
use app\common\model\InvRequisitionItem;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use support\Request;
|
||||
use support\Db;
|
||||
use support\exception\BusinessException;
|
||||
|
||||
class InvRequisitionService
|
||||
{
|
||||
|
||||
use CrudServiceTrait;
|
||||
|
||||
/**
|
||||
* 指定当前要操作的模型
|
||||
*/
|
||||
protected string $modelClass = InvRequisition::class;
|
||||
|
||||
/**
|
||||
* 验证器
|
||||
*/
|
||||
protected $validator = InvRequisitionValidate::class;
|
||||
|
||||
/**
|
||||
* 获取验证器
|
||||
*/
|
||||
public function getValidator()
|
||||
{
|
||||
return new $this->validator;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 创建物品申请 前置
|
||||
*
|
||||
* @param array $data
|
||||
* @param Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function beforeServiceStore($data, Request $request): array
|
||||
{
|
||||
$user = (new UserService())->getUserInfo($request->user->uid, '');
|
||||
|
||||
$data['order_no'] = $this->generateOrderNo();
|
||||
$data['applicant_id'] = $user['user']['id'];
|
||||
$data['applicant_name'] = $user['user']['name'];
|
||||
$data['leader_id'] = $user['user']['report_to'];
|
||||
$data['status'] = InvRequisition::STATUS_LEADER;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理物品申请
|
||||
*
|
||||
* @param Request $request
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
public function serviceStore(Request $request, array $data, string $scene = '')
|
||||
{
|
||||
try {
|
||||
// 关联表增加事务处理
|
||||
return Db::transaction(function () use ($request, $data) {
|
||||
$data = $this->preProcess('Store', $data, $request);
|
||||
$dl = $this->getDataLimitFromRequest($request);
|
||||
$created = $this->logicCreate($data, $dl);
|
||||
// 处理物品申请项
|
||||
$this->processRequisitionItems($created, $data['items']);
|
||||
// 处理物品申请附件
|
||||
$this->processRequisitionAttachmentItems($created, $data['attachment']);
|
||||
return $this->postProcess('Store', $created);
|
||||
});
|
||||
} catch (\Throwable $e) {
|
||||
throw new BusinessException("创建物品申请失败:" . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新物品申请
|
||||
*
|
||||
* @param Request $request
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
public function serviceUpdate(Request $request, array $data, string $scene = '')
|
||||
{
|
||||
try {
|
||||
// 关联表增加事务处理
|
||||
return Db::transaction(function () use ($request, $data) {
|
||||
$data = $this->preProcess('Update', $data, $request);
|
||||
$config = $this->buildQueryConfig($request, 'update');
|
||||
|
||||
// 获取申请项/附件
|
||||
$items = $data['items'];
|
||||
$attachment = $data['attachment'];
|
||||
unset($data['items']);
|
||||
unset($data['attachment']);
|
||||
|
||||
// 执行更新操作
|
||||
$this->logicUpdateBy($config, $data);
|
||||
|
||||
// 获取更新后的完整记录
|
||||
$updated = $this->logicShow($config);
|
||||
|
||||
// 重新创建新的申请项
|
||||
$this->processRequisitionItems((object)$updated, $items, true);
|
||||
|
||||
// 重新创建新的附件
|
||||
$this->processRequisitionAttachmentItems((object)$updated, $attachment, true);
|
||||
|
||||
return $this->postProcess('Update', $updated);
|
||||
});
|
||||
} catch (\Throwable $e) {
|
||||
throw new BusinessException("更新物品申请失败:" . $e->getMessage()."|".$e->getLine()."|".$e->getFile());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理物品申请项
|
||||
*
|
||||
* @param Model $created
|
||||
* @param array $items
|
||||
* @return void
|
||||
*/
|
||||
private function processRequisitionItems(Model $created, array $items, bool $isUpdate = false): void
|
||||
{
|
||||
if ($isUpdate) {
|
||||
$this->clearRequisitionItems($created->id);
|
||||
}
|
||||
|
||||
foreach ($items as $item) {
|
||||
$itemData = [
|
||||
'requisition_id' => $created->id,
|
||||
'item_id' => $item['item_id'],
|
||||
'item_name_snap' => $item['item_name_snap'], // 修改:使用 snap 字段
|
||||
'spec_model_snap' => $item['spec_model_snap'], // 修改:使用 snap 字段
|
||||
'unit_snap' => $item['unit_snap'], // 修改:使用 snap 字段
|
||||
'is_consumable_snap' => $item['is_consumable_snap'], // 修改:使用 snap 字段
|
||||
'request_qty' => (int) $item['request_qty'] ?? 1, // 动态获取数量,转为整型
|
||||
'approved_qty' => (int) $item['request_qty'] ?? 1, // 初始审批数量等于申请数量
|
||||
'remark' => $item['remark'] ?? ''
|
||||
];
|
||||
InvRequisitionItem::create($itemData);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理物品申请项
|
||||
*
|
||||
* @param Model $created
|
||||
* @param array $items
|
||||
* @return void
|
||||
*/
|
||||
private function processRequisitionAttachmentItems(Model $created, array $attachment, bool $isUpdate = false): void
|
||||
{
|
||||
if ($isUpdate) {
|
||||
$this->clearRequisitionAttachmentItems($created->id);
|
||||
}
|
||||
|
||||
foreach ($attachment as $file) {
|
||||
$attachmentData = [
|
||||
'requisition_id' => $created->id,
|
||||
'file_name' => $file['original_name'],
|
||||
'file_path' => $file['file_path']
|
||||
];
|
||||
InvRequisitionAttachment::create($attachmentData);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除申请项
|
||||
*
|
||||
* @param int $requisitionId
|
||||
* @return void
|
||||
*/
|
||||
public function clearRequisitionItems(int $requisitionId): void
|
||||
{
|
||||
InvRequisitionItem::where('requisition_id', $requisitionId)->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除申请项
|
||||
*
|
||||
* @param int $requisitionId
|
||||
* @return void
|
||||
*/
|
||||
public function clearRequisitionAttachmentItems(int $requisitionId): void
|
||||
{
|
||||
InvRequisitionAttachment::where('requisition_id', $requisitionId)->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成申请单号
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function generateOrderNo(): string
|
||||
{
|
||||
return 'RQ' . date('Ymd') . strtoupper(substr(uniqid(), -6));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class InvItemValidate extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class InvRequisitionAttachmentValidate extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class InvRequisitionItemReturnAttachmentValidate extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class InvRequisitionItemReturnValidate extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class InvRequisitionItemValidate extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class InvRequisitionValidate extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
'applicant_id' => 'number',
|
||||
'borrow_reason' => 'require|max:255',
|
||||
'use_start_date' => 'require|date',
|
||||
'use_end_date' => 'date',
|
||||
'items' => 'require|array',
|
||||
'items.*.item_id' => 'require|number',
|
||||
'items.*.request_qty' => 'require|number|gt:0',
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
'applicant_id.number' => '申请人格式错误',
|
||||
'borrow_reason.require' => '领用事由不能为空',
|
||||
'borrow_reason.max' => '领用事由最多不能超过255个字符',
|
||||
'use_start_date.require' => '使用开始日期不能为空',
|
||||
'use_start_date.date' => '使用开始日期格式错误',
|
||||
'use_end_date.date' => '预计归还日期格式错误',
|
||||
'items.require' => '申请物品明细不能为空',
|
||||
'items.array' => '申请物品明细格式错误',
|
||||
'items.*.item_id.require' => '物品ID不能为空',
|
||||
'items.*.item_id.number' => '物品ID格式错误',
|
||||
'items.*.request_qty.require' => '申请数量不能为空',
|
||||
'items.*.request_qty.number' => '申请数量格式错误',
|
||||
'items.*.request_qty.gt' => '申请数量必须大于0',
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
],
|
||||
|
||||
'apply' => [
|
||||
'applicant_id',
|
||||
'borrow_reason',
|
||||
'use_start_date',
|
||||
'use_end_date',
|
||||
'items'
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -74,25 +74,25 @@ class IndexController
|
||||
$options = [
|
||||
'controller' => [
|
||||
'module' => 'common',
|
||||
'name' => 'usedcar_crawl_results_images'
|
||||
'name' => 'inv_requisition_item_return_attachment'
|
||||
],
|
||||
'model' => [
|
||||
'module' => 'common',
|
||||
'name' => 'usedcar_crawl_results_images'
|
||||
'name' => 'inv_requisition_item_return_attachment'
|
||||
],
|
||||
'service' => [
|
||||
'module' => 'common',
|
||||
'name' => 'usedcar_crawl_results_images'
|
||||
'name' => 'inv_requisition_item_return_attachment'
|
||||
],
|
||||
'logic' => [
|
||||
'module' => 'common',
|
||||
'name' => 'usedcar_crawl_results_images'
|
||||
'name' => 'inv_requisition_item_return_attachment'
|
||||
],
|
||||
'validate' => [
|
||||
'module' => 'common',
|
||||
'name' => 'usedcar_crawl_results_images'
|
||||
'name' => 'inv_requisition_item_return_attachment'
|
||||
],
|
||||
'table' => 'usedcar_crawl_results_images'
|
||||
'table' => 'inv_requisition_item_return_attachment'
|
||||
];
|
||||
|
||||
$result = (new Generate($options))->doGenerate();
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
namespace app\mobile\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\common\service\InvRequisitionService;
|
||||
use support\Request;
|
||||
|
||||
class InvRequisitionController extends BaseController
|
||||
{
|
||||
use CrudControllerTrait;
|
||||
|
||||
protected $service;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->service = new InvRequisitionService();
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交物品申请
|
||||
*
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function apply(Request $request)
|
||||
{
|
||||
try {
|
||||
// 验证申请数据
|
||||
$data = $this->validate($this->service->getValidator(), $request->post(), 'apply');
|
||||
|
||||
// 处理申请逻辑
|
||||
$result = $this->service->serviceStore($request, $data, 'apply');
|
||||
|
||||
return $this->success($result, '申请提交成功');
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
// protected function indexFormat($data)
|
||||
// {
|
||||
// if (isset($data['created_at']))
|
||||
// $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
|
||||
// if (isset($data['updated_at']))
|
||||
// $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
|
||||
// return $data;
|
||||
// }
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
namespace app\mobile\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\common\service\InvRequisitionItemReturnService;
|
||||
use support\Request;
|
||||
|
||||
class InvRequisitionItemReturnController extends BaseController
|
||||
{
|
||||
use CrudControllerTrait;
|
||||
|
||||
protected $service;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->service = new InvRequisitionItemReturnService();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
// protected function indexFormat($data)
|
||||
// {
|
||||
// if (isset($data['created_at']))
|
||||
// $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
|
||||
// if (isset($data['updated_at']))
|
||||
// $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
|
||||
// return $data;
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
* 物品兑换确认
|
||||
*
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function returnConfirm(Request $request)
|
||||
{
|
||||
try {
|
||||
// 验证申请数据
|
||||
$data = $this->validate($this->service->getValidator(), $request->post(), 'returnConfirm');
|
||||
|
||||
// 处理申请逻辑
|
||||
$result = $this->service->returnConfirm($request, $data, 'returnConfirm');
|
||||
|
||||
return $this->success($result, '申请提交成功');
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,16 +12,6 @@ class CheckWeb
|
||||
|
||||
public function onWorkerStart()
|
||||
{
|
||||
// if (getenv('ENVIRONMENT') === 'master') {
|
||||
// new Crontab('0 */10 * * * *', function(){
|
||||
// $result = $this->tocurl('https://magicbridgeauto.com');
|
||||
// if (!preg_match('/magicbridgeauto/', $result['body'])) {
|
||||
// flg("【magicbridgeauto】疑似被篡改");
|
||||
// }
|
||||
// return true;
|
||||
// });
|
||||
// }
|
||||
|
||||
// 每秒执行:队列二手车数据处理
|
||||
new Crontab('* * * * * *', function(){
|
||||
$service = new \app\common\utils\crawl\service\UsedCarCrawl();
|
||||
|
||||
+2
-1
@@ -48,7 +48,8 @@
|
||||
"webman/gateway-worker": "^1.0",
|
||||
"mpdf/mpdf": "^8.2",
|
||||
"jaeger/querylist": "^4.4",
|
||||
"zoujingli/ip2region": "^3.0"
|
||||
"zoujingli/ip2region": "^3.0",
|
||||
"webman/log": "^2.1"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-event": "For better performance. "
|
||||
|
||||
Generated
+333
-291
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
return [
|
||||
'enable' => true,
|
||||
'exception' => [
|
||||
// 是否记录异常到日志
|
||||
'enable' => true,
|
||||
// 不会记录到日志的异常类
|
||||
'dontReport' => [
|
||||
support\exception\BusinessException::class
|
||||
]
|
||||
],
|
||||
'dontReport' => [
|
||||
'app' => [],
|
||||
'controller' => [],
|
||||
'action' => [],
|
||||
'path' => []
|
||||
],
|
||||
'channel' => 'default' // 日志通道(在config/log.php里配置,默认是default)
|
||||
];
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of webman.
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* For full copyright and license information, please see the MIT-LICENSE.txt
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @author walkor<walkor@workerman.net>
|
||||
* @copyright walkor<walkor@workerman.net>
|
||||
* @link http://www.workerman.net/
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
|
||||
use Webman\Log\Middleware;
|
||||
|
||||
return [
|
||||
'@' => [
|
||||
Middleware::class
|
||||
]
|
||||
];
|
||||
@@ -505,6 +505,16 @@ Route::group('/admin', function () {
|
||||
Route::any('/destroy', [app\admin\controller\FinanceReconDubaiFilesController::class, 'destroy']);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
// 物品领用
|
||||
Route::group('/inv', function () {
|
||||
Route::any('/item/list', [app\admin\controller\InvItemController::class, 'index']);
|
||||
Route::any('/item/store', [app\admin\controller\InvItemController::class, 'store']);
|
||||
Route::any('/item/update', [app\admin\controller\InvItemController::class, 'update']);
|
||||
Route::any('/item/show', [app\admin\controller\InvItemController::class, 'show']);
|
||||
Route::any('/item/destroy', [app\admin\controller\InvItemController::class, 'destroy']);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -625,3 +635,16 @@ Route::group('/crm', function () {
|
||||
Route::any('/destroy', [app\common\controller\VehModificationController::class, 'destroy']);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
// 移动端
|
||||
Route::group('/mobile', function () {
|
||||
// 物品领用
|
||||
Route::group('/inv', function () {
|
||||
Route::any('/requisition/apply', [app\mobile\controller\InvRequisitionController::class, 'apply']);
|
||||
Route::any('/requisition/update', [app\mobile\controller\InvRequisitionController::class, 'update']);
|
||||
Route::any('/requisition/item/return', [app\mobile\controller\InvRequisitionItemReturnController::class, 'store']);
|
||||
Route::any('/requisition/item/return/update', [app\mobile\controller\InvRequisitionItemReturnController::class, 'update']);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,174 @@
|
||||
SET NAMES utf8mb4;
|
||||
SET FOREIGN_KEY_CHECKS = 0;
|
||||
|
||||
-- 1. 物品主数据表:增加 company_id
|
||||
DROP TABLE IF EXISTS inv_item;
|
||||
CREATE TABLE inv_item (
|
||||
id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||
company_id BIGINT(20) UNSIGNED DEFAULT NULL COMMENT '物品所属公司ID',
|
||||
item_code VARCHAR(64) NOT NULL COMMENT '物品编号(公司内部编码)',
|
||||
item_name VARCHAR(128) NOT NULL COMMENT '物品名称',
|
||||
category_id BIGINT(20) UNSIGNED DEFAULT NULL COMMENT '物品分类ID(可选,指向分类表)',
|
||||
spec_model VARCHAR(128) DEFAULT NULL COMMENT '规格型号',
|
||||
unit VARCHAR(32) DEFAULT '件' COMMENT '计量单位,如 件/盒/包',
|
||||
is_consumable TINYINT(1) DEFAULT 1 COMMENT '是否耗材:1耗材(不需归还),0非耗材(需归还)',
|
||||
stock_qty INT(11) DEFAULT 0 COMMENT '当前库存数量',
|
||||
manage_user_id BIGINT(20) UNSIGNED DEFAULT NULL COMMENT '物品管理员用户ID',
|
||||
location VARCHAR(255) DEFAULT NULL COMMENT '存放位置说明',
|
||||
remark VARCHAR(255) DEFAULT NULL COMMENT '备注',
|
||||
created_at INT(11) NOT NULL DEFAULT 0 COMMENT '创建时间时间戳',
|
||||
updated_at INT(11) NOT NULL DEFAULT 0 COMMENT '更新时间时间戳',
|
||||
PRIMARY KEY (id),
|
||||
UNIQUE KEY uk_item_code (item_code),
|
||||
KEY idx_company (company_id),
|
||||
KEY idx_category (category_id),
|
||||
KEY idx_manage_user (manage_user_id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='物品主数据表';
|
||||
|
||||
|
||||
-- 2. 物品领用/借用申请单(主表)
|
||||
DROP TABLE IF EXISTS inv_requisition;
|
||||
CREATE TABLE inv_requisition (
|
||||
id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||
order_no VARCHAR(64) NOT NULL COMMENT '申请单号',
|
||||
|
||||
applicant_company_id BIGINT(20) UNSIGNED DEFAULT NULL COMMENT '申请人所在公司ID(可选)',
|
||||
dept_id BIGINT(20) UNSIGNED DEFAULT NULL COMMENT '申请人部门ID',
|
||||
applicant_id BIGINT(20) UNSIGNED NOT NULL COMMENT '申请人用户ID',
|
||||
applicant_name VARCHAR(64) DEFAULT NULL COMMENT '申请人姓名快照',
|
||||
leader_id BIGINT(20) UNSIGNED DEFAULT NULL COMMENT '直属上级用户ID',
|
||||
manager_id BIGINT(20) UNSIGNED DEFAULT NULL COMMENT '物品管理员用户ID(主负责人)',
|
||||
|
||||
borrow_reason VARCHAR(255) NOT NULL COMMENT '领用/借用事由',
|
||||
use_start_date DATE NOT NULL COMMENT '借用/预计使用开始日期',
|
||||
use_end_date DATE DEFAULT NULL COMMENT '预计归还日期(耗材可为空)',
|
||||
|
||||
-- 0草稿 10待直属上级审批 20直属上级通过待物品管理员审批
|
||||
-- 30全部通过 40已驳回 50已取消
|
||||
status TINYINT(3) NOT NULL DEFAULT 10 COMMENT '审批状态',
|
||||
|
||||
is_returned TINYINT(1) NOT NULL DEFAULT 0 COMMENT '是否已全部归还(针对需要归还的物品):0否 1是',
|
||||
|
||||
remark VARCHAR(255) DEFAULT NULL COMMENT '备注',
|
||||
created_at INT(11) NOT NULL DEFAULT 0 COMMENT '创建时间时间戳',
|
||||
updated_at INT(11) NOT NULL DEFAULT 0 COMMENT '更新时间时间戳',
|
||||
|
||||
PRIMARY KEY (id),
|
||||
UNIQUE KEY uk_order_no (order_no),
|
||||
KEY idx_applicant (applicant_id),
|
||||
KEY idx_status (status)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='物品领用/借用申请单';
|
||||
|
||||
|
||||
-- 3. 申请单明细表:支持部分、多次归还
|
||||
DROP TABLE IF EXISTS inv_requisition_item;
|
||||
CREATE TABLE inv_requisition_item (
|
||||
id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||
requisition_id BIGINT(20) UNSIGNED NOT NULL COMMENT '申请单ID',
|
||||
item_id BIGINT(20) UNSIGNED NOT NULL COMMENT '物品ID',
|
||||
|
||||
item_name_snap VARCHAR(128) DEFAULT NULL COMMENT '物品名称快照',
|
||||
spec_model_snap VARCHAR(128) DEFAULT NULL COMMENT '规格型号快照',
|
||||
unit_snap VARCHAR(32) DEFAULT NULL COMMENT '单位快照',
|
||||
is_consumable_snap TINYINT(1) DEFAULT NULL COMMENT '是否耗材快照:1耗材 0非耗材',
|
||||
|
||||
request_qty INT(11) NOT NULL DEFAULT 1 COMMENT '申请数量',
|
||||
approved_qty INT(11) DEFAULT NULL COMMENT '实批数量(可与申请数量不同)',
|
||||
returned_qty INT(11) NOT NULL DEFAULT 0 COMMENT '已归还数量(累加)',
|
||||
|
||||
-- 对于非耗材:returned_qty >= approved_qty 时置为1
|
||||
is_finished TINYINT(1) NOT NULL DEFAULT 0 COMMENT '该物品是否已完成归还:0否 1是',
|
||||
|
||||
remark VARCHAR(255) DEFAULT NULL COMMENT '行备注',
|
||||
created_at INT(11) NOT NULL DEFAULT 0 COMMENT '创建时间时间戳',
|
||||
updated_at INT(11) NOT NULL DEFAULT 0 COMMENT '更新时间时间戳',
|
||||
|
||||
PRIMARY KEY (id),
|
||||
KEY idx_req (requisition_id),
|
||||
KEY idx_item (item_id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='物品领用申请明细表';
|
||||
|
||||
|
||||
-- 4. 审批记录表(同上一版,略微无改动)
|
||||
DROP TABLE IF EXISTS inv_requisition_approve;
|
||||
CREATE TABLE inv_requisition_approve (
|
||||
id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||
requisition_id BIGINT(20) UNSIGNED NOT NULL COMMENT '申请单ID',
|
||||
node_type VARCHAR(32) NOT NULL COMMENT '审批节点类型:leader=直属上级,manager=物品管理员,other=其他',
|
||||
approver_id BIGINT(20) UNSIGNED NOT NULL COMMENT '审批人用户ID',
|
||||
approver_name VARCHAR(64) DEFAULT NULL COMMENT '审批人姓名快照',
|
||||
action TINYINT(3) NOT NULL COMMENT '审批动作:1通过 2驳回',
|
||||
comment VARCHAR(255) DEFAULT NULL COMMENT '审批意见',
|
||||
action_at INT(11) NOT NULL DEFAULT 0 COMMENT '审批时间时间戳',
|
||||
|
||||
created_at INT(11) NOT NULL DEFAULT 0 COMMENT '创建时间时间戳',
|
||||
updated_at INT(11) NOT NULL DEFAULT 0 COMMENT '更新时间时间戳',
|
||||
|
||||
PRIMARY KEY (id),
|
||||
KEY idx_req (requisition_id),
|
||||
KEY idx_node (node_type),
|
||||
KEY idx_approver (approver_id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='物品领用申请审批记录表';
|
||||
|
||||
|
||||
-- 5. 申请单附件表(申请时上传)
|
||||
DROP TABLE IF EXISTS inv_requisition_attachment;
|
||||
CREATE TABLE inv_requisition_attachment (
|
||||
id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||
requisition_id BIGINT(20) UNSIGNED NOT NULL COMMENT '申请单ID',
|
||||
file_name VARCHAR(255) NOT NULL COMMENT '文件原始名称',
|
||||
file_path VARCHAR(255) NOT NULL COMMENT '文件存储路径/URL',
|
||||
file_size INT(11) DEFAULT NULL COMMENT '文件大小(字节)',
|
||||
created_at INT(11) NOT NULL DEFAULT 0 COMMENT '创建时间时间戳',
|
||||
updated_at INT(11) NOT NULL DEFAULT 0 COMMENT '更新时间时间戳',
|
||||
|
||||
PRIMARY KEY (id),
|
||||
KEY idx_req (requisition_id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='物品领用申请附件表';
|
||||
|
||||
|
||||
/* ================= 归 还 相 关 表 ================= */
|
||||
|
||||
-- 6. 归还记录表:一次归还动作(可归还一个明细的一部分)
|
||||
DROP TABLE IF EXISTS inv_requisition_item_return;
|
||||
CREATE TABLE inv_requisition_item_return (
|
||||
id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||
requisition_id BIGINT(20) UNSIGNED NOT NULL COMMENT '申请单ID',
|
||||
requisition_item_id BIGINT(20) UNSIGNED NOT NULL COMMENT '申请单明细ID',
|
||||
item_id BIGINT(20) UNSIGNED NOT NULL COMMENT '物品ID',
|
||||
|
||||
return_qty INT(11) NOT NULL DEFAULT 0 COMMENT '本次归还数量',
|
||||
handler_id BIGINT(20) UNSIGNED NOT NULL COMMENT '办理归还的人(通常是物品管理员)',
|
||||
handler_name VARCHAR(64) DEFAULT NULL COMMENT '办理人姓名快照',
|
||||
|
||||
return_status TINYINT(3) NOT NULL DEFAULT 1 COMMENT '归还状态:1正常归还 2损坏 3其他',
|
||||
remark VARCHAR(255) DEFAULT NULL COMMENT '归还备注',
|
||||
|
||||
return_at INT(11) NOT NULL DEFAULT 0 COMMENT '归还时间时间戳',
|
||||
created_at INT(11) NOT NULL DEFAULT 0 COMMENT '创建时间时间戳',
|
||||
updated_at INT(11) NOT NULL DEFAULT 0 COMMENT '更新时间时间戳',
|
||||
|
||||
PRIMARY KEY (id),
|
||||
KEY idx_req (requisition_id),
|
||||
KEY idx_req_item (requisition_item_id),
|
||||
KEY idx_item (item_id),
|
||||
KEY idx_handler (handler_id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='物品归还记录表(支持多次、部分归还)';
|
||||
|
||||
|
||||
-- 7. 归还附件表:归还时拍照留底
|
||||
DROP TABLE IF EXISTS inv_requisition_item_return_attachment;
|
||||
CREATE TABLE inv_requisition_item_return_attachment (
|
||||
id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||
return_id BIGINT(20) UNSIGNED NOT NULL COMMENT '归还记录ID',
|
||||
file_name VARCHAR(255) NOT NULL COMMENT '文件原始名称',
|
||||
file_path VARCHAR(255) NOT NULL COMMENT '文件存储路径/URL(通常为照片)',
|
||||
file_size INT(11) DEFAULT NULL COMMENT '文件大小(字节)',
|
||||
created_at INT(11) NOT NULL DEFAULT 0 COMMENT '创建时间时间戳',
|
||||
updated_at INT(11) NOT NULL DEFAULT 0 COMMENT '更新时间时间戳',
|
||||
|
||||
PRIMARY KEY (id),
|
||||
KEY idx_return (return_id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='物品归还记录附件表(归还拍照留底)';
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
Reference in New Issue
Block a user