diff --git a/application/crm/controller/Business.php b/application/crm/controller/Business.php index d6473d6..f5d8b28 100644 --- a/application/crm/controller/Business.php +++ b/application/crm/controller/Business.php @@ -628,6 +628,21 @@ class Business extends ApiCommon 'customer_ids' => ',' . $businessInfo['customer_id'] . ',' ]); + # 删除待办事项的关联数据 + db('crm_dealt_relation')->where(['types' => ['eq', 'crm_business'], 'types_id' => ['eq', $data['business_id']]])->delete(); + # 创建待办事项的关联数据 + $checkUserIds = db('crm_business')->where('business_id', $data['business_id'])->value('check_user_id'); + $checkUserIdArray = stringToArray($checkUserIds); + $dealtData = []; + foreach ($checkUserIdArray AS $kk => $vv) { + $dealtData[] = [ + 'types' => 'crm_business', + 'types_id' => $data['business_id'], + 'user_id' => $vv + ]; + } + if (!empty($dealtData)) db('crm_dealt_relation')->insertAll($dealtData); + //推进记录添加 $temp['status_id'] = $status_id ?: 0; $temp['is_end'] = $businessInfo['is_end'] ?: 0; diff --git a/application/crm/controller/Message.php b/application/crm/controller/Message.php index 79e220f..356fa0b 100644 --- a/application/crm/controller/Message.php +++ b/application/crm/controller/Message.php @@ -735,7 +735,7 @@ class Message extends ApiCommon } # 处理待审核合同、回款、发票 - if (in_array($type, ['checkContract', 'checkReceivables', 'checkInvoice'])) { + if (in_array($type, ['checkContract', 'checkReceivables', 'checkInvoice','checkBusiness'])) { $where['check_status'] = ['lt', '2']; $where['check_user_id'] = ['like', ',%' . $userId . '%,']; @@ -754,6 +754,11 @@ class Message extends ApiCommon $invoiceId = !empty($typeId) ? $typeId : Db::name('crm_invoice')->where($where)->column('invoice_id'); db('crm_dealt_relation')->where('user_id', $userId)->where('types', 'crm_invoice')->whereIn('types_id', $invoiceId)->delete(); } + # 商机 + if ($type == 'checkBusiness') { + $invoiceId = !empty($typeId) ? $typeId : Db::name('crm_business')->where($where)->column('business_id'); + db('crm_dealt_relation')->where('user_id', $userId)->where('types', 'crm_business')->whereIn('types_id', $invoiceId)->delete(); + } } diff --git a/application/crm/logic/MessageLogic.php b/application/crm/logic/MessageLogic.php index da2d9e8..e4fbd05 100644 --- a/application/crm/logic/MessageLogic.php +++ b/application/crm/logic/MessageLogic.php @@ -248,7 +248,7 @@ class MessageLogic extends Common # 待审核、审核中 $param['check_status'] = ['lt', 2]; $param['check_user_id'] = ['like', '%,'. $param['user_id'] .',%']; - # 要提醒的发票ID + # 要提醒的商机ID $businessIdArray = db('crm_dealt_relation')->where(['types' => ['eq', 'crm_business'], 'user_id' => ['eq', $param['user_id']]])->column('types_id'); $param['businessIdArray'] = !empty($businessIdArray) ? $businessIdArray : -1; $param['dealt'] = 1;