示例#1
0
 public function NewBillParse($s, array &$info, array &$details)
 {
     #账户基本信息
     $date = '\\d{4}\\/\\d{2}\\/\\d{2}';
     $money = '[\\-\\d\\.,]+';
     $p = "/Ceiling Credit Limit # ({$money}) # 日常信用额度 Daily Credit Limit # ({$money}) # 取现额度 Cash Advance Limit # ({$money}) #/";
     $r = $this->pregMatchAll($p, $s, $out);
     //        print_r($out);
     //        exit;
     if ($r) {
         $info['credit_limit'] = ParseUtil::formatMoney($out[1][0]);
         $info['cash_advance_limit'] = ParseUtil::formatMoney($out[3][0]);
     } else {
         # # 信用额度 Credit Limit # 11,000 # 取现额度 Cash Advance
         #  Limit # 3,300 # 本期应还款总额 Total Statement Balance # RMB:4,130.41 USD:0.00
         #   # 本期最低还款额
         $p = "/信用额度 Credit Limit # ({$money}) # 取现额度 Cash Advance Limit # ({$money}) # 本期应还款总额/";
         $r = $this->pregMatchAll($p, $s, $out);
         //            print_r($out);
         //            exit;
         $info['credit_limit'] = ParseUtil::formatMoney($out[1][0]);
         $info['cash_advance_limit'] = ParseUtil::formatMoney($out[2][0]);
     }
     //        print_r($info);
     //        exit;
     $p = "/Total.*?({$money}) USD:0.00 # 本期最低还款额 Total Min Amount Due # RMB:({$money}) USD:0.00 # 到期还款日 Payment Due Date # ({$date}) #/";
     //Total Statement Balance # RMB:4,035.97 # 本期最低还款额 Total Min Amount Due # RMB:675.59 # 到期还款日 Payment Due Date # 2014/08/09 # 本期积分余额 Total Points Available # 65,701 #
     $r = $this->pregMatchAll($p, $s, $out);
     if (!$r) {
         $p = "/Total.*?({$money}) # 本期最低还款额 Total Min Amount Due # RMB:({$money}) # 到期还款日 Payment Due Date # ({$date}) #/";
         //Total Statement Balance # RMB:4,035.97 # 本期最低还款额 Total Min Amount Due # RMB:675.59 # 到期还款日 Payment Due Date # 2014/08/09 # 本期积分余额 Total Points Available # 65,701 #
         $r = $this->pregMatchAll($p, $s, $out);
     }
     if ($r) {
         $info['new_balance'] = ParseUtil::formatMoney($out[1][0]);
         $info['min_payment'] = ParseUtil::formatMoney($out[2][0]);
         $info['payment_due_date'] = ParseUtil::formatDate($out[3][0]);
         $info['payment_cur_date'] = strtotime('20 days ago', $info['payment_due_date']);
         $info['statement_end_date'] = $info['payment_cur_date'];
         $info['statement_start_date'] = strtotime('30 days ago', $info['statement_end_date']);
     }
     //本期账务说明
     $p = "/Last Statement Balance # [RMB:]*({$money})[^#]*#[^#]*# [RMB:]*({$money})[^#]*#[^#]*# [RMB:]*({$money})/";
     $p = "/New Charges # RMB:({$money}) USD:0.00 #   # RMB:({$money}) USD:0.00 #   # RMB:({$money}) USD:0.00 #   # RMB:({$money}) USD:0.00 #/";
     $r = $this->pregMatchAll($p, $s, $out);
     //        print_r($out);
     //        exit;
     if (!$r) {
         $p = "/New Charges # RMB:({$money}) #   # RMB:({$money}) #   # RMB:({$money}) #   # RMB:({$money}) #/";
         $r = $this->pregMatchAll($p, $s, $out);
     }
     if ($r) {
         $info['last_balance'] = ParseUtil::formatMoney($out[2][0]);
         $info['last_payment'] = ParseUtil::formatMoney($out[3][0]);
         $info['new_charges'] = ParseUtil::formatMoney($out[4][0]);
     }
     //积分明细
     $num = '[\\-\\d,]+';
     //$p = "/Points Beginning Balance # ($num) #[^#]+# ($num) #[^#]+# ($num) #[^#]+# ($num) #[^#]+# ($num) #[^#]+# ($num)/";
     $p = "/本期兑换积分 Points Redeemed This Month # ({$num}) # ({$num}) #   # ({$num}) #   # ({$num}) #   # ({$num}) #   # ({$num}) #   # ({$num}) #/";
     $r = $this->pregMatchAll($p, $s, $out);
     //        print_r($out);
     //        exit;
     if ($r) {
         $info['total_points'] = ParseUtil::formatNum($out[2][0]);
         $info['last_points'] = ParseUtil::formatNum($out[3][0]);
         $info['earned_points'] = ParseUtil::formatNum($out[4][0]);
         $info['adjusted_points'] = ParseUtil::formatNum($out[5][0]);
         $info['rewarded_points'] = ParseUtil::formatNum($out[6][0]);
         $info['redeemed_points'] = ParseUtil::formatNum($out[7][0]);
         $info = ParseUtil::trimArr($info);
     }
     //本期账务明细
     $p = '/交易金额 Amount(.*)# 卡号末四位/';
     $r = $this->pregMatchAll($p, $s, $out);
     $d = $out[1][0];
     $p = "/({$date}) # ({$date}) # ([^#]*) # (\\d{4}) # [RMB:]*({$money})/";
     $r = $this->pregMatchAll($p, $d, $out);
     //        print_r($out);
     //        exit;
     if ($r) {
         $cards = array_unique($out[4], SORT_REGULAR);
         sort($cards);
         $defaultNo = array_pop($cards);
         for ($i = 0; $i < count($out[0]); $i++) {
             $one['trans_date'] = ParseUtil::formatDate($out[1][$i], $info['statement_end_date']);
             $one['post_date'] = ParseUtil::formatDate($out[2][$i], $info['statement_end_date']);
             $one['description'] = $out[3][$i];
             $cardNo = empty($out[4][$i]) ? $defaultNo : $out[4][$i];
             $one['card_no'] = $cardNo;
             $one['rmb_amount'] = ParseUtil::formatMoney($out[5][$i]);
             $details[$cardNo][] = ParseUtil::trimArr($one);
             unset($one);
         }
         print_r($details);
     }
 }
示例#2
0
 public function parse($content)
 {
     $info = array();
     $s = str_replace('&nbsp;', ' ', $content);
     $s = str_replace('</td>', ' # ', $s);
     $s = strip_tags($s);
     $s = preg_replace('/\\s+/', ' ', $s);
     $s = preg_replace('/(#\\s)+/', '# ', $s);
     //        file_put_contents('/home/rong/tmp/guangda.' .time() . '.' . rand(0,100) . '.txt', $s);
     #用户信息 没有区分先生和女士
     $zh = '[\\x{4e00}-\\x{9fa5}]+';
     $p = "/尊敬的\\s*({$zh}?)\\s*(女士|先生)/u";
     $r = $this->pregMatchAll($p, $s, $out);
     $info['name'] = $out[1][0];
     $info['sex'] = $out[2][0];
     $fullCardNo = '\\d+\\*{2,8}\\d+';
     preg_match_all("/{$fullCardNo}/", $s, $match);
     //2015/06/25 added by wanghuafeng 多卡解析,合并多卡卡号
     $card_num_arr = array();
     $unique_cards_arr = array_unique($match[0]);
     foreach ($unique_cards_arr as $val) {
         $card_num_arr[] = substr($val, -4);
     }
     $all_card_no_str = implode(',', $card_num_arr);
     //        print_r($all_card_no_str);
     //        print_r($match);
     //        exit;
     $cards_count = count($card_num_arr);
     #账户基本信息
     #额度基本信息(人民币)
     $p = '/Rewards Points Balance # (\\S+) # (\\S+) # (\\S+) # (\\S+) # (\\S+) # (\\S+)/';
     $r = $this->pregMatchAll($p, $s, $out);
     $info['payment_cur_date'] = ParseUtil::formatDate($out[1][0]);
     $info['payment_due_date'] = ParseUtil::formatDate($out[2][0]);
     $info['credit_limit'] = ParseUtil::formatMoney($out[3][0]);
     #$info['cash_advance_limit'] = $out[2][0];
     $info['new_balance'] = ParseUtil::formatMoney($out[4][0]);
     $info['min_payment'] = ParseUtil::formatMoney($out[5][0]);
     //没有账单周期,自己算,当前账单日设为周期末尾一天
     $info['statement_end_date'] = $info['payment_cur_date'];
     $info['statement_start_date'] = strtotime('last month', $info['payment_cur_date']);
     #获取各张卡的账单汇总
     $p = '/Minimum Payment Due # (.*?)总计 #/';
     $r = $this->pregMatchAll($p, $s, $out);
     $d = $out[1][0];
     //        print_r($out);
     //        exit;
     $cards = array();
     if ($r) {
         $p = '/([\\d\\*]+) # (\\S+) # (\\S+) # (\\S+) # (\\S+)/';
         $r = $this->pregMatchAll($p, $d, $out);
         //            print_r($out);
         //            exit;
         for ($i = 0; $i < count($out[0]); $i++) {
             $card_key = $out[1][$i];
             //                $card['available_balance'] = ParseUtil::formatMoney($out[3][0]);//修改前AvailableCredit字段对应
             $card['new_charges'] = ParseUtil::formatMoney($out[3][0]);
             //竹君文档中对应new_charges
             $card['new_balance'] = ParseUtil::formatMoney($out[4][$i]);
             $card['min_payment'] = ParseUtil::formatMoney($out[5][$i]);
             $cards[$card_key]['balance'] = $card;
         }
         //            print_r($cards);
         //            exit;
     }
     #获取各张卡的交易信息
     $p = '/RMB Account Details(.*)精彩活动/';
     $r = $this->pregMatchAll($p, $s, $out);
     //        print_r($out);
     //        print_r($cards);
     //        exit;
     if ($r) {
         $trade_txt = $out[1][0];
         //            var_dump($trade_txt);
         //            exit;
         $trades_txt = explode('账号 Account Number:', $trade_txt);
         //            var_dump(count($trade_txt));
         //            exit;
         for ($i = 1; $i < count($trades_txt); $i++) {
             $this->pregMatchAll('/([\\d\\*]+)[^\\d]*上期(欠|存)款/', $trades_txt[$i], $out);
             //                var_dump($out);
             //                exit;
             $card_key = $out[1][0];
             //信用卡卡号00035683****1690593
             $date = '\\d{4}\\/\\d{2}\\/\\d{2}';
             $money = '([0-9,]+\\.\\d{2})';
             $p = "/({$date}) # ({$date}) # (\\d+) # ([^#]*?) # (\\(存入\\))?{$money}/";
             //完整版的账单详情(交易日期,记账日期,卡号末四位,交易明细,金额)
             $r = $this->pregMatchAll($p, $trades_txt[$i], $out_tmp);
             //                $previousBalancePattern = '/Previous Balance:([0-9,]+\.\d{2})/';
             //                $pbMatched = preg_match($previousBalancePattern, $trade_txt, $pbMatch);
             //                if ($pbMatched) {   //last_balance解析
             //                    $pb = $pbMatch[1];
             //                    $cards[$card_key]['balance']['last_balance'] = ParseUtil::formatMoney($pb);
             //                }
             //                var_dump($trades_txt[$i]);
             //                var_dump($out_tmp);
             //                exit;
             for ($j = 0; $j < count($out_tmp[1]); $j++) {
                 $trade['trans_date'] = ParseUtil::formatDate($out_tmp[1][$j], $info['statement_end_date']);
                 $trade['post_date'] = ParseUtil::formatDate($out_tmp[2][$j], $info['statement_end_date']);
                 $trade['card_no'] = $out_tmp[3][$j];
                 $trade['description'] = $out_tmp[4][$j];
                 $trade['currency'] = ParseUtil::getCurrencyType($out_tmp[6][$j]);
                 $trade['rmb_amount'] = ParseUtil::formatMoney($out_tmp[6][$j]);
                 if (!empty($out_tmp[5][$j])) {
                     $trade['rmb_amount'] *= -1;
                 }
                 $trade['type'] = ParseUtil::getConsumeType($trade['description']);
                 //消费分类
                 $trade['is_doubt'] = ParseUtil::isDoubtComsume($trade['description']);
                 //可疑消费分析
                 $trades[] = $trade;
             }
             //                var_dump($trades);
             //                exit;
             $cards[$card_key]['trade'] = $trades;
             $p = "/({$date}) # ({$date}) # ([^#]*?) # (\\(存入\\))?{$money}/";
             //缺少卡号末四位的明细(交易日期,记账日期,交易明细,金额)
             $r = $this->pregMatchAll($p, $trades_txt[$i], $out_tmp);
             //                var_dump($trades_txt[$i]);
             //                var_dump($out_tmp);
             //                exit;
             if ($r) {
                 for ($j = 0; $j < count($out_tmp[1]); $j++) {
                     $trade['trans_date'] = ParseUtil::formatDate($out_tmp[1][$j], $info['statement_end_date']);
                     $trade['post_date'] = ParseUtil::formatDate($out_tmp[2][$j], $info['statement_end_date']);
                     $trade['description'] = $out_tmp[3][$j];
                     if (!empty($out_tmp[4][$j])) {
                         $trade['rmb_amount'] *= -1;
                     }
                     $trade['currency'] = ParseUtil::getCurrencyType($out_tmp[5][$j]);
                     $trade['rmb_amount'] = ParseUtil::formatMoney($out_tmp[5][$j]);
                     $trade['type'] = ParseUtil::getConsumeType($trade['description']);
                     //消费分类
                     $trade['is_doubt'] = ParseUtil::isDoubtComsume($trade['description']);
                     //可疑消费分析
                     $trades[] = $trade;
                 }
                 $cards[$card_key]['trade'] = $trades;
             }
             $p = "/({$date}) # ({$date}) # (\\d+) # ([^#]*?) # /";
             //(只缺少金额)
             $r = $this->pregMatchAll($p, $trades_txt[$i], $out_tmp);
             //                var_dump($trades_txt[$i]);
             //                var_dump($out_tmp);
             //                exit;
             if ($r) {
                 for ($j = 0; $j < count($out_tmp[1]); $j++) {
                     $trade['trans_date'] = ParseUtil::formatDate($out_tmp[1][$j], $info['statement_end_date']);
                     $trade['post_date'] = ParseUtil::formatDate($out_tmp[2][$j], $info['statement_end_date']);
                     $trade['card_no'] = $out_tmp[3][$j];
                     $trade['description'] = $out_tmp[4][$j];
                     $fenqi = preg_match("/本期应还款{$money}/", $trade['description'], $rmbMatch);
                     if ($fenqi) {
                         //                            var_dump($trade['description']);
                         //                            var_dump($rmbMatch);
                         //                            exit;
                         $trade['currency'] = ParseUtil::getCurrencyType($rmbMatch[1]);
                         $trade['rmb_amount'] = ParseUtil::formatMoney($rmbMatch[1]);
                         $trade['type'] = ParseUtil::getConsumeType($trade['description']);
                         //消费分类
                         $trade['is_doubt'] = ParseUtil::isDoubtComsume($trade['description']);
                         //可疑消费分析
                         $trades[] = $trade;
                     } elseif (preg_match("/{$money}/", $trade['description'], $rmbMatch)) {
                         //                            var_dump($trade['description']);
                         //                            var_dump($rmbMatch);
                         //                            exit;
                         $trade['currency'] = ParseUtil::getCurrencyType($rmbMatch[1]);
                         $trade['rmb_amount'] = ParseUtil::formatMoney($rmbMatch[1]);
                         $trade['type'] = ParseUtil::getConsumeType($trade['description']);
                         //消费分类
                         $trade['is_doubt'] = ParseUtil::isDoubtComsume($trade['description']);
                         //可疑消费分析
                         $trades[] = $trade;
                     }
                 }
                 $cards[$card_key]['trade'] = $trades;
             }
             $p = "/({$date}) # ({$date}) # ([^#]*?) # /";
             //(缺少卡号和金额,解析交易说明中的)
             $r = $this->pregMatchAll($p, $trades_txt[$i], $out_tmp);
             //                var_dump($trades_txt[$i]);
             //                var_dump($out_tmp);
             //                exit;
             if ($r) {
                 for ($j = 0; $j < count($out_tmp[1]); $j++) {
                     $trade['trans_date'] = ParseUtil::formatDate($out_tmp[1][$j], $info['statement_end_date']);
                     $trade['post_date'] = ParseUtil::formatDate($out_tmp[2][$j], $info['statement_end_date']);
                     $trade['description'] = $out_tmp[3][$j];
                     $fenqi = preg_match("/本期应还款{$money}/", $trade['description'], $rmbMatch);
                     if ($fenqi) {
                         $trade['currency'] = ParseUtil::getCurrencyType($rmbMatch[1]);
                         $trade['rmb_amount'] = ParseUtil::formatMoney($rmbMatch[1]);
                         $trade['type'] = ParseUtil::getConsumeType($trade['description']);
                         //消费分类
                         $trade['is_doubt'] = ParseUtil::isDoubtComsume($trade['description']);
                         //可疑消费分析
                         $trades[] = $trade;
                     }
                 }
                 $cards[$card_key]['trade'] = $trades;
             }
         }
     }
     #积分明细
     $p = '/调整积分 ?Adjusted.*?# (\\d+) #[^#]*# (\\d+) #[^#]*# (\\d+) #[^#]*# (\\d+) #[^#]*# (\\d+)/';
     $r = $this->pregMatchAll($p, $s, $out);
     if ($r) {
         $info['total_points'] = ParseUtil::formatNum($out[1][0]);
         $info['last_points'] = ParseUtil::formatNum($out[2][0]);
         $info['earned_points'] = ParseUtil::formatNum($out[3][0]);
         $info['redeemed_points'] = ParseUtil::formatNum($out[4][0]);
         $info['adjusted_points'] = ParseUtil::formatNum($out[5][0]);
     }
     if (empty($cards)) {
         return $this->insert($info);
     }
     //        print_r($cards);
     //        exit;
     //区分不同的卡
     foreach ($cards as $key => $detail) {
         $oneCardInfo = $info;
         //            $oneCardInfo['card_no'] = substr($key, -4);
         $oneCardInfo['card_no'] = $all_card_no_str;
         $oneCardInfo['trans_detail'] = json_encode($detail['trade']);
         if (is_array($detail['balance'])) {
             $oneCardInfo = array_merge($oneCardInfo, $detail['balance']);
         }
         //            $this->insert($oneCardInfo);
     }
     return true;
 }
