Files
huangguo_server/web/service/ai_mate_ser/ai_mate.go
T
rootandClaude Opus 5 8679200f41 Initial commit
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-15 13:57:10 +08:00

46 lines
1.5 KiB
Go

package ai_mate_ser
import (
"91porn-server/common/log"
"91porn-server/common/stderr"
"91porn-server/models/v/txnmod"
"fmt"
"go.mongodb.org/mongo-driver/bson"
)
type AIMateTransactionInfo struct {
OrderId string `json:"orderId"` // 订单Id
Credit_delta string `json:"credit_delta"` // 此次操作积分数
Post_credit string `json:"post_credit"` // 操作后剩余积分数
Created_at string `json:"created_at"` // 操作时间
Operation_type string `json:"operation_type"` // 操作类型
}
// GetBalance 获取AI伴侣用户交易记录
func GetUserTransactionsList(uid uint64, pageNumber, pageSize uint64) (code stderr.Code, data map[string]interface{}) {
code = stderr.Success
filter := bson.M{"tranTypeInt": bson.M{"$in": []txnmod.TransType{txnmod.AiMateChat, txnmod.AdminAiMateSet, txnmod.AiMateCurrencyExchange}}, "uid": uid}
list, _, total, err := txnmod.GetCoinLogs(pageNumber, pageSize, filter)
if err != nil {
log.Error("ai_mate_ser GetCoinLogs", log.Any("err", err), log.Any("uid", uid))
return
}
rsl := make([]AIMateTransactionInfo, 0)
for _, v := range list {
info := AIMateTransactionInfo{
OrderId: v.ID.Hex(),
Credit_delta: fmt.Sprintf("%v", v.AiMatePoint),
Post_credit: fmt.Sprintf("%v", v.RealAiMatePoint),
Created_at: v.CreatedAt.String(),
Operation_type: v.TranType,
}
rsl = append(rsl, info)
}
data = map[string]interface{}{}
data["count"] = total
data["list"] = rsl
return
}