|
@@ -4,6 +4,7 @@ namespace app\common\service;
|
|
|
|
|
|
use app\common\constant\ApplyConstant;
|
|
|
use app\common\constant\CommonConstant;
|
|
|
+use app\common\constant\MaintainConstant;
|
|
|
use app\common\model\Approve;
|
|
|
use app\common\model\ApproveApplyGoods;
|
|
|
use app\common\model\ApproveEvectionPeerUser;
|
|
@@ -344,7 +345,7 @@ class ApproveService
|
|
|
|
|
|
switch ($type) {
|
|
|
case 'audit':
|
|
|
- self::audit($approve, $info, $params);
|
|
|
+ self::audit($approve, $info, $params, $user);
|
|
|
break;
|
|
|
case 'edit':
|
|
|
self::edit($approve, $info, $params);
|
|
@@ -360,32 +361,41 @@ class ApproveService
|
|
|
* @param mixed $info 申请信息
|
|
|
* @param array $params 数组
|
|
|
**/
|
|
|
- public static function audit($approve, $info, $params)
|
|
|
+ public static function audit($approve, $info, $params, $user)
|
|
|
{
|
|
|
- Db::startTrans();
|
|
|
- try {
|
|
|
- $status = $params['status'];
|
|
|
- $remark = $params['remark'];
|
|
|
- $approve_time = date('Y-m-d H:i:s');
|
|
|
- $duration = time() - strtotime($approve['approve_time']);
|
|
|
-
|
|
|
- if ($status == CommonConstant::STATUS_3) {
|
|
|
- if ($info->module == CommonConstant::MODULE_3) {
|
|
|
- // 入库商品列表 TODO
|
|
|
- $stock_goods = $info->stock_goods;
|
|
|
- if (!$stock_goods->toArray()) {
|
|
|
- throw new Exception('入库商品不存在');
|
|
|
- }
|
|
|
+ $status = $params['status'];
|
|
|
+ $remark = $params['remark'];
|
|
|
+ $maintain_user_id = $params['maintain_user_id'] ?: 0;
|
|
|
+ $approve_time = date('Y-m-d H:i:s');
|
|
|
+ $duration = time() - strtotime($approve['approve_time']);
|
|
|
+ if ($status == CommonConstant::STATUS_3) {
|
|
|
+ if ($info->module == CommonConstant::MODULE_3) {
|
|
|
+ // 入库商品列表 TODO
|
|
|
+ $stock_goods = $info->stock_goods;
|
|
|
+ if (!$stock_goods->toArray()) {
|
|
|
+ except('入库商品不存在');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ($info->module == CommonConstant::MODULE_4) {
|
|
|
+ // 领用商品列表 TODO
|
|
|
+ $use_goods = $info->use_goods;
|
|
|
+ if (!$use_goods->toArray()) {
|
|
|
+ except('领用商品不存在');
|
|
|
}
|
|
|
- if ($info->module == CommonConstant::MODULE_4) {
|
|
|
- // 领用商品列表 TODO
|
|
|
- $use_goods = $info->use_goods;
|
|
|
- if (!$use_goods->toArray()) {
|
|
|
- throw new Exception('领用商品不存在');
|
|
|
+ }
|
|
|
+ if ($info->module == CommonConstant::MODULE_8) {
|
|
|
+ // 维修
|
|
|
+ // 匹配用户是否是 物业主管或信息负责人
|
|
|
+ if (in_array($user['title'], MaintainConstant::get_type_title_list())) {
|
|
|
+ if (!$maintain_user_id) {
|
|
|
+ except('请选择维修人员');
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
+ Db::startTrans();
|
|
|
+ try {
|
|
|
// 更新审批申请
|
|
|
if ($status == CommonConstant::STATUS_3) {
|
|
|
// 审批通过
|
|
@@ -399,9 +409,12 @@ class ApproveService
|
|
|
if ($status == CommonConstant::STATUS_4) {
|
|
|
// 审批驳回
|
|
|
// 全部改为历史记录
|
|
|
- Approve::where('info_id',$approve['info_id'])->update(['state' => CommonConstant::IS_WHO_1]);
|
|
|
+ Approve::where('info_id', $approve['info_id'])->update(['state' => CommonConstant::IS_WHO_1]);
|
|
|
$info->status = $status;
|
|
|
}
|
|
|
+ if ($maintain_user_id > 0) {
|
|
|
+ $info->maintain_user_id = $maintain_user_id;
|
|
|
+ }
|
|
|
$info->cur_num = $info['cur_num'] + 1;
|
|
|
$info->save();
|
|
|
|
|
@@ -428,13 +441,13 @@ class ApproveService
|
|
|
**/
|
|
|
public static function edit($approve, $info, $params)
|
|
|
{
|
|
|
+ $info->module_info;
|
|
|
+ if (!$info->module_info) {
|
|
|
+ except(CommonConstant::get_module_list()[$params['module']] . '记录不存在或已删除');
|
|
|
+ }
|
|
|
+
|
|
|
Db::startTrans();
|
|
|
try {
|
|
|
- $info->module_info;
|
|
|
- if (!$info->module_info) {
|
|
|
- throw new Exception(CommonConstant::get_module_list()[$params['module']] . '记录不存在或已删除');
|
|
|
- }
|
|
|
-
|
|
|
// 编辑对应模块
|
|
|
$result = ApproveInfoService::create_module($params['module'], $params, $info->id, $info, 'update');
|
|
|
|