-- 支付模块 local log = require "model.log" local common_fun = require "model.common_fun" local module_fun = require "model.module_fun" local currency local function payment(character, receipt, not_check) assert(character) assert(receipt) local module = assert(receipt.module) local brief = assert(receipt.brief) local context = receipt.context local record = {} local detail = common_fun.merge_award(assert(receipt.detail)) local errno = 0 if not not_check then errno = module_fun.paymeny_check(character, detail) end if errno ~= 0 then return errno end local now = {} local debris_list = {} for _, v in ipairs(detail) do local num = v.num local id = v.id local gtype = common_fun.goods_type(id) currency = currency or require "model.currency" if gtype == GOODS_MONEY then local cur = currency.pay_money(character, id, num) table.insert(now, {id = id, num = cur}) end end -- 记录日志 if next(detail) then log.receipt(character, module, brief, context, detail) end --向客户端发送货币 if next(now) then character.send("pay_currency", {now = now, pay = detail}) end if next(debris_list) then character.send("pay_debris_nty", {list = debris_list}) end return 0 end return payment