注意事项立即发送

This commit is contained in:
meimei
2025-04-16 17:14:47 +08:00
parent 6fb3f0b830
commit bf50e4f3a2
2 changed files with 18 additions and 6 deletions

View File

@@ -3,10 +3,12 @@
namespace app\admin\controller;
use app\common\controller\Backend;
use app\index\controller\Tasktimer;
use think\Db;
use think\Exception;
use think\exception\PDOException;
use think\exception\ValidateException;
use wanghua\general_utility_tools_php\tool\Tools;
/**
* 客户回访记录
@@ -237,7 +239,6 @@ class Firmcustomerfollowuprecord extends Backend
}
$result = false;
//todo 需要增加一个有注意事项就需要立即发送内容
Db::startTrans();
try {
//是否采用模型验证
@@ -262,6 +263,7 @@ class Firmcustomerfollowuprecord extends Backend
$this->error('添加失败,请重新操作');
}
}
$this->returnNotespoints($customerData,$params['notes']);
Db::commit();
} catch (ValidateException|PDOException|Exception $e) {
Db::rollback();
@@ -272,5 +274,15 @@ class Firmcustomerfollowuprecord extends Backend
}
$this->success();
}
/*
* 立即发送注意事项
*/
function returnNotespoints($customer_record,$notesMsg){
if(!empty($notesMsg)){
Tools::log_to_write_txt(['客户注意事项,开始:$item'=>$customer_record]);
$ret = (new Tasktimer())->postMatterText($customer_record,['content'=>$notesMsg],'注意事项');
Tools::log_to_write_txt(['客户注意事项,结束:$res'=>$ret]);
}
}
}

View File

@@ -188,7 +188,7 @@ class Tasktimer extends Controller
->find();
if(!empty($birthday_record)){
Tools::log_to_write_txt(['客户生日祝福计划,开始:$item'=>$value]);
$ret = $this->postBirthdayText($value,$birthday_record);
$ret = $this->postMatterText($value,$birthday_record,'生日');
Tools::log_to_write_txt(['客户生日祝福计划,结束:$res'=>$ret]);
}
Tools::log_to_write_txt(['无生日祝福,无需发送']);
@@ -196,14 +196,14 @@ class Tasktimer extends Controller
}
return '';
}
private function postBirthdayText($customer_record,$birthday_record){
public function postMatterText($customer_record,$birthday_record,$msg=''){
//查询客户所绑定的ai客服
$ai_config = Db::table('fa_aicustomerservice')
->where('id',$customer_record['aicustomerservice_ids'])
->find();
if(empty($ai_config)){
return Tools::set_fail('有回访计划无ai客服服务该客户');
return Tools::set_fail('有'.$msg.'计划无ai客服服务该客户');
}
$base_url = $ai_config['server_url'];
if(empty($customer_record['rel_group'])){
@@ -227,9 +227,9 @@ class Tasktimer extends Controller
//@的好友,多个英文逗号分隔。群主或管理员@全部的人,则填写'notify@all'
'ats'=>$customer_record['rel_wx'],
];
Tools::log_to_write_txt(['回访微信群客户,开始:$post_data'=>$data]);
Tools::log_to_write_txt([$msg.'微信群客户,开始:$post_data'=>$data]);
$res = $logic->postGroupText($data);
Tools::log_to_write_txt(['回访微信群客户,结束:$res'=>$res]);
Tools::log_to_write_txt([$msg.'微信群客户,结束:$res'=>$res]);
return Tools::set_ok('发送成功');
}