-- 开桌统计 local TimeSettingPanel = import(".TimeSettingPanel") local GroupMngPlayStatView = {} local M = GroupMngPlayStatView function GroupMngPlayStatView.new(gid) local self = M self.class = "GroupMngPlayStatView" self.group_id = gid self:InitView() return self end function M:initData() self:GetConsumeStatData() end function M:InitView() self._view = UIPackage.CreateObjectFromURL("ui://NewGroup/View_GroupPlayStat") self.consume_stat = {} --消耗统计 self.lst_consume_stat = self._view:GetChild("lst_consume_stat") self.lst_consume_stat:SetVirtual() self.lst_consume_stat.itemRenderer = function(index, obj) self:OnRenderConsumeItem(index, obj) end self._view:GetChild("btn_search").onClick:Set(function() self.consume_stat = {} self.lst_consume_stat.numItems = 0 self:GetConsumeStatData() end) self.time_panel = TimeSettingPanel.new(self._view, self._view:GetChild("btn_date1"), self._view:GetChild("btn_date2"), -308, 0) end function M:GetConsumeStatData() ViewUtil.ShowModalWait() local begin_time, end_time = self.time_panel:GetDate() local fgCtr = ControllerManager.GetController(NewGroupController) fgCtr:FG_GetConsumeStat(self.group_id,begin_time,end_time, function(res) if self._is_destroy then return end ViewUtil.CloseModalWait() if res.ReturnCode ~= 0 then ViewUtil.ErrorTip(res.ReturnCode, "获取统计数据失败") else self.consume_stat = res.Data.cosume_logs local top = #self.consume_stat + 1 self.consume_stat[top] = {round=0,valid=0,no_valid=0,diamo_cost=0,pid=0} for i = 1,#self.consume_stat - 1 do self.consume_stat[top].round = (self.consume_stat[top].round + self.consume_stat[i].round) self.consume_stat[top].valid = (self.consume_stat[top].valid + self.consume_stat[i].valid) self.consume_stat[top].no_valid = (self.consume_stat[top].no_valid + self.consume_stat[i].no_valid) self.consume_stat[top].diamo_cost = (self.consume_stat[top].diamo_cost + self.consume_stat[i].diamo_cost) end self.lst_consume_stat.numItems = #self.consume_stat end end) end function M:OnRenderConsumeItem(index, obj) local ci = index + 1 local data = self.consume_stat[ci] local play = DataManager.groups:get(self.group_id):getPlay(data.pid) obj:GetChild("title").text = play and play.name or "总计" if ci ~= #self.consume_stat then obj:GetController("total").selectedIndex = 0 else obj:GetController("total").selectedIndex = 1 end obj:GetChild("tex_round").text = data.round / 100 obj:GetChild("tex_finish").text = data.valid / 100 obj:GetChild("tex_unfinish").text = data.no_valid / 100 obj:GetChild("tex_diamond").text = data.diamo_cost / 100 end return M