chore(init): 初始化解忧商行项目并完成 Phase 0 基座
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
package adminfinance
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"hfb_sys/backend/internal/timeutil"
|
||||
)
|
||||
|
||||
// settlementDiffThresholdCent 是判定"结算差异"的最小绝对金额(分)。
|
||||
// 号主应得与实际入账的差额绝对值达到此阈值,才视为财务异常。
|
||||
// SQL、presenter、前端展示统一引用此口径,避免多处硬编码不一致。
|
||||
const settlementDiffThresholdCent = 5
|
||||
|
||||
const (
|
||||
financeStatusNormal = "normal"
|
||||
financeStatusRefundPending = "refund_pending"
|
||||
financeStatusRefundFailed = "refund_failed"
|
||||
financeStatusSettlementDiff = "settlement_diff"
|
||||
financeStatusOfflineSettlementPending = "offline_settlement_pending"
|
||||
)
|
||||
|
||||
func payBizTypes() []string {
|
||||
return []string{"order_pay", "mohong_pay"}
|
||||
}
|
||||
|
||||
func refundBizTypes() []string {
|
||||
return []string{
|
||||
"cancel_refund",
|
||||
"admin_close_refund",
|
||||
"admin_refund",
|
||||
"checkout_refund",
|
||||
"deposit_refund",
|
||||
"rent_refund",
|
||||
"arbitration_refund",
|
||||
"mohong_refund",
|
||||
}
|
||||
}
|
||||
|
||||
// normalRefundBizTypes 正常(租赁)订单退款类型,不含撞车商城退款。
|
||||
func normalRefundBizTypes() []string {
|
||||
return []string{
|
||||
"cancel_refund",
|
||||
"admin_close_refund",
|
||||
"admin_refund",
|
||||
"checkout_refund",
|
||||
"deposit_refund",
|
||||
"rent_refund",
|
||||
"arbitration_refund",
|
||||
}
|
||||
}
|
||||
|
||||
// settledSettlementStatuses 是视为"已完成结算"的结算状态集合。
|
||||
// 预计收入只统计尚未结算的订单,这些状态需从预计口径中排除。
|
||||
func settledSettlementStatuses() []string {
|
||||
return []string{"settled", "closed", "arbitrated"}
|
||||
}
|
||||
|
||||
// nonBillableOrderStatuses 是不产生平台收入的订单状态集合(待支付、已取消、已关闭)。
|
||||
// 预计收入排除这些状态,只保留进行中/待结算且未来会产生手续费的订单。
|
||||
func nonBillableOrderStatuses() []string {
|
||||
return []string{"pending_payment", "cancelled", "closed"}
|
||||
}
|
||||
|
||||
func dayStart(value time.Time) time.Time {
|
||||
loc := timeutil.ShanghaiLocation()
|
||||
local := value.In(loc)
|
||||
return time.Date(local.Year(), local.Month(), local.Day(), 0, 0, 0, 0, loc)
|
||||
}
|
||||
|
||||
func dailyDateKey(value string) string {
|
||||
value = strings.TrimSpace(value)
|
||||
if len(value) >= len("2006-01-02") {
|
||||
return value[:len("2006-01-02")]
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
func absCent(value int64) int64 {
|
||||
if value < 0 {
|
||||
return -value
|
||||
}
|
||||
return value
|
||||
}
|
||||
Reference in New Issue
Block a user