Merge branch 'meixiongfeng' of http://git.legu.cc/liwei_3d/go_dreamfactory into dev

This commit is contained in:
meixiongfeng 2022-12-07 19:20:12 +08:00
commit 35dfe59537
6 changed files with 123 additions and 51 deletions

View File

@ -32,5 +32,11 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.GourmetGetListRe
// 任务统计 // 任务统计
this.module.ModuleRtask.SendToRtask(session, comm.Rtype136, _gourmet.TotalTime) this.module.ModuleRtask.SendToRtask(session, comm.Rtype136, _gourmet.TotalTime)
resp := &pb.GourmetCreateOrderReq{}
resp.Order = append(resp.Order, &pb.OrderCook{
FoodType: 1001,
FoodCount: 10,
})
this.CreateOrder(session, resp)
return return
} }

View File

@ -133,7 +133,7 @@ func (this *Mainline) CheckPoint(uid string) bool {
func (this *Mainline) ModifyMainlineDataByNanduID(uid string, nandu, id int32) (code pb.ErrorCode) { func (this *Mainline) ModifyMainlineDataByNanduID(uid string, nandu, id int32) (code pb.ErrorCode) {
conf := this.configure.GetMainlineConfigData(id, nandu) conf := this.configure.GetMainlineConfigData(id, nandu)
if conf != nil { if conf == nil {
code = pb.ErrorCode_ConfigNoFound // 找不到配置 code = pb.ErrorCode_ConfigNoFound // 找不到配置
return return
} }
@ -142,17 +142,19 @@ func (this *Mainline) ModifyMainlineDataByNanduID(uid string, nandu, id int32) (
// 获取当前的章节数据 // 获取当前的章节数据
jumpCap := conf.Chapter jumpCap := conf.Chapter
// 先加所有难度小于1 的章节 // 先加所有难度小于1 的章节
for ndIndex := 1; ndIndex < int(nandu)-1; ndIndex++ { for ndIndex := 1; ndIndex <= int(nandu)-1; ndIndex++ {
max := this.configure.GetMaxMainlineChapter() max := this.configure.GetMaxMainlineChapter()
for i := 1; i <= int(max); i++ { for i := 1; i <= int(max); i++ {
confCap := this.configure.GetMainlineChapter(int32(i))
//_conf := this.configure.GetMainlineConfigData(int32(i), int32(ndIndex))
_data := &pb.DBMainline{} _data := &pb.DBMainline{}
_data.Id = primitive.NewObjectID().Hex() _data.Id = primitive.NewObjectID().Hex()
_data.ChapterId = conf.Chapter _data.ChapterId = int32(i)
_data.MainlineId = conf.Id _data.MainlineId = confCap.Id
_mData := make(map[string]interface{}, 0) _mData := make(map[string]interface{}, 0)
_data.Uid = uid _data.Uid = uid
_data.Intensity = int32(ndIndex) // 难度1 _data.Intensity = int32(ndIndex) // 难度1
confCap := this.configure.GetMainlineChapter(int32(i))
for _, v := range confCap.Episode { for _, v := range confCap.Episode {
_data.BranchID = append(_data.BranchID, v) _data.BranchID = append(_data.BranchID, v)
} }
@ -163,12 +165,12 @@ func (this *Mainline) ModifyMainlineDataByNanduID(uid string, nandu, id int32) (
} }
} }
// 加当前难度 的章节数据 // 加当前难度 的章节数据
for i := 1; i < int(jumpCap-1); i++ { for i := 1; i <= int(jumpCap-1); i++ {
confCap := this.configure.GetMainlineChapter(int32(i)) confCap := this.configure.GetMainlineChapter(int32(i))
_data := &pb.DBMainline{} _data := &pb.DBMainline{}
_data.Id = primitive.NewObjectID().Hex() _data.Id = primitive.NewObjectID().Hex()
_data.ChapterId = conf.Chapter _data.ChapterId = int32(i)
_data.MainlineId = conf.Id _data.MainlineId = confCap.Id
_mData := make(map[string]interface{}, 0) _mData := make(map[string]interface{}, 0)
_data.Uid = uid _data.Uid = uid
_data.Intensity = int32(nandu) // 难度1 _data.Intensity = int32(nandu) // 难度1
@ -186,9 +188,12 @@ func (this *Mainline) ModifyMainlineDataByNanduID(uid string, nandu, id int32) (
_mData := make(map[string]interface{}, 0) _mData := make(map[string]interface{}, 0)
_data.Uid = uid _data.Uid = uid
_data.Intensity = int32(nandu) // 难度1 _data.Intensity = int32(nandu) // 难度1
// for _, v := range confCap.Episode { confCap := this.configure.GetMainlineChapter(int32(conf.Chapter))
// _data.BranchID = append(_data.BranchID, v) for _, v := range confCap.Episode {
// } if v <= id {
_data.BranchID = append(_data.BranchID, v)
}
}
_mData[_data.Id] = _data _mData[_data.Id] = _data
this.modelMainline.addNewChapter(uid, _mData) this.modelMainline.addNewChapter(uid, _mData)

View File

@ -5,10 +5,18 @@ import (
"go_dreamfactory/lego/sys/gin/engine" "go_dreamfactory/lego/sys/gin/engine"
"go_dreamfactory/pb" "go_dreamfactory/pb"
"net/http" "net/http"
"time"
"go.mongodb.org/mongo-driver/bson/primitive"
) )
type CrateMailReq struct { type CrateMailReq struct {
pb.DBMailData Uid string `json:"uid"` // uid
Title string `json:"title"` // 邮件标题
Contex string `json:"contex"` // 邮件内容 支持自定义
Items []*pb.UserAssets // 附件
Cid string `json:"cid"` // 多语言表id
Param []string // 自定义参数
Sign string `json:"sign"` Sign string `json:"sign"`
} }
@ -27,11 +35,9 @@ func (this *Api_Comp) CreateMail(c *engine.Context) {
"Uid": req.Uid, "Uid": req.Uid,
"Title": req.Title, "Title": req.Title,
"Contex": req.Contex, "Contex": req.Contex,
"CreateTime": req.CreateTime,
"DueTime": req.DueTime,
"Check": req.Check,
"Reward": req.Reward,
"Items": req.Items, "Items": req.Items,
"Cid": req.Cid,
"Param": req.Param,
}); sign != req.Sign { }); sign != req.Sign {
this.module.Errorf("LoginByCaptchaReq SignError sgin:%s", sign) this.module.Errorf("LoginByCaptchaReq SignError sgin:%s", sign)
code = pb.ErrorCode_SignError code = pb.ErrorCode_SignError
@ -43,7 +49,23 @@ func (this *Api_Comp) CreateMail(c *engine.Context) {
msg = pb.GetErrorCodeMsg(code) msg = pb.GetErrorCodeMsg(code)
return return
} }
if err = this.module.modelMail.CreateGMMail(&req.DBMailData); err != nil { mail := &pb.DBMailData{
ObjId: primitive.NewObjectID().Hex(),
Uid: req.Uid,
Title: req.Title,
Contex: req.Contex,
CreateTime: uint64(time.Now().Unix()),
DueTime: uint64(time.Now().Unix() + 30*24*3600),
Check: false,
Reward: false,
Items: req.Items,
Cid: req.Cid,
Param: req.Param,
}
if len(req.Items) > 0 {
mail.Reward = true
}
if err = this.module.modelMail.CreateGMMail(mail); err != nil {
this.module.Errorf("LoginByCaptchaReq CreateMail err:%v", err) this.module.Errorf("LoginByCaptchaReq CreateMail err:%v", err)
code = pb.ErrorCode_DBError code = pb.ErrorCode_DBError
msg = pb.GetErrorCodeMsg(code) msg = pb.GetErrorCodeMsg(code)

View File

@ -364,3 +364,45 @@ func (r Robot) AddGrormetItem() bool {
func (r *Robot) SetAccount(account string) { func (r *Robot) SetAccount(account string) {
r.account = account r.account = account
} }
func (r Robot) GourmetOrder() int64 {
var byteLen int64
mainType := "gourmet"
subType := "createorder"
msg := &pb.UserMessage{MainType: mainType, SubType: subType}
rsp := &pb.GourmetCreateOrderReq{}
rsp.Order = append(rsp.Order, &pb.OrderCook{
FoodType: 1001,
FoodCount: 10,
})
msg.Sec = r.BuildSecStr()
if comm.ProtoMarshal(rsp, msg) {
data, _ := proto.Marshal(msg)
err := r.ws.WriteMessage(websocket.BinaryMessage, data)
if err != nil {
fmt.Printf("WriteMessage err:%v", err)
}
}
for {
var msg *pb.UserMessage = &pb.UserMessage{}
_, data, err := r.ws.ReadMessage()
if err != nil {
fmt.Printf("readMessage err:%v", err)
continue
}
if err = proto.Unmarshal(data, msg); err != nil {
fmt.Printf("unmarshal err:%v", err)
}
if msg.MainType == mainType && msg.SubType == subType {
byteLen += int64(len(data))
resp := &pb.GourmetCreateOrderResp{}
if !comm.ProtoUnmarshal(msg, resp) { //反序列化失败
break
}
break
}
}
return byteLen
}

View File

@ -59,7 +59,7 @@ func Dispose(ctx context.Context, concurrency, totalNumber uint64, request *mode
head := &pb.UserMessage{MainType: "user", SubType: "login"} head := &pb.UserMessage{MainType: "user", SubType: "login"}
// 先登录 // 先登录
r.SendToClient(head, &pb.UserLoginReq{}) r.SendToClient(head, &pb.UserLoginReq{})
r.AddGrormetItem() //r.AddGrormetItem()
go golink.WebSocket(ctx, i, ch, totalNumber, &wg, request, r) go golink.WebSocket(ctx, i, ch, totalNumber, &wg, request, r)
case 2: case 2:
// 并发建立长链接 // 并发建立长链接

View File

@ -3,17 +3,12 @@ package golink
import ( import (
"context" "context"
"fmt"
"sync" "sync"
"time" "time"
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"go_dreamfactory/stress/helper" "go_dreamfactory/stress/helper"
"go_dreamfactory/stress/model" "go_dreamfactory/stress/model"
"go_dreamfactory/stress/robot" "go_dreamfactory/stress/robot"
"github.com/golang/protobuf/proto"
) )
const ( const (
@ -87,29 +82,31 @@ func webSocketRequest(chanID uint64, ch chan<- *model.RequestResults, i uint64,
//startTime := time.Now() //startTime := time.Now()
// r.GetRandUser() // 获取随机在线玩家数据 // r.GetRandUser() // 获取随机在线玩家数据
r.GetGourmetList() byteLen = r.GourmetOrder()
if byteLen > 0 {
for {
var msg *pb.UserMessage = &pb.UserMessage{}
data, err := r.GetMessagedata()
if err != nil {
fmt.Printf("readMessage err:%v", err)
isSucceed = false
break
}
if err = proto.Unmarshal(data, msg); err != nil {
fmt.Printf("unmarshal err:%v", err)
}
if msg.MainType == "gourmet" && msg.SubType == "getlist" {
byteLen += int64(len(data))
isSucceed = true isSucceed = true
resp := &pb.GourmetGetListResp{}
if !comm.ProtoUnmarshal(msg, resp) { //反序列化失败
break
}
break
}
} }
// for {
// var msg *pb.UserMessage = &pb.UserMessage{}
// data, err := r.GetMessagedata()
// if err != nil {
// fmt.Printf("readMessage err:%v", err)
// isSucceed = false
// break
// }
// if err = proto.Unmarshal(data, msg); err != nil {
// fmt.Printf("unmarshal err:%v", err)
// }
// if msg.MainType == "gourmet" && msg.SubType == "getlist" {
// byteLen += int64(len(data))
// isSucceed = true
// resp := &pb.GourmetGetListResp{}
// if !comm.ProtoUnmarshal(msg, resp) { //反序列化失败
// break
// }
// break
// }
// }
requestTime := uint64(helper.DiffNano(startTime)) requestTime := uint64(helper.DiffNano(startTime))
requestResults := &model.RequestResults{ requestResults := &model.RequestResults{