diff --git a/call/currency.go b/call/currency.go index bda16a2..a432405 100644 --- a/call/currency.go +++ b/call/currency.go @@ -206,7 +206,8 @@ func (b *BaseCurrency) UpdatePro() (*ProRes, error) { if b.ProType == ProTypeMineCash { callName = "mineCurrency" } - err := db.Mysql().C().Raw(fmt.Sprintf("call %s(%d,'%v',%d,%d,@a,@b)", callName, uid, field, b.Value, b.NeedBet)).Scan(pro).Error + sql := fmt.Sprintf("call %s(%d,'%v',%d,%d,@a,@b)", callName, uid, field, b.Value, b.NeedBet) + err := db.Mysql().C().Raw(sql).Scan(pro).Error if err != nil { log.Error("err:%v", err) return pro, err diff --git a/common/activity.go b/common/activity.go index 22c5294..1c137fa 100644 --- a/common/activity.go +++ b/common/activity.go @@ -663,12 +663,13 @@ func (m *PddDataNew) TableName() string { } type PddLotteryHistory struct { - ID int `gorm:"primarykey"` - UID int `gorm:"column:uid;not null;type:int(11)" json:"uid"` - ExpiredAt int64 `gorm:"column:expired_at;type:bigint(20);comment:过期时间" json:"expiredAt"` - AddAmount string `gorm:"column:add_amount;type:varchar(255);default:'';comment:增加余额" json:"addAmount"` - Amount string `gorm:"column:amount;type:varchar(255);default:'';comment:余额" json:"amount"` - CreatedAt int64 `gorm:"column:created_at;type:bigint(20);comment:创建时间" json:"createdAt"` + ID int `gorm:"primarykey"` + UID int `gorm:"column:uid;not null;type:int(11)" json:"uid"` + WithdrawRecord int `gorm:"column:withdraw_record;default:0;type:int(11);comment:是否是提现记录" json:"withdrawRecord"` + ExpiredAt int64 `gorm:"column:expired_at;type:bigint(20);comment:过期时间" json:"expiredAt"` + AddAmount string `gorm:"column:add_amount;type:varchar(255);default:'';comment:增加余额" json:"addAmount"` + Amount string `gorm:"column:amount;type:varchar(255);default:'';comment:余额" json:"amount"` + CreatedAt int64 `gorm:"column:created_at;type:bigint(20);comment:创建时间" json:"createdAt"` } func (m *PddLotteryHistory) TableName() string { diff --git a/modules/backend/handler/sys/sys.go b/modules/backend/handler/sys/sys.go index ce9dc26..28f35ae 100644 --- a/modules/backend/handler/sys/sys.go +++ b/modules/backend/handler/sys/sys.go @@ -339,6 +339,23 @@ func EditChannel(c *gin.Context) { // one.FBAccessToken = *req.FBAccessToken update["ad_upload"] = *req.ADUpload } + + if req.ShareUrl != nil && one.ShareURL != *req.ShareUrl { + update["share_url"] = *req.ShareUrl + } + if req.UIVersion != nil && one.UIVersion != *req.UIVersion { + update["ui_version"] = *req.UIVersion + } + if req.ApiURL != nil && one.ApiURL != *req.ApiURL { + update["api_url"] = *req.ApiURL + } + if req.HotURL != nil && one.HotURL != *req.HotURL { + update["hot_url"] = *req.HotURL + } + if req.Is != nil && one.Is != *req.Is { + update["is"] = *req.Is + } + if len(update) == 0 { a.Code = values.CodeParam a.Msg = "无内容修改" diff --git a/modules/backend/values/protocol.go b/modules/backend/values/protocol.go index c72f2df..8df1548 100644 --- a/modules/backend/values/protocol.go +++ b/modules/backend/values/protocol.go @@ -247,6 +247,11 @@ type EditChannelReq struct { FBAccessToken *string UP *int ADUpload *int + ShareUrl *string `json:"ShareUrl"` + UIVersion *string `json:"UIVersion"` + ApiURL *string `json:"ApiURL"` + HotURL *string `json:"HotURL"` + Is *int `json:"Is"` } // DelChannelReq 删除渠道 diff --git a/modules/pay/values/values.go b/modules/pay/values/values.go index 9dc2c78..6851dbb 100644 --- a/modules/pay/values/values.go +++ b/modules/pay/values/values.go @@ -100,9 +100,63 @@ const ( MtxxPay RobusPay MoneydealerNativePay + VirgoPay PayAll ) +type WithdrawWay int + +const ( + FunzoneWithdraw WithdrawWay = iota + WellWithdraw + OctroWithdraw + IGeekWithdraw + CloudWithdraw + VSWithdraw + JoyWithdraw + FFWithdraw + BestWithdraw + HXWithdraw + MGWithdraw + OOWithdraw + ZWWithdraw + FastWithdraw + HaoWithdraw + QPWithdraw + OwlWithdraw + SkyWithdraw + GreWithdraw + MoonWithdraw + AceWithdraw + MccWithdraw + YoduWithdraw + WordWithdraw + HWWithdraw + JJWithdraw + AntWithdraw + MLWithdraw + RojWithdraw + QuantaWithdraw + InnoWithdraw + PeWithdraw + FF8Withdraw + FlaWithdraw + DidaWithdraw + CYGGWithdraw + ZWithdraw + HappyWithdraw + FastPlusWithdraw + GoWithdraw + LemonWithdraw + CamelWithdraw + MoonWithdraw2 + SWithdraw + VendooWithdraw + MtxxPayWithdraw + RobusWithdraw + WithdrawAll +) + // 错误码 const ( CodeOk = iota diff --git a/modules/web/app/response.go b/modules/web/app/response.go index ec5643f..6ccd4a1 100644 --- a/modules/web/app/response.go +++ b/modules/web/app/response.go @@ -36,6 +36,7 @@ type Gin struct { WhiteIps []string Prefix string DeviceType int + Resversion int } type R struct { @@ -53,6 +54,7 @@ func NewApp(c *gin.Context) *Gin { g.Token = c.GetHeader("token") g.Lang = common.CheckLang(c.GetHeader("lang")) g.Referrer = c.GetHeader("referrer") + g.Resversion = util.ToInt(c.GetHeader("resversion")) channel := c.GetHeader("channel") if len(channel) > 0 { g.Channel, _ = strconv.Atoi(channel) diff --git a/modules/web/handler/pdd.go b/modules/web/handler/pdd.go index 327b46d..093a738 100644 --- a/modules/web/handler/pdd.go +++ b/modules/web/handler/pdd.go @@ -96,7 +96,7 @@ func PddCfg(c *gin.Context) { } } historyDB := db.Mysql().C().Model(&common.PddLotteryHistory{}). - Where("uid = ? and expired_at = ?", uid, pddData.ExpiredAt). + Where("uid = ? and expired_at = ? and withdraw_record = 0", uid, pddData.ExpiredAt). Order("created_at desc") if req.Page != 0 && req.PageSize != 0 { historyDB = historyDB.Offset((req.Page - 1) * req.PageSize).Limit(req.PageSize) @@ -116,7 +116,6 @@ func PddCfg(c *gin.Context) { }, } } - log.Debug("resp:%+v", *resp) } func PddLottery(c *gin.Context) { @@ -281,6 +280,17 @@ func PddDraw(c *gin.Context) { a.Code = values.CodeRetry return } + err = db.Mysql().C().Model(&common.PddLotteryHistory{}).Create(&common.PddLotteryHistory{ + UID: uid, + WithdrawRecord: 1, + ExpiredAt: pddData.ExpiredAt, + AddAmount: fmt.Sprintf("%d", pdd.WithdrawalAmount), + Amount: fmt.Sprintf("%d", pdd.WithdrawalAmount), + CreatedAt: time.Now().Unix(), + }).Error + if err != nil { + log.Error("create award history err, %s", err.Error()) + } _, err = call.UpdateCurrencyPro(&common.UpdateCurrency{ CurrencyBalance: &common.CurrencyBalance{ UID: a.UID, @@ -298,3 +308,38 @@ func PddDraw(c *gin.Context) { } resp.Amount = pdd.WithdrawalAmount } + +func PddAwardHistory(c *gin.Context) { + a := app.NewApp(c) + defer func() { + a.Response() + }() + + req := new(values.PddDrawHistoryReq) + if !a.S(req) { + return + } + uid := a.UID + + resp := &values.PddDrawHistoryResp{} + a.Data = resp + + mdb := db.Mysql().C().Model(&common.PddLotteryHistory{}). + Where("uid = ? and withdraw_record = 1", uid) + err := mdb.Count(&resp.Total).Error + if err != nil { + log.Error("get ward history count err, %s", err.Error) + a.Code = values.CodeRetry + return + } + mdb = mdb.Order("created_at desc") + if req.Page != 0 && req.PageSize != 0 { + mdb = mdb.Offset((req.Page - 1) * req.PageSize).Limit(req.PageSize) + } + err = mdb.Find(&resp.LotteryHistory).Error + if err != nil { + log.Error("get award history err, %s", err.Error()) + a.Code = values.CodeRetry + return + } +} diff --git a/modules/web/handler/withdraw.go b/modules/web/handler/withdraw.go index 83c7764..7a4c6f5 100644 --- a/modules/web/handler/withdraw.go +++ b/modules/web/handler/withdraw.go @@ -206,6 +206,23 @@ func WithdrawInfo(c *gin.Context) { if resp.NeedBet == 0 { resp.CanWithdraw = resp.Cash } + var withdrawInfo common.WithdrawInfo + err := db.Mysql().C().Model(&common.WithdrawInfo{}).Where("uid = ?", a.UID).Find(&withdrawInfo).Error + if err != nil { + log.Error("err:%v", err) + a.Code = values.CodeRetry + return + } + if withdrawInfo.ID == 0 { + return + } + resp.WithdrawInfo.BankName = withdrawInfo.BankName + resp.WithdrawInfo.BankBranchName = withdrawInfo.BankBranchName + resp.WithdrawInfo.PhoneNumber = withdrawInfo.PhoneNumber + resp.WithdrawInfo.UserName = withdrawInfo.UserName + resp.WithdrawInfo.IFSCCode = withdrawInfo.IFSCCode + resp.WithdrawInfo.AccountNumber = withdrawInfo.AccountNumber + resp.WithdrawInfo.Email = withdrawInfo.Email a.Data = resp } diff --git a/modules/web/middleware/cross.go b/modules/web/middleware/cross.go index d7da3e0..bf63a0c 100644 --- a/modules/web/middleware/cross.go +++ b/modules/web/middleware/cross.go @@ -25,7 +25,7 @@ func CrosHandler() gin.HandlerFunc { context.Header("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE,UPDATE") //允许跨域设置可以返回其他子段,可以自定义字段 - context.Header("Access-Control-Allow-Headers", "fbc,fbp,lang,zone,res_version,share,Channel,uuid,version,Authorization, Content-Length, X-CSRF-Token, Token,session,X_Requested_With,Accept, Origin, Host, Connection, Accept-Encoding, Accept-Language,DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, Cache-Control, Content-Type, Pragma,token,openid,opentoken") + context.Header("Access-Control-Allow-Headers", "fbc,fbp,lang,zone,res_version,share,Channel,uuid,version,Resversion,Authorization, Content-Length, X-CSRF-Token, Token,session,X_Requested_With,Accept, Origin, Host, Connection, Accept-Encoding, Accept-Language,DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, Cache-Control, Content-Type, Pragma,token,openid,opentoken") // 允许浏览器(客户端)可以解析的头部 (重要) context.Header("Access-Control-Expose-Headers", "Content-Length, Access-Control-Allow-Origin, Access-Control-Allow-Headers,Cache-Control,Content-Language,Content-Type,Expires,Last-Modified,Pragma,FooBar") diff --git a/modules/web/providers/base/base.go b/modules/web/providers/base/base.go index 8e36bef..20f6cc2 100644 --- a/modules/web/providers/base/base.go +++ b/modules/web/providers/base/base.go @@ -368,8 +368,9 @@ func SessionBet(req *BetReq) (resp BetResp) { resp.MyUUID = uuid return } - if betAmount > 0 { - pro := call.MineCurrencyProReal( + var pro *call.ProRes + if betAmount > 0 { // 存储下注金额 + pro = call.MineCurrencyProReal( &common.UpdateCurrency{ CurrencyBalance: &common.CurrencyBalance{ UID: uid, @@ -391,13 +392,25 @@ func SessionBet(req *BetReq) (resp BetResp) { resp.Code = CodeNotEnoughAmount } } - if req.SessionType == SessionTypeBet { + if req.SessionType == SessionTypeBet { // 下注回合的直接返回,等结算的再一起上报 resp.Balance = pro.Balance resp.MyUUID = uuid return } } - var pro *call.ProRes + if pro == nil { + tmpRecord := &common.ProviderBetRecord{ + UID: uid, + SessionID: req.SessionID, + Type: 1, + } + db.Mysql().Get(tmpRecord) + if tmpRecord.ID == 0 { + resp.Code = CodeBetNotExist + return + } + betAmount = tmpRecord.Amount + } setValue := settle + req.Preserve if setValue != 0 { cb := &common.CurrencyBalance{ @@ -423,17 +436,18 @@ func SessionBet(req *BetReq) (resp BetResp) { } } util.IndexTryS(func() error { - return call.Publish(natsClient.TopicInnerAfterSettle, &pb.InnerAfterSettle{ + sendData := &pb.InnerAfterSettle{ UID: int64(uid), ProviderID: int64(provider.ProviderID), GameID: int64(req.GameID), UUID: req.BetID, CurrencyType: int64(ct), - TotalBet: req.TurnOver, + TotalBet: betAmount, OriginSettle: settle, FinalSettle: settle, MyUUID: fmt.Sprintf("%d", uuid), - }) + } + return call.Publish(natsClient.TopicInnerAfterSettle, sendData) }) if pro != nil { resp.Balance = pro.Balance diff --git a/modules/web/routers/routers_pdd.go b/modules/web/routers/routers_pdd.go index 047d2c2..7c4878d 100644 --- a/modules/web/routers/routers_pdd.go +++ b/modules/web/routers/routers_pdd.go @@ -9,4 +9,5 @@ func pdd(e *gin.RouterGroup) { e.POST("/pdd/cfg", handler.PddCfg) e.POST("/pdd/lottery", handler.PddLottery) e.POST("/pdd/award", handler.PddDraw) + e.POST("/pdd/award/history", handler.PddAwardHistory) } diff --git a/modules/web/values/pay.go b/modules/web/values/pay.go index 2ff22c1..88b1b1a 100644 --- a/modules/web/values/pay.go +++ b/modules/web/values/pay.go @@ -117,7 +117,7 @@ type WithdrawCheckReq struct { // WithdrawReq 退出请求 type WithdrawReq struct { - Type int `json:"Type" binding:"required"` + Type int `json:"Type"` ChannelID *int `json:"ChannelID"` // 代付渠道选择 CurrencyType common.CurrencyType `json:"CurrencyType"` // 可能对应多种结构 @@ -180,9 +180,10 @@ type WithDrawInfoResp struct { Fees []int64 Bets []int64 - Cash int64 // 货币 - CanWithdraw int64 // 可提现金额 - NeedBet int64 // 打码信息 + Cash int64 // 货币 + CanWithdraw int64 // 可提现金额 + NeedBet int64 // 打码信息 + WithdrawInfo WithdrawInfo } // WithdrawHistoryReq 请求退出记录 diff --git a/modules/web/values/pdd.go b/modules/web/values/pdd.go index 8341b8a..90d8975 100644 --- a/modules/web/values/pdd.go +++ b/modules/web/values/pdd.go @@ -44,3 +44,13 @@ type PddDrawReq struct { type PddDrawResp struct { Amount int `json:"amount"` // 金额 } + +type PddDrawHistoryReq struct { + Page int `json:"page"` + PageSize int `json:"pageSize"` +} + +type PddDrawHistoryResp struct { + Total int64 `json:"total"` + LotteryHistory []common.PddLotteryHistory `json:"lotteryHistory"` +}