Selaa lähdekoodia

1.增加GM 2.增加年龄充值限制相关代码

gitxsm 1 päivä sitten
vanhempi
sitoutus
e47aa4db2f

+ 5 - 0
script/common/ProtoID.lua

@@ -1736,6 +1736,7 @@ _ENV[1776]="GC_ZHUANPAN_ONCE_REWARD_QUERY"
 _ENV[1777]="CG_ZHUANPAN_ONCE_REWARD_GET"
 _ENV[1778]="CG_ALL_HERO_BOOK_QUERY"
 _ENV[1779]="GC_ALL_HERO_BOOK_QUERY"
+_ENV[1780]="GC_DRAWCARD_OP2"
 _ENV[1781]="CG_SERVEERCOMMERCE_ACT_BATTLEGROUND_MAINPAGE_QUERY"
 _ENV[1782]="GC_SERVEERCOMMERCE_ACT_BATTLEGROUND_MAINPAGE_QUERY"
 _ENV[1783]="CG_SERVEERCOMMERCE_ACT_BATTLEGROUND_MATCHLIST_QUERY"
@@ -1822,6 +1823,8 @@ _ENV[1899]="CG_ZHUANPAN_TB_ADD_DESKTOP"
 _ENV[1900]="CG_ZHUANPAN_TB_QUERY"
 _ENV[1891]="GC_ZHUANPAN_TB_QUERY"
 _ENV[1892]="CG_ZHUANPAN_TB_REWARD_GET"
+_ENV[1893]="CG_TOPUP_AGE_QUERY"
+_ENV[1894]="GC_TOPUP_AGE_QUERY"
 
 _ENV[1901]="CG_ZHUANPAN_YOUXI_TASK_QUERY"
 _ENV[1902]="GC_ZHUANPAN_YOUXI_TASK_QUERY"
@@ -1834,3 +1837,5 @@ _ENV[1906]="GC_ZHUANPAN_DY_DESKTOP_QUERY"
 _ENV[1907]="CG_BATTLE_HANG_FULL_TIME_QUERY"
 _ENV[1908]="GC_BATTLE_HANG_FULL_TIME_QUERY"
 
+
+

+ 107 - 0
script/module/chat/Gm.lua

@@ -351,6 +351,23 @@ function d3.vipexp(human, val)
 	VipLogic.addExp(human, val)	
 end
 
+-- 设置玩家年龄(测试充值限额):1=8岁以下 2=8~16岁 3=16~18岁 4=18岁以上
+function d3.age(human, val)
+	local ageType = tonumber(val)
+	if not ageType or ageType < 1 or ageType > 4 then
+		return Broadcast.sendErr(human, "参数错误:1=8岁以下 2=8~16岁 3=16~18岁 4=18岁以上")
+	end
+
+	local ageMap = {[1] = 7, [2] = 10, [3] = 17, [4] = 18}
+	human.db.age = ageMap[ageType]
+
+	local AgeLimitLogic = require("topup.AgeLimitLogic")
+	if human.fd then
+		AgeLimitLogic.query(human)
+	end
+	Broadcast.sendErr(human, "年龄已设置为" .. human.db.age .. "岁")
+end
+
 function d3.it1(human, value)
 	value = tonumber(value)
 	if not value then return end
@@ -1239,6 +1256,33 @@ function d3.updaily(human)
     ObjHuman.updateDaily(human, true)
 end
 
+-- 模拟跨月,重置月累充等跨月数据
+function d3.kuayue(human)
+	local oldMonthTopup = human.db.topupAccountMonth or 0
+
+	local t = os.date("*t")
+	t.month = t.month - 1
+	if t.month <= 0 then
+		t.month = 12
+		t.year = t.year - 1
+	end
+	human.db.update_daily_time = os.time(t)
+
+	-- 跨月重置月累充,与 ObjHuman.updateDaily 保持一致
+	if human.db.update_daily_time and Util.isSameMonth(human.db.update_daily_time) ~= true then
+		human.db.topupAccountMonth = nil
+	end
+
+	ObjHuman.updateDaily(human, true)
+
+	local AgeLimitLogic = require("topup.AgeLimitLogic")
+	if human.fd then
+		AgeLimitLogic.query(human)
+	end
+
+	send(human, string.format("跨月成功,月累充 %d -> %d", oldMonthTopup, human.db.topupAccountMonth or 0))
+end
+
 function d3.clguide(human)
 	human.db.noguide = nil
     human.db.guide = nil
