<?php

class Financial_OtherFeeController extends Ec_Controller_Action
{
    public function preDispatch()
    {
        $this->tplDirectory = "financial/views/other_fee/";
    }


    /**
     * @desc 查看全部未出帐应付费用
     */
    public function listAction()
    {
        $businessType = Process_BillConfig::businessType('auto');
        $rpType = Process_BillConfig::rpType('auto');
        $bilPaymentStatus = Process_BillConfig::bilPaymentStatus('auto');
        $withdrawSign = Process_BillConfig::withdrawSign('auto');
        $return = array(
            "state" => 0,
            "message" => "No Data"
        );
        if ($this->_request->isPost()) {
            $page = $this->_request->getParam('page', 1);
            $pageSize = $this->_request->getParam('pageSize', 20);

            $page = $page ? $page : 1;
            $pageSize = $pageSize ? $pageSize : 20;

            $condition['sp_code'] = trim($this->_request->getParam("spCode", ""));
            $condition['bb_refer_code'] = trim($this->_request->getParam("code", ""));
            // $condition['ds_code'] = trim($this->_request->getParam("businessType", ""));
            $condition['dateFrom'] = trim($this->_request->getParam("dateFrom", ""));
            $condition['dateTo'] = trim($this->_request->getParam("dateTo", ""));
            $condition['ft_code'] = trim($this->_request->getParam("ft_code", ""));

            if (isset($condition['dateFrom']) && !empty($condition['dateFrom'])) {
                $condition['dateFrom'] = date("Y-m-d H:i:s", strtotime($condition['dateFrom']));
            }
            if (isset($condition['dateTo']) && !empty($condition['dateTo'])) {
                $condition['dateTo'] = date("Y-m-d H:i:s", strtotime($condition['dateTo']));
            }

            //非逻辑
            /*
            $condition['bp_create_type'] = 1;
            $condition['ds_code'] = 'vf';//业务类型  虚拟
            */
            //已审核
            $condition['bp_status'] = 2;

            $count = Service_BilPayment::getNotAuditFeesGroupByCondition($condition, 'count(*)');

            $return['total'] = $count;

            if ($count) {
                $type = array(

                    'sum(bil_payment.bp_amount) as bp_amount',

                    'service_provider.sp_name',
                    'service_provider.sp_code',
                );
                $rows = Service_BilPayment::getNotAuditFeesGroupByCondition($condition, $type, $pageSize, $page, array("service_provider.sp_code asc"));
                $return['data'] = $rows;
                $return['state'] = 1;
                $return['message'] = "";
                $return['rpType'] = $rpType;
                $return['bilPaymentStatus'] = $bilPaymentStatus;
                $return['withdrawSign'] = $withdrawSign;
                $editFeeConfig = Process_BusinessPayment::editBusinessPaymentFeeConfig();
                $return['editFeeConfig'] = array_flip($editFeeConfig);
            }
            die(Zend_Json::encode($return));
        }
        $this->view->businessType = $businessType;
        $this->view->billDateFrom = '';
        $this->view->billDateTo = '';
        $this->view->feeType = Service_FeeType::getByCondition(array(), array("ft_code", "ft_name_cn"));
        $this->view->bilPaymentStatus = $bilPaymentStatus;
        echo Ec::renderTpl($this->tplDirectory . "list2.tpl", 'layout');
    }

