refactor platform menus and entity statuses
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"reflect"
|
||||
"time"
|
||||
|
||||
"git.apinb.com/heqiapp/platforms/backend/api/internal/logic/common"
|
||||
"git.apinb.com/heqiapp/platforms/backend/api/internal/models"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
"gorm.io/gorm"
|
||||
@@ -27,7 +28,7 @@ func MockData(database *gorm.DB) error {
|
||||
|
||||
return database.Transaction(func(tx *gorm.DB) error {
|
||||
gas := models.GasBasic{
|
||||
Entity: entity(1, "enabled"), Code: "MOCK-GAS-001", Name: "和气示例气站",
|
||||
Entity: entity(1, common.StatusEnable), Code: "MOCK-GAS-001", Name: "和气示例气站",
|
||||
CreditCode: "91310000MOCKGAS001", Principal: "张站长",
|
||||
Address: "上海市浦东新区示例路 1 号", Longitude: "121.5440", Latitude: "31.2210",
|
||||
}
|
||||
@@ -36,7 +37,7 @@ func MockData(database *gorm.DB) error {
|
||||
}
|
||||
|
||||
gasAccount := models.GasAccount{
|
||||
Entity: entity(2, "enabled"), GasBasicID: gas.ID, Username: "mock_gas_admin",
|
||||
Entity: entity(2, common.StatusEnable), GasBasicID: gas.ID, Username: "mock_gas_admin",
|
||||
DisplayName: "示例气站管理员", PasswordHash: string(passwordHash), RoleCode: "admin",
|
||||
}
|
||||
if err := put(tx, &gasAccount); err != nil {
|
||||
@@ -44,7 +45,7 @@ func MockData(database *gorm.DB) error {
|
||||
}
|
||||
|
||||
delivery := models.DeliveryBasic{
|
||||
Entity: entity(3, "enabled"), DeliveryCode: "MOCK-DELIVERY-001",
|
||||
Entity: entity(3, common.StatusEnable), DeliveryCode: "MOCK-DELIVERY-001",
|
||||
GasBasicID: gas.ID, Name: "和气示例配送点", Principal: "李主管",
|
||||
Address: "上海市浦东新区示例路 18 号",
|
||||
}
|
||||
@@ -53,7 +54,7 @@ func MockData(database *gorm.DB) error {
|
||||
}
|
||||
|
||||
deliveryAccount := models.DeliveryAccount{
|
||||
Entity: entity(4, "enabled"), DeliveryBasicID: delivery.ID,
|
||||
Entity: entity(4, common.StatusEnable), DeliveryBasicID: delivery.ID,
|
||||
Username: "mock_delivery_admin", DisplayName: "示例配送点管理员",
|
||||
PasswordHash: string(passwordHash), RoleCode: "admin",
|
||||
}
|
||||
@@ -62,7 +63,7 @@ func MockData(database *gorm.DB) error {
|
||||
}
|
||||
|
||||
staff := models.StaffAccount{
|
||||
Entity: entity(5, "enabled"), Username: "mock_driver", PasswordHash: string(passwordHash),
|
||||
Entity: entity(5, common.StatusEnable), Username: "mock_driver", PasswordHash: string(passwordHash),
|
||||
Name: "王师傅", Phone: "13900000001", RoleCode: "driver",
|
||||
GasBasicID: gas.ID, DeliveryBasicID: delivery.ID, WorkStatus: "on_duty",
|
||||
}
|
||||
@@ -71,7 +72,7 @@ func MockData(database *gorm.DB) error {
|
||||
}
|
||||
|
||||
credential := models.StaffCredential{
|
||||
Entity: entity(6, "enabled"), StaffAccountID: staff.ID,
|
||||
Entity: entity(6, common.StatusEnable), StaffAccountID: staff.ID,
|
||||
CredentialType: "delivery", CredentialNo: "MOCK-CERT-001", ExpiredAt: &nextYear,
|
||||
}
|
||||
if err := put(tx, &credential); err != nil {
|
||||
@@ -79,7 +80,7 @@ func MockData(database *gorm.DB) error {
|
||||
}
|
||||
|
||||
user := models.UserAccount{
|
||||
Entity: entity(7, "enabled"), Username: "mock_customer", PasswordHash: string(passwordHash),
|
||||
Entity: entity(7, common.StatusEnable), Username: "mock_customer", PasswordHash: string(passwordHash),
|
||||
Name: "陈女士", Phone: "13800000001", RealName: "陈示例",
|
||||
}
|
||||
if err := put(tx, &user); err != nil {
|
||||
@@ -87,7 +88,7 @@ func MockData(database *gorm.DB) error {
|
||||
}
|
||||
|
||||
address := models.UserAddress{
|
||||
Entity: entity(8, "enabled"), UserAccountID: user.ID,
|
||||
Entity: entity(8, common.StatusEnable), UserAccountID: user.ID,
|
||||
Address: "上海市浦东新区客户路 88 号", Longitude: "121.5500",
|
||||
Latitude: "31.2250", IsDefault: true,
|
||||
}
|
||||
@@ -96,7 +97,7 @@ func MockData(database *gorm.DB) error {
|
||||
}
|
||||
|
||||
serviceRelation := models.UserServiceRelation{
|
||||
Entity: entity(9, "enabled"), UserAccountID: user.ID, GasBasicID: gas.ID,
|
||||
Entity: entity(9, common.StatusEnable), UserAccountID: user.ID, GasBasicID: gas.ID,
|
||||
DeliveryBasicID: delivery.ID, StaffAccountID: staff.ID,
|
||||
}
|
||||
if err := put(tx, &serviceRelation); err != nil {
|
||||
@@ -104,14 +105,14 @@ func MockData(database *gorm.DB) error {
|
||||
}
|
||||
|
||||
productType := models.ProductType{
|
||||
Entity: entity(10, "enabled"), Code: "MOCK-LPG-15KG", Name: "15kg 液化气钢瓶",
|
||||
Entity: entity(10, common.StatusEnable), Code: "MOCK-LPG-15KG", Name: "15kg 液化气钢瓶",
|
||||
}
|
||||
if err := put(tx, &productType); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
warehouse := models.ProductWarehouse{
|
||||
Entity: entity(11, "enabled"), Code: "MOCK-WH-001", Name: "示例中心库房",
|
||||
Entity: entity(11, common.StatusEnable), Code: "MOCK-WH-001", Name: "示例中心库房",
|
||||
Address: gas.Address, Manager: "赵库管", Phone: "13700000001", IsEnabled: true,
|
||||
}
|
||||
if err := put(tx, &warehouse); err != nil {
|
||||
@@ -120,7 +121,7 @@ func MockData(database *gorm.DB) error {
|
||||
|
||||
enabledAt := yesterday
|
||||
productInfo := models.ProductInfo{
|
||||
Entity: entity(12, "enabled"), Code: "MOCK-CYLINDER-001", Name: "示例液化气钢瓶",
|
||||
Entity: entity(12, common.StatusEnable), Code: "MOCK-CYLINDER-001", Name: "示例液化气钢瓶",
|
||||
ProductTypeID: productType.ID, Params: `{"weight":"15kg","medium":"LPG"}`,
|
||||
WarehouseID: warehouse.ID, GasBasicID: gas.ID, ProducedAt: now.AddDate(-1, 0, 0),
|
||||
IsEnabled: true, EnabledAt: &enabledAt,
|
||||
@@ -130,7 +131,7 @@ func MockData(database *gorm.DB) error {
|
||||
}
|
||||
|
||||
productOwner := models.ProductOwner{
|
||||
Entity: entity(13, "enabled"), ProductInfoID: productInfo.ID,
|
||||
Entity: entity(13, common.StatusEnable), ProductInfoID: productInfo.ID,
|
||||
WarehouseID: warehouse.ID, GasBasicID: gas.ID, Action: "stock_in",
|
||||
OccurredAt: yesterday, Reason: "模拟数据初始化", OperatorName: "系统",
|
||||
}
|
||||
@@ -140,9 +141,9 @@ func MockData(database *gorm.DB) error {
|
||||
|
||||
completedAt := yesterday.Add(2 * time.Hour)
|
||||
productRepair := models.ProductRepair{
|
||||
Entity: entity(14, "completed"), ProductInfoID: productInfo.ID,
|
||||
Entity: entity(14, common.StatusCompleted), ProductInfoID: productInfo.ID,
|
||||
RepairNo: "MOCK-REPAIR-001", RepairType: "inspection", StartedAt: yesterday,
|
||||
CompletedAt: &completedAt, Result: "passed", TargetStatus: "enabled",
|
||||
CompletedAt: &completedAt, Result: "passed", TargetStatus: common.StatusEnable,
|
||||
Content: "外观、阀门与气密性检查", Operator: staff.Name,
|
||||
}
|
||||
if err := put(tx, &productRepair); err != nil {
|
||||
@@ -150,7 +151,7 @@ func MockData(database *gorm.DB) error {
|
||||
}
|
||||
|
||||
contract := models.GasorderContract{
|
||||
Entity: entity(15, "active"), ContractNo: "MOCK-CONTRACT-001",
|
||||
Entity: entity(15, 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,
|
||||
@@ -160,8 +161,8 @@ func MockData(database *gorm.DB) error {
|
||||
}
|
||||
|
||||
contractRevision := models.GasorderContractRevision{
|
||||
Entity: entity(16, "active"), GasorderContractID: contract.ID, Action: "activate",
|
||||
ContractStatus: "active", EffectiveAt: contract.EffectiveAt, ExpiredAt: contract.ExpiredAt,
|
||||
Entity: entity(16, common.StatusActive), GasorderContractID: contract.ID, Action: "activate",
|
||||
ContractStatus: common.StatusActive, EffectiveAt: contract.EffectiveAt, ExpiredAt: contract.ExpiredAt,
|
||||
OperatorIdentity: gasAccount.Identity, OperatorName: gasAccount.DisplayName,
|
||||
OccurredAt: yesterday, Reason: "模拟合同启用",
|
||||
}
|
||||
@@ -170,7 +171,7 @@ func MockData(database *gorm.DB) error {
|
||||
}
|
||||
|
||||
contractProduct := models.GasorderContractProduct{
|
||||
Entity: entity(17, "active"), GasorderContractID: contract.ID,
|
||||
Entity: entity(17, common.StatusActive), GasorderContractID: contract.ID,
|
||||
ProductInfoID: productInfo.ID, ProductCode: productInfo.Code,
|
||||
ProductTypeName: productType.Name, ProductParams: productInfo.Params,
|
||||
UnitPrice: 9800, BoundAt: yesterday,
|
||||
@@ -180,7 +181,7 @@ func MockData(database *gorm.DB) error {
|
||||
}
|
||||
|
||||
gasOrder := models.GasorderBasic{
|
||||
Entity: entity(18, "completed"), OrderNo: "MOCK-GASORDER-001",
|
||||
Entity: entity(18, 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,
|
||||
@@ -194,7 +195,7 @@ func MockData(database *gorm.DB) error {
|
||||
}
|
||||
|
||||
gasOrderItem := models.GasorderItem{
|
||||
Entity: entity(19, "completed"), GasorderBasicID: gasOrder.ID,
|
||||
Entity: entity(19, common.StatusCompleted), GasorderBasicID: gasOrder.ID,
|
||||
GasorderContractProductID: contractProduct.ID, ProductInfoID: productInfo.ID,
|
||||
ProductCode: productInfo.Code, ProductTypeName: productType.Name,
|
||||
ProductParams: productInfo.Params, UnitPrice: contractProduct.UnitPrice,
|
||||
@@ -204,7 +205,7 @@ func MockData(database *gorm.DB) error {
|
||||
}
|
||||
|
||||
assignment := models.GasorderAssign{
|
||||
Entity: entity(20, "completed"), GasorderBasicID: gasOrder.ID, GasBasicID: gas.ID,
|
||||
Entity: entity(20, common.StatusCompleted), 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: "系统示例派单",
|
||||
@@ -214,8 +215,8 @@ func MockData(database *gorm.DB) error {
|
||||
}
|
||||
|
||||
orderStatus := models.GasorderStatus{
|
||||
Entity: entity(21, "completed"), GasorderBasicID: gasOrder.ID,
|
||||
FromStatus: "delivering", ToStatus: "completed",
|
||||
Entity: entity(21, common.StatusCompleted), GasorderBasicID: gasOrder.ID,
|
||||
FromStatus: common.StatusDelivering, ToStatus: common.StatusCompleted,
|
||||
OperatorIdentity: staff.Identity, OperatorName: staff.Name,
|
||||
OccurredAt: now, Reason: "用户已签收",
|
||||
}
|
||||
@@ -225,7 +226,7 @@ func MockData(database *gorm.DB) error {
|
||||
|
||||
trackCompletedAt := now.Add(-10 * time.Minute)
|
||||
track := models.GasorderTrack{
|
||||
Entity: entity(22, "completed"), GasorderBasicID: gasOrder.ID,
|
||||
Entity: entity(22, common.StatusCompleted), GasorderBasicID: gasOrder.ID,
|
||||
StaffAccountID: staff.ID, AttemptNo: 1, StartedAt: now.Add(-90 * time.Minute),
|
||||
CompletedAt: &trackCompletedAt,
|
||||
}
|
||||
@@ -234,7 +235,7 @@ func MockData(database *gorm.DB) error {
|
||||
}
|
||||
|
||||
trackPoint := models.GasorderTrackPoint{
|
||||
Entity: entity(23, "completed"), GasorderTrackID: track.ID,
|
||||
Entity: entity(23, common.StatusCompleted), GasorderTrackID: track.ID,
|
||||
Longitude: address.Longitude, Latitude: address.Latitude,
|
||||
OccurredAt: trackCompletedAt, Source: "gps", Accuracy: "10m",
|
||||
}
|
||||
@@ -243,7 +244,7 @@ func MockData(database *gorm.DB) error {
|
||||
}
|
||||
|
||||
confirmation := models.GasorderConfirm{
|
||||
Entity: entity(24, "completed"), GasorderBasicID: gasOrder.ID,
|
||||
Entity: entity(24, common.StatusCompleted), GasorderBasicID: gasOrder.ID,
|
||||
ConfirmType: "signature", RecipientName: user.Name, RecipientPhone: user.Phone,
|
||||
ProofURI: "/mock/proofs/gasorder-001.png", ConfirmedAt: now, Remark: "模拟签收",
|
||||
}
|
||||
@@ -252,14 +253,14 @@ func MockData(database *gorm.DB) error {
|
||||
}
|
||||
|
||||
category := models.EcCategory{
|
||||
Entity: entity(25, "enabled"), Name: "瓶装燃气", SortNo: 10,
|
||||
Entity: entity(25, common.StatusEnable), Name: "瓶装燃气", SortNo: 10,
|
||||
}
|
||||
if err := put(tx, &category); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
ecProduct := models.EcProduct{
|
||||
Entity: entity(26, "enabled"), EcCategoryID: category.ID,
|
||||
Entity: entity(26, common.StatusEnable), EcCategoryID: category.ID,
|
||||
ProductCode: "MOCK-EC-LPG-001", Name: "15kg 液化气配送服务",
|
||||
PriceAmount: 10300, StockQuantity: 50,
|
||||
}
|
||||
@@ -268,7 +269,7 @@ func MockData(database *gorm.DB) error {
|
||||
}
|
||||
|
||||
attribute := models.EcProductAttribute{
|
||||
Entity: entity(27, "enabled"), EcProductID: ecProduct.ID,
|
||||
Entity: entity(27, common.StatusEnable), EcProductID: ecProduct.ID,
|
||||
Name: "规格", Value: "15kg/瓶", SortNo: 1,
|
||||
}
|
||||
if err := put(tx, &attribute); err != nil {
|
||||
@@ -276,7 +277,7 @@ func MockData(database *gorm.DB) error {
|
||||
}
|
||||
|
||||
image := models.EcProductImage{
|
||||
Entity: entity(28, "enabled"), EcProductID: ecProduct.ID,
|
||||
Entity: entity(28, common.StatusEnable), EcProductID: ecProduct.ID,
|
||||
ImageURI: "/mock/products/lpg-15kg.png", SortNo: 1, IsCover: true,
|
||||
}
|
||||
if err := put(tx, &image); err != nil {
|
||||
@@ -284,7 +285,7 @@ func MockData(database *gorm.DB) error {
|
||||
}
|
||||
|
||||
cart := models.EcCart{
|
||||
Entity: entity(29, "enabled"), UserAccountID: user.ID,
|
||||
Entity: entity(29, common.StatusEnable), UserAccountID: user.ID,
|
||||
EcProductID: ecProduct.ID, Quantity: 1, Selected: true,
|
||||
}
|
||||
if err := put(tx, &cart); err != nil {
|
||||
@@ -292,7 +293,7 @@ func MockData(database *gorm.DB) error {
|
||||
}
|
||||
|
||||
ecOrder := models.EcOrder{
|
||||
Entity: entity(30, "paid"), OrderNo: "MOCK-ECORDER-001",
|
||||
Entity: entity(30, common.StatusPaid), OrderNo: "MOCK-ECORDER-001",
|
||||
UserAccountID: user.ID, GasStationID: gas.ID, DeliveryPointID: delivery.ID,
|
||||
TotalAmount: ecProduct.PriceAmount,
|
||||
}
|
||||
@@ -301,7 +302,7 @@ func MockData(database *gorm.DB) error {
|
||||
}
|
||||
|
||||
ecOrderItem := models.EcOrderItem{
|
||||
Entity: entity(31, "paid"), EcOrderID: ecOrder.ID, EcProductID: ecProduct.ID,
|
||||
Entity: entity(31, common.StatusPaid), EcOrderID: ecOrder.ID, EcProductID: ecProduct.ID,
|
||||
ProductSnapshot: `{"code":"MOCK-EC-LPG-001","name":"15kg 液化气配送服务"}`,
|
||||
Quantity: 1, SaleAmount: ecProduct.PriceAmount,
|
||||
}
|
||||
@@ -310,7 +311,7 @@ func MockData(database *gorm.DB) error {
|
||||
}
|
||||
|
||||
review := models.EcReview{
|
||||
Entity: entity(32, "published"), EcOrderID: ecOrder.ID,
|
||||
Entity: entity(32, common.StatusPublished), EcOrderID: ecOrder.ID,
|
||||
EcProductID: ecProduct.ID, UserAccountID: user.ID,
|
||||
Score: 5, Content: "配送及时,服务规范。",
|
||||
}
|
||||
@@ -319,7 +320,7 @@ func MockData(database *gorm.DB) error {
|
||||
}
|
||||
|
||||
wallet := models.WalletBasic{
|
||||
Entity: entity(33, "enabled"), OwnerType: "user", OwnerID: user.ID,
|
||||
Entity: entity(33, common.StatusEnable), OwnerType: "user", OwnerID: user.ID,
|
||||
OwnerIdentity: user.Identity, AlipayID: "mock@example.com", AlipayName: user.Name,
|
||||
WxpayID: "mock_customer", WxpayName: user.Name,
|
||||
PayPasswordHash: string(passwordHash), Balance: 50000, WithdrawalBalance: 30000,
|
||||
@@ -329,7 +330,7 @@ func MockData(database *gorm.DB) error {
|
||||
}
|
||||
|
||||
bank := models.WalletBank{
|
||||
Entity: entity(34, "enabled"), WalletBasicID: wallet.ID,
|
||||
Entity: entity(34, common.StatusEnable), WalletBasicID: wallet.ID,
|
||||
CardNoCiphertext: "mock-ciphertext-card", CardFingerprint: "mock-card-fingerprint-001",
|
||||
CardNoLast4: "8888", BankName: "示例银行", CardOwner: user.RealName,
|
||||
IDCardCiphertext: "mock-ciphertext-id", PhoneCiphertext: "mock-ciphertext-phone",
|
||||
@@ -340,7 +341,7 @@ func MockData(database *gorm.DB) error {
|
||||
}
|
||||
|
||||
walletPayment := models.WalletPayment{
|
||||
Entity: entity(35, "success"), WalletBasicID: wallet.ID,
|
||||
Entity: entity(35, 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,
|
||||
@@ -351,7 +352,7 @@ func MockData(database *gorm.DB) error {
|
||||
}
|
||||
|
||||
walletRecord := models.WalletRecord{
|
||||
Entity: entity(36, "completed"), WalletBasicID: wallet.ID,
|
||||
Entity: entity(36, common.StatusCompleted), WalletBasicID: wallet.ID,
|
||||
RecordNo: "MOCK-RECORD-001", RequestNo: "MOCK-REQ-RECORD-001",
|
||||
Direction: "in", TradeType: "recharge", Amount: 50000,
|
||||
BalanceAfter: 50000, WithdrawalBalanceAfter: 30000,
|
||||
@@ -365,7 +366,7 @@ func MockData(database *gorm.DB) error {
|
||||
|
||||
refundCompletedAt := now
|
||||
refund := models.WalletRefund{
|
||||
Entity: entity(37, "completed"), WalletBasicID: wallet.ID,
|
||||
Entity: entity(37, 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"}`,
|
||||
@@ -376,7 +377,7 @@ func MockData(database *gorm.DB) error {
|
||||
}
|
||||
|
||||
applyCash := models.WalletApplyCash{
|
||||
Entity: entity(38, "approved"), WalletBasicID: wallet.ID, WalletBankID: bank.ID,
|
||||
Entity: entity(38, 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,
|
||||
@@ -387,7 +388,7 @@ func MockData(database *gorm.DB) error {
|
||||
}
|
||||
|
||||
gasOrderPayment := models.GasorderPayment{
|
||||
Entity: entity(39, "success"), GasorderBasicID: gasOrder.ID,
|
||||
Entity: entity(39, common.StatusSuccess), GasorderBasicID: gasOrder.ID,
|
||||
WalletPaymentID: walletPayment.ID, AttemptNo: 1, Amount: gasOrder.PayableAmount,
|
||||
}
|
||||
if err := put(tx, &gasOrderPayment); err != nil {
|
||||
@@ -395,7 +396,7 @@ func MockData(database *gorm.DB) error {
|
||||
}
|
||||
|
||||
finPayment := models.FinPayment{
|
||||
Entity: entity(40, "paid"), EcOrderID: ecOrder.ID,
|
||||
Entity: entity(40, common.StatusPaid), EcOrderID: ecOrder.ID,
|
||||
Channel: "wallet", Amount: ecOrder.TotalAmount, PaidAt: &now,
|
||||
}
|
||||
if err := put(tx, &finPayment); err != nil {
|
||||
@@ -403,7 +404,7 @@ func MockData(database *gorm.DB) error {
|
||||
}
|
||||
|
||||
settlement := models.FinSettlement{
|
||||
Entity: entity(41, "completed"), SettlementNo: "MOCK-SETTLEMENT-001",
|
||||
Entity: entity(41, common.StatusCompleted), SettlementNo: "MOCK-SETTLEMENT-001",
|
||||
SubjectType: "gas", SubjectID: gas.ID,
|
||||
PeriodStart: now.AddDate(0, 0, -30), PeriodEnd: now,
|
||||
}
|
||||
@@ -412,7 +413,7 @@ func MockData(database *gorm.DB) error {
|
||||
}
|
||||
|
||||
reconciliation := models.FinReconciliation{
|
||||
Entity: entity(42, "matched"), Channel: "wallet",
|
||||
Entity: entity(42, common.StatusMatched), Channel: "wallet",
|
||||
BillDate: now, DifferenceAmount: 0,
|
||||
}
|
||||
if err := put(tx, &reconciliation); err != nil {
|
||||
@@ -420,7 +421,7 @@ func MockData(database *gorm.DB) error {
|
||||
}
|
||||
|
||||
content := models.CmsContent{
|
||||
Entity: entity(43, "enabled"), ContentType: "notice",
|
||||
Entity: entity(43, common.StatusEnable), ContentType: "notice",
|
||||
Title: "模拟数据使用说明", Body: "本内容由 platform-cli mock-data 生成。",
|
||||
VersionNo: 1, PublishStatus: "published",
|
||||
}
|
||||
@@ -429,7 +430,7 @@ func MockData(database *gorm.DB) error {
|
||||
}
|
||||
|
||||
ticket := models.CsTicket{
|
||||
Entity: entity(44, "open"), TicketNo: "MOCK-TICKET-001",
|
||||
Entity: entity(44, common.StatusOpen), TicketNo: "MOCK-TICKET-001",
|
||||
UserAccountID: user.ID, Category: "delivery", Priority: "normal",
|
||||
}
|
||||
if err := put(tx, &ticket); err != nil {
|
||||
@@ -437,7 +438,7 @@ func MockData(database *gorm.DB) error {
|
||||
}
|
||||
|
||||
role := models.PlatformRole{
|
||||
Entity: entity(45, "enabled"), RoleCode: "mock_operator",
|
||||
Entity: entity(45, common.StatusEnable), RoleCode: "mock_operator",
|
||||
Name: "模拟运营人员", DataScope: "global", IsSystem: false,
|
||||
}
|
||||
if err := put(tx, &role); err != nil {
|
||||
@@ -445,7 +446,7 @@ func MockData(database *gorm.DB) error {
|
||||
}
|
||||
|
||||
platformAccount := models.PlatformAccount{
|
||||
Entity: entity(46, "enabled"), Username: "mock_operator",
|
||||
Entity: entity(46, common.StatusEnable), Username: "mock_operator",
|
||||
DisplayName: "模拟运营人员", PasswordHash: string(passwordHash),
|
||||
PlatformRoleCode: role.RoleCode, Phone: "13600000001",
|
||||
}
|
||||
@@ -453,16 +454,12 @@ func MockData(database *gorm.DB) error {
|
||||
return err
|
||||
}
|
||||
|
||||
var menu models.PlatformMenu
|
||||
if err := tx.Where("menu_code = ?", "dashboard").First(&menu).Error; err != nil {
|
||||
return fmt.Errorf("find dashboard menu: %w", err)
|
||||
}
|
||||
roleMenu := models.PlatformRoleMenu{
|
||||
PlatformRoleID: role.ID, PlatformMenuID: menu.ID,
|
||||
PlatformRoleID: role.ID, MenuCode: "dashboard",
|
||||
}
|
||||
if err := tx.Where(
|
||||
"platform_role_id = ? AND platform_menu_id = ?",
|
||||
role.ID, menu.ID,
|
||||
"platform_role_id = ? AND menu_code = ?",
|
||||
role.ID, roleMenu.MenuCode,
|
||||
).FirstOrCreate(&roleMenu).Error; err != nil {
|
||||
return fmt.Errorf("seed platform_role_menu: %w", err)
|
||||
}
|
||||
@@ -470,7 +467,7 @@ func MockData(database *gorm.DB) error {
|
||||
})
|
||||
}
|
||||
|
||||
func entity(sequence int, status string) models.Entity {
|
||||
func entity(sequence int, status int) models.Entity {
|
||||
return models.Entity{
|
||||
Identity: fmt.Sprintf("%s%012d", mockIdentityPrefix, sequence),
|
||||
Status: status,
|
||||
|
||||
Reference in New Issue
Block a user