|
@@ -15,6 +15,8 @@
|
|
|
|
|
|
|
|
namespace app\adminapi\service;
|
|
namespace app\adminapi\service;
|
|
|
|
|
|
|
|
|
|
+use app\common\model\dict\DictData;
|
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -27,14 +29,16 @@ class WeCallService
|
|
|
protected $appKey;
|
|
protected $appKey;
|
|
|
protected $appSecret;
|
|
protected $appSecret;
|
|
|
protected $taskId;
|
|
protected $taskId;
|
|
|
|
|
+ protected $status = 0;
|
|
|
|
|
|
|
|
public function __construct()
|
|
public function __construct()
|
|
|
{
|
|
{
|
|
|
- $config = config('custom.wecall');
|
|
|
|
|
|
|
+ $config = DictData::where('type_value', 'wecall')->column('value','name');
|
|
|
if ($config) {
|
|
if ($config) {
|
|
|
- $this->appKey = $config['appKey'];
|
|
|
|
|
- $this->appSecret = $config['appSecret'];
|
|
|
|
|
- $this->taskId = $config['taskId'];
|
|
|
|
|
|
|
+ $this->appKey = isset($config['appKey']) ?? '';
|
|
|
|
|
+ $this->appSecret = isset($config['appSecret']) ?? '';
|
|
|
|
|
+ $this->taskId = isset($config['taskId']) ?? '';
|
|
|
|
|
+ $this->status = isset($config['status']) ?? 0;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -63,7 +67,7 @@ class WeCallService
|
|
|
* 向外呼任务导入客户
|
|
* 向外呼任务导入客户
|
|
|
*/
|
|
*/
|
|
|
public function importUser($customerList){
|
|
public function importUser($customerList){
|
|
|
- if (empty($this->appKey) || empty($this->appSecret) || empty($this->taskId)) {
|
|
|
|
|
|
|
+ if ($this->status == 0) {
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
$requestBody = [
|
|
$requestBody = [
|
|
@@ -91,7 +95,7 @@ class WeCallService
|
|
|
* 开启外呼任务(仅手动任务可调用)
|
|
* 开启外呼任务(仅手动任务可调用)
|
|
|
*/
|
|
*/
|
|
|
public function startTask(){
|
|
public function startTask(){
|
|
|
- if (empty($this->appKey) || empty($this->appSecret) || empty($this->taskId)) {
|
|
|
|
|
|
|
+ if ($this->status == 0) {
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
$requestBody = [
|
|
$requestBody = [
|
|
@@ -116,7 +120,7 @@ class WeCallService
|
|
|
* 停止外呼任务(仅手动任务可调用)
|
|
* 停止外呼任务(仅手动任务可调用)
|
|
|
*/
|
|
*/
|
|
|
public function stopTask(){
|
|
public function stopTask(){
|
|
|
- if (empty($this->appKey) || empty($this->appSecret) || empty($this->taskId)) {
|
|
|
|
|
|
|
+ if ($this->status == 0) {
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
$requestBody = [
|
|
$requestBody = [
|
|
@@ -153,9 +157,9 @@ class WeCallService
|
|
|
{
|
|
{
|
|
|
$taskId = $data['taskId'];
|
|
$taskId = $data['taskId'];
|
|
|
$status = $data['status'];
|
|
$status = $data['status'];
|
|
|
- $updateTime = $data['updateTime'];
|
|
|
|
|
if ($taskId == $this->taskId && $status == 'COMPLETE') {
|
|
if ($taskId == $this->taskId && $status == 'COMPLETE') {
|
|
|
// TODO 任务状态改变
|
|
// TODO 任务状态改变
|
|
|
|
|
+ $this->stopTask();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|