Skip to content

Commit

Permalink
Fixed: 修正ATM付款通知判斷邏輯
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryder Hsieh authored and Ryder Hsieh committed Mar 29, 2023
1 parent 902199b commit 78a2a51
Showing 1 changed file with 27 additions and 36 deletions.
63 changes: 27 additions & 36 deletions upload/catalog/controller/extension/payment/payunipayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,20 +121,6 @@ public function returnInfo() {
unset($this->session->data['vouchers']);
}

// 訂單付款明細寫入歷程
$this->load->model('checkout/order');
$orderInfo = $this->model_checkout_order->getOrder($encryptInfo['MerTradeNo']);

// 訂單是待處理狀態才更新歷程
if ( $orderInfo['order_status_id'] == $this->configSetting['order_status'] ) {
$this->model_checkout_order->addOrderHistory(
$orderInfo['order_id'],
4, // 待付款
$this->SetNotice($encryptInfo),
true
);
}

// 顯示的 Title
$title = ($encryptInfo['Status'] == 'SUCCESS') ? $this->language->get('heading_title') : $this->language->get('heading_title_fail') . $encryptInfo['Message'];

Expand Down Expand Up @@ -226,28 +212,33 @@ public function notify() {
exit();
}

// 3. 檢查訂單狀態是否為已付款
if ($encryptInfo['TradeStatus'] == '1') {
$msg = $orderInfo['order_id'] . ' OK'; //訂單成功

// 已付款,更新訂單狀態並寫入訂單歷程
$this->model_checkout_order->addOrderHistory(
$orderInfo['order_id'],
$this->configSetting['order_finish_status'],
$this->SetNotice($encryptInfo),
true
);

} else {
$msg = "錯誤: 訂單付款失敗";

// 付款失敗,更新訂單狀態並寫入訂單歷程
$this->model_checkout_order->addOrderHistory(
$orderInfo['order_id'],
$this->configSetting['order_fail_status'],
$msg,
true
);
// 3. 檢查訂單狀態
switch ($encryptInfo['TradeStatus']) {
case '0':
$msg = $orderInfo['order_id'] . ' Pending'; //訂單未付款

// 訂單未付款,更新訂單狀態並寫入訂單歷程
$this->model_checkout_order->addOrderHistory(
$orderInfo['order_id'],
4, // 待付款
$this->SetNotice($encryptInfo),
true
);
break;
case '1':
$msg = $orderInfo['order_id'] . ' OK'; //訂單成功

// 已付款,更新訂單狀態並寫入訂單歷程
$this->model_checkout_order->addOrderHistory(
$orderInfo['order_id'],
$this->configSetting['order_finish_status'],
$this->SetNotice($encryptInfo),
true
);
break;
default:
$msg = '';
break;
}

$this->writeLog($msg);
Expand Down

0 comments on commit 78a2a51

Please sign in to comment.