示例#3
0
 public function parse($content)
 {
     //        echo $content;
     //        exit;
     $info = array();
     $s = str_replace('&nbsp;', ' ', $content);
     $s = str_replace('#', '', $s);
     $s = str_replace(array('</td>', '</TD>'), ' # ', $s);
     $s = strip_tags($s);
     $s = preg_replace('/\\s+/', ' ', $s);
     // 		$s = preg_replace('/(#\s)+/', '# ', $s);
     // 		file_put_contents('/home/rong/tmp/huaxia.one.' . date('Ymd.His') . '.' . rand(0,100) . '.txt', $s);
     #用户信息
     $zh = '[\\x{4e00}-\\x{9fa5}]+';
     $p = "/尊敬的\\s*({$zh})\\s*(先生|女士)/u";
     $r = $this->pregMatchAll($p, $s, $out);
     if (!$r) {
         $p = "/尊敬的*({$zh})\\s*(先生|女士)/u";
         $r = $this->pregMatchAll($p, $s, $out);
     }
     $info['name'] = $out[1][0];
     $info['sex'] = $out[2][0];
     $date = '\\d{4}\\/\\d{2}\\/\\d{2}';
     $money = '[\\-\\d\\.,]+';
     $this->pregMatchAll('/信用卡对账单[^\\d]*?(\\d.*)份/', $s, $out);
     $month = $out[1][0];
     #账户基本信息
     $p = "/Statement Date: # 每月(\\d{2}日).*Payment Due Date: # ({$date}).*Credit Limit: # ({$money}).*Cash Advance Limit: # ({$money})/";
     $r = $this->pregMatchAll($p, $s, $out);
     if ($r) {
         $info['payment_cur_date'] = ParseUtil::formatDate($month . $out[1][0]);
         $info['payment_due_date'] = ParseUtil::formatDate($out[2][0]);
         $info['credit_limit'] = ParseUtil::formatMoney($out[3][0]);
         $info['cash_advance_limit'] = ParseUtil::formatMoney($out[4][0]);
         $info['statement_end_date'] = $info['payment_cur_date'];
         $info['payment_cur_date'] > 0 && ($info['statement_start_date'] = strtotime('last month', $info['payment_cur_date']));
     }
     $rmbStr = substr($s, 0, strpos($s, "美元账户"));
     #账户还款计算明细(tip:中间有中文空白符)
     $p = "/Amount Payable: ({$money}).*?Minimum Payment: ({$money}).*?Interest # ({$money})[\\s #]+({$money})[\\s #]+({$money})[\\s #]+({$money})[\\s #]+({$money})[\\s #]+({$money})/";
     $r = $this->pregMatchAll($p, $s, $out);
     if ($r) {
         //            print_r($out);
         //            exit;
         $info['new_balance'] = ParseUtil::formatMoney($out[3][0]);
         // Closing Balance
         $info['min_payment'] = ParseUtil::formatMoney($out[2][0]);
         //Minimum Payment:
         $info['last_balance'] = ParseUtil::formatMoney($out[4][0]);
         //Opening Balance
         $info['last_payment'] = ParseUtil::formatMoney($out[5][0]);
         // New Credits
         $info['new_charges'] = ParseUtil::formatMoney($out[6][0]);
         //New Debits
         $info['adjustment'] = ParseUtil::formatMoney($out[7][0]);
         //Adjustment
         $info['interest'] = ParseUtil::formatMoney($out[8][0]);
         //Interest
     }
     print_r($info);
     #积分明细
     $number = '[\\d,]+';
     $p = "/Points Redeemed this month # ({$number})[\\s #]+({$number})[\\s #]+({$number})[\\s #]+({$number})[\\s #]+({$number})[\\s #]+({$number})/";
     $r = $this->pregMatchAll($p, $s, $out);
     if ($r) {
         $info['total_points'] = ParseUtil::formatNum($out[1][0]);
         $info['last_points'] = ParseUtil::formatNum($out[2][0]);
         $info['earned_points'] = ParseUtil::formatNum($out[3][0]);
         $info['rewarded_points'] = ParseUtil::formatNum($out[4][0]);
         $info['adjusted_points'] = ParseUtil::formatNum($out[5][0]);
         $info['redeemed_points'] = ParseUtil::formatNum($out[6][0]);
         $info = ParseUtil::trimArr($info);
     }
     var_export($info);
     //详细交易信息
     $details = array();
     $p = "/({$date})[^#]* # ({$date}) # ([^#]*) # ({$money}) # (\\d{4})/";
     $this->pregMatchAll($p, $s, $out);
     for ($j = 0; $j < count($out[0]); $j++) {
         $one['trans_date'] = ParseUtil::formatDate($out[1][$j], $info['statement_end_date']);
         $one['post_date'] = ParseUtil::formatDate($out[2][$j], $info['statement_end_date']);
         $one['description'] = $out[3][$j];
         $one['rmb_amount'] = ParseUtil::formatMoney($out[4][$j]);
         $one['currency'] = ParseUtil::getCurrencyType($out[4][$j]);
         $one['card_no'] = $out[5][$j];
         $cardNo = $one['card_no'];
         $one['orign_amount'] = $one['rmb_amount'];
         $one['type'] = ParseUtil::getConsumeType($one['description']);
         // 消费分类
         $one['is_doubt'] = ParseUtil::isDoubtComsume($one['description']);
         // 可疑消费分析
         $details[$cardNo][] = ParseUtil::trimArr($one);
     }
     if (empty($details)) {
         return $this->insert($info);
     }
     //区分不同的卡
     foreach ($details as $cardNo => $detail) {
         $oneCardInfo = $info;
         $oneCardInfo['card_no'] = $cardNo;
         $oneCardInfo['trans_detail'] = json_encode($detail);
         $this->insert($oneCardInfo);
     }
     return true;
 }
