Files
wordpress-theme-aksrt/inc/helpers/aksrt-transactions.php
T
kate522 1d2505356e feat: remove shop feature (Phase 2)
Delete all shop domain classes, controllers, schema builders, templates,
JS/CSS, admin SPA pages, and shop-only payment classes (Shipping,
AfterSale, Discount). Remove shop-only DB table definitions (product_variant,
after_sale, order_shipping, card_key) from migrator and add their DROP
to uninstall.php. Clean up shared files:

- Remove aksrt_product CPT + taxonomies from Setup.php
- Remove shop rewrite rules/query vars/template redirect from SetupPart2.php
- Remove shop widget areas from SetupPart1.php
- Remove shop enqueues from ScriptsPart1b.php
- Remove sepakerator-aksrt-shop from SetupPart2.php
- Remove get_shop_settings facade (delete ForumShop.php, clean DomainGroups.php)
- Remove ORDER_PRODUCT_SHOP constant from DomainModel.php
- Remove Shop::class fallback branches from UserOrders.php, OrderCenterRest.php
- Remove shipping/after-sale branches from OrderRepositoryAdmin.php, PayMenus.php, PayOrders.php
- Remove shop product widgets from widgets-register.php
- Remove cart page from template-registry.php, routing.php, ScriptsPart2.php
- Remove cart UI from sidebar-nav.php, profile-orders.php, sidebar-orders.php
- Clean up order-center.js (remove rebuy/cartUrl/receipt/after-sale handlers)
- Remove aksrt_get_cart_page_url/product_page/product_edit from transactions.php
- Clean up aksrt_product_cat references in Coupon.php, PayCoupons.php

Shared payment/order/credits/content-pay stack fully retained.
2026-08-02 21:25:52 +08:00

99 lines
3.2 KiB
PHP

<?php
/**
* AKSRT Transaction Helpers
*
* Frontend transaction view-model helpers.
*
* @package AKSRT
*/
defined('ABSPATH') || exit;
function aksrt_get_order_status_labels(): array {
if (class_exists('\AKSRT\Core\DomainModel')) {
return \AKSRT\Core\DomainModel::order_status_labels();
}
return [];
}
function aksrt_get_orders_page_view(int $user_id, int $paged = 1, int $per_page = 20, string $status = '', string $product_type = ''): array {
$empty = [
'items' => [],
'total' => 0,
'total_pages' => 1,
'page' => 1,
'stats' => ['total' => 0, 'pending' => 0, 'paid' => 0],
'product_types' => class_exists('\AKSRT\Core\DomainModel')
? array_merge(['' => __('全部类型', 'aksrt')], \AKSRT\Core\DomainModel::order_product_type_labels())
: [],
];
if ($user_id <= 0) {
return $empty;
}
$args = [
'page' => $paged,
'per_page' => $per_page,
'status' => $status,
'product_type' => $product_type,
];
if (class_exists('\AKSRT\Payment\UserOrders')) {
return \AKSRT\Payment\UserOrders::get_instance()->get_order_center_view($user_id, $args);
}
return $empty;
}
function aksrt_get_revenue_page_view(int $user_id): array {
$balance = 0.0;
$total_earned = 0.0;
$total_withdrawn = 0.0;
$records = [];
if (class_exists('\AKSRT\Credits\Credits')) {
$balance = (float) \AKSRT\Credits\Credits::balance($user_id);
}
if (class_exists('\AKSRT\Payment\Revenue')) {
$revenues = \AKSRT\Payment\Revenue::get_instance()->get_user_revenues($user_id, ['limit' => 200]);
foreach ($revenues as $rev) {
$row = is_array($rev) ? $rev : (array) $rev;
$total_earned += (float) ($row['amount'] ?? 0);
$records[] = [
'type' => 'earning',
'title' => (string) ($row['description'] ?? $row['type'] ?? __('创作分成', 'aksrt')),
'amount' => (float) ($row['amount'] ?? 0),
'created_at' => (string) ($row['created_at'] ?? ''),
];
}
}
if (class_exists('\AKSRT\Payment\Withdrawal')) {
$withdrawals = \AKSRT\Payment\Withdrawal::get_instance()->get_user_withdrawals($user_id, ['limit' => 200]);
foreach ($withdrawals as $w) {
$wrow = is_array($w) ? $w : (array) $w;
$total_withdrawn += (float) ($wrow['amount'] ?? 0);
$records[] = [
'type' => 'withdrawal',
'title' => __('提现', 'aksrt'),
'amount' => (float) ($wrow['amount'] ?? 0),
'created_at' => (string) ($wrow['created_at'] ?? ''),
'status' => (string) ($wrow['status'] ?? ''),
];
}
}
usort($records, static function ($a, $b) {
return strcmp($b['created_at'] ?? '', $a['created_at'] ?? '');
});
return [
'balance' => $balance,
'total_earned' => $total_earned,
'total_withdrawn' => $total_withdrawn,
'records' => $records,
];
}