feat(withdrawal): 开放售后提现审核权限
This commit is contained in:
@@ -560,6 +560,22 @@ func TestWithdrawalAdminAllTenantScopeIncludesLegacyDistribution(t *testing.T) {
|
||||
t.Fatalf("dachui admin legacy detail error = %v, want not found", err)
|
||||
}
|
||||
|
||||
dachuiFinanceCtx := tenancy.WithScope(context.Background(), tenancy.Scope{
|
||||
TenantID: 101, TenantCode: "dachui",
|
||||
})
|
||||
legacyList, err := repo.AdminList(dachuiFinanceCtx, AdminListQuery{Page: 1, Size: 20})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if legacyList.Total != 2 || len(legacyList.Items) != 2 {
|
||||
t.Fatalf("dachui withdrawal list with legacy records = %+v, want 2", legacyList)
|
||||
}
|
||||
if detail, err := repo.AdminFindByID(dachuiFinanceCtx, withdrawals[0].ID); err != nil {
|
||||
t.Fatalf("dachui legacy detail: %v", err)
|
||||
} else if detail.DistributionSiteID != site.ID {
|
||||
t.Fatalf("dachui legacy detail site = %d, want %d", detail.DistributionSiteID, site.ID)
|
||||
}
|
||||
|
||||
superCtx := tenancy.WithAdminAllTenantScope(dachuiCtx)
|
||||
superList, err := repo.AdminList(superCtx, AdminListQuery{Page: 1, Size: 20})
|
||||
if err != nil {
|
||||
@@ -576,7 +592,7 @@ func TestWithdrawalAdminAllTenantScopeIncludesLegacyDistribution(t *testing.T) {
|
||||
t.Fatalf("legacy withdrawal detail = %+v", detail)
|
||||
}
|
||||
approved := true
|
||||
reviewed, err := repo.Review(superCtx, 1, withdrawals[0].ID, ReviewWithdrawalRequest{Approved: &approved})
|
||||
reviewed, err := repo.Review(dachuiFinanceCtx, 1, withdrawals[0].ID, ReviewWithdrawalRequest{Approved: &approved})
|
||||
if err != nil {
|
||||
t.Fatalf("platform super admin legacy review: %v", err)
|
||||
}
|
||||
|
||||
@@ -86,11 +86,14 @@ func scopeAdminTenant(ctx context.Context, db *gorm.DB, column string) *gorm.DB
|
||||
if tenancy.HasAdminAllTenantScope(ctx) {
|
||||
return db
|
||||
}
|
||||
tenantID := tenancy.IDFromContext(ctx)
|
||||
if tenantID > 0 {
|
||||
return db.Where(column+" = ?", tenantID)
|
||||
scope, ok := tenancy.FromContext(ctx)
|
||||
if !ok {
|
||||
return db
|
||||
}
|
||||
return db
|
||||
if scope.TenantCode == "dachui" {
|
||||
return db.Where("("+column+" = ? OR "+column+" = 0)", scope.TenantID)
|
||||
}
|
||||
return db.Where(column+" = ?", scope.TenantID)
|
||||
}
|
||||
|
||||
func (r *Repository) withdrawalReviewSummary(ctx context.Context, userID, siteID uint64) (WithdrawalReviewSummaryDTO, error) {
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
-- +goose Up
|
||||
|
||||
-- 售后可核验并处理提现,但确认打款仍仅限财务角色。
|
||||
INSERT IGNORE INTO role_permissions (role_id, permission_id)
|
||||
SELECT r.id, p.id
|
||||
FROM roles r
|
||||
JOIN permissions p ON p.code IN ('withdrawal:list', 'withdrawal:detail', 'withdrawal:review')
|
||||
WHERE r.code = 'cs';
|
||||
|
||||
-- +goose Down
|
||||
|
||||
DELETE rp
|
||||
FROM role_permissions rp
|
||||
JOIN roles r ON r.id = rp.role_id
|
||||
JOIN permissions p ON p.id = rp.permission_id
|
||||
WHERE r.code = 'cs'
|
||||
AND p.code IN ('withdrawal:list', 'withdrawal:detail', 'withdrawal:review');
|
||||
@@ -387,7 +387,7 @@ A 站商品进入 B 站货架
|
||||
- 每个站点只能管理本站发起的线下提号;提号时可以选择另一站点的已上架货源。
|
||||
- 跨站线下提号的利润和出款统计归属提号站点,号主结算进入货源站点号主钱包。
|
||||
- 两个站点的手动录单、平台选项、操作人选项和出款操作人选项互不可见。
|
||||
- 历史分销用户、订单、钱包和分销结算不会进入经营站点后台及统计;`tenant_id=0` 的历史分销用户钱包提现由平台超级管理员在提现审核页统一审核,不计入经营站点财务统计。
|
||||
- 历史分销用户、订单、钱包和分销结算不会进入经营站点后台及统计;`tenant_id=0` 的历史分销用户钱包提现可由大锤租户内拥有提现权限的售后/财务审核,确认打款仍仅限财务或平台超级管理员,且不计入经营站点财务统计。
|
||||
- 每个经营站点可以在商品详情中独立设置本站售价和展示状态。
|
||||
- 无租户上下文的任务暂停并告警。
|
||||
- 现有分销 E2E 全部通过。
|
||||
|
||||
@@ -13,12 +13,17 @@ import AuthImage from '@/shared/components/business/AuthImage.vue'
|
||||
import { formatCent, formatCentWithSymbol } from '@/shared/utils/money'
|
||||
import { orderStatusLabel, settlementStatusLabel } from '@/shared/utils/statusLabels'
|
||||
import { formatDateTime } from '@/shared/utils/time'
|
||||
import { useAdminSessionStore } from '@/stores/adminSession'
|
||||
|
||||
const props = defineProps<{
|
||||
modelValue: boolean
|
||||
withdrawal: WithdrawalDetail | null
|
||||
}>()
|
||||
|
||||
const adminSession = useAdminSessionStore()
|
||||
const canReview = computed(() => adminSession.hasPermission('withdrawal:review'))
|
||||
const canPay = computed(() => adminSession.hasPermission('withdrawal:pay'))
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:modelValue', val: boolean): void
|
||||
(e: 'saved'): void
|
||||
@@ -607,7 +612,7 @@ function incomeText(income?: number) {
|
||||
<div class="dialog-footer">
|
||||
<div>
|
||||
<el-button
|
||||
v-if="withdrawal?.status === 'pending'"
|
||||
v-if="withdrawal?.status === 'pending' && canReview"
|
||||
type="success"
|
||||
:loading="submitting"
|
||||
@click="handleReview(true)"
|
||||
@@ -615,7 +620,7 @@ function incomeText(income?: number) {
|
||||
通过审核
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="withdrawal?.status === 'pending'"
|
||||
v-if="withdrawal?.status === 'pending' && canReview"
|
||||
type="danger"
|
||||
:loading="submitting"
|
||||
@click="handleReview(false)"
|
||||
@@ -623,7 +628,7 @@ function incomeText(income?: number) {
|
||||
拒绝
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="withdrawal?.status === 'processing'"
|
||||
v-if="withdrawal?.status === 'processing' && canPay"
|
||||
type="primary"
|
||||
:loading="submitting"
|
||||
@click="handleConfirmPayment"
|
||||
|
||||
@@ -25,10 +25,12 @@ import {
|
||||
} from '@/features/admin/api/adminWithdrawal'
|
||||
import { formatCentWithSymbol } from '@/shared/utils/money'
|
||||
import { formatDateTime } from '@/shared/utils/time'
|
||||
import { useAdminSessionStore } from '@/stores/adminSession'
|
||||
import AdminTablePagination from '../components/AdminTablePagination.vue'
|
||||
import WithdrawalDetailDialog from '../components/WithdrawalDetailDialog.vue'
|
||||
|
||||
const route = useRoute()
|
||||
const adminSession = useAdminSessionStore()
|
||||
|
||||
const loading = ref(false)
|
||||
const withdrawals = ref<WithdrawalListItem[]>([])
|
||||
@@ -63,6 +65,8 @@ const completedAmount = computed(() =>
|
||||
.filter(w => w.status === 'completed')
|
||||
.reduce((sum, w) => sum + Number(w.actual_amount_cent || w.amount_cent || 0), 0)
|
||||
)
|
||||
const canReview = computed(() => adminSession.hasPermission('withdrawal:review'))
|
||||
const canPay = computed(() => adminSession.hasPermission('withdrawal:pay'))
|
||||
|
||||
onMounted(() => {
|
||||
restoreListState()
|
||||
@@ -438,7 +442,7 @@ function money(cent: number | undefined | null) {
|
||||
详情
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="row.status === 'pending'"
|
||||
v-if="row.status === 'pending' && canReview"
|
||||
link
|
||||
type="success"
|
||||
@click="handleReview(row, true)"
|
||||
@@ -446,7 +450,7 @@ function money(cent: number | undefined | null) {
|
||||
通过
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="row.status === 'pending'"
|
||||
v-if="row.status === 'pending' && canReview"
|
||||
link
|
||||
type="danger"
|
||||
@click="handleReview(row, false)"
|
||||
@@ -454,7 +458,7 @@ function money(cent: number | undefined | null) {
|
||||
拒绝
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="row.status === 'processing'"
|
||||
v-if="row.status === 'processing' && canPay"
|
||||
link
|
||||
type="primary"
|
||||
@click="handleConfirmPayment(row)"
|
||||
|
||||
Reference in New Issue
Block a user