示例#4
0
 public function parse($content)
 {
     $info = array();
     $s = str_replace('&nbsp;', ' ', $content);
     $s = preg_replace('/<\\/td>/', ' # ', $s);
     $s = strip_tags($s);
     $s = preg_replace('/\\s+/', ' ', $s);
     $s = preg_replace('/(#\\s)+/', '# ', $s);
     //        file_put_contents('/home/rong/tmp/gongshang.' .time() . '.' . rand(0,100) . '.txt', $s);
     //用户信息
     $zh = '[\\x{4e00}-\\x{9fa5}]+';
     $p = "/尊敬的\\s*?({$zh})\\s*?(女士|先生)/u";
     $r = $this->pregMatchAll($p, $s, $out);
     if ($r) {
         $info['name'] = $out[1][0];
         $info['sex'] = $out[2][0];
     }
     $cardPattern = '# (\\d{4}) #';
     preg_match_all("/{$cardPattern}/", $s, $cardMatch);
     $card_num_arr = array();
     $unique_cards_arr = array_unique($cardMatch[1]);
     foreach ($unique_cards_arr as $val) {
         $card_num_arr[] = substr($val, -4);
     }
     $cards_count = count($card_num_arr);
     $all_card_no_str = implode(',', array_unique($card_num_arr));
     var_dump($all_card_no_str);
     var_dump($cards_count);
     exit;
     //用户基本信息
     $p = '/贷记卡到期还款日 # ([^#]+) #.*?账单周期 ([^#]+) # 对账单生成日 ([^#]+) #/';
     $r = $this->pregMatchAll($p, $s, $out);
     $t = explode('—', trim($out[2][0]));
     if ($t) {
         $info['statement_start_date'] = ParseUtil::formatDate($t[0]);
         $info['statement_end_date'] = strtotime('+ 30 days', $info['statement_start_date']);
         $info['payment_cur_date'] = ParseUtil::formatDate($out[3][0]);
         $info['payment_due_date'] = ParseUtil::formatDate($out[1][0]);
     }
     $cards = array();
     $p = '/信用额度 #(.*)?合计 # 人民币/';
     $r = $this->pregMatchAll($p, $s, $out);
     $d = $out[1][0];
     $money = '([\\d\\-\\.\\/,RMB]+)';
     $p = "/(\\d+)[^#]*? # (\\S+) # {$money} # {$money} # {$money}/";
     $r = $this->pregMatchAll($p, $d, $out);
     //        print_r($out);
     //        exit;
     if ($out[1][0]) {
         $info['card_no'] = $all_card_no_str;
     }
     for ($i = 0; $i < count($out[0]); $i++) {
         $cardNo = $out[1][$i];
         $card['new_balance'] = ParseUtil::formatMoney($out[3][$i]);
         $card['min_payment'] = ParseUtil::formatMoney($out[4][$i]);
         $card['credit_limit'] = ParseUtil::formatMoney($out[5][$i]);
         $cards[$cardNo]['balance']['人民币'] = $card;
     }
     //本期交易汇总(人民币)
     $p = '/本期余额 # .*?人民币(.*)?合计/';
     $r = $this->pregMatchAll($p, $s, $out);
     $d = $out[1][0];
     $p = "/(\\d+) # {$money} # {$money} # {$money} # {$money}/";
     $r = $this->pregMatchAll($p, $d, $out);
     /*
     		for ($i = 0; $i < count($out[0]); $i++) {
     			$cardNo = $out[1][$i];
     			$one ['last_balance'] = ParseUtil::formatMoney($out[2][$i]);
     			$one ['last_payment'] = ParseUtil::formatMoney($out[3][$i]);
     			$one ['new_charges'] = ParseUtil::formatMoney($out[4][$i]);
     			if (is_array($cards[$cardNo]['balance']['人民币'])) {
     				$cards[$cardNo]['balance']['人民币'] = array_merge($cards[$cardNo]['balance']['人民币'], $one);
     			} else {
     				$cards[$cardNo]['balance']['人民币'] = $one;
     			}
     		}
     */
     //        print_r($out);
     //        exit;
     if ($r) {
         if ($cards_count > 1) {
             $cardNo = $out[1][$i];
             $last_balance = 0;
             foreach ($out[2] as $val) {
                 $last_balance += ParseUtil::formatMoney($val);
             }
             $one['last_balance'] = $last_balance * -1;
             //last_balance 正负号对调
             $last_payment = 0;
             foreach ($out[3] as $val) {
                 $last_payment += ParseUtil::formatMoney($val);
             }
             $one['last_payment'] = $last_payment;
             $new_charges = 0;
             foreach ($out[4] as $val) {
                 $new_charges += ParseUtil::formatMoney($val);
             }
             $one['new_charges'] = $new_charges;
             if (is_array($cards[$cardNo]['balance']['人民币'])) {
                 $cards[$cardNo]['balance']['人民币'] = array_merge($cards[$cardNo]['balance']['人民币'], $one);
             } else {
                 $cards[$cardNo]['balance']['人民币'] = $one;
             }
             //                print_r($one);
             //                exit;
         } else {
             for ($i = 0; $i < count($out[0]); $i++) {
                 $cardNo = $out[1][$i];
                 $one['last_balance'] = ParseUtil::formatMoney($out[2][$i]) * -1;
                 //last_balance 正负号对调
                 $one['last_payment'] = ParseUtil::formatMoney($out[3][$i]);
                 $one['new_charges'] = ParseUtil::formatMoney($out[4][$i]);
                 if (is_array($cards[$cardNo]['balance']['人民币'])) {
                     $cards[$cardNo]['balance']['人民币'] = array_merge($cards[$cardNo]['balance']['人民币'], $one);
                 } else {
                     $cards[$cardNo]['balance']['人民币'] = $one;
                 }
             }
         }
         //            var_dump($one);
         //            exit;
         #	Yii::log(print_r($out,1).print_r($s,1)."=======gongshang0==");
     }
     //详细交易信息
     $date = '\\d{4}\\-\\d{2}\\-\\d{2}';
     $p = '/交 易 明 细 #(.*)?积 分 信 息 /';
     $r = $this->pregMatchAll($p, $s, $out);
     $d = $out[1][0];
     //        print_r($out);
     //        exit;
     $p = "/(\\d{4}) # ({$date}) # ({$date}) # ([^#]*) # ([^#]*) # {$money} # {$money}\\((存入|支出)\\)/";
     #	$p = "/(\d{4}) # ($date) # ($date) # (\S+) # (\S+) # $money # $money\((存入|支出)\)/";
     $r = $this->pregMatchAll($p, $d, $out);
     for ($i = 0; $i < count($out[0]); $i++) {
         unset($one);
         $cardNo = $out[1][$i];
         $one['card_no'] = $cardNo;
         $one['trans_date'] = intval(strtotime($out[2][$i]));
         $one['post_date'] = intval(strtotime($out[3][$i]));
         $one['description'] = $out[4][$i];
         $one['rmb_amount'] = ParseUtil::formatMoney($out[6][$i]);
         if ($out[8][$i] == '存入') {
             $one['rmb_amount'] *= -1;
         }
         $one['currency'] = ParseUtil::getCurrencyType($out[6][$i]);
         $one['type'] = ParseUtil::getConsumeType($one['description']);
         //消费分类
         $one['is_doubt'] = ParseUtil::isDoubtComsume($one['description']);
         //可疑消费分析
         $cards[$cardNo]['trades'][] = $one;
     }
     //        print_r($cards[$cardNo]['trades']);
     //        exit;
     //细分明细(信用卡积分,分行特色信用卡积分,联名积分1,联名积分2)
     //		$p = '/分行特色信用卡积分 # 新增 ([\d,]+) # 余额 ([\d,]+)/';
     $p = '/积分 # (新增 ([\\d,]+) # )?余额 ([\\d,]+)/';
     $r = $this->pregMatchAll($p, $s, $out);
     if ($r) {
         $info['total_points'] = ParseUtil::formatNum($out[3][0]);
         $info['earned_points'] = ParseUtil::formatNum($out[2][0]);
     }
     $info = ParseUtil::trimArr($info);
     if (empty($cards)) {
         return $this->insert($info);
     }
     //区分不同的卡
     $oneCardInfo = $info;
     if ($cards_count > 1) {
         $detailArr = array();
         foreach ($cards as $key => $detail) {
             //$oneCardInfo['card_no'] = $key;
             if (isset($detail['trades'])) {
                 $detailArr = array_merge($detailArr, $detail['trades']);
             }
             if (is_array($detail['balance'])) {
                 $oneCardInfo = array_merge($oneCardInfo, $detail['balance']);
                 unset($oneCardInfo['人民币']);
             }
             if (is_array($detail['balance']['人民币'])) {
                 $oneCardInfo = array_merge($oneCardInfo, $detail['balance']['人民币']);
             }
             if (isset($detail['balance']['美元'])) {
                 $oneCardInfo['credit_limit_usd'] = $detail['balance']['美元']['credit_limit'];
                 $oneCardInfo['new_balance_usd'] = $detail['balance']['美元']['new_balance'];
                 $oneCardInfo['min_payment_usd'] = $detail['balance']['美元']['min_payment'];
             }
             if (is_array(@$detail['points'])) {
                 $oneCardInfo = array_merge($oneCardInfo, $detail['points']);
             }
         }
         $oneCardInfo['trans_detail'] = json_encode($detailArr);
         print_r($oneCardInfo);
         exit;
         //            $this->insert($oneCardInfo);
     } else {
         foreach ($cards as $key => $detail) {
             //$oneCardInfo['card_no'] = $key;
             if (isset($detail['trades'])) {
                 $oneCardInfo['trans_detail'] = json_encode($detail['trades']);
             }
             if (is_array($detail['balance'])) {
                 $oneCardInfo = array_merge($oneCardInfo, $detail['balance']);
                 unset($oneCardInfo['人民币']);
             }
             if (is_array($detail['balance']['人民币'])) {
                 $oneCardInfo = array_merge($oneCardInfo, $detail['balance']['人民币']);
             }
             if (isset($detail['balance']['美元'])) {
                 $oneCardInfo['credit_limit_usd'] = $detail['balance']['美元']['credit_limit'];
                 $oneCardInfo['new_balance_usd'] = $detail['balance']['美元']['new_balance'];
                 $oneCardInfo['min_payment_usd'] = $detail['balance']['美元']['min_payment'];
             }
             if (is_array(@$detail['points'])) {
                 $oneCardInfo = array_merge($oneCardInfo, $detail['points']);
             }
             //            $this->insert($oneCardInfo);
             //            print_r($oneCardInfo);
         }
     }
     //        print_r($oneCardInfo);
     exit;
     return true;
 }
示例#5
0
 public function newBillParse($s, array &$info, array &$details)
 {
     #账户基本信息
     #额度基本信息(人民币)
     //账单日 Statement Date # 20141127 # 信用额度 Credit Limit # 3900.00 CNY #
     $money = '([\\-\\d\\.,]+)';
     $date = '\\d{8}';
     $p = "/账单日.*? ({$date})/";
     //.*?Credit Limit # ($money) #/";
     $r = $this->pregMatchAll($p, $s, $out);
     if ($r) {
         $info['payment_cur_date'] = ParseUtil::formatDate($out[1][0]);
         //没有账单周期,自己算,当前账单日设为周期末尾一天
         $info['statement_end_date'] = $info['payment_cur_date'];
         $info['statement_start_date'] = strtotime('last month', $info['payment_cur_date']);
     }
     $p = "/到期还款日.*? ({$date}) # 还款明细 #/";
     $r = $this->pregMatchAll($p, $s, $out);
     if ($r) {
         $info['payment_due_date'] = ParseUtil::formatDate($out[1][0]);
     }
     $p = "/信用额度 Credit Limit # ({$money}) CNY/";
     $r = $this->pregMatchAll($p, $s, $out);
     //        print_r($s);
     //        print_r($out);
     //        exit;
     $info['credit_limit'] = ParseUtil::formatMoney($out[1][0]);
     $p = "/人民币\\(CNY\\) # ({$money}) # ({$money}) # ({$date}) # 还款明细 #/";
     $r = $this->pregMatchAll($p, $s, $out);
     #$info['cash_advance_limit'] = $out[5][0];
     $info['new_balance'] = ParseUtil::formatMoney($out[1][0]) * -1;
     $info['min_payment'] = ParseUtil::formatMoney($out[3][0]);
     //		$info['credit_limit_usd'] = ParseUtil::formatMoney($out[4][0]);
     #账户还款计算明细(人民币)
     $p = "/人民币(CNY) # {$money} # {$money} # {$money} # {$money} # {$money} #/";
     $r = $this->pregMatchAll($p, $s, $out);
     $info['last_balance'] = ParseUtil::formatMoney($out[1][0]) * -1;
     $info['last_payment'] = ParseUtil::formatMoney($out[3][0]);
     $info['new_charges'] = ParseUtil::formatMoney($out[2][0]);
     $p = '/\\d{4,8} # \\d{4,8} # \\d{4} # [^#]* # [^#]* # [^#]+ # [^#]+ /';
     $r = $this->pregMatchAll($p, $s, $out);
     for ($i = 0; $i < count($out[0]); $i++) {
         $out[$i + 1] = explode("#", $out[0][$i]);
     }
     for ($i = 1; $i < count($out[0]) + 1; $i++) {
         $one['trans_date'] = intval(strtotime($out[$i][0]));
         $one['post_date'] = intval(strtotime($out[$i][1]));
         $one['card_no'] = trim($out[$i][2]);
         $one['description'] = $out[$i][3];
         $one['rmb_amount'] = ParseUtil::formatMoney($out[$i][6]) * -1;
         $one['currency'] = ParseUtil::getCurrencyType($out[$i][5]);
         #$one['trans_area'] = $out[5][0];
         #$one['orign_amount'] = $out[7][0];
         $one['type'] = ParseUtil::getConsumeType($one['description']);
         //消费分类
         $one['is_doubt'] = ParseUtil::isDoubtComsume($one['description']);
         // 可疑消费分析
         $details[$one['card_no']][] = ParseUtil::trimArr($one);
     }
 }
