Compare commits

...

3 Commits

Author SHA1 Message Date
mofangmin 241fdacda0 优惠券通知 1 year ago
mofangmin 452911d4a9 优惠券接口 1 year ago
mofangmin 38f930ad38 优惠券 1 year ago
  1. 24
      call/config.go
  2. 17
      call/item.go
  3. 19
      call/mail.go
  4. 117
      call/pay.go
  5. 10
      call/reload.go
  6. 3
      call/share.go
  7. 3
      cmd/build.sh
  8. 14
      common/activity.go
  9. 1
      common/config.go
  10. 1
      common/currency.go
  11. 2
      modules/backend/handler/examine/examine.go
  12. 4
      modules/backend/handler/statistics/reviewAppSummary.go
  13. 6
      modules/backend/handler/statistics/reviewData.go
  14. 3
      modules/pay/base/callback.go
  15. 64
      modules/web/handler/activity.go
  16. 2
      modules/web/handler/mail.go
  17. 61
      modules/web/handler/recharge.go
  18. 1
      modules/web/handler/share.go
  19. 2
      modules/web/routers/routers_activity.go
  20. 12
      modules/web/values/activity.go
  21. 14
      modules/web/values/pay.go
  22. 16
      pb/proto/platform.proto

@ -64,6 +64,7 @@ var (
configTgRobot []*common.ConfigTgRobot
configBetDraw []*common.ConfigActivityBetDraw
configActivityPopup []*common.ConfigActivityPopup
configDiscountTicket []common.ConfigDiscountTicket
// 客服
configCustomerRobot []*common.ConfigCustomerRobot
customerOrderLabel []*common.CustomerOrderLabel
@ -1558,3 +1559,26 @@ func GetConfigActivityPopupByType(jumpType int) []*common.ConfigActivityPopup {
}
return ret
}
func LoadConfigDiscountTicket() (err error) {
var list []common.ConfigDiscountTicket
if _, err = db.Mysql().QueryAll("", "", &common.ConfigDiscountTicket{}, &list); err != nil {
log.Error("err:%v", err)
return err
}
configDiscountTicket = list
return nil
}
func GetConfigDiscountTicket() []common.ConfigDiscountTicket {
return configDiscountTicket
}
func GetConfigDiscountTicketByAmount(amount int64) common.ConfigDiscountTicket {
for _, item := range configDiscountTicket {
if item.RechargeAmount == amount {
return item
}
}
return common.ConfigDiscountTicket{}
}

