新增其他线下出款记账
This commit is contained in:
@@ -71,9 +71,21 @@ func (r *Repository) disbursementSummary(ctx context.Context, query DashboardQue
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var manualPaid struct {
|
||||
AmountCent int64
|
||||
Count int64
|
||||
}
|
||||
if err := db.Table("manual_disbursements").
|
||||
Select(`COALESCE(SUM(amount_cent), 0) AS amount_cent, COUNT(id) AS count`).
|
||||
Where("status = ?", "paid").
|
||||
Where("paid_at >= ? AND paid_at <= ?", query.StartDate, query.EndDate).
|
||||
Scan(&manualPaid).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &DisbursementSummaryDTO{
|
||||
PaidAmountCent: offlinePaid.AmountCent + withdrawalPaid.ActualAmountCent,
|
||||
PaidCount: offlinePaid.Count + withdrawalPaid.Count,
|
||||
PaidAmountCent: offlinePaid.AmountCent + withdrawalPaid.ActualAmountCent + manualPaid.AmountCent,
|
||||
PaidCount: offlinePaid.Count + withdrawalPaid.Count + manualPaid.Count,
|
||||
PendingPaymentAmountCent: offlinePending.AmountCent + withdrawalPending.ActualAmountCent,
|
||||
PendingPaymentCount: offlinePending.Count + withdrawalPending.Count,
|
||||
OfflineSettlementPaidAmountCent: offlinePaid.AmountCent,
|
||||
@@ -88,6 +100,8 @@ func (r *Repository) disbursementSummary(ctx context.Context, query DashboardQue
|
||||
WithdrawalPendingCount: withdrawalPending.Count,
|
||||
WithdrawalReviewAmountCent: withdrawalReview.ActualAmountCent,
|
||||
WithdrawalReviewCount: withdrawalReview.Count,
|
||||
ManualPaidAmountCent: manualPaid.AmountCent,
|
||||
ManualPaidCount: manualPaid.Count,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -118,7 +132,19 @@ func (r *Repository) dailyDisbursements(ctx context.Context, query DashboardQuer
|
||||
return nil, err
|
||||
}
|
||||
|
||||
rowsByDate := make(map[string]dailyDisbursementRow, len(offlineRows)+len(withdrawalRows))
|
||||
manualRows := make([]dailyDisbursementSourceRow, 0)
|
||||
if err := db.Table("manual_disbursements").
|
||||
Select(`DATE(paid_at) AS date,
|
||||
COALESCE(SUM(amount_cent), 0) AS amount_cent,
|
||||
COUNT(id) AS count`).
|
||||
Where("status = ?", "paid").
|
||||
Where("paid_at >= ? AND paid_at <= ?", query.StartDate, query.EndDate).
|
||||
Group("DATE(paid_at)").
|
||||
Scan(&manualRows).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
rowsByDate := make(map[string]dailyDisbursementRow, len(offlineRows)+len(withdrawalRows)+len(manualRows))
|
||||
for _, row := range offlineRows {
|
||||
date := dailyDateKey(row.Date)
|
||||
item := rowsByDate[date]
|
||||
@@ -135,6 +161,14 @@ func (r *Repository) dailyDisbursements(ctx context.Context, query DashboardQuer
|
||||
item.WithdrawalPaidCount = row.Count
|
||||
rowsByDate[date] = item
|
||||
}
|
||||
for _, row := range manualRows {
|
||||
date := dailyDateKey(row.Date)
|
||||
item := rowsByDate[date]
|
||||
item.Date = date
|
||||
item.ManualPaidAmountCent = row.AmountCent
|
||||
item.ManualPaidCount = row.Count
|
||||
rowsByDate[date] = item
|
||||
}
|
||||
|
||||
rows := make([]dailyDisbursementRow, 0, len(rowsByDate))
|
||||
for day := dayStart(query.StartDate); !day.After(query.EndDate); day = day.AddDate(0, 0, 1) {
|
||||
@@ -157,4 +191,6 @@ type dailyDisbursementRow struct {
|
||||
OfflineSettlementPaidCount int64
|
||||
WithdrawalPaidAmountCent int64
|
||||
WithdrawalPaidCount int64
|
||||
ManualPaidAmountCent int64
|
||||
ManualPaidCount int64
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user