示例#6
0
 /**
  * 解析2013年11月份之后的账单
  * @param array $card
  * @param array $info
  */
 public function parseNewBill($s, array &$cards, array &$info)
 {
     $dateHead = '\\d{4}年\\d{1,2}月\\d{1,2}日';
     $money = '[-\\d\\.,]+';
     $p = "/记录了您({$dateHead})\\S*-\\S*({$dateHead})账户变动信息.*?最后还款日:({$dateHead})/";
     $r = $this->pregMatchAll($p, $s, $out);
     //        print_r($out);
     //        exit;
     if ($r) {
         $info['statement_start_date'] = ParseUtil::formatDate($out[1][0]);
         $info['statement_end_date'] = ParseUtil::formatDate($out[2][0]);
         $info['payment_cur_date'] = $info['statement_end_date'];
         $info['payment_due_date'] = ParseUtil::formatDate($out[3][0]);
     } else {
         return false;
     }
     $p = "/信用额度 # 申请调额 # RMB # ({$money})元 # RMB # ({$money})元 # RMB # ({$money}) # 预借现金额度 # RMB # ({$money})/";
     $r = $this->pregMatchAll($p, $s, $out);
     //        print_r($out);
     //        exit;
     //2014年11份以后部分账单
     if (!$r) {
         #     $p = "/信用额度 # 申请调额 # [^#]* # RMB # ($money)元 # [^#]* # RMB # ($money)元 # [^#]* # RMB # ($money) # 预借现金额度 # [^#]* # RMB # ($money) #/";
         $p = "/信用额度 # 申请调额 # [^#]* # [^#]* # RMB # ({$money})元 # [^#]* # EUR # RMB # ({$money})元 # [^#]* # HKD # RMB # ({$money}) # 预借现金额度 # [^#]* # EUR # RMB # ({$money}) #/";
         $r = $this->pregMatchAll($p, $s, $out);
         //            print_r($out);
         //            exit;
     }
     if (!$r) {
         $p = "/信用额度 # 申请调额 # RMB # ({$money})元 # [^#]* # USD # ({$money})元 # RMB # ({$money})元 # HKD # USD # ({$money})元 # EUR # RMB # ({$money}) # 预借现金额度 # HKD # RMB # ({$money}) #/";
         $r = $this->pregMatchAll($p, $s, $out);
     }
     if (!$r) {
         $p = "/信用额度 # 申请调额 # [\\D]* # ({$money})元 # [\\D]* # ({$money})元 # [\\D]* # ({$money})元 # [\\D    ]* # ({$money})元 # [\\D]* # ({$money}) # 预借现金额度 # [\\D]* # ({$money}) #/";
         $r = $this->pregMatchAll($p, $s, $out);
     }
     if (!$r) {
         #信用额度 # 申请调额 # nullQR # RMB # 8382.99元 # HKD # RMB # 419.15元 # nullKJi # RMB # 40,000 # 预借现金额度 #
         $p = "/信用额度 # 申请调额 # [\\D]* # RMB # ({$money})元 # HKD # RMB # ({$money})元 # [\\D]* # RMB # ({$money}) # 预借现金额度 # HKD # RMB # ({$money})/";
         $r = $this->pregMatchAll($p, $s, $out);
         #Yii::log(print_r($out, 1)."======zhongxin0");
     }
     if (!$r) {
         #信用额度 # 申请调额 # nulluQI # nullHCIJ # RMB # 6440.43元 # nullRL # RMB # RMB # 322.02元 # USD # USD # RMB # 18,000 # 预借现金额度 # nullHCIJ # RMB # RMB # 18,000 #
         $p = "/信用额度 # 申请调额 # .*? # RMB # ({$money})元 # .*? # RMB # ({$money})元 # .*? # RMB # ({$money}) # 预借现金额度 # .*? # RMB # ({$money})/";
         $r = $this->pregMatchAll($p, $s, $out);
     }
     //        print_r($s);
     //        print_r($out);
     //        exit;
     if ($r) {
         if (count($out) > 6) {
             $info['new_balance'] = ParseUtil::formatMoney($out[1][0]);
             $info['min_payment'] = ParseUtil::formatMoney($out[3][0]);
             $info['credit_limit'] = ParseUtil::formatMoney($out[5][0]);
             $info['cash_advance_limit'] = ParseUtil::formatMoney($out[6][0]);
         } else {
             $info['new_balance'] = ParseUtil::formatMoney($out[1][0]);
             $info['min_payment'] = ParseUtil::formatMoney($out[2][0]);
             $info['credit_limit'] = ParseUtil::formatMoney($out[3][0]);
             $info['cash_advance_limit'] = ParseUtil::formatMoney($out[4][0]);
         }
     }
     //        print_r($out);
     print_r($info);
     exit;
     #$tmp = array_merge($out, $info);
     #Yii::log(print_r($tmp,1)."==========zhongxin================!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
     #获取各张卡的账单汇总(该部门没变)
     $p = '/Current Balance # Min.Payment # (.*?)消费走势/';
     $r = $this->pregMatchAll($p, $s, $out);
     //        print_r($s);
     //        exit;
     $d = $out[1][0];
     //        print_r($out);
     //        exit;
     $cards = array();
     if ($r) {
         $p = "/# RMB # ({$money}) # ({$money}) # ({$money}) # ({$money}) # ({$money}) #/";
         $r = $this->pregMatchAll($p, $d, $out);
         //            print_r($out);
         //            exit;
         if ($this->cards_count > 1) {
             $last_balance = 0;
             foreach ($out[1] as $val) {
                 $last_balance += ParseUtil::formatMoney($val);
             }
             $info['last_balance'] = $last_balance;
             $last_payment = 0;
             foreach ($out[2] as $val) {
                 $last_payment += ParseUtil::formatMoney($val);
             }
             $info['last_payment'] = $last_payment;
             $new_charges = 0;
             foreach ($out[3] as $val) {
                 $new_charges += ParseUtil::formatMoney($val);
             }
             $info['new_charges'] = $new_charges;
             $new_balance = 0;
             foreach ($out[4] as $val) {
                 $new_balance += ParseUtil::formatMoney($val);
             }
             $info['new_balance'] = $new_balance;
             $min_payment = 0;
             foreach ($out[5] as $val) {
                 $min_payment += ParseUtil::formatMoney($val);
             }
             $info['min_payment'] = $min_payment;
             //                print_r($info);
             //                exit;
         } else {
             for ($i = 0; $i < count($out[0]); $i++) {
                 $info['last_balance'] = ParseUtil::formatMoney($out[1][$i]);
                 $info['last_payment'] = ParseUtil::formatMoney($out[2][$i]);
                 $info['new_charges'] = ParseUtil::formatMoney($out[3][$i]);
                 $info['new_balance'] = ParseUtil::formatMoney($out[4][$i]);
                 $info['min_payment'] = ParseUtil::formatMoney($out[5][$i]);
             }
         }
     }
     return true;
 }
示例#7
0
 public function newBillParse($s, array &$info, array &$details)
 {
     $money = '[¥$\\$\\d\\-\\., ]+';
     // $p = "/Statement Cycle # ($date)-($date).*?Date # ($date).*?Limit # ($money).*?Balance # ($money).*?Limit # ($money).*?Payment # ($money)/";
     $p = "/本期应还金额 New Balance # ({$money}) # ({$money}).*?Payment # ({$money}) # ({$money}) #/";
     $r = $this->pregMatchAll($p, $s, $out);
     //        print_r($s);
     //        print_r($out);
     //        exit;
     //新账单分为两种,两种的串不同,若没有匹配出来则匹配另一个串
     if (NULL === $out[3][0]) {
         $p = "/# 您 # (\\d{4}) # 年 # (\\d{2}) # 月信用卡个人卡账单已出, # # 最后还款日 # (\\d{2}) # 月 # (\\d{2}) # 日/";
         $r = $this->pregMatchAll($p, $s, $out);
     }
     if ($r) {
         $info['new_balance'] = ParseUtil::formatMoney($out[1][0]);
         $info['min_payment'] = ParseUtil::formatMoney($out[3][0]);
         //            print_r($info);
     }
     $p = "/# 您 # (\\d{4}) # 年 # (\\d{2}) # 月信用卡个人卡账单已出, # # 最后还款日\\(Payment Due Date\\) # (\\d{2}) # 月 # (\\d{2}) # 日/";
     $r = $this->pregMatchAll($p, $s, $out);
     //        print_r($out);
     //        exit;
     //新账单分为两种,两种的串不同,若没有匹配出来则匹配另一个串
     if (NULL === $out[3][0]) {
         $p = "/# 您 # (\\d{4}) # 年 # (\\d{2}) # 月信用卡个人卡账单已出, # # 最后还款日 # (\\d{2}) # 月 # (\\d{2}) # 日/";
         $r = $this->pregMatchAll($p, $s, $out);
     }
     //有些账单没有还款日  需要从发件日期处取时间作为payment_cur_date
     if (!$r) {
         $p = "/# 您 # (\\d{4}) # 年 # (\\d{2}) # 月信用卡个人卡账单已出/";
         $r = $this->pregMatchAll($p, $s, $out);
         //            print_r($s);
         //            print_r($out);
         //            exit;
         if ($r) {
             $p = "/时 间: (\\d{4})年(\\d{2})月(\\d{1,2})日\\(.*?\\)/";
             //时 间: 2014年11月9日(星期天)
             $r = $this->pregMatchAll($p, $s, $out);
             if ($r) {
                 $info['payment_cur_date'] = ParseUtil::formatDate($out[1][0] . '-' . $out[2][0] . '-' . $out[3][0]);
                 echo $out[1][0] . '-' . $out[3][0] . '-' . $out[4][0];
                 $info['payment_due_date'] = strtotime('+ 17 days', $info['payment_cur_date']);
                 $info['statement_end_date'] = strtotime('17 days ago', $info['payment_cur_date']);
                 $info['statement_start_date'] = strtotime('30 days ago', $info['statement_end_date']);
                 //匹配成功返回到主函数
                 return;
             }
         }
         //            exit;
     }
     //年份拼接   看账单月份和还款月份之间是否跨年
     if (1 == $out[3][0]) {
         if (1 != $out[2][0]) {
             $out[1][0] = (string) ($out[1][0] + 1);
         }
     }
     $info['payment_due_date'] = ParseUtil::formatDate($out[1][0] . '-' . $out[3][0] . '-' . $out[4][0]);
     $info['payment_cur_date'] = strtotime('20 days ago', $info['payment_due_date']);
     $info['statement_end_date'] = $info['payment_due_date'];
     $info['statement_start_date'] = strtotime('30 days ago', $info['statement_end_date']);
     $info['card_no'] = '0000';
 }
示例#8
0
 /**
  * 解析邮件内容
  * @param int $bankId
  * @param string $content
  * @return boolean 是否解析成功
  */
 public static function getMailDetail($mail, $bankId, $content, $emailBasicInfo = array())
 {
     $filename = "{$mail}.{$bankId}." . ParseUtil::microtimeFloat() . '.html';
     $dir = EcConfig::$zhangdanPath . date('Ymd') . '/';
     if (!file_exists($dir)) {
         mkdir($dir);
     }
     file_put_contents($dir . $filename, $content);
     //抓取的文件内容同步到云盘并将url写入zhangdan表(风控系统访问)
     $fileExtension = 'html';
     $mimeType = 'text/html';
     $yunStorageModel = new YunStorageDocFile('loan');
     $html_url = $yunStorageModel->uploadDoc($content, $fileExtension, $mimeType, $remark = '');
     $emailBasicInfo['html_url'] = $html_url;
     //		$path_url = $yunStorageModel->getDocFileAbsPath($html_name);
     //		$html_url = $yunStorageModel->createLoanDocUrl($html_name);
     Yii::log($dir . $filename, CLogger::LEVEL_INFO);
     //检查是否支持该银行的解析
     if (!isset(EcConfig::$BANK_PARSE_CONFIG[$bankId])) {
         Yii::log('Did not support this bank.bank_id=' . $bankId, CLogger::LEVEL_WARNING);
         return false;
     }
     $className = EcConfig::$BANK_PARSE_CONFIG[$bankId];
     if (!class_exists($className)) {
         Yii::log('Class not exist.bank_id=' . $bankId, CLogger::LEVEL_WARNING);
         return false;
     }
     $billModel = new $className($mail, $bankId);
     $billModel->setEmailBasicInfo($emailBasicInfo);
     $ret = $billModel->parse($content);
     return $ret;
 }
