ServerCommerceManager.lua 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690
  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. do
  269. return
  270. end
  271. local nNowTime = os.time()
  272. local tDate = os.date("*t",nNowTime)
  273. -- 活动未开启
  274. if tDate.hour == ServerCommerceActDefine.COMMERCEACT_BEGINTIME then
  275. -- 获取DB数据
  276. local tCommerceDBInfo = CommonDB.GetCommerceActInfo()
  277. if not tCommerceDBInfo or nil == _G.next(tCommerceDBInfo) then
  278. CommerceAct_LaterTimeQuery(ServerCommerceActDefine.COMMERCEACT_ZERO)
  279. return
  280. end
  281. -- 存在DB数据说明已经满足条件了
  282. if true == CommerceAct_CheckActIsOverTime() then
  283. local bOpenNext = CommerceAct_CanOpenNext()
  284. if false == bOpenNext then
  285. return
  286. end
  287. -- 开启下一轮
  288. if tCommerceDBInfo.nBatch < ServerCommerceActDefine.COMMERCEACT_ENDBATCH then
  289. CommerveManager_WriteLog("[CommerveManager-onZeroAll] 当前条件满足开启下一轮活动")
  290. CommerceAct_CreateCommonDB()
  291. -- 存在数据说明时间是满足的
  292. CommerceAct_CreateCacheInfo(ServerCommerceActDefine.COMMERCEACT_OPEN, true)
  293. -- 清理排行榜数据
  294. CommerceAct_ClearRankInfo()
  295. end
  296. end
  297. end
  298. end
  299. function onHour(hour)
  300. do
  301. return
  302. end
  303. local nNowTime = os.time()
  304. local tDate = os.date("*t",nNowTime)
  305. if tDate.hour == ServerCommerceActDefine.COMMERCEACT_ENDTIME then
  306. if not tCommerceActInfo or tCommerceActInfo.nOpen == ServerCommerceActDefine.COMMERCEACT_NOOPEN then
  307. return
  308. end
  309. local tCommerceDBInfo = CommonDB.GetCommerceActInfo()
  310. if not tCommerceDBInfo or nil == _G.next(tCommerceDBInfo) then
  311. print("[CommerceAct_onZeroAll] 存在缓存数据, 但是获取不到DB数据")
  312. return
  313. end
  314. local nEndTime = tCommerceDBInfo.nEndTime
  315. if nEndTime <= nNowTime then
  316. -- 活动结束处理
  317. CommerceAct_End()
  318. tCommerceActInfo.nSendRankMail = true
  319. end
  320. end
  321. end
  322. -- 请求活动打开信息
  323. function CommerceAct_GetActOpen(nOperate)
  324. print("[CommerceAct_GetActOpen] 开始向中心服请求活动数据")
  325. ServerCommerceMiddle.CommerceMiddle_IsActOpen(nOperate)
  326. end
  327. -- 中心服回复活动信息
  328. function CommerceAct_ActCheckOpen(nOpen, nOperate, nServerKey)
  329. print("[CommerceAct_ActCheckOpen] 收到活动信息开始处理 nOpen = "..nOpen.." nOperate ="..nOperate)
  330. CommerceAct_ActCheckOpen_InitServer(nOpen, nOperate, nServerKey)
  331. end
  332. -- 起服初始化
  333. function CommerceAct_Init()
  334. do
  335. return
  336. end
  337. if _G.is_middle == true then
  338. -- 中心服起服获取信息
  339. ServerCommerceMiddle.CommerceMiddle_InitServer()
  340. return
  341. end
  342. local nNowTime = os.time()
  343. for nID, v in pairs(ServerCommerceCof.CommerceAct) do
  344. if v.moduleFn then
  345. local moduleFn = load("return require(\"" .. v.moduleFn .. "\")")()
  346. if moduleFn then
  347. tCommerceActModuel[nID] = moduleFn
  348. if moduleFn.Init then
  349. local bRet = moduleFn.Init()
  350. if false == bRet then
  351. print("[CommerceAct_Init] 初始化模块数据失败 nID ".. nID)
  352. end
  353. end
  354. print("[CommerceAct_Init] 加载模块成功 name = "..v.name)
  355. else
  356. print("[CommerceAct_Init] 加载模块失败 nID ".. nID)
  357. end
  358. else
  359. print("[CommerceAct_Init] 未配置 name = "..v.name)
  360. end
  361. end
  362. print("[CommerceAct_Init] 延迟进行请求数据操作")
  363. -- 延迟向中心服请求数据
  364. CommerceAct_LaterTimeQuery(ServerCommerceActDefine.COMMERCEACT_SERVEROPEN)
  365. end
  366. -- 是否还在活动期间
  367. function CommerceAct_IsRun()
  368. if not tCommerceActInfo then
  369. return false
  370. end
  371. return false
  372. -- return tCommerceActInfo.isRun
  373. end
  374. -- 玩家登录
  375. function onLogin(human, funcID)
  376. do
  377. return
  378. end
  379. if not human then
  380. return
  381. end
  382. -- 下发活动基础数据
  383. if true == CommerceAct_IsRun() then
  384. local tCommonDBData = CommonDB.GetCommerceActInfo()
  385. if not tCommonDBData or nil == _G.next(tCommonDBData) then
  386. print("[onLogin] 玩家登录不存在对应的数据通用DB数据!!!!")
  387. return
  388. end
  389. -- 不存在数据直接创建
  390. if not human.db.ServerCommerce then
  391. CommerceAct_CreateHumanDB(human)
  392. else
  393. -- 用记在玩家身上的批次 和 CommonDB 中的数据比较
  394. local nOldBatchID = human.db.ServerCommerce.nBatchID
  395. local nNowBatchID = tCommonDBData.nBatchID
  396. if nNowBatchID ~= nOldBatchID then
  397. CommerceAct_CreateHumanDB(human)
  398. end
  399. end
  400. CommerceAct_SendActInfo(human)
  401. for _, module in pairs(tCommerceActModuel) do
  402. if module and module.onLogin then
  403. module.onLogin(human)
  404. end
  405. end
  406. else
  407. -- 不在活动中
  408. local tCommonDBData = CommonDB.GetCommerceActInfo()
  409. if not tCommonDBData or nil == _G.next(tCommonDBData) then
  410. print("[onLogin] 玩家登录不存在对应的数据通用DB数据!!!!")
  411. return
  412. end
  413. -- 不存在对应DB数据
  414. if not human.db.ServerCommerce then
  415. return
  416. end
  417. -- 未发送个人邮件都是未上榜的
  418. local bSendPlayerMail = CommerveManager_GetHumanSendPlayerMail(human)
  419. if false == bSendPlayerMail then
  420. CommerveManager_SetHumanSendPlayerMail(human, true)
  421. ServerCommerceActRank.CommercerActRank_SendHumanMailHumanLogin(human)
  422. end
  423. -- 全服邮件
  424. local bSendServerMail = CommerveManager_GetHumanSendServerMail(human)
  425. if false == bSendServerMail and true == tCommonDBData.bSendServerMail then
  426. CommerveManager_SetHumanSendServerMail(human, true)
  427. ServerCommerceActRank.CommercerActRank_SendServerMailHumanLogin(human)
  428. end
  429. end
  430. end
  431. -- 是否开启
  432. function isOpen(human, YYInfo, funcConfig)
  433. local bRet = CommerceAct_IsRun()
  434. local nRet = bRet and 1 or 0
  435. print("CommerceAct_isOpen 结束 nRet = "..nRet)
  436. return bRet
  437. end
  438. --
  439. function isActive(human, YYInfo, funcConfig)
  440. return not isOpen(human, YYInfo, funcConfig)
  441. end
  442. function isRed(human, YYInfo, funcConfig)
  443. return false
  444. if false == CommerceAct_IsRun() then
  445. return
  446. end
  447. if not human.db.ServerCommerce then
  448. CommerceAct_CreateHumanDB(human)
  449. end
  450. local bRet = false
  451. for _, module in pairs(tCommerceActModuel) do
  452. if module and module.isRed then
  453. bRet = module.isRed(human)
  454. if true == bRet then
  455. break
  456. end
  457. end
  458. end
  459. return bRet
  460. end
  461. function onCharge(human, price, funcID, buyID)
  462. do
  463. return
  464. end
  465. if not human then
  466. return
  467. end
  468. if false == CommerceAct_IsRun() then
  469. return
  470. end
  471. if not human.db.ServerCommerce then
  472. CommerceAct_CreateHumanDB(human)
  473. end
  474. print("[onCharge] 跨服商业活动 玩家充值回调开始 name = "..human.db.name.." price = "..price)
  475. for _, module in pairs(tCommerceActModuel) do
  476. if module and module.onCharge then
  477. module.onCharge(human, price, funcID, buyID)
  478. end
  479. end
  480. local tBuyCfg = BuyConf.buy[buyID]
  481. if tBuyCfg then
  482. local region = human.region or "CN"
  483. local nPoint = tBuyCfg[region]
  484. CommerveManager_AddServerPoint(nPoint)
  485. CommerveManager_AddHumanPint(human, nPoint)
  486. end
  487. end
  488. -- 增加整个服务器的点数
  489. function CommerveManager_AddServerPoint(nAddPoint)
  490. local tCommonDBData = CommonDB.GetCommerceActInfo()
  491. local nNewPoint = tCommonDBData.nPoint + nAddPoint
  492. CommonDB.SetCommerceActInfo_Point(nNewPoint)
  493. print("[CommerveManager_AddServerPoint] 增加整个服务器的点数 nAddPoint = "..nAddPoint.." nNewPoint = "..nNewPoint)
  494. for _, module in pairs(tCommerceActModuel) do
  495. if module and module.onAllPointChange then
  496. module.onAllPointChange()
  497. end
  498. end
  499. end
  500. -- 增加个人积分
  501. function CommerveManager_AddHumanPint(human, nPoint)
  502. local nNowPoint = CommerceAct_GetHumanPoint(human)
  503. local nNewPoint = nNowPoint + nPoint
  504. CommerceAct_SetHumanPoint(human ,nNewPoint)
  505. print("[CommerveManager_AddHumanPint] 增加个人积分 nAddPoint = "..nPoint.." nNewPoint = "..nNewPoint.." name = "..human.db.name)
  506. ServerCommerceActRank.CommercerActRank_HumanPointChange(human, nNewPoint)
  507. end
  508. -- 写日志
  509. function CommerveManager_WriteLog(szLogText, human)
  510. if human then
  511. szLogText = szLogText.." name = "..human.db.name.." id = "..human.db._id
  512. end
  513. Log.write(Log.LOGID_OSS_COMMON_ACT, szLogText)
  514. end
  515. -- 设置全服发送邮件奖励
  516. function CommerveManager_SetCommDBSendMail()
  517. local bSendMail = CommonDB.GetCommerceActInfo_SendServerMail()
  518. if nil == bSendMail then
  519. return
  520. end
  521. CommonDB.SetCommerceActInfo_SendServerMail(true)
  522. end
  523. -- 获取全服发送邮件标识
  524. function CommerveManager_GetCommDBSendMail()
  525. return CommonDB.GetCommerceActInfo_SendServerMail()
  526. end
  527. -- 设置玩家已经获取了全服奖励邮件
  528. function CommerveManager_SetHumanSendServerMail(human, nValue)
  529. human.db.ServerCommerce.bSendServerMail = nValue
  530. end
  531. -- 获取玩家全服奖励邮件状态
  532. function CommerveManager_GetHumanSendServerMail(human)
  533. return human.db.ServerCommerce.bSendServerMail
  534. end
  535. -- 设置玩家已经获取了个人奖励邮件
  536. function CommerveManager_SetHumanSendPlayerMail(human, nValue)
  537. human.db.ServerCommerce.bSendPlayerMail = nValue
  538. end
  539. -- 获取玩家全服奖励邮件状态
  540. function CommerveManager_GetHumanSendPlayerMail(human)
  541. return human.db.ServerCommerce.bSendPlayerMail
  542. end
  543. -- GM 清理数据
  544. function CommerveManager_GMClear(human)
  545. human.db.ServerCommerce =
  546. {
  547. nPoint = 0, -- 当前玩家个人积分
  548. Task = {}, -- 任务信息
  549. Charge = {}, -- 连充豪礼
  550. Shop = {}, -- 战区钜惠
  551. nBatchID = 1, -- 批次
  552. bSendPlayerMail = false, -- 是否发送个人邮件
  553. bSendServerMail = false, -- 是否发送全服邮件
  554. }
  555. for nID, module in pairs(tCommerceActModuel) do
  556. if module and module.CreatDB then
  557. local bRet = module.CreatDB(human)
  558. if false == bRet then
  559. print("[CommerceAct_CreateHumanDB] nID 初始化DB 数据失败 nID = "..nID)
  560. end
  561. end
  562. end
  563. print("[CommerveManager_GMClear] 玩家重置数据完成 name = "..human.db.name)
  564. end
  565. -- GM 增加个人积分
  566. function CommerveManager_GMAddHumanPoint(human, nNum)
  567. CommerveManager_AddHumanPint(human, nNum)
  568. end
  569. -- GM 增加服务器积分
  570. function CommerveManager_GMAddServerPoint(nNum)
  571. CommerveManager_AddServerPoint(nNum)
  572. end
  573. -- GM 发送邮件
  574. function CommerveManager_SendMail()
  575. CommerceAct_End()
  576. end
  577. function CommerceMiddle_AddTaskPoint(human, nNum)
  578. ServerCommerceTask.CommerceTask_AddPoint(human, nNum)
  579. end