78 lines
2.1 KiB
Go
78 lines
2.1 KiB
Go
package venture
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
cfg "go_dreamfactory/sys/configure/structs"
|
|
)
|
|
|
|
// 参数校验
|
|
func (this *apiComp) SignRewardCheck(session comm.IUserSession, req *pb.VentureSignRewardReq) (errdata *pb.ErrorData) {
|
|
if req.Day == 0 {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ReqParameterError,
|
|
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
func (this *apiComp) SignReward(session comm.IUserSession, req *pb.VentureSignRewardReq) (errdata *pb.ErrorData) {
|
|
var (
|
|
err error
|
|
conf *cfg.GameVenturegiftsLoginData
|
|
sign *pb.DBVentureSign
|
|
atno []*pb.UserAtno
|
|
)
|
|
if errdata = this.SignRewardCheck(session, req); errdata != nil {
|
|
return
|
|
}
|
|
|
|
if conf, err = this.module.configure.getGameVenturegiftsLogin(req.Day); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Title: pb.ErrorCode_DBError.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
if sign, err = this.module.ModelSign.getUserSign(session.GetUserId()); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Title: pb.ErrorCode_DBError.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
|
|
if len(sign.Sign) >= int(sign.Val) {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ActivityCantReward,
|
|
Title: pb.ErrorCode_ActivityCantReward.ToString(),
|
|
}
|
|
return
|
|
}
|
|
if _, ok := sign.Sign[req.Day]; ok {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ActivityRepatReward,
|
|
Title: pb.ErrorCode_ActivityRepatReward.ToString(),
|
|
}
|
|
return
|
|
}
|
|
if errdata, atno = this.module.DispenseAtno(session, []*cfg.Gameatn{conf.Loginreward}, true); errdata != nil {
|
|
return
|
|
}
|
|
sign.Sign[req.Day] = 1
|
|
this.module.ModelSign.Change(session.GetUserId(), map[string]interface{}{
|
|
"sign": sign.Sign,
|
|
})
|
|
session.SendMsg(string(this.module.GetType()), "signreward", &pb.VentureSignRewardResp{
|
|
Sign: sign,
|
|
Atno: atno,
|
|
})
|
|
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
|
|
this.module.WriteUserLog(session.GetUserId(), comm.GMResAddType, "VentureSignRewardReq", atno)
|
|
})
|
|
return
|
|
}
|