Ver código fonte

Merge branch 'master' of 8.134.163.21:box/box-server

neo 1 ano atrás
pai
commit
8965a8cab9

+ 32 - 1
dev/data/pay.lua

@@ -7,7 +7,6 @@ LastEditors: Neo,Huang
7 7
 LastEditTime: 2022-03-14 20:21:10
8 8
 --]]
9 9
 local timeUtil = require("utils.timeUtil")
10
-local util_user = require("utils.util_user")
11 10
 
12 11
 local shopAdapt = require("adapt.shopAdapt")
13 12
 
@@ -201,4 +200,36 @@ function root:pack_goods_pay_custom_info_list(uid)
201 200
     end
202 201
 end
203 202
 
203
+-- 打包 - 支付信息
204
+function root:pack_pay_info(uid)
205
+    if is_empty(uid) then
206
+        return
207
+    end
208
+    local payInfo = {}
209
+
210
+    -- 终生
211
+    payInfo.totalTimes = 0
212
+    payInfo.totalMoney = 0
213
+    local goodsList = moduleData:hget_json(uid, MODULE_NAME, "goodsList")
214
+    if not is_empty(goodsList) then
215
+        for _, v in ipairs(goodsList) do
216
+            payInfo.totalTimes = payInfo.totalTimes + 1
217
+            payInfo.totalMoney = payInfo.totalMoney + v.amount
218
+        end
219
+    end
220
+
221
+    -- 当天
222
+    payInfo.dayMoney = 0
223
+    payInfo.dayTimes = 0
224
+    local dayInfo = self:get_day_info(uid)
225
+    if not is_empty(dayInfo.goodsList) then
226
+        for _, v in ipairs(dayInfo.goodsList) do
227
+            payInfo.dayTimes = payInfo.dayTimes + 1
228
+            payInfo.dayMoney = payInfo.dayMoney + v.amount
229
+        end
230
+    end
231
+
232
+    return payInfo
233
+end
234
+
204 235
 return root

+ 2 - 0
dev/modules/pay.lua

@@ -66,6 +66,8 @@ function root:dispatch_goods_items(role, gid)
66 66
     end
67 67
     util_user:user_dispatch_event(uid, gameConst.EVENT_ID.PAY, evtParams)
68 68
 
69
+    util_user:user_proto_notify(uid, "on_shop_pay_info", {payInfo = payData:pack_pay_info(uid)})
70
+
69 71
     return code.OK, {items = items}
70 72
 end
71 73
 

+ 146 - 0
dev/utils/util_roll.lua