    /**
     * @desc 查看全部未出帐应付费用
     */
    public function detailListAction()
    {
        $businessType = Process_BillConfig::businessType('auto');
        $rpType = Process_BillConfig::rpType('auto');
        $bilPaymentStatus = Process_BillConfig::bilPaymentStatus('auto');
        $withdrawSign = Process_BillConfig::withdrawSign('auto');
        $return = array(
            "state" => 0,
            "message" => "No Data"
        );
        if ($this->_request->isPost()) {
            $page = $this->_request->getParam('page', 1);
            $pageSize = $this->_request->getParam('pageSize', 20);

            $page = $page ? $page : 1;
            $pageSize = $pageSize ? $pageSize : 20;

            $condition['sp_code'] = trim($this->_request->getParam("spCode", ""));
            $condition['bb_refer_code'] = trim($this->_request->getParam("code", ""));
            // $condition['ds_code'] = trim($this->_request->getParam("businessType", ""));
            $condition['dateFrom'] = trim($this->_request->getParam("dateFrom", ""));
            $condition['dateTo'] = trim($this->_request->getParam("dateTo", ""));
            $condition['ft_code'] = trim($this->_request->getParam("ft_code", ""));

            if (isset($condition['dateFrom']) && !empty($condition['dateFrom'])) {
                $condition['dateFrom'] = date("Y-m-d H:i:s", strtotime($condition['dateFrom']));
            }
            if (isset($condition['dateTo']) && !empty($condition['dateTo'])) {
                $condition['dateTo'] = date("Y-m-d H:i:s", strtotime($condition['dateTo']));
            }

            //非逻辑
            /*
            $condition['bp_create_type'] = 1;
            $condition['ds_code'] = 'vf';//业务类型  虚拟
            */
            //已审核
            $condition['bp_status'] = 2;

            $count = Service_BilPayment::getNotAuditFeesByCondition($condition, 'count(*)');

            $return['total'] = $count;

            if ($count) {
                $type = array(
                    'bil_payment.bb_id',
                    'bil_payment.bp_id',
                    'bil_payment.bp_chargeable_time',
                    'bil_payment.ft_code',
                    'bil_payment.sm_code',
                    'bil_payment.bp_amount',
                    'bil_business.ds_code',
                    'fee_type.ft_name_cn',
                    'bil_payment.bp_rp_type',
                    'bil_payment.bp_status',
                    'bil_payment.bp_verify_time',
                    'bil_payment.bp_add_time',
                    'service_provider.sp_name',
                    'service_provider.sp_code',
                    'bil_payment.bp_withdraw_sign',
                    'bil_payment.bp_note',
                );
                $rows = Service_BilPayment::getNotAuditFeesByCondition($condition, $type, $pageSize, $page, array("bil_payment.bp_chargeable_time desc"));
                $return['data'] = $rows;
                $return['state'] = 1;
                $return['message'] = "";
                $return['rpType'] = $rpType;
                $return['bilPaymentStatus'] = $bilPaymentStatus;
                $return['withdrawSign'] = $withdrawSign;
                $editFeeConfig = Process_BusinessPayment::editBusinessPaymentFeeConfig();
                $return['editFeeConfig'] = array_flip($editFeeConfig);
            }
            die(Zend_Json::encode($return));
        }
        $this->view->businessType = $businessType;
        $this->view->billDateFrom = '';
        $this->view->billDateTo = '';
        $this->view->feeType = Service_FeeType::getByCondition(array(), array("ft_code", "ft_name_cn"));
        $this->view->bilPaymentStatus = $bilPaymentStatus;
        echo Ec::renderTpl($this->tplDirectory . "list.tpl", 'layout');
    }


    /**
     * @desc 审核费用
     */
    public function verityFeeAction()
    {
        $result = array(
            "state" => 0,
            "message" => "Fail.",
            "data" => array()
        );
        if ($this->_request->isPost()) {
            $codes = $this->_request->getParam("codes", array());
            $note = $this->_request->getParam("desc", "");
            $opType = $this->_request->getParam("opType", "");
            if (is_array($codes) && !empty($codes)) {
                $result['state'] = 1;
                $result['message'] = '';
                $obj = new Process_BusinessPayment();
                foreach ($codes as $code) {
                    $param['bp_id'] = $code;
                    $param['note'] = $note;
                    $param['opType'] = $opType;
                    $result['data'][] = $obj->verifyBusinessFeeTransaction($param);
                }
            }
        }

        die(Zend_Json::encode($result));
    }

