refactor platform domain states and permissions
This commit is contained in:
@@ -113,7 +113,7 @@ func MockData(database *gorm.DB) error {
|
||||
|
||||
warehouse := models.ProductWarehouse{
|
||||
Entity: entity(11, common.StatusEnable), Code: "MOCK-WH-001", Name: "示例中心库房",
|
||||
Address: gas.Address, Manager: "赵库管", Phone: "13700000001", IsEnabled: true,
|
||||
Address: gas.Address, Manager: "赵库管", Phone: "13700000001",
|
||||
}
|
||||
if err := put(tx, &warehouse); err != nil {
|
||||
return err
|
||||
@@ -122,9 +122,9 @@ func MockData(database *gorm.DB) error {
|
||||
enabledAt := yesterday
|
||||
productInfo := models.ProductInfo{
|
||||
Entity: entity(12, common.StatusEnable), Code: "MOCK-CYLINDER-001", Name: "示例液化气钢瓶",
|
||||
ProductStatus: common.StatusInStock,
|
||||
ProductTypeID: productType.ID, Params: `{"weight":"15kg","medium":"LPG"}`,
|
||||
WarehouseID: warehouse.ID, GasBasicID: gas.ID, ProducedAt: now.AddDate(-1, 0, 0),
|
||||
IsEnabled: true, EnabledAt: &enabledAt,
|
||||
WarehouseID: warehouse.ID, ProducedAt: now.AddDate(-1, 0, 0), EnabledAt: &enabledAt,
|
||||
}
|
||||
if err := put(tx, &productInfo); err != nil {
|
||||
return err
|
||||
@@ -132,7 +132,7 @@ func MockData(database *gorm.DB) error {
|
||||
|
||||
productOwner := models.ProductOwner{
|
||||
Entity: entity(13, common.StatusEnable), ProductInfoID: productInfo.ID,
|
||||
WarehouseID: warehouse.ID, GasBasicID: gas.ID, Action: "stock_in",
|
||||
WarehouseID: warehouse.ID, Action: "stock_in",
|
||||
OccurredAt: yesterday, Reason: "模拟数据初始化", OperatorName: "系统",
|
||||
}
|
||||
if err := put(tx, &productOwner); err != nil {
|
||||
@@ -141,9 +141,9 @@ func MockData(database *gorm.DB) error {
|
||||
|
||||
completedAt := yesterday.Add(2 * time.Hour)
|
||||
productRepair := models.ProductRepair{
|
||||
Entity: entity(14, common.StatusCompleted), ProductInfoID: productInfo.ID,
|
||||
Entity: entity(14, common.StatusEnable), ProductInfoID: productInfo.ID,
|
||||
RepairNo: "MOCK-REPAIR-001", RepairType: "inspection", StartedAt: yesterday,
|
||||
CompletedAt: &completedAt, Result: "passed", TargetStatus: common.StatusEnable,
|
||||
CompletedAt: &completedAt, Result: "passed", TargetProductStatus: common.StatusInStock,
|
||||
Content: "外观、阀门与气密性检查", Operator: staff.Name,
|
||||
}
|
||||
if err := put(tx, &productRepair); err != nil {
|
||||
@@ -151,7 +151,7 @@ func MockData(database *gorm.DB) error {
|
||||
}
|
||||
|
||||
contract := models.GasorderContract{
|
||||
Entity: entity(15, common.StatusActive), ContractNo: "MOCK-CONTRACT-001",
|
||||
Entity: entity(15, common.StatusEnable), ContractStatus: common.StatusActive, ContractNo: "MOCK-CONTRACT-001",
|
||||
UserAccountID: user.ID, GasBasicID: gas.ID, DeliveryBasicID: delivery.ID,
|
||||
Title: "居民瓶装气配送示例合同", Terms: "按需配送,安全使用。",
|
||||
DefaultDeliveryFee: 500, SignedAt: yesterday, EffectiveAt: yesterday, ExpiredAt: &nextYear,
|
||||
@@ -161,7 +161,7 @@ func MockData(database *gorm.DB) error {
|
||||
}
|
||||
|
||||
contractRevision := models.GasorderContractRevision{
|
||||
Entity: entity(16, common.StatusActive), GasorderContractID: contract.ID, Action: "activate",
|
||||
Entity: entity(16, common.StatusEnable), GasorderContractID: contract.ID, Action: "activate",
|
||||
ContractStatus: common.StatusActive, EffectiveAt: contract.EffectiveAt, ExpiredAt: contract.ExpiredAt,
|
||||
OperatorIdentity: gasAccount.Identity, OperatorName: gasAccount.DisplayName,
|
||||
OccurredAt: yesterday, Reason: "模拟合同启用",
|
||||
@@ -171,7 +171,7 @@ func MockData(database *gorm.DB) error {
|
||||
}
|
||||
|
||||
contractProduct := models.GasorderContractProduct{
|
||||
Entity: entity(17, common.StatusActive), GasorderContractID: contract.ID,
|
||||
Entity: entity(17, common.StatusEnable), GasorderContractID: contract.ID,
|
||||
ProductInfoID: productInfo.ID, ProductCode: productInfo.Code,
|
||||
ProductTypeName: productType.Name, ProductParams: productInfo.Params,
|
||||
UnitPrice: 9800, BoundAt: yesterday,
|
||||
@@ -181,7 +181,7 @@ func MockData(database *gorm.DB) error {
|
||||
}
|
||||
|
||||
gasOrder := models.GasorderBasic{
|
||||
Entity: entity(18, common.StatusCompleted), OrderNo: "MOCK-GASORDER-001",
|
||||
Entity: entity(18, common.StatusEnable), OrderStatus: common.StatusCompleted, OrderNo: "MOCK-GASORDER-001",
|
||||
RequestNo: "MOCK-REQ-GASORDER-001", GasorderContractID: contract.ID,
|
||||
UserAccountID: user.ID, CreatorType: "user", CreatorID: user.ID,
|
||||
CreatorIdentity: user.Identity, GasBasicID: gas.ID, DeliveryBasicID: delivery.ID,
|
||||
@@ -195,7 +195,7 @@ func MockData(database *gorm.DB) error {
|
||||
}
|
||||
|
||||
gasOrderItem := models.GasorderItem{
|
||||
Entity: entity(19, common.StatusCompleted), GasorderBasicID: gasOrder.ID,
|
||||
Entity: entity(19, common.StatusEnable), GasorderBasicID: gasOrder.ID,
|
||||
GasorderContractProductID: contractProduct.ID, ProductInfoID: productInfo.ID,
|
||||
ProductCode: productInfo.Code, ProductTypeName: productType.Name,
|
||||
ProductParams: productInfo.Params, UnitPrice: contractProduct.UnitPrice,
|
||||
@@ -205,7 +205,7 @@ func MockData(database *gorm.DB) error {
|
||||
}
|
||||
|
||||
assignment := models.GasorderAssign{
|
||||
Entity: entity(20, common.StatusCompleted), GasorderBasicID: gasOrder.ID, GasBasicID: gas.ID,
|
||||
Entity: entity(20, common.StatusEnable), GasorderBasicID: gasOrder.ID, GasBasicID: gas.ID,
|
||||
DeliveryBasicID: delivery.ID, StaffAccountID: staff.ID,
|
||||
AssignerIdentity: deliveryAccount.Identity, AssignerName: deliveryAccount.DisplayName,
|
||||
AssignedAt: now.Add(-2 * time.Hour), Reason: "系统示例派单",
|
||||
@@ -215,7 +215,7 @@ func MockData(database *gorm.DB) error {
|
||||
}
|
||||
|
||||
orderStatus := models.GasorderStatus{
|
||||
Entity: entity(21, common.StatusCompleted), GasorderBasicID: gasOrder.ID,
|
||||
Entity: entity(21, common.StatusEnable), GasorderBasicID: gasOrder.ID,
|
||||
FromStatus: common.StatusDelivering, ToStatus: common.StatusCompleted,
|
||||
OperatorIdentity: staff.Identity, OperatorName: staff.Name,
|
||||
OccurredAt: now, Reason: "用户已签收",
|
||||
@@ -226,7 +226,7 @@ func MockData(database *gorm.DB) error {
|
||||
|
||||
trackCompletedAt := now.Add(-10 * time.Minute)
|
||||
track := models.GasorderTrack{
|
||||
Entity: entity(22, common.StatusCompleted), GasorderBasicID: gasOrder.ID,
|
||||
Entity: entity(22, common.StatusEnable), GasorderBasicID: gasOrder.ID,
|
||||
StaffAccountID: staff.ID, AttemptNo: 1, StartedAt: now.Add(-90 * time.Minute),
|
||||
CompletedAt: &trackCompletedAt,
|
||||
}
|
||||
@@ -235,7 +235,7 @@ func MockData(database *gorm.DB) error {
|
||||
}
|
||||
|
||||
trackPoint := models.GasorderTrackPoint{
|
||||
Entity: entity(23, common.StatusCompleted), GasorderTrackID: track.ID,
|
||||
Entity: entity(23, common.StatusEnable), GasorderTrackID: track.ID,
|
||||
Longitude: address.Longitude, Latitude: address.Latitude,
|
||||
OccurredAt: trackCompletedAt, Source: "gps", Accuracy: "10m",
|
||||
}
|
||||
@@ -244,7 +244,7 @@ func MockData(database *gorm.DB) error {
|
||||
}
|
||||
|
||||
confirmation := models.GasorderConfirm{
|
||||
Entity: entity(24, common.StatusCompleted), GasorderBasicID: gasOrder.ID,
|
||||
Entity: entity(24, common.StatusEnable), GasorderBasicID: gasOrder.ID,
|
||||
ConfirmType: "signature", RecipientName: user.Name, RecipientPhone: user.Phone,
|
||||
ProofURI: "/mock/proofs/gasorder-001.png", ConfirmedAt: now, Remark: "模拟签收",
|
||||
}
|
||||
@@ -293,7 +293,7 @@ func MockData(database *gorm.DB) error {
|
||||
}
|
||||
|
||||
ecOrder := models.EcOrder{
|
||||
Entity: entity(30, common.StatusPaid), OrderNo: "MOCK-ECORDER-001",
|
||||
Entity: entity(30, common.StatusEnable), OrderStatus: common.StatusPaid, OrderNo: "MOCK-ECORDER-001",
|
||||
UserAccountID: user.ID, GasStationID: gas.ID, DeliveryPointID: delivery.ID,
|
||||
TotalAmount: ecProduct.PriceAmount,
|
||||
}
|
||||
@@ -302,7 +302,7 @@ func MockData(database *gorm.DB) error {
|
||||
}
|
||||
|
||||
ecOrderItem := models.EcOrderItem{
|
||||
Entity: entity(31, common.StatusPaid), EcOrderID: ecOrder.ID, EcProductID: ecProduct.ID,
|
||||
Entity: entity(31, common.StatusEnable), EcOrderID: ecOrder.ID, EcProductID: ecProduct.ID,
|
||||
ProductSnapshot: `{"code":"MOCK-EC-LPG-001","name":"15kg 液化气配送服务"}`,
|
||||
Quantity: 1, SaleAmount: ecProduct.PriceAmount,
|
||||
}
|
||||
@@ -311,7 +311,7 @@ func MockData(database *gorm.DB) error {
|
||||
}
|
||||
|
||||
review := models.EcReview{
|
||||
Entity: entity(32, common.StatusPublished), EcOrderID: ecOrder.ID,
|
||||
Entity: entity(32, common.StatusEnable), EcOrderID: ecOrder.ID,
|
||||
EcProductID: ecProduct.ID, UserAccountID: user.ID,
|
||||
Score: 5, Content: "配送及时,服务规范。",
|
||||
}
|
||||
@@ -341,7 +341,7 @@ func MockData(database *gorm.DB) error {
|
||||
}
|
||||
|
||||
walletPayment := models.WalletPayment{
|
||||
Entity: entity(35, common.StatusSuccess), WalletBasicID: wallet.ID,
|
||||
Entity: entity(35, common.StatusEnable), PaymentStatus: common.StatusSuccess, WalletBasicID: wallet.ID,
|
||||
PaymentNo: "MOCK-PAYMENT-001", OrderNo: gasOrder.OrderNo,
|
||||
TradeNo: "MOCK-TRADE-001", PaymentType: "gasorder",
|
||||
PayChannel: "balance", PayType: "wallet", Amount: gasOrder.PayableAmount,
|
||||
@@ -352,7 +352,7 @@ func MockData(database *gorm.DB) error {
|
||||
}
|
||||
|
||||
walletRecord := models.WalletRecord{
|
||||
Entity: entity(36, common.StatusCompleted), WalletBasicID: wallet.ID,
|
||||
Entity: entity(36, common.StatusEnable), WalletBasicID: wallet.ID,
|
||||
RecordNo: "MOCK-RECORD-001", RequestNo: "MOCK-REQ-RECORD-001",
|
||||
Direction: "in", TradeType: "recharge", Amount: 50000,
|
||||
BalanceAfter: 50000, WithdrawalBalanceAfter: 30000,
|
||||
@@ -366,7 +366,7 @@ func MockData(database *gorm.DB) error {
|
||||
|
||||
refundCompletedAt := now
|
||||
refund := models.WalletRefund{
|
||||
Entity: entity(37, common.StatusCompleted), WalletBasicID: wallet.ID,
|
||||
Entity: entity(37, common.StatusEnable), RefundStatus: common.StatusCompleted, WalletBasicID: wallet.ID,
|
||||
WalletPaymentID: walletPayment.ID, RefundNo: "MOCK-REFUND-001",
|
||||
OrderIdentity: gasOrder.Identity, Amount: 1000, Reason: "模拟部分退款",
|
||||
OrderInfo: `{"order_no":"MOCK-GASORDER-001"}`, Result: `{"status":"success"}`,
|
||||
@@ -377,7 +377,7 @@ func MockData(database *gorm.DB) error {
|
||||
}
|
||||
|
||||
applyCash := models.WalletApplyCash{
|
||||
Entity: entity(38, common.StatusApproved), WalletBasicID: wallet.ID, WalletBankID: bank.ID,
|
||||
Entity: entity(38, common.StatusEnable), ApplyStatus: common.StatusApproved, WalletBasicID: wallet.ID, WalletBankID: bank.ID,
|
||||
CashNo: "MOCK-CASH-001", RequestNo: "MOCK-REQ-CASH-001", Amount: 5000,
|
||||
Channel: "bank", TradeNo: "MOCK-CASH-TRADE-001", Remark: "模拟提现",
|
||||
ReviewerIdentity: gasAccount.Identity, ReviewerName: gasAccount.DisplayName,
|
||||
@@ -388,7 +388,7 @@ func MockData(database *gorm.DB) error {
|
||||
}
|
||||
|
||||
gasOrderPayment := models.GasorderPayment{
|
||||
Entity: entity(39, common.StatusSuccess), GasorderBasicID: gasOrder.ID,
|
||||
Entity: entity(39, common.StatusEnable), GasorderBasicID: gasOrder.ID,
|
||||
WalletPaymentID: walletPayment.ID, AttemptNo: 1, Amount: gasOrder.PayableAmount,
|
||||
}
|
||||
if err := put(tx, &gasOrderPayment); err != nil {
|
||||
@@ -396,7 +396,7 @@ func MockData(database *gorm.DB) error {
|
||||
}
|
||||
|
||||
finPayment := models.FinPayment{
|
||||
Entity: entity(40, common.StatusPaid), EcOrderID: ecOrder.ID,
|
||||
Entity: entity(40, common.StatusEnable), PaymentStatus: common.StatusPaid, EcOrderID: ecOrder.ID,
|
||||
Channel: "wallet", Amount: ecOrder.TotalAmount, PaidAt: &now,
|
||||
}
|
||||
if err := put(tx, &finPayment); err != nil {
|
||||
@@ -404,7 +404,7 @@ func MockData(database *gorm.DB) error {
|
||||
}
|
||||
|
||||
settlement := models.FinSettlement{
|
||||
Entity: entity(41, common.StatusCompleted), SettlementNo: "MOCK-SETTLEMENT-001",
|
||||
Entity: entity(41, common.StatusEnable), SettlementNo: "MOCK-SETTLEMENT-001",
|
||||
SubjectType: "gas", SubjectID: gas.ID,
|
||||
PeriodStart: now.AddDate(0, 0, -30), PeriodEnd: now,
|
||||
}
|
||||
@@ -413,7 +413,7 @@ func MockData(database *gorm.DB) error {
|
||||
}
|
||||
|
||||
reconciliation := models.FinReconciliation{
|
||||
Entity: entity(42, common.StatusMatched), Channel: "wallet",
|
||||
Entity: entity(42, common.StatusEnable), ReconciliationStatus: common.StatusMatched, Channel: "wallet",
|
||||
BillDate: now, DifferenceAmount: 0,
|
||||
}
|
||||
if err := put(tx, &reconciliation); err != nil {
|
||||
@@ -430,7 +430,7 @@ func MockData(database *gorm.DB) error {
|
||||
}
|
||||
|
||||
ticket := models.CsTicket{
|
||||
Entity: entity(44, common.StatusOpen), TicketNo: "MOCK-TICKET-001",
|
||||
Entity: entity(44, common.StatusEnable), TicketStatus: common.StatusOpen, TicketNo: "MOCK-TICKET-001",
|
||||
UserAccountID: user.ID, Category: "delivery", Priority: "normal",
|
||||
}
|
||||
if err := put(tx, &ticket); err != nil {
|
||||
@@ -439,7 +439,7 @@ func MockData(database *gorm.DB) error {
|
||||
|
||||
role := models.PlatformRole{
|
||||
Entity: entity(45, common.StatusEnable), RoleCode: "mock_operator",
|
||||
Name: "模拟运营人员", DataScope: "global", IsSystem: false,
|
||||
Name: "模拟运营人员", LocationScope: "standard", IsSystem: false,
|
||||
}
|
||||
if err := put(tx, &role); err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user