|
@@ -22,23 +22,24 @@ class ApproveService
|
|
|
|
|
|
/**
|
|
|
* 请假审批
|
|
|
- * @param $approve_id 审批记录
|
|
|
+ * @param $apply_id 申请记录id
|
|
|
* @param $user_id 审批会员
|
|
|
* @param $status 审批状态
|
|
|
* @param $remark 审批备注
|
|
|
* @return array
|
|
|
*/
|
|
|
- public static function approveLeave($approve_id,$user_id,$status,$remark)
|
|
|
+ public static function approveLeave($apply_id,$user_id,$status,$remark)
|
|
|
{
|
|
|
Db::startTrans();
|
|
|
try {
|
|
|
+ $apply_info = LeaveInfo::where('id',$apply_id)->find()->toArray();
|
|
|
+ $approve_info = LeaveApprove::where('info_id',$apply_id)->where('approve_user',$user_id)->find();
|
|
|
+ if(empty($approve_info)) throw new Exception('没有审核权限');
|
|
|
if(!in_array($status,[2,3]))throw new Exception('审批状态错误');
|
|
|
- $approve_info = LeaveApprove::where('id',$approve_id)->find()->toArray();
|
|
|
- $leave_info = LeaveInfo::where('id',$approve_info['info_id'])->find()->toArray();
|
|
|
- if($approve_info['approve_user'] != $user_id) throw new Exception('没有审核权限');
|
|
|
+ $approve_info = $approve_info->toArray();
|
|
|
if($approve_info['status'] == 0) throw new Exception('请等待审核');
|
|
|
if($approve_info['status'] != 1) throw new Exception('该记录已审核');
|
|
|
- if($leave_info['status'] != 1) throw new Exception('该记录已审核或已取消');
|
|
|
+ if($apply_info['status'] != 1) throw new Exception('该记录已审核或已取消');
|
|
|
$approve_update = [];
|
|
|
$approve_update['status'] = $status;
|
|
|
$approve_update['remark'] = $remark;
|
|
@@ -46,18 +47,18 @@ class ApproveService
|
|
|
$approve_time = time() - strtotime($approve_info['start_time']);
|
|
|
$approve_update['time'] = $approve_time;
|
|
|
$approve_update['time_desc'] = get_stay_time($approve_time);
|
|
|
- LeaveApprove::where('id',$approve_id)->update($approve_update);// 更新审批记录
|
|
|
+ LeaveApprove::where('info_id',$apply_id)->where('approve_user',$user_id)->update($approve_update);// 更新审批记录
|
|
|
$leave_data = [];
|
|
|
// 审批流程数 + 1
|
|
|
- $leave_data['cur_num'] = $leave_info['cur_num'] + 1;
|
|
|
- if($approve_info['flow'] < $leave_info['approve_num']){
|
|
|
+ $leave_data['cur_num'] = $apply_info['cur_num'] + 1;
|
|
|
+ if($approve_info['flow'] < $apply_info['approve_num']){
|
|
|
// 更新下一级审批记录状态
|
|
|
LeaveApprove::where(['info_id'=>$approve_info['info_id'],'flow'=>$approve_info['flow'] + 1,'approve_type'=>1])->update(['status'=>1,'start_time'=>date('Y-m-d H:i:s')]);
|
|
|
if($status == 3) $leave_data['status'] = 3;
|
|
|
- } else if($approve_info['flow'] == $leave_info['approve_num']) {
|
|
|
+ } else if($approve_info['flow'] == $apply_info['approve_num']) {
|
|
|
$leave_data['status'] = $status;
|
|
|
}
|
|
|
- LeaveInfo::where('id',$leave_info['id'])->update($leave_data);// 更新请假状态
|
|
|
+ LeaveInfo::where('id',$apply_info['id'])->update($leave_data);// 更新请假状态
|
|
|
Db::commit();
|
|
|
}catch (\Exception $e) {
|
|
|
Db::rollback();
|
|
@@ -70,23 +71,26 @@ class ApproveService
|
|
|
|
|
|
/**
|
|
|
* 用车申请审批
|
|
|
- * @param $approve_id 审批记录
|
|
|
+ * @param $apply_id 申请记录id
|
|
|
* @param $user_id 审批会员
|
|
|
* @param $status 审批状态
|
|
|
* @param $remark 审批备注
|
|
|
* @return array
|
|
|
*/
|
|
|
- public static function approveCar($approve_id,$user_id,$status,$remark)
|
|
|
+ public static function approveCar($apply_id,$user_id,$status,$remark)
|
|
|
{
|
|
|
Db::startTrans();
|
|
|
try {
|
|
|
+ $apply_info = LeaveInfo::where('id',$apply_id)->find()->toArray();
|
|
|
+ $approve_info = LeaveApprove::where('info_id',$apply_id)->where('approve_user',$user_id)->find();
|
|
|
+ if(empty($approve_info)) throw new Exception('没有审核权限');
|
|
|
if(!in_array($status,[2,3]))throw new Exception('审批状态错误');
|
|
|
- $approve_info = CarApprove::where('id',$approve_id)->find()->toArray();
|
|
|
- $car_info = CarInfo::where('id',$approve_info['car_id'])->find()->toArray();
|
|
|
+ $approve_info = $approve_info->toArray();
|
|
|
+
|
|
|
if($approve_info['approve_user'] != $user_id) throw new Exception('没有审核权限');
|
|
|
if($approve_info['status'] == 0) throw new Exception('请等待审核');
|
|
|
if($approve_info['status'] != 1) throw new Exception('该记录已审核');
|
|
|
- if($car_info['status'] != 1) throw new Exception('该记录已审核或已取消');
|
|
|
+ if($apply_info['status'] != 1) throw new Exception('该记录已审核或已取消');
|
|
|
$approve_update = [];
|
|
|
$approve_update['status'] = $status;
|
|
|
$approve_update['remark'] = $remark;
|
|
@@ -94,18 +98,18 @@ class ApproveService
|
|
|
$approve_time = time() - strtotime($approve_info['start_time']);
|
|
|
$approve_update['time'] = $approve_time;
|
|
|
$approve_update['time_desc'] = get_stay_time($approve_time);
|
|
|
- CarApprove::where('id',$approve_id)->update($approve_update);// 更新审批记录
|
|
|
+ CarApprove::where('info_id',$apply_id)->where('approve_user',$user_id)->update($approve_update);// 更新审批记录
|
|
|
$car_data = [];
|
|
|
// 审批流程数 + 1
|
|
|
- $car_data['cur_num'] = $car_info['cur_num'] + 1;
|
|
|
- if($approve_info['flow'] < $car_info['approve_num']){
|
|
|
+ $car_data['cur_num'] = $apply_info['cur_num'] + 1;
|
|
|
+ if($approve_info['flow'] < $apply_info['approve_num']){
|
|
|
// 更新下一级审批记录状态
|
|
|
CarApprove::where(['car_id'=>$approve_info['car_id'],'flow'=>$approve_info['flow'] + 1,'approve_type'=>1])->update(['status'=>1,'start_time'=>date('Y-m-d H:i:s')]);
|
|
|
if($status == 3) $car_data['status'] = 3;
|
|
|
- } else if($approve_info['flow'] == $car_info['approve_num']) {
|
|
|
+ } else if($approve_info['flow'] == $apply_info['approve_num']) {
|
|
|
$car_data['status'] = $status;
|
|
|
}
|
|
|
- CarInfo::where('id',$car_info['id'])->update($car_data);// 更新用车申请状态
|
|
|
+ CarInfo::where('id',$apply_info['id'])->update($car_data);// 更新用车申请状态
|
|
|
Db::commit();
|
|
|
}catch (\Exception $e) {
|
|
|
Db::rollback();
|
|
@@ -117,23 +121,24 @@ class ApproveService
|
|
|
|
|
|
/**
|
|
|
* 出差申请审批
|
|
|
- * @param $approve_id 审批记录
|
|
|
+ * @param $apply_id 申请记录id
|
|
|
* @param $user_id 审批会员
|
|
|
* @param $status 审批状态
|
|
|
* @param $remark 审批备注
|
|
|
* @return array
|
|
|
*/
|
|
|
- public static function approveEvection($approve_id,$user_id,$status,$remark)
|
|
|
+ public static function approveEvection($apply_id,$user_id,$status,$remark)
|
|
|
{
|
|
|
Db::startTrans();
|
|
|
try {
|
|
|
+ $apply_info = EvectionInfo::where('id',$apply_id)->find()->toArray();
|
|
|
+ $approve_info =EvectionApprove::where('info_id',$apply_id)->where('approve_user',$user_id)->find();
|
|
|
+ if(empty($approve_info)) throw new Exception('没有审核权限');
|
|
|
if(!in_array($status,[2,3]))throw new Exception('审批状态错误');
|
|
|
- $approve_info =EvectionApprove::where('id',$approve_id)->find()->toArray();
|
|
|
- $car_info = EvectionInfo::where('id',$approve_info['info_id'])->find()->toArray();
|
|
|
- if($approve_info['approve_user'] != $user_id) throw new Exception('没有审核权限');
|
|
|
+ $approve_info = $approve_info->toArray();
|
|
|
if($approve_info['status'] == 0) throw new Exception('请等待审核');
|
|
|
if($approve_info['status'] != 1) throw new Exception('该记录已审核');
|
|
|
- if($car_info['status'] != 1) throw new Exception('该记录已审核或已取消');
|
|
|
+ if($apply_info['status'] != 1) throw new Exception('该记录已审核或已取消');
|
|
|
$approve_update = [];
|
|
|
$approve_update['status'] = $status;
|
|
|
$approve_update['remark'] = $remark;
|
|
@@ -141,18 +146,18 @@ class ApproveService
|
|
|
$approve_time = time() - strtotime($approve_info['start_time']);
|
|
|
$approve_update['time'] = $approve_time;
|
|
|
$approve_update['time_desc'] = get_stay_time($approve_time);
|
|
|
- EvectionApprove::where('id',$approve_id)->update($approve_update);// 更新审批记录
|
|
|
+ EvectionApprove::where('info_id',$apply_id)->where('approve_user',$user_id)->update($approve_update);// 更新审批记录
|
|
|
$Info_up = [];
|
|
|
// 审批流程数 + 1
|
|
|
- $Info_up['cur_num'] = $car_info['cur_num'] + 1;
|
|
|
- if($approve_info['flow'] < $car_info['approve_num']){
|
|
|
+ $Info_up['cur_num'] = $approve_info['cur_num'] + 1;
|
|
|
+ if($approve_info['flow'] < $approve_info['approve_num']){
|
|
|
// 更新下一级审批记录状态
|
|
|
EvectionApprove::where(['info_id'=>$approve_info['info_id'],'flow'=>$approve_info['flow'] + 1,'approve_type'=>1])->update(['status'=>1,'start_time'=>date('Y-m-d H:i:s')]);
|
|
|
if($status == 3) $Info_up['status'] = 3;
|
|
|
- } else if($approve_info['flow'] == $car_info['approve_num']) {
|
|
|
+ } else if($approve_info['flow'] == $approve_info['approve_num']) {
|
|
|
$Info_up['status'] = $status;
|
|
|
}
|
|
|
- EvectionInfo::where('id',$car_info['id'])->update($Info_up);// 更新用车申请状态
|
|
|
+ EvectionInfo::where('id',$approve_info['id'])->update($Info_up);// 更新用车申请状态
|
|
|
Db::commit();
|
|
|
}catch (\Exception $e) {
|
|
|
Db::rollback();
|
|
@@ -165,20 +170,21 @@ class ApproveService
|
|
|
|
|
|
/**
|
|
|
* 呈批申请审批
|
|
|
- * @param $approve_id 审批记录
|
|
|
+ * @param $apply_id 申请记录id
|
|
|
* @param $user_id 审批会员
|
|
|
* @param $status 审批状态
|
|
|
* @param $remark 审批备注
|
|
|
* @return array
|
|
|
*/
|
|
|
- public static function approveOffer($approve_id,$user_id,$status,$remark)
|
|
|
+ public static function approveOffer($apply_id,$user_id,$status,$remark)
|
|
|
{
|
|
|
- var_dump($user_id);
|
|
|
Db::startTrans();
|
|
|
try {
|
|
|
+ $apply_info = EvectionInfo::where('id',$apply_id)->find()->toArray();
|
|
|
+ $approve_info =EvectionApprove::where('info_id',$apply_id)->where('approve_user',$user_id)->find();
|
|
|
+ if(empty($approve_info)) throw new Exception('没有审核权限');
|
|
|
if(!in_array($status,[2,3]))throw new Exception('审批状态错误');
|
|
|
- $approve_info = OfferApprove::where('id',$approve_id)->find()->toArray();
|
|
|
- $apply_info = OfferInfo::where('id',$approve_info['info_id'])->find()->toArray();
|
|
|
+ $approve_info = $approve_info->toArray();
|
|
|
if($approve_info['approve_user'] != $user_id) throw new Exception('没有审核权限');
|
|
|
if($approve_info['status'] == 0) throw new Exception('请等待审核');
|
|
|
if($approve_info['status'] != 1) throw new Exception('该记录已审核');
|
|
@@ -190,7 +196,7 @@ class ApproveService
|
|
|
$approve_time = time() - strtotime($approve_info['start_time']);
|
|
|
$approve_update['time'] = $approve_time;
|
|
|
$approve_update['time_desc'] = get_stay_time($approve_time);
|
|
|
- OfferApprove::where('id',$approve_id)->update($approve_update);// 更新审批记录
|
|
|
+ OfferApprove::where('info_id',$apply_id)->where('approve_user',$user_id)->update($approve_update);// 更新审批记录
|
|
|
$Info_up = [];
|
|
|
// 审批流程数 + 1
|
|
|
$Info_up['cur_num'] = $apply_info['cur_num'] + 1;
|