    /**
     * @desc 按搜索条件导出费用
     */
    public function exportAction()
    {
        if ($this->_request->isPost()) {
            require_once("PHPExcel.php");
            require_once("PHPExcel/Reader/Excel2007.php");
            require_once("PHPExcel/Reader/Excel5.php");
            require_once('PHPExcel/IOFactory.php');
            $codesStr = "F1_" . date("Y-m-d");
            $objExcel = new PHPExcel();
            $objProps = $objExcel->getProperties();
            $objProps->setCreator('EC');
            $objProps->setTitle('Template');
            $objExcel->setActiveSheetIndex(0);

            $objActSheet = $objExcel->getActiveSheet();

            $condition['sp_code'] = trim($this->_request->getParam("spCode", ""));
            $condition['bb_refer_code'] = trim($this->_request->getParam("code", ""));

            $condition['dateFrom'] = trim($this->_request->getParam("dateFrom", ""));
            $condition['dateTo'] = trim($this->_request->getParam("dateTo", ""));
            $condition['ft_code'] = trim($this->_request->getParam("ft_code", ""));
            $condition['bp_status'] = trim($this->_request->getParam("E11", ""));


            //计费时间
            if (isset($condition['dateFrom']) && !empty($condition['dateFrom'])) {
                $condition['dateFrom'] = date("Y-m-d H:i:s", strtotime($condition['dateFrom']));
            }
            if (isset($condition['dateTo']) && !empty($condition['dateTo'])) {
                $condition['dateTo'] = date("Y-m-d H:i:s", strtotime($condition['dateTo']));
            }

            $condition['bp_status'] = 2;

            $feeData = Service_BilPayment::getFeeData($condition);

            if (!empty($feeData)) {
                //表头
                $ExcelKey = $feeData[1];
                foreach ($ExcelKey as $key => $val) {
                    $objActSheet->setCellValue($key . '1', $val);
                }
                //费用
                foreach ($feeData as $key => $orderArr) {
                    foreach ($ExcelKey as $k => $v) {
                        $val = isset($orderArr[$k]) ? $orderArr[$k] : '';
                        $objActSheet->setCellValue($k . $key, $val);
                    }
                }
            } else {

                $objActSheet->setCellValue('A1', "没有找到匹配的数据");
            }

            header('Pragma:public');
            header('Content-Type:application/x-msexecl;name="' . $codesStr . '.xls');
            header("Content-Disposition:inline;filename=" . $codesStr . '.xls');
            $objWriter = PHPExcel_IOFactory::createWriter($objExcel, 'Excel5');
            $objWriter->save('php://output');
        }
    }


    /**
     * @desc 按搜索条件导出费用
     */
    public function exportFeeAction()
    {
        if ($this->_request->isPost()) {
            require_once("PHPExcel.php");
            require_once("PHPExcel/Reader/Excel2007.php");
            require_once("PHPExcel/Reader/Excel5.php");
            require_once('PHPExcel/IOFactory.php');
            $codesStr = "F2_" . date("Y-m-d");
            $objExcel = new PHPExcel();
            $objProps = $objExcel->getProperties();
            $objProps->setCreator('EC');
            $objProps->setTitle('Template');
            $objExcel->setActiveSheetIndex(0);

            $objActSheet = $objExcel->getActiveSheet();

            $condition['sp_code'] = trim($this->_request->getParam("spCode", ""));
            $condition['bb_refer_code'] = trim($this->_request->getParam("code", ""));

            $condition['dateFrom'] = trim($this->_request->getParam("dateFrom", ""));
            $condition['dateTo'] = trim($this->_request->getParam("dateTo", ""));
            $condition['ft_code'] = trim($this->_request->getParam("ft_code", ""));
            $condition['bp_status'] = trim($this->_request->getParam("E11", ""));


            //计费时间
            if (isset($condition['dateFrom']) && !empty($condition['dateFrom'])) {
                $condition['dateFrom'] = date("Y-m-d H:i:s", strtotime($condition['dateFrom']));
            }
            if (isset($condition['dateTo']) && !empty($condition['dateTo'])) {
                $condition['dateTo'] = date("Y-m-d H:i:s", strtotime($condition['dateTo']));
            }

            //非逻辑
            $condition['bp_create_type'] = 1;
            $condition['ds_code'] = 'vf'; //业务类型  虚拟


            $feeData = Service_BilPayment::getFeeData($condition);

            if (!empty($feeData)) {
                //表头
                $ExcelKey = $feeData[1];
                foreach ($ExcelKey as $key => $val) {
                    $objActSheet->setCellValue($key . '1', $val);
                }
                //费用
                foreach ($feeData as $key => $orderArr) {
                    foreach ($ExcelKey as $k => $v) {
                        $val = isset($orderArr[$k]) ? $orderArr[$k] : '';
                        $objActSheet->setCellValue($k . $key, $val);
                    }
                }
            } else {

                $objActSheet->setCellValue('A1', "没有找到匹配的数据");
            }

            header('Pragma:public');
            header('Content-Type:application/x-msexecl;name="' . $codesStr . '.xls');
            header("Content-Disposition:inline;filename=" . $codesStr . '.xls');
            $objWriter = PHPExcel_IOFactory::createWriter($objExcel, 'Excel5');
            $objWriter->save('php://output');
        }
    }