@@ -2135,6 +2179,68 @@ function d3.dayaddHuoYue(human, nNum)
 	day.Gm_AddHuoYue(human, nNum)
 end
 
+-- 批量获取英雄:getAllHero [星级] [等级] [grade] [camp]
+-- 星级/等级/camp 未填时使用默认值;grade 未填时增加 grade>=4 的英雄,填写时按 grade 精确匹配
+function d3.getAllHero(human, val)
+	val = val or ""
+	local tb = Util.split(val, " ")
+	local HeroLogic = require("hero.HeroLogic")
+	local HERO_MAX_STAR = 20
+	local DEFAULT_MAX_LV = 9999
+
+	local star
+	if tb[1] == nil or tb[1] == "" then
+		star = HERO_MAX_STAR
+	else
+		star = tonumber(tb[1])
+		if not star or star <= 0 then
+			return Broadcast.sendErr(human, "星级参数错误,必须大于0")
+		end
+	end
+
+	local lv
+	if tb[2] == nil or tb[2] == "" then
+		lv = DEFAULT_MAX_LV
+	else
+		lv = tonumber(tb[2])
+		if not lv or lv <= 0 then
+			return Broadcast.sendErr(human, "等级参数错误,必须大于0")
+		end
+	end
+
+	local useDefaultGrade = (tb[3] == nil or tb[3] == "")
+	local grade
+	if not useDefaultGrade then
+		grade = tonumber(tb[3])
+		if not grade or grade <= 0 or grade > 5 then
+			return Broadcast.sendErr(human, "grade参数错误,必须在1~5之间")
+		end
+	end
+
+	local camp
+	if tb[4] ~= nil and tb[4] ~= "" then
+		camp = tonumber(tb[4])
+		if not camp or camp < 1 or camp > 5 then
+			return Broadcast.sendErr(human, "种族参数错误,必须在1~5之间")
+		end
+	end
+
+	local addCnt = 0
+	for id, hero in pairs(HeroTable) do
+		local gradeMatch
+		if useDefaultGrade then
+			gradeMatch = hero.grade >= 4
+		else
+			gradeMatch = hero.grade == grade
+		end
+		local campMatch = not camp or hero.camp == camp
+		if gradeMatch and campMatch then
+			d3.heroadd(human, string.format("%d %d %d %d", id, 1, lv, star))
+			addCnt = addCnt + 1
+		end
+	end
+end
+
 local allHeroIds= {}
 -- 一键获取所有资源--
 function d3.getAll(human)
