|
|
@@ -211,48 +211,61 @@ class Contract extends ApiCommon
|
|
211
|
211
|
$param['num'] = $numberInfo['number'];
|
|
212
|
212
|
}
|
|
213
|
213
|
|
|
214
|
|
- //已进行审批,不能编辑
|
|
|
214
|
+ # 已进行审批,不能编辑
|
|
215
|
215
|
if (!in_array($dataInfo['check_status'], ['3', '4', '5', '6'])) {
|
|
216
|
216
|
return resultArray(['error' => '当前状态为审批中或已审批通过,不可编辑']);
|
|
217
|
217
|
}
|
|
218
|
|
- if (($examineStatus != false && $examineStatus != 'false') || $examineStatus == 1) {
|
|
219
|
|
- //将合同审批状态至为待审核,提交后重新进行审批
|
|
220
|
|
- //审核判断(是否有符合条件的审批流)
|
|
221
|
|
- $examineFlowModel = new \app\admin\model\ExamineFlow();
|
|
222
|
|
- $examineStepModel = new \app\admin\model\ExamineStep();
|
|
223
|
|
- if (!$examineFlowModel->checkExamine($dataInfo['owner_user_id'], 'crm_contract')) {
|
|
224
|
|
- return resultArray(['error' => '暂无审批人,无法创建']);
|
|
225
|
|
- }
|
|
226
|
|
- //添加审批相关信息
|
|
227
|
|
- $examineFlowData = $examineFlowModel->getFlowByTypes($dataInfo['owner_user_id'], 'crm_contract');
|
|
228
|
|
- if (!$examineFlowData) {
|
|
229
|
|
- return resultArray(['error' => '无可用审批流,请联系管理员']);
|
|
230
|
|
- }
|
|
231
|
|
- $param['flow_id'] = $examineFlowData['flow_id'];
|
|
232
|
|
- //获取审批人信息
|
|
233
|
|
- if ($examineFlowData['config'] == 1) {
|
|
234
|
|
- //固定审批流
|
|
235
|
|
- $nextStepData = $examineStepModel->nextStepUser($dataInfo['owner_user_id'], $examineFlowData['flow_id'], 'crm_contract', 0, 0, 0);
|
|
236
|
|
- $next_user_ids = arrayToString($nextStepData['next_user_ids']) ? : '';
|
|
237
|
|
- $check_user_id = $next_user_ids ? : [];
|
|
238
|
|
- $param['order_id'] = 1;
|
|
239
|
|
- } else {
|
|
240
|
|
- $check_user_id = $param['check_user_id'] ? ','.$param['check_user_id'].',' : '';
|
|
241
|
|
- }
|
|
242
|
|
- if ($param['is_draft'] || (!empty($param['check_status']) && $param['check_status'] == 5)) {
|
|
243
|
|
- //保存为草稿
|
|
244
|
|
- $param['check_status'] = 5;
|
|
245
|
|
- $param['check_user_id'] = $param['check_user_id'] ? ','.$param['check_user_id'].',' : '';
|
|
246
|
|
- } else {
|
|
247
|
|
- if (!$check_user_id) {
|
|
248
|
|
- return resultArray(['error' => '无可用审批人,请联系管理员']);
|
|
249
|
|
- }
|
|
250
|
|
- $param['check_user_id'] = is_array($check_user_id) ? ','.implode(',',$check_user_id).',' : $check_user_id;
|
|
251
|
|
- $param['check_status'] = 0;
|
|
|
218
|
+
|
|
|
219
|
+ # 审批开启
|
|
|
220
|
+ if (($examineStatus != false && $examineStatus != 'false') || $examineStatus == 1) {
|
|
|
221
|
+ //将合同审批状态至为待审核,提交后重新进行审批
|
|
|
222
|
+ //审核判断(是否有符合条件的审批流)
|
|
|
223
|
+ $examineFlowModel = new \app\admin\model\ExamineFlow();
|
|
|
224
|
+ $examineStepModel = new \app\admin\model\ExamineStep();
|
|
|
225
|
+ if (!$examineFlowModel->checkExamine($dataInfo['owner_user_id'], 'crm_contract')) {
|
|
|
226
|
+ return resultArray(['error' => '暂无审批人,无法创建']);
|
|
|
227
|
+ }
|
|
|
228
|
+ //添加审批相关信息
|
|
|
229
|
+ $examineFlowData = $examineFlowModel->getFlowByTypes($dataInfo['owner_user_id'], 'crm_contract');
|
|
|
230
|
+ if (!$examineFlowData) {
|
|
|
231
|
+ return resultArray(['error' => '无可用审批流,请联系管理员']);
|
|
|
232
|
+ }
|
|
|
233
|
+ $param['flow_id'] = $examineFlowData['flow_id'];
|
|
|
234
|
+ //获取审批人信息
|
|
|
235
|
+ if ($examineFlowData['config'] == 1) {
|
|
|
236
|
+ //固定审批流
|
|
|
237
|
+ $nextStepData = $examineStepModel->nextStepUser($dataInfo['owner_user_id'], $examineFlowData['flow_id'], 'crm_contract', 0, 0, 0);
|
|
|
238
|
+ $next_user_ids = arrayToString($nextStepData['next_user_ids']) ? : '';
|
|
|
239
|
+ $check_user_id = $next_user_ids ? : [];
|
|
|
240
|
+ $param['order_id'] = 1;
|
|
|
241
|
+ } else {
|
|
|
242
|
+ $check_user_id = $param['check_user_id'] ? ','.$param['check_user_id'].',' : '';
|
|
|
243
|
+ }
|
|
|
244
|
+ if ($param['is_draft'] || (!empty($param['check_status']) && $param['check_status'] == 5)) {
|
|
|
245
|
+ //保存为草稿
|
|
|
246
|
+ $param['check_status'] = 5;
|
|
|
247
|
+ $param['check_user_id'] = $param['check_user_id'] ? ','.$param['check_user_id'].',' : '';
|
|
|
248
|
+ } else {
|
|
|
249
|
+ if (!$check_user_id) {
|
|
|
250
|
+ return resultArray(['error' => '无可用审批人,请联系管理员']);
|
|
252
|
251
|
}
|
|
253
|
|
- $param['flow_user_id'] = '';
|
|
|
252
|
+ $param['check_user_id'] = is_array($check_user_id) ? ','.implode(',',$check_user_id).',' : $check_user_id;
|
|
|
253
|
+ $param['check_status'] = 0;
|
|
254
|
254
|
}
|
|
255
|
|
-
|
|
|
255
|
+ $param['flow_user_id'] = '';
|
|
|
256
|
+ }
|
|
|
257
|
+
|
|
|
258
|
+ # 是否开启审核
|
|
|
259
|
+ $examineFlowWheres['types'] = 'crm_contract';
|
|
|
260
|
+ $examineFlowWheres['status'] = 1;
|
|
|
261
|
+ $examineFlowWheres['is_deleted'] = 0;
|
|
|
262
|
+ $contractExamineCount = db('admin_examine_flow')->where($examineFlowWheres)->count();
|
|
|
263
|
+ # 审核没有开启,更新作废合同的状态
|
|
|
264
|
+ if ($contractExamineCount == 0 && $dataInfo['check_status'] == 6 && empty($param['is_draft'])) $param['check_status'] = 2;
|
|
|
265
|
+ # 审核没有开启,更新作废合同的状态
|
|
|
266
|
+ if ($contractExamineCount == 0 && $dataInfo['check_status'] == 5 && empty($param['is_draft'])) $param['check_status'] = 2;
|
|
|
267
|
+ # 审核没有开启,保存为草稿
|
|
|
268
|
+ if ($contractExamineCount == 0 && !empty($param['is_draft'])) $param['check_status'] = 5;
|
|
256
|
269
|
|
|
257
|
270
|
if ($contractModel->updateDataById($param, $param['id'])) {
|
|
258
|
271
|
//将审批记录至为无效
|