50 lines
1.3 KiB
Go
50 lines
1.3 KiB
Go
package pay
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
cfg "go_dreamfactory/sys/configure/structs"
|
|
|
|
"google.golang.org/protobuf/proto"
|
|
)
|
|
|
|
//参数校验
|
|
func (this *apiComp) DailyBuyCheck(session comm.IUserSession, req *pb.PayDailyBuyReq) (code pb.ErrorCode) {
|
|
if req.Id == 0 {
|
|
code = pb.ErrorCode_ReqParameterError
|
|
return
|
|
}
|
|
return
|
|
}
|
|
|
|
///获取系统公告
|
|
func (this *apiComp) DailyBuy(session comm.IUserSession, req *pb.PayDailyBuyReq) (code pb.ErrorCode, data proto.Message) {
|
|
var (
|
|
info *pb.DBPayDaily
|
|
conf *cfg.GamePayPackageData
|
|
err error
|
|
)
|
|
if code = this.DailyBuyCheck(session, req); code != pb.ErrorCode_Success {
|
|
return
|
|
}
|
|
if conf, err = this.module.configure.getPayPackageData(req.Id); err != nil {
|
|
code = pb.ErrorCode_ConfigNoFound
|
|
return
|
|
}
|
|
if info, err = this.module.modelDaily.queryUserDaily(session.GetUserId()); err != nil {
|
|
code = pb.ErrorCode_DBError
|
|
return
|
|
}
|
|
if info.Items[conf.Id] != nil {
|
|
if info.Items[conf.Id].Buyunm <= 0 {
|
|
code = pb.ErrorCode_PayBuyNumNotEnough
|
|
return
|
|
}
|
|
}
|
|
if code = this.module.modelDaily.delivery(session.GetUserId(), conf.Packagetype); code == pb.ErrorCode_Success {
|
|
return
|
|
}
|
|
session.SendMsg(string(this.module.GetType()), "dailybuy", &pb.PayDailyBuyResp{Isucc: true})
|
|
return
|
|
}
|