diff --git a/comm/const.go b/comm/const.go index 62b23a1f3..dfefde3b9 100644 --- a/comm/const.go +++ b/comm/const.go @@ -98,6 +98,7 @@ const ( ModuleStone core.M_Modules = "stonehenge" //巨石秘境 ModuleKFTask core.M_Modules = "kftask" //开服任务 ModuleHeroTask core.M_Modules = "herotask" //守护者任务 + ModuleShopCenter core.M_Modules = "shopcenter" //购物中心 ) // 数据表名定义处 diff --git a/comm/imodule.go b/comm/imodule.go index f4cd78a3f..5e5a3053b 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -26,6 +26,10 @@ type ( IActivityNotice interface { ActivityNotice(hdlist *pb.DBHuodong) } + //支付发布接口 + IPayDelivery interface { + Delivery(session IUserSession, pId string) (errdata *pb.ErrorData, items []*pb.UserAssets) + } ) /* @@ -396,7 +400,7 @@ type ( } IPrivilege interface { // 创建一个新的特权卡 - Delivery(session IUserSession, pId string) (errdata *pb.ErrorData, items []*pb.UserAssets) + IPayDelivery // 续费特权卡 RenewPrivilegeCard(session IUserSession, cId string) (errdata *pb.ErrorData) // 检查特权 参数 计费点 返回值 是否有特权 @@ -465,10 +469,6 @@ type ( ModulePayDelivery(session IUserSession, Productid string, Price int32) (errdata *pb.ErrorData) IActivityNotice } - //支付发货 - IPayDelivery interface { - Delivery(session IUserSession, pid string) (errdata *pb.ErrorData, items []*pb.UserAssets) - } //实时Pvp IPvp interface { @@ -586,7 +586,7 @@ type ( } //战令 IWarorder interface { - Delivery(session IUserSession, pid string) (errdata *pb.ErrorData, items []*pb.UserAssets) + IPayDelivery IActivityNotice } @@ -616,4 +616,9 @@ type ( ///红点 IGetReddot } + + //购物中心 + IShopcenter interface { + IPayDelivery + } ) diff --git a/modules/passon/api_clearcd.go b/modules/passon/api_clearcd.go index b0c5bbc77..5e490f4fd 100644 --- a/modules/passon/api_clearcd.go +++ b/modules/passon/api_clearcd.go @@ -33,7 +33,7 @@ func (this *apiComp) ClearCD(session comm.IUserSession, req *pb.PassonClearCDReq return } - if errdata = this.module.DispenseRes(session, []*cfg.Gameatn{conf.Remake}, true); errdata != nil { + if errdata = this.module.ConsumeRes(session, []*cfg.Gameatn{conf.Remake}, true); errdata != nil { return } diff --git a/modules/pay/module.go b/modules/pay/module.go index 3fbaf002e..b112236c8 100644 --- a/modules/pay/module.go +++ b/modules/pay/module.go @@ -34,6 +34,7 @@ type Pay struct { modelActivity *modelActivityComp //活动礼包 privilege comm.IPayDelivery //月卡 warorder comm.IWarorder //战令 + shopcenter comm.IPayDelivery //购物中心 configure *configureComp } @@ -59,6 +60,10 @@ func (this *Pay) Start() (err error) { return } this.warorder = module.(comm.IWarorder) + if module, err = this.service.GetModule(comm.ModuleShopCenter); err != nil { + return + } + this.shopcenter = module.(comm.IPayDelivery) this.service.RegisterFunctionName(string(comm.Rpc_ModulePayDelivery), this.Rpc_ModulePayDelivery) return } @@ -155,6 +160,12 @@ func (this *Pay) Rpc_ModulePayDelivery(ctx context.Context, args *pb.PayDelivery return } break + case 6: + if errdata, items = this.shopcenter.Delivery(session, args.Productid); errdata != nil { + reply.Code = errdata.Code + return + } + break } for _, v := range res { items = append(items, &pb.UserAssets{A: v.A, T: v.T, N: v.N}) @@ -251,6 +262,10 @@ func (this *Pay) ModulePayDelivery(session comm.IUserSession, Productid string, return } break + case 6: //购物中心 + if errdata, items = this.shopcenter.Delivery(session, Productid); errdata != nil { + return + } } for _, v := range res { items = append(items, &pb.UserAssets{A: v.A, T: v.T, N: v.N}) diff --git a/modules/shopcenter/api_receive.go b/modules/shopcenter/api_receive.go index 4f5705221..ef0c5fea5 100644 --- a/modules/shopcenter/api_receive.go +++ b/modules/shopcenter/api_receive.go @@ -1,6 +1,7 @@ package shopcenter import ( + "fmt" "go_dreamfactory/comm" "go_dreamfactory/pb" cfg "go_dreamfactory/sys/configure/structs" @@ -20,6 +21,9 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.ShopCenterReceiv fconf *cfg.GameShopCenterFundData info *pb.DBShopCenter item *pb.DBShopCenterItem + user *pb.DBUser + drop int32 + items []*cfg.Gameatn ok bool err error ) @@ -68,7 +72,14 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.ShopCenterReceiv Message: "activity is close", } } - + if user = this.module.ModuleUser.GetUser(session.GetUserId()); user == nil { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_DBError, + Title: pb.ErrorCode_DBError.ToString(), + Message: "no found user!", + } + return + } switch conf.Type { case 1: if pconf, err = this.module.configure.getGameShopCenterSubmeter(req.Pid); err != nil { @@ -88,6 +99,7 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.ShopCenterReceiv } return } + drop = pconf.Group case 2, 3, 4, 5: if fconf, err = this.module.configure.getGameShopCenterFund(req.Pid); err != nil { errdata = &pb.ErrorData{ @@ -98,27 +110,38 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.ShopCenterReceiv return } if conf.Type == 2 { //等级基金 - if user := this.module.ModuleUser.GetUser(session.GetUserId()); user == nil { + if user.Lv < fconf.Unlock { //没有达到目标等级 errdata = &pb.ErrorData{ - Code: pb.ErrorCode_DBError, - Title: pb.ErrorCode_DBError.ToString(), - Message: "no found user!", + Code: pb.ErrorCode_ReqParameterError, + Title: pb.ErrorCode_ReqParameterError.ToString(), + Message: "user lv no achieve", } return - } else { - if user.Lv < fconf.Unlock { //没有达到目标等级 - errdata = &pb.ErrorData{ - Code: pb.ErrorCode_ReqParameterError, - Title: pb.ErrorCode_ReqParameterError.ToString(), - Message: "user lv no achieve", - } - return - } } - + drop = fconf.Group + } + } + item.Record[req.Pid] = true + if items = this.module.ModuleTools.GetGroupDataByLottery(drop, user.Vip, user.Lv); len(items) == 0 { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_ConfigNoFound, + Title: pb.ErrorCode_ConfigNoFound.ToString(), + Message: fmt.Sprintf("掉落组未找到:%d", drop), + } + return + } + if errdata = this.module.DispenseRes(session, items, true); errdata != nil { + return + } + if err = this.module.modelshop.Change(session.GetUserId(), map[string]interface{}{ + "item": item, + }); err != nil { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_DBError, + Title: pb.ErrorCode_DBError.ToString(), + Message: err.Error(), } } - session.SendMsg(string(this.module.GetType()), "receive", &pb.ShopCenterReceiveResp{}) return } diff --git a/modules/shopcenter/configure.go b/modules/shopcenter/configure.go index 3ea96fcf4..0798bfb78 100644 --- a/modules/shopcenter/configure.go +++ b/modules/shopcenter/configure.go @@ -33,6 +33,19 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp return } +// 获取活跃度奖励配置 +func (this *configureComp) getGameShopCenterControls() (confs []*cfg.GameShopCenterControlData, err error) { + var ( + v interface{} + ) + if v, err = this.GetConfigure(game_shopcentercontrol); err != nil { + return + } else { + confs = v.(*cfg.GameShopCenterControl).GetDataList() + } + return +} + // 获取活跃度奖励配置 func (this *configureComp) getGameShopCenterControl(fid int32) (conf *cfg.GameShopCenterControlData, err error) { var ( diff --git a/modules/shopcenter/modelShop.go b/modules/shopcenter/modelShop.go index b7cdb689e..272b32e06 100644 --- a/modules/shopcenter/modelShop.go +++ b/modules/shopcenter/modelShop.go @@ -14,7 +14,8 @@ import ( type ModelShop struct { modules.MCompModel - module *ShopCenter + module *ShopCenter + activitys map[int32]*pb.DBHuodong } func (this *ModelShop) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { diff --git a/modules/shopcenter/module.go b/modules/shopcenter/module.go index 587997abf..52cb5864c 100644 --- a/modules/shopcenter/module.go +++ b/modules/shopcenter/module.go @@ -1,10 +1,12 @@ package shopcenter import ( + "fmt" "go_dreamfactory/comm" "go_dreamfactory/lego/core" "go_dreamfactory/modules" "go_dreamfactory/pb" + cfg "go_dreamfactory/sys/configure/structs" ) type ShopCenter struct { @@ -62,3 +64,62 @@ func (this *ShopCenter) ActivityNotice(hdlist *pb.DBHuodong) { break } } + +// 发货 +func (this *ShopCenter) Delivery(session comm.IUserSession, pid string) (errdata *pb.ErrorData, items []*pb.UserAssets) { + var ( + confs []*cfg.GameShopCenterControlData + conf *cfg.GameShopCenterControlData + info *pb.DBShopCenter + err error + ) + if confs, err = this.configure.getGameShopCenterControls(); err != nil { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_ConfigNoFound, + Title: pb.ErrorCode_ConfigNoFound.String(), + Message: err.Error(), + } + return + } + + for _, v := range confs { + if v.Point == pid { + conf = v + } + } + if conf == nil { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_ConfigNoFound, + Title: pb.ErrorCode_ConfigNoFound.String(), + Message: fmt.Sprintf("no found Point:%s", pid), + } + return + } + + if info, err = this.modelshop.getUserShopCenter(session.GetUserId()); err != nil { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_DBError, + Title: pb.ErrorCode_DBError.ToString(), + Message: err.Error(), + } + return + } + + info.Item[conf.Id] = &pb.DBShopCenterItem{ + Id: conf.Id, + Vip: true, + Open: true, + Record: make(map[int32]bool), + } + items = make([]*pb.UserAssets, 0) + if err = this.modelshop.Change(session.GetUserId(), map[string]interface{}{ + "item": info.Item, + }); err != nil { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_DBError, + Title: pb.ErrorCode_DBError.ToString(), + Message: err.Error(), + } + } + return +}