fix: PayPal: 重复的webhook记录

webht/payment
Lei OT 1 year ago
parent b6a0658cf0
commit bad05aa0ed

@ -28,11 +28,27 @@ class Online_payment_note_model extends CI_Model {
return $this->info->query($ret, array($refund_id))->num_rows() > 0;
}
public function insert_note($column)
public function insert_note($column, $check_exists = false)
{
if ($column === null) {
return false;
}
if ($check_exists === true) {
$sql = "SELECT TOP 1 OPN_SN
FROM OnlinePaymentNote
WHERE OPN_accountMethod={$column['OPN_accountMethod']} AND OPN_transactionId = '{$column['OPN_transactionId']}'";
$query = $this->info->query($sql);
if ($query->num_rows() > 0) {
$update = array(
'OPN_payFee' => isset($column['OPN_payFee']) ? $column['OPN_payFee'] : null,
'OPN_netAmount' => $column['OPN_netAmount'],
'OPN_entryAmountCNY' => $column['OPN_entryAmountCNY'],
);
$where = " OPN_SN=" . $query->row()->OPN_SN;
$this->update_note($where, $update);
return false;
}
}
$this->info->insert('OnlinePaymentNote', $column);
$ret = "SELECT TOP 1 * FROM OnlinePaymentNote WHERE OPN_transactionId=? ORDER BY OPN_SN DESC ";
return $this->info->query($ret, array($column['OPN_transactionId']))->row();
@ -580,7 +596,7 @@ class Online_payment_note_model extends CI_Model {
$save_column['OPN_fundSource'] = $result_data['fund_source'];
$save_column['OPN_rawContent'] = $result_data['memo'];
$save_column['OPN_noticeTime'] = date('Y-m-d H:i:s');
$this->insert_note($save_column) ;
$this->insert_note($save_column, true) ;
return;
}

Loading…
Cancel
Save