- 修改了 OrderSubmitParam 和 OrderSubmitRequest 结构体的字段名称,统一添加 Sys 前缀 - 更新了 CreateOrderSubmitRequest 函数以适应新的结构体字段 -调整了单元测试中的测试数据,以匹配新的接口参数
459 lines
9.3 KiB
Go
459 lines
9.3 KiB
Go
package cs
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"testing"
|
|
)
|
|
|
|
/**
|
|
* 客服工单服务,单元测试
|
|
*/
|
|
|
|
// 获取faq树状数据
|
|
func TestGetFaq(t *testing.T) {
|
|
client, newErr := NewClient()
|
|
if newErr != nil {
|
|
panic(newErr)
|
|
}
|
|
|
|
req := CreateGetFaqRequest()
|
|
faq, err := client.GetFaq(req)
|
|
if err != nil {
|
|
t.Error(err)
|
|
return
|
|
}
|
|
|
|
fmt.Printf(fmt.Sprintf("%#+v", faq))
|
|
}
|
|
|
|
// 获取玩家基本信息
|
|
func TestGetUserInfo(t *testing.T) {
|
|
client, newErr := NewClient()
|
|
if newErr != nil {
|
|
panic(newErr)
|
|
}
|
|
req := CreateGetUserInfoRequest("ws45265737")
|
|
info, err := client.GetUserInfo(req)
|
|
if err != nil {
|
|
t.Error(err)
|
|
return
|
|
}
|
|
|
|
fmt.Printf(fmt.Sprintf("%v", info))
|
|
}
|
|
|
|
// 获取玩家角色列表
|
|
func TestGetUserRoleList(t *testing.T) {
|
|
client, newErr := NewClient()
|
|
if newErr != nil {
|
|
panic(newErr)
|
|
}
|
|
req := CreateGetUserRoleListRequest(int64(63610626), int64(2850))
|
|
info, err := client.GetCsUserRoleList(req)
|
|
if err != nil {
|
|
t.Error(err)
|
|
return
|
|
}
|
|
if info.Code != 0 {
|
|
t.Error("获取玩家角色列表失败")
|
|
fmt.Printf(fmt.Sprintf("%v", info))
|
|
return
|
|
}
|
|
fmt.Printf(fmt.Sprintf("%v", info))
|
|
}
|
|
|
|
// 获取玩家区服列表
|
|
func TestGetUserServerList(t *testing.T) {
|
|
client, newErr := NewClient()
|
|
if newErr != nil {
|
|
panic(newErr)
|
|
}
|
|
req := CreateGetUserServerListRequest(int64(63610626), int64(2850))
|
|
info, err := client.GetUserServerList(req)
|
|
if err != nil {
|
|
t.Error(err)
|
|
return
|
|
}
|
|
if info.Code != 0 {
|
|
t.Error("获取玩家区服列表失败")
|
|
fmt.Printf(fmt.Sprintf("%v", info))
|
|
return
|
|
}
|
|
fmt.Printf(fmt.Sprintf("%v", info))
|
|
}
|
|
|
|
// 给玩家发送短信
|
|
func TestSendSms(t *testing.T) {
|
|
client, newErr := NewClient()
|
|
if newErr != nil {
|
|
panic(newErr)
|
|
}
|
|
req := CreateSendSmsRequest(SendSmsReq{
|
|
Phone: "13725263463",
|
|
})
|
|
info, err := client.SendSmsCode(req)
|
|
if err != nil {
|
|
t.Error(err)
|
|
return
|
|
}
|
|
if info.Code != 0 {
|
|
t.Error("给玩家发送短信失败")
|
|
}
|
|
fmt.Printf(fmt.Sprintf("%v", info))
|
|
}
|
|
|
|
// 工单图片上传
|
|
func TestUpload(t *testing.T) {
|
|
client, newErr := NewClient()
|
|
if newErr != nil {
|
|
panic(newErr)
|
|
}
|
|
// 读取文件流
|
|
file, err := os.ReadFile("test.png")
|
|
if err != nil {
|
|
t.Error(err)
|
|
return
|
|
}
|
|
req := CreateUploadRequest()
|
|
req.FileStream = file
|
|
res, err := client.Upload(req)
|
|
if err != nil {
|
|
t.Error(err)
|
|
return
|
|
}
|
|
if res.Code != 0 {
|
|
t.Error("工单图片上传失败")
|
|
}
|
|
fmt.Printf(fmt.Sprintf("%v", res))
|
|
}
|
|
|
|
// 工单模板查询
|
|
func TestGetOrderTemplateDetail(t *testing.T) {
|
|
client, newErr := NewClient()
|
|
if newErr != nil {
|
|
panic(newErr)
|
|
}
|
|
templateId := int64(12)
|
|
req := CreateOrderTemplateDetailReq(templateId)
|
|
res, err := client.GetOrderTemplateDetail(req)
|
|
if err != nil {
|
|
t.Error(err)
|
|
return
|
|
}
|
|
if res.Code != 0 {
|
|
t.Error("工单模板查询失败")
|
|
}
|
|
fmt.Printf(fmt.Sprintf("%v", res))
|
|
}
|
|
|
|
// 工单补充字段设置
|
|
func TestGetOrderFurtherPart(t *testing.T) {
|
|
client, newErr := NewClient()
|
|
if newErr != nil {
|
|
panic(newErr)
|
|
}
|
|
req := CreateGetOrderFurtherPartRequest(GetOrderFurtherPartParam{
|
|
OrderNum: "20250605092301764049"})
|
|
res, err := client.GetOrderFurtherPart(req)
|
|
if err != nil {
|
|
t.Error(err)
|
|
return
|
|
}
|
|
if res.Code != 0 {
|
|
t.Error("工单补充字段设置获取失败")
|
|
}
|
|
fmt.Printf(fmt.Sprintf("%v", res))
|
|
}
|
|
|
|
// 用户催单
|
|
func TestOrderUrgent(t *testing.T) {
|
|
client, newErr := NewClient()
|
|
if newErr != nil {
|
|
panic(newErr)
|
|
}
|
|
req := CreateOrderUrgentRequest(OrderUrgentParam{
|
|
OrderNum: "20250530173554491048"})
|
|
res, err := client.OrderUrgent(req)
|
|
if err != nil {
|
|
t.Error(err)
|
|
return
|
|
}
|
|
if res.Code != 0 {
|
|
t.Error("用户催单失败")
|
|
}
|
|
fmt.Printf(fmt.Sprintf("%v", res))
|
|
}
|
|
|
|
// 用户更新工单处理标识
|
|
func TestOrderUpdateHandle(t *testing.T) {
|
|
client, newErr := NewClient()
|
|
if newErr != nil {
|
|
panic(newErr)
|
|
}
|
|
req := CreateOrderUpdateHandleRequest(OrderUpdateHandleParam{
|
|
IsHandle: 1,
|
|
OrderNum: "20250530173554491048"})
|
|
res, err := client.OrderUpdateHandle(req)
|
|
if err != nil {
|
|
t.Error(err)
|
|
return
|
|
}
|
|
if res.Code != 0 {
|
|
t.Error("用户催单失败")
|
|
}
|
|
fmt.Printf(fmt.Sprintf("%v", res))
|
|
}
|
|
|
|
// 用户评价工单
|
|
func TestOrderAppraise(t *testing.T) {
|
|
client, newErr := NewClient()
|
|
if newErr != nil {
|
|
panic(newErr)
|
|
}
|
|
req := CreateOrderAppraiseRequest(OrderAppraiseParam{
|
|
OrderNum: "20250530173554491048",
|
|
Score: 5,
|
|
})
|
|
res, err := client.OrderAppraise(req)
|
|
if err != nil {
|
|
t.Error(err)
|
|
return
|
|
}
|
|
if res.Code != 0 {
|
|
t.Error("用户评价失败")
|
|
}
|
|
fmt.Printf(fmt.Sprintf("%v", res))
|
|
}
|
|
|
|
// 工单重启
|
|
func TestOrderRestart(t *testing.T) {
|
|
client, newErr := NewClient()
|
|
if newErr != nil {
|
|
panic(newErr)
|
|
}
|
|
req := CreateOrderRestartRequest(OrderRestartParam{
|
|
OrderNum: "20250530173554491048",
|
|
RemarkContent: "模拟用户重启",
|
|
RemarkPic: []string{},
|
|
})
|
|
res, err := client.OrderRestart(req)
|
|
if err != nil {
|
|
t.Error(err)
|
|
return
|
|
}
|
|
if res.Code != 0 {
|
|
t.Error("工单重启失败")
|
|
}
|
|
fmt.Printf(fmt.Sprintf("%v", res))
|
|
}
|
|
|
|
// 提交工单
|
|
func TestOrderSubmit(t *testing.T) {
|
|
client, newErr := NewClient()
|
|
if newErr != nil {
|
|
panic(newErr)
|
|
}
|
|
req := CreateOrderSubmitRequest(OrderSubmitParam{
|
|
SysGameId: 7874,
|
|
SysUserName: "rz35990497",
|
|
SysUid: 221016372,
|
|
SysRoleId: "265500394",
|
|
SysRoleName: "好玩的尼",
|
|
SysServerName: "碧水连天",
|
|
SysOrderTemplateCode: "findAccount",
|
|
SysDetail: "测试go-common改动。",
|
|
SysPhone: "13725263463",
|
|
ApplyIp: "192.168.1.202",
|
|
SysOrderParts: []OrderSubmitPart{
|
|
{
|
|
PartKey: "email",
|
|
PartName: "联系邮箱",
|
|
PartValue: "kingson2011@126.com",
|
|
PicValue: nil,
|
|
},
|
|
{
|
|
PartKey: "pay_pic",
|
|
PartName: "充值凭证",
|
|
PartValue: "",
|
|
PicValue: []string{
|
|
"uploads/068/068eefab055a96ae404db19b7a121898.jpeg",
|
|
"uploads/908/90822cca4e87ed49acaf82050dd3ac09.jpeg",
|
|
},
|
|
},
|
|
},
|
|
SysSmsCode: "7204",
|
|
})
|
|
res, err := client.OrderSubmit(req)
|
|
if err != nil {
|
|
t.Error(err)
|
|
return
|
|
}
|
|
if res.Code != 0 {
|
|
t.Error("工单提交失败")
|
|
}
|
|
fmt.Printf(fmt.Sprintf("%v", res))
|
|
}
|
|
|
|
// 用户工单补充资料
|
|
func TestOrderFurtherPart(t *testing.T) {
|
|
client, newErr := NewClient()
|
|
if newErr != nil {
|
|
panic(newErr)
|
|
}
|
|
req := CreateOrderFurtherPartRequest(OrderFurtherPartParam{
|
|
OrderNum: "20250611160840208567",
|
|
OrderParts: []OrderSubmitPart{
|
|
{
|
|
PartKey: "game_name",
|
|
PartName: "游戏名称",
|
|
PartValue: "镇魂街:最终章",
|
|
},
|
|
},
|
|
})
|
|
res, err := client.OrderFurtherPart(req)
|
|
if err != nil {
|
|
t.Error(err)
|
|
return
|
|
}
|
|
if res.Code != 0 {
|
|
t.Error("用户工单补充资料失败")
|
|
}
|
|
fmt.Printf(fmt.Sprintf("%v", res))
|
|
}
|
|
|
|
// 工单列表查询
|
|
func TestGetWorkOrderRecordList(t *testing.T) {
|
|
client, newErr := NewClient()
|
|
if newErr != nil {
|
|
panic(newErr)
|
|
}
|
|
req := CreateGetWorkOrderRecordListRequest(GetWorkOrderRecordListParam{
|
|
HandleStatus: "",
|
|
UserName: "ws45265737",
|
|
GameId: 7991,
|
|
Page: 1,
|
|
PageSize: 20,
|
|
})
|
|
res, err := client.OrderRecordList(req)
|
|
if err != nil {
|
|
t.Error(err)
|
|
return
|
|
}
|
|
if res.Code != 0 {
|
|
t.Error("工单列表查询失败")
|
|
}
|
|
fmt.Printf(fmt.Sprintf("%v", res))
|
|
}
|
|
|
|
// 工单详情查询
|
|
func TestOrderRecordDetail(t *testing.T) {
|
|
client, newErr := NewClient()
|
|
if newErr != nil {
|
|
panic(newErr)
|
|
}
|
|
req := CreateGetWorkOrderRecordDetailRequest(OrderDetailParam{
|
|
OrderNum: "20250611160840208567",
|
|
})
|
|
res, err := client.OrderRecordDetail(req)
|
|
if err != nil {
|
|
t.Error(err)
|
|
return
|
|
}
|
|
if res.Code != 0 {
|
|
t.Error("工单详情查询失败")
|
|
}
|
|
fmt.Printf(fmt.Sprintf("%v", res))
|
|
}
|
|
|
|
// 获取faq详情
|
|
func TestGetFaqDetail(t *testing.T) {
|
|
client, newErr := NewClient()
|
|
if newErr != nil {
|
|
panic(newErr)
|
|
}
|
|
req := CreateGetFaqDetailRequest(FaqDetailRequest{
|
|
Id: int64(31),
|
|
})
|
|
res, err := client.GetFaqDetail(req)
|
|
if err != nil {
|
|
t.Error(err)
|
|
return
|
|
}
|
|
if res.Code != 0 || res.Data.Id == 0 {
|
|
t.Error("获取faq详情失败")
|
|
}
|
|
fmt.Printf(fmt.Sprintf("%v", res))
|
|
}
|
|
|
|
// 获取热门faq
|
|
func TestGetFaqHotList(t *testing.T) {
|
|
client, newErr := NewClient()
|
|
if newErr != nil {
|
|
panic(newErr)
|
|
}
|
|
req := CreateGetHotFaqRequest()
|
|
res, err := client.GetHotFaqList(req)
|
|
if err != nil {
|
|
t.Error(err)
|
|
return
|
|
}
|
|
if res.Code != 0 || len(res.Data) == 0 {
|
|
t.Error("获取热门faq失败")
|
|
}
|
|
fmt.Printf(fmt.Sprintf("%v", res))
|
|
}
|
|
|
|
// 清理faq列表缓存
|
|
func TestClearFaqListCache(t *testing.T) {
|
|
client, newErr := NewClient()
|
|
if newErr != nil {
|
|
panic(newErr)
|
|
}
|
|
req := CreateClearFaqListCacheRequest()
|
|
res, err := client.ClearFaqListCache(req)
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
if res.Code != 0 {
|
|
t.Error("清理faq列表缓存失败")
|
|
}
|
|
fmt.Printf(fmt.Sprintf("%v", res))
|
|
}
|
|
|
|
// 清理faq详情缓存
|
|
func TestClearFaqDetailCache(t *testing.T) {
|
|
client, newErr := NewClient()
|
|
if newErr != nil {
|
|
panic(newErr)
|
|
}
|
|
req := CreateClearFaqDetailCacheRequest(FaqDetailRequest{
|
|
Id: int64(30),
|
|
})
|
|
res, err := client.ClearFaqDetailCache(req)
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
if res.Code != 0 {
|
|
t.Error("清理faq详情缓存失败")
|
|
}
|
|
fmt.Printf(fmt.Sprintf("%v", res))
|
|
}
|
|
|
|
// 清理热门faq缓存
|
|
func TestClearHotFaqCache(t *testing.T) {
|
|
client, newErr := NewClient()
|
|
if newErr != nil {
|
|
panic(newErr)
|
|
}
|
|
req := CreateClearHotFaqCacheRequest()
|
|
res, err := client.ClearHotFaqCache(req)
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
if res.Code != 0 {
|
|
t.Error("清理热门faq缓存失败")
|
|
}
|
|
fmt.Printf(fmt.Sprintf("%v", res))
|
|
}
|