pull/26/head
张萌 2 years ago
parent 80d1af3d0d
commit 7c31cc34bf

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

@ -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,11 @@ class Business extends ApiCommon
$businessData['statusRemark'] = $dataInfo['submit_remark']; $businessData['statusRemark'] = $dataInfo['submit_remark'];
$result = $this->advanceAfterCheck($businessData); $result = $this->advanceAfterCheck($businessData);
echo $result;
echo '\\n';
echo !empty($result);
if (!empty($result)) return resultArray(['error' => $result]); if (!empty($result)) return resultArray(['error' => $result]);
echo '12345';
return resultArray(['data' => '领取成功!']);
} else { } else {
if ($status) { if ($status) {
//发送站内信 //发送站内信
@ -754,7 +754,8 @@ class Business extends ApiCommon
); );
} }
} }
return resultArray(['data' => '审批成功']); echo '1234';
return resultArray(['success' => '审批成功']);
} else { } else {
return resultArray(['error' => '审批失败,请重试!']); return resultArray(['error' => '审批失败,请重试!']);
} }
@ -802,7 +803,7 @@ 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 resultArray(['error' => '推进失败,请重试']);

@ -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; 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); 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; return $data;
} else { } else {
$this->error = '添加失败'; $this->error = '添加失败';

Loading…
Cancel
Save