@ -4,7 +4,9 @@ import (
"fmt"
"server/common"
"server/db"
"time"
"server/pb"
"github.com/liangdas/mqant/log"
)
func GetUserItem(uid, itemID int) []*common.PlayerItems {
@ -13,6 +15,11 @@ func GetUserItem(uid, itemID int) []*common.PlayerItems {
return list
}
func GetItem(id int) *common.PlayerItems {
list := &common.PlayerItems{ID: id, Status: common.ItemStatusNormal}
db.Mysql().Get(&list)
return list
}
func GetUserValidItems(uid, itemID int) []*common.PlayerItems {
list := []*common.PlayerItems{}
db.Mysql().QueryAll(fmt.Sprintf("uid = %d and item_id = %d and status = %d", uid, itemID, common.ItemStatusNormal), "", &common.PlayerItems{}, &list)
@ -35,6 +42,10 @@ func GetUserBestDiscountTicket(uid int) *common.PlayerItems {
return nil
}
func AddUserDiscountTicket(uid int, exi1, exi2 int64) {
db.Mysql().Create(&common.PlayerItems{UID: uid, ItemID: common.ItemDiscountTicket, Time: time.Now().Unix(), Status: common.ItemStatusNormal, Exi1: exi1, Exi2: exi2})
func AddUserDiscountTicket(uid int, exi1, exi2, t int64) {
err := db.Mysql().Create(&common.PlayerItems{UID: uid, ItemID: common.ItemDiscountTicket, Time: t, Status: common.ItemStatusNormal, Exi1: exi1, Exi2: exi2})
if err != nil {
log.Error("AddUserDiscountTicket err:%v", err)
}
SendNR(uid, int(pb.ServerCommonResp_CommonDisCountTicketResp), &pb.DiscountTicketNotify{Discount: exi1, Amount: exi2}, "common")
}

@ -10,6 +10,14 @@ import (
"gorm.io/gorm"
)
var (
SystemTitle = "System Notice"
EmailWithdrawPass = "Your order %v, amount: $%v is in the payment status, please be patient."
EmailWithdrawSuccess = "Your order %v, amount: $%v has been credited, please check. If you have any questions, you can contact customer service."
EmailWithdrawFail = "Your order %v, Amount: $%v\nYour withdrawal failed due to incorrect information. Please verify or change your withdrawal details and resubmit"
EmailDiscount = "Congratulations, you have received a $%v coupon for a top-up of $%v or more."
)
func checkMail(uid int, red *common.PlayerRed) {
data := &common.PlayerData{UID: uid}
db.Mysql().Get(data)
@ -59,6 +67,17 @@ func SendWithdrawMail(uid int, contentType string) {
UpsertRedPointAndNotify(uid, 1, ModuleMail)
}
func SendMailWithContent(uid int, title, content string) {
one := &common.Mail{
Sender: "System",
Receiver: uid,
Title: title,
Content: content,
Time: time.Now().Unix(),
}
db.Mysql().Create(one)
UpsertRedPointAndNotify(uid, 1, ModuleMail)
}
func SendMail(mail *common.Mail) {
db.Mysql().Create(mail)
UpsertRedPointAndNotify(mail.Receiver, 1, ModuleMail)

@ -6,6 +6,7 @@ import (
"errors"
"fmt"
"io/ioutil"
"math/rand"
"net/http"
"server/common"
"server/config"
@ -13,6 +14,7 @@ import (
"server/natsClient"
"server/pb"
"server/util"
"sort"
"time"
"github.com/gogo/protobuf/proto"
@ -39,7 +41,7 @@ func GetRechargeInfo(uid int) *common.RechargeInfo {
// Recharge 内部充值调用
func Recharge(data *pb.InnerRechargeReq) (*pb.InnerRechargeResp, error) {
to, cancel := context.WithTimeout(context.Background(), 5*time.Second)
to, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
module := "pay"
if data.PaySource == common.PaySourceBlockPay {
@ -99,11 +101,6 @@ func RechargeCallback(r *common.RechargeOrder, success bool, payAccount, extra s
log.Error("get recharage info err:%v,uid:%v", err, r.UID)
return err
}
// product := GetConfigPayProductByID(r.ProductID)
// if product == nil {
// log.Error("unkonwn product:%d", r.ProductID)
// return errors.New("unkonwn product")
// }
amount := r.Amount
notCharge := re.TotalRecharge == 0
@ -115,31 +112,9 @@ func RechargeCallback(r *common.RechargeOrder, success bool, payAccount, extra s
dayR = true
re.DayRecharge += amount
}
// if util.IsSameWeek(re.LastRecharge, now) || re.LastRecharge == 0 {
// weekR = true
// re.WeekRecharge += amount
// }
re.LastRecharge = now
re.TotalRechargeCount++
// re.ProductPayCount = common.AddProductPayCount(re.ProductPayCount, r.ProductID)
// if product.IsFirstPayProduct() {
// json.Unmarshal([]byte(re.ProductFirstPay), &re.ProductFirstPaySub)
// if util.SliceContain(re.ProductFirstPaySub, product.ProductID) { // 该商品已购买,替换为可多次购买的同价值商品
// product = GetConfigPayProductShopByAmount(product.Amount)
// if product == nil {
// return errors.New("product invalid")
// }
// } else {
// re.ProductFirstPaySub = append(re.ProductFirstPaySub, int(product.ProductID))
// str, _ := json.Marshal(re.ProductFirstPaySub)
// re.ProductFirstPay = string(str)
// }
// }
// var per int64 = 0
// level := GetConfigFirstPayLevelByAmount(r.Amount)
// playerPayData := GetPlayerPayData(uid)
tx := db.Mysql().Begin()
defer func() {
if err == nil {
@ -165,27 +140,6 @@ func RechargeCallback(r *common.RechargeOrder, success bool, payAccount, extra s
return nil
}
// 更新paydata
// if playerPayData.ID == 0 {
// err = tx.Model(playerPayData).Create(playerPayData).Error
// if err != nil {
// log.Error("err:%v", err)
// return
// }
// } else {
// playerPayData.SubFirstPay = append(playerPayData.SubFirstPay, level)
// updatePayData, _ := json.Marshal(playerPayData.SubFirstPay)
// res := tx.Model(playerPayData).Where("id = ? and first_pay = ?", playerPayData.ID, playerPayData.FirstPay).Updates(map[string]interface{}{"first_pay": string(updatePayData)})
// if res.RowsAffected == 0 {
// log.Error("err:%v", err)
// return errors.New("update payData fail")
// }
// if err != nil {
// log.Error("update payData err:%v", err)
// return err
// }
// }
// 第二步,更新recharge_info
payData := &common.ESPlayerPayData{UID: uid, Channel: r.ChannelID, Type: 1, CurrencyType: r.CurrencyType}
if re.ID == 0 {
@ -204,19 +158,13 @@ func RechargeCallback(r *common.RechargeOrder, success bool, payAccount, extra s
"total_recharge_count": gorm.Expr("total_recharge_count + 1"),
"total_recharge": gorm.Expr("total_recharge + ?", amount),
"last_recharge": now,
// "product_paycount": re.ProductPayCount,
// "product_firstpay": re.ProductFirstPay,
}
if dayR {
updates["day_recharge"] = gorm.Expr("day_recharge + ?", amount)
} else {
updates["day_recharge"] = amount
}
// if weekR {
// updates["week_recharge"] = gorm.Expr("week_recharge + ?", amount)
// } else {
// updates["week_recharge"] = amount
// }
err = tx.Model(re).Where("uid=?", re.UID).Updates(updates).Error
}
if err != nil {
@ -226,32 +174,14 @@ func RechargeCallback(r *common.RechargeOrder, success bool, payAccount, extra s
// 第三步,给玩家发货
// 正常商城充值
var bonus = r.Bonus
discountOriginAmount := r.Amount // 折扣前的价格
if r.ProductID == 0 {
amount := PayExtra(r) // 判断特殊购买,如优惠券
if amount == 0 {
amount = r.Amount
} else {
discountOriginAmount = amount
}
// cb := &common.CurrencyBalance{
// UID: r.UID,
// Type: r.CurrencyType,
// Value: amount,
// Event: common.CurrencyEvent(r.Event),
// Exs1: r.OrderID,
// Exi1: int(amount), // 充值金额传递
// Exi2: r.ProductID,
// NeedBet: GetConfigCurrencyResourceNeedBet(common.CurrencyResourceRecharge, amount),
// }
// err = UpdateCurrencyProReal(&common.UpdateCurrency{
// CurrencyBalance: cb,
// }).Err
// if err != nil {
// return
// }
// } else {
// per := GetConfigFirstPayPerByAmount(notCharge, amount)
// if per > 0 {
// bonus = amount * per / 100
// }
t := common.CurrencyResourceRecharge
if notCharge && bonus > 0 { // 首充
t = common.CurrencyResourceFirstRecharge
@ -286,6 +216,39 @@ func RechargeCallback(r *common.RechargeOrder, success bool, payAccount, extra s
if bonus > 0 {
UploadActivityData(uid, common.ActivityIDRecharge, common.ActivityDataJoin, bonus)
}
if r.ProductID == 0 {
ticket := GetConfigDiscountTicketByAmount(discountOriginAmount)
log.Info("ticket:%v", ticket)
if ticket.Id > 0 {
// 赠送优惠券
tickets := GetConfigDiscountTicket()
sort.Slice(tickets, func(i, j int) bool {
return tickets[i].RechargeAmount < tickets[j].RechargeAmount
})
// 获取下一档
nextIdx := -1
for idx, product := range tickets {
if product.RechargeAmount == discountOriginAmount {
nextIdx = idx + 1
}
}
var nextTicket = ticket
if len(tickets) > nextIdx && nextIdx != -1 {
nextTicket = tickets[nextIdx]
}
log.Info("nextTicket:%v", nextTicket)
count := ticket.CurProb + ticket.NextProb
val := rand.Intn(count)
log.Info("val:%v", val)
if val <= ticket.CurProb {
AddUserDiscountTicket(uid, ticket.DiscountAmount, ticket.RechargeAmount, -1)
SendMailWithContent(uid, SystemTitle, fmt.Sprintf(EmailDiscount, ticket.RechargeAmount/common.DecimalDigits, ticket.DiscountAmount/common.DecimalDigits))
} else if nextTicket.Id > 0 {
AddUserDiscountTicket(uid, ticket.DiscountAmount, ticket.RechargeAmount, -1)
SendMailWithContent(uid, SystemTitle, fmt.Sprintf(EmailDiscount, ticket.RechargeAmount/common.DecimalDigits, ticket.DiscountAmount/common.DecimalDigits))
}
}
}
user, _ := GetUserInfo(uid)
PayActivity(r, notCharge, user)
if r.Event != int(common.CurrencyEventGMRecharge) {

@ -466,6 +466,16 @@ func CommonReload(c map[int][]func(*pb.ReloadGameConfig) error) {
return nil
}}
}
if _, ok := c[common.ReloadConfigDiscountTicket]; !ok {
c[common.ReloadConfigDiscountTicket] = []func(*pb.ReloadGameConfig) error{func(rgc *pb.ReloadGameConfig) error {
if err := LoadConfigDiscountTicket(); err != nil {
log.Error("error : [%s]", err.Error())
return err
}
return nil
}}
}
// 客服
if _, ok := c[common.ReloadConfigCustomerRobot]; !ok {
c[common.ReloadConfigCustomerRobot] = []func(*pb.ReloadGameConfig) error{func(rgc *pb.ReloadGameConfig) error {

@ -67,9 +67,6 @@ func ShareBind(share string, isOld bool, uid, cid int) {
// 判断分享,发放有效用户奖励
func CheckShare(r *common.RechargeOrder) {
reward := GetConfigShareSys().ShareReward
if reward <= 0 {
return
}
if r.Amount < GetConfigShareSys().ShareRecharge {
return
}

@ -8,4 +8,5 @@ cd pb/proto
# go generate
cd ../..
#go build main.go
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o indiaprovider main.go
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o indiaprovider main.go
#CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o gameserver main.go

@ -546,6 +546,18 @@ type ConfigActivityPopup struct {
AdditionalInfo string `gorm:"column:additional_info;type:text;comment:附加信息" web:"additional_info"`
}
func (c *ConfigActivityPopup) TableName() string {
func (m *ConfigActivityPopup) TableName() string {
return "config_activity_popup"
}
type ConfigDiscountTicket struct {
Id int `gorm:"column:id;type:int(11) AUTO_INCREMENT;primary_key" json:"id"`
RechargeAmount int64 `gorm:"column:recharge_amount;type:bigint(20)" json:"recharge_amount"`
DiscountAmount int64 `gorm:"column:discount_amount;type:bigint(20)" json:"discount_amount"`
CurProb int `gorm:"column:cur_prob;type:int(11)" json:"cur_prob"`
NextProb int `gorm:"column:next_prob;type:int(11)" json:"next_prob"`
}
func (m *ConfigDiscountTicket) TableName() string {
return "config_discount_ticket"
}

@ -52,6 +52,7 @@ const (
ReloadConfigTgRobot // tg机器人配置
ReloadConfigBetDraw // 下注抽奖
ReloadConfigActivityPopup // 活动弹窗
ReloadConfigDiscountTicket // 折扣券
ReloadConfigCustomerRobot // 客服系统机器人配置
ReloadConfigCustomerLabel // 客服系统订单标签

@ -29,6 +29,7 @@ const (
CurrencyResourceRechargeBonus // bonus充值
CurrencyResourceFirstRecharge // 首充
CurrencyResourceWeekCard // 周卡
CurrencyResourceShare // 分享
CurrencyResourceAll
)

@ -178,7 +178,9 @@ func WithdrawExamine(c *gin.Context) {
if err != nil {
log.Error(err.Error())
}
return
}
call.SendMailWithContent(one.UID, call.SystemTitle, fmt.Sprintf(call.EmailWithdrawPass, one.OrderID, one.Amount/common.DecimalDigits))
a.RecordEdit(values.PowerExamineWithdraw, fmt.Sprintf("审核退出订单ID:%v", req.ID))
}

@ -144,7 +144,7 @@ func ReviewAppSummary(c *gin.Context) {
// activePlayTime += ap
// ar, _ := strconv.ParseFloat(resp.PlatformData[i].ARPPU, 64)
// arppu += ar
// ws, _ := strconv.ParseFloat(strings.ReplaceAll(resp.PlatformData[i].WithdrawSuccess, "%", ""), 64)
// ws, _ := strconv.ParseFloat(strings.ReplaceAll(resp.PlatformData[i].EmailWithdrawSuccess, "%", ""), 64)
// withdrawSuccess += ws
}
@ -164,7 +164,7 @@ func ReviewAppSummary(c *gin.Context) {
// resp.Total.OldPlayTime = util.FormatFloat(oldPlayTime/float64(len(tempChannelArr)), 2)
// resp.Total.ActivePlayTime = util.FormatFloat(activePlayTime/float64(len(tempChannelArr)), 2)
// resp.Total.ARPPU = util.FormatFloat(arppu/float64(len(tempChannelArr)), 2)
// resp.Total.WithdrawSuccess = utils.GetPer(int64(withdrawSuccess*100), int64(len(tempChannelArr))*10000)
// resp.Total.EmailWithdrawSuccess = utils.GetPer(int64(withdrawSuccess*100), int64(len(tempChannelArr))*10000)
}
switch req.Sort {

@ -150,7 +150,7 @@ func ReviewData(c *gin.Context) {
// activePlayTime += ap
// ar, _ := strconv.ParseFloat(one.ARPPU, 64)
// arppu += ar
// withdrawSuccess = utils.AddPerFloat(withdrawSuccess, one.WithdrawSuccess)
// withdrawSuccess = utils.AddPerFloat(withdrawSuccess, one.EmailWithdrawSuccess)
}
sort.Slice(resp.PlatformData, func(i, j int) bool {
return resp.PlatformData[i].Time > resp.PlatformData[j].Time
@ -169,7 +169,7 @@ func ReviewData(c *gin.Context) {
// total.OldPlayTime = util.FormatFloat(oldPlayTime/float64(resp.Count), 2)
// total.ActivePlayTime = util.FormatFloat(activePlayTime/float64(resp.Count), 2)
// total.ARPPU = util.FormatFloat(arppu/float64(resp.Count), 2)
// total.WithdrawSuccess = utils.GetPer(int64(withdrawSuccess*100), resp.Count*10000)
// total.EmailWithdrawSuccess = utils.GetPer(int64(withdrawSuccess*100), resp.Count*10000)
total.NewPayPer = utils.GetPer(total.NewPayCount, total.NewCount)
// total.NewPlayPer = utils.GetPer(total.NewPlayCount, total.NewCount)
@ -353,7 +353,7 @@ func GetReviewPlatformData(start, end int64, platform ...*int) *values.ReviewDat
db.Mysql().C().Table("withdraw_order").Where(sql).Distinct("uid").Count(&ret.WithdrawPlayerNum)
// 退出成功率
// ret.WithdrawSuccess = utils.GetPer(ret.WithdrawCount, withdrawAll)
// ret.EmailWithdrawSuccess = utils.GetPer(ret.WithdrawCount, withdrawAll)
// 人次成功率
// ret.WithdrawPlayerSuccess = utils.GetPer(ret.WithdrawPlayerNum, totalWithdrawPlayer)

@ -2,6 +2,7 @@ package base
import (
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
@ -95,8 +96,10 @@ func (b *Base) WithdrawCallback(c *gin.Context) {
}
if !success {
values.WithdrawAmount(values.PayWay(or.PayChannel), false, or.Amount*100)
call.SendMailWithContent(or.UID, call.SystemTitle, fmt.Sprintf(call.EmailWithdrawFail, or.OrderID, or.Amount/common.DecimalDigits))
} else {
values.WithdrawSuccess(values.PayWay(or.PayChannel))
call.SendMailWithContent(or.UID, call.SystemTitle, fmt.Sprintf(call.EmailWithdrawSuccess, or.OrderID, or.Amount/common.DecimalDigits))
}
}

@ -1306,7 +1306,6 @@ func ActivityWeekCardInfo(c *gin.Context) {
}
rewardList = append([]int64{cons.DayOneReward}, rewardList...)
rewardList = append(rewardList, 0)
if cardInfo.ID <= 0 || len(cardInfo.Rewards) == 0 {
cardInfo.Day = 0
rewardList, err = util.GenerateRandomSequence(cons.RewardAmount, cons.MiniLimit, 5)
@ -1373,7 +1372,7 @@ func ActivityWeekCardDraw(c *gin.Context) {
}
resp := &values.ActivityWeekCardDrawResp{}
a.Data = resp
conf := call.GetConfigActivityWeekCard()
// conf := call.GetConfigActivityWeekCard()
card := call.GetUserWeekCard(a.UID)
if card.ID == 0 {
a.Code = values.CodeRetry
@ -1419,18 +1418,34 @@ func ActivityWeekCardDraw(c *gin.Context) {
if count >= 3 {
up = true
}
exi2 := int64(300) * common.DecimalDigits
// 判断充值的金额
productList := call.GetConfigPayProduct()
for _, product := range productList {
if product.Amount > card.RechargeAmount && up && exi2 < product.Amount {
exi2 = product.Amount
} else if product.Amount < card.RechargeAmount && up && exi2 > product.Amount {
exi2 = product.Amount
ticket := call.GetConfigDiscountTicketByAmount(int64(300) * common.DecimalDigits)
log.Info("ticket:%v", ticket)
if ticket.Id > 0 {
// 赠送优惠券
products := call.GetConfigPayProductByActivityID(0)
nextProduct := &common.ConfigPayProduct{}
for _, product := range products {
if product.Amount > card.RechargeAmount && nextProduct.Amount < product.Amount {
nextProduct = product
} else if product.Amount < card.RechargeAmount && nextProduct.Amount > product.Amount {
nextProduct = product
}
}
var nextTicket common.ConfigDiscountTicket
if nextProduct != nil {
nextTicket = call.GetConfigDiscountTicketByAmount(nextProduct.Amount)
}
if up {
call.AddUserDiscountTicket(a.UID, ticket.DiscountAmount, ticket.RechargeAmount, -1)
call.SendMailWithContent(a.UID, call.SystemTitle, fmt.Sprintf(call.EmailDiscount, ticket.RechargeAmount/common.DecimalDigits, ticket.DiscountAmount/common.DecimalDigits))
} else if nextTicket.Id > 0 {
call.AddUserDiscountTicket(a.UID, nextTicket.DiscountAmount, nextTicket.RechargeAmount, -1)
call.SendMailWithContent(a.UID, call.SystemTitle, fmt.Sprintf(call.EmailDiscount, ticket.RechargeAmount/common.DecimalDigits, ticket.DiscountAmount/common.DecimalDigits))
}
resp.DiscountTicket = ticket.DiscountAmount
resp.Amount = ticket.RechargeAmount
}
call.AddUserDiscountTicket(a.UID, conf.Discount, exi2)
resp.DiscountTicket = conf.Discount
}
resource := common.CurrencyResourceWeekCard
if card.Day > 0 {
@ -1778,7 +1793,7 @@ func ActivitySevenDayBoxDraw(c *gin.Context) {
call.UploadActivityData(a.UID, common.ActivityIDSevenDayBox, common.ActivityDataJoin, reward)
}
if oneDiscount.Discount > 0 {
// call.AddUserDiscountTicket(a.UID, oneDiscount.Discount)
// call.AddUserDiscountTicket(a.UID, oneDiscount.EmailDiscount)
resp.Discount = oneDiscount.Discount
}
}
@ -1934,6 +1949,7 @@ func ActivityBetDrawInfo(c *gin.Context) {
drawInfo.SpinInfo.SpinNum < drawInfo.SpinInfo.SpinCount &&
now.Unix() >= drawInfo.SpinInfo.NextSpinTIme {
call.PushRed(a.UID, pb.RedPointModule_RedPointFreeSpin, uint32(1))
break
}
}
}
@ -2102,3 +2118,25 @@ func WeekCardDraw(c *gin.Context) {
resp.List = call.GetConfigActivityPopupByType(req.JumpType)
}
}
func DiscountTicketInfo(c *gin.Context) {
a := app.NewApp(c)
defer func() {
a.Response()
}()
resp := new(values.DiscountTicketResp)
a.Data = resp
list := call.GetUserValidItems(a.UID, common.ItemDiscountTicket)
sort.Slice(list, func(i, j int) bool {
return list[i].Exi2 > list[i].Exi2
})
currency := call.GetUserCurrency(a.UID, common.CurrencyINR)
if len(list) > 0 && currency <= config.GetConfig().Web.BreakLimit {
resp.Ticket = &values.DiscountTicketInfo{
Amount: list[0].Exi1,
Discount: list[0].Exi2,
Id: int64(list[0].ID),
}
}
resp.ChannelList = call.GetConfigPayChannelsByID(common.CurrencyINR)
}

@ -6,6 +6,7 @@ import (
"server/db"
"server/modules/web/app"
"server/modules/web/values"
"server/pb"
"github.com/gin-gonic/gin"
"github.com/liangdas/mqant/log"
@ -41,6 +42,7 @@ func MailList(c *gin.Context) {
Count: int(count),
}
a.Data = resp
call.PushRed(a.UID, pb.RedPointModule_RedPointMail, 0)
}
func ReadMail(c *gin.Context) {

@ -2,7 +2,6 @@ package handler
import (
"encoding/json"
"fmt"
"server/call"
"server/config"
"server/db"
@ -91,36 +90,21 @@ func RechargeInfo(c *gin.Context) {
if a.UID > 0 {
// 判断是否有折扣券
tickets := call.GetUserValidItems(a.UID, common.ItemDiscountTicket)
discount := int64(0)
for _, v := range tickets {
thisDiscount := v.Exi1
diff := v.Time + common.ActivityWeekCardTicketExpireTime - time.Now().Unix()
if diff <= 0 {
diff := v.Time - time.Now().Unix()
if v.Time != -1 && diff <= 0 {
id := v.ID
util.Go(func() {
db.Mysql().Update(&common.PlayerItems{ID: id}, map[string]interface{}{"status": common.ItemStatusInvalid})
})
continue
}
if discount < thisDiscount {
discount = thisDiscount
resp.DiscountTicket = append(resp.DiscountTicket, &values.DiscountTicket{
// Level: con.Level,
Discount: fmt.Sprintf("%d", 100-discount),
TimeLeft: diff,
Amount: v.Exi2,
})
// 折扣券
// con := call.GetConfigActivityWeekCardByLevel(1)
// if con != nil {
// resp.DiscountTicket.Range = con.SubRange
// }
// if discount > 50 {
// resp.DiscountTicket.Level = 1
// } else {
// resp.DiscountTicket.Level = 2
// }
}
resp.DiscountTicket = append(resp.DiscountTicket, &values.DiscountTicket{
Id: v.ID,
Discount: v.Exi1,
TimeLeft: v.Time,
Amount: v.Exi2,
})
}
}
}
@ -254,37 +238,16 @@ func NewRechargeImp(req *values.RechargeReq, uid, cid int, ip string) *RechargeI
ProductID: req.ProductID,
}
// 只有商城购买才能使用优惠券
if req.ProductID == 0 {
// 首先判断折扣券
var ticket *common.PlayerItems
discount := int64(-1)
exi2 := int64(0)
if req.ProductID == 0 && req.DiscountTicketId > 0 {
// 判断是否有折扣券
tickets := call.GetUserValidItems(uid, common.ItemDiscountTicket)
for i, v := range tickets {
thisDiscount := v.Exi1
diff := v.Time + common.ActivityWeekCardTicketExpireTime - time.Now().Unix()
if diff <= 0 {
id := v.ID
util.Go(func() {
db.Mysql().Update(&common.PlayerItems{ID: id}, map[string]interface{}{"status": common.ItemStatusInvalid})
})
continue
}
if discount < 0 || thisDiscount < discount {
discount = thisDiscount
ticket = tickets[i]
exi2 = v.Exi2
}
}
if discount > 0 && order.Amount == exi2 && ticket != nil {
ticket := call.GetItem(req.DiscountTicketId)
if ticket != nil && req.Amount >= ticket.Exi2 {
ticketData := common.ActivityRechargeData{ID: common.ItemDiscountTicket, I1: int(ticket.Exi1), I2: req.Amount}
ticketByte, _ := json.Marshal(ticketData)
order.Extra = string(ticketByte)
req.Amount = common.RoundCurrency(common.CurrencyINR, req.Amount*discount/common.DecimalDigits)
req.Amount = common.RoundCurrency(common.CurrencyINR, req.Amount-ticket.Exi1)
order.Amount = req.Amount
}
}
re := call.GetRechargeInfo(uid)
notCharge := re.TotalRecharge == 0

@ -232,6 +232,7 @@ func ShareWithdraw(c *gin.Context) {
ChannelID: a.Channel,
Value: req.Amount,
Event: common.CurrencyEventShareWithdraw,
NeedBet: call.GetConfigCurrencyResourceNeedBet(common.CurrencyResourceShare, req.Amount),
},
})
return

@ -46,4 +46,6 @@ func activity(e *gin.RouterGroup) {
e.POST("/activity/firstRechargeBack/draw", handler.ActivityFirstRechargeBackDraw)
e.POST("/activity/weekCard/info", handler.ActivityWeekCardInfo)
e.POST("/activity/weekCard/draw", handler.ActivityWeekCardDraw)
// 优惠券
e.POST("/activity/discountTicket/info", handler.DiscountTicketInfo)
}

@ -165,6 +165,7 @@ type ActivityWeekCardDrawReq struct {
type ActivityWeekCardDrawResp struct {
Reward int64
DiscountTicket int64
Amount int64
}
// Spin 可转次数
@ -313,3 +314,14 @@ type ActivityPopupResp struct {
type ActivityFirstRechargeInfoResp struct {
List []*common.ConfigActivityPopup
}
type DiscountTicketInfo struct {
Id int64
Amount int64
Discount int64
}
type DiscountTicketResp struct {
Ticket *DiscountTicketInfo
ChannelList []*common.ConfigPayChannels
}

@ -29,18 +29,20 @@ type RechargeInfoResp struct {
}
type DiscountTicket struct {
Discount string
Id int
Discount int64
TimeLeft int64
Amount int64
}
// RechargeReq 充值请求 地址格式为:{"city":"Mumbai","street":"sarang street","houseNumber":"-54/a"}
type RechargeReq struct {
CurrencyType common.CurrencyType `json:"CurrencyType"`
Amount int64 `json:"Amount"`
PayChannel int
ProductID int
Bonus bool
CurrencyType common.CurrencyType `json:"CurrencyType"`
Amount int64 `json:"Amount"`
PayChannel int
ProductID int
Bonus bool
DiscountTicketId int // 折扣券ID
}
// RechargeHistoryReq 请求充值记录

@ -106,12 +106,13 @@ enum ServerCommonReq{
enum ServerCommonResp{
CommonInvalidResp = 0;
CommonPlayerBalanceResp = 1; // PlayerBalanceResp
CommonPlayerBalanceResp = 1; // PlayerBalanceResp
CommonRedPointResp = 2; // RedPoint
CommonConfigChangeResp = 3; // ConfigChangeResp
CommonActivityItemResp = 4; // ActivityResp
CommonVipResp = 5; // ActivityResp
CommonBroadcastResp = 6; // 广
CommonConfigChangeResp = 3; // ConfigChangeResp
CommonActivityItemResp = 4; // ActivityResp
CommonVipResp = 5; // ActivityResp
CommonBroadcastResp = 6; // 广
CommonDisCountTicketResp = 7; //
}
//
@ -149,7 +150,10 @@ message Product {
int64 Amount = 3; //
}
message DiscountTicketNotify{
int64 discount = 1; //
int64 amount = 2; //
}
/****************************************通用平台类消息开始**********************************************/
enum ServerCommonCmd{

Loading…
Cancel
Save