修复气站与配送点支付记录数据范围
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
// 功能:提供配送点管理端钱包、支付、充值、提现及结算接口。
|
||||
// 版本:v1.1。
|
||||
package delivery
|
||||
|
||||
import (
|
||||
@@ -55,10 +57,24 @@ func listWalletChild(ctx *gin.Context, model any, table string) {
|
||||
listScoped(ctx, model, query, table+".created_at desc")
|
||||
}
|
||||
|
||||
func ListBank(ctx *gin.Context) { listWalletChild(ctx, &models.WalletBank{}, "wallet_bank") }
|
||||
func ListPayment(ctx *gin.Context) { listWalletChild(ctx, &models.PaymentOrder{}, "payment_order") }
|
||||
func ListRecord(ctx *gin.Context) { listWalletChild(ctx, &models.WalletRecord{}, "wallet_record") }
|
||||
func ListRefund(ctx *gin.Context) { listWalletChild(ctx, &models.PaymentRefund{}, "payment_refund") }
|
||||
func ListBank(ctx *gin.Context) { listWalletChild(ctx, &models.WalletBank{}, "wallet_bank") }
|
||||
func ListRecord(ctx *gin.Context) { listWalletChild(ctx, &models.WalletRecord{}, "wallet_record") }
|
||||
func ListRefund(ctx *gin.Context) { listWalletChild(ctx, &models.PaymentRefund{}, "payment_refund") }
|
||||
|
||||
// paymentOrderQuery 按统一支付单关联的业务对象限定当前配送点数据范围。
|
||||
func paymentOrderQuery(point models.DeliveryBasic) *gorm.DB {
|
||||
query := common.ActiveRecords(db().Model(&models.PaymentOrder{}))
|
||||
return common.ScopePaymentOrdersByOwner(query, "delivery", point.ID, point.Identity)
|
||||
}
|
||||
|
||||
// ListPayment 返回当前配送点业务范围内的统一支付记录。
|
||||
func ListPayment(ctx *gin.Context) {
|
||||
point, _, ok := currentScope(ctx)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
listScoped(ctx, &models.PaymentOrder{}, paymentOrderQuery(point), "payment_order.created_at desc")
|
||||
}
|
||||
func ListRecharge(ctx *gin.Context) {
|
||||
point, _, ok := currentScope(ctx)
|
||||
if !ok {
|
||||
@@ -86,10 +102,19 @@ func getWalletChild(ctx *gin.Context, model any, table string) {
|
||||
respondRecord(ctx, query, model)
|
||||
}
|
||||
|
||||
func GetBank(ctx *gin.Context) { getWalletChild(ctx, &models.WalletBank{}, "wallet_bank") }
|
||||
func GetPayment(ctx *gin.Context) { getWalletChild(ctx, &models.PaymentOrder{}, "payment_order") }
|
||||
func GetRecord(ctx *gin.Context) { getWalletChild(ctx, &models.WalletRecord{}, "wallet_record") }
|
||||
func GetRefund(ctx *gin.Context) { getWalletChild(ctx, &models.PaymentRefund{}, "payment_refund") }
|
||||
func GetBank(ctx *gin.Context) { getWalletChild(ctx, &models.WalletBank{}, "wallet_bank") }
|
||||
func GetRecord(ctx *gin.Context) { getWalletChild(ctx, &models.WalletRecord{}, "wallet_record") }
|
||||
func GetRefund(ctx *gin.Context) { getWalletChild(ctx, &models.PaymentRefund{}, "payment_refund") }
|
||||
|
||||
// GetPayment 返回当前配送点业务范围内的单条统一支付记录。
|
||||
func GetPayment(ctx *gin.Context) {
|
||||
point, _, ok := currentScope(ctx)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
query := paymentOrderQuery(point).Where("payment_order.identity = ?", ctx.Param("identity"))
|
||||
respondRecord(ctx, query, &models.PaymentOrder{})
|
||||
}
|
||||
func GetRecharge(ctx *gin.Context) {
|
||||
point, _, ok := currentScope(ctx)
|
||||
if !ok {
|
||||
|
||||
Reference in New Issue
Block a user