示例#9
0
 public function parse($content)
 {
     $info = array();
     $s = str_replace('&nbsp;', ' ', $content);
     $s = str_replace('</td>', ' # ', $s);
     $s = strip_tags($s);
     $s = preg_replace('/\\s+/', ' ', $s);
     $s = preg_replace('/(#\\s)+/', '# ', $s);
     //        file_put_contents('/home/rong/tmp/jianshe.' .time() . '.' . rand(0,100) . '.txt', $s);
     //        var_dump($s);
     //        exit;
     #用户信息
     $zh = '[\\x{4e00}-\\x{9fa5}]+';
     $p = "/尊敬的({$zh})?,/u";
     $r = $this->pregMatchAll($p, $s, $out);
     //        print_r($out);
     //        exit;
     $fullCardNo = '\\d{4,}\\*{2,8}\\d{4,}';
     preg_match_all("/{$fullCardNo}/", $s, $match);
     //2015/06/25 added by wanghuafeng 多卡解析,合并多卡卡号
     $card_num_arr = array();
     $unique_cards_arr = array_unique($match[0]);
     foreach ($unique_cards_arr as $val) {
         $card_num_arr[] = substr($val, -4);
     }
     $all_card_no_str = implode(',', array_unique($card_num_arr));
     $cards_count = count($card_num_arr);
     //        print_r($all_card_no_str);
     if ($r) {
         $info['name'] = $out[1][0];
         $info['sex'] = @$out[2][0];
     }
     $lastPaymentPattern = '/金额人民币: ([0-9,]+\\.\\d{2})/';
     $lpMatched = preg_match($lastPaymentPattern, $s, $lastPaymentMatch);
     if ($lpMatched) {
         $info['last_payment'] = ParseUtil::formatMoney($lastPaymentMatch[1]);
     } else {
         $info['last_payment'] = 0;
     }
     //        print_r($info);
     //        exit;
     #账户基本信息
     #$p = '/账单周期.*?(\d\S+).*?Date # ([\d\-\/]+).*?Date # ([\d\-\/]+).*?Limit # [A-Z]*\s*([\d,]+).*?Limit # [A-Z]*\s*([\d,]+).*?Points # ([\d,]+).*?(CNY) # ([\d\.,]+) # ([\d\.,]+)/';
     $circleDate = '\\d{4}年\\d{2}月\\d{2}日';
     $date = '\\d{4}\\-\\d{2}\\-\\d{2}';
     $money = '[CNY\\-\\d\\., ]+';
     $num = '[\\d,]+';
     #$p = "/Statement Date # (\d+) #[^#]*# ($date) #[^#]*# ($money) #[^#]*# ($money) #[^#]*# RMB:($money)[^#]*#[^#]*# RMB:($money)/";
     $p = "/({$circleDate})\\-({$circleDate}) #[^#]*#[^#]*# ({$date}) #[^#]*# ({$date}|已逾期) #[^#]*# ({$money}) #[^#]*# ({$money}) #[^#]*# ({$num})/";
     $r = $this->pregMatchAll($p, $s, $out);
     //        print_r($out);
     //        exit;
     if ($r) {
         $info['statement_start_date'] = ParseUtil::formatDate(trim($out[1][0]));
         $info['statement_end_date'] = ParseUtil::formatDate(trim($out[2][0]));
         $info['payment_cur_date'] = strtotime(trim($out[3][0]));
         $info['payment_due_date'] = strtotime(trim($out[4][0]));
         $info['credit_limit'] = ParseUtil::formatMoney($out[5][0]);
         $info['cash_advance_limit'] = ParseUtil::formatMoney($out[6][0]);
         #积分余额
         $info['total_points'] = ParseUtil::formatNum($out[7][0]);
     }
     $p = "/Dispute Amt\\/Nbr #[^#]*# ({$money}) # ({$money})/";
     //        print_r($s);
     $r = $this->pregMatchAll($p, $s, $out);
     //        print_r($out);
     //        exit;
     if ($r) {
         $info['new_balance'] = ParseUtil::formatMoney($out[1][0]);
         $info['min_payment'] = ParseUtil::formatMoney($out[2][0]);
         if (preg_match_all("/美元(USD) # ({$money}) # ({$money}) #/", $s, $match)) {
             $info['new_balance_usd'] = ParseUtil::formatMoney($match[1][0]);
             $info['min_payment_usd'] = ParseUtil::formatMoney($match[2][0]);
         }
     }
     #账户还款计算明细
     $p = "/上期账单余额\\(Previous Balance\\) # ({$money}) # (.*?)\\*\\*\\* 结束/";
     $r = $this->pregMatchAll($p, $s, $out);
     //        print_r($out);
     //        exit;
     $info['last_balance'] = ParseUtil::formatMoney($out[1][0]);
     $d = $out[2][0];
     #详细交易信息
     $date = '\\d{4}\\-\\d{2}\\-\\d{2}';
     $p = "/({$date}) # ({$date}) # (\\d{4}) # ([^#].*?) # ([A-Z]*) # ([-\\d\\.,]+) #/";
     $details = array();
     $r = $this->pregMatchAll($p, $d, $out);
     if ($r) {
         for ($i = 0; $i < count($out[0]); $i++) {
             $one['trans_date'] = intval(strtotime($out[1][$i]));
             $one['post_date'] = intval(strtotime($out[2][$i]));
             $one['card_no'] = $out[3][0];
             $one['description'] = $out[4][$i];
             # $one['currency'] = ParseUtil::getCurrencyType($out [5] [$i]);
             $one['rmb_amount'] = ParseUtil::formatMoney($out[6][$i]);
             #$one['trans_area'] = $out[6][0];
             #$one['orign_amount'] = format_money($out[7][0]);
             $one['type'] = ParseUtil::getConsumeType($one['description']);
             //TODO 消费分类
             $one['is_doubt'] = ParseUtil::isDoubtComsume($one['description']);
             // 可疑消费分析
             $details[$one['card_no']][] = ParseUtil::trimArr($one);
         }
     }
     #积分明细
     $p = '/Total Points #[^#]*(\\d{4}) # ([\\d\\.,]+) # ([\\d\\.,]+) # ([\\d\\.,]+) # ([\\d\\.,]+) # ([\\d\\.,]+) # ([\\d\\.,]+) #/';
     $r = $this->pregMatchAll($p, $s, $out);
     if ($r) {
         $info['total_points'] = ParseUtil::formatNum($out[7][0]);
         $info['last_points'] = ParseUtil::formatNum($out[2][0]);
         $info['earned_points'] = ParseUtil::formatNum($out[3][0]);
         $info['rewarded_points'] = ParseUtil::formatNum($out[4][0]);
         $info['adjusted_points'] = ParseUtil::formatNum($out[5][0]);
         $info['redeemed_points'] = ParseUtil::formatNum($out[6][0]);
         $info = ParseUtil::trimArr($info);
     }
     if (empty($details)) {
         return $this->insert($info);
     }
     //区分不同的卡
     foreach ($details as $cardNo => $detail) {
         $oneCardInfo = $info;
         $oneCardInfo['card_no'] = $all_card_no_str;
         $oneCardInfo['trans_detail'] = json_encode($detail);
         //            $this->insert($oneCardInfo);
     }
     print_r($oneCardInfo);
     return true;
 }
示例#10
0
 /**
  * 解析2013年5月份之后的账单
  * @param array $card
  * @param array $info
  */
 public function parseNewBill($s, array &$cards, array &$info)
 {
     $money = '[\\-\\d\\.,]+';
     $date = '\\d{2}\\/\\d{2}';
     //		$p = "/RMB\/USD Account[ #]+RMB ($money) # RMB ($money) # (\d+).* New Balance[ #]+$money [^\d]+ ($money) [^\d]+ ($money) [^\d]+ ($money) [^\d]+ ($money) [^\d]+ ($money) [^\d]+/";
     $p = "/本期最低还款额 Min\\.Payment.*?({$money}).*?本期应还款金额.*?({$money}).*?上期账单金额.*?({$money}).*?本期已还金额.*?({$money}).*?本期账单金额.*?({$money}).*?本期调整金额.*?({$money}).*?循环利息.*?({$money})/";
     $r = $this->pregMatchAll($p, $s, $out);
     if ($r) {
         //TODO $out[3][0] 为Balance B/F 对应数据库字段last_balance
         //            print_r($out);
         //            exit;
         $card['balance']['人民币']['new_balance'] = ParseUtil::formatMoney($out[2][0]);
         //New Balance
         $card['balance']['人民币']['min_payment'] = ParseUtil::formatMoney($out[1][0]);
         //Min.Payment
         $card['balance']['人民币']['last_balance'] = ParseUtil::formatMoney($out[3][0]);
         //Balance B/F
         $card['balance']['人民币']['last_payment'] = ParseUtil::formatMoney($out[4][0]);
         //Payment
         $card['balance']['人民币']['new_charges'] = ParseUtil::formatMoney($out[5][0]);
         //New Carges
         $card['balance']['人民币']['adjustment'] = ParseUtil::formatMoney($out[6][0]);
         //Adjustment
         $card['balance']['人民币']['interest'] = ParseUtil::formatMoney($out[7][0]);
         //循环利息
         //            print_r($card['balance']['人民币']);
         //            exit;
     }
     // 细交易信息(人民币)
     //		$p = '/CARD No\.\(last 4 digits\)(.*?)本账户积分明细/';
     $p = '/交易日(.*?)本账户积分明细/';
     $r = $this->pregMatchAll($p, $s, $out);
     $d = $out[1][0];
     $p = "/({$date}) # ({$date}) # (.*?) # ({$money}) # (\\d{4}) #/";
     $r = $this->pregMatchAll($p, $d, $out);
     for ($j = 0; $j < count($out[1]); $j++) {
         $one['trans_date'] = ParseUtil::formatDate($out[1][$j], $info['statement_end_date']);
         $one['post_date'] = ParseUtil::formatDate($out[2][$j], $info['statement_end_date']);
         $one['description'] = $out[3][$j];
         $one['rmb_amount'] = ParseUtil::formatMoney($out[4][$j]);
         $one['card_no'] = $out[5][$j];
         $one['currency'] = ParseUtil::getCurrencyType($out[4][$j]);
         $one['type'] = ParseUtil::getConsumeType($one['description']);
         // 消费分类
         $one['is_doubt'] = ParseUtil::isDoubtComsume($one['description']);
         // 可疑消费分析
         $trades[] = $one;
         $info['card_no'] = $one['card_no'];
     }
     #积分明细(信用卡积分,分行特色信用卡积分,联名积分1,联名积分2)
     #bug-fix by shupan at 20131212 17:04
     //		$p = '/EndingBalance # (\d+)[^\d]*(\d+)[^\d]*(\d+)[^\d]*(\d+)[^\d]*(\d+)[^\d]*(\d+)[^\d]*(\d+)/';
     $num = '\\d+';
     $p = "/累计积分余额 [^\\d]* ({$num}) [^\\d]* ({$num}) [^\\d]* ({$num}) [^\\d]* ({$num}) [^\\d]* ({$num}) [^\\d]* ({$num})/";
     $r = $this->pregMatchAll($p, $s, $out);
     if ($r) {
         $point['total_points'] = ParseUtil::formatNum($out[1][0]);
         $point['earned_points'] = ParseUtil::formatNum($out[4][0]);
         $point['adjusted_points'] = ParseUtil::formatNum($out[5][0]);
         $point['rewarded_points'] = ParseUtil::formatNum($out[6][0]);
         $point['last_points'] = ParseUtil::formatNum($out[2][0]);
         $point['redeemed_points'] = ParseUtil::formatNum($out[3][0]);
     }
     $card['trades'] = $trades;
     $card['points'] = $point;
     $cards[$info['card_no']] = $card;
 }
