Files
rootandClaude Opus 5 8679200f41 Initial commit
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-15 13:57:10 +08:00

101 lines
2.5 KiB
Go

package laosiji_app
import (
"context"
"fmt"
"time"
)
func GetUserName(env string, appID int32, uid uint64) string {
if env != "prod" {
return fmt.Sprintf("TEST-%d_%d", appID, uid)
}
return fmt.Sprintf("JHA-%d_%d", appID, uid)
}
type GetAiMateURLReq struct {
Username string
Nickname string
Asset string
Currency string
Theme string
UserAvatar string
LogoURL string
}
type GetAiMateURLResp struct {
AuthURL string `json:"auth_url"`
}
func GetAiMateURL(ctx context.Context, req GetAiMateURLReq) (resp GetAiMateURLResp, err error) {
err = post(ctx, cfg.APIURL+"/lsjapi/aiGirlFriend/auth", map[string]interface{}{
"username": req.Username,
"nickname": req.Nickname,
"asset": req.Asset,
"currency": req.Currency,
"theme": req.Theme,
"user_avatar": req.UserAvatar,
"logo_url": req.LogoURL,
}, &resp)
return
}
type AiMateBringOutReq struct {
Username string
}
type AiMateBringOutResp struct {
Currency string `json:"currency"`
Balance string `json:"balance"`
}
func AiMateBringOut(ctx context.Context, req AiMateBringOutReq) (resp AiMateBringOutResp, err error) {
err = post(ctx, cfg.APIURL+"/lsjapi/aiGirlFriend/bringOutAssets", map[string]interface{}{
"username": req.Username,
}, &resp)
return
}
type AiMateOrderLogsReq struct {
AppID int32
UID uint64
Page int
PageSize int
StartTime time.Time
EndTime time.Time
}
type AiMateOrderLogsResponse struct {
Page string `json:"page"`
PageSize string `json:"page_size"`
Total string `json:"total"`
TotalPage string `json:"total_page"`
Items []AiMateOrderLog `json:"items"`
}
type AiMateOrderLog struct {
ID string `json:"id"`
Username string `json:"username"`
Type string `json:"type"`
TypeStr string `json:"type_str"`
Amount string `json:"amount"`
Balance string `json:"balance"`
Currency string `json:"currency"`
Remark string `json:"remark"`
TypeName string `json:"type_name"`
RoleID string `json:"role_id"`
RoleName string `json:"role_name"`
CreatedAt string `json:"created_at"`
}
func GetAiMateOrderLogs(ctx context.Context, env string, req AiMateOrderLogsReq) (resp AiMateOrderLogsResponse, err error) {
err = post(ctx, cfg.APIURL+"/lsjapi/aiGirlFriend/orderLogs", map[string]interface{}{
"username": GetUserName(env, req.AppID, req.UID),
"page": req.Page,
"page_size": req.PageSize,
"start_time": req.StartTime.Unix(),
"end_time": req.EndTime.Unix(),
}, &resp)
return
}