印度包网
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
2.8 KiB

1 year ago
package guser
import (
"fmt"
"server/common"
"server/db"
"server/modules/backend/app"
"server/modules/backend/models"
utils "server/modules/backend/util"
"server/modules/backend/values"
"github.com/gin-gonic/gin"
"github.com/liangdas/mqant/log"
)
func GetGameUserWithdrawHistory(c *gin.Context) {
a := app.NewApp(c)
defer func() {
a.Response()
}()
req := new(values.GetGameUserWithdrawHistoryReq)
if !a.S(req) {
return
}
resp := values.GetGameUserWithdrawHistoryResp{}
var ret []common.WithdrawOrder
if req.UID > 0 {
count, err := db.Mysql().QueryPlayerRWHistory(&req.UID, nil, req.Page-1, req.Num, []int{int(common.CurrencyEventWithDraw)}, req.Start, req.End, &common.WithdrawOrder{}, &ret)
if err != nil {
log.Error("err:%v", err)
a.Code = values.CodeRetry
return
}
resp.Count = count
for _, v := range ret {
resp.List = append(resp.List, values.OneWithdrawList{UID: v.UID, Time: v.CreateTime, PayAccount: v.PayAccount,
Amount: v.Amount, Status: int(v.Status), OrderID: v.APIPayID, MyOrderID: v.OrderID, FailReason: v.FailReason, OrderCreateAt: v.CreateTime,
AuditTime: v.AuditTime, CallbackTime: v.CallbackTime, Channel: v.PayChannel})
}
resp.WithdrawCount = db.Mysql().Count(&common.RechargeOrder{}, fmt.Sprintf("uid = %v and event = %v", req.UID, common.CurrencyEventWithDraw))
re := &common.RechargeInfo{UID: req.UID}
err = db.Mysql().Get(re)
if err != nil {
log.Error(err.Error())
}
resp.WithdrawTotal = re.TotalWithdraw
successCount := db.Mysql().Count(&common.RechargeOrder{}, fmt.Sprintf("uid = %v and event = %v and status = %v", req.UID, common.CurrencyEventWithDraw, common.StatusROrderFinish))
resp.WithdrawSuccessPer = utils.GetPer(successCount, resp.WithdrawCount)
resp.WithdrawCash = db.Mysql().Sum(&common.WithdrawOrder{}, fmt.Sprintf("uid = %v and event = %v and status = %v", req.UID, common.CurrencyEventWithDraw, common.StatusROrderFinish), "withdraw_cash")
resp.WithdrawTax = resp.WithdrawCash - resp.WithdrawTotal*100
resp.RechargeTotal = models.GetRechargeTotalByUid(&req.UID)
resp.WithDrawPer = utils.GetPer(resp.WithdrawTotal, resp.RechargeTotal)
} else if req.Data != "" {
resp.Count, _ = db.Mysql().QueryList(req.Page-1, req.Num, fmt.Sprintf(`event = %v and (apipayid = "%v" or orderid = '%v')`, common.CurrencyEventWithDraw, req.Data, req.Data), "create_time desc", &common.WithdrawOrder{}, &ret)
for _, v := range ret {
resp.List = append(resp.List, values.OneWithdrawList{UID: v.UID, Time: v.CreateTime, PayAccount: v.PayAccount,
Amount: v.Amount, Status: int(v.Status), OrderID: v.APIPayID, MyOrderID: v.OrderID, FailReason: v.FailReason, OrderCreateAt: v.CreateTime,
AuditTime: v.AuditTime, CallbackTime: v.CallbackTime, Channel: v.PayChannel})
}
} else {
a.Code = values.CodeParam
a.Msg = "查询条件有误"
return
}
a.Data = resp
}