diff --git a/webht/third_party/pay/config/lianlian.php b/webht/third_party/pay/config/lianlian.php new file mode 100644 index 00000000..b25c6d5e --- /dev/null +++ b/webht/third_party/pay/config/lianlian.php @@ -0,0 +1,4 @@ +alipayrsaPublicKey = $this->alipay_public_key; - $ret->check = $result = $aop->rsaCheckV1($arr, $this->alipay_public_key, $this->signtype); + $ret->check = $result = $aop->rsaCheckV2($arr, $this->alipay_public_key, $this->signtype); if ($result === false) { log_message('error','Alipay sign ERROR ! orderId:'.$arr_obj->out_trade_no.'; dealId:'.$arr_obj->trade_no . "; Original return:".json_encode($arr)."; "); return $ret; diff --git a/webht/third_party/pay/controllers/LianlianService.php b/webht/third_party/pay/controllers/LianlianService.php new file mode 100644 index 00000000..be607587 --- /dev/null +++ b/webht/third_party/pay/controllers/LianlianService.php @@ -0,0 +1,236 @@ +load->helper('payment'); + $this->config->load('lianlian', true); + $this->load->model('Online_payment_note_model', 'note_model'); + $this->load->model('Online_payment_account_model', 'account_model'); + + $this->merchant_config = $this->config->item('test', 'lianlian'); + } + + public function index() {} + + public function query_status() {} + + public function query_payment() {} + + public function query_refund() {} + + public function notify($site = 'cht') + { + // $this->merchant_config = $this->config->item($site, 'lianlian'); // test: 测试环境 + + error_reporting(0); + log_message('error', 'LianlianPay notify begin ----'); + $response['code'] = 0; + $response['message'] = ''; + $raw_post_data = file_get_contents('php://input'); + if (empty($raw_post_data)) { + # 如果没有数据,直接返回失败 + return $this->output->set_content_type('application/json')->set_output(json_encode($response)); + } + log_message('error','test: ' . __METHOD__ . ': ' . __LINE__ . ' ' . PHP_EOL . var_export($raw_post_data, 1)); + + $signature = $this->input->server('HTTP_SIGNATURE'); + $payment_result = json_decode($raw_post_data, true); + if ($this->check_sign($payment_result, $signature) !== true) { + $response['message'] = 'sign error'; + // return $this->output->set_content_type('application/json')->set_output(json_encode($response)); + } + + $payment_data = $payment_result['payment_data']; + $payment_result['GAI_API'] = array( + 'merchant' => $site, + 'invoice' => $payment_result['merchant_transaction_id'], + 'transaction_id' => $payment_result['ll_transaction_id'], + ); + + // todo: 计算手续费, 实收 + $payment_fee = $payment_data['payment_amount'] - $payment_data['settlement_amount']; + $ssje = $this->account_model->get_ssje($payment_data['settlement_amount'], str_replace("CNY", "RMB", strtoupper($payment_data['settlement_currency_code'])), $this->merchant_config['method_code']); + $save_column = array(); + $save_column['OPN_transactionId'] = $payment_result['ll_transaction_id']; + $save_column['OPN_orderId'] = $payment_result['merchant_transaction_id']; + $save_column['OPN_rawOrderId'] = $payment_result['merchant_transaction_id']; + $save_column['OPN_invoiceId'] = $payment_result['merchant_transaction_id']; + $save_column['OPN_subject'] = $payment_result['merchant_transaction_id']; + $save_column['OPN_currency'] = $payment_data['payment_currency_code']; + $save_column['OPN_orderAmount'] = $payment_data['payment_amount']; + $save_column['OPN_payAmount'] = $payment_data['payment_amount']; + // $save_column['OPN_payFee'] = $payment_fee; // todo: 计算手续费; 退款 1USD 原手续费不退 + $save_column['OPN_netAmount'] = $payment_data['settlement_amount']; + $save_column['OPN_transactionResult'] = $payment_data['payment_status'] === 'PS' ? 'completed' : 'declined'; + $save_column['OPN_resultCode'] = $payment_data['payment_status']; + // $save_column['OPN_resultMsg'] = isset($payment_result['return_msg']) ? $payment_result['return_msg'] : $payment_result['result_code']; + // $save_column['OPN_errCode'] = isset($payment_result['err_code']) ? $payment_result['err_code'] : NULL; + // $save_column['OPN_errMsg'] = isset($payment_result['err_code_des']) ? $payment_result['err_code_des'] : NULL; + $save_column['OPN_acquiringTime'] = date('Y-m-d H:i:s', strtotime($payment_data['payment_time'])); + $save_column['OPN_completeTime'] = date('Y-m-d H:i:s', strtotime($payment_data['payment_time'])); + // $save_column['OPN_remark'] = $payment_result['attach'] ? $payment_result['attach'] : $payment_result['out_trade_no']; + // $save_column['OPN_payerLogId'] = $payment_result['openid']; + // $save_column['OPN_payerStatus'] = $payment_result['is_subscribe']==='Y' ? "subscribed" : NULL; + $save_column['OPN_fundSource'] = $site; + $save_column['OPN_entryAmountCNY'] = floatval($ssje); + $save_column['OPN_rawContent'] = json_encode($payment_result); + $save_column['OPN_noticeTime'] = date('Y-m-d H:i:s'); + // $save_column['OPN_noticeType'] = intval($payment_result['total_fee'])>0 ? 'pay' : 'refund'; + $save_column['OPN_noticeType'] = 'pay'; + $save_column['OPN_noticeSendStatus'] = $payment_data['payment_status'] === 'PS' ? 'unsend' : 'closed'; + $save_column['OPN_noticeSendTime'] = NULL; + $save_column['OPN_accountMethod'] = $this->merchant_config['method_code']; + + if ($this->note_model->insert_note($save_column)) { + $response['code'] = 200; + $response['message'] = 'success'; + } + + $this->output->set_content_type('application/json')->set_output(json_encode($response)); + } + + public function notify_refund($site = 'cht') + { + // $this->merchant_config = $this->config->item($site, 'lianlian'); // test: 测试环境 + + error_reporting(0); + log_message('error', 'LianlianPay notify refund begin ----'); + $response['code'] = 0; + $response['message'] = ''; + $raw_post_data = file_get_contents('php://input'); + if (empty($raw_post_data)) { + # 如果没有数据,直接返回失败 + return $this->output->set_content_type('application/json')->set_output(json_encode($response)); + } + + $signature = $this->input->server('HTTP_SIGNATURE'); + $payment_result = json_decode($raw_post_data, true); + if ($this->check_sign($payment_result, $signature) !== true) { + log_message('error','debug: ' . __METHOD__ . ': ' . __LINE__ . ' signature' . PHP_EOL . var_export($signature, 1)); + log_message('error','debug: ' . __METHOD__ . ': ' . __LINE__ . ' raw_post_data' . PHP_EOL . var_export($raw_post_data, 1)); + $response['message'] = 'sign error'; + // return $this->output->set_content_type('application/json')->set_output(json_encode($response)); // debug: + } + + $payment_data = $payment_result['refund_data']; + $find_related = $this->note_model->get_note_where(['OPN_invoiceId' => ['=', $payment_result['original_transaction_id']], 'OPN_transactionResult' => ['=', 'completed']]); + + // ! 退款手续费 1USD, 原交易手续费不退 + // $payment_fee = $payment_data['payment_amount'] - $payment_data['settlement_amount']; + // $ssje = $this->account_model->get_ssje('-' . $payment_data['actual_refund_amount'], str_replace("CNY", "RMB", strtoupper($payment_data['actual_refund_currency_code'])), $this->merchant_config['method_code']); + $ssje = $this->account_model->get_ssje('-' . $payment_data['settlement_amount'], str_replace("CNY", "RMB", strtoupper($payment_data['settlement_currency_code'])), $this->merchant_config['method_code']); + $save_column = array(); + $save_column['OPN_transactionId'] = $payment_result['ll_transaction_id']; + $save_column['OPN_orderId'] = $payment_result['original_transaction_id']; + $save_column['OPN_rawOrderId'] = $payment_result['merchant_transaction_id']; + $save_column['OPN_invoiceId'] = $payment_result['merchant_transaction_id']; + $save_column['OPN_relatedId'] = isset($find_related[0]->OPN_transactionId) ? $find_related[0]->OPN_transactionId : null; + $save_column['OPN_subject'] = $payment_result['merchant_transaction_id'] . ' ' . $payment_data['reason']; + + $save_column['OPN_currency'] = $payment_data['refund_currency_code']; + $save_column['OPN_orderAmount'] = '-'.$payment_data['refund_amount']; + $save_column['OPN_payAmount'] = '-'.$payment_data['refund_amount']; + $save_column['OPN_payFee'] = null; // 1; // ! todo: 计算手续费; 退款 1 USD 原手续费不退 + $save_column['OPN_netAmount'] = '-'.$payment_data['settlement_amount']; // todo: + $save_column['OPN_transactionResult'] = refund_status($payment_data['refund_status']); + $save_column['OPN_resultCode'] = $payment_data['refund_status']; + // $save_column['OPN_resultMsg'] = isset($payment_result['return_msg']) ? $payment_result['return_msg'] : $payment_result['result_code']; + // $save_column['OPN_errCode'] = isset($payment_result['err_code']) ? $payment_result['err_code'] : NULL; + // $save_column['OPN_errMsg'] = isset($payment_result['err_code_des']) ? $payment_result['err_code_des'] : NULL; + $save_column['OPN_acquiringTime'] = date('Y-m-d H:i:s', strtotime($payment_data['refund_time'])); + $save_column['OPN_completeTime'] = date('Y-m-d H:i:s', strtotime($payment_data['refund_time'])); + $save_column['OPN_remark'] = $payment_data['reason'] ? $payment_data['reason'] : ''; + // $save_column['OPN_payerLogId'] = $payment_result['openid']; + // $save_column['OPN_payerStatus'] = $payment_result['is_subscribe']==='Y' ? "subscribed" : NULL; + $save_column['OPN_fundSource'] = $site; + $save_column['OPN_entryAmountCNY'] = floatval($ssje); + $save_column['OPN_rawContent'] = json_encode($payment_result); + $save_column['OPN_noticeTime'] = date('Y-m-d H:i:s'); + $save_column['OPN_noticeType'] = 'refund'; + $save_column['OPN_noticeSendStatus'] = refund_status_send($payment_data['refund_status']); + $save_column['OPN_noticeSendTime'] = NULL; + $save_column['OPN_accountMethod'] = $this->merchant_config['method_code']; + // log_message('error','test: ' . __METHOD__ . ': ' . __LINE__ . ' to in' . PHP_EOL . var_export($save_column, 1)); + // die; // test:0 + if ($this->note_model->insert_note($save_column)) { + $response['code'] = 200; + $response['message'] = 'success'; + } + + $this->output->set_content_type('application/json')->set_output(json_encode($response)); + } + + + + // protected function generateSignArray($params, $signType = "RSA") + // { + // return $this->sign(generateSignContent($params), $signType); + // } + + // protected function sign($data, $signType = "RSA") + // { + // $this->private_key = $this->merchant_config['merchant_private_key']; + // $priKey = $this->private_key; + // $res = "-----BEGIN RSA PRIVATE KEY-----\n" . + // wordwrap($priKey, 64, "\n", true) . + // "\n-----END RSA PRIVATE KEY-----"; + + // ($res) or die('您使用的私钥格式错误,请检查RSA私钥配置'); + + // if ("RSA2" == $signType) { + // openssl_sign($data, $sign, $res, OPENSSL_ALGO_SHA256); + // } else { + // openssl_sign($data, $sign, $res); + // } + + // $sign = base64_encode($sign); + // return $sign; + // } + + protected function check_sign($data, $signature) + { + if (empty($signature)) { + log_message('error', 'LianlianPay notify error: no sign.'); + return false; + } + $verify_res = $this->verify_signature(generateSignContent($data), $signature); + if ( ! $verify_res) { + log_message('error', 'LianlianPay notify error: sign. ' . generateSignContent($data)); + return false; + } + // return false; // test: 0 + return true; + } + + protected function verify_signature($data, $sign, $signType = "RSA") + { + // Load the public key + $pubKey = $this->merchant_config['lianlian_public_key']; + if (!$pubKey) { + return false; // Public key file not found or unreadable. + } + $res = "-----BEGIN PUBLIC KEY-----\n" . + wordwrap($pubKey, 64, "\n", true) . + "\n-----END PUBLIC KEY-----"; + $res = openssl_get_publickey($res); + ($res) or die('LianlianRSA公钥错误。请检查公钥文件格式是否正确'); + //调用openssl内置方法验签,返回bool值 + if ("RSA2" == $signType) { + $result = (bool)openssl_verify($data, base64_decode($sign), $res, OPENSSL_ALGO_SHA256); // sha256 OPENSSL_ALGO_SHA256 + } else { + $result = (bool)openssl_verify($data, base64_decode($sign), $res); + } + // log_message('error', 'test: ' . __METHOD__ . ': ' . __LINE__ . ' result' . PHP_EOL . var_export($result, 1)); + //释放资源 + openssl_free_key($res); + return $result; + } +} diff --git a/webht/third_party/pay/controllers/PaymentService.php b/webht/third_party/pay/controllers/PaymentService.php index 2d947036..23ef77f1 100644 --- a/webht/third_party/pay/controllers/PaymentService.php +++ b/webht/third_party/pay/controllers/PaymentService.php @@ -25,6 +25,7 @@ class PaymentService extends CI_Controller { "15015" => "Alipay", "15016" => "WeChat", "15018" => "Credit Card-iPaylinks", + "15035" => "Credit Card-Lianlian", ); public function index() @@ -36,8 +37,8 @@ class PaymentService extends CI_Controller { $this->permission->is_admin(true); $data = array(); $method = $this->input->get_post("method"); - $method = $method===false ? null : $method; - $data['method_code'] = ''; + $method = $method===false ? null : $method; // explode(',', $method); + $data['method_code'] = $method ? $method : ''; // $data["paytext"] = $this->payment_status(); if (isset($this->code_brandname[$method])) { $data['method_code'] = $method; @@ -99,7 +100,7 @@ class PaymentService extends CI_Controller { $wx_app = $wx_app!=='0' ? $wx_app : (isset($raw->appid) ? $raw->appid : '0'); $ele->app_name = ""; - if ($this->wxpay_app[$wx_app]) { + if ($ele->OPN_accountMethod===15016 && $this->wxpay_app[$wx_app]) { $ele->app_name = $this->wxpay_app[$wx_app]; } } @@ -168,6 +169,11 @@ class PaymentService extends CI_Controller { // continue; } + $GAI_API = null; + $_memo = json_decode($item->OPN_rawContent); + $GAI_API = property_exists($_memo, 'GAI_API') ? $_memo->GAI_API : null; + $GAI_API = json_encode($GAI_API, JSON_UNESCAPED_SLASHES); + // 开始查找订单和录入 $handpick = empty($opn_id) ? false : true; $advisor_info = $this->account_model->get_order($orderid_info->orderid, true, $orderid_info->ordertype, $handpick); @@ -216,7 +222,7 @@ class PaymentService extends CI_Controller { $item->OPN_payerName, $item->OPN_payerEmail, $item->OPN_transactionId, - $ht_memo + $ht_memo, $GAI_API ); if ($is_refund === true && $insertID) { $this->account_model->exec_BIZ_TrainCostAdd($COLI_SN, $ssje); @@ -254,7 +260,7 @@ class PaymentService extends CI_Controller { $item->OPN_payerName, $item->OPN_payerEmail, $item->OPN_transactionId, - $ht_memo + $ht_memo, $GAI_API ); // 更新订单主表付款方式,防止没访问thankyou-train.asp $this->account_model->update_paymanner($COLI_SN, $item->OPN_accountMethod); @@ -280,7 +286,7 @@ class PaymentService extends CI_Controller { $item->OPN_payerName, $item->OPN_payerEmail, $item->OPN_transactionId, - $ht_memo + $ht_memo, $GAI_API ); if ($is_refund === false) { //添加汉特的订单提醒 @@ -346,7 +352,7 @@ class PaymentService extends CI_Controller { // todo:iPaylinks需要发收款, 退款发所有 // 3. 更新是否发送财务 if($is_refund === true ) { - $this->send_refund($send_email, $item, $orderid_info, $advisor_info); + $this->send_refund_email($send_email, $item, $orderid_info, $advisor_info); } //显示处理记录 @@ -362,7 +368,7 @@ class PaymentService extends CI_Controller { // return $this->output->set_content_type('application/json')->set_output(json_encode($data)); } - public function send_refund($send_email, $item, $orderid_info, $advisor_info) + public function send_refund_email($send_email, $item, $orderid_info, $advisor_info) { // 发送客人 if ($send_email===true diff --git a/webht/third_party/pay/controllers/WxpayService.php b/webht/third_party/pay/controllers/WxpayService.php index 2281f1b1..06da38d9 100644 --- a/webht/third_party/pay/controllers/WxpayService.php +++ b/webht/third_party/pay/controllers/WxpayService.php @@ -24,7 +24,7 @@ class WxpayService extends CI_Controller { public function notify($site='cht') { error_reporting(0); -// log_message('error','notify begin ----'); + // log_message('error','wxpay notify begin ----'); $response['return_code'] = 'FAIL'; $response['return_msg'] = ''; $GLOBALS['__WX_SITE_NAME__'] = $site; @@ -129,6 +129,8 @@ class WxpayService extends CI_Controller { $save_column['OPN_transactionId'] = $row['refund_id']; $save_column['OPN_orderAmount'] = "-" . $row['settlement_refund_fee']; $save_column['OPN_payAmount'] = "-" . $row['settlement_refund_fee']; + // $save_column['OPN_payFee'] = bcsub(0, $row['wxpay_fee']); + // $save_column['OPN_netAmount'] = "-" . bcadd($row['call_refund_fee'], $row['wxpay_fee']); $save_column['OPN_resultCode'] = $row['refund_status']; $save_column['OPN_resultMsg'] = $row['refund_status']; $save_column['OPN_entryAmountCNY'] = floatval("-" . $ssje); @@ -136,7 +138,11 @@ class WxpayService extends CI_Controller { $save_column['OPN_relatedId'] = $row['transaction_id']; } else { // 收款 - $ssje = $this->account_model->get_ssje($row['settlement_total_fee'], str_replace("CNY", "RMB", strtoupper($row['currency_type'])), $save_column['OPN_accountMethod']); + $save_column['OPN_payFee'] = bcsub(0, $row['wxpay_fee']); + $save_column['OPN_netAmount'] = bcsub($row['settlement_total_fee'], $row['wxpay_fee']); + + $ssje = $this->account_model->get_ssje_exclude_fee($save_column['OPN_netAmount'], str_replace("CNY", "RMB", strtoupper($row['currency_type'])), $save_column['OPN_accountMethod']); + $save_column['OPN_transactionId'] = $row['transaction_id']; $save_column['OPN_orderAmount'] = $row['settlement_total_fee']; $save_column['OPN_payAmount'] = $row['settlement_total_fee']; @@ -174,15 +180,22 @@ class WxpayService extends CI_Controller { $transaction_id = $this->input->get_post("keywords"); $this->load->model('WxpayQueryContentBuilder', 'query_builder'); $this->query_builder->set_transaction_id($transaction_id); + // $this->query_builder->set_out_trade_no($transaction_id); $this->load->library('Wxpay_call'); foreach ($all_account as $account) { + // echo json_encode($this->query_builder); + // return; $resultR = $this->wxpay_call->query_order_refund($this->query_builder, 0, $account); $result = $this->wxpay_call->query_order_refund($this->query_builder, 1, $account); if ($result['status'] === true) { + echo json_encode($result); + return; $this->note_model->add_note_wxpay($result['data'], $account, 'pay'); } if ($resultR['status'] === true) { + echo json_encode($result); + return; $this->note_model->add_note_wxpay($resultR['data'], $account, 'refund'); } // log_message('error',"query wxpay failed. $account $transaction_id"); @@ -191,7 +204,8 @@ class WxpayService extends CI_Controller { $data["method_name"] = 'WeChat'; $data['date'] = date('Y-m-d'); $data['notelist'] = $this->note_model->search_key($transaction_id); - $this->load->view("payment_list",$data); + echo json_encode($data); + // $this->load->view("payment_list",$data); return; } diff --git a/webht/third_party/pay/helpers/payment_helper.php b/webht/third_party/pay/helpers/payment_helper.php index 815fa3c8..11bb330a 100644 --- a/webht/third_party/pay/helpers/payment_helper.php +++ b/webht/third_party/pay/helpers/payment_helper.php @@ -316,3 +316,93 @@ function zero_to_one($value) { return $value==0 ? 1 : $value; } + +function to_json($arr, $options = 0) +{ + if (version_compare(phpversion(), '5.4.0', '>=') === true) { + return json_encode($arr, $options | 64); + } + return str_replace('\\/', '/', json_encode($arr, $options)); // ~ php 5.3 +} + +/** + * 校验$value是否非空 + * if not set ,return true; + * if is null , return true; + **/ +function checkEmpty($value) +{ + if (!isset($value)) + return true; + if ($value === null) + return true; + if (trim($value) === "") + return true; + + return false; +} + +/** + * 连连支付 + * @uses LianlianService + */ +/** + * 递归地将数组转为key=value形式, 仅拼接叶子节点 + * @uses LianlianService + */ +function generateKeyValueParts($key, $value, &$parts) { + if (is_array($value)) { + ksort($value); // Sort inner array keys + foreach ($value as $innerKey => $innerValue) { + generateKeyValueParts($innerKey, $innerValue, $parts); //recursive call and build the key + } + } else { + $parts[] = $key . '=' . $value; + } +} + +/** + * 生成待加签字符串 + * @uses LianlianService + */ +function generateSignContent($data) { + ksort($data); // Sort keys alphabetically + + $parts = []; + foreach ($data as $key => $value) { + generateKeyValueParts($key, $value, $parts); + } + + return implode('&', $parts); +} + +/** + * 连连 + * 退款状态, 结果码 + */ +function refund_status($code) { + $lianlian_refund_code = [ + 'PC' => 'pending', + 'RS' => 'completed', + 'RF' => 'failed', + ]; + return $code ? $lianlian_refund_code[$code] : ''; +} + +/** + * 连连 + * 退款状态, 发送码 + * @param string $code + */ +function refund_status_send($code) { + $lianlian_refund_code = [ + 'PC' => 'closed', + 'RS' => 'unsend', + 'RF' => 'closed', + ]; + return $code ? $lianlian_refund_code[$code] : ''; +} + +/** + * End 连连支付 + */ diff --git a/webht/third_party/pay/models/Online_payment_account_model.php b/webht/third_party/pay/models/Online_payment_account_model.php index ad679d89..fbd90f22 100644 --- a/webht/third_party/pay/models/Online_payment_account_model.php +++ b/webht/third_party/pay/models/Online_payment_account_model.php @@ -23,6 +23,16 @@ class Online_payment_account_model extends CI_Model { } return NULL; } + public function get_ssje_exclude_fee($amount, $currency='USD', $pay_type='15002') + { + $sql = "SELECT dbo.ConvertToRMB(?, ?) as ssje"; + $query = $this->HT->query($sql,array($currency, $amount)); + $result = $query->result(); + if ( ! empty($result)) { + return $result[0]->ssje; + } + return 0; + } //根据订单号获取外联邮箱 public function get_order($COLI_ID, $orderinfo = false, $ordertype = 'N', $handpick=false) { @@ -248,7 +258,7 @@ class Online_payment_account_model extends CI_Model { } //添加收款记录(商务订单) - public function add_account_info($GAI_COLI_SN, $payment_method, $GAI_COLI_ID, $GAI_SQJE, $GAI_SQDate, $GAI_SQJECurrency, $GAI_SSJE, $GAI_SSDate, $GAI_AccountDate, $GAI_SubmitDate, $GAI_CusName, $GAI_CusEmail, $GAI_AccreditNo, $GAI_Memo) { + public function add_account_info($GAI_COLI_SN, $payment_method, $GAI_COLI_ID, $GAI_SQJE, $GAI_SQDate, $GAI_SQJECurrency, $GAI_SSJE, $GAI_SSDate, $GAI_AccountDate, $GAI_SubmitDate, $GAI_CusName, $GAI_CusEmail, $GAI_AccreditNo, $GAI_Memo, $GAI_API = null) { //先判断是否有这条数据 $sql = " @@ -272,17 +282,18 @@ class Online_payment_account_model extends CI_Model { ,GAI_CusEmail ,GAI_AccreditNo ,GAI_Memo + ,GAI_API ,GAI_State ,DeleteFlag,LastEditTime - ) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,0,0,GETDATE())"; - $query = $this->HT->query($sql, array($GAI_AccreditNo, $GAI_COLI_SN, $GAI_COLI_ID, $payment_method, $GAI_SQJE, $GAI_SQDate, $GAI_SQJECurrency, $GAI_SSJE, $GAI_SSDate, $GAI_AccountDate, $GAI_SubmitDate, $GAI_CusName, $GAI_CusEmail, $GAI_AccreditNo, $GAI_Memo)); + ) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,0,0,GETDATE())"; + $query = $this->HT->query($sql, array($GAI_AccreditNo, $GAI_COLI_SN, $GAI_COLI_ID, $payment_method, $GAI_SQJE, $GAI_SQDate, $GAI_SQJECurrency, $GAI_SSJE, $GAI_SSDate, $GAI_AccountDate, $GAI_SubmitDate, $GAI_CusName, $GAI_CusEmail, $GAI_AccreditNo, $GAI_Memo, $GAI_API)); $insertid = ($query && $query->num_rows() > 0) ? $this->HT->last_id('BIZ_GroupAccountInfo') : false; return $insertid; } //添加收款记录(商务订单),APP会自动增加记录,所以添加前根据金额来判断是否有重复记录 - public function add_account_info_forAPP($GAI_COLI_SN, $payment_method, $GAI_COLI_ID, $GAI_SQJE, $GAI_SQDate, $GAI_SQJECurrency, $GAI_SSJE, $GAI_SSDate, $GAI_AccountDate, $GAI_SubmitDate, $GAI_CusName, $GAI_CusEmail, $GAI_AccreditNo, $GAI_Memo) { + public function add_account_info_forAPP($GAI_COLI_SN, $payment_method, $GAI_COLI_ID, $GAI_SQJE, $GAI_SQDate, $GAI_SQJECurrency, $GAI_SSJE, $GAI_SSDate, $GAI_AccountDate, $GAI_SubmitDate, $GAI_CusName, $GAI_CusEmail, $GAI_AccreditNo, $GAI_Memo, $GAI_API = null) { //先判断是否有这条数据 $sql = " IF NOT EXISTS( @@ -305,10 +316,11 @@ class Online_payment_account_model extends CI_Model { ,GAI_CusEmail ,GAI_AccreditNo ,GAI_Memo + ,GAI_API ,GAI_State ,DeleteFlag,LastEditTime - ) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,0,0,GETDATE())"; - $query = $this->HT->query($sql, array($GAI_COLI_SN, $GAI_SQJE, $payment_method, $GAI_COLI_SN, $GAI_COLI_ID, $payment_method, $GAI_SQJE, $GAI_SQDate, $GAI_SQJECurrency, $GAI_SSJE, $GAI_SSDate, $GAI_AccountDate, $GAI_SubmitDate, $GAI_CusName, $GAI_CusEmail, $GAI_AccreditNo, $GAI_Memo)); + ) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,0,0,GETDATE())"; + $query = $this->HT->query($sql, array($GAI_COLI_SN, $GAI_SQJE, $payment_method, $GAI_COLI_SN, $GAI_COLI_ID, $payment_method, $GAI_SQJE, $GAI_SQDate, $GAI_SQJECurrency, $GAI_SSJE, $GAI_SSDate, $GAI_AccountDate, $GAI_SubmitDate, $GAI_CusName, $GAI_CusEmail, $GAI_AccreditNo, $GAI_Memo, $GAI_API)); $insertid = ($query && $query->num_rows() > 0) ? $this->HT->last_id('BIZ_GroupAccountInfo') : false; return $insertid; // return $query->num_rows() > 0; @@ -321,10 +333,9 @@ class Online_payment_account_model extends CI_Model { } //添加收款记录(传统订单) - public function add_tour_account_info($GAI_COLI_SN, $payment_method, $GAI_SQJE, $GAI_SQDate, $GAI_SQJECurrency, $GAI_SSJE, $GAI_SSDate, $GAI_AccountDate, $GAI_SubmitDate, $GAI_CusName, $GAI_CusEmail, $GAI_AccreditNo, $GAI_Memo) { + public function add_tour_account_info($GAI_COLI_SN, $payment_method, $GAI_SQJE, $GAI_SQDate, $GAI_SQJECurrency, $GAI_SSJE, $GAI_SSDate, $GAI_AccountDate, $GAI_SubmitDate, $GAI_CusName, $GAI_CusEmail, $GAI_AccreditNo, $GAI_Memo, $GAI_API = null) { //先判断是否有这条数据 $sql = " - IF NOT EXISTS( SELECT TOP 1 1 FROM GroupAccountInfo @@ -344,10 +355,11 @@ class Online_payment_account_model extends CI_Model { ,GAI_CusEmail ,GAI_AccreditNo ,GAI_Memo + ,GAI_API ,GAI_State ,DeleteFlag,LastEditTime - ) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,0,0,GETDATE())"; - $query = $this->HT->query($sql, array($GAI_AccreditNo, $GAI_COLI_SN, $payment_method, $GAI_SQJE, $GAI_SQDate, $GAI_SQJECurrency, $GAI_SSJE, $GAI_SSDate, $GAI_AccountDate, $GAI_SubmitDate, $GAI_CusName, $GAI_CusEmail, $GAI_AccreditNo, $GAI_Memo)); + ) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,0,0,GETDATE())"; + $query = $this->HT->query($sql, array($GAI_AccreditNo, $GAI_COLI_SN, $payment_method, $GAI_SQJE, $GAI_SQDate, $GAI_SQJECurrency, $GAI_SSJE, $GAI_SSDate, $GAI_AccountDate, $GAI_SubmitDate, $GAI_CusName, $GAI_CusEmail, $GAI_AccreditNo, $GAI_Memo, $GAI_API)); $insertid = ($query && $query->num_rows() > 0) ? $this->HT->last_id('GroupAccountInfo') : false; return $insertid; } diff --git a/webht/third_party/pay/models/Online_payment_note_model.php b/webht/third_party/pay/models/Online_payment_note_model.php index b5482767..f9cc83e7 100644 --- a/webht/third_party/pay/models/Online_payment_note_model.php +++ b/webht/third_party/pay/models/Online_payment_note_model.php @@ -64,7 +64,7 @@ class Online_payment_note_model extends CI_Model { $this->init_query(); $this->topnum = $num; // $this->send = " AND (OPN_noticeSendStatus='unsend' OR OPN_noticeSendStatus='' OR OPN_noticeSendStatus IS NULL) "; - $this->search = $method===null ? "" : " AND OPN_accountMethod=$method "; + $this->search = $method===null ? "" : " AND OPN_accountMethod IN ($method) "; $this->send = " AND ISNULL(OPN_noticeSendStatus,'') in ('', 'unsend') "; return $this->query_note(); @@ -75,7 +75,7 @@ class Online_payment_note_model extends CI_Model { $this->init_query(); $this->topnum = $num; $this->send = " AND (OPN_noticeSendStatus) = 'closed' "; - $this->search = $method===null ? "" : " AND OPN_accountMethod=$method "; + $this->search = $method===null ? "" : " AND OPN_accountMethod IN ($method) "; $this->search .= " AND OPN_noticeTime BETWEEN '$date 00:00:00' AND '$date 23:59:59' "; return $this->query_note(); } @@ -84,7 +84,7 @@ class Online_payment_note_model extends CI_Model { { $this->init_query(); $this->topnum = $num; - $this->search = $method===null ? "" : " AND OPN_accountMethod=$method "; + $this->search = $method===null ? "" : " AND OPN_accountMethod IN ($method) "; // 1小时前 $date = date("Y-m-d H:i:s", time() - 3600); $this->search .= $num !== false ? " AND OPN_noticeSendTime < '$date' " : ''; @@ -119,6 +119,7 @@ class Online_payment_note_model extends CI_Model { "15015" => "Alipay", "15016" => "WeChat", "15018" => "Credit Card-iPaylinks", + "15035" => "Credit Card-Lianlian", ); private $wxpay_app = array( "wx749246dd935ca07b" => "APP", @@ -172,6 +173,32 @@ class Online_payment_note_model extends CI_Model { return $this->query_note(); } + /** + * @param mixed $where ['OPN_SN' => ['=', {val}] ] + */ + public function get_note_where($where) { + $this->init_query(); + $this->topnum=1; + $this->search = ''; + foreach ($where as $key => $value) { + $where_val = ''; + switch (strtolower($value[0])) { + case '=': + $where_val = " = {$this->info->escape($value[1])}"; + break; + case 'in': + $where_val = " IN ({$this->info->escape($value[1])})"; + break; + + default: + $where_val = " = {$this->info->escape($value[1])}"; + break; + } + $this->search .= " AND {$key} {$where_val} "; + } + return $this->query_note(); + } + public function search_key($keyword) { $this->init_query(); @@ -191,7 +218,7 @@ class Online_payment_note_model extends CI_Model { public function search_date($date, $method=null) { $this->init_query(); - $this->search = $method===null ? "" : " AND OPN_accountMethod=$method "; + $this->search = $method===null ? "" : " AND OPN_accountMethod IN ($method) "; $this->search .= " AND OPN_noticeTime BETWEEN '$date 00:00:00' AND '$date 23:59:59' "; $this->send = " AND isnull(OPN_noticeSendStatus,'') NOT IN ('', 'sendfail', 'unsend', 'closed' )"; return $this->query_note(); diff --git a/webht/third_party/pay/views/payment_list.php b/webht/third_party/pay/views/payment_list.php index 93250612..94ed87ce 100644 --- a/webht/third_party/pay/views/payment_list.php +++ b/webht/third_party/pay/views/payment_list.php @@ -30,12 +30,19 @@ .paypal-color {background-color: #002D89;} .alipay-color {background-color: #00AAEE;} .ipaylinks-color,.creditcard-color,.creditcard-ipaylinks-color {background-color: #A31022;} + .creditcard-lianlian-color {background-color: #1985ff;} .modal {background-color: rgba(0,0,0,0.075);} .cht-color {background-color: #A31022;} .trippest-color {background-color: #E83201;} .app-color {background-color: #EC3A4F;} .hly-color {background-color: #009fe9;} + .unknown-color{ background-color: #999999;} + + .flex {display: flex;} + .items-center {align-items: center;} + .justify-center {justify-content: center;} + .ml-auto {margin-left: auto;}