52 lines
1.2 KiB
Go
52 lines
1.2 KiB
Go
package oldtimes
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
)
|
|
|
|
func (this *apiComp) ReceiveCheck(session comm.IUserSession, req *pb.OldtimesReceiveReq) (errdata *pb.ErrorData) {
|
|
if req.ChapterId <= 0 {
|
|
code = pb.ErrorCode_ReqParameterError
|
|
}
|
|
return
|
|
}
|
|
|
|
func (this *apiComp) Receive(session comm.IUserSession, req *pb.OldtimesReceiveReq) (errdata *pb.ErrorData) {
|
|
if code = this.ReceiveCheck(session, req); code != pb.ErrorCode_Success {
|
|
return
|
|
}
|
|
uid := session.GetUserId()
|
|
|
|
rsp := &pb.OldtimesReceiveResp{}
|
|
ot := this.module.modelOldtimes.getDBOldtimes(uid)
|
|
if ot != nil {
|
|
for _, v := range ot.Chapters {
|
|
if v.Cid == req.ChapterId {
|
|
if v.Received == 1 {
|
|
code = pb.ErrorCode_OldtimesReceived
|
|
return
|
|
} else if v.Status != int32(finish) {
|
|
code = pb.ErrorCode_OldtimesNoAllFinished
|
|
return
|
|
} else {
|
|
v.Received = 1
|
|
this.module.modelOldtimes.updateOldtimes(uid, ot)
|
|
//发奖
|
|
gltl, err := this.module.configure.getTimelineCfg()
|
|
if err != nil {
|
|
return
|
|
}
|
|
if conf, ok := gltl.GetDataMap()[req.ChapterId]; ok {
|
|
this.module.DispenseRes(session, conf.Reward, true)
|
|
}
|
|
break
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
session.SendMsg(string(this.module.GetType()), "receive", rsp)
|
|
return
|
|
}
|