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

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{})
}

View File

@@ -163,6 +163,19 @@ func ListGasorderContractProduct(ctx *gin.Context) {
listScoped(ctx, &models.GasorderContractProduct{}, query, "gasorder_contract_product.created_at desc")
}
// GetGasorderContractProduct 返回当前气站合同范围内的单条合同气瓶。
func GetGasorderContractProduct(ctx *gin.Context) {
station, ok := currentGas(ctx)
if !ok {
return
}
query := common.ActiveRecords(impl.DBService.Model(&models.GasorderContractProduct{})).
Select("gasorder_contract_product.*").
Joins("JOIN gasorder_contract ON gasorder_contract.id = gasorder_contract_product.gasorder_contract_id").
Where("gasorder_contract_product.identity = ? AND gasorder_contract.gas_basic_id = ?", ctx.Param("identity"), station.ID)
respondScopedRecord(ctx, query, &models.GasorderContractProduct{})
}
// ListContractProductCandidate 仅返回当前气站服务用户名下可用于合同绑定的气瓶。
func ListContractProductCandidate(ctx *gin.Context) {
station, ok := currentGas(ctx)
@@ -176,6 +189,19 @@ func ListContractProductCandidate(ctx *gin.Context) {
listScoped(ctx, &models.ProductInfo{}, query, "product_info.created_at desc")
}
// GetContractProductCandidate 返回当前气站服务用户范围内的单条候选气瓶。
func GetContractProductCandidate(ctx *gin.Context) {
station, ok := currentGas(ctx)
if !ok {
return
}
query := common.ActiveRecords(impl.DBService.Model(&models.ProductInfo{})).
Select("product_info.*").
Joins("JOIN user_service_relation ON user_service_relation.user_account_id = product_info.user_account_id AND user_service_relation.status <> ?", common.StatusArchived).
Where("product_info.identity = ? AND user_service_relation.gas_basic_id = ?", ctx.Param("identity"), station.ID)
respondScopedRecord(ctx, query, &models.ProductInfo{})
}
func ListGasorderContractRevision(ctx *gin.Context) {
station, ok := currentGas(ctx)
if !ok {
@@ -187,6 +213,19 @@ func ListGasorderContractRevision(ctx *gin.Context) {
listScoped(ctx, &models.GasorderContractRevision{}, query, "gasorder_contract_revision.created_at desc")
}
// GetGasorderContractRevision 返回当前气站合同范围内的单条修订记录。
func GetGasorderContractRevision(ctx *gin.Context) {
station, ok := currentGas(ctx)
if !ok {
return
}
query := common.ActiveRecords(impl.DBService.Model(&models.GasorderContractRevision{})).
Select("gasorder_contract_revision.*").
Joins("JOIN gasorder_contract ON gasorder_contract.id = gasorder_contract_revision.gasorder_contract_id").
Where("gasorder_contract_revision.identity = ? AND gasorder_contract.gas_basic_id = ?", ctx.Param("identity"), station.ID)
respondScopedRecord(ctx, query, &models.GasorderContractRevision{})
}
func ListGasorderBasic(ctx *gin.Context) {
station, ok := currentGas(ctx)
if !ok {