|
|
|
@ -10,6 +10,7 @@ class Index extends CI_Controller {
|
|
|
|
|
// $this->output->enable_profiler(TRUE);
|
|
|
|
|
$this->load->model('Paypal_model');
|
|
|
|
|
$this->load->model('Note_model');
|
|
|
|
|
bcscale(2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function index() {
|
|
|
|
@ -1004,12 +1005,28 @@ class Index extends CI_Controller {
|
|
|
|
|
$allmost_day = 30;
|
|
|
|
|
}
|
|
|
|
|
$last_sn = null;
|
|
|
|
|
$last_notice_sn = null;
|
|
|
|
|
$last_notice_record = array();
|
|
|
|
|
if ( ! empty($last_record)) {
|
|
|
|
|
$last_sn = strstr($last_record, '@', TRUE);
|
|
|
|
|
$from_date = substr(strstr($last_record, '@'),1);
|
|
|
|
|
$selection_text = explode("@", $last_record);
|
|
|
|
|
$last_sn = $selection_text[0];
|
|
|
|
|
$last_notice_record = $this->Note_model->list_export_record($last_sn);
|
|
|
|
|
if ( ! empty($last_notice_record[0])) {
|
|
|
|
|
$last_notice_sn = $last_notice_record[0]->TEL_transactionNoticeId;
|
|
|
|
|
// 查询导出记录时包含上次导出的最后一条.
|
|
|
|
|
// 因此目标金额设为本次的目标+上次已导出的部分
|
|
|
|
|
// 得到结果集之后会把本次的第一条的金额重新计算,即减去上次已导出金额.下述<!$>
|
|
|
|
|
$amount = bcadd($amount, $last_notice_record[0]->TEL_exportAmount);
|
|
|
|
|
$from_date = strstr($last_notice_record[0]->TEL_transactionDate, " ", TRUE);
|
|
|
|
|
$currency = $last_notice_record[0]->TEL_transactionCurrency;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$all_list = $this->target_amount_recursive($currency, $amount, 0, $from_date, $allmost_day, array(), $last_sn);
|
|
|
|
|
$all_list = $this->target_amount_recursive($currency, $amount, 0, $from_date, $allmost_day, array(), $last_notice_sn);
|
|
|
|
|
$export_list = $all_list['list'];
|
|
|
|
|
// <!$>修改导出的第一条记录, 金额改为剩余金额<!$>
|
|
|
|
|
if ( ! empty($last_notice_record[0]) && $last_notice_record[0]->TEL_transactionNoticeId==$export_list[0]->pn_sn) {
|
|
|
|
|
$export_list[0]->pn_mc_gross = bcsub($last_notice_record[0]->TEL_transactionAmount, $last_notice_record[0]->TEL_exportAmount);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ($export_list == false) {
|
|
|
|
|
echo "Not found any records for export.";
|
|
|
|
@ -1017,6 +1034,8 @@ class Index extends CI_Controller {
|
|
|
|
|
}
|
|
|
|
|
// 记录这次导出的最后一条
|
|
|
|
|
if (isset($all_list['last_flag']) && ! empty($all_list['last_flag'])) {
|
|
|
|
|
$balance_diff = bcsub($all_list['now_amount'], $amount);
|
|
|
|
|
$last_record_export = bcsub($all_list['last_flag']->pn_mc_gross, $balance_diff);
|
|
|
|
|
$insert_db = array(
|
|
|
|
|
"TEL_transactionType" => 15002
|
|
|
|
|
,"TEL_transactionNoticeId" => $all_list['last_flag']->pn_sn
|
|
|
|
@ -1025,10 +1044,14 @@ class Index extends CI_Controller {
|
|
|
|
|
,"TEL_transactionAmount" => $all_list['last_flag']->pn_mc_gross
|
|
|
|
|
,"TEL_transactionCurrency" => $all_list['last_flag']->pn_mc_currency
|
|
|
|
|
,"TEL_orderId" => $all_list['last_flag']->pn_invoice
|
|
|
|
|
,"TEL_exportAmount" => $all_list['last_flag']->pn_mc_gross
|
|
|
|
|
,"TEL_exportAmount" => $last_record_export
|
|
|
|
|
,"TEL_exportDate" => date('Y-m-d H:i:s')
|
|
|
|
|
);
|
|
|
|
|
$this->Note_model->export_record($insert_db);
|
|
|
|
|
// 修改导出的最后一条
|
|
|
|
|
array_pop($export_list);
|
|
|
|
|
$all_list['last_flag']->pn_mc_gross = $last_record_export;
|
|
|
|
|
array_push($export_list, $all_list['last_flag']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->save_excel($export_list);
|
|
|
|
@ -1054,7 +1077,8 @@ class Index extends CI_Controller {
|
|
|
|
|
}
|
|
|
|
|
$ret = array(
|
|
|
|
|
"last_flag" => $last_flag,
|
|
|
|
|
"list" => $list
|
|
|
|
|
"list" => $list,
|
|
|
|
|
"now_amount" => $now_amount
|
|
|
|
|
);
|
|
|
|
|
if (empty($former_list)) {
|
|
|
|
|
return $ret;
|
|
|
|
|