merge: 合并最新 main 到 dev_11.15
This commit is contained in:
@@ -31,12 +31,12 @@ func (CSManualEntry) TableName() string {
|
|||||||
return "cs_manual_entries"
|
return "cs_manual_entries"
|
||||||
}
|
}
|
||||||
|
|
||||||
// CSManualEntryOption 客服手动录单的可选项配置(平台 / 操作人)。
|
// CSManualEntryOption 客服手动录单的可选项配置(平台 / 录单操作人 / 出款实际操作人)。
|
||||||
// 仅作为录单表单的下拉数据源,记录里保存的是名称快照。
|
// 仅作为录单表单的下拉数据源,记录里保存的是名称快照。
|
||||||
// 操作人选项可通过 group_tag 标记所属组别(收号/出号),录单时用于自动带出组别。
|
// 操作人选项可通过 group_tag 标记所属组别(收号/出号),录单时用于自动带出组别。
|
||||||
type CSManualEntryOption struct {
|
type CSManualEntryOption struct {
|
||||||
ID uint64 `gorm:"primaryKey" json:"id"`
|
ID uint64 `gorm:"primaryKey" json:"id"`
|
||||||
Type string `gorm:"size:16;not null;uniqueIndex:uk_cs_manual_entry_options_type_name,priority:1" json:"type"`
|
Type string `gorm:"size:32;not null;uniqueIndex:uk_cs_manual_entry_options_type_name,priority:1" json:"type"`
|
||||||
Name string `gorm:"size:64;not null;uniqueIndex:uk_cs_manual_entry_options_type_name,priority:2" json:"name"`
|
Name string `gorm:"size:64;not null;uniqueIndex:uk_cs_manual_entry_options_type_name,priority:2" json:"name"`
|
||||||
GroupTag string `gorm:"size:16;not null;default:''" json:"group_tag"`
|
GroupTag string `gorm:"size:16;not null;default:''" json:"group_tag"`
|
||||||
SortOrder int `gorm:"not null;default:0" json:"sort_order"`
|
SortOrder int `gorm:"not null;default:0" json:"sort_order"`
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ type RentalOrder struct {
|
|||||||
OfflineSettlementStatus string `gorm:"size:16;not null;default:'none';index" json:"offline_settlement_status"`
|
OfflineSettlementStatus string `gorm:"size:16;not null;default:'none';index" json:"offline_settlement_status"`
|
||||||
OfflineSettlementAmountCent int64 `gorm:"not null;default:0" json:"offline_settlement_amount_cent"`
|
OfflineSettlementAmountCent int64 `gorm:"not null;default:0" json:"offline_settlement_amount_cent"`
|
||||||
OfflineSettlementRemark string `gorm:"size:255;not null;default:''" json:"offline_settlement_remark"`
|
OfflineSettlementRemark string `gorm:"size:255;not null;default:''" json:"offline_settlement_remark"`
|
||||||
|
ActualPayoutOperator string `gorm:"column:offline_settlement_actual_operator;size:64;not null;default:'';index" json:"offline_settlement_actual_operator"`
|
||||||
OfflineSettledBy *uint64 `json:"offline_settled_by"`
|
OfflineSettledBy *uint64 `json:"offline_settled_by"`
|
||||||
OfflineSettledAt *time.Time `json:"offline_settled_at"`
|
OfflineSettledAt *time.Time `json:"offline_settled_at"`
|
||||||
RefundStatus string `gorm:"size:32;not null;default:'none';index" json:"refund_status"`
|
RefundStatus string `gorm:"size:32;not null;default:'none';index" json:"refund_status"`
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ type AdminPickup struct {
|
|||||||
Status string `gorm:"size:20;not null;default:'picking_up';index" json:"status"`
|
Status string `gorm:"size:20;not null;default:'picking_up';index" json:"status"`
|
||||||
OfflineSettlementStatus string `gorm:"size:16;not null;default:'none';index" json:"offline_settlement_status"`
|
OfflineSettlementStatus string `gorm:"size:16;not null;default:'none';index" json:"offline_settlement_status"`
|
||||||
OfflineSettlementRemark string `gorm:"size:255;not null;default:''" json:"offline_settlement_remark"`
|
OfflineSettlementRemark string `gorm:"size:255;not null;default:''" json:"offline_settlement_remark"`
|
||||||
|
ActualPayoutOperator string `gorm:"column:offline_settlement_actual_operator;size:64;not null;default:'';index" json:"offline_settlement_actual_operator"`
|
||||||
OfflineSettledBy *uint64 `json:"offline_settled_by,omitempty"`
|
OfflineSettledBy *uint64 `json:"offline_settled_by,omitempty"`
|
||||||
OfflineSettledAt *time.Time `json:"offline_settled_at,omitempty"`
|
OfflineSettledAt *time.Time `json:"offline_settled_at,omitempty"`
|
||||||
Remark string `gorm:"size:255;not null;default:''" json:"remark"`
|
Remark string `gorm:"size:255;not null;default:''" json:"remark"`
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ func (r *Repository) disbursementListBaseQuery(ctx context.Context, phoneKeyword
|
|||||||
ro.offline_settled_at AS paid_at,
|
ro.offline_settled_at AS paid_at,
|
||||||
ro.offline_settled_by AS operator_id,
|
ro.offline_settled_by AS operator_id,
|
||||||
COALESCE(NULLIF(operator.nickname, ''), operator.username, '') AS operator_name,
|
COALESCE(NULLIF(operator.nickname, ''), operator.username, '') AS operator_name,
|
||||||
|
ro.offline_settlement_actual_operator AS actual_operator_name,
|
||||||
ro.offline_settlement_remark AS remark,
|
ro.offline_settlement_remark AS remark,
|
||||||
'' AS category,
|
'' AS category,
|
||||||
'' AS custom_category_name,
|
'' AS custom_category_name,
|
||||||
@@ -119,6 +120,7 @@ func (r *Repository) disbursementListBaseQuery(ctx context.Context, phoneKeyword
|
|||||||
ap.offline_settled_at AS paid_at,
|
ap.offline_settled_at AS paid_at,
|
||||||
ap.offline_settled_by AS operator_id,
|
ap.offline_settled_by AS operator_id,
|
||||||
COALESCE(NULLIF(operator.nickname, ''), operator.username, '') AS operator_name,
|
COALESCE(NULLIF(operator.nickname, ''), operator.username, '') AS operator_name,
|
||||||
|
ap.offline_settlement_actual_operator AS actual_operator_name,
|
||||||
ap.offline_settlement_remark AS remark,
|
ap.offline_settlement_remark AS remark,
|
||||||
'' AS category,
|
'' AS category,
|
||||||
'' AS custom_category_name,
|
'' AS custom_category_name,
|
||||||
@@ -157,6 +159,7 @@ func (r *Repository) disbursementListBaseQuery(ctx context.Context, phoneKeyword
|
|||||||
fa.settled_at AS paid_at,
|
fa.settled_at AS paid_at,
|
||||||
fa.settled_by AS operator_id,
|
fa.settled_by AS operator_id,
|
||||||
COALESCE(NULLIF(operator.nickname, ''), operator.username, '') AS operator_name,
|
COALESCE(NULLIF(operator.nickname, ''), operator.username, '') AS operator_name,
|
||||||
|
ap.offline_settlement_actual_operator AS actual_operator_name,
|
||||||
fa.reason AS remark,
|
fa.reason AS remark,
|
||||||
'' AS category,
|
'' AS category,
|
||||||
'' AS custom_category_name,
|
'' AS custom_category_name,
|
||||||
@@ -201,6 +204,7 @@ func (r *Repository) disbursementListBaseQuery(ctx context.Context, phoneKeyword
|
|||||||
wr.paid_at,
|
wr.paid_at,
|
||||||
COALESCE(wr.paid_by, wr.reviewed_by) AS operator_id,
|
COALESCE(wr.paid_by, wr.reviewed_by) AS operator_id,
|
||||||
COALESCE(NULLIF(operator.nickname, ''), operator.username, '') AS operator_name,
|
COALESCE(NULLIF(operator.nickname, ''), operator.username, '') AS operator_name,
|
||||||
|
'' AS actual_operator_name,
|
||||||
CASE WHEN wr.payment_remark <> '' THEN wr.payment_remark ELSE wr.review_remark END AS remark,
|
CASE WHEN wr.payment_remark <> '' THEN wr.payment_remark ELSE wr.review_remark END AS remark,
|
||||||
'' AS category,
|
'' AS category,
|
||||||
'' AS custom_category_name,
|
'' AS custom_category_name,
|
||||||
@@ -242,6 +246,7 @@ func (r *Repository) disbursementListBaseQuery(ctx context.Context, phoneKeyword
|
|||||||
md.paid_at,
|
md.paid_at,
|
||||||
md.created_by AS operator_id,
|
md.created_by AS operator_id,
|
||||||
COALESCE(NULLIF(creator.nickname, ''), creator.username, '') AS operator_name,
|
COALESCE(NULLIF(creator.nickname, ''), creator.username, '') AS operator_name,
|
||||||
|
'' AS actual_operator_name,
|
||||||
md.remark,
|
md.remark,
|
||||||
md.category,
|
md.category,
|
||||||
md.custom_category_name,
|
md.custom_category_name,
|
||||||
@@ -289,6 +294,9 @@ func (r *Repository) applyDisbursementFilters(db *gorm.DB, query DisbursementQue
|
|||||||
if query.OperatorID > 0 {
|
if query.OperatorID > 0 {
|
||||||
db = db.Where("d.operator_id = ?", query.OperatorID)
|
db = db.Where("d.operator_id = ?", query.OperatorID)
|
||||||
}
|
}
|
||||||
|
if query.ActualOperator != "" {
|
||||||
|
db = db.Where("d.actual_operator_name LIKE ?", "%"+query.ActualOperator+"%")
|
||||||
|
}
|
||||||
if !query.StartDate.IsZero() && !query.EndDate.IsZero() {
|
if !query.StartDate.IsZero() && !query.EndDate.IsZero() {
|
||||||
if query.DateType == "paid" {
|
if query.DateType == "paid" {
|
||||||
db = db.Where("d.paid_at >= ? AND d.paid_at <= ?", query.StartDate, query.EndDate)
|
db = db.Where("d.paid_at >= ? AND d.paid_at <= ?", query.StartDate, query.EndDate)
|
||||||
@@ -335,6 +343,7 @@ type disbursementItemRow struct {
|
|||||||
PaidAt *time.Time
|
PaidAt *time.Time
|
||||||
OperatorID *uint64
|
OperatorID *uint64
|
||||||
OperatorName string
|
OperatorName string
|
||||||
|
ActualOperatorName string
|
||||||
Remark string
|
Remark string
|
||||||
Category string
|
Category string
|
||||||
CustomCategoryName string
|
CustomCategoryName string
|
||||||
@@ -380,6 +389,7 @@ func (r disbursementItemRow) toDTO() DisbursementItemDTO {
|
|||||||
PaidAt: r.PaidAt,
|
PaidAt: r.PaidAt,
|
||||||
OperatorID: r.OperatorID,
|
OperatorID: r.OperatorID,
|
||||||
OperatorName: r.OperatorName,
|
OperatorName: r.OperatorName,
|
||||||
|
ActualOperatorName: r.ActualOperatorName,
|
||||||
Remark: r.Remark,
|
Remark: r.Remark,
|
||||||
Category: r.Category,
|
Category: r.Category,
|
||||||
CustomCategoryName: r.CustomCategoryName,
|
CustomCategoryName: r.CustomCategoryName,
|
||||||
|
|||||||
@@ -30,18 +30,20 @@ func TestDisbursementListCombinesPlatformSettlementsAndWithdrawals(t *testing.T)
|
|||||||
}
|
}
|
||||||
if err := db.Exec(`INSERT INTO rental_orders
|
if err := db.Exec(`INSERT INTO rental_orders
|
||||||
(id, order_no, listing_id, account_id, owner_id, renter_id, settlement_mode, offline_settlement_status,
|
(id, order_no, listing_id, account_id, owner_id, renter_id, settlement_mode, offline_settlement_status,
|
||||||
offline_settlement_amount_cent, offline_settlement_remark, settled_at, offline_settled_at, offline_settled_by)
|
offline_settlement_amount_cent, offline_settlement_remark, offline_settlement_actual_operator,
|
||||||
|
settled_at, offline_settled_at, offline_settled_by)
|
||||||
VALUES
|
VALUES
|
||||||
(1, 'R202607010001', 101, 101, 1, 2, 'platform_managed', 'settled', 12000, '支付宝转账', ?, ?, 7),
|
(1, 'R202607010001', 101, 101, 1, 2, 'platform_managed', 'settled', 12000, '支付宝转账', '出款甲', ?, ?, 7),
|
||||||
(2, 'R202607010002', 102, 102, 1, 2, 'platform_managed', 'pending', 8000, '', ?, NULL, NULL)`,
|
(2, 'R202607010002', 102, 102, 1, 2, 'platform_managed', 'pending', 8000, '', '', ?, NULL, NULL)`,
|
||||||
at(2), at(3), at(4)).Error; err != nil {
|
at(2), at(3), at(4)).Error; err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if err := db.Exec(`INSERT INTO admin_pickups
|
if err := db.Exec(`INSERT INTO admin_pickups
|
||||||
(id, pickup_no, listing_id, account_id, owner_id, admin_id, source_channel, settlement_mode, settle_amount_cent,
|
(id, pickup_no, listing_id, account_id, owner_id, admin_id, source_channel, settlement_mode, settle_amount_cent,
|
||||||
offline_settlement_status, offline_settlement_remark, offline_settled_by, offline_settled_at, completed_at,
|
offline_settlement_status, offline_settlement_remark, offline_settlement_actual_operator,
|
||||||
|
offline_settled_by, offline_settled_at, completed_at,
|
||||||
created_at, account_snapshot)
|
created_at, account_snapshot)
|
||||||
VALUES (30, 'P202607010001', 101, 101, 1, 7, '线下录入', 'platform_managed', 4000, 'settled', '提号结算', 7, ?, ?, ?, '{}')`,
|
VALUES (30, 'P202607010001', 101, 101, 1, 7, '线下录入', 'platform_managed', 4000, 'settled', '提号结算', '出款乙', 7, ?, ?, ?, '{}')`,
|
||||||
at(4), at(3), at(2)).Error; err != nil {
|
at(4), at(3), at(2)).Error; err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -125,6 +127,9 @@ func TestDisbursementListCombinesPlatformSettlementsAndWithdrawals(t *testing.T)
|
|||||||
if platformItem.PayeeName != "外部卖家" || platformItem.PayeePhone != "13800000000" || platformItem.UploaderName != "上传客服甲" {
|
if platformItem.PayeeName != "外部卖家" || platformItem.PayeePhone != "13800000000" || platformItem.UploaderName != "上传客服甲" {
|
||||||
t.Fatalf("平台收款人/上传人 = %s/%s/%s", platformItem.PayeeName, platformItem.PayeePhone, platformItem.UploaderName)
|
t.Fatalf("平台收款人/上传人 = %s/%s/%s", platformItem.PayeeName, platformItem.PayeePhone, platformItem.UploaderName)
|
||||||
}
|
}
|
||||||
|
if platformItem.ActualOperatorName != "出款甲" {
|
||||||
|
t.Fatalf("平台实际操作人 = %q, want 出款甲", platformItem.ActualOperatorName)
|
||||||
|
}
|
||||||
var pickupItem *DisbursementItemDTO
|
var pickupItem *DisbursementItemDTO
|
||||||
for index := range result.Items {
|
for index := range result.Items {
|
||||||
if result.Items[index].BusinessNo == "P202607010001" {
|
if result.Items[index].BusinessNo == "P202607010001" {
|
||||||
@@ -135,6 +140,9 @@ func TestDisbursementListCombinesPlatformSettlementsAndWithdrawals(t *testing.T)
|
|||||||
if pickupItem == nil || pickupItem.SourceType != "pickup" || pickupItem.ActualAmountCent != 4000 {
|
if pickupItem == nil || pickupItem.SourceType != "pickup" || pickupItem.ActualAmountCent != 4000 {
|
||||||
t.Fatalf("线下提号出款信息不正确: %+v", pickupItem)
|
t.Fatalf("线下提号出款信息不正确: %+v", pickupItem)
|
||||||
}
|
}
|
||||||
|
if pickupItem.ActualOperatorName != "出款乙" {
|
||||||
|
t.Fatalf("提号实际操作人 = %q, want 出款乙", pickupItem.ActualOperatorName)
|
||||||
|
}
|
||||||
var adjustmentItem *DisbursementItemDTO
|
var adjustmentItem *DisbursementItemDTO
|
||||||
for index := range result.Items {
|
for index := range result.Items {
|
||||||
if result.Items[index].SourceType == "pickup_adjustment" {
|
if result.Items[index].SourceType == "pickup_adjustment" {
|
||||||
@@ -192,4 +200,22 @@ func TestDisbursementListCombinesPlatformSettlementsAndWithdrawals(t *testing.T)
|
|||||||
t.Fatalf("操作人筛选返回了其他操作人: %+v", item)
|
t.Fatalf("操作人筛选返回了其他操作人: %+v", item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
actualOperatorFiltered, err := repo.Disbursements(t.Context(), DisbursementQuery{
|
||||||
|
ActualOperator: "出款甲",
|
||||||
|
DateType: "created",
|
||||||
|
StartDate: at(1),
|
||||||
|
EndDate: time.Date(2026, 7, 10, 23, 59, 59, 0, loc),
|
||||||
|
Page: 1,
|
||||||
|
PageSize: 20,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("按实际操作人查询出款失败: %v", err)
|
||||||
|
}
|
||||||
|
if actualOperatorFiltered.Total != 1 || len(actualOperatorFiltered.Items) != 1 {
|
||||||
|
t.Fatalf("按实际操作人查询结果 = %+v", actualOperatorFiltered.Items)
|
||||||
|
}
|
||||||
|
if actualOperatorFiltered.Items[0].BusinessNo != "R202607010001" {
|
||||||
|
t.Fatalf("实际操作人筛选命中错误记录: %+v", actualOperatorFiltered.Items[0])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,18 +22,19 @@ type DetailQuery struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type DisbursementQuery struct {
|
type DisbursementQuery struct {
|
||||||
SourceType string
|
SourceType string
|
||||||
Status string
|
Status string
|
||||||
DateType string
|
DateType string
|
||||||
BusinessNo string
|
BusinessNo string
|
||||||
Keyword string
|
Keyword string
|
||||||
Operator string
|
Operator string
|
||||||
OperatorID uint64
|
OperatorID uint64
|
||||||
UserID uint64
|
ActualOperator string
|
||||||
StartDate time.Time
|
UserID uint64
|
||||||
EndDate time.Time
|
StartDate time.Time
|
||||||
Page int
|
EndDate time.Time
|
||||||
PageSize int
|
Page int
|
||||||
|
PageSize int
|
||||||
}
|
}
|
||||||
|
|
||||||
type OperatingExpenseQuery struct {
|
type OperatingExpenseQuery struct {
|
||||||
@@ -160,6 +161,7 @@ type DisbursementItemDTO struct {
|
|||||||
PaidAt *time.Time `json:"paid_at,omitempty"`
|
PaidAt *time.Time `json:"paid_at,omitempty"`
|
||||||
OperatorID *uint64 `json:"operator_id,omitempty"`
|
OperatorID *uint64 `json:"operator_id,omitempty"`
|
||||||
OperatorName string `json:"operator_name"`
|
OperatorName string `json:"operator_name"`
|
||||||
|
ActualOperatorName string `json:"actual_operator_name"`
|
||||||
Remark string `json:"remark"`
|
Remark string `json:"remark"`
|
||||||
Category string `json:"category"`
|
Category string `json:"category"`
|
||||||
CustomCategoryName string `json:"custom_category_name"`
|
CustomCategoryName string `json:"custom_category_name"`
|
||||||
|
|||||||
@@ -218,14 +218,15 @@ func parseDisbursementQuery(c *gin.Context) (DisbursementQuery, bool) {
|
|||||||
return DisbursementQuery{}, false
|
return DisbursementQuery{}, false
|
||||||
}
|
}
|
||||||
query := DisbursementQuery{
|
query := DisbursementQuery{
|
||||||
SourceType: strings.TrimSpace(c.Query("source_type")),
|
SourceType: strings.TrimSpace(c.Query("source_type")),
|
||||||
Status: strings.TrimSpace(c.Query("status")),
|
Status: strings.TrimSpace(c.Query("status")),
|
||||||
DateType: c.DefaultQuery("date_type", "created"),
|
DateType: c.DefaultQuery("date_type", "created"),
|
||||||
BusinessNo: strings.TrimSpace(c.Query("business_no")),
|
BusinessNo: strings.TrimSpace(c.Query("business_no")),
|
||||||
Keyword: strings.TrimSpace(c.Query("keyword")),
|
Keyword: strings.TrimSpace(c.Query("keyword")),
|
||||||
Operator: strings.TrimSpace(c.Query("operator")),
|
Operator: strings.TrimSpace(c.Query("operator")),
|
||||||
StartDate: start,
|
ActualOperator: strings.TrimSpace(c.Query("actual_operator")),
|
||||||
EndDate: end,
|
StartDate: start,
|
||||||
|
EndDate: end,
|
||||||
}
|
}
|
||||||
if query.Operator == "" {
|
if query.Operator == "" {
|
||||||
query.Operator = strings.TrimSpace(c.Query("operator_name"))
|
query.Operator = strings.TrimSpace(c.Query("operator_name"))
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import "time"
|
|||||||
const (
|
const (
|
||||||
OptionTypePlatform = "platform" // 平台
|
OptionTypePlatform = "platform" // 平台
|
||||||
OptionTypeOperator = "operator" // 操作人
|
OptionTypeOperator = "operator" // 操作人
|
||||||
|
// OptionTypeDisbursementOperator 线下结算实际操作人;独立于录单操作人。
|
||||||
|
OptionTypeDisbursementOperator = "disbursement_operator"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 录单组别。
|
// 录单组别。
|
||||||
@@ -68,12 +70,12 @@ type PaginatedResult struct {
|
|||||||
|
|
||||||
// AgentDayStatsDTO 某客服某日录单统计(按组分列)。
|
// AgentDayStatsDTO 某客服某日录单统计(按组分列)。
|
||||||
type AgentDayStatsDTO struct {
|
type AgentDayStatsDTO struct {
|
||||||
Date string `json:"date"` // YYYY-MM-DD(北京时间)
|
Date string `json:"date"` // YYYY-MM-DD(北京时间)
|
||||||
AdminID uint64 `json:"admin_id"`
|
AdminID uint64 `json:"admin_id"`
|
||||||
AdminName string `json:"admin_name"`
|
AdminName string `json:"admin_name"`
|
||||||
Count int64 `json:"count"` // 总录单量
|
Count int64 `json:"count"` // 总录单量
|
||||||
CollectCount int64 `json:"collect_count"` // 收号录单量
|
CollectCount int64 `json:"collect_count"` // 收号录单量
|
||||||
SellCount int64 `json:"sell_count"` // 出号录单量
|
SellCount int64 `json:"sell_count"` // 出号录单量
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateResult 录单结果。
|
// CreateResult 录单结果。
|
||||||
@@ -81,7 +83,7 @@ type CreateResult struct {
|
|||||||
Entry EntryDTO `json:"entry"`
|
Entry EntryDTO `json:"entry"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// OptionDTO 录单可选项(平台 / 操作人)。
|
// OptionDTO 可选项(平台 / 操作人 / 出款实际操作人)。
|
||||||
type OptionDTO struct {
|
type OptionDTO struct {
|
||||||
ID uint64 `json:"id"`
|
ID uint64 `json:"id"`
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
@@ -91,20 +93,21 @@ type OptionDTO struct {
|
|||||||
CreatedAt time.Time `json:"created_at"`
|
CreatedAt time.Time `json:"created_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// OptionListDTO 平台与操作人选项集合,供录单表单下拉直接使用。
|
// OptionListDTO 平台、操作人与出款实际操作人选项集合。
|
||||||
type OptionListDTO struct {
|
type OptionListDTO struct {
|
||||||
Platforms []OptionDTO `json:"platforms"`
|
Platforms []OptionDTO `json:"platforms"`
|
||||||
Operators []OptionDTO `json:"operators"`
|
Operators []OptionDTO `json:"operators"`
|
||||||
|
DisbursementOperators []OptionDTO `json:"disbursement_operators"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateOptionRequest 新增平台 / 操作人选项。
|
// CreateOptionRequest 新增平台 / 操作人 / 出款实际操作人选项。
|
||||||
type CreateOptionRequest struct {
|
type CreateOptionRequest struct {
|
||||||
Type string `json:"type" binding:"required"`
|
Type string `json:"type" binding:"required"`
|
||||||
Name string `json:"name" binding:"required"`
|
Name string `json:"name" binding:"required"`
|
||||||
GroupTag string `json:"group_tag"` // 仅操作人类型可用,collect/sell/空
|
GroupTag string `json:"group_tag"` // 仅操作人类型可用,collect/sell/空
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateOptionRequest 重命名平台 / 操作人选项(可同时更新组别标记)。
|
// UpdateOptionRequest 重命名选项(录单操作人可同时更新组别标记)。
|
||||||
type UpdateOptionRequest struct {
|
type UpdateOptionRequest struct {
|
||||||
Name string `json:"name" binding:"required"`
|
Name string `json:"name" binding:"required"`
|
||||||
GroupTag string `json:"group_tag"` // 仅操作人类型可用,collect/sell/空
|
GroupTag string `json:"group_tag"` // 仅操作人类型可用,collect/sell/空
|
||||||
|
|||||||
@@ -49,10 +49,10 @@ func (h *Handler) List(c *gin.Context) {
|
|||||||
EntryNo: strings.TrimSpace(c.Query("entry_no")),
|
EntryNo: strings.TrimSpace(c.Query("entry_no")),
|
||||||
EntryGroup: strings.TrimSpace(c.Query("entry_group")),
|
EntryGroup: strings.TrimSpace(c.Query("entry_group")),
|
||||||
Keyword: strings.TrimSpace(c.Query("keyword")),
|
Keyword: strings.TrimSpace(c.Query("keyword")),
|
||||||
StartDate: strings.TrimSpace(c.Query("start_date")),
|
StartDate: strings.TrimSpace(c.Query("start_date")),
|
||||||
EndDate: strings.TrimSpace(c.Query("end_date")),
|
EndDate: strings.TrimSpace(c.Query("end_date")),
|
||||||
Page: page,
|
Page: page,
|
||||||
PageSize: pageSize,
|
PageSize: pageSize,
|
||||||
}
|
}
|
||||||
if raw := c.Query("admin_id"); raw != "" {
|
if raw := c.Query("admin_id"); raw != "" {
|
||||||
adminID, err := strconv.ParseUint(raw, 10, 64)
|
adminID, err := strconv.ParseUint(raw, 10, 64)
|
||||||
@@ -123,7 +123,7 @@ func (h *Handler) Delete(c *gin.Context) {
|
|||||||
response.OK(c, gin.H{"deleted": true})
|
response.OK(c, gin.H{"deleted": true})
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListOptions 返回平台与操作人选项,供录单表单下拉使用。
|
// ListOptions 返回平台、操作人与出款实际操作人选项。
|
||||||
func (h *Handler) ListOptions(c *gin.Context) {
|
func (h *Handler) ListOptions(c *gin.Context) {
|
||||||
if _, ok := currentAdminID(c); !ok {
|
if _, ok := currentAdminID(c); !ok {
|
||||||
response.Unauthorized(c, "缺少管理员上下文")
|
response.Unauthorized(c, "缺少管理员上下文")
|
||||||
@@ -137,7 +137,21 @@ func (h *Handler) ListOptions(c *gin.Context) {
|
|||||||
response.OK(c, result)
|
response.OK(c, result)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateOption 新增平台 / 操作人选项。
|
// ListDisbursementOperators 返回线下结算实际操作人可选项。
|
||||||
|
func (h *Handler) ListDisbursementOperators(c *gin.Context) {
|
||||||
|
if _, ok := currentAdminID(c); !ok {
|
||||||
|
response.Unauthorized(c, "缺少管理员上下文")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
result, err := h.service.ListDisbursementOperators(c.Request.Context())
|
||||||
|
if err != nil {
|
||||||
|
writeManualEntryError(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.OK(c, result)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOption 新增平台 / 操作人 / 出款实际操作人选项。
|
||||||
func (h *Handler) CreateOption(c *gin.Context) {
|
func (h *Handler) CreateOption(c *gin.Context) {
|
||||||
if _, ok := currentAdminID(c); !ok {
|
if _, ok := currentAdminID(c); !ok {
|
||||||
response.Unauthorized(c, "缺少管理员上下文")
|
response.Unauthorized(c, "缺少管理员上下文")
|
||||||
@@ -156,7 +170,7 @@ func (h *Handler) CreateOption(c *gin.Context) {
|
|||||||
response.Created(c, option)
|
response.Created(c, option)
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateOption 重命名平台 / 操作人选项。
|
// UpdateOption 重命名选项。
|
||||||
func (h *Handler) UpdateOption(c *gin.Context) {
|
func (h *Handler) UpdateOption(c *gin.Context) {
|
||||||
if _, ok := currentAdminID(c); !ok {
|
if _, ok := currentAdminID(c); !ok {
|
||||||
response.Unauthorized(c, "缺少管理员上下文")
|
response.Unauthorized(c, "缺少管理员上下文")
|
||||||
|
|||||||
@@ -238,7 +238,7 @@ func (r *Repository) ListOptions(ctx context.Context, optionType string) ([]Opti
|
|||||||
return items, nil
|
return items, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListAllOptions 返回平台与操作人两组可选项,供录单表单直接使用。
|
// ListAllOptions 返回平台、操作人与出款实际操作人三组可选项。
|
||||||
func (r *Repository) ListAllOptions(ctx context.Context) (*OptionListDTO, error) {
|
func (r *Repository) ListAllOptions(ctx context.Context) (*OptionListDTO, error) {
|
||||||
platforms, err := r.ListOptions(ctx, OptionTypePlatform)
|
platforms, err := r.ListOptions(ctx, OptionTypePlatform)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -248,10 +248,18 @@ func (r *Repository) ListAllOptions(ctx context.Context) (*OptionListDTO, error)
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &OptionListDTO{Platforms: platforms, Operators: operators}, nil
|
disbursementOperators, err := r.ListOptions(ctx, OptionTypeDisbursementOperator)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &OptionListDTO{
|
||||||
|
Platforms: platforms,
|
||||||
|
Operators: operators,
|
||||||
|
DisbursementOperators: disbursementOperators,
|
||||||
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateOption 新增一个平台 / 操作人选项,重名返回 ErrOptionExists。
|
// CreateOption 新增一个可选项,重名返回 ErrOptionExists。
|
||||||
// 操作人选项可通过 groupTag 标记所属组别(collect/sell,空表示未分组)。
|
// 操作人选项可通过 groupTag 标记所属组别(collect/sell,空表示未分组)。
|
||||||
func (r *Repository) CreateOption(ctx context.Context, optionType, name, groupTag string) (*OptionDTO, error) {
|
func (r *Repository) CreateOption(ctx context.Context, optionType, name, groupTag string) (*OptionDTO, error) {
|
||||||
if !IsValidOptionType(optionType) {
|
if !IsValidOptionType(optionType) {
|
||||||
@@ -309,7 +317,9 @@ func (r *Repository) DeleteOption(ctx context.Context, id uint64) error {
|
|||||||
|
|
||||||
// IsValidOptionType 判断选项类型是否合法。
|
// IsValidOptionType 判断选项类型是否合法。
|
||||||
func IsValidOptionType(optionType string) bool {
|
func IsValidOptionType(optionType string) bool {
|
||||||
return optionType == OptionTypePlatform || optionType == OptionTypeOperator
|
return optionType == OptionTypePlatform ||
|
||||||
|
optionType == OptionTypeOperator ||
|
||||||
|
optionType == OptionTypeDisbursementOperator
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseDay(value string, loc *time.Location) (time.Time, error) {
|
func parseDay(value string, loc *time.Location) (time.Time, error) {
|
||||||
|
|||||||
@@ -74,6 +74,10 @@ func TestRepositoryOptionCRUDAndEntryPlatformOperator(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("创建操作人选项失败: %v", err)
|
t.Fatalf("创建操作人选项失败: %v", err)
|
||||||
}
|
}
|
||||||
|
disbursementOperator, err := repo.CreateOption(ctx, OptionTypeDisbursementOperator, "出款小王", "")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("创建出款实际操作人选项失败: %v", err)
|
||||||
|
}
|
||||||
if _, err := repo.CreateOption(ctx, OptionTypePlatform, "网易大神", ""); !errors.Is(err, ErrOptionExists) {
|
if _, err := repo.CreateOption(ctx, OptionTypePlatform, "网易大神", ""); !errors.Is(err, ErrOptionExists) {
|
||||||
t.Fatalf("重复平台应返回 ErrOptionExists, got %v", err)
|
t.Fatalf("重复平台应返回 ErrOptionExists, got %v", err)
|
||||||
}
|
}
|
||||||
@@ -105,6 +109,9 @@ func TestRepositoryOptionCRUDAndEntryPlatformOperator(t *testing.T) {
|
|||||||
if len(options.Operators) != 2 {
|
if len(options.Operators) != 2 {
|
||||||
t.Fatalf("操作人选项 = %+v, want 2 条", options.Operators)
|
t.Fatalf("操作人选项 = %+v, want 2 条", options.Operators)
|
||||||
}
|
}
|
||||||
|
if len(options.DisbursementOperators) != 1 || options.DisbursementOperators[0].ID != disbursementOperator.ID {
|
||||||
|
t.Fatalf("出款实际操作人选项 = %+v, want 1 条", options.DisbursementOperators)
|
||||||
|
}
|
||||||
|
|
||||||
// 2. 录单写入平台 / 操作人
|
// 2. 录单写入平台 / 操作人
|
||||||
entry, err := repo.Create(ctx, admin.ID, "客服小张", "cs001", "202610130001", EntryGroupCollect, "网易", "技术测试", "备注1")
|
entry, err := repo.Create(ctx, admin.ID, "客服小张", "cs001", "202610130001", EntryGroupCollect, "网易", "技术测试", "备注1")
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ func (s *Service) TodayAgentStats(ctx context.Context) ([]AgentDayStatsDTO, erro
|
|||||||
return s.repo.TodayAgentStats(ctx, timeutil.ShanghaiNow())
|
return s.repo.TodayAgentStats(ctx, timeutil.ShanghaiNow())
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListOptions 返回平台与操作人两组可选项。
|
// ListOptions 返回平台、操作人与出款实际操作人三组可选项。
|
||||||
func (s *Service) ListOptions(ctx context.Context) (*OptionListDTO, error) {
|
func (s *Service) ListOptions(ctx context.Context) (*OptionListDTO, error) {
|
||||||
if s.repo == nil {
|
if s.repo == nil {
|
||||||
return nil, ErrDependencyUnavailable
|
return nil, ErrDependencyUnavailable
|
||||||
@@ -112,7 +112,15 @@ func (s *Service) ListOptions(ctx context.Context) (*OptionListDTO, error) {
|
|||||||
return s.repo.ListAllOptions(ctx)
|
return s.repo.ListAllOptions(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateOption 新增平台 / 操作人选项。
|
// ListDisbursementOperators 返回线下结算实际操作人可选项。
|
||||||
|
func (s *Service) ListDisbursementOperators(ctx context.Context) ([]OptionDTO, error) {
|
||||||
|
if s.repo == nil {
|
||||||
|
return nil, ErrDependencyUnavailable
|
||||||
|
}
|
||||||
|
return s.repo.ListOptions(ctx, OptionTypeDisbursementOperator)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOption 新增平台 / 操作人 / 出款实际操作人选项。
|
||||||
func (s *Service) CreateOption(ctx context.Context, req CreateOptionRequest) (*OptionDTO, error) {
|
func (s *Service) CreateOption(ctx context.Context, req CreateOptionRequest) (*OptionDTO, error) {
|
||||||
if s.repo == nil {
|
if s.repo == nil {
|
||||||
return nil, ErrDependencyUnavailable
|
return nil, ErrDependencyUnavailable
|
||||||
@@ -135,7 +143,7 @@ func (s *Service) CreateOption(ctx context.Context, req CreateOptionRequest) (*O
|
|||||||
return s.repo.CreateOption(ctx, optionType, name, groupTag)
|
return s.repo.CreateOption(ctx, optionType, name, groupTag)
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateOption 重命名平台 / 操作人选项。
|
// UpdateOption 重命名选项。
|
||||||
func (s *Service) UpdateOption(ctx context.Context, id uint64, req UpdateOptionRequest) (*OptionDTO, error) {
|
func (s *Service) UpdateOption(ctx context.Context, id uint64, req UpdateOptionRequest) (*OptionDTO, error) {
|
||||||
if s.repo == nil {
|
if s.repo == nil {
|
||||||
return nil, ErrDependencyUnavailable
|
return nil, ErrDependencyUnavailable
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ type OrderDTO struct {
|
|||||||
OfflineSettlementStatus string `json:"offline_settlement_status,omitempty"`
|
OfflineSettlementStatus string `json:"offline_settlement_status,omitempty"`
|
||||||
OfflineSettlementAmountCent int64 `json:"offline_settlement_amount_cent"`
|
OfflineSettlementAmountCent int64 `json:"offline_settlement_amount_cent"`
|
||||||
OfflineSettlementRemark string `json:"offline_settlement_remark,omitempty"`
|
OfflineSettlementRemark string `json:"offline_settlement_remark,omitempty"`
|
||||||
|
ActualPayoutOperator string `json:"offline_settlement_actual_operator,omitempty"`
|
||||||
OfflineSettledBy *uint64 `json:"offline_settled_by,omitempty"`
|
OfflineSettledBy *uint64 `json:"offline_settled_by,omitempty"`
|
||||||
OfflineSettledAt *time.Time `json:"offline_settled_at,omitempty"`
|
OfflineSettledAt *time.Time `json:"offline_settled_at,omitempty"`
|
||||||
RefundStatus string `json:"refund_status,omitempty"`
|
RefundStatus string `json:"refund_status,omitempty"`
|
||||||
@@ -225,7 +226,8 @@ type ForceHandoffRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type OfflineSettlementRequest struct {
|
type OfflineSettlementRequest struct {
|
||||||
Remark string `json:"remark"`
|
ActualOperator string `json:"actual_operator" binding:"required,max=64"`
|
||||||
|
Remark string `json:"remark"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type AdminOrderQuery struct {
|
type AdminOrderQuery struct {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"hfb_sys/backend/internal/middleware"
|
"hfb_sys/backend/internal/middleware"
|
||||||
"hfb_sys/backend/pkg/response"
|
"hfb_sys/backend/pkg/response"
|
||||||
@@ -177,7 +178,12 @@ func (h *Handler) AdminMarkOfflineSettlement(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
var req OfflineSettlementRequest
|
var req OfflineSettlementRequest
|
||||||
if err := c.ShouldBindJSON(&req); err != nil && !errors.Is(err, io.EOF) {
|
if err := c.ShouldBindJSON(&req); err != nil && !errors.Is(err, io.EOF) {
|
||||||
response.BadRequest(c, "线下结算备注格式不正确")
|
response.BadRequest(c, "请选择出款实际操作人,并检查结算备注")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
req.ActualOperator = strings.TrimSpace(req.ActualOperator)
|
||||||
|
if req.ActualOperator == "" {
|
||||||
|
response.BadRequest(c, "请选择出款实际操作人")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := h.service.AdminMarkOfflineSettlement(c.Request.Context(), adminID, id, req, auditMeta(c)); err != nil {
|
if err := h.service.AdminMarkOfflineSettlement(c.Request.Context(), adminID, id, req, auditMeta(c)); err != nil {
|
||||||
|
|||||||
@@ -444,19 +444,24 @@ func (r *Repository) AdminMarkOfflineSettlement(ctx context.Context, adminID uin
|
|||||||
now := time.Now()
|
now := time.Now()
|
||||||
order.OfflineSettlementStatus = offlineSettlementStatusSettled
|
order.OfflineSettlementStatus = offlineSettlementStatusSettled
|
||||||
order.OfflineSettlementRemark = req.Remark
|
order.OfflineSettlementRemark = req.Remark
|
||||||
|
order.ActualPayoutOperator = req.ActualOperator
|
||||||
order.OfflineSettledBy = &adminID
|
order.OfflineSettledBy = &adminID
|
||||||
order.OfflineSettledAt = &now
|
order.OfflineSettledAt = &now
|
||||||
order.OwnerSettledAt = &now
|
order.OwnerSettledAt = &now
|
||||||
if err := appendOrderEvent(tx, order, "settlement", "offline_settlement_confirmed", processlog.ActorAdmin, adminID, processlog.ActorUser, &order.OwnerID, "确认已完成线下结算。", req.Remark, map[string]any{"offline_settlement_amount_cent": order.OfflineSettlementAmountCent}, before, nil); err != nil {
|
if err := appendOrderEvent(tx, order, "settlement", "offline_settlement_confirmed", processlog.ActorAdmin, adminID, processlog.ActorUser, &order.OwnerID, "确认已完成线下结算。", req.Remark, map[string]any{
|
||||||
|
"offline_settlement_amount_cent": order.OfflineSettlementAmountCent,
|
||||||
|
"offline_settlement_actual_operator": order.ActualPayoutOperator,
|
||||||
|
}, before, nil); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := appendAuditLog(tx, adminID, "order.offline_settlement", "order", order.ID, meta, map[string]any{
|
if err := appendAuditLog(tx, adminID, "order.offline_settlement", "order", order.ID, meta, map[string]any{
|
||||||
"order_id": order.ID,
|
"order_id": order.ID,
|
||||||
"order_no": order.OrderNo,
|
"order_no": order.OrderNo,
|
||||||
"before_offline_settlement_status": beforeStatus,
|
"before_offline_settlement_status": beforeStatus,
|
||||||
"after_offline_settlement_status": order.OfflineSettlementStatus,
|
"after_offline_settlement_status": order.OfflineSettlementStatus,
|
||||||
"offline_settlement_amount_cent": order.OfflineSettlementAmountCent,
|
"offline_settlement_amount_cent": order.OfflineSettlementAmountCent,
|
||||||
"remark": req.Remark,
|
"offline_settlement_actual_operator": order.ActualPayoutOperator,
|
||||||
|
"remark": req.Remark,
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -138,6 +138,7 @@ func (row orderRow) toAdminDTO() OrderDTO {
|
|||||||
OfflineSettlementStatus: effectiveOfflineSettlementStatus(row.RentalOrder),
|
OfflineSettlementStatus: effectiveOfflineSettlementStatus(row.RentalOrder),
|
||||||
OfflineSettlementAmountCent: row.OfflineSettlementAmountCent,
|
OfflineSettlementAmountCent: row.OfflineSettlementAmountCent,
|
||||||
OfflineSettlementRemark: row.OfflineSettlementRemark,
|
OfflineSettlementRemark: row.OfflineSettlementRemark,
|
||||||
|
ActualPayoutOperator: row.ActualPayoutOperator,
|
||||||
OfflineSettledBy: row.OfflineSettledBy,
|
OfflineSettledBy: row.OfflineSettledBy,
|
||||||
OfflineSettledAt: row.OfflineSettledAt,
|
OfflineSettledAt: row.OfflineSettledAt,
|
||||||
RefundStatus: row.RefundStatus,
|
RefundStatus: row.RefundStatus,
|
||||||
|
|||||||
@@ -14,8 +14,9 @@ const processBusinessOrder = "order"
|
|||||||
func orderState(order model.RentalOrder) map[string]any {
|
func orderState(order model.RentalOrder) map[string]any {
|
||||||
return map[string]any{
|
return map[string]any{
|
||||||
"order_status": order.Status, "handoff_status": order.HandoffStatus,
|
"order_status": order.Status, "handoff_status": order.HandoffStatus,
|
||||||
"settlement_status": order.SettlementStatus,
|
"settlement_status": order.SettlementStatus,
|
||||||
"offline_settlement_status": effectiveOfflineSettlementStatus(order),
|
"offline_settlement_status": effectiveOfflineSettlementStatus(order),
|
||||||
|
"offline_settlement_actual_operator": order.ActualPayoutOperator,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1868,7 +1868,10 @@ func TestPlatformManagedOrderOfflineSettlementFlow(t *testing.T) {
|
|||||||
t.Fatal("admin dto should expose offline settlement action")
|
t.Fatal("admin dto should expose offline settlement action")
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := repo.AdminMarkOfflineSettlement(t.Context(), adminID, order.ID, OfflineSettlementRequest{Remark: "支付宝线下转账"}, AuditMeta{}); err != nil {
|
if err := repo.AdminMarkOfflineSettlement(t.Context(), adminID, order.ID, OfflineSettlementRequest{
|
||||||
|
ActualOperator: "出款小王",
|
||||||
|
Remark: "支付宝线下转账",
|
||||||
|
}, AuditMeta{}); err != nil {
|
||||||
t.Fatalf("AdminMarkOfflineSettlement() error = %v", err)
|
t.Fatalf("AdminMarkOfflineSettlement() error = %v", err)
|
||||||
}
|
}
|
||||||
if err := db.First(&saved, order.ID).Error; err != nil {
|
if err := db.First(&saved, order.ID).Error; err != nil {
|
||||||
@@ -1886,6 +1889,9 @@ func TestPlatformManagedOrderOfflineSettlementFlow(t *testing.T) {
|
|||||||
if saved.OfflineSettlementRemark != "支付宝线下转账" {
|
if saved.OfflineSettlementRemark != "支付宝线下转账" {
|
||||||
t.Fatalf("offline settlement remark = %q", saved.OfflineSettlementRemark)
|
t.Fatalf("offline settlement remark = %q", saved.OfflineSettlementRemark)
|
||||||
}
|
}
|
||||||
|
if saved.ActualPayoutOperator != "出款小王" {
|
||||||
|
t.Fatalf("offline settlement actual operator = %q", saved.ActualPayoutOperator)
|
||||||
|
}
|
||||||
if err := db.Model(&model.WalletLedger{}).Where("user_id = ?", owner.ID).Count(&ownerLedgerCount).Error; err != nil {
|
if err := db.Model(&model.WalletLedger{}).Where("user_id = ?", owner.ID).Count(&ownerLedgerCount).Error; err != nil {
|
||||||
t.Fatalf("recount wallet ledger failed: %v", err)
|
t.Fatalf("recount wallet ledger failed: %v", err)
|
||||||
}
|
}
|
||||||
@@ -1969,7 +1975,10 @@ func TestAdminMarkOfflineSettlementAllowsArbitratedPlatformOrder(t *testing.T) {
|
|||||||
if !canAdminMarkOfflineSettlement(order) {
|
if !canAdminMarkOfflineSettlement(order) {
|
||||||
t.Fatal("arbitrated platform order should allow offline settlement")
|
t.Fatal("arbitrated platform order should allow offline settlement")
|
||||||
}
|
}
|
||||||
if err := repo.AdminMarkOfflineSettlement(t.Context(), adminID, order.ID, OfflineSettlementRequest{Remark: "仲裁后线下转账"}, AuditMeta{}); err != nil {
|
if err := repo.AdminMarkOfflineSettlement(t.Context(), adminID, order.ID, OfflineSettlementRequest{
|
||||||
|
ActualOperator: "出款小李",
|
||||||
|
Remark: "仲裁后线下转账",
|
||||||
|
}, AuditMeta{}); err != nil {
|
||||||
t.Fatalf("AdminMarkOfflineSettlement() error = %v", err)
|
t.Fatalf("AdminMarkOfflineSettlement() error = %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1983,6 +1992,9 @@ func TestAdminMarkOfflineSettlementAllowsArbitratedPlatformOrder(t *testing.T) {
|
|||||||
if saved.OfflineSettledBy == nil || *saved.OfflineSettledBy != adminID {
|
if saved.OfflineSettledBy == nil || *saved.OfflineSettledBy != adminID {
|
||||||
t.Fatalf("offline settled by = %#v, want %d", saved.OfflineSettledBy, adminID)
|
t.Fatalf("offline settled by = %#v, want %d", saved.OfflineSettledBy, adminID)
|
||||||
}
|
}
|
||||||
|
if saved.ActualPayoutOperator != "出款小李" {
|
||||||
|
t.Fatalf("offline settlement actual operator = %q", saved.ActualPayoutOperator)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPlatformManagedCheckoutIncludesConsumableAndDepositCompensation(t *testing.T) {
|
func TestPlatformManagedCheckoutIncludesConsumableAndDepositCompensation(t *testing.T) {
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ type PickupDTO struct {
|
|||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
OfflineSettlementStatus string `json:"offline_settlement_status"`
|
OfflineSettlementStatus string `json:"offline_settlement_status"`
|
||||||
OfflineSettlementRemark string `json:"offline_settlement_remark"`
|
OfflineSettlementRemark string `json:"offline_settlement_remark"`
|
||||||
|
ActualPayoutOperator string `json:"offline_settlement_actual_operator"`
|
||||||
OfflineSettledBy *uint64 `json:"offline_settled_by,omitempty"`
|
OfflineSettledBy *uint64 `json:"offline_settled_by,omitempty"`
|
||||||
OfflineSettledAt *time.Time `json:"offline_settled_at,omitempty"`
|
OfflineSettledAt *time.Time `json:"offline_settled_at,omitempty"`
|
||||||
Remark string `json:"remark"`
|
Remark string `json:"remark"`
|
||||||
@@ -129,7 +130,8 @@ type CompleteRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type OfflineSettlementRequest struct {
|
type OfflineSettlementRequest struct {
|
||||||
Remark string `json:"remark" binding:"max=255"`
|
ActualOperator string `json:"actual_operator" binding:"required,max=64"`
|
||||||
|
Remark string `json:"remark" binding:"max=255"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type UpdateProfitRequest struct {
|
type UpdateProfitRequest struct {
|
||||||
|
|||||||
@@ -79,7 +79,12 @@ func (h *Handler) MarkOfflineSettlement(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
var req OfflineSettlementRequest
|
var req OfflineSettlementRequest
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := c.ShouldBindJSON(&req); err != nil {
|
||||||
response.BadRequest(c, "线下结算备注格式不正确")
|
response.BadRequest(c, "请选择出款实际操作人,并检查结算备注")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
req.ActualOperator = strings.TrimSpace(req.ActualOperator)
|
||||||
|
if req.ActualOperator == "" {
|
||||||
|
response.BadRequest(c, "请选择出款实际操作人")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
item, err := h.service.MarkOfflineSettlement(c.Request.Context(), id, req, adminID, auditMeta(c))
|
item, err := h.service.MarkOfflineSettlement(c.Request.Context(), id, req, adminID, auditMeta(c))
|
||||||
|
|||||||
@@ -35,7 +35,8 @@ type ProcessEventDTO struct {
|
|||||||
func pickupState(row model.AdminPickup) map[string]any {
|
func pickupState(row model.AdminPickup) map[string]any {
|
||||||
return map[string]any{
|
return map[string]any{
|
||||||
"pickup_status": row.Status, "offline_settlement_status": row.OfflineSettlementStatus,
|
"pickup_status": row.Status, "offline_settlement_status": row.OfflineSettlementStatus,
|
||||||
"settlement_mode": row.SettlementMode,
|
"settlement_mode": row.SettlementMode,
|
||||||
|
"offline_settlement_actual_operator": row.ActualPayoutOperator,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -405,6 +405,7 @@ func (r *Repository) MarkOfflineSettlement(ctx context.Context, pickupID uint64,
|
|||||||
now := time.Now()
|
now := time.Now()
|
||||||
pickup.OfflineSettlementStatus = OfflineSettlementStatusSettled
|
pickup.OfflineSettlementStatus = OfflineSettlementStatusSettled
|
||||||
pickup.OfflineSettlementRemark = strings.TrimSpace(req.Remark)
|
pickup.OfflineSettlementRemark = strings.TrimSpace(req.Remark)
|
||||||
|
pickup.ActualPayoutOperator = strings.TrimSpace(req.ActualOperator)
|
||||||
pickup.OfflineSettledBy = &adminID
|
pickup.OfflineSettledBy = &adminID
|
||||||
pickup.OfflineSettledAt = &now
|
pickup.OfflineSettledAt = &now
|
||||||
if err := tx.Save(&pickup).Error; err != nil {
|
if err := tx.Save(&pickup).Error; err != nil {
|
||||||
@@ -424,6 +425,7 @@ func (r *Repository) MarkOfflineSettlement(ctx context.Context, pickupID uint64,
|
|||||||
}
|
}
|
||||||
if err := appendPickupEvent(tx, pickup, "pickup_offline_settlement_confirmed", adminID, "确认已完成提号线下结算。", pickup.OfflineSettlementRemark, map[string]any{
|
if err := appendPickupEvent(tx, pickup, "pickup_offline_settlement_confirmed", adminID, "确认已完成提号线下结算。", pickup.OfflineSettlementRemark, map[string]any{
|
||||||
"settle_amount_cent": effectiveSettleAmountCent, "settled_adjustment_count": pendingTotals.Count,
|
"settle_amount_cent": effectiveSettleAmountCent, "settled_adjustment_count": pendingTotals.Count,
|
||||||
|
"offline_settlement_actual_operator": pickup.ActualPayoutOperator,
|
||||||
}, before); err != nil {
|
}, before); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -437,12 +439,13 @@ func (r *Repository) MarkOfflineSettlement(ctx context.Context, pickupID uint64,
|
|||||||
BizID: &bid,
|
BizID: &bid,
|
||||||
Meta: meta,
|
Meta: meta,
|
||||||
Detail: map[string]any{
|
Detail: map[string]any{
|
||||||
"pickup_no": pickup.PickupNo,
|
"pickup_no": pickup.PickupNo,
|
||||||
"settle_amount_cent": effectiveSettleAmountCent,
|
"settle_amount_cent": effectiveSettleAmountCent,
|
||||||
"settled_adjustment_count": pendingTotals.Count,
|
"settled_adjustment_count": pendingTotals.Count,
|
||||||
"before_offline_settlement_status": OfflineSettlementStatusPending,
|
"before_offline_settlement_status": OfflineSettlementStatusPending,
|
||||||
"after_offline_settlement_status": pickup.OfflineSettlementStatus,
|
"after_offline_settlement_status": pickup.OfflineSettlementStatus,
|
||||||
"remark": pickup.OfflineSettlementRemark,
|
"offline_settlement_actual_operator": pickup.ActualPayoutOperator,
|
||||||
|
"remark": pickup.OfflineSettlementRemark,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -1619,6 +1622,7 @@ func (row pickupRow) toDTO() PickupDTO {
|
|||||||
Status: row.Status,
|
Status: row.Status,
|
||||||
OfflineSettlementStatus: row.OfflineSettlementStatus,
|
OfflineSettlementStatus: row.OfflineSettlementStatus,
|
||||||
OfflineSettlementRemark: row.OfflineSettlementRemark,
|
OfflineSettlementRemark: row.OfflineSettlementRemark,
|
||||||
|
ActualPayoutOperator: row.ActualPayoutOperator,
|
||||||
OfflineSettledBy: row.OfflineSettledBy,
|
OfflineSettledBy: row.OfflineSettledBy,
|
||||||
OfflineSettledAt: row.OfflineSettledAt,
|
OfflineSettledAt: row.OfflineSettledAt,
|
||||||
Remark: row.Remark,
|
Remark: row.Remark,
|
||||||
|
|||||||
@@ -526,7 +526,10 @@ func TestRepositoryCompletePlatformManagedPickupUsesOfflineSettlement(t *testing
|
|||||||
t.Fatalf("平台代管提号不应生成钱包流水, got %d", ledgerCount)
|
t.Fatalf("平台代管提号不应生成钱包流水, got %d", ledgerCount)
|
||||||
}
|
}
|
||||||
|
|
||||||
settled, err := repo.MarkOfflineSettlement(t.Context(), pickup.ID, OfflineSettlementRequest{Remark: "已转账"}, 100, auditlog.Meta{})
|
settled, err := repo.MarkOfflineSettlement(t.Context(), pickup.ID, OfflineSettlementRequest{
|
||||||
|
ActualOperator: "出款小王",
|
||||||
|
Remark: "已转账",
|
||||||
|
}, 100, auditlog.Meta{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("MarkOfflineSettlement() error = %v", err)
|
t.Fatalf("MarkOfflineSettlement() error = %v", err)
|
||||||
}
|
}
|
||||||
@@ -536,6 +539,9 @@ func TestRepositoryCompletePlatformManagedPickupUsesOfflineSettlement(t *testing
|
|||||||
if settled.OfflineSettlementRemark != "已转账" {
|
if settled.OfflineSettlementRemark != "已转账" {
|
||||||
t.Fatalf("线下结算备注 = %q", settled.OfflineSettlementRemark)
|
t.Fatalf("线下结算备注 = %q", settled.OfflineSettlementRemark)
|
||||||
}
|
}
|
||||||
|
if settled.ActualPayoutOperator != "出款小王" {
|
||||||
|
t.Fatalf("实际操作人 = %q, want 出款小王", settled.ActualPayoutOperator)
|
||||||
|
}
|
||||||
var audit model.AuditLog
|
var audit model.AuditLog
|
||||||
if err := db.Where("action = ? AND biz_id = ?", "pickup_offline_settlement", pickup.ID).First(&audit).Error; err != nil {
|
if err := db.Where("action = ? AND biz_id = ?", "pickup_offline_settlement", pickup.ID).First(&audit).Error; err != nil {
|
||||||
t.Fatalf("确认线下结算应写审计日志: %v", err)
|
t.Fatalf("确认线下结算应写审计日志: %v", err)
|
||||||
@@ -634,7 +640,9 @@ func TestRepositoryFinancialAdjustmentSettlesPlatformManagedPickupSeparately(t *
|
|||||||
if _, err = repo.Complete(t.Context(), pickup.ID, CompleteRequest{SettleAmountCent: 12000}, 99, auditlog.Meta{}); err != nil {
|
if _, err = repo.Complete(t.Context(), pickup.ID, CompleteRequest{SettleAmountCent: 12000}, 99, auditlog.Meta{}); err != nil {
|
||||||
t.Fatalf("Complete() error = %v", err)
|
t.Fatalf("Complete() error = %v", err)
|
||||||
}
|
}
|
||||||
if _, err = repo.MarkOfflineSettlement(t.Context(), pickup.ID, OfflineSettlementRequest{}, 100, auditlog.Meta{}); err != nil {
|
if _, err = repo.MarkOfflineSettlement(t.Context(), pickup.ID, OfflineSettlementRequest{
|
||||||
|
ActualOperator: "出款甲",
|
||||||
|
}, 100, auditlog.Meta{}); err != nil {
|
||||||
t.Fatalf("MarkOfflineSettlement() error = %v", err)
|
t.Fatalf("MarkOfflineSettlement() error = %v", err)
|
||||||
}
|
}
|
||||||
updated, err := repo.CreateFinancialAdjustment(t.Context(), pickup.ID, FinancialAdjustmentRequest{
|
updated, err := repo.CreateFinancialAdjustment(t.Context(), pickup.ID, FinancialAdjustmentRequest{
|
||||||
@@ -701,7 +709,10 @@ func TestRepositoryOfflineSettlementProcessesPendingPickupAdjustments(t *testing
|
|||||||
if err != nil || len(adjustments) != 1 || adjustments[0].Status != FinancialAdjustmentStatusPending {
|
if err != nil || len(adjustments) != 1 || adjustments[0].Status != FinancialAdjustmentStatusPending {
|
||||||
t.Fatalf("结算前调整流水 = %+v, %v", adjustments, err)
|
t.Fatalf("结算前调整流水 = %+v, %v", adjustments, err)
|
||||||
}
|
}
|
||||||
settled, err := repo.MarkOfflineSettlement(t.Context(), pickup.ID, OfflineSettlementRequest{Remark: "按修正后金额打款"}, 101, auditlog.Meta{})
|
settled, err := repo.MarkOfflineSettlement(t.Context(), pickup.ID, OfflineSettlementRequest{
|
||||||
|
ActualOperator: "出款乙",
|
||||||
|
Remark: "按修正后金额打款",
|
||||||
|
}, 101, auditlog.Meta{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("MarkOfflineSettlement() error = %v", err)
|
t.Fatalf("MarkOfflineSettlement() error = %v", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -776,6 +776,11 @@ func New(cfg config.Config, deps Dependencies, logger *zap.Logger) *gin.Engine {
|
|||||||
adminRoutes.GET("/dashboard", requirePerm("dashboard:view"), adminDashboardHandler.Summary)
|
adminRoutes.GET("/dashboard", requirePerm("dashboard:view"), adminDashboardHandler.Summary)
|
||||||
adminRoutes.GET("/manual-entries/today-stats", requirePerm("cs_manual_entry:view"), manualEntryHandler.TodayAgentStats)
|
adminRoutes.GET("/manual-entries/today-stats", requirePerm("cs_manual_entry:view"), manualEntryHandler.TodayAgentStats)
|
||||||
adminRoutes.GET("/manual-entries/options", requirePerm("cs_manual_entry:view"), manualEntryHandler.ListOptions)
|
adminRoutes.GET("/manual-entries/options", requirePerm("cs_manual_entry:view"), manualEntryHandler.ListOptions)
|
||||||
|
adminRoutes.GET(
|
||||||
|
"/manual-entries/options/disbursement-operators",
|
||||||
|
requireAnyPerm("cs_manual_entry:view", "order:mark_abnormal", "order:pickup", "wallet:view"),
|
||||||
|
manualEntryHandler.ListDisbursementOperators,
|
||||||
|
)
|
||||||
adminRoutes.POST("/manual-entries/options", requirePerm("cs_manual_entry:option_manage"), manualEntryHandler.CreateOption)
|
adminRoutes.POST("/manual-entries/options", requirePerm("cs_manual_entry:option_manage"), manualEntryHandler.CreateOption)
|
||||||
adminRoutes.PUT("/manual-entries/options/:id", requirePerm("cs_manual_entry:option_manage"), manualEntryHandler.UpdateOption)
|
adminRoutes.PUT("/manual-entries/options/:id", requirePerm("cs_manual_entry:option_manage"), manualEntryHandler.UpdateOption)
|
||||||
adminRoutes.DELETE("/manual-entries/options/:id", requirePerm("cs_manual_entry:option_manage"), manualEntryHandler.DeleteOption)
|
adminRoutes.DELETE("/manual-entries/options/:id", requirePerm("cs_manual_entry:option_manage"), manualEntryHandler.DeleteOption)
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
-- +goose Up
|
||||||
|
|
||||||
|
-- 线下结算实际操作人:保存管理员在确认结算时选择的名称快照。
|
||||||
|
-- offline_settled_by 仍保留为执行确认动作的后台账号,两者语义不同。
|
||||||
|
ALTER TABLE cs_manual_entry_options
|
||||||
|
MODIFY COLUMN type VARCHAR(32) NOT NULL COMMENT '选项类型: platform=平台, operator=录单操作人, disbursement_operator=出款实际操作人';
|
||||||
|
|
||||||
|
ALTER TABLE rental_orders
|
||||||
|
ADD COLUMN offline_settlement_actual_operator VARCHAR(64) NOT NULL DEFAULT ''
|
||||||
|
COMMENT '线下结算实际操作人名称快照' AFTER offline_settlement_remark,
|
||||||
|
ADD KEY idx_rental_orders_actual_operator (offline_settlement_actual_operator);
|
||||||
|
|
||||||
|
ALTER TABLE admin_pickups
|
||||||
|
ADD COLUMN offline_settlement_actual_operator VARCHAR(64) NOT NULL DEFAULT ''
|
||||||
|
COMMENT '线下结算实际操作人名称快照' AFTER offline_settlement_remark,
|
||||||
|
ADD KEY idx_admin_pickups_actual_operator (offline_settlement_actual_operator);
|
||||||
|
|
||||||
|
-- +goose Down
|
||||||
|
|
||||||
|
ALTER TABLE admin_pickups
|
||||||
|
DROP KEY idx_admin_pickups_actual_operator,
|
||||||
|
DROP COLUMN offline_settlement_actual_operator;
|
||||||
|
|
||||||
|
ALTER TABLE rental_orders
|
||||||
|
DROP KEY idx_rental_orders_actual_operator,
|
||||||
|
DROP COLUMN offline_settlement_actual_operator;
|
||||||
|
|
||||||
|
DELETE FROM cs_manual_entry_options WHERE type = 'disbursement_operator';
|
||||||
|
|
||||||
|
ALTER TABLE cs_manual_entry_options
|
||||||
|
MODIFY COLUMN type VARCHAR(16) NOT NULL COMMENT '选项类型: platform=平台, operator=操作人';
|
||||||
@@ -155,6 +155,7 @@ export interface FinanceDisbursementItem {
|
|||||||
paid_at?: string
|
paid_at?: string
|
||||||
operator_id?: number
|
operator_id?: number
|
||||||
operator_name: string
|
operator_name: string
|
||||||
|
actual_operator_name: string
|
||||||
remark: string
|
remark: string
|
||||||
category: string
|
category: string
|
||||||
custom_category_name: string
|
custom_category_name: string
|
||||||
@@ -204,6 +205,7 @@ export interface FinanceDisbursementQuery extends FinanceDateQuery {
|
|||||||
operator?: string
|
operator?: string
|
||||||
operator_name?: string
|
operator_name?: string
|
||||||
operator_id?: string
|
operator_id?: string
|
||||||
|
actual_operator?: string
|
||||||
user_id?: string
|
user_id?: string
|
||||||
page?: number
|
page?: number
|
||||||
page_size?: number
|
page_size?: number
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ import { apiClient } from '@/shared/api/client'
|
|||||||
|
|
||||||
import type { ApiResponse, PaginatedResult } from '@/shared/types/types'
|
import type { ApiResponse, PaginatedResult } from '@/shared/types/types'
|
||||||
|
|
||||||
/** 录单可选项类型:平台 / 操作人 */
|
/** 可选项类型:平台 / 录单操作人 / 出款实际操作人 */
|
||||||
export type ManualEntryOptionType = 'platform' | 'operator'
|
export type ManualEntryOptionType = 'platform' | 'operator' | 'disbursement_operator'
|
||||||
|
|
||||||
/** 录单组别:收号 / 出号 */
|
/** 录单组别:收号 / 出号 */
|
||||||
export type ManualEntryGroup = 'collect' | 'sell'
|
export type ManualEntryGroup = 'collect' | 'sell'
|
||||||
@@ -34,6 +34,7 @@ export interface ManualEntryOption {
|
|||||||
export interface ManualEntryOptions {
|
export interface ManualEntryOptions {
|
||||||
platforms: ManualEntryOption[]
|
platforms: ManualEntryOption[]
|
||||||
operators: ManualEntryOption[]
|
operators: ManualEntryOption[]
|
||||||
|
disbursement_operators: ManualEntryOption[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ManualEntryAgentStats {
|
export interface ManualEntryAgentStats {
|
||||||
@@ -121,6 +122,14 @@ export async function fetchManualEntryOptions() {
|
|||||||
return data.data
|
return data.data
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 获取线下结算实际操作人选项。 */
|
||||||
|
export async function fetchDisbursementOperators() {
|
||||||
|
const { data } = await apiClient.get<ApiResponse<ManualEntryOption[]>>(
|
||||||
|
'/admin/manual-entries/options/disbursement-operators'
|
||||||
|
)
|
||||||
|
return data.data
|
||||||
|
}
|
||||||
|
|
||||||
export async function createManualEntryOption(payload: {
|
export async function createManualEntryOption(payload: {
|
||||||
type: ManualEntryOptionType
|
type: ManualEntryOptionType
|
||||||
name: string
|
name: string
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ export interface AdminPickup {
|
|||||||
status: string
|
status: string
|
||||||
offline_settlement_status: PickupOfflineSettlementStatus
|
offline_settlement_status: PickupOfflineSettlementStatus
|
||||||
offline_settlement_remark: string
|
offline_settlement_remark: string
|
||||||
|
offline_settlement_actual_operator: string
|
||||||
offline_settled_by?: number
|
offline_settled_by?: number
|
||||||
offline_settled_at?: string
|
offline_settled_at?: string
|
||||||
remark: string
|
remark: string
|
||||||
@@ -140,6 +141,7 @@ export interface AdminPickupThirdPartyOrderNoUpdateRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface AdminPickupOfflineSettlementRequest {
|
export interface AdminPickupOfflineSettlementRequest {
|
||||||
|
actual_operator: string
|
||||||
remark?: string
|
remark?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -347,7 +349,7 @@ export async function completeAdminPickup(id: number, req: AdminPickupCompleteRe
|
|||||||
|
|
||||||
export async function confirmAdminPickupOfflineSettlement(
|
export async function confirmAdminPickupOfflineSettlement(
|
||||||
id: number,
|
id: number,
|
||||||
req: AdminPickupOfflineSettlementRequest = {}
|
req: AdminPickupOfflineSettlementRequest
|
||||||
) {
|
) {
|
||||||
const { data } = await apiClient.post<ApiResponse<AdminPickup>>(
|
const { data } = await apiClient.post<ApiResponse<AdminPickup>>(
|
||||||
`/admin/pickups/${id}/offline-settlement`,
|
`/admin/pickups/${id}/offline-settlement`,
|
||||||
|
|||||||
@@ -156,6 +156,7 @@ const filters = reactive({
|
|||||||
business_no: '',
|
business_no: '',
|
||||||
keyword: '',
|
keyword: '',
|
||||||
operator: '',
|
operator: '',
|
||||||
|
actual_operator: '',
|
||||||
user_id: '',
|
user_id: '',
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -196,6 +197,7 @@ function resetFilters() {
|
|||||||
filters.business_no = ''
|
filters.business_no = ''
|
||||||
filters.keyword = ''
|
filters.keyword = ''
|
||||||
filters.operator = ''
|
filters.operator = ''
|
||||||
|
filters.actual_operator = ''
|
||||||
filters.user_id = ''
|
filters.user_id = ''
|
||||||
currentPage.value = 1
|
currentPage.value = 1
|
||||||
void loadItems()
|
void loadItems()
|
||||||
@@ -600,10 +602,18 @@ function accountTypeLabel(type: string) {
|
|||||||
<el-input v-model="filters.keyword" clearable placeholder="姓名、手机号或账号" />
|
<el-input v-model="filters.keyword" clearable placeholder="姓名、手机号或账号" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item label="操作人">
|
<el-form-item label="管理员操作人">
|
||||||
<el-input v-model="filters.operator" clearable placeholder="姓名、用户名或管理员 ID" />
|
<el-input v-model="filters.operator" clearable placeholder="姓名、用户名或管理员 ID" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item label="实际操作人">
|
||||||
|
<el-input
|
||||||
|
v-model="filters.actual_operator"
|
||||||
|
clearable
|
||||||
|
placeholder="按出款实际操作人筛选"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item label="用户 ID">
|
<el-form-item label="用户 ID">
|
||||||
<el-input v-model="filters.user_id" clearable placeholder="按用户 ID 检索" />
|
<el-input v-model="filters.user_id" clearable placeholder="按用户 ID 检索" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@@ -722,12 +732,18 @@ function accountTypeLabel(type: string) {
|
|||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
|
||||||
<el-table-column label="操作人" min-width="110">
|
<el-table-column label="管理员操作人" min-width="120">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<span class="operator-name">{{ row.operator_name || '-' }}</span>
|
<span class="operator-name">{{ row.operator_name || '-' }}</span>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
|
||||||
|
<el-table-column label="实际操作人" min-width="120">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<span class="operator-name">{{ row.actual_operator_name || '-' }}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
|
||||||
<el-table-column label="备注" min-width="160" show-overflow-tooltip>
|
<el-table-column label="备注" min-width="160" show-overflow-tooltip>
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<span class="remark-text">{{ row.remark || '-' }}</span>
|
<span class="remark-text">{{ row.remark || '-' }}</span>
|
||||||
|
|||||||
@@ -98,7 +98,7 @@
|
|||||||
|
|
||||||
.option-config-grid {
|
.option-config-grid {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||||
gap: 20px;
|
gap: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,11 @@ const filters = reactive({
|
|||||||
dateRange: null as string[] | null,
|
dateRange: null as string[] | null,
|
||||||
})
|
})
|
||||||
|
|
||||||
const options = ref<ManualEntryOptions>({ platforms: [], operators: [] })
|
const options = ref<ManualEntryOptions>({
|
||||||
|
platforms: [],
|
||||||
|
operators: [],
|
||||||
|
disbursement_operators: [],
|
||||||
|
})
|
||||||
const optionsLoading = ref(false)
|
const optionsLoading = ref(false)
|
||||||
|
|
||||||
const entryForm = reactive({
|
const entryForm = reactive({
|
||||||
@@ -273,16 +277,26 @@ const optionSubmitting = ref(false)
|
|||||||
const newPlatformName = ref('')
|
const newPlatformName = ref('')
|
||||||
const newOperatorName = ref('')
|
const newOperatorName = ref('')
|
||||||
const newOperatorGroupTag = ref<ManualEntryGroup | ''>('')
|
const newOperatorGroupTag = ref<ManualEntryGroup | ''>('')
|
||||||
|
const newDisbursementOperatorName = ref('')
|
||||||
|
|
||||||
function openConfig() {
|
function openConfig() {
|
||||||
configVisible.value = true
|
configVisible.value = true
|
||||||
if (!options.value.platforms.length && !options.value.operators.length) {
|
if (
|
||||||
|
!options.value.platforms.length &&
|
||||||
|
!options.value.operators.length &&
|
||||||
|
!options.value.disbursement_operators.length
|
||||||
|
) {
|
||||||
void loadOptions()
|
void loadOptions()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleAddOption(type: ManualEntryOptionType) {
|
async function handleAddOption(type: ManualEntryOptionType) {
|
||||||
const name = (type === 'platform' ? newPlatformName.value : newOperatorName.value).trim()
|
const name =
|
||||||
|
type === 'platform'
|
||||||
|
? newPlatformName.value.trim()
|
||||||
|
: type === 'operator'
|
||||||
|
? newOperatorName.value.trim()
|
||||||
|
: newDisbursementOperatorName.value.trim()
|
||||||
if (!name) {
|
if (!name) {
|
||||||
ElMessage.warning('请输入名称')
|
ElMessage.warning('请输入名称')
|
||||||
return
|
return
|
||||||
@@ -294,10 +308,13 @@ async function handleAddOption(type: ManualEntryOptionType) {
|
|||||||
name,
|
name,
|
||||||
group_tag: type === 'operator' ? newOperatorGroupTag.value || undefined : undefined,
|
group_tag: type === 'operator' ? newOperatorGroupTag.value || undefined : undefined,
|
||||||
})
|
})
|
||||||
if (type === 'platform') newPlatformName.value = ''
|
if (type === 'platform') {
|
||||||
else {
|
newPlatformName.value = ''
|
||||||
|
} else if (type === 'operator') {
|
||||||
newOperatorName.value = ''
|
newOperatorName.value = ''
|
||||||
newOperatorGroupTag.value = ''
|
newOperatorGroupTag.value = ''
|
||||||
|
} else {
|
||||||
|
newDisbursementOperatorName.value = ''
|
||||||
}
|
}
|
||||||
ElMessage.success('已添加')
|
ElMessage.success('已添加')
|
||||||
await loadOptions()
|
await loadOptions()
|
||||||
@@ -326,7 +343,10 @@ async function handleRenameOption(item: ManualEntryOption) {
|
|||||||
if (!name || name === item.name) return
|
if (!name || name === item.name) return
|
||||||
optionSubmitting.value = true
|
optionSubmitting.value = true
|
||||||
try {
|
try {
|
||||||
await updateManualEntryOption(item.id, { name, group_tag: item.group_tag })
|
await updateManualEntryOption(item.id, {
|
||||||
|
name,
|
||||||
|
group_tag: item.type === 'operator' ? item.group_tag : '',
|
||||||
|
})
|
||||||
ElMessage.success('已重命名')
|
ElMessage.success('已重命名')
|
||||||
await loadOptions()
|
await loadOptions()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -358,9 +378,11 @@ async function handleOperatorGroupChange(item: ManualEntryOption, groupTag: Manu
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function handleRemoveOption(item: ManualEntryOption) {
|
async function handleRemoveOption(item: ManualEntryOption) {
|
||||||
|
const typeLabel =
|
||||||
|
item.type === 'platform' ? '平台' : item.type === 'operator' ? '录单操作人' : '出款实际操作人'
|
||||||
try {
|
try {
|
||||||
await ElMessageBox.confirm(
|
await ElMessageBox.confirm(
|
||||||
`确定删除${item.type === 'platform' ? '平台' : '操作人'}【${item.name}】吗?历史录单记录不受影响。`,
|
`确定删除${typeLabel}【${item.name}】吗?历史记录不受影响。`,
|
||||||
'删除确认',
|
'删除确认',
|
||||||
{ confirmButtonText: '确认删除', cancelButtonText: '取消', type: 'warning' }
|
{ confirmButtonText: '确认删除', cancelButtonText: '取消', type: 'warning' }
|
||||||
)
|
)
|
||||||
@@ -391,7 +413,7 @@ async function handleRemoveOption(item: ManualEntryOption) {
|
|||||||
</div>
|
</div>
|
||||||
<div class="page-header-actions">
|
<div class="page-header-actions">
|
||||||
<el-button v-if="canManageOptions" :loading="optionsLoading" @click="openConfig">
|
<el-button v-if="canManageOptions" :loading="optionsLoading" @click="openConfig">
|
||||||
配置平台/操作人
|
配置平台/操作人/出款人
|
||||||
</el-button>
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -626,17 +648,17 @@ async function handleRemoveOption(item: ManualEntryOption) {
|
|||||||
</template>
|
</template>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
|
||||||
<!-- 平台 / 操作人配置弹窗 -->
|
<!-- 平台 / 操作人 / 出款实际操作人配置弹窗 -->
|
||||||
<el-dialog
|
<el-dialog
|
||||||
v-model="configVisible"
|
v-model="configVisible"
|
||||||
title="配置平台与操作人"
|
title="配置平台、操作人与出款实际操作人"
|
||||||
width="720px"
|
width="980px"
|
||||||
destroy-on-close
|
destroy-on-close
|
||||||
class="manual-entry-config-dialog"
|
class="manual-entry-config-dialog"
|
||||||
>
|
>
|
||||||
<p class="option-config-tip">
|
<p class="option-config-tip">
|
||||||
这里维护的可选项会出现在录单表单的下拉中;删除选项不会影响已登记的历史记录。
|
录单操作人与出款实际操作人是两套独立配置。出款实际操作人用于平台代管订单和提号确认线下结算;
|
||||||
操作人可设置组别标记(收号/出号),录单选中后自动带出对应组别。
|
删除选项不会影响已保存的历史记录。
|
||||||
</p>
|
</p>
|
||||||
<div class="option-config-grid">
|
<div class="option-config-grid">
|
||||||
<section class="option-config-panel">
|
<section class="option-config-panel">
|
||||||
@@ -726,6 +748,42 @@ async function handleRemoveOption(item: ManualEntryOption) {
|
|||||||
</ul>
|
</ul>
|
||||||
<p v-if="!options.operators.length" class="option-config-empty">暂无操作人,请先添加</p>
|
<p v-if="!options.operators.length" class="option-config-empty">暂无操作人,请先添加</p>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<section class="option-config-panel">
|
||||||
|
<header class="option-config-title">出款实际操作人</header>
|
||||||
|
<div class="option-config-add">
|
||||||
|
<el-input
|
||||||
|
v-model="newDisbursementOperatorName"
|
||||||
|
placeholder="新增出款实际操作人"
|
||||||
|
maxlength="64"
|
||||||
|
clearable
|
||||||
|
@keyup.enter="handleAddOption('disbursement_operator')"
|
||||||
|
/>
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
:loading="optionSubmitting"
|
||||||
|
@click="handleAddOption('disbursement_operator')"
|
||||||
|
>
|
||||||
|
添加
|
||||||
|
</el-button>
|
||||||
|
</div>
|
||||||
|
<ul class="option-config-list">
|
||||||
|
<li v-for="item in options.disbursement_operators" :key="item.id">
|
||||||
|
<span class="option-config-name">{{ item.name }}</span>
|
||||||
|
<span class="option-config-actions">
|
||||||
|
<el-button link type="primary" size="small" @click="handleRenameOption(item)">
|
||||||
|
重命名
|
||||||
|
</el-button>
|
||||||
|
<el-button link type="danger" size="small" @click="handleRemoveOption(item)">
|
||||||
|
删除
|
||||||
|
</el-button>
|
||||||
|
</span>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<p v-if="!options.disbursement_operators.length" class="option-config-empty">
|
||||||
|
暂无可选实际出款人,请先添加
|
||||||
|
</p>
|
||||||
|
</section>
|
||||||
</div>
|
</div>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<el-button type="primary" @click="configVisible = false">关闭</el-button>
|
<el-button type="primary" @click="configVisible = false">关闭</el-button>
|
||||||
|
|||||||
@@ -29,6 +29,10 @@ import {
|
|||||||
} from '@/features/orders'
|
} from '@/features/orders'
|
||||||
import { adminCreateOrderDispute } from '@/features/disputes'
|
import { adminCreateOrderDispute } from '@/features/disputes'
|
||||||
import { fetchAdminPayments, type AdminPayment } from '@/features/admin/api/adminPayments'
|
import { fetchAdminPayments, type AdminPayment } from '@/features/admin/api/adminPayments'
|
||||||
|
import {
|
||||||
|
fetchDisbursementOperators,
|
||||||
|
type ManualEntryOption,
|
||||||
|
} from '@/features/admin/api/adminManualEntry'
|
||||||
import CheckoutSystemDetail from '@/features/orders/components/CheckoutSystemDetail.vue'
|
import CheckoutSystemDetail from '@/features/orders/components/CheckoutSystemDetail.vue'
|
||||||
import {
|
import {
|
||||||
getSnapshotHafCoinM,
|
getSnapshotHafCoinM,
|
||||||
@@ -95,6 +99,9 @@ const platformCheckoutCounterForm = ref({
|
|||||||
})
|
})
|
||||||
const offlineSettlementVisible = ref(false)
|
const offlineSettlementVisible = ref(false)
|
||||||
const offlineSettlementRemark = ref('')
|
const offlineSettlementRemark = ref('')
|
||||||
|
const offlineSettlementOperator = ref('')
|
||||||
|
const disbursementOperators = ref<ManualEntryOption[]>([])
|
||||||
|
const disbursementOperatorsLoading = ref(false)
|
||||||
const platformSubmitting = ref(false)
|
const platformSubmitting = ref(false)
|
||||||
const adminDisputeVisible = ref(false)
|
const adminDisputeVisible = ref(false)
|
||||||
const adminDisputeSubmitting = ref(false)
|
const adminDisputeSubmitting = ref(false)
|
||||||
@@ -792,16 +799,42 @@ async function submitAdminDispute() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function loadDisbursementOperators() {
|
||||||
|
if (disbursementOperatorsLoading.value) return
|
||||||
|
disbursementOperatorsLoading.value = true
|
||||||
|
fetchDisbursementOperators()
|
||||||
|
.then(items => {
|
||||||
|
disbursementOperators.value = Array.isArray(items) ? items : []
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
ElMessage.error(readError(error, '获取出款实际操作人失败'))
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
disbursementOperatorsLoading.value = false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
function openOfflineSettlement() {
|
function openOfflineSettlement() {
|
||||||
offlineSettlementRemark.value = ''
|
offlineSettlementRemark.value = ''
|
||||||
|
offlineSettlementOperator.value = ''
|
||||||
offlineSettlementVisible.value = true
|
offlineSettlementVisible.value = true
|
||||||
|
if (!disbursementOperators.value.length) loadDisbursementOperators()
|
||||||
}
|
}
|
||||||
|
|
||||||
async function submitOfflineSettlement() {
|
async function submitOfflineSettlement() {
|
||||||
if (!order.value) return
|
if (!order.value) return
|
||||||
|
const actualOperator = offlineSettlementOperator.value.trim()
|
||||||
|
if (!actualOperator) {
|
||||||
|
ElMessage.warning('请选择出款实际操作人')
|
||||||
|
return
|
||||||
|
}
|
||||||
platformSubmitting.value = true
|
platformSubmitting.value = true
|
||||||
try {
|
try {
|
||||||
await adminMarkOfflineSettlement(order.value.id, offlineSettlementRemark.value.trim())
|
await adminMarkOfflineSettlement(
|
||||||
|
order.value.id,
|
||||||
|
actualOperator,
|
||||||
|
offlineSettlementRemark.value.trim()
|
||||||
|
)
|
||||||
ElMessage.success('线下结算已确认')
|
ElMessage.success('线下结算已确认')
|
||||||
offlineSettlementVisible.value = false
|
offlineSettlementVisible.value = false
|
||||||
await loadOrder()
|
await loadOrder()
|
||||||
@@ -1279,6 +1312,10 @@ function formatRatioNumber(value: number) {
|
|||||||
<dt>确认客服</dt>
|
<dt>确认客服</dt>
|
||||||
<dd>ID {{ order.offline_settled_by }}</dd>
|
<dd>ID {{ order.offline_settled_by }}</dd>
|
||||||
</div>
|
</div>
|
||||||
|
<div v-if="order.offline_settlement_actual_operator">
|
||||||
|
<dt>实际操作人</dt>
|
||||||
|
<dd>{{ order.offline_settlement_actual_operator }}</dd>
|
||||||
|
</div>
|
||||||
<div v-if="order.offline_settled_at">
|
<div v-if="order.offline_settled_at">
|
||||||
<dt>确认时间</dt>
|
<dt>确认时间</dt>
|
||||||
<dd>{{ formatDateTime(order.offline_settled_at) }}</dd>
|
<dd>{{ formatDateTime(order.offline_settled_at) }}</dd>
|
||||||
@@ -1778,12 +1815,34 @@ function formatRatioNumber(value: number) {
|
|||||||
待打款金额
|
待打款金额
|
||||||
<strong>{{ moneyCent(order.offline_settlement_amount_cent) }}</strong>
|
<strong>{{ moneyCent(order.offline_settlement_amount_cent) }}</strong>
|
||||||
</p>
|
</p>
|
||||||
<el-input
|
<el-form label-position="top">
|
||||||
v-model="offlineSettlementRemark"
|
<el-form-item label="实际操作人" required>
|
||||||
type="textarea"
|
<el-select
|
||||||
:rows="4"
|
v-model="offlineSettlementOperator"
|
||||||
placeholder="填写线下转账备注,可留空"
|
filterable
|
||||||
/>
|
clearable
|
||||||
|
class="full-control"
|
||||||
|
:loading="disbursementOperatorsLoading"
|
||||||
|
placeholder="请选择实际完成出款的人员"
|
||||||
|
no-data-text="暂无可选项,请先在客服手动录单的配置中添加"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="item in disbursementOperators"
|
||||||
|
:key="item.id"
|
||||||
|
:label="item.name"
|
||||||
|
:value="item.name"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="结算备注">
|
||||||
|
<el-input
|
||||||
|
v-model="offlineSettlementRemark"
|
||||||
|
type="textarea"
|
||||||
|
:rows="4"
|
||||||
|
placeholder="填写线下转账备注,可留空"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
</div>
|
</div>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<el-button @click="offlineSettlementVisible = false">取消</el-button>
|
<el-button @click="offlineSettlementVisible = false">取消</el-button>
|
||||||
|
|||||||
@@ -499,6 +499,10 @@ function readSnapshotResources(summary: Record<string, unknown> | null): Snapsho
|
|||||||
<dt>线下结算时间</dt>
|
<dt>线下结算时间</dt>
|
||||||
<dd>{{ formatDateTime(pickup.offline_settled_at, '待确认') }}</dd>
|
<dd>{{ formatDateTime(pickup.offline_settled_at, '待确认') }}</dd>
|
||||||
</div>
|
</div>
|
||||||
|
<div v-if="pickup.settlement_mode === 'platform_managed'">
|
||||||
|
<dt>实际操作人</dt>
|
||||||
|
<dd>{{ pickup.offline_settlement_actual_operator || '-' }}</dd>
|
||||||
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<dt>交易渠道</dt>
|
<dt>交易渠道</dt>
|
||||||
<dd>{{ pickup.platform || '-' }}</dd>
|
<dd>{{ pickup.platform || '-' }}</dd>
|
||||||
|
|||||||
@@ -20,12 +20,17 @@ import {
|
|||||||
type PickupAccountSource,
|
type PickupAccountSource,
|
||||||
type PickupOfflineSettlementStatus,
|
type PickupOfflineSettlementStatus,
|
||||||
} from '@/features/admin/api/adminPickup'
|
} from '@/features/admin/api/adminPickup'
|
||||||
|
import {
|
||||||
|
fetchDisbursementOperators,
|
||||||
|
type ManualEntryOption,
|
||||||
|
} from '@/features/admin/api/adminManualEntry'
|
||||||
import PickupShopDialog from '@/features/admin/components/PickupShopDialog.vue'
|
import PickupShopDialog from '@/features/admin/components/PickupShopDialog.vue'
|
||||||
import { useAdminSessionStore } from '@/stores/adminSession'
|
import { useAdminSessionStore } from '@/stores/adminSession'
|
||||||
import { centToYuan, formatCentWithSymbol, yuanToCent } from '@/shared/utils/money'
|
import { centToYuan, formatCentWithSymbol, yuanToCent } from '@/shared/utils/money'
|
||||||
import { formatDateTime } from '@/shared/utils/time'
|
import { formatDateTime } from '@/shared/utils/time'
|
||||||
import { pickupStatusLabel } from '@/shared/utils/statusLabels'
|
import { pickupStatusLabel } from '@/shared/utils/statusLabels'
|
||||||
import { adminPath } from '@/shared/utils/adminPath'
|
import { adminPath } from '@/shared/utils/adminPath'
|
||||||
|
import { readError } from '@/shared/utils/error'
|
||||||
|
|
||||||
const adminSession = useAdminSessionStore()
|
const adminSession = useAdminSessionStore()
|
||||||
const currentAdminName = computed(() => adminSession.nickname || adminSession.username || '')
|
const currentAdminName = computed(() => adminSession.nickname || adminSession.username || '')
|
||||||
@@ -62,12 +67,14 @@ const completeDialogVisible = ref(false)
|
|||||||
const profitDialogVisible = ref(false)
|
const profitDialogVisible = ref(false)
|
||||||
const financialAdjustmentDialogVisible = ref(false)
|
const financialAdjustmentDialogVisible = ref(false)
|
||||||
const thirdPartyOrderNoDialogVisible = ref(false)
|
const thirdPartyOrderNoDialogVisible = ref(false)
|
||||||
|
const offlineSettlementDialogVisible = ref(false)
|
||||||
const shopMgrVisible = ref(false)
|
const shopMgrVisible = ref(false)
|
||||||
const activePickupId = ref(0)
|
const activePickupId = ref(0)
|
||||||
const activePickup = ref<AdminPickup | null>(null)
|
const activePickup = ref<AdminPickup | null>(null)
|
||||||
const profitSaving = ref(false)
|
const profitSaving = ref(false)
|
||||||
const financialAdjustmentSaving = ref(false)
|
const financialAdjustmentSaving = ref(false)
|
||||||
const thirdPartyOrderNoSaving = ref(false)
|
const thirdPartyOrderNoSaving = ref(false)
|
||||||
|
const offlineSettlementSaving = ref(false)
|
||||||
const thirdPartyOrderNoForm = reactive({ third_party_order_no: '' })
|
const thirdPartyOrderNoForm = reactive({ third_party_order_no: '' })
|
||||||
|
|
||||||
const createForm = reactive({
|
const createForm = reactive({
|
||||||
@@ -84,6 +91,9 @@ const createForm = reactive({
|
|||||||
const completeForm = reactive({ settle_amount: 0, profit_amount: 0, complete_remark: '' })
|
const completeForm = reactive({ settle_amount: 0, profit_amount: 0, complete_remark: '' })
|
||||||
const profitForm = reactive({ profit_amount: 0, reason: '' })
|
const profitForm = reactive({ profit_amount: 0, reason: '' })
|
||||||
const financialAdjustmentForm = reactive({ profit_amount: 0, settle_amount: 0, reason: '' })
|
const financialAdjustmentForm = reactive({ profit_amount: 0, settle_amount: 0, reason: '' })
|
||||||
|
const offlineSettlementForm = reactive({ actual_operator: '', remark: '' })
|
||||||
|
const disbursementOperators = ref<ManualEntryOption[]>([])
|
||||||
|
const disbursementOperatorsLoading = ref(false)
|
||||||
|
|
||||||
const listingOptions = ref<AvailableListing[]>([])
|
const listingOptions = ref<AvailableListing[]>([])
|
||||||
const listingLoading = ref(false)
|
const listingLoading = ref(false)
|
||||||
@@ -310,31 +320,54 @@ function openCompleteDialog(row: AdminPickup) {
|
|||||||
completeDialogVisible.value = true
|
completeDialogVisible.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleConfirmOfflineSettlement(row: AdminPickup) {
|
function loadDisbursementOperators() {
|
||||||
|
if (disbursementOperatorsLoading.value) return
|
||||||
|
disbursementOperatorsLoading.value = true
|
||||||
|
fetchDisbursementOperators()
|
||||||
|
.then(items => {
|
||||||
|
disbursementOperators.value = Array.isArray(items) ? items : []
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
ElMessage.error(readError(error, '获取出款实际操作人失败'))
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
disbursementOperatorsLoading.value = false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function openOfflineSettlementDialog(row: AdminPickup) {
|
||||||
|
activePickupId.value = row.id
|
||||||
|
activePickup.value = row
|
||||||
|
offlineSettlementForm.actual_operator = ''
|
||||||
|
offlineSettlementForm.remark = ''
|
||||||
|
offlineSettlementDialogVisible.value = true
|
||||||
|
if (!disbursementOperators.value.length) loadDisbursementOperators()
|
||||||
|
}
|
||||||
|
|
||||||
|
async function submitOfflineSettlement() {
|
||||||
|
if (!activePickupId.value) return
|
||||||
|
const actualOperator = offlineSettlementForm.actual_operator.trim()
|
||||||
|
if (!actualOperator) {
|
||||||
|
ElMessage.warning('请选择出款实际操作人')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (offlineSettlementForm.remark.length > 255) {
|
||||||
|
ElMessage.warning('结算备注不能超过 255 个字符')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
offlineSettlementSaving.value = true
|
||||||
try {
|
try {
|
||||||
const { value } = await ElMessageBox.prompt(
|
await confirmAdminPickupOfflineSettlement(activePickupId.value, {
|
||||||
`确认已向卖家线下支付 ${formatCentWithSymbol(effectiveSettleCent(row))}?`,
|
actual_operator: actualOperator,
|
||||||
'确认线下结算',
|
remark: offlineSettlementForm.remark.trim(),
|
||||||
{
|
})
|
||||||
confirmButtonText: '确认已打款',
|
ElMessage.success('已确认线下结算')
|
||||||
cancelButtonText: '取消',
|
offlineSettlementDialogVisible.value = false
|
||||||
inputType: 'textarea',
|
loadList()
|
||||||
inputPlaceholder: '结算备注(可选)',
|
} catch (error) {
|
||||||
inputValidator: input => input.length <= 255 || '备注不能超过 255 个字符',
|
ElMessage.error(errorMessage(error) || '确认失败')
|
||||||
}
|
} finally {
|
||||||
)
|
offlineSettlementSaving.value = false
|
||||||
loading.value = true
|
|
||||||
try {
|
|
||||||
await confirmAdminPickupOfflineSettlement(row.id, { remark: value })
|
|
||||||
ElMessage.success('已确认线下结算')
|
|
||||||
loadList()
|
|
||||||
} catch (e: unknown) {
|
|
||||||
ElMessage.error(errorMessage(e) || '确认失败')
|
|
||||||
} finally {
|
|
||||||
loading.value = false
|
|
||||||
}
|
|
||||||
} catch {
|
|
||||||
/* 用户放弃 */
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -803,7 +836,7 @@ function listingOptionLabel(item: AvailableListing) {
|
|||||||
type="primary"
|
type="primary"
|
||||||
size="small"
|
size="small"
|
||||||
plain
|
plain
|
||||||
@click="handleConfirmOfflineSettlement(row)"
|
@click="openOfflineSettlementDialog(row)"
|
||||||
>
|
>
|
||||||
确认线下结算
|
确认线下结算
|
||||||
</el-button>
|
</el-button>
|
||||||
@@ -1180,6 +1213,63 @@ function listingOptionLabel(item: AvailableListing) {
|
|||||||
</template>
|
</template>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
|
||||||
|
<!-- 确认线下结算 -->
|
||||||
|
<el-dialog
|
||||||
|
v-model="offlineSettlementDialogVisible"
|
||||||
|
title="确认线下结算"
|
||||||
|
width="520px"
|
||||||
|
destroy-on-close
|
||||||
|
>
|
||||||
|
<el-form label-position="top">
|
||||||
|
<el-form-item label="提号单号">
|
||||||
|
<span>{{ activePickup?.pickup_no || '-' }}</span>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="确认打款金额">
|
||||||
|
<strong>{{
|
||||||
|
activePickup ? formatCentWithSymbol(effectiveSettleCent(activePickup)) : '-'
|
||||||
|
}}</strong>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="实际操作人" required>
|
||||||
|
<el-select
|
||||||
|
v-model="offlineSettlementForm.actual_operator"
|
||||||
|
filterable
|
||||||
|
clearable
|
||||||
|
class="full-control"
|
||||||
|
:loading="disbursementOperatorsLoading"
|
||||||
|
placeholder="请选择实际完成出款的人员"
|
||||||
|
no-data-text="暂无可选项,请先在客服手动录单的配置中添加"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="item in disbursementOperators"
|
||||||
|
:key="item.id"
|
||||||
|
:label="item.name"
|
||||||
|
:value="item.name"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="结算备注">
|
||||||
|
<el-input
|
||||||
|
v-model="offlineSettlementForm.remark"
|
||||||
|
type="textarea"
|
||||||
|
:rows="4"
|
||||||
|
maxlength="255"
|
||||||
|
show-word-limit
|
||||||
|
placeholder="填写线下转账备注,可留空"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<template #footer>
|
||||||
|
<el-button @click="offlineSettlementDialogVisible = false">取消</el-button>
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
:loading="offlineSettlementSaving"
|
||||||
|
@click="submitOfflineSettlement"
|
||||||
|
>
|
||||||
|
确认已打款
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
|
||||||
<!-- 补录/修改第三方单号 -->
|
<!-- 补录/修改第三方单号 -->
|
||||||
<el-dialog
|
<el-dialog
|
||||||
v-model="thirdPartyOrderNoDialogVisible"
|
v-model="thirdPartyOrderNoDialogVisible"
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ export interface Order {
|
|||||||
offline_settlement_status?: string
|
offline_settlement_status?: string
|
||||||
offline_settlement_amount_cent?: number
|
offline_settlement_amount_cent?: number
|
||||||
offline_settlement_remark?: string
|
offline_settlement_remark?: string
|
||||||
|
offline_settlement_actual_operator?: string
|
||||||
offline_settled_by?: number
|
offline_settled_by?: number
|
||||||
offline_settled_at?: string
|
offline_settled_at?: string
|
||||||
refund_status?: string
|
refund_status?: string
|
||||||
@@ -619,10 +620,14 @@ export async function adminPlatformCheckoutDispute(id: number, reason: string) {
|
|||||||
return data.data
|
return data.data
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function adminMarkOfflineSettlement(id: number, remark: string) {
|
export async function adminMarkOfflineSettlement(
|
||||||
|
id: number,
|
||||||
|
actualOperator: string,
|
||||||
|
remark: string
|
||||||
|
) {
|
||||||
const { data } = await apiClient.post<ApiResponse<{ settled: boolean }>>(
|
const { data } = await apiClient.post<ApiResponse<{ settled: boolean }>>(
|
||||||
`/admin/orders/${id}/offline-settlement`,
|
`/admin/orders/${id}/offline-settlement`,
|
||||||
{ remark }
|
{ actual_operator: actualOperator, remark }
|
||||||
)
|
)
|
||||||
return data.data
|
return data.data
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user