ro-table/Assets/Resources/Script/Com/Data/ActivityEvent/AELotteryDiscountData.txt
2025-06-04 05:12:01 +08:00

51 lines
1.3 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

AELotteryDiscountData = class("AELotteryDiscountData")
AELotteryDiscountData.CoinType = {
Coin = ActivityEvent_pb.ECoinType_Coin,
Ticket = ActivityEvent_pb.ECoinType_Ticket,
}
function AELotteryDiscountData:ctor(data)
self:SetData(data)
end
function AELotteryDiscountData:SetData(data)
if data ~= nil then
self.id = data.id
self.beginTime = data.begintime
self.endTime = data.endtime
local discount = data.lotterydiscount
self.type = discount.lotterytype
self.cointype = discount.cointype --貨幣型別
self.usertype = discount.usertype --適用對像
self.discount = discount.discount --折扣70表示7折
self.count = discount.count --折扣次數
self.yearmonth = discount.yearmonth
self.year = math.floor(self.yearmonth / 100)
self.month = self.yearmonth % 100
self.usedCount = 0 --已用折扣次數
end
end
function AELotteryDiscountData:SetUsedCount(count)
self.usedCount = count
end
function AELotteryDiscountData:IsInActivity()
if self.beginTime ~= nil and self.endTime ~= nil then
local server = ServerTime.CurServerTime()/1000
return server >= self.beginTime and server <= self.endTime
else
return true
end
end
--獲取折扣值
function AELotteryDiscountData:GetDiscount()
if self:IsInActivity() and (self.count ~= 0 and self.usedCount < self.count) then
return self.discount
end
return 100
end