123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- --[[
- Descripttion:支付统计
- version:
- Author: Neo,Huang
- Date: 2023-11-15 22:34:35
- LastEditors: Neo,Huang
- LastEditTime: 2023-11-15 23:57:03
- --]]
- local code = require("code")
- local gameConst = require("const.gameConst")
- local util_user = require("utils.util_user")
- local shopAdapt = require("adapt.shopAdapt")
- local payData = require("data.pay")
- local bagData = require("data.bag")
- local root = class("pay", require("base.baseModule"))
- function root:ctor(uid)
- root.super.ctor(self, uid, "pay", "uid", true)
- self.uid = uid
- end
- function root:mysql_get_init_columns()
- return {
- uid = "int(11) NOT NULL COMMENT '用户id'",
- totalAmount = "int(10) DEFAULT NULL COMMENT '总支付金额(单位分)'",
- goodsList = "JSON COMMENT '支付商品信息列表'",
- dayInfo = "JSON COMMENT '当天支付商品信息'",
- goodsPreCustomItems = "JSON COMMENT '定制商品信息列表'",
- goodsPayCustomItems = "JSON COMMENT '定制商品信息列表'"
- }
- end
- -- 发放商品物品
- function root:dispatch_goods_items(role, gid)
- local uid = self.uid
- local conf = gid and shopAdapt:goods_get_info(gid)
- if not conf then
- return code.PARAMTER_ERROR
- end
- -- 获取物品
- local eventId = string.format("shop-pay-%s", tostring(gid))
- local items = payData:get_goods_pre_custom_items(uid, gid) or conf.items
- bagData:add_items(uid, items, eventId)
- -- 定制信息
- if payData:del_goods_pre_custom_items(uid, gid) then
- payData:update_goods_pay_custom_items(uid, gid, items)
- end
- -- 通知前端 - 商品发货
- local pack = {goodsId = gid, items = items}
- util_user:user_proto_notify(uid, "on_shop_buy_goods", pack)
- -- 事件
- local evtParams = {
- times = 1,
- gid = gid
- }
- evtParams.isFirstPay = payData:is_first_pay(uid)
- evtParams.isGoodsFirstPay = payData:is_goods_first_pay(uid, gid)
- if not is_empty(conf.rmb) then
- payData:user_add_pay(uid, gid, conf.rmb)
- evtParams.amount = conf.rmb
- evtParams.totalAmount = self:redis_get_key_info("totalAmount")
- end
- util_user:user_dispatch_event(uid, gameConst.EVENT_ID.PAY, evtParams)
- util_user:user_proto_notify(uid, "on_shop_pay_info", {payInfo = payData:pack_pay_info(uid)})
- return code.OK, {items = items}
- end
- return root
|