Files

54 lines
2.3 KiB
Go
Raw Permalink 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.
package entity
import (
pricingConsts "shop-user-trade/consts/pricing"
"gitea.redpowerfuture.com/red-future/common/beans"
"github.com/gogf/gf/v2/os/gtime"
)
type chargeOrderCol struct {
beans.SQLBaseCol
SubjectType string
SubjectID string
BizOrderNo string
UserId string
ChargeMode string
Status string
ActualAmount string
Usage string
RuleSnapshot string
SettleTime string
}
var ChargeOrderCol = chargeOrderCol{
SQLBaseCol: beans.DefSQLBaseCol,
SubjectType: "subject_type",
SubjectID: "subject_id",
BizOrderNo: "biz_order_no",
UserId: "user_id",
ChargeMode: "charge_mode",
Status: "status",
ActualAmount: "actual_amount",
Usage: "usage",
RuleSnapshot: "rule_snapshot",
SettleTime: "settle_time",
}
// ChargeOrder 计费单实体:一次计价调用 = 一张计费单(幂等键 subject_type+subject_id+biz_order_no
// 状态机:CREATED(已建单,不动钱) → SETTLED(已结算) / FAILED(已失败,不扣费)
type ChargeOrder struct {
beans.SQLBaseDO `orm:",inherit"`
SubjectType pricingConsts.SubjectType `orm:"subject_type" json:"subjectType" description:"计价对象类型"`
SubjectID string `orm:"subject_id" json:"subjectId" description:"计价对象ID"`
BizOrderNo string `orm:"biz_order_no" json:"bizOrderNo" description:"业务单据号(幂等键,如工作流 execId)"`
UserId int64 `orm:"user_id" json:"userId,string" description:"扣费用户ID"`
ChargeMode pricingConsts.ChargeMode `orm:"charge_mode" json:"chargeMode" description:"计费方式(建单快照)"`
Status pricingConsts.ChargeOrderStatus `orm:"status" json:"status" description:"状态:1已建单 2已结算 3已失败"`
ActualAmount float64 `orm:"actual_amount" json:"actualAmount" description:"实收金额(元,保留2位小数)"`
Usage map[string]any `orm:"usage" json:"usage" description:"实际用量JSON对象"`
RuleSnapshot map[string]any `orm:"rule_snapshot" json:"ruleSnapshot" description:"结算用费率快照JSON对象(防改价影响在途单)"`
SettleTime *gtime.Time `orm:"settle_time" json:"settleTime" description:"结算时间"`
}