From a61dde85f5183155950bda6217faebb626762feb Mon Sep 17 00:00:00 2001 From: zhora Date: Mon, 13 Oct 2025 17:32:11 +0800 Subject: [PATCH] =?UTF-8?q?ea=E6=94=AF=E4=BB=98;=E4=BC=98=E6=83=A0?= =?UTF-8?q?=E5=88=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- call/item.go | 4 ++-- call/mail.go | 1 + call/pay.go | 4 ++-- common/activity.go | 10 +++++++--- common/player.go | 4 ++-- modules/pay/eanipay/base.go | 2 -- modules/pay/moonpay2/base.go | 2 -- modules/web/handler/recharge.go | 20 ++++++++++++-------- modules/web/values/pay.go | 20 ++++++++++---------- 9 files changed, 36 insertions(+), 31 deletions(-) diff --git a/call/item.go b/call/item.go index 05d028b..8b8edd1 100644 --- a/call/item.go +++ b/call/item.go @@ -15,8 +15,8 @@ func GetUserItem(uid, itemID int) []*common.PlayerItems { return list } -func GetItem(id int) *common.PlayerItems { - list := &common.PlayerItems{ID: id, Status: common.ItemStatusNormal} +func GetItem(id, uid int) *common.PlayerItems { + list := &common.PlayerItems{ID: id, UID: uid, Status: common.ItemStatusNormal} db.Mysql().Get(&list) return list } diff --git a/call/mail.go b/call/mail.go index 2249a97..075f6bc 100644 --- a/call/mail.go +++ b/call/mail.go @@ -99,6 +99,7 @@ func SendMailWithContent(uid int, title, content string) { Receiver: uid, Title: title, Content: content, + Tag: 1, Time: time.Now().Unix(), } db.Mysql().Create(one) diff --git a/call/pay.go b/call/pay.go index 810a73d..e8045d2 100644 --- a/call/pay.go +++ b/call/pay.go @@ -302,10 +302,10 @@ func RechargeCallback(r *common.RechargeOrder, success bool, payAccount, extra s if bonus > 0 { UploadActivityData(uid, common.ActivityIDRecharge, common.ActivityDataJoin, bonus) } - if r.ProductID == 0 { + if r.ActivityID == 0 { ticket := GetConfigDiscountTicketByAmount(discountOriginAmount) - log.Info("ticket:%v", ticket) if ticket.ID > 0 { + log.Info("ticket:%v", ticket) // 赠送优惠券 tickets := GetConfigDiscountTicket() sort.Slice(tickets, func(i, j int) bool { diff --git a/common/activity.go b/common/activity.go index 3b9ae3d..08fd1fe 100644 --- a/common/activity.go +++ b/common/activity.go @@ -531,11 +531,15 @@ func (m *ConfigActivityPopup) TableName() string { } type ConfigDiscountTicket struct { - ID int `gorm:"column:id;type:int(11) AUTO_INCREMENT;primary_key" json:"id"` + ID int `gorm:"column:id;type:int(11) AUTO_INCREMENT;primary_key" json:"id"` + // 充值额度(单位分) RechargeAmount int64 `gorm:"column:recharge_amount;type:bigint(20)" web:"recharge_amount"` + // 满减金额(单位分) DiscountAmount int64 `gorm:"column:discount_amount;type:bigint(20)" web:"discount_amount"` - CurProb int `gorm:"column:cur_prob;type:int(11)" web:"cur_prob"` - NextProb int `gorm:"column:next_prob;type:int(11)" web:"next_prob"` + // 本档位概率 + CurProb int `gorm:"column:cur_prob;type:int(11)" web:"cur_prob"` + // 向上档位概率 + NextProb int `gorm:"column:next_prob;type:int(11)" web:"next_prob"` } func (m *ConfigDiscountTicket) TableName() string { diff --git a/common/player.go b/common/player.go index ce95fd7..a7945f6 100644 --- a/common/player.go +++ b/common/player.go @@ -178,8 +178,8 @@ type PlayerItems struct { ItemID int `gorm:"column:item_id;default:0;comment:物品id"` Time int64 `gorm:"column:time;type:bigint(20);default:0;comment:获得的时间"` Status int `gorm:"column:status;type:int(11);default:0;comment:物品状态"` - Exi1 int64 `gorm:"column:exi1;type:bigint(20);default:0;comment:物品标识字段1"` - Exi2 int64 `gorm:"column:exi2;type:bigint(20);default:0;comment:物品标识字段2"` + Exi1 int64 `gorm:"column:exi1;type:bigint(20);default:0;comment:物品标识字段1"` // 优惠金额 + Exi2 int64 `gorm:"column:exi2;type:bigint(20);default:0;comment:物品标识字段2"` // 额度 Exi3 int64 `gorm:"column:exi3;type:bigint(20);default:0;comment:物品标识字段3"` } diff --git a/modules/pay/eanipay/base.go b/modules/pay/eanipay/base.go index ec532e8..e854726 100644 --- a/modules/pay/eanipay/base.go +++ b/modules/pay/eanipay/base.go @@ -97,7 +97,6 @@ func (s *Sub) GetResp() (proto.Message, error) { func (s *Sub) PackPayReq() interface{} { r := s.Base.PayReq - r.Amount /= 100 if len(r.Phone) == 12 { r.Phone = r.Phone[2:] } @@ -122,7 +121,6 @@ func (s *Sub) PackPayReq() interface{} { func (s *Sub) PackWithdrawReq() interface{} { r := s.Base.WithdrawReq - r.Amount /= 100 if len(r.Phone) == 12 { r.Phone = r.Phone[2:] } diff --git a/modules/pay/moonpay2/base.go b/modules/pay/moonpay2/base.go index 867b828..eb2ead4 100644 --- a/modules/pay/moonpay2/base.go +++ b/modules/pay/moonpay2/base.go @@ -142,7 +142,6 @@ func (s *Sub) PackPayReq() interface{} { if len(r.Phone) == 12 { r.Phone = r.Phone[2:] } - r.Amount /= 100 send := &PayReq{ MerchantID: mid, OrderNumber: r.OrderID, @@ -162,7 +161,6 @@ func (s *Sub) PackWithdrawReq() interface{} { if len(r.Phone) == 12 { r.Phone = r.Phone[2:] } - r.Amount /= 100 send := &WithdrawReq{ MerchantID: mid, OrderNumber: r.OrderID, diff --git a/modules/web/handler/recharge.go b/modules/web/handler/recharge.go index 59c5f95..1ab6495 100644 --- a/modules/web/handler/recharge.go +++ b/modules/web/handler/recharge.go @@ -151,11 +151,15 @@ func RechargeInfo(c *gin.Context) { }) continue } + if v.Time == -1 { + diff = 0 + } resp.DiscountTicket = append(resp.DiscountTicket, &values.DiscountTicket{ - Id: v.ID, - Discount: v.Exi1, - TimeLeft: v.Time, - Amount: v.Exi2, + Id: v.ID, + Discount: v.Exi1, + TimeLeftAt: v.Time, + TimeLeft: diff, + Amount: v.Exi2, }) } } @@ -329,11 +333,10 @@ func NewRechargeImp(req *values.RechargeReq, uid, cid int, ip string) *RechargeI } } } - // 只有商城购买才能使用优惠券 - // todo activityId为0才是商城购买 - if req.ProductID == 0 && req.DiscountTicketId > 0 { + // 使用了优惠券 + if req.DiscountTicketId > 0 { // 判断是否有折扣券 - ticket := call.GetItem(req.DiscountTicketId) + ticket := call.GetItem(req.DiscountTicketId, uid) if ticket != nil && req.Amount >= ticket.Exi2 { ticketData := common.ActivityRechargeData{ID: common.ItemDiscountTicket, I1: int(ticket.Exi1), I2: req.Amount} ticketByte, _ := json.Marshal(ticketData) @@ -346,6 +349,7 @@ func NewRechargeImp(req *values.RechargeReq, uid, cid int, ip string) *RechargeI //notCharge := re.TotalRecharge == 0 //per := call.GetConfigFirstPayPerByAmount(notCharge, order.Amount) var times int + // todo bonus赠送 且 非活动 if req.Bonus && req.ActivityID == 0 { buyCount, per, topThree := call.GetConfigFirstPayByCount(order.UID, order.Amount, re.BuyAmountDataMap) if per > 0 { diff --git a/modules/web/values/pay.go b/modules/web/values/pay.go index 30d0b58..2129912 100644 --- a/modules/web/values/pay.go +++ b/modules/web/values/pay.go @@ -44,10 +44,11 @@ type RechargeInfoFirstResp struct { } type DiscountTicket struct { - Id int - Discount int64 - TimeLeft int64 - Amount int64 + Id int + Discount int64 // 优惠额度 + TimeLeftAt int64 // 过期时间 + TimeLeft int64 // 过期时间 + Amount int64 // 充值挡位 } // RechargeReq 充值请求 地址格式为:{"city":"Mumbai","street":"sarang street","houseNumber":"-54/a"} @@ -55,12 +56,11 @@ type RechargeReq struct { CurrencyType common.CurrencyType `json:"CurrencyType"` PayChannel int `json:"PayChannel"` - DiscountTicketId int `json:"DiscountTicketId"` // 折扣券ID - - Amount int64 `json:"amount"` - Bonus bool `json:"bonus"` - ProductID int `json:"productId"` - ActivityID int `json:"activityID"` + Amount int64 `json:"amount"` + Bonus bool `json:"bonus"` + ProductID int `json:"productId"` + ActivityID int `json:"activityID"` + DiscountTicketId int `json:"discountTicketId"` // 折扣券ID UserName *string `json:"userName"` // 用户姓名 UserPhone string `json:"userPhone"` // 用户手机号