zm #26

Merged
mengfucius merged 2 commits from zm into master 2 years ago

@ -69,7 +69,11 @@ function resultArray($array)
$array['data'] = '';
} elseif (isset($array['error'])) {
$code = 400;
$array['data'] = '';
$array['data'] = '操作失败';
} elseif (isset($array['success'])) {
$array['error'] = '';
$array['data'] =$array['success'] ;
$code = 200;
}
return json([
'code' => $code,
@ -834,7 +838,8 @@ function advancedQueryDataTransform($data, $condition)
* @version: 11.1.0
* Date: 2021/9/2 14:44
*/
function advancedQueryDataUserform($data, $condition){
function advancedQueryDataUserform($data, $condition)
{
if (in_array($condition, ['contains', 'notContains'])) {
array_walk($data, function ($value, $key) use (&$data) {
$data[$key] = $value;
@ -842,6 +847,7 @@ function advancedQueryDataUserform($data, $condition){
}
return $data;
}
/**
* 等于(时间段)数据处理
*

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

@ -394,31 +394,6 @@ class Business extends Common
}
}
}
//站内信
$send_user_id = stringToArray(getUserSuperior($param['create_user_id']));
(new Message())->send(
Message::CUSTOMER_CHECK_TO_DO,
[
'title' => $param['name'],
'action_id' => $this->business_id
],
$send_user_id
);
$data = [];
$data['business_id'] = $this->business_id;
# 创建待办事项的关联数据
$dealtData = [];
foreach ($send_user_id as $kk => $vv) {
$dealtData[] = [
'types' => 'crm_business_new',
'types_id' => $data['business_id'],
'user_id' => $vv
];
}
if (!empty($dealtData)) db('crm_dealt_relation')->insertAll($dealtData);
# 设置今日需联系商机
if (!empty($param['next_time']) && $param['next_time'] >= strtotime(date('Y-m-d 00:00:00'))) $param['is_dealt'] = 0;
@ -462,6 +437,30 @@ class Business extends Common
});
db('crm_business_data')->insertAll($businessData);
//站内信
$send_user_id = stringToArray(getUserSuperior($param['create_user_id']));
(new Message())->send(
Message::CUSTOMER_CHECK_TO_DO,
[
'title' => $param['name'],
'action_id' => $this->business_id
],
$send_user_id
);
$data = [];
$data['business_id'] = $this->business_id;
# 创建待办事项的关联数据
$dealtData = [];
foreach ($send_user_id as $kk => $vv) {
$dealtData[] = [
'types' => 'crm_business_new',
'types_id' => $data['business_id'],
'user_id' => $vv
];
}
if (!empty($dealtData)) db('crm_dealt_relation')->insertAll($dealtData);
return $data;
} else {
$this->error = '添加失败';

Loading…
Cancel
Save