ice_reward_user.go
1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package sdkdb
import (
"log"
"strconv"
"client/icesimba.mall/utils"
"github.com/astaxie/beego/orm"
)
type IceRewardUser struct {
UserID string `orm:pk;unique` // 用户ID
RewardID string `orm:unique` // 奖励ID
IsPost int64 // 是否发放(0 未发放 1 已发放)
IsGet int64 // 是否领取(0 未领取 1 已领取)
StartTime int64 // 开始时间
EndTime int64 // 结束时间
}
type IceRewardContent struct {
Name string //奖励名字
Count int //奖励数量
}
func IceRewardUserInit() {
// 注册模型
orm.RegisterModel(new(IceRewardContent))
}
func IceRewardUserSendReward(uid string, rewardid string, ispost int64, isget int64, starttime int64, endtime int64, rank int, title string, content string, gtname string) (err error) {
myorm, _ := DBBegin()
o := orm.NewOrm()
var datalist []orm.Params
sqlstr := `select a.COUNT,b.NAME from ice_reward_prop a,ice_prop b where a.PROPID = b.ID and a.REWARDID =?`
_, err = o.Raw(sqlstr, rewardid).Values(&datalist)
if err != nil {
return
}
rankString := strconv.Itoa(rank)
infoTitle := "你在" + gtname + "中获得了第" + rankString + "名"
infoContent := gtname + "奖励【排名】" + rankString + "【奖励】"
for _, v := range datalist {
infoContent = infoContent + v["NAME"].(string) + "x" + v["COUNT"].(string) + " "
}
sqlstr = "insert into ice_reward_user (userid,rewardid,ispost,isget,starttime,endtime,ruid,title,content) values(?,?,?,?,?,?,?,?,?)"
res, err := myorm.Raw(sqlstr, uid, rewardid, ispost, isget, starttime, endtime, utils.GetUuid(), infoTitle, infoContent).Exec()
if err != nil {
log.Printf("IceRewardUserSendReward err[%v]", err)
}
log.Printf("IceRewardUserSendReward res[%v] err[%v]", res, err)
num, _ := res.RowsAffected()
log.Printf("IceRewardUserSendReward affected nums[%d]", num)
DBCommit(myorm)
return
}