|
|
|
|
@ -32,8 +32,22 @@ func ShareBind(share string, isOld bool, uid, cid int) { |
|
|
|
|
if share == "" || isOld { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
now := time.Now().Unix() |
|
|
|
|
codeInfo := &common.ShareActivityCode{ShareCode: share} |
|
|
|
|
upInfo := &common.ShareInfo{} |
|
|
|
|
db.Mysql().Get(codeInfo) |
|
|
|
|
if codeInfo.Id > 0 { |
|
|
|
|
upInfo.UID = codeInfo.UID |
|
|
|
|
// 判断是否过期
|
|
|
|
|
if now < codeInfo.ExpireAt { |
|
|
|
|
util.Go(func() { |
|
|
|
|
SendShareReward(uid, codeInfo.ActivityId) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
// 一级
|
|
|
|
|
upInfo := &common.ShareInfo{Share: share} |
|
|
|
|
upInfo = &common.ShareInfo{Share: share} |
|
|
|
|
} |
|
|
|
|
db.Mysql().Get(upInfo) |
|
|
|
|
if upInfo.ID <= 0 { |
|
|
|
|
return |
|
|
|
|
@ -154,3 +168,37 @@ func GetUserShareRechargeAmount(uid, level int) (count int64) { |
|
|
|
|
} |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// GetActivityShareCode 根据actid获取share code
|
|
|
|
|
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) |
|
|
|
|
if err != nil { |
|
|
|
|
log.Error("GetActivityShareCode err:%v", err) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
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, |
|
|
|
|
ShareCode: code, |
|
|
|
|
ActivityId: actId, |
|
|
|
|
ExpireAt: expireTime.Unix(), |
|
|
|
|
CreateAt: now.Unix(), |
|
|
|
|
}) |
|
|
|
|
if err != nil { |
|
|
|
|
log.Error("GetActivityShareCode err:%v", err) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
code = ret[0].ShareCode |
|
|
|
|
} |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func SendShareReward(uid, actId int) { |
|
|
|
|
switch actId { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|