    /**
     * @desc 查看非逻辑费用
     */
    public function paymentListAction()
    {
        $businessType = Process_BillConfig::businessType('auto');
        $rpType = Process_BillConfig::rpType('auto');
        $bilPaymentStatus = Process_BillConfig::bilPaymentStatus('auto');
        $withdrawSign = Process_BillConfig::withdrawSign('auto');
        $return = array(
            "state" => 0,
            "message" => "No Data"
        );
        if ($this->_request->isPost()) {
            $page = $this->_request->getParam('page', 1);
            $pageSize = $this->_request->getParam('pageSize', 20);

            $page = $page ? $page : 1;
            $pageSize = $pageSize ? $pageSize : 20;

            $condition['sp_code'] = trim($this->_request->getParam("spCode", ""));
            $condition['bb_refer_code'] = trim($this->_request->getParam("code", ""));
            // $condition['ds_code'] = trim($this->_request->getParam("businessType", ""));
            $sDate = trim($this->_request->getParam("dateFrom", ""));
            $tDate = trim($this->_request->getParam("dateTo", ""));
            $condition['ft_code'] = trim($this->_request->getParam("ft_code", ""));
            $condition['bp_status'] = trim($this->_request->getParam("E11", ""));

            $dateType = trim($this->_request->getParam("searchDateType", ""));

            /*  if (isset($condition['dateFrom']) && !empty($condition['dateFrom'])) {
                $condition['dateFrom'] = date("Y-m-d H:i:s", strtotime($condition['dateFrom']));
            }
            if (isset($condition['dateTo']) && !empty($condition['dateTo'])) {
                $condition['dateTo'] = date("Y-m-d H:i:s", strtotime($condition['dateTo']));
            }*/

            if ($sDate != '') {
                $sDate = date("Y-m-d H:i:s", strtotime($sDate));
            }
            if ($tDate != '') {
                $tDate = date("Y-m-d H:i:s", strtotime($tDate));
            }

            if ($dateType == 'createDate' || $dateType == '') {
                $condition['dateFrom'] = $sDate;
                $condition['dateTo'] = $tDate;
            } else {
                $condition['verifyFrom'] = $sDate;
                $condition['verifyTo'] = $tDate;
            }


            //非逻辑
            $condition['bp_create_type'] = 1;
            $condition['ds_code'] = 'vf'; //业务类型  虚拟


            $count = Service_BilPayment::getNotAuditFeesByCondition($condition, 'count(*)');

            $return['total'] = $count;

            if ($count) {
                $type = array(
                    'bil_payment.bp_id',
                    'DATE_FORMAT(bil_payment.bp_chargeable_time,\'%Y-%m-%d\') as bp_chargeable_time',
                    'bil_payment.ft_code',
                    'bil_payment.sm_code',
                    'bil_payment.bp_amount',
                    'bil_business.ds_code',
                    'fee_type.ft_name_cn',
                    'bil_payment.bp_rp_type',
                    'bil_payment.bp_status',
                    'bil_payment.bp_verify_time',
                    'bil_payment.bp_add_time',
                    'service_provider.sp_name',
                    'service_provider.sp_code',
                    'bil_payment.bp_withdraw_sign',
                    'bil_payment.bp_note',
                );
                $rows = Service_BilPayment::getNotAuditFeesByCondition($condition, $type, $pageSize, $page, array("bil_payment.bp_chargeable_time desc"));
                $return['data'] = $rows;
                $return['state'] = 1;
                $return['message'] = "";
                $return['rpType'] = $rpType;
                $return['bilPaymentStatus'] = $bilPaymentStatus;
                $return['withdrawSign'] = $withdrawSign;
                $editFeeConfig = Process_BusinessPayment::editBusinessPaymentFeeConfig();
                $return['editFeeConfig'] = array_flip($editFeeConfig);
            }
            die(Zend_Json::encode($return));
        }
        $this->view->businessType = $businessType;
        $this->view->billDateFrom = date("Y-m-d", strtotime("-40 days"));
        $this->view->billDateTo = ''; //date("Y-m-d H:i", strtotime("+1 days"));
        $this->view->feeType = Service_FeeType::getByCondition(array(), array("ft_code", "ft_name_cn"));
        $this->view->bilPaymentStatus = $bilPaymentStatus;
        echo Ec::renderTpl($this->tplDirectory . "payment.tpl", 'layout');
    }

    /**
     * @desc 批量上传费用(非逻辑)
     */
    public function uploadFeeAction()
    {
        if ($this->getRequest()->isPost()) {
            set_time_limit(0);
            ini_set('memory_limit', '500M');
            $return = array(
                'state' => 0,
                'message' => array('Request Method Err')
            );
            $file = $_FILES['fileToUpload'];
            $obj = new Process_BusinessPayment();
            $return = $obj->uploadFeeTransaction($file);
            die(Zend_Json::encode($return));
        }
    }