示例#11
0
 public function parse($content)
 {
     $info = array();
     $s = str_replace('&nbsp;', ' ', $content);
     $s = str_replace('#', '', $s);
     $s = str_replace('</td>', ' # ', $s);
     $s = strip_tags($s);
     $s = preg_replace('/\\s+/', ' ', $s);
     //        var_dump($s);
     //        exit;
     // 		file_put_contents('/home/rong/tmp/guangfa.' . date('Ymd.His') . '.' . rand(0,100) . '.txt', $s);
     #用户信息
     $zh = '[\\x{4e00}-\\x{9fa5}]+';
     $p = "/尊敬的\\s*?({$zh})\\s*?(女士|先生)/u";
     $r = $this->pregMatchAll($p, $s, $out);
     //        print_r($out);
     //        exit;
     if ($r) {
         $info['name'] = $out[1][0];
         $info['sex'] = $out[2][0];
     } elseif ($this->pregMatchAll("/尊敬的\\s*?({$zh}).*?(女士|先生)/u", $s, $out)) {
         $info['name'] = $out[1][0];
         $info['sex'] = $out[2][0];
     }
     //        print_r($info);
     //        exit;
     $money = '[¥$\\$\\d\\-\\., ]+';
     $date = '\\d{4}\\/\\d{2}\\/\\d{2}';
     $fullCardNo = '\\d{4}\\*{8}\\d{4}';
     preg_match_all("/{$fullCardNo}/", $s, $match);
     //TODO 多卡解析,合并多卡卡号
     //        print_r(array_unique($match[0]));
     //筛选出所有的卡号
     $card_num_arr = array();
     $unique_cards_arr = array_unique($match[0]);
     foreach ($unique_cards_arr as $val) {
         $card_num_arr[] = substr($val, -4);
     }
     $all_card_no_str = implode(',', array_unique($card_num_arr));
     $cards_count = count($card_num_arr);
     // 该详情页含有的信用卡的数量
     //        var_dump($all_card_no_str);
     //        exit;
     /**
      * (2011年11月账单)账单周期Statement cycle # 2011/11/02-2011/12/01 # 综合信用额度Total Credit Limit # 10,000.00 #
      * (2013年10月账单)账单周期 Statement Cycle # 2013/10/04-2013/11/03 # # # # # 综合信用额度 Total Credit Limit # 13,000
      * bug-fix by shupan at 2013-11-09 14:36
      */
     $p = "/Statement ?[Cc]ycle # ({$date})[\\- ]+({$date}) .*?Total Credit Limit # ({$money})/";
     $r = preg_match_all($p, $s, $out);
     if (!$r) {
         //2013年部分账单(5月),账单周期和综合信用额度用的是图片,太坑爹啦
         $p = "/({$date})[\\- ]+({$date}) [ #]+ ({$money})/";
         $r = $this->pregMatchAll($p, $s, $out);
     }
     if ($r) {
         $info['statement_start_date'] = ParseUtil::formatDate($out[1][0]);
         $info['statement_end_date'] = ParseUtil::formatDate($out[2][0]);
         //            var_dump($info ['statement_end_date']);
         //            exit;
         $info['payment_cur_date'] = $info['statement_end_date'];
         $info["credit_limit"] = ParseUtil::formatMoney($out[3][0]);
     }
     $cards = array();
     $p = '/卡号 Card Number # (\\S+) [ #]+ 本期应还总额 New Balance # (\\S+) [ #]+ 本期最低还款额 Min Payment # (\\S+) [ #]+ 还款到期日 Payment Due Date # (\\S+) [ #]+ 清算货币 Currency # (\\S+) [ #]+ 信用额(元) Credit Limit # (\\S+)/';
     // 		$p = '/卡号 Card Number # (\S+) [ #]+ 本期应还总额 New Balance # (\S+) [ #]+ 本期最低还款额 Min Payment # (\S+) [ #]+ 还款到期日 Payment Due Date # (\S+)/';
     //		$r = $this->pregMatchAll($p, $s, $out);
     $r = preg_match_all($p, $s, $out);
     //        print_r($out);
     //        exit;
     if (!$r) {
         //bug-fix by shupan at 2013-11-09 14:36, 支持2011年旧账单
         //          $p = "/信用额[(\(]元[)\)] ?Credit Limit [ #]* ($fullCardNo) # ($money) # ($money) # ($date) # ([^#]*) # ($money)/";
         $p = "/信用额.*?元.*?Credit Limit [ #]* ({$fullCardNo}) # ({$money}) # ({$money}) # ({$date}) # ([^#]*) # ({$money})/";
         $r = preg_match_all($p, $s, $out);
         //            print_r($out);
         //            exit;
     }
     if (!$r) {
         //2013年部分账单(5月),信用卡基本信息都是用的是图片
         $p = "/({$fullCardNo}) [ #]+ ({$money}) [ #]+ ({$money}) [ #]+ ({$date}) [ #]+ ([^#]*) [ #]+ ({$money})/";
         $r = $this->pregMatchAll($p, $s, $out);
         //            print_r($out);
         //            exit;
     }
     if ($r) {
         if (count($out[1]) > 1) {
             //TODO 多卡问题,new_balance等信息解析
             $new_balance = 0;
             foreach ($out[2] as $val) {
                 $new_balance += ParseUtil::formatMoney($val);
             }
             $card['new_balance'] = $new_balance;
             //                var_dump($new_balance);
             $min_payment = 0;
             foreach ($out[3] as $val) {
                 $min_payment += ParseUtil::formatMoney($val);
             }
             $card['min_payment'] = $min_payment;
             //                var_dump($min_payment);
             $payment_due_date = 0;
             foreach ($out[4] as $val) {
                 $payment_due_date = ParseUtil::formatDate($val);
             }
             $card['payment_due_date'] = $payment_due_date;
             //                var_dump($payment_due_date);
             $credit_limit_arr = array();
             foreach ($out[6] as $val) {
                 $credit_limit_arr[] = ParseUtil::formatMoney($val);
             }
             $card['credit_limit'] = max($credit_limit_arr);
             //取最大额作为其信用额度
             //                var_dump($card['credit_limit']);
             $currency = $out[5][0];
             //暂时按统一币种处理
             $card_key = $unique_cards_arr[0];
             $cards[$card_key]['balance'][$currency] = $card;
             //                print_r($cards);
         } else {
             //单卡问题
             for ($i = 0; $i < count($out[1]); $i++) {
                 $card['new_balance'] = ParseUtil::formatMoney($out[2][$i]);
                 $card['min_payment'] = ParseUtil::formatMoney($out[3][$i]);
                 $card['payment_due_date'] = ParseUtil::formatDate($out[4][$i]);
                 $card["credit_limit"] = ParseUtil::formatMoney($out[6][$i]);
                 $currency = $out[5][$i];
                 $card_key = $out[1][$i];
                 $cards[$card_key]['balance'][$currency] = $card;
             }
         }
     }
     //        print_r($out);
     //        exit;
     #获取各张卡的交易信息
     $transDate = '\\d{8}';
     $p = "/卡号.*?({$fullCardNo}) [ #]+ {$transDate} # {$transDate} (.*?) # 合计/";
     $r = preg_match_all($p, $s, $out);
     //        print_r($out);
     //        exit;
     //        $money = '([0-9,-]+\.\d{2})';   // TODO 金额包含正负号
     if (!$r) {
         //            $transDate = '\d{2}\/\d{2}';
         $p = "/交易明细 [ #]+ (.*?) # 合计/";
         $r = $this->pregMatchAll($p, $s, $out);
         //            print_r($out);
         //            exit;
         if ($r) {
             $transDate = '\\d{4}-?\\d{2}-?\\d{2}';
             $transContent = $out[1][0];
             print_r($transContent);
             $p = "/({$transDate}|\\s?) # ({$transDate}|\\s?)\\s?# (.*?) # {$money} # (人民币) # {$money}/";
             $transDetailMatched = $this->pregMatchAll($p, $transContent, $transDetailMatch);
             //                print_r($transDetailMatch);
             //                exit;
             if ($transDetailMatched) {
                 for ($rnum = 0; $rnum < count($transDetailMatch[0]); $rnum++) {
                     if (!trim($transDetailMatch[1][$rnum])) {
                         $trade['trans_date'] = $info['statement_end_date'];
                         $trade['post_date'] = $info['statement_end_date'];
                     } else {
                         $trade['trans_date'] = ParseUtil::formatDate($transDetailMatch[1][$rnum], $info['statement_end_date']);
                         $trade['post_date'] = ParseUtil::formatDate($transDetailMatch[2][$rnum], $info['statement_end_date']);
                     }
                     $trade['description'] = str_replace('#', '', $transDetailMatch[3][$rnum]);
                     $trade['rmb_amount'] = ParseUtil::formatMoney($transDetailMatch[4][$rnum]);
                     if ($trade['rmb_amount'] == '0.0') {
                         $trade['rmb_amount'] = ParseUtil::formatMoney('-' . $transDetailMatch[5][$rnum]);
                     }
                     $trade['currency'] = ParseUtil::getCurrencyType($transDetailMatch[6][$rnum]);
                     $trade['type'] = ParseUtil::getConsumeType($trade['description']);
                     //消费分类
                     $trade['is_doubt'] = ParseUtil::isDoubtComsume($trade['description']);
                     //可疑消费分析
                     $trades[] = $trade;
                 }
             }
             //                print_r($trades);
             //                print_r($cards);
             //                exit;
             foreach ($cards as $key => $val) {
                 //                    $card_key = substr($key, -4);
                 $card_key = $key;
                 $cards[$card_key]['trades'] = $trades;
             }
             //                print_r($cards[$card_key]['trades']);
             //                exit;
         }
     }
     if ($r) {
         $card_num = count($out[0]);
         for ($cnum = 0; $cnum < $card_num; $cnum++) {
             $card_key = $out[1][$cnum];
             //                print_r($card_key);
             //                print_r($cards);
             if ($cards_count < 2) {
                 if (array_key_exists($card_key, $cards)) {
                     $p = "/({$transDate}|\\s)[\\s]?#[\\s]?({$transDate}|\\s+)[\\s]?# ([^#]*?) # (\\S+) # (人民币) # (\\S+) #/";
                     $r = $this->pregMatchAll($p, $out[0][$cnum], $out_tmp);
                     //                    print_r($out_tmp);
                     //                    exit;
                     if ($r) {
                         for ($rnum = 0; $rnum < count($out_tmp[0]); $rnum++) {
                             if (!trim($out_tmp[1][$rnum])) {
                                 $trade['trans_date'] = $info['statement_end_date'];
                                 $trade['post_date'] = $info['statement_end_date'];
                             } else {
                                 $trade['trans_date'] = ParseUtil::formatDate($out_tmp[1][$rnum], $info['statement_end_date']);
                                 $trade['post_date'] = ParseUtil::formatDate($out_tmp[2][$rnum], $info['statement_end_date']);
                             }
                             $trade['description'] = $out_tmp[3][$rnum];
                             $trade['rmb_amount'] = ParseUtil::formatMoney($out_tmp[4][$rnum]);
                             if ($trade['rmb_amount'] == '0.0') {
                                 $trade['rmb_amount'] = ParseUtil::formatMoney('-' . $out_tmp[5][$rnum]);
                             }
                             $trade['currency'] = ParseUtil::getCurrencyType($out_tmp[6][$rnum]);
                             $trade['type'] = ParseUtil::getConsumeType($trade['description']);
                             //消费分类
                             $trade['is_doubt'] = ParseUtil::isDoubtComsume($trade['description']);
                             //可疑消费分析
                             $trades[] = $trade;
                         }
                     }
                     $cards[$card_key]['trades'] = $trades;
                     //                    var_dump($cards[$card_key]['trades']);
                     //                    exit;
                 }
             } else {
                 $p = "/({$transDate}|\\s)[\\s]?#[\\s]?({$transDate}|\\s+)[\\s]?# ([^#]*?) # (\\S+) # (人民币) # (\\S+) #/";
                 $r = $this->pregMatchAll($p, $out[0][$cnum], $out_tmp);
                 //                    print_r($out_tmp);
                 //                    exit;
                 if ($r) {
                     for ($rnum = 0; $rnum < count($out_tmp[0]); $rnum++) {
                         if (!trim($out_tmp[1][$rnum])) {
                             $trade['trans_date'] = $info['statement_end_date'];
                             $trade['post_date'] = $info['statement_end_date'];
                         } else {
                             $trade['trans_date'] = ParseUtil::formatDate($out_tmp[1][$rnum], $info['statement_end_date']);
                             $trade['post_date'] = ParseUtil::formatDate($out_tmp[2][$rnum], $info['statement_end_date']);
                         }
                         $trade['description'] = $out_tmp[3][$rnum];
                         $trade['rmb_amount'] = ParseUtil::formatMoney($out_tmp[4][$rnum]);
                         if ($trade['rmb_amount'] == '0.0') {
                             $trade['rmb_amount'] = ParseUtil::formatMoney('-' . $out_tmp[5][$rnum]);
                         }
                         $trade['currency'] = ParseUtil::getCurrencyType($out_tmp[6][$rnum]);
                         $trade['type'] = ParseUtil::getConsumeType($trade['description']);
                         //消费分类
                         $trade['is_doubt'] = ParseUtil::isDoubtComsume($trade['description']);
                         //可疑消费分析
                         $trades[] = $trade;
                     }
                 }
                 $cards[$card_key]['trades'] = $trades;
                 //                    var_dump($cards[$card_key]['trades']);
                 //                    exit;
             }
         }
     }
     //        print_r($cards);
     //        exit;
     #解析本期应还总额情况
     #added by xudongbo 20150505
     $p = "/# 人民币 # ({$money}) # # ({$money}) # # ({$money}) # # ({$money})[ #]* 积分按卡号汇总情/";
     $r = $this->pregMatchAll($p, $s, $out);
     //        print_r($out);
     //        print_r($s);
     //        exit;
     if (!$r) {
         # 人民币 # 7,136.96 # # 4,878.48 # # 7,139.00 # # 4,876.44 # # # # # # # # # # # # # # # # 分期付款明细
         $p = "/# 人民币 # ({$money}) # # ({$money}) # # ({$money}) # # ({$money})[ #]* 分期付款明细/";
         $r = $this->pregMatchAll($p, $s, $out);
         //            print_r($out);
         //            exit;
         if ($r) {
             for ($i = 0; $i < count($out[1]); $i++) {
                 $info['last_balance'] = ParseUtil::formatMoney($out[1][$i]);
                 $info['new_charges'] = ParseUtil::formatMoney($out[2][$i]);
                 $info['last_payment'] = ParseUtil::formatMoney($out[3][$i]);
             }
         }
     } else {
         //字段修改字段对应数据
         for ($i = 0; $i < count($out[1]); $i++) {
             $info['last_balance'] = ParseUtil::formatMoney($out[1][$i]);
             $info['new_charges'] = ParseUtil::formatMoney($out[2][$i]);
             $info['last_payment'] = ParseUtil::formatMoney($out[3][$i]);
         }
     }
     if ($cards_count > 1) {
         // TODO 多卡问题
         //            print_r($s);
         $p = "/\\d{4} # 人民币 # ({$money}) # # ({$money}) # # ({$money}) # # ({$money})/";
         $r = $this->pregMatchAll($p, $s, $match);
         print_r($match);
         $last_balance = 0;
         foreach ($match[1] as $val) {
             $last_balance += ParseUtil::formatMoney($val);
         }
         $info['last_balance'] = $last_balance;
         //Opening Balance
         $new_charges = 0;
         foreach ($match[2] as $val) {
             $new_charges += ParseUtil::formatMoney($val);
         }
         $info['new_charges'] = $new_charges;
         //Total Debits
         $last_payment = 0;
         foreach ($match[3] as $val) {
             $last_payment += ParseUtil::formatMoney($val);
             //Total Credits
         }
         $info['last_payment'] = $last_payment;
         //            print_r($info);
         //            exit;
     }
     #获取积分信息
     $p = '/本期扣减.*?本期余额 ?Current Balance [ #]+ (.*?) [◆|【]/';
     $r = $this->pregMatchAll($p, $s, $out);
     $num = '[\\d,\\-]*';
     if ($r) {
         $p = "/(\\S+) # (\\S+) # ({$num}) [ #]* ({$num}) [ #]* ({$num}) [ #]* ({$num})/";
         $r = $this->pregMatchAll($p, $out[1][0], $out_tmp);
         for ($jfnum = 0; $jfnum < count($out_tmp[0]); $jfnum++) {
             $card_key = $out_tmp[1][$jfnum];
             if (array_key_exists($card_key, $cards)) {
                 // 					$jf['type'] = $out_tmp[2][$jfnum];
                 $jf['last_points'] = ParseUtil::formatNum($out_tmp[3][$jfnum]);
                 $jf['earned_points'] = ParseUtil::formatNum($out_tmp[4][$jfnum]);
                 $jf['redeemed_points'] = ParseUtil::formatNum($out_tmp[5][$jfnum]);
                 $jf['total_points'] = ParseUtil::formatNum($out_tmp[6][$jfnum]);
             }
             //                print_r($jf);
             //                exit;
             $cards[$card_key]['points'] = $jf;
         }
     }
     if (empty($cards)) {
         return $this->insert($info);
     }
     //多卡问题
     //        print_r($cards);
     //        exit;
     if ($cards_count > 1) {
         $combine_cards_info = array();
         foreach ($cards as $key => $detail) {
             $oneCardInfo = $info;
             //            print_r($info);
             //            print_r($cards);
             //            var_dump($detail);
             //            exit;
             //            $oneCardInfo['card_no'] = substr($key, -4);     //TODO 多卡问题
             $oneCardInfo['card_no'] = $all_card_no_str;
             //            print_r($oneCardInfo['card_no']);
             //            exit;
             if (isset($detail['trades'])) {
                 $oneCardInfo['trans_detail'] = json_encode($detail['trades']);
             }
             if (is_array($detail['balance']['人民币'])) {
                 $oneCardInfo = array_merge($oneCardInfo, $detail['balance']['人民币']);
             }
             if (isset($detail['balance']['美元'])) {
                 $oneCardInfo['credit_limit_usd'] = $detail['balance']['美元']['credit_limit'];
                 $oneCardInfo['new_balance_usd'] = $detail['balance']['美元']['new_balance'];
                 $oneCardInfo['min_payment_usd'] = $detail['balance']['美元']['min_payment'];
             }
             if (is_array($detail['points'])) {
                 $oneCardInfo = array_merge($oneCardInfo, $detail['points']);
             }
             $combine_cards_info = array_merge($combine_cards_info, $oneCardInfo);
             //            print_r($oneCardInfo);
             //            exit;
             //            $this->insert($oneCardInfo);
         }
         print_r($combine_cards_info);
         exit;
         return true;
     } else {
         foreach ($cards as $key => $detail) {
             $oneCardInfo = $info;
             //            $oneCardInfo['card_no'] = substr($key, -4);     //TODO 多卡问题
             $oneCardInfo['card_no'] = $all_card_no_str;
             //            print_r($oneCardInfo['card_no']);
             //            exit;
             if (isset($detail['trades'])) {
                 $oneCardInfo['trans_detail'] = json_encode($detail['trades']);
             }
             if (is_array($detail['balance']['人民币'])) {
                 $oneCardInfo = array_merge($oneCardInfo, $detail['balance']['人民币']);
             }
             if (isset($detail['balance']['美元'])) {
                 $oneCardInfo['credit_limit_usd'] = $detail['balance']['美元']['credit_limit'];
                 $oneCardInfo['new_balance_usd'] = $detail['balance']['美元']['new_balance'];
                 $oneCardInfo['min_payment_usd'] = $detail['balance']['美元']['min_payment'];
             }
             if (is_array($detail['points'])) {
                 $oneCardInfo = array_merge($oneCardInfo, $detail['points']);
             }
             print_r($oneCardInfo);
             //            $this->insert($oneCardInfo);
         }
         return true;
     }
 }