@@ -0,0 +1,146 @@
1
+--[[
2
+Descripttion:roll房
3
+version:
4
+Author: Neo,Huang
5
+Date: 2023-11-21 23:01:45
6
+LastEditors: Neo,Huang
7
+LastEditTime: 2023-11-21 23:01:59
8
+--]]
9
+local code = require("code")
10
+local lib_game_redis = require("lib_game_redis")
11
+local redisUtil = require("utils.redisUtil")
12
+local util_player = require("utils.util_player")
13
+local timeUtil = require("utils.timeUtil")
14
+local nodeMgr = require("nodeMgr")
15
+
16
+local userData = require("data.user")
17
+local payData = require("data.pay")
18
+
19
+local ROLL_MAIN_KEY = "roll:room"
20
+
21
+local root = {}
22
+
23
+local function _get_roll_room_key(rid)
24
+    return string.format("%s:%s", ROLL_MAIN_KEY, tostring(rid))
25
+end
26
+-- 打包 - 房间信息
27
+function root:pack_roll_room_info(rid)
28
+    if is_empty(rid) then
29
+        return
30
+    end
31
+    local key = _get_roll_room_key(rid)
32
+    local isExist = lib_game_redis:exists(key)
33
+    if not isExist then
34
+        -- 房间已不存在
35
+        return
36
+    end
37
+    local info = {
38
+        roomId = rid,
39
+        name = redisUtil.hget(key, "name"),
40
+        bandShareCode = redisUtil.hget(key, "bandShareCode"),
41
+        createTime = redisUtil.hget_int(key, "createTime"),
42
+        showStartTime = redisUtil.hget_int(key, "showStartTime"),
43
+        signupStartTime = redisUtil.hget_int(key, "signupStartTime"),
44
+        signupEndTime = redisUtil.hget_int(key, "signupEndTime"),
45
+        awardTime = redisUtil.hget_int(key, "awardTime"),
46
+        conditions = redisUtil.hget_json(key, "conditions"),
47
+        itemIdList = redisUtil.hget_json(key, "itemIdList")
48
+    }
49
+    -- 玩家信息
50
+    local signupUidList = redisUtil.hget_json(key, "signupUidList")
51
+    if not is_empty(signupUidList) then
52
+        for _, uid in ipairs(signupUidList) do
53
+            local playerInfo = util_player:get_base_info(uid)
54
+            if not is_empty(playerInfo) then
55
+                if info.signupPlayerList == nil then
56
+                    info.signupPlayerList = {}
57
+                end
58
+                table.insert(info.signupPlayerList, playerInfo)
59
+            end
60
+        end
61
+    end
62
+
63
+    return info
64
+end
65
+-- 打包 - 所有活跃房间
66
+function root:pack_roll_room_info_list()
67
+    local roomIdList = lib_game_redis:smembers(ROLL_MAIN_KEY)
68
+    if is_empty(roomIdList) then
69
+        return
70
+    end
71
+    local roomInfoList = {}
72
+    for _, v in ipairs(roomIdList) do
73
+        local rid = tonumber(v)
74
+        local roomInfo = self:pack_roll_room_info(rid)
75
+        if not is_empty(roomInfo) then
76
+            table.insert(roomInfoList, roomInfo)
77
+        end
78
+    end
79
+    return roomInfoList
80
+end
81
+
82
+-- 报名
83
+function root:sign_up(uid, roomId)
84
+    if is_empty(uid) or is_empty(roomId) then
85
+        return code.PARAMTER_ERROR
86
+    end
87
+    local key = _get_roll_room_key(roomId)
88
+    local isExist = lib_game_redis:exists(key)
89
+    if not isExist then
90
+        -- 房间已不存在
91
+        return code.UNKNOWN
92
+    end
93
+    -- 是否已报名
94
+    local signupUidList = redisUtil.hget_json(key, "signupUidList")
95
+    if table.include(signupUidList, uid) then
96
+        return code.UNKNOWN
97
+    end
98
+    -- 是否绑定推广码
99
+    local bandShareCode = redisUtil.hget(key, "bandShareCode")
100
+    if not is_empty(bandShareCode) then
101
+        local _bandShareCode = userData:get_key_info(uid, "bandShareCode")
102
+        if bandShareCode ~= _bandShareCode then
103
+            return code.UNKNOWN
104
+        end
105
+    end
106
+    -- 报名时间
107
+    local currTime = timeUtil.now(uid)
108
+    local signupStartTime = redisUtil.hget_int(key, "signupStartTime")
109
+    if signupStartTime > currTime then
110
+        -- 未开始报名
111
+        return code.UNKNOWN
112
+    end
113
+    local signupEndTime = redisUtil.hget_int(key, "signupEndTime")
114
+    if currTime > signupEndTime then
115
+        -- 报名已结束
116
+        return code.UNKNOWN
117
+    end
118
+    -- 报名条件
119
+    local conditions = redisUtil.hget_json(key, "conditions")
120
+    if not is_empty(conditions) then
121
+        for _, v in ipairs(conditions) do
122
+            local playerValue = nil
123
+            if v.c == "pay_day_totalAmount" then
124
+                -- 今日充值
125
+                playerValue = payData:get_day_total_amount(uid)
126
+            end
127
+            if v.cv > playerValue then
128
+                return code.UNKNOWN
129
+            end
130
+        end
131
+    end
132
+    -- 报名成功
133
+    table.insert(signupUidList, uid)
134
+    redisUtil.hset(key, "signupUidList", signupUidList)
135
+
136
+    -- 广播
137
+    local pack = {
138
+        roomId = roomId,
139
+        playerInfo = util_player:get_base_info(uid)
140
+    }
141
+    nodeMgr.broadcast_proto_notify("on_roll_player", pack)
142
+
143
+    return code.OK
144
+end
145
+
146
+return root

