上传购物中心代码
This commit is contained in:
parent
d44d6069a9
commit
2ee68b9822
@ -3,6 +3,7 @@ package shopcenter
|
|||||||
import (
|
import (
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
|
cfg "go_dreamfactory/sys/configure/structs"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 参数校验
|
// 参数校验
|
||||||
@ -15,12 +16,15 @@ func (this *apiComp) InfoCheck(session comm.IUserSession, req *pb.ShopCenterInfo
|
|||||||
func (this *apiComp) Info(session comm.IUserSession, req *pb.ShopCenterInfoReq) (errdata *pb.ErrorData) {
|
func (this *apiComp) Info(session comm.IUserSession, req *pb.ShopCenterInfoReq) (errdata *pb.ErrorData) {
|
||||||
var (
|
var (
|
||||||
info *pb.DBShopCenter
|
info *pb.DBShopCenter
|
||||||
|
conf *cfg.GameShopCenterControlData
|
||||||
|
activitys map[int32]*pb.DBHuodong
|
||||||
|
ok bool
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
if errdata = this.InfoCheck(session, req); errdata != nil {
|
if errdata = this.InfoCheck(session, req); errdata != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
activitys = this.module.modelshop.getactivity()
|
||||||
if info, err = this.module.modelshop.getUserShopCenter(session.GetUserId()); err != nil {
|
if info, err = this.module.modelshop.getUserShopCenter(session.GetUserId()); err != nil {
|
||||||
errdata = &pb.ErrorData{
|
errdata = &pb.ErrorData{
|
||||||
Code: pb.ErrorCode_DBError,
|
Code: pb.ErrorCode_DBError,
|
||||||
@ -30,6 +34,33 @@ func (this *apiComp) Info(session comm.IUserSession, req *pb.ShopCenterInfoReq)
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for _, v := range info.Item {
|
||||||
|
if conf, err = this.module.configure.getGameShopCenterControl(v.Id); err != nil {
|
||||||
|
errdata = &pb.ErrorData{
|
||||||
|
Code: pb.ErrorCode_ConfigNoFound,
|
||||||
|
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||||
|
Message: err.Error(),
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if conf.Type == 1 || conf.Type == 2 {
|
||||||
|
v.Open = true
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if _, ok = activitys[comm.XSFundPhysical]; ok && conf.Type == 3 {
|
||||||
|
v.Open = true
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if _, ok = activitys[comm.XSFundRecruit]; ok && conf.Type == 4 {
|
||||||
|
v.Open = true
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if _, ok = activitys[comm.XSFundExp]; ok && conf.Type == 5 {
|
||||||
|
v.Open = true
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
session.SendMsg(string(this.module.GetType()), "info", &pb.ShopCenterInfoResp{Info: info})
|
session.SendMsg(string(this.module.GetType()), "info", &pb.ShopCenterInfoResp{Info: info})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
"go_dreamfactory/lego/sys/mgo"
|
"go_dreamfactory/lego/sys/mgo"
|
||||||
"go_dreamfactory/modules"
|
"go_dreamfactory/modules"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
|
"sync"
|
||||||
|
|
||||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||||
"go.mongodb.org/mongo-driver/mongo"
|
"go.mongodb.org/mongo-driver/mongo"
|
||||||
@ -15,6 +16,7 @@ import (
|
|||||||
type ModelShop struct {
|
type ModelShop struct {
|
||||||
modules.MCompModel
|
modules.MCompModel
|
||||||
module *ShopCenter
|
module *ShopCenter
|
||||||
|
lock sync.RWMutex
|
||||||
activitys map[int32]*pb.DBHuodong
|
activitys map[int32]*pb.DBHuodong
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -25,9 +27,26 @@ func (this *ModelShop) Init(service core.IService, module core.IModule, comp cor
|
|||||||
this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{
|
this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{
|
||||||
Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}},
|
Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}},
|
||||||
})
|
})
|
||||||
|
this.activitys = make(map[int32]*pb.DBHuodong)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *ModelShop) addactivity(id int32, activity *pb.DBHuodong) {
|
||||||
|
this.lock.Lock()
|
||||||
|
this.activitys[id] = activity
|
||||||
|
this.lock.Unlock()
|
||||||
|
}
|
||||||
|
func (this *ModelShop) delactivity(id int32, activity *pb.DBHuodong) {
|
||||||
|
this.lock.Lock()
|
||||||
|
delete(this.activitys, id)
|
||||||
|
this.lock.Unlock()
|
||||||
|
}
|
||||||
|
func (this *ModelShop) getactivity() map[int32]*pb.DBHuodong {
|
||||||
|
this.lock.RLock()
|
||||||
|
defer this.lock.RUnlock()
|
||||||
|
return this.activitys
|
||||||
|
}
|
||||||
|
|
||||||
// 获取用户全部的埋点数据
|
// 获取用户全部的埋点数据
|
||||||
func (this *ModelShop) getUserShopCenter(uid string) (results *pb.DBShopCenter, err error) {
|
func (this *ModelShop) getUserShopCenter(uid string) (results *pb.DBShopCenter, err error) {
|
||||||
results = &pb.DBShopCenter{}
|
results = &pb.DBShopCenter{}
|
||||||
|
@ -51,23 +51,33 @@ func (this *ShopCenter) OnInstallComp() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 活动开启
|
// 活动开启
|
||||||
func (this *ShopCenter) ActivityNotice(hdlist *pb.DBHuodong) {
|
func (this *ShopCenter) ActivityOpenNotice(hdlist *pb.DBHuodong) {
|
||||||
switch hdlist.Itype {
|
switch hdlist.Itype {
|
||||||
case comm.XSFundPhysical:
|
case comm.XSFundPhysical:
|
||||||
this.open = true
|
this.modelshop.addactivity(comm.XSFundPhysical, hdlist)
|
||||||
break
|
break
|
||||||
case comm.XSFundRecruit:
|
case comm.XSFundRecruit:
|
||||||
this.open = true
|
this.modelshop.addactivity(comm.XSFundRecruit, hdlist)
|
||||||
break
|
break
|
||||||
case comm.XSFundExp:
|
case comm.XSFundExp:
|
||||||
this.open = true
|
this.modelshop.addactivity(comm.XSFundExp, hdlist)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 活动关闭
|
// 移除关闭
|
||||||
func (this *ShopCenter) ActivityCloseNotice(hdlist *pb.DBHuodong) {
|
func (this *ShopCenter) ActivityCloseNotice(hdlist *pb.DBHuodong) {
|
||||||
|
switch hdlist.Itype {
|
||||||
|
case comm.XSFundPhysical:
|
||||||
|
this.modelshop.delactivity(comm.XSFundPhysical, hdlist)
|
||||||
|
break
|
||||||
|
case comm.XSFundRecruit:
|
||||||
|
this.modelshop.delactivity(comm.XSFundRecruit, hdlist)
|
||||||
|
break
|
||||||
|
case comm.XSFundExp:
|
||||||
|
this.modelshop.delactivity(comm.XSFundExp, hdlist)
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 发货
|
// 发货
|
||||||
|
Loading…
Reference in New Issue
Block a user