49 lines
1.2 KiB
Go
49 lines
1.2 KiB
Go
package pay
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
cfg "go_dreamfactory/sys/configure/structs"
|
|
"time"
|
|
|
|
"google.golang.org/protobuf/proto"
|
|
)
|
|
|
|
//参数校验
|
|
func (this *apiComp) InfoCheck(session comm.IUserSession, req *pb.PayInfoReq) (code pb.ErrorCode) {
|
|
|
|
return
|
|
}
|
|
|
|
///获取系统公告
|
|
func (this *apiComp) Info(session comm.IUserSession, req *pb.PayInfoReq) (code pb.ErrorCode, data proto.Message) {
|
|
var (
|
|
info *pb.DBPayDaily
|
|
conf *cfg.GamePayPackageData
|
|
err error
|
|
)
|
|
if code = this.InfoCheck(session, req); code != pb.ErrorCode_Success {
|
|
return
|
|
}
|
|
if info, err = this.module.modelDaily.queryUserDaily(session.GetUserId()); err != nil {
|
|
code = pb.ErrorCode_DBError
|
|
return
|
|
}
|
|
for _, v := range info.Items {
|
|
if time.Now().Sub(time.Unix(v.Lastrefresh, 0)).Hours() > 24 {
|
|
if conf, err = this.module.configure.getPayPackageData(v.Id); err != nil {
|
|
code = pb.ErrorCode_ConfigNoFound
|
|
return
|
|
}
|
|
v.Buyunm = conf.BuyNum
|
|
v.Lastrefresh = time.Now().Unix()
|
|
}
|
|
}
|
|
if err = this.module.modelDaily.updateUserDaily(info); err != nil {
|
|
code = pb.ErrorCode_DBError
|
|
return
|
|
}
|
|
session.SendMsg(string(this.module.GetType()), "info", &pb.PayInfoResp{Info: info})
|
|
return
|
|
}
|