完成气站标准资源全页管理改造

This commit is contained in:
czl231
2026-08-18 00:26:39 +08:00
parent eef791427a
commit 084eccc3ec
51 changed files with 7081 additions and 1141 deletions

View File

@@ -1,4 +1,4 @@
package gas
package gas
import (
"strings"
@@ -33,6 +33,17 @@ func ListWalletBasic(ctx *gin.Context) {
listScoped(ctx, &models.WalletBasic{}, query, "wallet_basic.created_at desc")
}
// GetWalletBasic 返回当前气站拥有的单个钱包。
func GetWalletBasic(ctx *gin.Context) {
station, ok := currentGas(ctx)
if !ok {
return
}
query := common.ActiveRecords(impl.DBService.Model(&models.WalletBasic{})).
Where("identity = ? AND owner_type = ? AND owner_id = ?", ctx.Param("identity"), "gas", station.ID)
respondScopedRecord(ctx, query, &models.WalletBasic{})
}
func listWalletChild(ctx *gin.Context, model any, table string) {
station, ok := currentGas(ctx)
if !ok {
@@ -44,19 +55,45 @@ func listWalletChild(ctx *gin.Context, model any, table string) {
listScoped(ctx, model, query, table+".created_at desc")
}
// getWalletChild 返回当前气站钱包范围内的单条子资源。
func getWalletChild(ctx *gin.Context, model any, table string) {
station, ok := currentGas(ctx)
if !ok {
return
}
query := common.ActiveRecords(impl.DBService.Model(model)).
Select(table+".*").
Joins("JOIN wallet_basic ON wallet_basic.id = "+table+".wallet_basic_id").
Where(table+".identity = ? AND wallet_basic.owner_type = ? AND wallet_basic.owner_id = ?", ctx.Param("identity"), "gas", station.ID)
respondScopedRecord(ctx, query, model)
}
func ListWalletBank(ctx *gin.Context) { listWalletChild(ctx, &models.WalletBank{}, "wallet_bank") }
func GetWalletBank(ctx *gin.Context) { getWalletChild(ctx, &models.WalletBank{}, "wallet_bank") }
func ListPaymentOrder(ctx *gin.Context) {
listWalletChild(ctx, &models.PaymentOrder{}, "payment_order")
}
func GetPaymentOrder(ctx *gin.Context) {
getWalletChild(ctx, &models.PaymentOrder{}, "payment_order")
}
func ListWalletRecord(ctx *gin.Context) {
listWalletChild(ctx, &models.WalletRecord{}, "wallet_record")
}
func GetWalletRecord(ctx *gin.Context) {
getWalletChild(ctx, &models.WalletRecord{}, "wallet_record")
}
func ListPaymentRefund(ctx *gin.Context) {
listWalletChild(ctx, &models.PaymentRefund{}, "payment_refund")
}
func GetPaymentRefund(ctx *gin.Context) {
getWalletChild(ctx, &models.PaymentRefund{}, "payment_refund")
}
func ListWalletApplyCash(ctx *gin.Context) {
listWalletChild(ctx, &models.WalletApplyCash{}, "wallet_apply_cash")
}
func GetWalletApplyCash(ctx *gin.Context) {
getWalletChild(ctx, &models.WalletApplyCash{}, "wallet_apply_cash")
}
func CreateWalletApplyCash(ctx *gin.Context) {
account, station, ok := CurrentGasAccount(ctx)
@@ -120,8 +157,26 @@ func ListFinSettlement(ctx *gin.Context) {
listScoped(ctx, &models.FinSettlement{}, query, "fin_settlement.created_at desc")
}
// GetFinSettlement 返回当前气站主体范围内的单条结算记录。
func GetFinSettlement(ctx *gin.Context) {
station, ok := currentGas(ctx)
if !ok {
return
}
query := common.ActiveRecords(impl.DBService.Model(&models.FinSettlement{})).
Where("identity = ? AND subject_type = ? AND subject_id = ?", ctx.Param("identity"), "gas", station.ID)
respondScopedRecord(ctx, query, &models.FinSettlement{})
}
// 对账表目前没有主体归属字段,气站端不得暴露平台全局渠道数据。
func ListFinReconciliation(ctx *gin.Context) {
query := common.ActiveRecords(impl.DBService.Model(&models.FinReconciliation{})).Where("1 = 0")
listScoped(ctx, &models.FinReconciliation{}, query, "fin_reconciliation.created_at desc")
}
// GetFinReconciliation 保持与列表相同的数据边界;当前气站端不暴露全局对账记录。
func GetFinReconciliation(ctx *gin.Context) {
query := common.ActiveRecords(impl.DBService.Model(&models.FinReconciliation{})).
Where("identity = ? AND 1 = 0", ctx.Param("identity"))
respondScopedRecord(ctx, query, &models.FinReconciliation{})
}