@@ -2148,6 +2254,7 @@ function d3.getAll(human)
 		d3.heroadd(human, val)
 	end
 	local items = {
+		{31,999999},
 		{101, 1000000000},
 		{111, 1000000000},
 		{112, 1000000},

+ 97 - 0
script/module/topup/AgeLimitLogic.lua

@@ -0,0 +1,97 @@
+-------------------------------------------------
+-- 未成年人充值限额(依据玩家年龄)
+-------------------------------------------------
+
+local Util = require("common.Util")
+local Lang = require("common.Lang")
+local Msg = require("core.Msg")
+local ObjHuman = require("core.ObjHuman")
+local Broadcast = require("broadcast.Broadcast")
+
+local BUY_PRICE_ONE2 = 50    -- 八周岁以上未满十六周岁,单次上限
+local BUY_PRICE_MONTH2 = 200 -- 八周岁以上未满十六周岁,每月累计上限
+local BUY_PRICE_ONE3 = 100   -- 十六周岁以上未满十八周岁,单次上限
+local BUY_PRICE_MONTH3 = 400 -- 十六周岁以上未满十八周岁,每月累计上限
+
+-- 充值限额类型
+TOPUP_LIMIT_NONE = 0    -- 成年人或未设置年龄,无限制
+TOPUP_LIMIT_FORBID = 1  -- 不满八周岁,禁止充值
+TOPUP_LIMIT_MINOR = 2   -- 八周岁以上未满十八周岁,有单次/月累计限额
+
+-- maxMonthTopup 协议约定:-1 无限制,0 禁止充值,>0 为月累计上限
+TOPUP_MONTH_NO_LIMIT = -1
+
+local function getAge(human)
+	return human.db.age
+end
+
+-- 返回:limitType, maxSingleTopup, maxMonthTopup
+local function getLimitByAge(age)
+	if not age or age >= 18 then
+		return TOPUP_LIMIT_NONE, 0, TOPUP_MONTH_NO_LIMIT
+	end
+	if age < 8 then
+		return TOPUP_LIMIT_FORBID, 0, 0
+	elseif age < 16 then
+		return TOPUP_LIMIT_MINOR, BUY_PRICE_ONE2, BUY_PRICE_MONTH2
+	elseif age < 18 then
+		return TOPUP_LIMIT_MINOR, BUY_PRICE_ONE3, BUY_PRICE_MONTH3
+	end
+	return TOPUP_LIMIT_NONE, 0, TOPUP_MONTH_NO_LIMIT
+end
+
+function getLimitInfo(human)
+	local age = getAge(human) or 0
+	local monthTopup = human.db.topupAccountMonth or 0
+	local limitType, maxSingleTopup, maxMonthTopup = getLimitByAge(getAge(human))
+	return age, monthTopup, maxMonthTopup, maxSingleTopup, limitType
+end
+
+local function checkBuyPrice(human, price, oneLimit, monthLimit, ageTip)
+	if price > oneLimit then
+		Broadcast.sendErr(human, Util.format(Lang.BUY_CHECK_ERR_FCM_AGE, ageTip))
+		Broadcast.sendErr(human, Util.format(Lang.BUY_CHECK_ERR_FCM_ONE, oneLimit))
+		return false
+	end
+
+	local sum = human.db.topupAccountMonth or 0
+	if (sum + price) > monthLimit then
+		Broadcast.sendErr(human, Util.format(Lang.BUY_CHECK_ERR_FCM_AGE, ageTip))
+		Broadcast.sendErr(human, Util.format(Lang.BUY_CHECK_ERR_FCM_MONTH, monthLimit))
+		return false
+	end
+	return true
+end
+
+function checkCanBuy(human, price)
+	if not human.db then
+		return true
+	end
+
+	ObjHuman.updateDaily(human)
+
+	local limitType, maxSingleTopup, maxMonthTopup = getLimitByAge(getAge(human))
+	if limitType == TOPUP_LIMIT_NONE then
+		return true
+	end
+
+	if limitType == TOPUP_LIMIT_FORBID then
+		Broadcast.sendErr(human, Util.format(Lang.BUY_CHECK_ERR_FCM_AGE, 8))
+		Broadcast.sendErr(human, Lang.BUY_CHECK_ERR_FCM_NOCHARGE)
+		return false
+	end
+
+	local ageTip = maxMonthTopup == BUY_PRICE_MONTH2 and 16 or 18
+	return checkBuyPrice(human, price, maxSingleTopup, maxMonthTopup, ageTip)
+end
+
+function query(human)
+	ObjHuman.updateDaily(human)
+
+	local age, monthTopup, maxMonthTopup = getLimitInfo(human)
+	local msgRet = Msg.gc.GC_TOPUP_AGE_QUERY
+	msgRet.age = age
+	msgRet.monthTopup = monthTopup
+	msgRet.maxMonthTopup = maxMonthTopup
+	Msg.send(msgRet, human.fd)
+end

+ 26 - 1
script/module/topup/BuyLogic.lua

@@ -51,6 +51,7 @@ local CommonDefine = require("common.CommonDefine")
 local ZhuanpanGift = require("zhuanpan.ZhuanpanGift")
 local VoucherInvest = require("voucher.VoucherInvest")
 local CommonActLoginGift = require("absAct.CommonActLoginGift")
+local AgeLimitLogic = require("topup.AgeLimitLogic")
 
 BUY_CODE_NORMAL = 0   -- 正常调平台的充值接口
 BUY_CODE_WX_KEFU = 1  -- 微信小程序客服充值接口
@@ -399,6 +400,11 @@ function checkBuy(human, ret)
 			return false
 		end
 
+		local buyNum = ret.cnt or 1
+		if not AgeLimitLogic.checkCanBuy(human, ret.money * buyNum) then
+			return false
+		end
+
 		return true
 	end
 	ret.result = 8
@@ -435,7 +441,19 @@ function buy(human, arg, nolog)
 		buyID = arg
 		buyNum = 1
 	end
-    local buyConf = BuyExcel[buyID]	
+    local buyConf = BuyExcel[buyID]
+	if not buyConf then return end
+
+	local price
+	if type(arg) == "table" then
+		price = arg.price or arg.money or getRealPrice(human, buyID, human.region or "CN")
+	else
+		price = getRealPrice(human, buyID, human.region or "CN")
+	end
+	if price and not AgeLimitLogic.checkCanBuy(human, price * buyNum) then
+		return
+	end
+
 	local isFirst = getIsFirst(human, buyID)
     local cnt = getBuyCnt(human, buyID)
     local buyDB = human.db.buy
@@ -464,6 +482,10 @@ function buy(human, arg, nolog)
 		afterCharge(human, arg, buyID, buyConf, buyNum)
 	end
 
+	if human.fd then
+		AgeLimitLogic.query(human)
+	end
+
 	if false == GetFirstMark(human) then
 		MainDianLogic.MaiDian_Begin(human, MaiDianDefine.MAIDIAN_TYPE_BUY, {nValue = buyID})
 		SetFirstMark(human, 1)
@@ -548,6 +570,9 @@ function checkCanBuy(human, buyID)
 	if price and not FcmLogic.checkCanBuy(human, price) then
 		return
 	end
+	if price and not AgeLimitLogic.checkCanBuy(human, price) then
+		return
+	end
 
 	if SceneHandler.canCharge(human) ~= true then
 		return Broadcast.sendErr(human, Lang.CHARGE_CLOSE_TIP)

+ 5 - 0
script/module/topup/Handler.lua

@@ -1,5 +1,6 @@
 local TopupLogic = require("topup.TopupLogic")
 local BuyLogic = require("topup.BuyLogic")
+local AgeLimitLogic = require("topup.AgeLimitLogic")
 
 function CG_TOPUP_QUERY(human,msg)
 	TopupLogic.query(human)
@@ -13,3 +14,7 @@ function CG_FIREWORKS_QUERY(human,msg)
     TopupLogic.DurationofBonus(human)
 end
 
+function CG_TOPUP_AGE_QUERY(human, msg)
+	AgeLimitLogic.query(human)
+end
+

+ 9 - 0
script/module/topup/Proto.lua

@@ -58,3 +58,12 @@ GC_FIREWORKS_SHOW={
 	{"buffDuration", 1, "int"}, -- buff时效(单位:秒)
 	{"playerName",   1, "string"}  -- 新增:玩家名字
 }
+
+-- 查询玩家年龄及当月充值限额
+CG_TOPUP_AGE_QUERY = {
+}
+GC_TOPUP_AGE_QUERY = {
+	{"age",           1, "short"},    -- 玩家年龄
+	{"monthTopup",    1, "double"}, -- 当月累充金额
+	{"maxMonthTopup", 1, "double"}, -- 当月最大可充值金额,-1无限制,0禁止充值,>0为月累计上限
+}

+ 7 - 3
script/module/voucher/VoucherShopLogic.lua

@@ -21,6 +21,7 @@ local HeroLogic = require("hero.HeroLogic")
 local BagLogic = require("bag.BagLogic")
 local Log = require("common.Log")
 local BuyLogic = require("topup.BuyLogic")
+local AgeLimitLogic = require("topup.AgeLimitLogic")
 local YunYingLogic = require("yunying.YunYingLogic")
 local TopupLogic =require("topup.TopupLogic")
 local TriggerDefine = require("trigger.TriggerDefine")
@@ -421,13 +422,16 @@ function VoucherShop_BuyItem(human, nBuyID, nBuyNum)
         end
     end
 
-    -- 删物品
-    BagLogic.delItem(human, VoucherShopDefine.VOUCHERITME_ID, nDelVoucherNum, "voucher_use")
-
     local reallyPrice = tTrueBuyConfig.CN
     if human.phpChanelID and table.find(CommonDefine.SEA_CHANNEL_ARR, human.phpChanelID) then
 		reallyPrice = tTrueBuyConfig.US
 	end
+    if not AgeLimitLogic.checkCanBuy(human, reallyPrice * nBuyNum) then
+        return
+    end
+
+    -- 删物品
+    BagLogic.delItem(human, VoucherShopDefine.VOUCHERITME_ID, nDelVoucherNum, "voucher_use")
 
     -- 发道具
     local tBuyInfo =