+ 26 - 0
nodes/game/interface/roll.lua

@@ -0,0 +1,26 @@
1
+--[[
2
+Descripttion:roll房
3
+version:
4
+Author: Neo,Huang
5
+Date: 2023-11-21 23:02:31
6
+LastEditors: Neo,Huang
7
+LastEditTime: 2023-11-21 23:02:43
8
+--]]
9
+local code = require "code"
10
+local util_roll = require("utils.util_roll")
11
+
12
+local root = {}
13
+
14
+-- 获取房间列表
15
+function root:roll_get_info(role, msg)
16
+    local roomInfoList = util_roll:pack_roll_room_info_list()
17
+    return code.OK, {roomList = roomInfoList}
18
+end
19
+
20
+-- 报名
21
+function root:roll_sign_up(role, msg)
22
+    local roomId = msg.roomId
23
+    return util_roll:sign_up(role.uid, roomId)
24
+end
25
+
26
+return root

+ 6 - 1
nodes/game/interface/user.lua

@@ -10,6 +10,8 @@ local code = require "code"
10 10
 local timeUtil = require("utils.timeUtil")
11 11
 local util_user = require("utils.util_user")
12 12
 
13
+local payData = require("data.pay")
14
+
13 15
 local root = {}
14 16
 
15 17
 function root:user_keepalive(role)
@@ -22,7 +24,10 @@ function root:user_self_info(role, msg)
22 24
 end
23 25
 -- 登录完成后
24 26
 function root:after_user_self_info(role, msg)
25
-    local pack = {}
27
+    local uid = role.uid
28
+    local pack = {
29
+        payInfo = payData:pack_pay_info(uid)
30
+    }
26 31
     util_user:user_proto_notify(role.uid, "on_user_system_info", pack)
27 32
 end
28 33
 

+ 9 - 2
nodes/global/service/rollSrv.lua

@@ -11,7 +11,9 @@ local baseService = require("baseService")
11 11
 local lib_game_redis = require("lib_game_redis")
12 12
 local redisUtil = require("utils.redisUtil")
13 13
 local util_mail = require("utils.util_mail")
14
-local timeUtil = require "utils.timeUtil"
14
+local timeUtil = require("utils.timeUtil")
15
+local nodeMgr = require("nodeMgr")
16
+local util_roll = require("utils.util_roll")
15 17
 
16 18
 local resAdapt = require("adapt.resAdapt")
17 19
 
@@ -95,8 +97,8 @@ local function _roll_award(rid)
95 97
 	for _, uid in ipairs(signupUidList) do
96 98
 		if mapUidItems[uid] == nil then
97 99
 			local cnt = string.format("很遗憾,您参与的%sroll房活动中未获得奖励。", tostring(name))
100
+			util_mail:add_mail(uid, 0, title, cnt, {}, 0, nil, nil, "system")
98 101
 		end
99
-		util_mail:add_mail(uid, 0, title, cnt, {}, 0, nil, nil, "system")
100 102
 	end
101 103
 end
102 104
 -- 定时器结束
@@ -146,6 +148,11 @@ function root.add_roll(rid)
146 148
 		end
147 149
 		if not isMatch then
148 150
 			table.insert(root.rollList, {id = rid, awardTime = awardTime})
151
+			-- 广播 - 新房
152
+			local roomInfo = util_roll:pack_roll_room_info(rid)
153
+			if not is_empty(roomInfo) then
154
+				nodeMgr.broadcast_proto_notify("on_roll_new", {room = roomInfo})
155
+			end
149 156
 		end
150 157
 	end
151 158
 end