示例#12
0
 public function OldBillParse($s, array &$info, array &$details)
 {
     #账户基本信息
     #额度基本信息(人民币)
     $money = '[\\-\\d\\.,]+';
     $date = '\\d{4}\\-\\d{2}\\-\\d{2}';
     $p = "/信用额度 # RMB ({$money}) # 取现额度 # RMB ({$money}) # 本期账单日 # ({$date}) # 本期应还金额 # RMB ({$money}) # 本期还款日 # ({$date}) # 本期最低还款额 # RMB ({$money})/";
     $r = preg_match_all($p, $s, $out);
     //        print_r($out);
     //        exit;
     if ($r) {
         $info['credit_limit'] = ParseUtil::formatMoney($out[1][0]);
         $info['cash_advance_limit'] = ParseUtil::formatMoney($out[2][0]);
         $info['payment_cur_date'] = ParseUtil::formatDate($out[3][0]);
         $info['payment_due_date'] = ParseUtil::formatDate($out[5][0]);
         $info['statement_end_date'] = $info['payment_cur_date'];
         $info['statement_start_date'] = strtotime('last month', $info['payment_cur_date']);
         $info['new_balance'] = ParseUtil::formatMoney($out[4][0]);
         $info['min_payment'] = ParseUtil::formatMoney($out[6][0]);
     } else {
         //bug-fix by shupan at 2013-11-09 19:09
         $p = "/信用额度 [^#]*# RMB ({$money}) # 取现额度 [^#]*# RMB ({$money}) # 账单日 [^#]*# ({$date}) # 到期还款日 [^#]*# ({$date}) # 本期应还款金额 [^#]*# RMB ({$money}) # 最低还款金额 [^#]*# RMB ({$money})/";
         $r = $this->pregMatchAll($p, $s, $out);
         //            print_r($s);
         //            print_r($out);
         //            exit;
         if ($r) {
             $info['credit_limit'] = ParseUtil::formatMoney($out[1][0]);
             $info['cash_advance_limit'] = ParseUtil::formatMoney($out[2][0]);
             $info['payment_cur_date'] = ParseUtil::formatDate($out[3][0]);
             $info['payment_due_date'] = ParseUtil::formatDate($out[4][0]);
             $info['new_balance'] = ParseUtil::formatMoney($out[5][0]);
             $info['min_payment'] = ParseUtil::formatMoney($out[6][0]);
         }
     }
     if ($r) {
         //没有账单周期,自己算,当前账单日设为周期末尾一天
         $info['statement_end_date'] = $info['payment_cur_date'];
         $info['statement_start_date'] = strtotime('last month', $info['payment_cur_date']);
     }
     #账户还款计算明细(人民币)
     $p = "/上期账单金额 ?RMB ({$money}) # 上期还款金额 ?RMB ({$money}) # 本期账单金额 ?RMB ({$money}) # 本期调整金额 ?RMB ({$money}) # 循环利息 ?RMB ({$money})/";
     //		$r = $this->pregMatchAll($p, $s, $out);
     $r = preg_match_all($p, $s, $out);
     //        print_r($out);
     //        exit;
     if (!$r) {
         //bug-fix by shupan at 2013-11-09 19:09
         $p = "/上期账单金额 [^#]* # RMB ({$money}) [^#]* # [^#]* # RMB ({$money}) [^#]* # [^#]* # RMB ({$money}) [^#]* # [^#]* # RMB ({$money}) [^#]* # [^#]* # RMB ({$money})/";
         $r = $this->pregMatchAll($p, $s, $out);
         //            print_r($s);
         //            print_r($out);
         //            exit;
     }
     //        print_r($out);
     //        exit;
     if ($r) {
         $info['last_balance'] = ParseUtil::formatMoney($out[1][0]);
         $info['last_payment'] = ParseUtil::formatMoney($out[2][0]);
         $info['new_charges'] = ParseUtil::formatMoney($out[3][0]);
         $info['adjustment'] = ParseUtil::formatMoney($out[4][0]);
         $info['interest'] = ParseUtil::formatMoney($out[5][0]);
     }
     //TODO美元
     #详细交易信息
     //		$p = '/人民币金额 # (.*)用卡小贴士/';
     $p = '/交易日期 # (.*)/';
     $r = $this->pregMatchAll($p, $s, $out);
     if ($r) {
         $d = $out[1][0];
         $p = "/({$date}) # ({$date})( # (\\d{4}))? # ([^#]*) # [RMB ]*({$money})/";
         $r = $this->pregMatchAll($p, $d, $out);
         //            print_r($out);
         //            exit;
         if ($r) {
             //账单详细明细中可能没有卡号,那么随机分配一个,这种账单应该是一起还的(已和PM确认),
             $cards = array_unique($out[4], SORT_REGULAR);
             sort($cards);
             $defaultNo = array_pop($cards);
             for ($i = 0; $i < count($out[0]); $i++) {
                 $one['trans_date'] = ParseUtil::formatDate($out[1][$i], $info['statement_end_date']);
                 $one['post_date'] = ParseUtil::formatDate($out[2][$i], $info['statement_end_date']);
                 $one['card_no'] = empty($out[4][$i]) ? $defaultNo : $out[4][$i];
                 //                    $one['card_no'] = $defaultNo;
                 $one['description'] = $out[5][$i];
                 $one['rmb_amount'] = ParseUtil::formatMoney($out[6][$i]);
                 $one['currency'] = ParseUtil::getCurrencyType($out[6][$i]);
                 $one['type'] = ParseUtil::getConsumeType($one['description']);
                 //消费分类
                 $one['is_doubt'] = ParseUtil::isDoubtComsume($one['description']);
                 //可疑消费分析
                 $details[$one['card_no']][] = ParseUtil::trimArr($one);
                 unset($one);
             }
         }
         //            print_r($details);
         //            exit;
     }
     $info['card_no'] = $this->all_card_no_str;
     //        print_r($info);
     //        exit;
     #积分明细
     $num = '([\\d,]+)';
     $p = "/万里通积分.*?本期余额 # ({$num}) # 本期新增 # ({$num}) # 本期调整 # ({$num})/";
     $r = $this->pregMatchAll($p, $s, $out);
     if ($r) {
         $info['total_points'] = ParseUtil::formatNum($out[1][0]);
         $info['earned_points'] = ParseUtil::formatNum($out[2][0]);
         $info['adjusted_points'] = ParseUtil::formatNum($out[3][0]);
     }
 }
