ServerCommerceManager.lua 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678
  1. --------------------------------
  2. -- 文件名 : ServerCommerceActManger.lua
  3. -- 文件说明 : 跨服商业-活动模板管理
  4. -- 创建时间 : 2025/03/26
  5. -- 创建人 : FC
  6. --------------------------------
  7. local Util = require("common.Util")
  8. local Lang = require("common.Lang")
  9. local Broadcast = require("broadcast.Broadcast")
  10. local MailExcel = require("excel.mail")
  11. local Msg = require("core.Msg")
  12. local ObjHuman = require("core.ObjHuman")
  13. local MailManager = require("mail.MailManager")
  14. local BagLogic = require("bag.BagLogic")
  15. local Grid = require("bag.Grid")
  16. local PanelDefine = require("broadcast.PanelDefine")
  17. local CommonDB = require("common.CommonDB")
  18. local BuyLogic = require("topup.BuyLogic")
  19. local GuideLogic = require("guide.GuideLogic")
  20. local Log = require("common.Log")
  21. local YunYingLogic = require("yunying.YunYingLogic")
  22. local ServerCommerceCof = require("excel.ServerCommerce")
  23. local ServerCommerceActDefine = require("serverCommerce.ServerCommerceActDefine")
  24. local Timer = require("core.Timer")
  25. local BuyConf = require("excel.buy")
  26. local ServerCommerceMiddle = require("serverCommerce.ServerCommerceMiddle")
  27. local ServerCommerceActCharge = require("serverCommerce.ServerCommerceActCharge")
  28. local ServerCommerceActRank = require("serverCommerce.ServerCommerceActRank")
  29. local ServerCommerceTask = require("serverCommerce.ServerCommerceActTask")
  30. -- 活动信息
  31. tCommerceActInfo = nil
  32. -- {
  33. -- nStartTime = nil, -- 开始时间
  34. -- nEendTime = nil, -- 结束时间
  35. -- isRun = nil, -- 是否在活动中
  36. -- nOpen = nil, -- 是否打开
  37. -- nBatchID = nil, -- 批次
  38. -- }
  39. -- 加载的模块
  40. tCommerceActModuel = {}
  41. ----------------------------------------- 内部处理开始 -------------------------------------
  42. -- 下发数据
  43. local function CommerceAct_SendData(tMsgData, fd)
  44. Msg.send(tMsgData, fd)
  45. end
  46. -- 创建玩家DB数据
  47. function CommerceAct_CreateHumanDB(human)
  48. local nBatchID = 1
  49. local tCommonDBData = CommonDB.GetCommerceActInfo()
  50. if tCommonDBData and nil ~= _G.next(tCommonDBData) then
  51. nBatchID = tCommonDBData.nBatchID
  52. end
  53. human.db.ServerCommerce =
  54. {
  55. nPoint = 0, -- 当前玩家个人积分
  56. Task = {}, -- 任务信息
  57. Charge = {}, -- 连充豪礼
  58. Shop = {}, -- 战区钜惠
  59. nBatchID = nBatchID, -- 批次
  60. bSendPlayerMail = false, -- 是否发送个人邮件
  61. bSendServerMail = false, -- 是否发送全服邮件
  62. }
  63. for nID, module in pairs(tCommerceActModuel) do
  64. if module and module.CreatDB then
  65. local bRet = module.CreatDB(human)
  66. if false == bRet then
  67. print("[CommerceAct_CreateHumanDB] nID 初始化DB 数据失败 nID = "..nID)
  68. end
  69. end
  70. end
  71. end
  72. -- 下发活动数据
  73. function CommerceAct_SendActInfo(human)
  74. if not human or not tCommerceActInfo then
  75. return
  76. end
  77. print("[CommerceAct_SendActInfo] 下发活动数据 开始 ")
  78. local tMsgData = Msg.gc.GC_SERVEERCOMMERCE_ACT_ALLINFO
  79. tMsgData.nStartTime = tCommerceActInfo.nStartTime
  80. tMsgData.nEendTime = tCommerceActInfo.nEendTime
  81. tMsgData.tActID[0] = #ServerCommerceCof.CommerceAct
  82. local nIndex = 1
  83. for id, v in pairs(ServerCommerceCof.CommerceAct) do
  84. local tActData = tMsgData.tActID[nIndex]
  85. nIndex = nIndex + 1
  86. tActData.ID = id
  87. tActData.name = v.name
  88. tActData.nSortID = v.sortID
  89. tActData.nIcon = v.icon
  90. tActData.nPanelID = v.panelID
  91. local bRed = false
  92. if tCommerceActModuel[id] and tCommerceActModuel[id].isRed then
  93. bRed = tCommerceActModuel[id].isRed(human)
  94. end
  95. print("[CommerceAct_SendActInfo] name = "..tActData.name)
  96. tActData.nRed = (bRed == true) and 1 or 0
  97. end
  98. YunYingLogic.sendBanner(human)
  99. CommerceAct_SendData(tMsgData, human.fd)
  100. print("[CommerceAct_SendActInfo] 下发活动数据 结束 ")
  101. end
  102. -- 各个子活动重置活动数据
  103. local function CommerceAct_ResetData(human)
  104. if not human then
  105. return
  106. end
  107. end
  108. -- 各个子活动处理结束数据
  109. local function CommerceAct_HandleEndData(human)
  110. if not human then
  111. return
  112. end
  113. end
  114. -- 所有活动初始化数据开始
  115. local function CommerceAct_BeginAllAct(human)
  116. if not human or not tCommerceActInfo then
  117. return
  118. end
  119. CommerceAct_CreateHumanDB(human)
  120. print("[CommerceAct_BeginAllAct] 所有活动初始化数据开始 ")
  121. end
  122. -- 结束所有活动
  123. local function CommerceAct_EndAllAct(human)
  124. -- 各个子活动处理数据
  125. CommerceAct_HandleEndData(human)
  126. end
  127. -- 活动开始
  128. local function CommerceAct_Begin()
  129. if not tCommerceActInfo then
  130. return
  131. end
  132. for nID, module in pairs(tCommerceActModuel) do
  133. if module and module.ClearCache then
  134. module.ClearCache()
  135. end
  136. end
  137. -- 遍历在线玩家
  138. for uuid, human in pairs(ObjHuman.onlineUuid) do
  139. CommerceAct_BeginAllAct(human)
  140. end
  141. end
  142. -- 活动结束
  143. local function CommerceAct_End()
  144. -- 排行榜结束
  145. ServerCommerceMiddle.CommerceMiddle_QueryServerRank(ServerCommerceActDefine.COMMERCEACT_SENDSERVERMAIL)
  146. end
  147. -- 延迟向中心服请求数据
  148. local function CommerceAct_LaterTimeQuery(nOperate)
  149. print("[CommerceAct_LaterTimeQuery] 延迟向中心服请求数据开始")
  150. Timer.addLater(ServerCommerceActDefine.COMMERCEACT_INITSERVERTIME, CommerceAct_GetActOpen, nOperate)
  151. end
  152. -- 延迟10分钟开始
  153. local function CommerceAct_LaterBeginAct()
  154. if not tCommerceActInfo then
  155. return
  156. end
  157. tCommerceActInfo.isRun = true
  158. CommerceAct_Begin()
  159. end
  160. -- 检查活动是否过期
  161. local function CommerceAct_CheckActIsOverTime()
  162. local tCommerceDBInfo = CommonDB.GetCommerceActInfo()
  163. if not tCommerceDBInfo or nil == _G.next(tCommerceDBInfo) then
  164. return true
  165. end
  166. local nEndTime = tCommerceDBInfo.nEndTime
  167. local nNowTime = os.time()
  168. return nNowTime >= nEndTime
  169. end
  170. -- 检查是否开启下一轮活动
  171. local function CommerceAct_CanOpenNext()
  172. local tCommerceDBInfo = CommonDB.GetCommerceActInfo()
  173. if not tCommerceDBInfo or nil == _G.next(tCommerceDBInfo) then
  174. return true
  175. end
  176. local nDiffDay = Util.diffDay(tCommerceDBInfo.nEndTime)
  177. if nDiffDay >= ServerCommerceActDefine.COMMERCEACT_NEXTDAY then
  178. return true
  179. end
  180. return false
  181. end
  182. -- 创建通用DB数据
  183. local function CommerceAct_CreateCommonDB()
  184. local nNowTime = os.time()
  185. local tCommerceInfo = CommonDB.GetCommerceActInfo()
  186. local nEndTime = nNowTime + ServerCommerceActDefine.COMMERCEACT_LASTDAY * 86400
  187. local tEndDate = os.date("*t",nEndTime)
  188. tEndDate.hour = ServerCommerceActDefine.COMMERCEACT_ENDTIME
  189. tEndDate.min = 0
  190. tEndDate.sec = 0
  191. nEndTime = os.time(tEndDate)
  192. local tDBData = {
  193. nBeginTime = nNowTime,
  194. nEndTime = nEndTime,
  195. nPoint = 0,
  196. nSendRankMail = false,
  197. }
  198. if not tCommerceInfo or nil == _G.next(tCommerceInfo) then
  199. tDBData.nBatchID = 1
  200. else
  201. tDBData.nBatchID = tDBData.nBatchID + 1
  202. end
  203. CommonDB.SetCommerceActInfo(tDBData)
  204. end
  205. -- 创建缓存数据
  206. local function CommerceAct_CreateCacheInfo(nOpen, bLater)
  207. local tCommerceInfo = CommonDB.GetCommerceActInfo()
  208. if not tCommerceInfo or nil == _G.next(tCommerceInfo) then
  209. print("[CommerceAct_CreateCacheInfo] 为什么会不存在数据\n")
  210. return
  211. end
  212. tCommerceActInfo = {}
  213. tCommerceActInfo.nStartTime = tCommerceInfo.nBeginTime
  214. tCommerceActInfo.nEendTime = tCommerceInfo.nEndTime
  215. tCommerceActInfo.isRun = bLater == true and false or true
  216. tCommerceActInfo.nOpen = nOpen
  217. tCommerceActInfo.nBatchID = tCommerceInfo.nBatchID
  218. print("[CommerceAct_CreateCacheInfo] 创建缓存数据 nStartTime = "..tCommerceActInfo.nStartTime.." nEendTime = "..tCommerceActInfo.nEendTime
  219. .." nOpen = "..tCommerceActInfo.nOpen.." nBatchID = "
  220. ..tCommerceActInfo.nBatchID.." isRun = "..(tCommerceActInfo.isRun == true and 1 or 0))
  221. if bLater == true then
  222. Timer.addLater(ServerCommerceActDefine.COMMERCEACT_BEGINDELATTIME, CommerceAct_LaterBeginAct)
  223. end
  224. end
  225. -- 清理排行榜数据
  226. local function CommerceAct_ClearRankInfo()
  227. ServerCommerceMiddle.CommerceMiddle_ClearRank()
  228. end
  229. -- 起服初始化数据
  230. local function CommerceAct_ActCheckOpen_InitServer(nOpen, nOperate, nServerKey)
  231. if ServerCommerceActDefine.COMMERCEACT_NOOPEN ~= nOpen then
  232. local tCommerceInfo = CommonDB.GetCommerceActInfo()
  233. -- 不存在数据
  234. if not tCommerceInfo or nil == _G.next(tCommerceInfo) then
  235. print("[CommerceAct_ActCheckOpen_InitServer] 不存在commonDB数据开始创建")
  236. CommerceAct_CreateCommonDB()
  237. else
  238. -- 存在数据检查是否结束
  239. if true == CommerceAct_CheckActIsOverTime() then
  240. local bOpenNext = CommerceAct_CanOpenNext()
  241. if true == bOpenNext then
  242. -- 开启下一轮
  243. if tCommerceInfo.nBatch < ServerCommerceActDefine.COMMERCEACT_ENDBATCH then
  244. CommerveManager_WriteLog("[CommerveManager-onZeroAll] 当前条件满足开启下一轮活动")
  245. CommerceAct_CreateCommonDB()
  246. -- 清理排行榜数据
  247. CommerceAct_ClearRankInfo()
  248. end
  249. end
  250. end
  251. end
  252. local bLater = nOperate == ServerCommerceActDefine.COMMERCEACT_ZERO and true or false
  253. CommerceAct_CreateCacheInfo(nOpen, bLater)
  254. ServerCommerceActRank.CommercerActRank_GetRankServerKey(nServerKey)
  255. ServerCommerceActRank.CommercerActRank_InitServerQueryRank()
  256. end
  257. end
  258. -- 获取玩家当前点数
  259. function CommerceAct_GetHumanPoint(human)
  260. return human.db.ServerCommerce.nPoint
  261. end
  262. -- 设置玩家当前点数
  263. local function CommerceAct_SetHumanPoint(human, nValue)
  264. human.db.ServerCommerce.nPoint = nValue
  265. end
  266. ----------------------------------------- 外部调用开始 -------------------------------------
  267. function onZeroAll(funcID)
  268. return
  269. local nNowTime = os.time()
  270. local tDate = os.date("*t",nNowTime)
  271. -- 活动未开启
  272. if tDate.hour == ServerCommerceActDefine.COMMERCEACT_BEGINTIME then
  273. -- 获取DB数据
  274. local tCommerceDBInfo = CommonDB.GetCommerceActInfo()
  275. if not tCommerceDBInfo or nil == _G.next(tCommerceDBInfo) then
  276. CommerceAct_LaterTimeQuery(ServerCommerceActDefine.COMMERCEACT_ZERO)
  277. return
  278. end
  279. -- 存在DB数据说明已经满足条件了
  280. if true == CommerceAct_CheckActIsOverTime() then
  281. local bOpenNext = CommerceAct_CanOpenNext()
  282. if false == bOpenNext then
  283. return
  284. end
  285. -- 开启下一轮
  286. if tCommerceDBInfo.nBatch < ServerCommerceActDefine.COMMERCEACT_ENDBATCH then
  287. CommerveManager_WriteLog("[CommerveManager-onZeroAll] 当前条件满足开启下一轮活动")
  288. CommerceAct_CreateCommonDB()
  289. -- 存在数据说明时间是满足的
  290. CommerceAct_CreateCacheInfo(ServerCommerceActDefine.COMMERCEACT_OPEN, true)
  291. -- 清理排行榜数据
  292. CommerceAct_ClearRankInfo()
  293. end
  294. end
  295. end
  296. end
  297. function onHour(hour)
  298. return
  299. local nNowTime = os.time()
  300. local tDate = os.date("*t",nNowTime)
  301. if tDate.hour == ServerCommerceActDefine.COMMERCEACT_ENDTIME then
  302. if not tCommerceActInfo or tCommerceActInfo.nOpen == ServerCommerceActDefine.COMMERCEACT_NOOPEN then
  303. return
  304. end
  305. local tCommerceDBInfo = CommonDB.GetCommerceActInfo()
  306. if not tCommerceDBInfo or nil == _G.next(tCommerceDBInfo) then
  307. print("[CommerceAct_onZeroAll] 存在缓存数据, 但是获取不到DB数据")
  308. return
  309. end
  310. local nEndTime = tCommerceDBInfo.nEndTime
  311. if nEndTime <= nNowTime then
  312. -- 活动结束处理
  313. CommerceAct_End()
  314. tCommerceActInfo.nSendRankMail = true
  315. end
  316. end
  317. end
  318. -- 请求活动打开信息
  319. function CommerceAct_GetActOpen(nOperate)
  320. print("[CommerceAct_GetActOpen] 开始向中心服请求活动数据")
  321. ServerCommerceMiddle.CommerceMiddle_IsActOpen(nOperate)
  322. end
  323. -- 中心服回复活动信息
  324. function CommerceAct_ActCheckOpen(nOpen, nOperate, nServerKey)
  325. print("[CommerceAct_ActCheckOpen] 收到活动信息开始处理 nOpen = "..nOpen.." nOperate ="..nOperate)
  326. CommerceAct_ActCheckOpen_InitServer(nOpen, nOperate, nServerKey)
  327. end
  328. -- 起服初始化
  329. function CommerceAct_Init()
  330. return
  331. if _G.is_middle == true then
  332. -- 中心服起服获取信息
  333. ServerCommerceMiddle.CommerceMiddle_InitServer()
  334. return
  335. end
  336. local nNowTime = os.time()
  337. for nID, v in pairs(ServerCommerceCof.CommerceAct) do
  338. if v.moduleFn then
  339. local moduleFn = load("return require(\"" .. v.moduleFn .. "\")")()
  340. if moduleFn then
  341. tCommerceActModuel[nID] = moduleFn
  342. if moduleFn.Init then
  343. local bRet = moduleFn.Init()
  344. if false == bRet then
  345. print("[CommerceAct_Init] 初始化模块数据失败 nID ".. nID)
  346. end
  347. end
  348. print("[CommerceAct_Init] 加载模块成功 name = "..v.name)
  349. else
  350. print("[CommerceAct_Init] 加载模块失败 nID ".. nID)
  351. end
  352. else
  353. print("[CommerceAct_Init] 未配置 name = "..v.name)
  354. end
  355. end
  356. print("[CommerceAct_Init] 延迟进行请求数据操作")
  357. -- 延迟向中心服请求数据
  358. CommerceAct_LaterTimeQuery(ServerCommerceActDefine.COMMERCEACT_SERVEROPEN)
  359. end
  360. -- 是否还在活动期间
  361. function CommerceAct_IsRun()
  362. return false
  363. if not tCommerceActInfo then
  364. return false
  365. end
  366. return tCommerceActInfo.isRun
  367. end
  368. -- 玩家登录
  369. function onLogin(human, funcID)
  370. return
  371. if not human then
  372. return
  373. end
  374. -- 下发活动基础数据
  375. if true == CommerceAct_IsRun() then
  376. local tCommonDBData = CommonDB.GetCommerceActInfo()
  377. if not tCommonDBData or nil == _G.next(tCommonDBData) then
  378. print("[onLogin] 玩家登录不存在对应的数据通用DB数据!!!!")
  379. return
  380. end
  381. -- 不存在数据直接创建
  382. if not human.db.ServerCommerce then
  383. CommerceAct_CreateHumanDB(human)
  384. else
  385. -- 用记在玩家身上的批次 和 CommonDB 中的数据比较
  386. local nOldBatchID = human.db.ServerCommerce.nBatchID
  387. local nNowBatchID = tCommonDBData.nBatchID
  388. if nNowBatchID ~= nOldBatchID then
  389. CommerceAct_CreateHumanDB(human)
  390. end
  391. end
  392. CommerceAct_SendActInfo(human)
  393. for _, module in pairs(tCommerceActModuel) do
  394. if module and module.onLogin then
  395. module.onLogin(human)
  396. end
  397. end
  398. else
  399. -- 不在活动中
  400. local tCommonDBData = CommonDB.GetCommerceActInfo()
  401. if not tCommonDBData or nil == _G.next(tCommonDBData) then
  402. print("[onLogin] 玩家登录不存在对应的数据通用DB数据!!!!")
  403. return
  404. end
  405. -- 不存在对应DB数据
  406. if not human.db.ServerCommerce then
  407. return
  408. end
  409. -- 未发送个人邮件都是未上榜的
  410. local bSendPlayerMail = CommerveManager_GetHumanSendPlayerMail(human)
  411. if false == bSendPlayerMail then
  412. CommerveManager_SetHumanSendPlayerMail(human, true)
  413. ServerCommerceActRank.CommercerActRank_SendHumanMailHumanLogin(human)
  414. end
  415. -- 全服邮件
  416. local bSendServerMail = CommerveManager_GetHumanSendServerMail(human)
  417. if false == bSendServerMail and true == tCommonDBData.bSendServerMail then
  418. CommerveManager_SetHumanSendServerMail(human, true)
  419. ServerCommerceActRank.CommercerActRank_SendServerMailHumanLogin(human)
  420. end
  421. end
  422. end
  423. -- 是否开启
  424. function isOpen(human, YYInfo, funcConfig)
  425. local bRet = CommerceAct_IsRun()
  426. local nRet = bRet and 1 or 0
  427. print("CommerceAct_isOpen 结束 nRet = "..nRet)
  428. return bRet
  429. end
  430. --
  431. function isActive(human, YYInfo, funcConfig)
  432. return not isOpen(human, YYInfo, funcConfig)
  433. end
  434. function isRed(human, YYInfo, funcConfig)
  435. return false
  436. if false == CommerceAct_IsRun() then
  437. return
  438. end
  439. if not human.db.ServerCommerce then
  440. CommerceAct_CreateHumanDB(human)
  441. end
  442. local bRet = false
  443. for _, module in pairs(tCommerceActModuel) do
  444. if module and module.isRed then
  445. bRet = module.isRed(human)
  446. if true == bRet then
  447. break
  448. end
  449. end
  450. end
  451. return bRet
  452. end
  453. function onCharge(human, price, funcID, buyID)
  454. return
  455. if not human then
  456. return
  457. end
  458. if false == CommerceAct_IsRun() then
  459. return
  460. end
  461. if not human.db.ServerCommerce then
  462. CommerceAct_CreateHumanDB(human)
  463. end
  464. print("[onCharge] 跨服商业活动 玩家充值回调开始 name = "..human.db.name.." price = "..price)
  465. for _, module in pairs(tCommerceActModuel) do
  466. if module and module.onCharge then
  467. module.onCharge(human, price, funcID, buyID)
  468. end
  469. end
  470. local tBuyCfg = BuyConf.buy[buyID]
  471. if tBuyCfg then
  472. local region = human.region or "CN"
  473. local nPoint = tBuyCfg[region]
  474. CommerveManager_AddServerPoint(nPoint)
  475. CommerveManager_AddHumanPint(human, nPoint)
  476. end
  477. end
  478. -- 增加整个服务器的点数
  479. function CommerveManager_AddServerPoint(nAddPoint)
  480. local tCommonDBData = CommonDB.GetCommerceActInfo()
  481. local nNewPoint = tCommonDBData.nPoint + nAddPoint
  482. CommonDB.SetCommerceActInfo_Point(nNewPoint)
  483. print("[CommerveManager_AddServerPoint] 增加整个服务器的点数 nAddPoint = "..nAddPoint.." nNewPoint = "..nNewPoint)
  484. for _, module in pairs(tCommerceActModuel) do
  485. if module and module.onAllPointChange then
  486. module.onAllPointChange()
  487. end
  488. end
  489. end
  490. -- 增加个人积分
  491. function CommerveManager_AddHumanPint(human, nPoint)
  492. local nNowPoint = CommerceAct_GetHumanPoint(human)
  493. local nNewPoint = nNowPoint + nPoint
  494. CommerceAct_SetHumanPoint(human ,nNewPoint)
  495. print("[CommerveManager_AddHumanPint] 增加个人积分 nAddPoint = "..nPoint.." nNewPoint = "..nNewPoint.." name = "..human.db.name)
  496. ServerCommerceActRank.CommercerActRank_HumanPointChange(human, nNewPoint)
  497. end
  498. -- 写日志
  499. function CommerveManager_WriteLog(szLogText, human)
  500. if human then
  501. szLogText = szLogText.." name = "..human.db.name.." id = "..human.db._id
  502. end
  503. Log.write(Log.LOGID_OSS_COMMON_ACT, szLogText)
  504. end
  505. -- 设置全服发送邮件奖励
  506. function CommerveManager_SetCommDBSendMail()
  507. local bSendMail = CommonDB.GetCommerceActInfo_SendServerMail()
  508. if nil == bSendMail then
  509. return
  510. end
  511. CommonDB.SetCommerceActInfo_SendServerMail(true)
  512. end
  513. -- 获取全服发送邮件标识
  514. function CommerveManager_GetCommDBSendMail()
  515. return CommonDB.GetCommerceActInfo_SendServerMail()
  516. end
  517. -- 设置玩家已经获取了全服奖励邮件
  518. function CommerveManager_SetHumanSendServerMail(human, nValue)
  519. human.db.ServerCommerce.bSendServerMail = nValue
  520. end
  521. -- 获取玩家全服奖励邮件状态
  522. function CommerveManager_GetHumanSendServerMail(human)
  523. return human.db.ServerCommerce.bSendServerMail
  524. end
  525. -- 设置玩家已经获取了个人奖励邮件
  526. function CommerveManager_SetHumanSendPlayerMail(human, nValue)
  527. human.db.ServerCommerce.bSendPlayerMail = nValue
  528. end
  529. -- 获取玩家全服奖励邮件状态
  530. function CommerveManager_GetHumanSendPlayerMail(human)
  531. return human.db.ServerCommerce.bSendPlayerMail
  532. end
  533. -- GM 清理数据
  534. function CommerveManager_GMClear(human)
  535. human.db.ServerCommerce =
  536. {
  537. nPoint = 0, -- 当前玩家个人积分
  538. Task = {}, -- 任务信息
  539. Charge = {}, -- 连充豪礼
  540. Shop = {}, -- 战区钜惠
  541. nBatchID = 1, -- 批次
  542. bSendPlayerMail = false, -- 是否发送个人邮件
  543. bSendServerMail = false, -- 是否发送全服邮件
  544. }
  545. for nID, module in pairs(tCommerceActModuel) do
  546. if module and module.CreatDB then
  547. local bRet = module.CreatDB(human)
  548. if false == bRet then
  549. print("[CommerceAct_CreateHumanDB] nID 初始化DB 数据失败 nID = "..nID)
  550. end
  551. end
  552. end
  553. print("[CommerveManager_GMClear] 玩家重置数据完成 name = "..human.db.name)
  554. end
  555. -- GM 增加个人积分
  556. function CommerveManager_GMAddHumanPoint(human, nNum)
  557. CommerveManager_AddHumanPint(human, nNum)
  558. end
  559. -- GM 增加服务器积分
  560. function CommerveManager_GMAddServerPoint(nNum)
  561. CommerveManager_AddServerPoint(nNum)
  562. end
  563. -- GM 发送邮件
  564. function CommerveManager_SendMail()
  565. CommerceAct_End()
  566. end
  567. function CommerceMiddle_AddTaskPoint(human, nNum)
  568. ServerCommerceTask.CommerceTask_AddPoint(human, nNum)
  569. end