    /**
     * @desc 批量上传服务商重量
     */
    public function uploadWeightAction()
    {
        if ($this->getRequest()->isPost()) {
            set_time_limit(0);
            ini_set('memory_limit', '500M');
            $return = array(
                'state' => 0,
                'message' => array('Request Method Err')
            );
            $file = $_FILES['fileToUpload'];
            $obj = new Process_Business();
            $return = $obj->uploadWeightTransaction($file);
            die(Zend_Json::encode($return));
        }
    }


    /**
     * @desc 批量删除费用(转到作废)
     */
    public function batchDeleteFeeAction()
    {
        $result = array(
            "state" => 0,
            "message" => "Fail.",
            "data" => array()
        );
        if ($this->_request->isPost()) {
            $codes = $this->_request->getParam("codes", array());
            if (is_array($codes) && !empty($codes)) {
                $result['state'] = 1;
                $result['message'] = '';
                $obj = new Process_BusinessPayment();
                foreach ($codes as $code) {
                    $param['bp_id'] = $code;
                    $result['data'][] = $obj->deleteBusinessFeeTransaction($param);
                }
            }
        }
        die(Zend_Json::encode($result));
    }

    /**
     * @desc 获取帐单费用明细信息
     */
    public function editFeeAction()
    {
        $paramId = $this->_request->getParam('paramId', '0');
        $rpType = Process_BillConfig::rpType('auto');
        $spSettlementType = Process_BillConfig::spSettlementType('auto');
        $bt = Process_BillConfig::bt('auto');

        //提交数据
        if ($this->_request->isPost()) {
            $return = array(
                "state" => 0,
                "message" => "error",
                "data" => array()
            );

            $param = array(
                'sp_code' => $this->_request->getParam('payer_code', ''),
                'bp_id' => $this->_request->getParam('bp_id', ''),
                'amount' => $this->_request->getParam('amount', ''),
                'bt_code' => $this->_request->getParam('bt_code', 'EX'),
                'ft_code' => $this->_request->getParam('ft_code', ''),
                'rp_type' => $this->_request->getParam('rp_type', ''),
                'note' => $this->_request->getParam('note', ''),
                'currency_code' => $this->_request->getParam('currency_code', ''),
                'charge_time' => $this->_request->getParam('charge_time', ''),
            );
            $param['charge_time'] = date('Y-m-d H:i:s', strtotime($param['charge_time']));

            //print_r($param);die;

            $obj = new Process_BusinessPayment();
            $return = $obj->editBusinessFeeTransaction($param);
            die(Zend_Json::encode($return));
        }
        $row = array(
            'bp_id' => '',
            'bb_id' => '',
            'bt_code' => 'EX',
            'bb_refer_code' => '',
            'sp_code' => '',
            'sp_name' => '',
            'ft_code' => '',
            'bp_amount' => '',
            'currency_code' => '',
            'bp_note' => '',
            'cash_type_text' => '',
            'sp_balance' => '',
            'hold_amount' => '',
            'bp_rp_type' => '',
            'rpType_text' => '',
            "cash_type" => '', 'bb_charge_time' => date('Y-m-d H:i:s')
        );
        $isEdit = 1;
        if (!empty($paramId)) {
            $row = Service_BilPayment::getByField($paramId);
            $bbaRow = Service_BilBusinessAttach::getByField($row['bb_id'], 'bb_id');
            $bbRow = Service_BilBusiness::getByField($row['bb_id'], 'bb_id');
            $cRow = Service_ServiceProvider::getByField($row['sp_code'], 'sp_code');
            $cRow['sp_currency_code'] = $cRow['currency_code'];
            $row = array_merge($row, $cRow, $bbRow);
            $row['bb_refer_code'] = $bbaRow['bb_refer_code'];
            $row['hold_amount'] = Table_BilPayment::getInstance()->getTotal($row['sp_code'], 2);
            $row['cash_type_text'] = isset($spSettlementType[$cRow['sp_settlement_type']]) ? $spSettlementType[$cRow['sp_settlement_type']] : '未绑定';
            $row['rpType_text'] = isset($rpType[$row['bp_rp_type']]) ? $rpType[$row['bp_rp_type']] : '异常';
            $row['bp_amount'] = abs($row['bp_amount']);
            $isEdit = in_array($row['bp_status'], Process_Business::editBusinessPaymentFeeConfig()) ? 1 : 0;
        }

        $this->view->feeType = Service_FeeType::getByCondition(array(), '*', 0);
        $this->view->currency = Service_Currency::getByCondition(array(), '*', 0);

        $this->view->title = !empty($row['bb_refer_code']) ? "编辑费用：" . $row['bb_refer_code'] : '新增费用';

        $this->view->isEdit = $isEdit;
        $this->view->data = $row;
        echo Ec::renderTpl($this->tplDirectory . "edit_fee.tpl", 'layout');
    }


