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.
51 lines
1.8 KiB
51 lines
1.8 KiB
package call |
|
|
|
import ( |
|
"fmt" |
|
"server/common" |
|
"server/db" |
|
"server/pb" |
|
|
|
"github.com/liangdas/mqant/log" |
|
) |
|
|
|
func GetUserItem(uid, itemID int) []*common.PlayerItems { |
|
list := []*common.PlayerItems{} |
|
db.Mysql().QueryAll(fmt.Sprintf("uid = %d and item_id = %d", uid, itemID), "", &common.PlayerItems{}, &list) |
|
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) |
|
return list |
|
} |
|
|
|
func GetUserItemByExi1(uid, itemID, exi1 int) []*common.PlayerItems { |
|
list := []*common.PlayerItems{} |
|
db.Mysql().QueryAll(fmt.Sprintf("uid = %d and item_id = %d and exi1 = %d and status = %d", uid, itemID, exi1, common.ItemStatusNormal), "", &common.PlayerItems{}, &list) |
|
return list |
|
} |
|
|
|
// 获取力度最大的折扣券 |
|
func GetUserBestDiscountTicket(uid int) *common.PlayerItems { |
|
list := []*common.PlayerItems{} |
|
db.Mysql().QueryAll(fmt.Sprintf("uid = %d and item_id = %d and status = %d", uid, common.ItemDiscountTicket, common.ItemStatusNormal), "exi1 desc", &common.PlayerItems{}, &list) |
|
if len(list) > 0 { |
|
return list[0] |
|
} |
|
return nil |
|
} |
|
|
|
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") |
|
}
|
|
|