55 lines
1.3 KiB
Go
55 lines
1.3 KiB
Go
package pay
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
cfg "go_dreamfactory/sys/configure/structs"
|
|
"time"
|
|
|
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
|
)
|
|
|
|
// 参数校验
|
|
func (this *apiComp) CreateOrderCheck(session comm.IUserSession, req *pb.PayCreateOrderReq) (errdata *pb.ErrorData) {
|
|
|
|
return
|
|
}
|
|
|
|
// /获取系统公告
|
|
func (this *apiComp) CreateOrder(session comm.IUserSession, req *pb.PayCreateOrderReq) (errdata *pb.ErrorData) {
|
|
var (
|
|
conf *cfg.GameRechargeData
|
|
order *pb.DBPayOrder
|
|
err error
|
|
)
|
|
if errdata = this.CreateOrderCheck(session, req); errdata != nil {
|
|
return
|
|
}
|
|
if conf, err = this.module.configure.getGameRecharge(order.Bpoints); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ConfigNoFound,
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
order = &pb.DBPayOrder{
|
|
Orderid: primitive.NewObjectID().Hex(),
|
|
Uid: session.GetUserId(),
|
|
Bpoints: req.BillingPoints,
|
|
Ctime: time.Now().Unix(),
|
|
State: pb.DBPayOrderState_PayOrder_Unpaid,
|
|
Ptype: req.Ptype,
|
|
Pid: req.Pid,
|
|
Price: conf.Amount,
|
|
Amount: 1,
|
|
}
|
|
if err = this.module.model.create(order); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Message: err.Error(),
|
|
}
|
|
}
|
|
session.SendMsg(string(this.module.GetType()), "createorder", &pb.PayCreateOrderResp{Order: order})
|
|
return
|
|
}
|