新增全局流水号
This commit is contained in:
@@ -368,8 +368,10 @@ trait OrderRepositoryCore {
|
||||
}
|
||||
}
|
||||
|
||||
private function update_status_in_transaction(string $order_number, string $new_status, array $extra = []): bool {
|
||||
private function update_status_in_transaction(string $order_number, string $new_status, array $extra = []): bool {
|
||||
global $wpdb;
|
||||
$ledger_active = class_exists('\AKSRT\Ledger\LedgerService')
|
||||
&& \AKSRT\Ledger\LedgerService::get_instance()->transaction_active();
|
||||
|
||||
$valid = \AKSRT\Core\DomainModel::order_status_labels();
|
||||
if (!isset($valid[$new_status])) return false;
|
||||
@@ -499,6 +501,13 @@ trait OrderRepositoryCore {
|
||||
}
|
||||
}
|
||||
|
||||
if (!$ledger_active) {
|
||||
$flow_number = \AKSRT\Finance\FinancialFlowService::get_instance()->record_order_payment($paid_order, true);
|
||||
if (is_wp_error($flow_number)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (class_exists('\AKSRT\Payment\CommissionLedger')) {
|
||||
$commission = \AKSRT\Payment\CommissionLedger::get_instance()->record_order_transition(
|
||||
$order_number,
|
||||
@@ -535,6 +544,17 @@ trait OrderRepositoryCore {
|
||||
'args' => [$order_number, $paid_order],
|
||||
];
|
||||
}
|
||||
|
||||
if ($new_status === \AKSRT\Core\DomainModel::ORDER_STATUS_REFUNDED
|
||||
&& $current_status === \AKSRT\Core\DomainModel::ORDER_STATUS_REFUNDING
|
||||
&& !$ledger_active
|
||||
) {
|
||||
$refunded_order = array_merge($order, $update_data, ['status' => $new_status]);
|
||||
$flow_number = \AKSRT\Finance\FinancialFlowService::get_instance()->record_order_refund($refunded_order, true);
|
||||
if (is_wp_error($flow_number)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $result !== false;
|
||||
|
||||
Reference in New Issue
Block a user