|
|
|
@ -113,6 +113,37 @@ class Online_payment_note_model extends CI_Model {
|
|
|
|
|
$this->orderby = ' ORDER BY OPN_SN DESC ';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private $code_brandname = array(
|
|
|
|
|
"15002" => "PayPal",
|
|
|
|
|
"15010" => "PayPal",
|
|
|
|
|
"15015" => "Alipay",
|
|
|
|
|
"15016" => "WeChat",
|
|
|
|
|
"15018" => "Credit Card-iPaylinks",
|
|
|
|
|
);
|
|
|
|
|
private $wxpay_app = array(
|
|
|
|
|
"wx749246dd935ca07b" => "APP",
|
|
|
|
|
"wx5d01021a6d515098" => "HLY", // "花梨鹰小程序", // 交行收款码
|
|
|
|
|
"wxd6c8dd69af5128cd" => "", // "NATIVE",
|
|
|
|
|
"wx7e605820faf98a05" => "Trippest-NATIVE",
|
|
|
|
|
"0" => "unknown",
|
|
|
|
|
);
|
|
|
|
|
public function set_brandname(&$ele)
|
|
|
|
|
{
|
|
|
|
|
$ele->brand_name = "none";
|
|
|
|
|
if ($this->code_brandname[$ele->OPN_accountMethod]) {
|
|
|
|
|
$ele->brand_name = $this->code_brandname[$ele->OPN_accountMethod];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$raw = json_decode($ele->OPN_rawContent);
|
|
|
|
|
$wx_app = isset($raw->app_id) ? $raw->app_id : '0';
|
|
|
|
|
$wx_app = $wx_app!=='0' ? $wx_app : (isset($raw->appid) ? $raw->appid : '0');
|
|
|
|
|
|
|
|
|
|
$ele->app_name = "";
|
|
|
|
|
if ($this->wxpay_app[$wx_app]) {
|
|
|
|
|
$ele->app_name = $this->wxpay_app[$wx_app];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function query_note()
|
|
|
|
|
{
|
|
|
|
|
$top_sql = $this->topnum ? (" TOP " . $this->topnum) : "";
|
|
|
|
@ -128,7 +159,9 @@ class Online_payment_note_model extends CI_Model {
|
|
|
|
|
// log_message('error', PHP_EOL . $sql);
|
|
|
|
|
|
|
|
|
|
$query = $this->info->query($sql);
|
|
|
|
|
return $query->result();
|
|
|
|
|
$result = $query->result();
|
|
|
|
|
array_walk($result, 'Online_payment_note_model::set_brandname');
|
|
|
|
|
return $result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function get_note($opn_id)
|
|
|
|
@ -147,6 +180,7 @@ class Online_payment_note_model extends CI_Model {
|
|
|
|
|
$search_sql = "";
|
|
|
|
|
if ( ! empty($keyword)) {
|
|
|
|
|
$search_sql.=" AND ( OPN_transactionId = '$keyword'
|
|
|
|
|
OR OPN_relatedId like '%$keyword%'
|
|
|
|
|
OR OPN_orderId like '%$keyword%'
|
|
|
|
|
OR OPN_rawOrderId like '%$keyword%' )";
|
|
|
|
|
}
|
|
|
|
@ -404,6 +438,61 @@ class Online_payment_note_model extends CI_Model {
|
|
|
|
|
return $result_object;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function add_note_wxpay($result_data, $target_account, $type='pay')
|
|
|
|
|
{
|
|
|
|
|
$this->load->model('Online_payment_account_model', 'account_model');
|
|
|
|
|
foreach ($result_data as $key => $row) {
|
|
|
|
|
$save_column = array();
|
|
|
|
|
$save_column['OPN_accountMethod'] = $this->config->item('method_code', 'wxpay');
|
|
|
|
|
$total_fee = bcdiv($row['total_fee'], $this->config->item('currency_unit', 'wxpay'));
|
|
|
|
|
$OPN_currency = isset($row['currency_type']) ? $row['currency_type'] : (isset($row['fee_type']) ? $row['fee_type'] : 'CNY');
|
|
|
|
|
if ($type != 'pay') {
|
|
|
|
|
// 退款
|
|
|
|
|
$refund_fee = bcdiv($row['refund_fee'], $this->config->item('currency_unit', 'wxpay'));
|
|
|
|
|
$ssje = $this->account_model->get_ssje($refund_fee, str_replace("CNY", "RMB", strtoupper($OPN_currency)), $save_column['OPN_accountMethod']);
|
|
|
|
|
$save_column['OPN_transactionId'] = $row['refund_id'];
|
|
|
|
|
$save_column['OPN_orderAmount'] = "-" . $refund_fee;
|
|
|
|
|
$save_column['OPN_payAmount'] = "-" . $refund_fee;
|
|
|
|
|
$save_column['OPN_resultCode'] = $row['refund_status'];
|
|
|
|
|
$save_column['OPN_resultMsg'] = $row['refund_status'];
|
|
|
|
|
$save_column['OPN_entryAmountCNY'] = floatval("-" . $ssje);
|
|
|
|
|
$save_column['OPN_noticeType'] = $type;
|
|
|
|
|
$save_column['OPN_relatedId'] = $row['transaction_id'];
|
|
|
|
|
$save_column['OPN_acquiringTime'] = date('Y-m-d H:i:s', strtotime($row['refund_success_time']));
|
|
|
|
|
$save_column['OPN_completeTime'] = date('Y-m-d H:i:s', strtotime($row['refund_success_time']));
|
|
|
|
|
} else {
|
|
|
|
|
// 收款
|
|
|
|
|
$total_fee = bcdiv($row['total_fee'], $this->config->item('currency_unit', 'wxpay'));
|
|
|
|
|
$ssje = $this->account_model->get_ssje($total_fee, str_replace("CNY", "RMB", strtoupper($OPN_currency)), $save_column['OPN_accountMethod']);
|
|
|
|
|
$save_column['OPN_transactionId'] = $row['transaction_id'];
|
|
|
|
|
$save_column['OPN_orderAmount'] = $total_fee;
|
|
|
|
|
$save_column['OPN_payAmount'] = $total_fee;
|
|
|
|
|
$save_column['OPN_resultCode'] = $row['trade_state'];
|
|
|
|
|
$save_column['OPN_resultMsg'] = $row['trade_state'];
|
|
|
|
|
$save_column['OPN_entryAmountCNY'] = floatval($ssje);
|
|
|
|
|
$save_column['OPN_noticeType'] = 'pay';
|
|
|
|
|
$save_column['OPN_relatedId'] = '';
|
|
|
|
|
$save_column['OPN_acquiringTime'] = date('Y-m-d H:i:s', strtotime($row['time_end']));
|
|
|
|
|
$save_column['OPN_completeTime'] = date('Y-m-d H:i:s', strtotime($row['time_end']));
|
|
|
|
|
}
|
|
|
|
|
$save_column['OPN_noticeSendStatus'] = 'unsend';
|
|
|
|
|
$save_column['OPN_transactionResult'] = 'completed';
|
|
|
|
|
$save_column['OPN_orderId'] = $row['out_trade_no'];
|
|
|
|
|
$save_column['OPN_rawOrderId'] = $row['out_trade_no'];
|
|
|
|
|
$save_column['OPN_invoiceId'] = $row['out_trade_no'];
|
|
|
|
|
$save_column['OPN_subject'] = isset($row['item_name']) ? $row['item_name'] : '';
|
|
|
|
|
$save_column['OPN_currency'] = $OPN_currency;
|
|
|
|
|
$save_column['OPN_remark'] = empty($row['attach']) ? '' : json_encode($row['attach']);
|
|
|
|
|
$save_column['OPN_payerLogId'] = isset( $row['openid']) ? $row['openid'] : '';
|
|
|
|
|
$save_column['OPN_fundSource'] = $target_account;
|
|
|
|
|
$save_column['OPN_rawContent'] = json_encode($row);
|
|
|
|
|
$save_column['OPN_noticeTime'] = date('Y-m-d H:i:s');
|
|
|
|
|
|
|
|
|
|
// $this->insert_note($save_column) ; // todo:
|
|
|
|
|
// log_message('error', 'test: ' . __CLASS__ . PHP_EOL . var_export($save_column, 1));
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|