|
|
|
|
<?php
|
|
|
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
|
|
|
|
|
|
|
|
class PaymentService extends CI_Controller {
|
|
|
|
|
|
|
|
|
|
public function __construct(){
|
|
|
|
|
parent::__construct();
|
|
|
|
|
bcscale(2);
|
|
|
|
|
$this->load->helper('payment');
|
|
|
|
|
$this->config->load('wxpay', true);
|
|
|
|
|
$this->config->load('paypal', true);
|
|
|
|
|
$this->load->model('Online_payment_note_model', 'note_model');
|
|
|
|
|
$this->load->model('Online_payment_account_model', 'account_model');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function index()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function note_list()
|
|
|
|
|
{
|
|
|
|
|
$this->permission->is_admin(true);
|
|
|
|
|
$data = array();
|
|
|
|
|
// $data["paytext"] = $this->payment_status();
|
|
|
|
|
$data["method_name"] = $this->input->get_post("method_name");
|
|
|
|
|
$data["keywords"] = $this->input->get_post("keywords");
|
|
|
|
|
$data["date"] = $this->input->get_post("date");
|
|
|
|
|
empty($data['date']) ? $data['date'] = date('Y-m-d') : false;
|
|
|
|
|
if (!empty($data['keywords'])) {
|
|
|
|
|
$data['notelist'] = $this->note_model->search_key($data['keywords']);
|
|
|
|
|
} else {
|
|
|
|
|
$data['notelist'] = $this->note_model->search_date($data['date']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 导出记录用的记录节点
|
|
|
|
|
* TODO
|
|
|
|
|
*/
|
|
|
|
|
// $data['record_flags'] = $this->note_model->list_export_record();
|
|
|
|
|
|
|
|
|
|
$this->load->view("payment_list",$data);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function note_faillist()
|
|
|
|
|
{
|
|
|
|
|
$this->permission->is_admin(true);
|
|
|
|
|
$data = array();
|
|
|
|
|
$data['date'] = date('Y-m-d');
|
|
|
|
|
$data['notelist'] = $this->note_model->failnote(100);
|
|
|
|
|
$this->load->view("payment_list",$data);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function send_notify($opn_id=NULL, $old_ssje=NULL)
|
|
|
|
|
{
|
|
|
|
|
log_message('error','send_notify begin ----');
|
|
|
|
|
// exit();
|
|
|
|
|
$data = array();
|
|
|
|
|
$show_index = 0;
|
|
|
|
|
//优先处理指定的交易号,用于修正交易号直接发送通知
|
|
|
|
|
if ( ! empty($opn_id)) {
|
|
|
|
|
$data['unsend_list'] = $this->note_model->get_note($opn_id);
|
|
|
|
|
}
|
|
|
|
|
// 待处理的
|
|
|
|
|
if (empty($data['unsend_list'])) {
|
|
|
|
|
$data['unsend_list'] = $this->note_model->unsend_note(10);
|
|
|
|
|
}
|
|
|
|
|
//没有未处理的数据再查找处理失败的数据
|
|
|
|
|
if (empty($data['unsend_list'])) {
|
|
|
|
|
$data['unsend_list'] = $this->note_model->sendfail_note(20);
|
|
|
|
|
}
|
|
|
|
|
// 开始处理
|
|
|
|
|
foreach ($data['unsend_list'] as $key => $item) {
|
|
|
|
|
// 只处理完成状态
|
|
|
|
|
if ($item->OPN_transactionResult != 'completed') {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if ($item->OPN_noticeType == 'Refunded') {
|
|
|
|
|
// 退款处理
|
|
|
|
|
continue ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 提取订单号
|
|
|
|
|
$orderid_info = analysis_orderid($item->OPN_orderId); // 先用已设置过的
|
|
|
|
|
if (empty($orderid_info)) {
|
|
|
|
|
$orderid_info = $this->method_analysis_orderid($item->OPN_accountMethod, $item->OPN_rawContent);
|
|
|
|
|
if (empty($orderid_info)) {
|
|
|
|
|
$this->note_model->update_send($item->OPN_SN, $item->OPN_transactionId, 'sendfail');
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$orderid_info = json_decode($orderid_info);
|
|
|
|
|
// TODO Trippest的订单号要特别查询
|
|
|
|
|
// 填入提取到的订单号
|
|
|
|
|
$this->note_model->set_invoice($item->OPN_SN, $orderid_info->orderid . '_' . $orderid_info->ordertype);
|
|
|
|
|
|
|
|
|
|
// APP自动出票的收款 跳过
|
|
|
|
|
if ($orderid_info->ordertype === 'A' && $item->OPN_noticeType === 'pay') {
|
|
|
|
|
$this->note_model->update_send($item->OPN_SN, $item->OPN_transactionId, 'closed');
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 开始查找订单和录入
|
|
|
|
|
$handpick = empty($opn_id) ? false : true;
|
|
|
|
|
$advisor_info = $this->account_model->get_order($orderid_info->orderid, false, $orderid_info->ordertype, $handpick);
|
|
|
|
|
$ssje = $this->account_model->get_ssje($item->OPN_orderAmount, mb_strtoupper($item->OPN_currency), $item->OPN_accountMethod);
|
|
|
|
|
$ssje = $old_ssje===NULL ? $ssje : $old_ssje;
|
|
|
|
|
$ht_memo = '交易号(自动录入):' . $item->OPN_transactionId;
|
|
|
|
|
if ( empty($advisor_info)) {
|
|
|
|
|
// record fail
|
|
|
|
|
$this->note_model->update_send($item->OPN_SN, $item->OPN_transactionId, 'sendfail');
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
$COLI_SN = isset($advisor_info->COLI_SN) ? $advisor_info->COLI_SN : 0;
|
|
|
|
|
$update_note_column = array();
|
|
|
|
|
if ($advisor_info->order_type == 0) {
|
|
|
|
|
/* 商务订单 */
|
|
|
|
|
if (substr($advisor_info->COLI_WebCode, 0, 6) == 'CHTAPP') {
|
|
|
|
|
/* APP */
|
|
|
|
|
$this->account_model->add_account_info_forAPP(
|
|
|
|
|
$COLI_SN,
|
|
|
|
|
$item->OPN_accountMethod,
|
|
|
|
|
$advisor_info->COLI_ID,
|
|
|
|
|
$item->OPN_orderAmount,
|
|
|
|
|
$item->OPN_completeTime,
|
|
|
|
|
mb_strtoupper($item->OPN_currency),
|
|
|
|
|
$ssje,
|
|
|
|
|
$item->OPN_completeTime,
|
|
|
|
|
$item->OPN_completeTime,
|
|
|
|
|
$item->OPN_completeTime,
|
|
|
|
|
$item->OPN_payerName,
|
|
|
|
|
$item->OPN_payerEmail,
|
|
|
|
|
$item->OPN_transactionId,
|
|
|
|
|
$ht_memo
|
|
|
|
|
);
|
|
|
|
|
if ($advisor_info->COLI_WebCode == 'CHTAPP' && $advisor_info->COLI_State == 11) {
|
|
|
|
|
//只修改APP组的订单状态,并且订单进度是我的订单
|
|
|
|
|
$this->account_model->update_biz_coli_state($COLI_SN, 8); //把订单状态改为已付款
|
|
|
|
|
$this->account_model->insert_biz_order_log($COLI_SN, 'BS8');
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
/* 其他商务订单 */
|
|
|
|
|
// 第一次录入收款记录时变更状态,记录日志
|
|
|
|
|
if (false == $this->account_model->if_biz_gai_exists($item->OPN_transactionId) ) {
|
|
|
|
|
$this->account_model->update_biz_coli_state($COLI_SN, 13);
|
|
|
|
|
$this->account_model->insert_biz_order_log($COLI_SN, 'BS13');
|
|
|
|
|
}
|
|
|
|
|
$this->account_model->add_account_info(
|
|
|
|
|
$COLI_SN,
|
|
|
|
|
$item->OPN_accountMethod,
|
|
|
|
|
$advisor_info->COLI_ID,
|
|
|
|
|
$item->OPN_orderAmount,
|
|
|
|
|
$item->OPN_completeTime,
|
|
|
|
|
mb_strtoupper($item->OPN_currency),
|
|
|
|
|
$ssje,
|
|
|
|
|
$item->OPN_completeTime,
|
|
|
|
|
$item->OPN_completeTime,
|
|
|
|
|
$item->OPN_completeTime,
|
|
|
|
|
$item->OPN_payerName,
|
|
|
|
|
$item->OPN_payerEmail,
|
|
|
|
|
$item->OPN_transactionId,
|
|
|
|
|
$ht_memo
|
|
|
|
|
);
|
|
|
|
|
// 更新订单主表付款方式,防止没访问thankyou-train.asp
|
|
|
|
|
$this->account_model->update_paymanner($COLI_SN, $item->OPN_accountMethod);
|
|
|
|
|
}
|
|
|
|
|
// 更新note
|
|
|
|
|
$update_note_column['OPN_accountType'] = 'B';
|
|
|
|
|
$update_note_column['OPN_accountStatus'] = 'recorded';
|
|
|
|
|
$update_note_column['OPN_accountTime'] = date('Y-m-d H:i:s');
|
|
|
|
|
} elseif ($advisor_info->order_type == 1) {
|
|
|
|
|
/* 传统 */
|
|
|
|
|
$gai_sn = $this->account_model->add_tour_account_info(
|
|
|
|
|
$COLI_SN,
|
|
|
|
|
$item->OPN_accountMethod,
|
|
|
|
|
$item->OPN_orderAmount,
|
|
|
|
|
$item->OPN_completeTime,
|
|
|
|
|
mb_strtoupper($item->OPN_currency),
|
|
|
|
|
$ssje,
|
|
|
|
|
$item->OPN_completeTime,
|
|
|
|
|
$item->OPN_completeTime,
|
|
|
|
|
$item->OPN_completeTime,
|
|
|
|
|
$item->OPN_payerName,
|
|
|
|
|
$item->OPN_payerEmail,
|
|
|
|
|
$item->OPN_transactionId,
|
|
|
|
|
$ht_memo
|
|
|
|
|
);
|
|
|
|
|
//添加汉特的订单提醒
|
|
|
|
|
$this->account_model->update_coli_introduction($COLI_SN, '已支付 ' . mb_strtoupper($item->OPN_currency) . $item->OPN_orderAmount);
|
|
|
|
|
// 添加HT任务
|
|
|
|
|
$this->account_model->exec_addToTask($gai_sn);
|
|
|
|
|
// 更新note
|
|
|
|
|
$update_note_column['OPN_accountType'] = 'B';
|
|
|
|
|
$update_note_column['OPN_accountStatus'] = 'recorded';
|
|
|
|
|
$update_note_column['OPN_accountTime'] = date('Y-m-d H:i:s');
|
|
|
|
|
}
|
|
|
|
|
// 更新note
|
|
|
|
|
if ( ! empty($update_note_column)) {
|
|
|
|
|
$where = " OPN_SN=" . $item->OPN_SN;
|
|
|
|
|
$this->note_model->update_note($where, $update_note_column);
|
|
|
|
|
}
|
|
|
|
|
// 邮件外联
|
|
|
|
|
$opi_email = !empty($advisor_info->OPI_Email) ? $advisor_info->OPI_Email : '';
|
|
|
|
|
$opi_firstname = !empty($advisor_info->OPI_FirstName) ? $advisor_info->OPI_FirstName : !empty($advisor_info->OPI_Name) ? $advisor_info->OPI_Name : '';
|
|
|
|
|
//没有外联信息表示订单未分配
|
|
|
|
|
if (empty($opi_email) || empty($opi_firstname)) {
|
|
|
|
|
$this->note_model->update_send($item->OPN_SN, $item->OPN_transactionId, 'sendfail');
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
//添加邮件发送记录
|
|
|
|
|
//给外联发送通知邮件
|
|
|
|
|
$fromName = !empty($item->OPN_payerName) ? $item->OPN_payerName : '';
|
|
|
|
|
$fromEmail = !empty($item->OPN_payerEmail) ? $item->OPN_payerEmail : '';
|
|
|
|
|
$toName = !empty($opi_firstname) ? $opi_firstname : '';
|
|
|
|
|
$toEmail = !empty($opi_email) ? $opi_email : '';
|
|
|
|
|
$subject = $orderid_info->orderid . '_' . $orderid_info->ordertype . ' / ' . $item->OPN_orderAmount . $item->OPN_currency . ' / ' . $fromName;
|
|
|
|
|
$body = $this->load->view('mail_advisor', $item, true); //$item->pn_memo;
|
|
|
|
|
$M_RelatedInfo = $item->OPN_SN;
|
|
|
|
|
$M_AddTime = $item->OPN_completeTime;
|
|
|
|
|
$M_State = 0;
|
|
|
|
|
$this->account_model->save_automail($fromName, $fromEmail, $toName, $toEmail, $subject, $body, $M_RelatedInfo, $M_State, $M_AddTime, 'payment note', 'payment note');
|
|
|
|
|
//添加邮件发送记录 end
|
|
|
|
|
// 2. 给客人发邮件,通知账单 todo ?? 是否需要
|
|
|
|
|
|
|
|
|
|
$this->note_model->update_send($item->OPN_SN, $item->OPN_transactionId, 'send');
|
|
|
|
|
|
|
|
|
|
//显示处理记录
|
|
|
|
|
if (empty($opn_id)) {
|
|
|
|
|
echo ++$show_index . ' ' . $item->OPN_transactionId . '<br/>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
// return $this->output->set_content_type('application/json')->set_output(json_encode($data));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 支付方式参数对应的配置文件名 */
|
|
|
|
|
/** @Deprecated */
|
|
|
|
|
public function method_name($name)
|
|
|
|
|
{
|
|
|
|
|
$config_name = 'paypal';
|
|
|
|
|
switch ($name) {
|
|
|
|
|
case 'paypal':
|
|
|
|
|
$config_name = 'paypal';
|
|
|
|
|
break;
|
|
|
|
|
case 'weixin':
|
|
|
|
|
$config_name = 'wxpay';
|
|
|
|
|
break;
|
|
|
|
|
case 'ipaylinks':
|
|
|
|
|
$config_name = 'iPayLinks';
|
|
|
|
|
break;
|
|
|
|
|
case 'alipay':
|
|
|
|
|
$config_name = 'alipay';
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
# code...
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return $config_name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function method_analysis_orderid($name, $raw_content)
|
|
|
|
|
{
|
|
|
|
|
$content_obj = json_decode($raw_content);
|
|
|
|
|
$orderid_info = array();
|
|
|
|
|
switch (strval($name)) {
|
|
|
|
|
case '15002':
|
|
|
|
|
case '15010': // paypal
|
|
|
|
|
$orderid_info = analysis_orderid($content_obj->invoice);
|
|
|
|
|
empty($orderid_info) ? $orderid_info = analysis_orderid($content_obj->transaction_subject) : NULL;
|
|
|
|
|
empty($orderid_info) ? $orderid_info = analysis_orderid($content_obj->custom) : NULL;
|
|
|
|
|
empty($orderid_info) ? $orderid_info = analysis_orderid($content_obj->item_name) : NULL;
|
|
|
|
|
empty($orderid_info) ? $orderid_info = analysis_orderid($content_obj->item_name1) : NULL;
|
|
|
|
|
empty($orderid_info) ? $orderid_info = analysis_orderid($content_obj->item_number) : NULL;
|
|
|
|
|
empty($orderid_info) ? $orderid_info = analysis_orderid($content_obj->item_number1) : NULL;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case '15016': // wxpay
|
|
|
|
|
$orderid_info = analysis_orderid($content_obj->out_trade_no);
|
|
|
|
|
break;
|
|
|
|
|
// TODO
|
|
|
|
|
case '15018': // iPaylinks
|
|
|
|
|
break;
|
|
|
|
|
case '15015': // alipay
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
# code...
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return $orderid_info;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function convert_send_status()
|
|
|
|
|
{
|
|
|
|
|
# code...
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function gai_modal($pn_id = null, $neworder=null)
|
|
|
|
|
{
|
|
|
|
|
$this->permission->is_admin(true);
|
|
|
|
|
$data = array();
|
|
|
|
|
$note = $this->note_model->get_note($pn_id);
|
|
|
|
|
$data['note'] = $note[0];
|
|
|
|
|
$data['order_info'] = NULL;
|
|
|
|
|
$pn_invoice = $data['note']->OPN_orderId ? $data['note']->OPN_orderId : $data['note']->OPN_rawOrderId;
|
|
|
|
|
$pn_txn_id = $data['note']->OPN_transactionId;
|
|
|
|
|
$orderid_info = analysis_orderid($pn_invoice);
|
|
|
|
|
if (!empty($orderid_info)) {
|
|
|
|
|
$orderid_info = json_decode($orderid_info);
|
|
|
|
|
$data['order_info'] = $this->account_model->get_order($orderid_info->orderid, true, $orderid_info->ordertype);
|
|
|
|
|
if ($orderid_info->ordertype === 'T') {
|
|
|
|
|
$data['gai_info'] = $this->account_model->get_money_t($pn_txn_id);
|
|
|
|
|
} elseif ($orderid_info->ordertype === 'B' || $orderid_info->ordertype === 'TP') {
|
|
|
|
|
$data['gai_info'] = $this->account_model->get_money_b($pn_txn_id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$data['old_order'] = $pn_invoice;
|
|
|
|
|
$data['new_order'] = $neworder;
|
|
|
|
|
if ($neworder !== null ) {
|
|
|
|
|
$neworder_id = analysis_orderid($neworder);
|
|
|
|
|
$neworder_id = json_decode($neworder_id);
|
|
|
|
|
if ( ! empty($neworder_id)) {
|
|
|
|
|
$data['order_info'] = $this->account_model->get_order($neworder_id->orderid, true, $neworder_id->ordertype);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
echo json_encode($this->load->view('payment_gai_setting', $data, true));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function gai_modal_save()
|
|
|
|
|
{
|
|
|
|
|
$data = array();
|
|
|
|
|
$old_ssje = NULL;
|
|
|
|
|
$pn_txn_id = $this->input->post('pn_txn_id');
|
|
|
|
|
$pn_id = $this->input->post('pn_id');
|
|
|
|
|
$neworder = $this->input->post('pn_invoice');
|
|
|
|
|
|
|
|
|
|
$note = $this->note_model->get_note($pn_id);
|
|
|
|
|
$data['note'] = $note[0];
|
|
|
|
|
$orderid_info = analysis_orderid($data['note']->OPN_orderId);
|
|
|
|
|
if (!empty($orderid_info)) {
|
|
|
|
|
$orderid_info = json_decode($orderid_info);
|
|
|
|
|
if ($orderid_info->ordertype === 'T') {
|
|
|
|
|
$data['gai_info'] = $this->account_model->get_money_t($pn_txn_id);
|
|
|
|
|
if ( ! empty($data['gai_info'])) {
|
|
|
|
|
$old_ssje = $data['gai_info'][0]->GAI_SSJE;
|
|
|
|
|
$this->account_model->delete_money_t($pn_txn_id);
|
|
|
|
|
}
|
|
|
|
|
} elseif ($orderid_info->ordertype === 'B' || $orderid_info->ordertype === 'TP') {
|
|
|
|
|
$data['gai_info'] = $this->account_model->get_money_b($pn_txn_id);
|
|
|
|
|
if ( ! empty($data['gai_info'])) {
|
|
|
|
|
$old_ssje = $data['gai_info'][0]->GAI_SSJE;
|
|
|
|
|
$this->account_model->delete_money_b($pn_txn_id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!empty($pn_txn_id) && !empty($neworder)) {
|
|
|
|
|
$orderid_info = analysis_orderid($neworder);
|
|
|
|
|
if (!empty($orderid_info)) {
|
|
|
|
|
$orderid_info = json_decode($orderid_info);
|
|
|
|
|
$advisor_info = $this->account_model->get_order($orderid_info->orderid, false, $orderid_info->ordertype);
|
|
|
|
|
if (!empty($advisor_info)) {
|
|
|
|
|
$this->note_model->set_invoice($data['note']->OPN_SN, $neworder);
|
|
|
|
|
$this->send_notify($data['note']->OPN_SN, $old_ssje);
|
|
|
|
|
echo json_encode('修改成功!');
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
echo json_encode('没找到数据!');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function close_gai($opn_id)
|
|
|
|
|
{
|
|
|
|
|
$data = array();
|
|
|
|
|
$data['note'] = $this->note_model->get_note($opn_id);
|
|
|
|
|
if (!empty($data['note'])) {
|
|
|
|
|
$this->note_model->update_send($opn_id, $data['note'][0]->OPN_transactionId, 'closed');
|
|
|
|
|
echo json_encode('该收款记录已经忽略!');
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
echo json_encode('没找到数据!');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* 发送状态是send-to-finance的记录
|
|
|
|
|
* refund-imported
|
|
|
|
|
* @date 2019-05-15
|
|
|
|
|
*/
|
|
|
|
|
public function refund_finance_notify()
|
|
|
|
|
{
|
|
|
|
|
$all_list = $this->account_model->get_refund_imported();
|
|
|
|
|
if (empty($all_list)) {
|
|
|
|
|
echo "No refund record.";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
$this->load->library('PHPExcel');
|
|
|
|
|
$objPHPExcel = new PHPExcel();
|
|
|
|
|
$objPHPExcel->setActiveSheetIndex(0);
|
|
|
|
|
//set width
|
|
|
|
|
$objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(5);
|
|
|
|
|
$objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(15); // 部门
|
|
|
|
|
$objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(30); // 团号
|
|
|
|
|
$objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(15); // 金额
|
|
|
|
|
$objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(15); // 币种
|
|
|
|
|
$objPHPExcel->getActiveSheet()->getColumnDimension('F')->setWidth(15); // 人民币
|
|
|
|
|
$objPHPExcel->getActiveSheet()->getColumnDimension('G')->setWidth(20); // 付款人
|
|
|
|
|
$objPHPExcel->getActiveSheet()->getColumnDimension('H')->setWidth(30); // 邮箱
|
|
|
|
|
$objPHPExcel->getActiveSheet()->getColumnDimension('I')->setWidth(20); // 交易号
|
|
|
|
|
$objPHPExcel->getActiveSheet()->getColumnDimension('J')->setWidth(20); // 时间
|
|
|
|
|
// 对齐
|
|
|
|
|
$objPHPExcel->getActiveSheet()->getStyle('D')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
|
|
|
|
|
$objPHPExcel->getActiveSheet()->getStyle('F')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
|
|
|
|
|
// 表标题行
|
|
|
|
|
$objPHPExcel->getActiveSheet()
|
|
|
|
|
->SetCellValue('A1', '#')
|
|
|
|
|
->SetCellValue('B1', '部门')
|
|
|
|
|
->SetCellValue('C1', '团号')
|
|
|
|
|
->SetCellValue('D1', '金额')
|
|
|
|
|
->SetCellValue('E1', '币种')
|
|
|
|
|
->SetCellValue('F1', '人民币')
|
|
|
|
|
->SetCellValue('G1', '付款人')
|
|
|
|
|
->SetCellValue('H1', '邮箱')
|
|
|
|
|
->SetCellValue('I1', '交易号')
|
|
|
|
|
->SetCellValue('J1', '时间');
|
|
|
|
|
$currency_sum = array();
|
|
|
|
|
bcscale(2);
|
|
|
|
|
$rowCount = 2;
|
|
|
|
|
foreach ($all_list as $key => $row) {
|
|
|
|
|
$objPHPExcel->getActiveSheet()
|
|
|
|
|
->SetCellValue('A'.$rowCount, ($rowCount-1))
|
|
|
|
|
->SetCellValue('B'.$rowCount, $row['department'])
|
|
|
|
|
->setCellValueExplicit('C'.$rowCount, $row['gri_name'], PHPExcel_Cell_DataType::TYPE_STRING)
|
|
|
|
|
->setCellValueExplicit('D'.$rowCount, number_format($row['amount'], 2, ".", ""),PHPExcel_Cell_DataType::TYPE_STRING)
|
|
|
|
|
->SetCellValue('E'.$rowCount, trim($row['currency']))
|
|
|
|
|
->setCellValueExplicit('F'.$rowCount, $row['amount_CNY'], PHPExcel_Cell_DataType::TYPE_STRING)
|
|
|
|
|
->SetCellValue('G'.$rowCount, $row['payer'])
|
|
|
|
|
->SetCellValue('H'.$rowCount, $row['payer_email'])
|
|
|
|
|
->setCellValueExplicit('I'.$rowCount, $row['transaction_id'], PHPExcel_Cell_DataType::TYPE_STRING)
|
|
|
|
|
->SetCellValue('J'.$rowCount, $row['payment_date']);
|
|
|
|
|
$rowCount++;
|
|
|
|
|
}
|
|
|
|
|
$filename = "refund_imported_" . date('Y-m-d_H_i_s');
|
|
|
|
|
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
|
|
|
|
|
$objWriter->save(FCPATH . "download_statement/refund/" . $filename . ".xls");
|
|
|
|
|
if (file_exists(FCPATH . "download_statement/refund/" . $filename . ".xls")) {
|
|
|
|
|
// 保存成功:更新标记,邮件
|
|
|
|
|
foreach ($all_list as $ka => $va) {
|
|
|
|
|
// $this->account_model->update_send_fiance($va['note_sn'], $va['payment_type']);
|
|
|
|
|
}
|
|
|
|
|
$fromName = 'refund imported';
|
|
|
|
|
$fromEmail = '';
|
|
|
|
|
$toName = 'lyt';
|
|
|
|
|
$toEmail = 'lyt@hainatravel.com';
|
|
|
|
|
$subject = $filename;
|
|
|
|
|
$body = "https://www.mycht.cn/download_statement/refund/" . $filename . ".xls";
|
|
|
|
|
$M_AddTime = date('Y-m-d_H_i_s');
|
|
|
|
|
$M_State = 0;
|
|
|
|
|
$this->account_model->save_automail($fromName, $fromEmail, $toName, $toEmail, $subject, $body, 0, $M_State, $M_AddTime, 'refund imported', 'refund imported');
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|