|
|
@ -390,7 +390,6 @@ class Business extends ApiCommon
|
|
|
|
$userModel = new \app\admin\model\User();
|
|
|
|
$userModel = new \app\admin\model\User();
|
|
|
|
$is_end = $param['is_end'] ?: 0; //1赢单2输单3无效
|
|
|
|
$is_end = $param['is_end'] ?: 0; //1赢单2输单3无效
|
|
|
|
$remark = $param['statusRemark'];
|
|
|
|
$remark = $param['statusRemark'];
|
|
|
|
$param['check_user_id'] = 1;// 临时测试需删除
|
|
|
|
|
|
|
|
unset($param['examineStatus']);
|
|
|
|
unset($param['examineStatus']);
|
|
|
|
|
|
|
|
|
|
|
|
if (!$param['business_id']) {
|
|
|
|
if (!$param['business_id']) {
|
|
|
@ -411,12 +410,12 @@ class Business extends ApiCommon
|
|
|
|
// 审核判断(是否有符合条件的审批流)
|
|
|
|
// 审核判断(是否有符合条件的审批流)
|
|
|
|
$examineFlowModel = new \app\admin\model\ExamineFlow();
|
|
|
|
$examineFlowModel = new \app\admin\model\ExamineFlow();
|
|
|
|
if (!$examineFlowModel->checkExamine($userInfo['id'], 'crm_business')) {
|
|
|
|
if (!$examineFlowModel->checkExamine($userInfo['id'], 'crm_business')) {
|
|
|
|
return '暂无审批人,无法创建';
|
|
|
|
return resultArray(['error' => '暂无审批人,无法创建']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//添加审批相关信息
|
|
|
|
//添加审批相关信息
|
|
|
|
$examineFlowData = $examineFlowModel->getFlowByTypes($userInfo['id'], 'crm_business');
|
|
|
|
$examineFlowData = $examineFlowModel->getFlowByTypes($userInfo['id'], 'crm_business');
|
|
|
|
if (!$examineFlowData) {
|
|
|
|
if (!$examineFlowData) {
|
|
|
|
return '无可用审批流,请联系管理员';
|
|
|
|
return resultArray(['error' => '无可用审批流,请联系管理员']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$data['flow_id'] = $examineFlowData['flow_id'];
|
|
|
|
$data['flow_id'] = $examineFlowData['flow_id'];
|
|
|
|
//获取审批人信息
|
|
|
|
//获取审批人信息
|
|
|
@ -430,7 +429,8 @@ class Business extends ApiCommon
|
|
|
|
$check_user_id = $param['check_user_id'] ? ',' . $param['check_user_id'] . ',' : '';
|
|
|
|
$check_user_id = $param['check_user_id'] ? ',' . $param['check_user_id'] . ',' : '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!$check_user_id) {
|
|
|
|
if (!$check_user_id) {
|
|
|
|
return '无可用审批人,请联系管理员';
|
|
|
|
|
|
|
|
|
|
|
|
return resultArray(['error' => '无可用审批人,请联系管理员']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$data['check_user_id'] = is_array($check_user_id) ? ',' . implode(',', $check_user_id) . ',' : $check_user_id;
|
|
|
|
$data['check_user_id'] = is_array($check_user_id) ? ',' . implode(',', $check_user_id) . ',' : $check_user_id;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -456,7 +456,6 @@ class Business extends ApiCommon
|
|
|
|
$send_user_id
|
|
|
|
$send_user_id
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# 创建待办事项的关联数据
|
|
|
|
# 创建待办事项的关联数据
|
|
|
|
$checkUserIds = db('crm_business')->where('business_id', $param['business_id'])->value('check_user_id');
|
|
|
|
$checkUserIds = db('crm_business')->where('business_id', $param['business_id'])->value('check_user_id');
|
|
|
|
$checkUserIdArray = stringToArray($checkUserIds);
|
|
|
|
$checkUserIdArray = stringToArray($checkUserIds);
|
|
|
@ -703,8 +702,8 @@ class Business extends ApiCommon
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//已审批人ID
|
|
|
|
//已审批人ID
|
|
|
|
$businessCheckData['flow_user_id'] = stringToArray($dataInfo['flow_user_id']) ? arrayToString(array_merge(stringToArray($dataInfo['flow_user_id']), [$user_id])) : arrayToString([$user_id]);
|
|
|
|
$businessCheckData['flow_user_id'] = stringToArray($dataInfo['flow_user_id']) ? arrayToString(array_merge(stringToArray($dataInfo['flow_user_id']), [$user_id])) : arrayToString([$user_id]);
|
|
|
|
$resCustomerCheck = db('crm_business')->where(['business_id' => $param['id']])->update($businessCheckData);
|
|
|
|
$resBusiness = db('crm_business')->where(['business_id' => $param['id']])->update($businessCheckData);
|
|
|
|
if ($resCustomerCheck) {
|
|
|
|
if ($resBusiness) {
|
|
|
|
//审批记录
|
|
|
|
//审批记录
|
|
|
|
$resRecord = $examineRecordModel->createData($checkData);
|
|
|
|
$resRecord = $examineRecordModel->createData($checkData);
|
|
|
|
//审核通过,修改相关信息
|
|
|
|
//审核通过,修改相关信息
|
|
|
@ -726,10 +725,7 @@ class Business extends ApiCommon
|
|
|
|
$businessData['statusRemark'] = $dataInfo['submit_remark'];
|
|
|
|
$businessData['statusRemark'] = $dataInfo['submit_remark'];
|
|
|
|
|
|
|
|
|
|
|
|
$result = $this->advanceAfterCheck($businessData);
|
|
|
|
$result = $this->advanceAfterCheck($businessData);
|
|
|
|
|
|
|
|
if (!empty($result)) return $result;
|
|
|
|
if (!empty($result)) return resultArray(['error' => $result]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return resultArray(['data' => '领取成功!']);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
if ($status) {
|
|
|
|
if ($status) {
|
|
|
|
//发送站内信
|
|
|
|
//发送站内信
|
|
|
@ -754,7 +750,7 @@ class Business extends ApiCommon
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return resultArray(['data' => '审批成功']);
|
|
|
|
return resultArray(['success' => '审批成功']);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
return resultArray(['error' => '审批失败,请重试!']);
|
|
|
|
return resultArray(['error' => '审批失败,请重试!']);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -774,11 +770,11 @@ class Business extends ApiCommon
|
|
|
|
$userModel = new \app\admin\model\User();
|
|
|
|
$userModel = new \app\admin\model\User();
|
|
|
|
$is_end = $param['is_end'] ?: 0; //1赢单2输单3无效
|
|
|
|
$is_end = $param['is_end'] ?: 0; //1赢单2输单3无效
|
|
|
|
if (!$param['business_id']) {
|
|
|
|
if (!$param['business_id']) {
|
|
|
|
return resultArray(['error' => '参数错误']);
|
|
|
|
return ['error' => '参数错误'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$businessInfo = db('crm_business')->where(['business_id' => $param['business_id']])->find();
|
|
|
|
$businessInfo = db('crm_business')->where(['business_id' => $param['business_id']])->find();
|
|
|
|
if ($businessInfo['is_end']) {
|
|
|
|
if ($businessInfo['is_end']) {
|
|
|
|
return resultArray(['error' => '已结束,不能推进']);
|
|
|
|
return ['error' => '已结束,不能推进'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//判断权限
|
|
|
|
//判断权限
|
|
|
|
$auth_user_ids = $userModel->getUserByPer('crm', 'business', 'update');
|
|
|
|
$auth_user_ids = $userModel->getUserByPer('crm', 'business', 'update');
|
|
|
@ -792,7 +788,7 @@ class Business extends ApiCommon
|
|
|
|
$status_id = $param['status_id'] ?: $businessInfo['status_id'];
|
|
|
|
$status_id = $param['status_id'] ?: $businessInfo['status_id'];
|
|
|
|
$statusInfo = db('crm_business_status')->where(['type_id' => $businessInfo['type_id'], 'status_id' => $status_id])->find();
|
|
|
|
$statusInfo = db('crm_business_status')->where(['type_id' => $businessInfo['type_id'], 'status_id' => $status_id])->find();
|
|
|
|
if (!$statusInfo && !$is_end) {
|
|
|
|
if (!$statusInfo && !$is_end) {
|
|
|
|
return resultArray(['error' => '参数错误']);
|
|
|
|
return ['error' => '参数错误'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$data = [];
|
|
|
|
$data = [];
|
|
|
|
$data['update_time'] = time();
|
|
|
|
$data['update_time'] = time();
|
|
|
@ -802,10 +798,10 @@ class Business extends ApiCommon
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
$data['status_id'] = $status_id;
|
|
|
|
$data['status_id'] = $status_id;
|
|
|
|
$data['status_time'] = time();
|
|
|
|
$data['status_time'] = time();
|
|
|
|
$data['submit_remark'] = $param['submit_remark'];
|
|
|
|
$data['remark'] = $param['submit_remark'];
|
|
|
|
$res = db('crm_business')->where(['business_id' => $param['business_id']])->update($data);
|
|
|
|
$res = db('crm_business')->where(['business_id' => $param['business_id']])->update($data);
|
|
|
|
if (!$res) {
|
|
|
|
if (!$res) {
|
|
|
|
return resultArray(['error' => '推进失败,请重试']);
|
|
|
|
return ['error' => '推进失败,请重试'];
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
# 商机变更后的名称
|
|
|
|
# 商机变更后的名称
|
|
|
|
$businessStatusName = Db::name('crm_business_status')->where('status_id', $param['status_id'])->value('name');
|
|
|
|
$businessStatusName = Db::name('crm_business_status')->where('status_id', $param['status_id'])->value('name');
|
|
|
@ -843,7 +839,7 @@ class Business extends ApiCommon
|
|
|
|
'status_list' => $businessStatus
|
|
|
|
'status_list' => $businessStatus
|
|
|
|
];
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
return resultArray(['data' => $result]);
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|