test(addon/aikefu): 测试会话管理及消息展示
This commit is contained in:
@@ -117,7 +117,10 @@ class Kefu extends BaseShop
|
|||||||
$conversation_id = input("conversation_id/s", "");
|
$conversation_id = input("conversation_id/s", "");
|
||||||
|
|
||||||
if (empty($conversation_id)) {
|
if (empty($conversation_id)) {
|
||||||
return $this->error('会话ID不能为空');
|
return json([
|
||||||
|
'code' => -1,
|
||||||
|
'msg' => '会话ID不能为空',
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$kefu_conversation_model = new KefuConversationModel();
|
$kefu_conversation_model = new KefuConversationModel();
|
||||||
@@ -127,10 +130,17 @@ class Kefu extends BaseShop
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
if (empty($conversation_info)) {
|
if (empty($conversation_info)) {
|
||||||
return $this->error('会话不存在');
|
return json([
|
||||||
|
'code' => -1,
|
||||||
|
'msg' => '会话不存在',
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->success('获取会话信息成功', null, $conversation_info);
|
return json([
|
||||||
|
'code' => 0,
|
||||||
|
'msg' => '获取会话信息成功',
|
||||||
|
'data' => $conversation_info,
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -142,7 +152,10 @@ class Kefu extends BaseShop
|
|||||||
$id = input("id/d", "");
|
$id = input("id/d", "");
|
||||||
|
|
||||||
if (empty($id)) {
|
if (empty($id)) {
|
||||||
return $this->error('会话ID不能为空');
|
return json([
|
||||||
|
'code' => -1,
|
||||||
|
'msg' => '会话ID不能为空',
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$kefu_conversation_model = new KefuConversationModel();
|
$kefu_conversation_model = new KefuConversationModel();
|
||||||
@@ -154,7 +167,18 @@ class Kefu extends BaseShop
|
|||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
return $this->success('会话已结束', null, $result);
|
if ($result === false) {
|
||||||
|
return json([
|
||||||
|
'code' => -1,
|
||||||
|
'msg' => '会话结束失败',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return json([
|
||||||
|
'code' => 0,
|
||||||
|
'msg' => '会话已结束',
|
||||||
|
'data' => $result,
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -168,7 +192,10 @@ class Kefu extends BaseShop
|
|||||||
|
|
||||||
// 验证参数
|
// 验证参数
|
||||||
if (empty($id) && empty($ids)) {
|
if (empty($id) && empty($ids)) {
|
||||||
return $this->error('会话ID不能为空');
|
return json([
|
||||||
|
'code' => -1,
|
||||||
|
'msg' => '会话ID不能为空',
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理单个ID或ID数组
|
// 处理单个ID或ID数组
|
||||||
@@ -208,11 +235,18 @@ class Kefu extends BaseShop
|
|||||||
// 提交事务
|
// 提交事务
|
||||||
Db::commit();
|
Db::commit();
|
||||||
|
|
||||||
return $this->success('会话已删除', null, $result);
|
return json([
|
||||||
|
'code' => 0,
|
||||||
|
'msg' => '会话已删除',
|
||||||
|
'data' => $result,
|
||||||
|
]);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
// 回滚事务
|
// 回滚事务
|
||||||
Db::rollback();
|
Db::rollback();
|
||||||
return $this->error($e->getMessage());
|
return json([
|
||||||
|
'code' => -1,
|
||||||
|
'msg' => $e->getMessage(),
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user