示例#13
0
 public function parse($content)
 {
     $info = array();
     $details = array();
     $s = str_replace('&nbsp;', ' ', $content);
     //        $s = str_replace('</td>', ' # ', $s);
     print_r(strtolower($s));
     exit;
     $s = strip_tags($s);
     $s = preg_replace('/\\s+/', ' ', $s);
     $s = preg_replace('/(#\\s)+/', '# ', $s);
     //		file_put_contents('/home/rong/tmp/jiaotong.' .time() . '.txt' , $s);
     #用户信息 没有区分先生和女士
     $zh = '[\\x{4e00}-\\x{9fa5}]+';
     $p = "/尊敬的\\s*({$zh})\\s*(女士|先生)/u";
     $r = $this->pregMatchAll($p, $s, $out);
     //        print_r($out);
     //        exit;
     if ($r) {
         $info['name'] = $out[1][0];
         $info['sex'] = $out[2][0];
     }
     //多卡问题
     $cardPattern = '/\\d+\\*+(\\d{4})/';
     preg_match_all($cardPattern, $s, $cardMatch);
     $card_num_arr = array();
     $unique_cards_arr = array_unique($cardMatch[1]);
     foreach ($unique_cards_arr as $val) {
         $card_num_arr[] = substr($val, -4);
     }
     $all_card_no_str = implode(',', array_unique($card_num_arr));
     $cards_count = count($card_num_arr);
     #bug-fix, by shupan, 2013-12-06 17:09。2011年x月之前账单,没有消费明细
     $date = '\\d{4}\\/\\d{2}\\/\\d{2}';
     $money = '[RMB¥$\\$\\d\\-\\., ]+';
     $dateOld = '[\\d\\-]{4}年[\\d\\-]{2}月[\\d\\-]{2}日';
     #eg:您尾号为1034的交通银行信用卡本期账单已于2010年12月24日生成,到期还款日为----年--月--日。
     $p = "/您尾号为(\\d{4})的交通银行信用卡本期账单已于({$dateOld})生成,到期还款日为({$dateOld}).*?Statement Balance # 人民币RMB # ({$money}) # 美元USD # ({$money}) # 本期最低还款额 Min.Payment Due # 人民币RMB # ({$money}) # 美元USD # ({$money}) # 本期积分余额 Available Points # 人民币账户RMB # ([\\d,]+)/";
     //这里不用打印日志
     $r = preg_match_all($p, $s, $out);
     //        print_r($s);
     //        exit;
     if ($r) {
         $info['card_no'] = $out[1][0];
         $info['payment_due_date'] = ParseUtil::formatDate($out[3][0]);
         $info['payment_cur_date'] = ParseUtil::formatDate($out[2][0]);
         $info['statement_end_date'] = $info['payment_cur_date'];
         $info['statement_start_date'] = strtotime('last month', $info['payment_cur_date']);
         $info['new_balance'] = ParseUtil::formatMoney($out[4][0]);
         $info['new_balance_usd'] = ParseUtil::formatMoney($out[5][0]);
         $info['min_payment'] = ParseUtil::formatMoney($out[6][0]);
         $info['min_payment_usd'] = ParseUtil::formatMoney($out[7][0]);
         $info['total_points'] = ParseUtil::formatNum($out[8][0]);
         $this->insert($info);
         return true;
     }
     #账户基本信息
     //		$money = '[\-\d\.,]+';
     #bug-fix, by shupan, 2013-12-06 17:09。2011年7月账单( Min.Payment Due # 人民币RMB 0.00 )
     #$p = "/Minimum Payment Due # 人民币RMB ($money) # 美元USD ($money) # 人民币RMB ($money) # 美元USD ($money)/";
     $p = "/Payment Due # 人民币RMB ({$money}) # 美元USD ({$money}) # 人民币RMB ({$money}) # 美元USD ({$money})/";
     $r = $this->pregMatchAll($p, $s, $out);
     //        print_r($out);
     //        exit;
     if ($r) {
         $info['available_balance'] = ParseUtil::formatMoney($out[1][0]);
         $info['available_balance_usd'] = ParseUtil::formatMoney($out[2][0]);
         $info['min_payment'] = ParseUtil::formatMoney($out[3][0]);
         $info['min_payment_usd'] = ParseUtil::formatMoney($out[4][0]);
     }
     #额度基本信息(人民币)
     #bug-fix, by shupan, 2013-12-06 15:38, 到期还款日可能为空
     $p = "/Statement Cycle # ({$date})-({$date})[^\\d]*?人民币 RMB ({$money})[^\\d]*?USD ({$money})[^\\d]*?Payment Due Day # ({$date})?[^\\d]*?人民币 RMB ({$money})[^\\d]*?USD ({$money})/";
     $r = $this->pregMatchAll($p, $s, $out);
     if (!$r) {
         $p = "/Statement Cycle # ({$date})- ({$date})[^\\d]*?人民币 RMB ({$money})[^\\d]*?USD ({$money})[^\\d]*?Payment Due Day # ({$date})?[^\\d]*?人民币 RMB ({$money})[^\\d]*?USD ({$money})/";
         $r = $this->pregMatchAll($p, $s, $out);
     }
     if ($r) {
         $info['statement_start_date'] = ParseUtil::formatDate($out[1][0]);
         $info['statement_end_date'] = ParseUtil::formatDate($out[2][0]);
         $info['payment_cur_date'] = $info['statement_end_date'];
         $info['credit_limit'] = ParseUtil::formatMoney($out[3][0]);
         $info['credit_limit_usd'] = ParseUtil::formatMoney($out[4][0]);
         $info['payment_due_date'] = ParseUtil::formatDate($out[5][0]);
         $info['cash_advance_limit'] = ParseUtil::formatMoney($out[6][0]);
         $info['cash_advance_limit_usd'] = ParseUtil::formatMoney($out[7][0]);
     } else {
         //TODO 交行新版本
         $info['card_no'] = $all_card_no_str;
         $statementDatePattern = "/账单周期:({$date})-({$date})/";
         $statementMatched = preg_match($statementDatePattern, $s, $statementMatch);
         //            print_r($statementMatch);
         //            exit;
         if ($statementMatched) {
             $info['statement_start_date'] = ParseUtil::formatDate($statementMatch[1]);
             //账单周期起始日
             $info['statement_end_date'] = ParseUtil::formatDate($statementMatch[2]);
             //账单周期结束日
             $paymentDueDatePattern = "/到期还款日 ({$date})/";
             preg_match($paymentDueDatePattern, $s, $paymentDueDateMatch);
             print_r($s);
             print_r($paymentDueDateMatch);
             exit;
             $info['payment_due_date'] = ParseUtil::formatDate($paymentDueDateMatch[1]);
             //账单到期还款日
             $info['payment_cur_date'] = $info['statement_end_date'];
         }
         $accountDetailPattern = "/本期应还款额 ({$money}) # ({$money}) # 最低还款额 ({$money}) # ({$money}) # 信用额度 ({$money}) # ({$money}) # 取现额度 ({$money}) # ({$money}) #/";
         $accountDetailMatched = preg_match($accountDetailPattern, $s, $accountDetailMatch);
         print_r($accountDetailMatch);
         exit;
         if ($accountDetailMatched) {
             $info['new_balance'] = ParseUtil::formatMoney($accountDetailMatch[1]);
             $info['new_balance_usd'] = ParseUtil::formatMoney($accountDetailMatch[2]);
             $info['min_payment'] = ParseUtil::formatMoney($accountDetailMatch[3]);
             $info['min_payment_usd'] = ParseUtil::formatMoney($accountDetailMatch[4]);
             $info['credit_limit'] = ParseUtil::formatMoney($accountDetailMatch[5]);
             $info['credit_limit_usd'] = ParseUtil::formatMoney($accountDetailMatch[6]);
             $info['cash_advance_limit'] = ParseUtil::formatMoney($accountDetailMatch[7]);
             $info['cash_advance_limit_usd'] = ParseUtil::formatMoney($accountDetailMatch[8]);
         }
         $balancePattern = "/人民币账户(?: RMB)? # ({$money}) # ({$money}) # ({$money}) # ({$money}) # 美元账户(?: USD)? # ({$money}) # ({$money}) # ({$money}) # ({$money})/";
         $balanceMatched = preg_match($balancePattern, $s, $balanceMatch);
         if ($balanceMatched) {
             $info['new_balance'] = ParseUtil::formatMoney($balanceMatch[1]);
             $info['last_balance'] = ParseUtil::formatMoney($balanceMatch[2]);
             $info['last_payment'] = ParseUtil::formatMoney($balanceMatch[3]);
             $info['new_charges'] = ParseUtil::formatMoney($balanceMatch[4]);
             $info['new_balance_usd'] = ParseUtil::formatMoney($balanceMatch[5]);
         }
         $pointPattern = '/本期积分说明.*人民币账户 # ([\\-\\d]+)/';
         $pointMatched = preg_match($pointPattern, $s, $pointMatch);
         if ($pointMatched) {
             $info['total_points'] = $pointMatch[1];
         }
         $transDetailPattern = "/({$date}) # ({$date}) # (.*?) # ({$money}) # ({$money})/";
         $transDetailMatched = preg_match_all($transDetailPattern, $s, $transDetailMatch);
         if ($transDetailMatched) {
             $card_no = '****';
             for ($i = 0; $i < count($transDetailMatch[0]); $i++) {
                 $one['trans_date'] = ParseUtil::formatDate($transDetailMatch[1][$i], $info['statement_end_date']);
                 $one['post_date'] = ParseUtil::formatDate($transDetailMatch[2][$i], $info['statement_end_date']);
                 $one['description'] = $transDetailMatch[3][$i];
                 $one['rmb_amount'] = ParseUtil::formatMoney($transDetailMatch[4][$i]) * -1;
                 $one['orign_amount'] = ParseUtil::formatMoney($transDetailMatch[5][$i]) * -1;
                 $details[$card_no][] = $one;
             }
         }
     }
     #账户还款计算明细(人民币)
     $p = "/advance\\/Charges # 人民币账户 RMB # ({$money}) # ({$money}) # ({$money}) # ({$money}) # 美 元账户 USD # ({$money}) # ({$money}) # ({$money}) # ({$money})/";
     $r = $this->pregMatchAll($p, $s, $out);
     if (!$r) {
         #	ret = array_merge($s, $out);
         #	Yii::log(print_r($s,1)."==========================jiaotong2====");
     }
     if ($r) {
         $info['new_balance'] = ParseUtil::formatMoney($out[1][0]);
         $info['last_balance'] = ParseUtil::formatMoney($out[2][0]);
         $info['last_payment'] = ParseUtil::formatMoney($out[3][0]);
         $info['new_charges'] = ParseUtil::formatMoney($out[4][0]);
         $info['new_balance_usd'] = ParseUtil::formatMoney($out[5][0]);
     }
     #详细交易信息 (还款、退货、返还明细)
     //        $details = array();
     #bug-fix, by shupan, 2013-12-06 15:27, 后面可能会出现(以下是您的消费、取现及其他费用明细)
     #$p = '/以下是您的还款、退货及费用返还明细.*?卡号末四位 (\d{4}) # (.*)以下是您的消费、取现及费用扣收明细/';
     $p = '/以下是您的还款、退货及费用返还明细.*?卡号末四位 (\\d{4}) # (.*?)(以下是您的消费|本期积分说明)/';
     $r = $this->pregMatchAll($p, $s, $out);
     //        print_r($out);
     //        exit;
     if ($r) {
         $card_no = $out[1][0];
         $d = $out[0][0];
         $p = "/({$date}) # ({$date}) # ([^#]*) # [A-Z]* # ({$money}) # [A-Z]* # ({$money})/";
         $r = $this->pregMatchAll($p, $d, $out);
         //            print_r($out);
         //            exit;
         for ($i = 0; $i < count($out[0]); $i++) {
             $one['trans_date'] = ParseUtil::formatDate($out[1][$i], $info['statement_end_date']);
             $one['post_date'] = ParseUtil::formatDate($out[2][$i], $info['statement_end_date']);
             $one['description'] = $out[3][$i];
             $one['rmb_amount'] = ParseUtil::formatMoney($out[4][$i]);
             #$one['card_no'] = $card_no;
             $one['orign_amount'] = ParseUtil::formatMoney($out[5][$i]);
             $details[$card_no][] = ParseUtil::trimArr($one);
             //                print_r($card_no);
             //                exit;
             unset($one);
         }
         //            print_r($details[$card_no]);
         //            exit;
     }
     #详细交易信息 (消费、取现及费用扣收明细)added 2015-06-18
     $p = '/以下是您的消费(.*)本期积分说明/';
     $r = $this->pregMatchAll($p, $s, $out);
     //        print_r($out);
     //        exit;
     if ($r) {
         $cardNoPattern = "/卡号:\\d+.*?(\\d+)/";
         $cardNoMatched = preg_match($cardNoPattern, $s, $cardNoMatch);
         //            print_r($cardNoMatch);
         //            exit;
         $card_no = $cardNoMatch[1];
         $d = $out[1][0];
         //            print_r($d);
         //            exit;
         $p = "/({$date}) # ({$date}) # ([^#]*) # [A-Z]* # ({$money}) # [A-Z]* # ({$money})/";
         $r = $this->pregMatchAll($p, $d, $out);
         //            print_r($out);
         //            exit;
         for ($i = 0; $i < count($out[0]); $i++) {
             $one['trans_date'] = ParseUtil::formatDate($out[1][$i], $info['statement_end_date']);
             $one['post_date'] = ParseUtil::formatDate($out[2][$i], $info['statement_end_date']);
             $one['description'] = $out[3][$i];
             $one['rmb_amount'] = ParseUtil::formatMoney($out[4][$i]);
             #$one['card_no'] = $card_no;
             $one['orign_amount'] = ParseUtil::formatMoney($out[5][$i]);
             $details[$card_no][] = ParseUtil::trimArr($one);
             //                print_r($card_no);
             //                exit;
             unset($one);
         }
     }
     //        print_r($details);
     //        exit;
     #积分明细
     $p = '/本期积分说明.*人民币账户 ?RMB # ([\\-\\d]+)/';
     $r = $this->pregMatchAll($p, $s, $out);
     //        print_r($out);
     //        exit;
     if ($r) {
         $info['total_points'] = ParseUtil::formatNum($out[1][0]);
     }
     if (empty($details)) {
         //            return $this->insert($info);
     }
     //区分不同的卡
     foreach ($details as $cardNo => $detail) {
         $oneCardInfo = $info;
         $oneCardInfo['card_no'] = $all_card_no_str;
         $oneCardInfo['trans_detail'] = json_encode($detail);
         //            $this->insert($oneCardInfo);
         print_r($oneCardInfo);
         exit;
     }
     return true;
 }