54 lines
1.3 KiB
Go
54 lines
1.3 KiB
Go
package growtask
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
|
|
"google.golang.org/protobuf/proto"
|
|
)
|
|
|
|
//进阶奖励领取
|
|
|
|
func (this *apiComp) AdvreceiveCheck(session comm.IUserSession, req *pb.GrowtaskAdvReceiveReq) (code pb.ErrorCode) {
|
|
if req.TaskType == 0 {
|
|
code = pb.ErrorCode_ReqParameterError
|
|
}
|
|
return
|
|
}
|
|
|
|
func (this *apiComp) Advreceive(session comm.IUserSession, req *pb.GrowtaskAdvReceiveReq) (code pb.ErrorCode, data proto.Message) {
|
|
if code = this.AdvreceiveCheck(session, req); code != pb.ErrorCode_Success {
|
|
return
|
|
}
|
|
|
|
uid := session.GetUserId()
|
|
if err := this.module.modelGrowtask.advReceive(uid, req.TaskType); err != nil {
|
|
code = pb.ErrorCode_GrowtaskAdvReceive
|
|
return
|
|
}
|
|
|
|
//发奖
|
|
ggt, err := this.module.configure.getGrowrewardCfg()
|
|
if err != nil {
|
|
code = pb.ErrorCode_ConfigNoFound
|
|
return
|
|
}
|
|
if ggt == nil {
|
|
code = pb.ErrorCode_ConfigNoFound
|
|
return
|
|
}
|
|
|
|
if conf, ok := ggt.GetDataMap()[req.TaskType]; ok {
|
|
if code := this.module.DispenseRes(session, conf.Allreward, true); code != pb.ErrorCode_Success {
|
|
this.module.Errorf("进阶奖励发放失败 taskType:%v uid:%v", req.TaskType, uid)
|
|
}
|
|
}
|
|
|
|
rsp := &pb.GrowtaskAdvReceiveResp{}
|
|
|
|
if err := session.SendMsg(string(this.module.GetType()), GrowtaskSubTypeAdvreceive, rsp); err != nil {
|
|
code = pb.ErrorCode_SystemError
|
|
}
|
|
return
|
|
}
|