    /**
     * @desc 应收重新计费
     */
    public function readjustmentIncomeAction()
    {
        set_time_limit(0);
        $result = array(
            "state" => 0,
            "message" => "Fail.",
            "data" => array()
        );
        $customerCodeStr=trim($this->_request->getParam('customerCodes',''));
        $customerCodeArr=explode(' ',$customerCodeStr);
        if ($this->_request->isPost()) {
            $param = array(
                'customer_code_arr' => $customerCodeArr
            );
            $obj = new Process_BusinessIncome();
            $result = $obj->batchReadjustmentIncome($param);
        }
        die(Zend_Json::encode($result));
    }

    /**
     * @desc 应付重新计费
     */
    public function readjustmentPaymentAction()
    {
        set_time_limit(0);
        $result = array(
            "state" => 0,
            "message" => "Fail.",
            "data" => array()
        );
        if ($this->_request->isPost()) {
            $spCodesStr=trim($this->_request->getParam('spCodes',''));
            $spCodeArr=explode(' ',$spCodesStr);
            $param = array(
                'sp_code_arr' => $spCodeArr
            );
            $obj = new Process_BusinessPayment();
            $result = $obj->batchReadjustmentPayment($param);
        }
        die(Zend_Json::encode($result));
    }


    /**
     * @desc 获取费用明细信息
     */
    public function detailAction()
    {
        $paramId = $this->_request->getParam('paramId', '0');

        $return = array(
            "state" => 0,
            "message" => "No Data"
        );
        $businessType = Process_BillConfig::businessType('auto');
        $customerSettlementType = Process_BillConfig::customerSettlementType('auto');
        if (empty($paramId)) {
            die("not data");
        }
        //业务
        $row = Service_BilBusiness::getAttrByField($paramId, 'bb_id');
        //客户
        if($row['customer_code']!=''){
            $cRow = Service_Customer::getByField($row['customer_code'], 'customer_code', array('customer_short', 'customer_currency', 'cash_type'));
        }else{
            $cRow=array();
        }

        $row = array_merge($row, $cRow);

        if (empty($row)) {
            die("not data");
        }

        if ($this->_request->isPost()) {

            $condition['bb_id'] = $paramId;

            if (empty($condition['bb_id'])) {
                die(Zend_Json::encode($return));
            }

            $count = Table_BilPayment::getInstance()->getFeeDetailByBusinessCondition($condition, 'count(*)');

            $return['total'] = $count;

            if ($count) {
                $rows = Table_BilPayment::getInstance()->getFeeDetailByBusinessCondition($condition, '*', 0, 0);
                $return['data'] = $rows;
                $return['state'] = 1;
                $return['message'] = "";
            }
            die(Zend_Json::encode($return));
        }
        //是否支持重新计费
        $codeArr = Process_Business::readjustment();
        $readjustment = isset($codeArr[$row['ds_code']]) ? 1 : 0;

        $row['ds_code_text'] = isset($businessType[$row['ds_code']]) ? $businessType[$row['ds_code']] : '';
        $row['cash_type_text'] = isset($customerSettlementType[$row['cash_type']]) ? $customerSettlementType[$row['cash_type']] : '';
        $this->view->data = $row;
        $this->view->paramId = $paramId;
        $this->view->readjustment = $readjustment;
        echo Ec::renderTpl($this->tplDirectory . "detail.tpl", 'layout');
    }


    /**
     * @desc 重新计费
     */
    public function readjustmentAction()
    {
        $result = array(
            "state" => 0,
            "message" => "Fail.",
            "data" => array()
        );

        if ($this->_request->isPost()) {
            $refer_code = $this->_request->getParam('refer_code', '');
            $ds_code = $this->_request->getParam('ds_code', '');
            $param = array(
                'refer_code' => $refer_code,
                'ds_code' => $ds_code,
            );
            $obj = new Process_BusinessPayment();
            $result = $obj->readjustmentPaymentTransaction($param);
        }
        die(Zend_Json::encode($result));
    }

}