diff --git a/call/share.go b/call/share.go index 0195597..3bd3c98 100644 --- a/call/share.go +++ b/call/share.go @@ -41,7 +41,7 @@ func ShareBind(share string, isOld bool, uid, cid int) { // 判断是否过期 if now < codeInfo.ExpireAt { util.Go(func() { - SendShareReward(uid, codeInfo.ActivityId) + SendShareReward(cid, codeInfo.UID, codeInfo.ActivityId) }) } } else { @@ -173,13 +173,13 @@ func GetUserShareRechargeAmount(uid, level int) (count int64) { func GetActivityShareCode(uid, actId int) (code string, err error) { now := time.Now() ret := make([]*common.ShareActivityCode, 0, 1) - _, err = db.Mysql().QueryList(0, 1, fmt.Sprintf("uid = %d and activity_id = %d and expire_at < %d", uid, actId, now.Unix()), "id", &common.ShareActivityCode{}, &ret) + _, err = db.Mysql().QueryList(0, 1, fmt.Sprintf("uid = %d and activity_id = %d ", uid, actId), "id", &common.ShareActivityCode{}, &ret) if err != nil { log.Error("GetActivityShareCode err:%v", err) return } + expireTime := util.GetZeroTime(now.AddDate(0, 0, 1)) if len(ret) == 0 { - expireTime := util.GetZeroTime(now.AddDate(0, 0, 1)) code = util.GetShareCode(-uid - actId) err = db.Mysql().Create(&common.ShareActivityCode{ UID: uid, @@ -194,11 +194,78 @@ func GetActivityShareCode(uid, actId int) (code string, err error) { } } else { code = ret[0].ShareCode + _, err = db.Mysql().UpdateRes(&common.ShareActivityCode{UID: uid, ActivityId: actId}, map[string]interface{}{ + "expire_at": expireTime.Unix(), + }) + if err != nil { + log.Error("GetActivityShareCode err:%v", err) + } } return } -func SendShareReward(uid, actId int) { - switch actId { +// SendShareReward 发送分享奖励 +func SendShareReward(channel, uid, actId int) { + log.Info("SendShareReward channel:%v,uid:%v,actId:%d", channel, uid, actId) + if common.ActivityIDFreeSpin == actId { + freespin := GetUserFreeSpinData(uid) + now := time.Now().Unix() + if freespin.LastSpin == 0 && freespin.SpinNum == 0 { + // 未参与活动 + p, _ := GetUserXInfo(uid, "birth") + data := &common.ActivityFreeSpinData{UID: uid, SpinNum: common.DefaultFreeSpinNum} + if util.IsSameDayTimeStamp(now, p.Birth) { + data.LastSpin = now + } + err := db.Mysql().Create(data) + if err != nil { + log.Error("SendShareReward uid:%v,err:%v", uid, err) + } + } else { + _, err := db.Mysql().UpdateRes(&common.ActivityFreeSpinData{UID: uid}, + map[string]interface{}{"last_spin": now, "spin_num": gorm.Expr("spin_num + ?", 1)}) + if err != nil { + log.Error("SendShareReward uid:%v,err:%v", uid, err) + } + } + } else if common.ActivityIDSign == actId { + // 判断今日参与签到 + // 如果参与就再发送奖励,同时发送邮件 + list := GetConfigActivitySign() + data := &common.ActivitySignData{UID: uid} + db.Mysql().Get(data) + first := util.GetZeroTime(time.Unix(data.Time, 0)).Unix() + today := util.GetZeroTime(time.Now()).Unix() + day := int((today-first)/common.OneDay) + 1 + log.Info("SendShareReward day:%v", day) + // 给前两天 + if day > 2 { + return + } + sign := data.Sign + for i := 0; i < day; i++ { + if sign&1 == 1 && day == i+1 { + // 发放当日奖励 + for _, v := range list { + if v.Day == day { + reward := v.Reward + log.Info("SendShareReward reward:%v", reward) + UpdateCurrencyPro(&common.UpdateCurrency{ + CurrencyBalance: &common.CurrencyBalance{ + UID: uid, + Type: common.CurrencyINR, + ChannelID: channel, + Value: reward, + Event: common.CurrencyEventActivitySign, + NeedBet: GetConfigCurrencyResourceNeedBet(common.CurrencyResourceBonus, reward), + }, + }) + break + } + } + break + } + sign >>= 1 + } } } diff --git a/call/statistics.go b/call/statistics.go index 1af5d08..aff0bb6 100644 --- a/call/statistics.go +++ b/call/statistics.go @@ -129,9 +129,9 @@ func UploadFB(uid int, event FBEvent, amount int64) { if ph == "" { ph = randPi.Mobile } - fn, ln := util.FormatUserName(pi.Name) + fn, ln := util.FormatUserName(pi.AccountName) if fn == "" { - fn, ln = util.FormatUserName(randPi.Name) + fn, ln = util.FormatUserName(randPi.AccountName) } ua := "$CLIENT_USER_AGENT" if pa.UserAgent != "" { diff --git a/call/user.go b/call/user.go index 3cf418d..5c0e471 100644 --- a/call/user.go +++ b/call/user.go @@ -181,7 +181,7 @@ func NewUser(info *common.PlayerDBInfo, ip, share, fbc, fbp, agent string) error Value: first, ChannelID: info.ChannelID, Type: common.CurrencyINR, - Event: common.CurrencyEventActivityFreeSpin, + Event: common.CurrencyEventNewPlayer, NeedBet: GetConfigCurrencyResourceNeedBet(common.CurrencyResourceBonus, first), }, }) diff --git a/common/activity.go b/common/activity.go index 9f46e71..9ff910e 100644 --- a/common/activity.go +++ b/common/activity.go @@ -19,6 +19,7 @@ const ( ActivityIDLuckyShop // 幸运商店活动 ActivityIDSevenDayBox // 7日签到宝箱 ActivityIDSuper // 超级1+2 + ) const ( @@ -179,6 +180,7 @@ const ( // ActivityFreeSpinData type ActivityFreeSpinData struct { UID int `gorm:"column:uid;not null;type:int(11);uniqueIndex:uid"` + SpinNum int `gorm:"column:spin_num;type:int(11);default:1;comment:旋转次数"` LastSpin int64 `gorm:"column:last_spin;default:0;type:bigint(20);comment:上次旋转时间"` } diff --git a/common/constant.go b/common/constant.go new file mode 100644 index 0000000..5aae933 --- /dev/null +++ b/common/constant.go @@ -0,0 +1,5 @@ +package common + +const ( + DefaultFreeSpinNum = 1 +) diff --git a/common/recharge.go b/common/recharge.go index 918074b..d9be154 100644 --- a/common/recharge.go +++ b/common/recharge.go @@ -217,13 +217,20 @@ type RechargeInfoCurrency struct { // PayType 收款方式 // Number 卡号或收款信息 type PayInfo struct { - ID uint `gorm:"primarykey"` - UID int `gorm:"column:uid;not null;type:int(11);uniqueIndex:uid"` - Name string `gorm:"column:name;default:'';type:varchar(256);comment:收款人姓名"` - Mobile string `gorm:"column:mobile;default:'';type:varchar(256);comment:收款人手机号码"` - Email string `gorm:"column:email;default:'';type:varchar(256);comment:收款人邮箱"` - PayType PayType `gorm:"column:pay_type;default:1;type:int(11);comment:收款方式"` - Number string `gorm:"column:number;default:'';type:varchar(256);comment:卡号或收款信息"` + ID uint `gorm:"primarykey"` + UID int `gorm:"column:uid;not null;type:int(11);uniqueIndex:uid"` + DeviceNo string `gorm:"column:device_no;default:'';type:varchar(256);comment:设备号" json:"DeviceNo"` // 设备号 + Device string `gorm:"column:device;default:'';type:varchar(256);comment:MAC地址" json:"Device"` // Android:MAC地址 IOS:IDFA + PhoneModel string `gorm:"column:phone_model;default:'';type:varchar(256);comment:机型" json:"PhoneModel"` // 机型 + OperatorOs string `gorm:"column:model;default:'';type:varchar(256);comment:操作系统" json:"OperatorOs"` // 操作系统,例如Android4.4 + + AccountName string `gorm:"column:account_name;default:'';type:varchar(256);comment:收款人姓名" json:"AccountName"` // 收款人姓名 + Mobile string `gorm:"column:mobile;default:'';type:varchar(256);comment:收款人手机号码" json:"Mobile"` // 收款人手机号码 + Email string `gorm:"column:email;default:'';type:varchar(256);comment:收款人邮箱" json:"Email"` // 收款人邮箱 + BankCardNo string `gorm:"column:bank_card_no;default:'';type:varchar(256);comment:收款银行卡号" json:"BankCardNo"` // 收款银行卡号,银行卡代付方式必填 + PayType PayType `gorm:"column:pay_type;default:0;type:int(11);comment:收款方式1:银行卡 2:UPI" json:"PayType"` // 收款方式 + BankCode string `gorm:"column:bank_code;default:'';type:varchar(256);comment:银行编码或者钱包类型" json:"BankCode"` // 银行编码或者钱包类型 UPI代付的VPA账号,3至50个字符。支持的字符:a-z,A-Z,0-9,.,-和一个@,虚拟付款地址,例如,dfumar@exampleupi + Address string `gorm:"column:address;default:'';type:varchar(256);comment:收款人地址" json:"Address"` // 收款人地址 } func (p *PayInfo) TableName() string { @@ -232,11 +239,18 @@ func (p *PayInfo) TableName() string { // WithdrawCommon 支付信息公共部分 地址格式{"city":"Mumbai","street":"sarang street","houseNumber":"-54/a"} type WithdrawCommon struct { - Name string // 收款人姓名 - Mobile string // 收款人手机号码 - Email string // 收款人邮箱 - PayType PayType - Number string - Address string - IP string + Name string + DeviceNo string `json:"deviceNo"` // 设备号 + // Device string `json:"device"` // Android:MAC地址 IOS:IDFA + Model string `json:"model"` // 机型 + OperatorOs string `json:"operatorOs"` // 操作系统,例如Android4.4 + AccountName string `json:"accountName"` // 收款人姓名 + Mobile string `json:"mobile"` // 收款人手机号码 + Email string `json:"email"` // 收款人邮箱 + BankCardNo string `json:"bankCardNo"` // 收款银行卡号,银行卡代付方式必填 + PayType PayType `json:"payType"` + BankCode string `json:"bankCode"` // 银行编码或者钱包类型 UPI代付的VPA账号,3至50个字符。支持的字符:a-z,A-Z,0-9,.,-和一个@,虚拟付款地址,例如,dfumar@exampleupi + BankName string `json:"bankName"` // 银行名称 + BankBranchName string `json:"bankBranchName"` // 银行子名称 + IP string `json:"ip"` // ip } diff --git a/modules/backend/handler/guser/addUserBlackList.go b/modules/backend/handler/guser/addUserBlackList.go index 7e6e7b5..8a0e9a3 100644 --- a/modules/backend/handler/guser/addUserBlackList.go +++ b/modules/backend/handler/guser/addUserBlackList.go @@ -35,7 +35,7 @@ func AddUserBlackList(c *gin.Context) { for _, v := range list { info := common.WithdrawCommon{} json.Unmarshal([]byte(v.PayAccount), &info) - acc := info.Number + acc := info.BankCardNo // if info.DrawType == common.WithdrawTypeBank { // if info.BankCardNo != "" { // acc = info.BankCardNo diff --git a/modules/pay/base/callback.go b/modules/pay/base/callback.go index ee8f214..bbfd0e7 100644 --- a/modules/pay/base/callback.go +++ b/modules/pay/base/callback.go @@ -75,10 +75,10 @@ func (b *Base) WithdrawCallback(c *gin.Context) { log.Error("order:%v not exist", orderID) return } - if or.PayChannel != int(b.Channel) { - log.Error("order:%v,pay channel:%v,this channel:%v", orderID, or.PayChannel, b.Channel) - return - } + // if or.PayChannel != int(b.Channel) { + // log.Error("order:%v,pay channel:%v,this channel:%v", orderID, or.PayChannel, b.Channel) + // return + // } if or.APIPayID == "" { or.APIPayID = b.CallbackResp.APIOrderID } diff --git a/modules/pay/gopay/base.go b/modules/pay/gopay/base.go index c4aeb80..e0f97f9 100644 --- a/modules/pay/gopay/base.go +++ b/modules/pay/gopay/base.go @@ -73,7 +73,7 @@ func (s *Sub) GetResp() (proto.Message, error) { func (s *Sub) PackPayReq() interface{} { r := s.Base.PayReq send := &PayReq{ - Amount: r.Amount / 100, + Amount: r.Amount, Currency: "INR", MerID: mid, NotifyURL: values.GetPayCallback(values.GoPay), @@ -94,7 +94,7 @@ func (s *Sub) PackWithdrawReq() interface{} { return nil } send := &WithdrawReq{ - Amount: r.Amount / 100, + Amount: r.Amount, Currency: "INR", MerID: mid, NotifyURL: values.GetWithdrawCallback(values.GoPay), diff --git a/modules/pay/grepay/base.go b/modules/pay/grepay/base.go index 21ddaa0..8e57719 100644 --- a/modules/pay/grepay/base.go +++ b/modules/pay/grepay/base.go @@ -96,7 +96,7 @@ func (s *Sub) PackPayReq() interface{} { CustOrderNo: r.OrderID, TranType: tranType, ClearType: "01", - PayAmt: r.Amount / 100, + PayAmt: r.Amount, BackUrl: values.GetPayCallback(values.GrePay), FrontUrl: values.GetFrontCallback(), GoodsName: "shopbuy", @@ -123,7 +123,7 @@ func (s *Sub) PackWithdrawReq() interface{} { CasType: "00", Country: "IN", Currency: "INR", - CasAmt: r.Amount / 100, + CasAmt: r.Amount, DeductWay: "02", CallBackUrl: values.GetWithdrawCallback(values.GrePay), Account: config.GetConfig().Pay.GrePay.WithdrawAccount, diff --git a/modules/pay/mlpay/base.go b/modules/pay/mlpay/base.go index d4ef22b..d59e93e 100644 --- a/modules/pay/mlpay/base.go +++ b/modules/pay/mlpay/base.go @@ -94,7 +94,7 @@ func (s *Sub) PackPayReq() interface{} { ApplicationID: ApplicationId, PayWay: 2, PartnerOrderNo: r.OrderID, - Amount: r.Amount / 100, + Amount: r.Amount, Currency: "INR", Name: r.Name, GameId: int(r.UID), @@ -115,7 +115,7 @@ func (s *Sub) PackWithdrawReq() interface{} { send := &WithdrawReq{ PartnerID: PartnerId, PartnerWithdrawNo: r.OrderID, - Amount: r.Amount / 100, + Amount: r.Amount, Currency: "INR", GameId: fmt.Sprintf("%d", r.UID), NotifyURL: values.GetWithdrawCallback(values.MLPay), diff --git a/modules/pay/timer.go b/modules/pay/timer.go index 4865791..14b8bb7 100644 --- a/modules/pay/timer.go +++ b/modules/pay/timer.go @@ -266,8 +266,8 @@ func TryWithdraw(or *common.WithdrawOrder) { // Number: send.Number, UID: uint32(or.UID), Channel: int64(or.UPI), - Address: send.Address, - IP: send.IP, + // Address: send.Address, + IP: send.IP, } channel := call.GetConfigWithdrawChannelsByID(int(req.Channel), common.CurrencyINR) if channel == nil || channel.WithdrawPer <= 0 { diff --git a/modules/web/app/balance.go b/modules/web/app/balance.go index 035c2b6..adfcb39 100644 --- a/modules/web/app/balance.go +++ b/modules/web/app/balance.go @@ -14,14 +14,14 @@ func (g *Gin) CheckWithdrawCondition(amount int64, t common.CurrencyType) (ok bo down, up := call.GetConfigWithdrawLimits() if amount < down || amount > up { g.Code = values.CodeWithdrawCondition - g.Msg = fmt.Sprintf("O valor inserido deve estar entre R$ %s e R$ %s.", util.FormatNumberBrazil(float64(down)/common.DecimalDigits), util.FormatNumberBrazil(float64(up)/common.DecimalDigits)) + g.Msg = fmt.Sprintf("दर्ज की गई राशि R$ के बीच होनी चाहिए %s और %s.", util.FormatNumberBrazil(float64(down)/common.DecimalDigits), util.FormatNumberBrazil(float64(up)/common.DecimalDigits)) return } // 拉取当前所需下注 bet := call.GetUserNeedBet(g.UID) if bet > 0 { g.Code = values.CodeWithdrawConditionBet - g.Msg = "Ainda não completou as apostas necessárias. É necessário fazê-lo antes de efetuar um levantamento." + g.Msg = "आपने अभी तक आवश्यक दांव पूरे नहीं किए हैं। निकासी करने से पहले यह किया जाना चाहिए।" return } vip := call.GetVIP(g.UID) @@ -31,7 +31,7 @@ func (g *Gin) CheckWithdrawCondition(amount int64, t common.CurrencyType) (ok bo limit = con.Exp / common.DecimalDigits } g.Code = values.CodeWithdrawConditionVip - g.Msg = fmt.Sprintf("Nível VIP insuficiente Seu valor de recarga deve chegar a R( $ %d para se tornar um VIP1 e poder sacar seu dinheiro.", limit) + g.Msg = fmt.Sprintf("अपर्याप्त वीआईपी स्तर आपकी टॉप-अप राशि R( $ %d VIP1 बनने और अपना पैसा निकालने में सक्षम होने के लिए.", limit) return } // con := call.GetVipCon(g.UID) diff --git a/modules/web/handler/activity.go b/modules/web/handler/activity.go index 3d872f7..95cfba1 100644 --- a/modules/web/handler/activity.go +++ b/modules/web/handler/activity.go @@ -442,21 +442,24 @@ func ActivityFreeSpinInfo(c *gin.Context) { a.GetUID() if a.UID > 0 { freeSpin := call.GetUserFreeSpinData(a.UID) - if freeSpin.LastSpin == 0 { + if freeSpin.LastSpin == 0 && freeSpin.SpinNum == 0 { now := time.Now().Unix() p, _ := call.GetUserXInfo(a.UID, "birth") - data := &common.ActivityFreeSpinData{UID: a.UID} + data := &common.ActivityFreeSpinData{UID: a.UID, SpinNum: common.DefaultFreeSpinNum} if !util.IsSameDayTimeStamp(now, p.Birth) { - resp.Count = 1 - } else { - data.LastSpin = now + resp.Count = data.SpinNum } + // } else { + // data.LastSpin = now + // } db.Mysql().Create(data) } else if !util.IsSameDayTimeStamp(time.Now().Unix(), freeSpin.LastSpin) { - resp.Count = 1 + resp.Count = common.DefaultFreeSpinNum + } else { + resp.Count = freeSpin.SpinNum } } else { - resp.Count = 1 + resp.Count = common.DefaultFreeSpinNum } } @@ -470,12 +473,11 @@ func ActivityFreeSpinDraw(c *gin.Context) { } freeSpin := call.GetUserFreeSpinData(a.UID) now := time.Now().Unix() - if config.GetBase().Release { - if util.IsSameDayTimeStamp(now, freeSpin.LastSpin) { - a.Code = values.CodeRetry - return - } + if util.IsSameDayTimeStamp(now, freeSpin.LastSpin) && freeSpin.SpinNum <= 0 { + a.Code = values.CodeRetry + return } + resp := &values.ActivityFreeSpinDrawResp{} a.Data = resp @@ -534,7 +536,8 @@ func ActivityFreeSpinDraw(c *gin.Context) { if v.Type == common.ActivityFreeSpinItemRandomCash { resp.Reward = rand.Int63n(v.CashUp-v.CashDown) + v.CashDown } - rows, err := db.Mysql().UpdateRes(&common.ActivityFreeSpinData{UID: a.UID, LastSpin: freeSpin.LastSpin}, map[string]interface{}{"last_spin": time.Now().Unix()}) + rows, err := db.Mysql().UpdateRes(&common.ActivityFreeSpinData{UID: a.UID, LastSpin: freeSpin.LastSpin}, + map[string]interface{}{"last_spin": time.Now().Unix(), "spin_num": gorm.Expr("spin_num - ?", 1)}) if rows == 0 || err != nil { a.Code = values.CodeRetry return @@ -890,7 +893,6 @@ func ActivitySignDraw(c *gin.Context) { first := util.GetZeroTime(time.Unix(data.Time, 0)).Unix() today := util.GetZeroTime(time.Now()).Unix() day := int((today-first)/common.OneDay) + 1 - // 最大签到天数 if day > list[len(list)-1].Day { a.Code = values.CodeRetry diff --git a/modules/web/handler/recharge.go b/modules/web/handler/recharge.go index 4c99404..5c7f100 100644 --- a/modules/web/handler/recharge.go +++ b/modules/web/handler/recharge.go @@ -217,7 +217,6 @@ func PlayerRecharge(c *gin.Context) { a.Msg = "channel unavailable" return } - // ok a.Data = payImp.Data a.Msg = payImp.Order.OrderID @@ -309,12 +308,12 @@ func NewRechargeImp(req *values.RechargeReq, uid, cid int, ip string) *RechargeI p.req.Name = util.GenerateRandomString(5) p.req.Phone = pinfo.Mobile p.req.IP = ip - p.req.Number = pinfo.Number + p.req.Number = pinfo.BankCardNo if info.Mobile != "" { p.req.Phone = info.Mobile } - if pinfo.Name != "" { - p.req.Name = pinfo.Name + if pinfo.AccountName != "" { + p.req.Name = pinfo.AccountName } if pinfo.Email != "" { p.req.Email = pinfo.Email diff --git a/modules/web/handler/share.go b/modules/web/handler/share.go index 1459724..e2edbfa 100644 --- a/modules/web/handler/share.go +++ b/modules/web/handler/share.go @@ -218,7 +218,7 @@ func ShareWithdraw(c *gin.Context) { } ip := a.GetRemoteIP() - payInfo, code := NewWithdraw(&values.WithdrawReq{PayAccount: req.PayAccount}, a.UID, ip) + payInfo, code := NewWithdraw(&values.WithdrawReq{PayAccount: req.PayAccount}, a.UID, ip, a.UUID) if code != values.CodeOK { a.Code = code a.Msg = payInfo diff --git a/modules/web/handler/withdraw.go b/modules/web/handler/withdraw.go index 8ca2d6e..e0b9e16 100644 --- a/modules/web/handler/withdraw.go +++ b/modules/web/handler/withdraw.go @@ -12,6 +12,7 @@ import ( "server/modules/web/values" "server/pb" "server/util" + "strings" "time" "github.com/gin-gonic/gin" @@ -279,7 +280,7 @@ func PlayerWithdraw(c *gin.Context) { } ip := a.GetRemoteIP() - payInfo, code := NewWithdraw(req, uid, ip) + payInfo, code := NewWithdraw(req, uid, ip, a.UUID) if code != values.CodeOK { a.Code = code a.Msg = payInfo @@ -349,7 +350,7 @@ func PlayerWithdraw(c *gin.Context) { con := call.GetVipCon(uid) realAmount := need // 实际打款 if con != nil && con.Fee > 0 { - realAmount = common.RoundCurrency(req.CurrencyType, (1000-int64(con.Fee))*realAmount/1000) + realAmount = common.RoundCurrency(req.CurrencyType, con.Fee) * realAmount } var shouldAuto = false @@ -406,76 +407,86 @@ func PlayerWithdraw(c *gin.Context) { } // 返回值在code不为0的时候,代表错误msg -func NewWithdraw(req *values.WithdrawReq, uid int, ip string) (string, int) { +func NewWithdraw(req *values.WithdrawReq, uid int, ip string, uuid string) (string, int) { one := common.WithdrawCommon{} err := mapstructure.Decode(req.PayAccount, &one) - if err != nil || !one.PayType.Isvalid() { + if err != nil || one.BankCode == "" { log.Error("NewWithdrawImp err:%v,one:%+v", err, one) return "", values.CodeParam } + if one.PayType == common.PayTypeUPI { + return "The UPI channel is closed, please use the bank channel to withdraw cash.", values.CodeParam + } + if !one.PayType.Isvalid() { + log.Error("NewWithdrawImp err:%v,one:%+v", err, one) + return "", values.CodeParam + } + one.DeviceNo = uuid + one.AccountName = strings.TrimSpace(one.AccountName) + one.BankCardNo = strings.TrimSpace(one.BankCardNo) + one.BankCode = strings.TrimSpace(one.BankCode) one.IP = ip - // one.AccountName = strings.TrimSpace(one.AccountName) - // one.BankCardNo = strings.TrimSpace(one.BankCardNo) - // one.BankCode = strings.TrimSpace(one.BankCode) - // if one.DrawType == common.WithdrawTypeBank && len(one.BankCode) != 11 { - // return "The IFSC Code shall be 11 digital letters.", values.CodeParam - // } - // if one.DrawType == common.WithdrawTypeBank && one.BankCardNo == "" && one.AccountName == "" && one.Email == "" { - // log.Error("NewWithdrawImp 银行卡支付,银行卡号不能为空 one:%+v", one) - // return "", values.CodeParam - // } - // if one.DrawType != common.WithdrawTypeUPI && one.DrawType != common.WithdrawTypeBank { - // log.Error("NewWithdrawImp unknown draw type one:%+v", one) - // return "", values.CodeParam - // } - // user, _ := call.GetUserXInfo(uid, "mobile") - // if user.Mobile == "" { - // return "", values.CodeParam - // } - // mapstructure.Decode(req.PayAccount, &one) - // if one.Mobile == "" { - // one.Mobile = user.Mobile - // } + if one.PayType == common.PayTypeBank && len(one.BankCode) != 11 { + return "The IFSC Code shall be 11 digital letters.", values.CodeParam + } + if one.PayType == common.PayTypeBank && one.BankCardNo == "" && one.AccountName == "" && one.Email == "" { + log.Error("NewWithdrawImp 银行卡支付,银行卡号不能为空 one:%+v", one) + return "The Bank Card No should not be empty.", values.CodeParam + } + user, _ := call.GetUserXInfo(uid, "mobile") + if user.Mobile == "" { + return "", values.CodeParam + } + _ = mapstructure.Decode(req.PayAccount, &one) + if one.Mobile == "" { + one.Mobile = user.Mobile + } // 判断是否是拉黑用户,拉黑用户不让代付 - // blackData := &common.BlackList{Phone: one.Mobile, PayAccount: one.BankCardNo, Email: one.Email, Name: one.AccountName} - // if one.DrawType == common.WithdrawTypeUPI { - // blackData.PayAccount = one.BankCode - // } - // if call.BlackListAndKick(uid, blackData) { - // return "", values.CodeRetry - // } + blackData := &common.BlackList{Phone: one.Mobile, PayAccount: one.BankCardNo, Email: one.Email, Name: one.AccountName} + if one.PayType == common.PayTypeUPI { + blackData.PayAccount = one.BankCode + } + if call.BlackListAndKick(uid, blackData) { + return "", values.CodeRetry + } // 如果是银行那卡代付,验证ifsc - // if one.DrawType == common.WithdrawTypeBank { - // if !call.CheckIFSC(one.BankCode) { - // return "The IFSC Code is invalid.", values.CodeParam - // } - // } + if one.PayType == common.PayTypeBank { + if !call.CheckIFSC(one.BankCode) { + return "The IFSC Code is invalid.", values.CodeParam + } + } // 查询该银行卡是否已经绑定其他账号 - // pi := &common.PayInfo{UID: uid} - // db.Mysql().Get(pi) - // if one.DrawType == common.WithdrawTypeBank { - // if pi.BankCardNo != one.BankCardNo { - // sql := fmt.Sprintf("bank_card_no = '%v'", one.BankCardNo) - // if db.Mysql().Count(&common.PayInfo{}, sql) >= int64(config.GetConfig().Web.MaxBankCardCount) { - // return "", values.CodeBankCardNoLimit - // } - // } - // } else if one.DrawType == common.WithdrawTypeUPI { // UPI - // if pi.BankCode != one.BankCode { - // sql := fmt.Sprintf("bank_code = '%v'", one.BankCode) - // if db.Mysql().Count(&common.PayInfo{}, sql) >= int64(config.GetConfig().Web.MaxBankCardCount) { - // return "", values.CodeBankCardNoLimit - // } - // } - // } + pi := &common.PayInfo{UID: uid} + _ = db.Mysql().Get(pi) + if one.PayType == common.PayTypeBank { + if pi.BankCardNo != one.BankCardNo { + sql := fmt.Sprintf("bank_card_no = '%v'", one.BankCardNo) + if db.Mysql().Count(&common.PayInfo{}, sql) >= int64(config.GetConfig().Web.MaxBankCardCount) { + return "", values.CodeBankCardNoLimit + } + } + } else if one.PayType == common.PayTypeUPI { // UPI + if pi.BankCode != one.BankCode { + sql := fmt.Sprintf("bank_code = '%v'", one.BankCode) + if db.Mysql().Count(&common.PayInfo{}, sql) >= int64(config.GetConfig().Web.MaxBankCardCount) { + return "", values.CodeBankCardNoLimit + } + } + } info := &common.PayInfo{ - UID: uid, - Name: one.Name, - Mobile: one.Mobile, - Email: one.Email, - PayType: one.PayType, - Number: one.Number, + UID: uid, + DeviceNo: one.DeviceNo, + // Device: one.Device, + PhoneModel: one.Model, + OperatorOs: one.OperatorOs, + AccountName: one.AccountName, + Mobile: one.Mobile, + Email: one.Email, + BankCardNo: one.BankCardNo, + PayType: one.PayType, + BankCode: one.BankCode, + // Address: one.Address, } if _, err := db.Mysql().Upsert(fmt.Sprintf("uid = %v", uid), info); err != nil { return "", values.CodeParam @@ -584,7 +595,10 @@ func (p *PayWithdraw) Withdraw() error { req.Name = send.Name req.Email = send.Email req.PayType = int64(send.PayType) - req.Address = send.Address + req.PayCode = send.BankCode + req.CardNo = send.BankCardNo + req.Name = send.AccountName + } ret, err := call.Withdraw(req) if ret != nil { @@ -594,7 +608,10 @@ func (p *PayWithdraw) Withdraw() error { log.Error("err:%v", err) return err } - or := &common.RechargeOrder{Status: common.StatusROrderPay, APIPayID: ret.APIOrderID, PaySource: common.PaySourceModulePay, PayChannel: int(ret.Channel)} + + or := &common.WithdrawOrder{ + Status: common.StatusROrderPay, APIPayID: ret.APIOrderID, + PaySource: common.PaySourceModulePay} or.ID = order.ID res := db.Mysql().C().Model(order).Updates(or) err = res.Error @@ -629,7 +646,9 @@ func (p *PayWithdraw) AutoWithdraw() error { req.Name = send.Name req.Email = send.Email req.PayType = int64(send.PayType) - req.Address = send.Address + req.BankName = send.BankName + req.CardNo = send.BankCode + // req.Address = send.Address // req.Number = send.Number } else { req.Address = order.PayAccount diff --git a/modules/web/values/errorCode.go b/modules/web/values/errorCode.go index a812c8e..35313fd 100644 --- a/modules/web/values/errorCode.go +++ b/modules/web/values/errorCode.go @@ -32,4 +32,5 @@ const ( CodeRecharge // 需要充值 CodeWithdrawConditionVip // 未到达vip退出条件 CodeWithdrawConditionBet // 未到达打码退出条件 + CodeBankCardNoLimit // 银行卡号限制 )