<?php
/**
 * @desc 点数分货费（DSFHF）
 */
class Process_DsfhfProcess{
    //非逻辑费用代码
    private static $_noLogically = array('GYTCF','KNCYF-01','KNCYF-02','SDF');
    
    public static function return_operation_type(){
        return array(
            '1' =>  'GYTCF',
            '2' =>  'KNCYF-01',
            '3' =>  'KNCYF-02',
            '4' =>  'SDF'
        );
    }
    
    public static function return_operation_type_co(){
        return array(
            '1' => 'GDF-01',
            '2' => 'GDF-02'
        );
    }
    
    public static function deductFee($otherFeeInfo,$dsRow){
        $response = array('status'=>'0','message'=>'');
        $otherFeeCode = strtolower($otherFeeInfo['fee_code']);
        $objOtherCalculte = new Common_CalculateOtherFee();
        $db = Service_Orders::getModelInstance()->getAdapter();
        $db->beginTransaction();
        try {
            $objOtherCalculte->setDsParams($dsRow);
            $otherfeeArr = $objOtherCalculte->getOtherFee($otherFeeCode);
            $otherfeeDsfhf = $otherfeeArr['data']['otherFee'][strtolower($otherFeeCode)];
            $isFeeCondition = array(
                'cbl_refer_code' => $dsRow['order_code'],//记录订单号
                'application_code' => $otherFeeCode,
            );
            $isFee = Service_CustomerBalanceLog::getByCondition($isFeeCondition, 'count(*)');
            //收取过点数分货费，将不再收取
            if($otherfeeDsfhf['price'] > 0 && empty($isFee)) {
                $customerData = Service_Customer::getByField($dsRow['customer_code'], 'customer_code', array('customer_id'));
                if(empty($customerData)){
                    throw new Exception('Customer does not exist');
                }
                //扣费
                $deductResult = Service_CustomerBalanceProcess::deductFee($customerData['customer_id'], $otherfeeDsfhf, '扣'.$otherFeeInfo['fee_name'], $dsRow['order_code'], $otherFeeCode, $otherfeeDsfhf['fee_id']);
                if($deductResult['ask'] !=1 ){
                    throw new Exception($deductResult['error']);
                }
                //处理收费业务数据
                $paymentArr = $incomeArr = $fee_cost_detail = array();
                $businessIncomArr = self::getBusinessAndIncom($dsRow['customer_code'], $dsRow['reference_no'], $dsRow['order_code'], $otherfeeDsfhf, $otherFeeInfo, $dsRow);
                if(!empty($businessIncomArr)){
                    if(array_key_exists('income', $businessIncomArr) && $businessIncomArr['income']){
                        $incomeArr[] = $businessIncomArr['income'];
                    }
                    if(array_key_exists('payment', $businessIncomArr) && $businessIncomArr['payment']){
                        $paymentArr[] = $businessIncomArr['payment'];
                    }
                    if(array_key_exists('cost_detail', $businessIncomArr) && $businessIncomArr['cost_detail']){
                        $fee_cost_detail[] = $businessIncomArr['cost_detail'];
                    }
                }
                //处理财务业务数据
                if(!empty($incomeArr) || !empty($paymentArr)){
                    self::doBusinessPaymentIncome($dsRow['customer_code'], $dsRow['warehouse_id'], $dsRow['order_code'], $dsRow['parcel_quantity'], $incomeArr, $paymentArr, $fee_cost_detail, 0);
                }
            }else {
                throw new Exception("订单：".$dsRow['order_code']."应收点数分货费用为0或者此订单已收取过点数分货费");
            }
            $response['status'] = '1';
            $db->commit();
            return  $response;
        }catch (Exception $e){
            $db->rollBack();
            $response['message'] = $e->getMessage();
            return $response;
        }
    }
    
    /**
     * [getBusinessAndIncom 获取费用 应收 | 应付 | 成本数组]
     * @author [simple] <[<^^^^^^^>]>
     * @param  [type] $customer_code [客户代码]
     * @param  [type] $reference_no  [追踪号]
     * @param  [type] $code_number   [单号]
     * @param  [type] $otherfeeRow   [杂费收费数组]
     * @param  [type] $otherFeeInfo  [杂费信息数组]
     * @return [type]                [description]
     */
    private static function getBusinessAndIncom($customer_code, $reference_no, $code_number,$otherfeeRow, $otherFeeInfo, $other){
        //应收 / 应付 / 成本
        $incomeArr = $paymentArr = $fee_cost_detail = array();
        $tmpFee = str_replace('-', '', strtolower($otherFeeInfo['fee_code']));
        if($tmpFee == strtolower('GYTCF')){
            $tmpFee = 'overnightparking';
        }
        $_otherfee_mix_arr = Process_BillConfig::getOtherFeeArr();
        $billConfig = $_otherfee_mix_arr[$tmpFee];
        if(empty($billConfig)){
            throw new Exception('费用['.$otherFeeInfo['fee_code'].']配置错误');
        }
        $userAuth = new Zend_Session_Namespace('userAuthorization');
        $remote_ip = Common_Common::getIP();
        $customerArr = Service_Customer::getByField($customer_code, 'customer_code', array('customer_saler_user_id','customer_currency'));
        //转为客户币种
        $convert_fee = Service_Currency::converByCode($otherfeeRow['currency_code'], $customerArr['customer_currency'], $otherfeeRow['price']);
        $date = date("Y-m-d H:i:s");
        if(!empty($code_number)){
            $aAddress                           = Service_OrderAddressBook::getByField($code_number, 'order_code');
            !empty($aAddress) && $countryArr    = Service_Country::getByField($aAddress['oab_country_id'],'country_id');
        }
        //应收
        $incomeArr = array(
            'customer_code' => $customer_code,
            'ft_code' => $billConfig['ftcode'],
            'ut_code' => $billConfig['utcode'],
            'sm_code' => @$other['sm_code']?$other['sm_code'] :'',
            'bi_amount' => $convert_fee,
            'bi_org_amount' => $otherfeeRow['price'],
            'currency_code' => $otherfeeRow['currency_code'],
            'currency_rate' => '',
            'bi_chargeable_time' => $date,
            'bi_note' => $otherFeeInfo['fee_name'],
        );
        $fee_detail = array(
            'fee_amount_customer' => $convert_fee,                                  //费用金额（客户）
            'fee_currency_code_customer' => $customerArr['customer_currency'],      //费用币种（客户）
            'discount_customer' => $otherFeeInfo['discount'],                       //折扣率（客户）（1=100%）
        );
        //应付费用  服务商不能为空
        $cost_detail = array(); 
        if (isset($otherfeeRow['cost']) && $otherfeeRow['cost'] > 0 && $otherFeeInfo['sp_code'] != '') {
            $spRow = Service_ServiceProvider::getByField($otherFeeInfo['sp_code'], 'sp_code');
            //$sp_currency_code = $spRow['currency_code'];
            //转为服务商币种
            $convert_fee = Service_Currency::converByCode($otherFeeInfo['cost_currency_code'], $spRow['currency_code'], $otherfeeRow['cost']);
            $paymentArr = array(
                'sp_code' => $otherFeeInfo['sp_code'],                              //服务商代码
                'ft_code' => $billConfig['ftcode'],
                'ut_code' => $billConfig['utcode'],
                'sm_code' => @$other['sm_code']?$other['sm_code']:'',
                'bp_amount' => $convert_fee,
                'bp_org_amount' => $otherfeeRow['cost'],
                'currency_code' => $otherFeeInfo['fee_currency_code'],
                'currency_rate' => '',
                'bp_chargeable_time' => @$other['add_time'] ? $other['add_time'] : $date,
                'bp_create_type'     => empty($code_number) ? '1' : '0'
            );
            $cost_detail = array(
                'cost_amount_org'           => $otherfeeRow['cost'],                //成本金额（原始）
                'cost_currency_code_org'    => $otherFeeInfo['cost_currency_code'], //成本币种（原始）
                'cost_amount_sp'            => $convert_fee,                        //成本金额（服务商）
                'cost_currency_code_sp'     => $spRow['currency_code'],             //成本币种（服务商）
                'sp_code'                   => $otherFeeInfo['sp_code'],            //服务商代码
            );
        }
        if(!empty($fee_detail) || !empty($cost_detail)){
            $fee_cost_common = array(
                'code_number'                   => $code_number,                        //单号
                'code_type'                     => 3,                                   //单号类型（1:区内单 2：区外单 3：ASN单）
                'customer_code'                 => $customer_code,                      //客户代码
                'reference_no'                  => $reference_no,                       //客户参考号
                'tracking_number'               => @$other['tracking_number']?$other['tracking_number']:'',           //服务商单号（跟踪号）
                'sm_code'                       => @$other['sm_code']?$other['sm_code']:'',                           //运输方式代码
                'country_code'                  => $countryArr['country_code'] ? $countryArr['country_code'] : '',   //国际简称（二字码）
                'fee_code'                      => $otherFeeInfo['fee_code'],           //费用编号
                'fee_name'                      => $billConfig['binote'],               //费用名称
                'fee_amount_org'                => $otherFeeInfo['price'],              //费用金额（原始）
                'fee_currency_code_org'         => $otherFeeInfo['fee_currency_code'],  //费用币种（原始）
                'price_batch_number'            => '',                                  //运输价格编号
                'currency_batch_number'         => '',                                  //货币汇率编号
                'fee_time'                      => $date,                               //扣费时间
                'fee_time_recalculate'          => $date,                               //重新扣费时间
                'ip'                            => $remote_ip,                          //扣费操作IP
                'ip_recalculate'                => $remote_ip,                          //重新扣费操作IP
                'operator'                      => $userAuth->user['user_name'],        //扣费操作人
                'operator_recalculate'          => $userAuth->user['user_name'],        //重新扣费操作人
            );
            $fee_cost_detail = array_merge($fee_detail, $cost_detail, $fee_cost_common);
        }
        return array(
            'income' => $incomeArr,
            'payment' => $paymentArr,
            'cost_detail' => $fee_cost_detail
        );
    }
    
    /**
     * [doBusinessPaymentIncome 处理财务业务数据customer_code]
     * @param  [type] $customer_code   [客户代码]
     * @param  [type] $warehouse_id    [仓库代码]
     * @param  [type] $bb_refer_code   [追踪号]
     * @param  [type] $bb_pieces       [数量]
     * @param  [type] $incomeArr       [应收]
     * @param  [type] $paymentArr      [应付]
     * @param  [type] $fee_cost_detail [成本]
     * @param  [type] $weight          [重量]
     * @return [type]                  [description]
     */
    private static function doBusinessPaymentIncome($customer_code, $warehouse_id, $bb_refer_code, $bb_pieces, $incomeArr, $paymentArr, $fee_cost_detail, $weight){
        $customerArr = Service_Customer::getByField($customer_code, 'customer_code', array('customer_saler_user_id','customer_currency'));
        //判断是否存在应收、应付
        if(!empty($incomeArr) || !empty($paymentArr)){
            $ft_code = !empty($incomeArr) ? $incomeArr[0]['ft_code'] : $paymentArr[0]['ft_code'];
            $sm_code = !empty($incomeArr) ? $incomeArr[0]['sm_code'] : $paymentArr[0]['sm_code'];
            //有逻辑，费用代码
            if(in_array($ft_code, array('DSFHF','GDF-01','GDF-02','YHDBF'))){ //易货打包费加入有逻辑杂费记录
                if(!empty($sm_code)){
                    $ds_code = 'so';
                }else{
                    $ds_code = 'asn';
                }
            }else{
                if(in_array($ft_code, self::$_noLogically)){
                    $ds_code = 'vf';
                }
            }
           
            //写入业务表
            $businessArr = array(
                'ds_code' => $ds_code,
                'customer_code' => $customer_code,
                'warehouse_id' => $warehouse_id,
                'sm_code' => '',
                'bb_volume_weight' => $weight,
                'bb_charge_weight' => $weight,
                'bb_delivered_weight' => $weight,
                'bb_pieces' => $bb_pieces,
                'bb_declared_value' => 0,
                'bb_declared_currency_code' => $incomeArr['currency_code'],
                'country_code' => '',
                'bb_postcode' => '',
                'bb_charge_time' => date("Y-m-d H:i:s"),
                'bb_declared_time' => date('Y-m-d H:i:s'),          //发货时间 此时间与服务商对接
                'bb_sales_id' => $customerArr['customer_saler_user_id'],
                'bb_refer_code' => $bb_refer_code,
                'bb_service_number' => '', //ref_tracking_number
                'bb_reference_no' => '',
            );
            $bsObj = new Process_Business();
            $businessResult = $bsObj->businessFee($businessArr, $incomeArr, $paymentArr);
            if($businessResult['state']!='1'){ 
                throw new Exception($businessResult['message']);
            }
        }
        //插入成本数据
        if(!empty($fee_cost_detail)){
            if(Service_FeeCostDetail::addMultiRows($fee_cost_detail) === false){
                throw new Exception('成本写入异常');
            }
        }
    }
    
    /**
     * 浏览器友好的变量输出
     * @param mixed $var 变量
     * @param boolean $echo 是否输出 默认为True 如果为false 则返回输出字符串
     * @param string $label 标签 默认为空
     * @param boolean $strict 是否严谨 默认为true
     * @return void|string
     */
    public static function dump($var, $echo=true, $label=null, $strict=true) {
        $label = ($label === null) ? '' : rtrim($label) . ' ';
        if (!$strict) {
            if (ini_get('html_errors')) {
                $output = print_r($var, true);
                $output = '<pre>' . $label . htmlspecialchars($output, ENT_QUOTES) . '</pre>';
            } else {
                $output = $label . print_r($var, true);
            }
        } else {
            ob_start();
            var_dump($var);
            $output = ob_get_clean();
            if (!extension_loaded('xdebug')) {
                $output = preg_replace('/\]\=\>\n(\s+)/m', '] => ', $output);
                $output = '<pre>' . $label . htmlspecialchars($output, ENT_QUOTES) . '</pre>';
            }
        }
        if ($echo) {
            echo($output);
            return null;
        }else
            return $output;
    }
    
    /**
     * [debug 调试输出]
     * @param  [type] $msg [description]
     * @return [type]      [description]
     */
    public static function debug($message = '')
    {
        echo '['.date('Y-m-d H:i:s').']'.$message . "\n\t";
    }
    
    public static function getQueryOrder($orderCodeArray,$type,$pageSize=0,$page=1, $order = ""){
        $data=array();
        $result=  Service_Orders::getInnerJionShiporderCondition(array('o_or_r_code'=>$orderCodeArray), $type,$pageSize,$page,$order);
        if($type=='count(*)'){
            $data['total']=$result;
            return $data;
        }
        if(!empty($result)){
    
            foreach($result as $key=>$value){
               $result[$key]['weight'] = $value['so_weight'];
            }
        }
        $data = $result;
        return $data;
    }
    
    public static function getCacheDir(){
        return str_replace('\\', '/', realpath(APPLICATION_PATH . '/../data/cache')) . '/';
    }
    
    public static function getData($file) {
        $response = array('status' => 0, 'message' => '');
    
        if (!is_file($file)) { // 判断文件是否存在
          $response['message'] = '缓存文件【' . $file . '】不存在';
    
          return $response;
        }
    
        $ext = strtolower(pathinfo($file, PATHINFO_EXTENSION)); // 文件扩展名
    
        if (!in_array($ext, array('xls', 'xlsx'), TRUE)) { // 允许的文件类型
          $response['message'] = '文件类型【' . $ext . '】错误，仅支持xls或xlsx类型文件';
          @unlink($file); // 删除文件
    
          return $response;
        }
    
        require_once APPLICATION_PATH . '/../libs/PHPExcel.php';
        require_once APPLICATION_PATH . '/../libs/PHPExcel/IOFactory.php';
    
        set_time_limit(0); // 不限制执行时间
        ini_set('memory_limit', '2048M'); // 2G内存限制
    
        $loaderObj = PHPExcel_IOFactory::load($file); // 加载Excel文件
    
        if (!$loaderObj) {
          $response['message'] = '文件解析失败，请确保所上传的文件类型为xls或xlsx';
          @unlink($file); // 删除文件
    
          return $response;
        }
    
        $sheetObj = $loaderObj->getSheet(0); // 获取第一个工作表
        $maxCols  = PHPExcel_Cell::columnIndexFromString($sheetObj->getHighestColumn()); // 最大列数
        $maxRows  = $sheetObj->getHighestRow(); // 最大行数
        $cacheDir = self::getCacheDir();
        $data     = array();
        $repeat   = array(); // 缓存订单号，排查重复单号
        $total_org = 0;
    
        for ($i = 2; $i <= $maxRows; ++$i) { // 排除表头，从第2行开始读取
          $orderCode = trim($sheetObj->getCell('A' . $i)->getValue());
          $total_org++;
          if ('' !== $orderCode) {
            if (isset($repeat[$orderCode])) {
              continue ;
            }
    
            $repeat[$orderCode] = $orderCode;
          }
        }
    $total=0;
    $startIndex=0;
    $data=array();
    while($pieceOrder=array_slice($repeat, $startIndex,50,true)){
        $result=self::getQueryOrder(array('o_or_r_code'=>$pieceOrder), $type = '*');
        if(!empty($result)){
            $data=  array_merge($data,$result);
            $total+=count($result);
        }
        $startIndex+=50;
    }
    if (!empty($data)) {
          $data['total']=$total;//有效单号
          $data['total_org'] = $total_org;//原数据量，即输入数据量
          $response = array('status' => 1, 'data'=> $data);
        }else {
          $response['message'] = '没有找到相匹配的数据';
        }
    
        unset($data);
        unset($repeat);
        @unlink($file); // 删除文件
    
        return $response;
      } 
      
      public static function deductOvernightParkingFee($otherFeeInfo,$otherParams){
          $customer_code = $otherParams['customer_code'];
          $fee_generate_time = $otherParams['fee_generate_time'];
          $quantity = $otherParams['quantity'];
          $code = $otherParams['code'];
          $response = array('status'=>'0','message'=>'');
          if(strtolower($otherFeeInfo['fee_code']) == strtolower('GYTCF')){
              $otherFeeCode = strtolower('OvernightParking');
          }else{
              $otherFeeCode = strtolower($otherFeeInfo['fee_code']);
          }
          $objOtherCalculte = new Common_CalculateOtherFee();
          $db = Service_Orders::getModelInstance()->getAdapter();
          $db->beginTransaction();
          try {
              $objOtherCalculte->setAtParams(array('customer_code'=>$customer_code,'quantity'=>$quantity)); //实报实销(Accountable)
              $otherfeeArr = $objOtherCalculte->getOtherFee($otherFeeCode);
              $otherfeeGytcf = $otherfeeArr['data']['otherFee'][$otherFeeCode];
              if($otherfeeGytcf['price'] > 0 ) {
                  $customerData = Service_Customer::getByField($customer_code, 'customer_code', array('customer_id'));
                  if(empty($customerData)){
                      throw new Exception('Customer does not exist');
                  }
                  //扣费
                  if(strtolower($otherFeeInfo['fee_code']) == strtolower('GYTCF')){
                      $refer_code = 'GYTC'.Common_GetNumber::getCode();//随机生成唯一的交易记录的参考号
                  }elseif(strtolower($otherFeeInfo['fee_code']) == strtolower('SDF')){
                      $refer_code = $code; //报关单删单,用单号做为交易记录的单号
                  }else{
                      $refer_code = 'KNCY'.Common_GetNumber::getCode();//随机生成唯一的交易记录的参考号
                  }
                  $otherParam['add_time'] = $fee_generate_time; //交易记录时间，记录（计费）业务时间
                  $deductResult = Service_CustomerBalanceProcess::deductFee($customerData['customer_id'], $otherfeeGytcf, '扣'.$otherFeeInfo['fee_name'], $refer_code, $otherFeeInfo['fee_code'], $otherfeeGytcf['fee_id'],$otherParam);
                  if($deductResult['ask'] !=1 ){
                      throw new Exception($deductResult['error']);
                  }
                  //处理收费业务数据
                  $paymentArr = $incomeArr = $fee_cost_detail = array();
                  $businessIncomArr = self::getBusinessAndIncom($customer_code, '', '', $otherfeeGytcf, $otherFeeInfo,$otherParam);
                  if(!empty($businessIncomArr)){
                      if(array_key_exists('income', $businessIncomArr) && $businessIncomArr['income']){
                          $incomeArr[] = $businessIncomArr['income'];
                      }
                      if(array_key_exists('payment', $businessIncomArr) && $businessIncomArr['payment']){
                          $paymentArr[] = $businessIncomArr['payment'];
                      }
                      if(array_key_exists('cost_detail', $businessIncomArr) && $businessIncomArr['cost_detail']){
                          $fee_cost_detail[] = $businessIncomArr['cost_detail'];
                      }
                  }
                  //处理财务业务数据
                  if(!empty($incomeArr) || !empty($paymentArr)){
                      self::doBusinessPaymentIncome($customer_code, '', $refer_code, '', $incomeArr, $paymentArr, '', 0);
                  }
              }else {
                  throw new Exception("客户：".$customer_code."，应收过夜停车费用为零");
              }
              $response['status'] = '1';
              $db->commit();
              return  $response;
          }catch (Exception $e){
              $db->rollBack();
              $response['message'] = $e->getMessage();
              return $response;
          }
      }
      
      public static function deductChangOrderFee($otherFeeInfo, $coRow){
          $response = array('status'=>'0','message'=>'');
          $otherFeeCode = strtolower($otherFeeInfo['fee_code']);
          $objOtherCalculte = new Common_CalculateOtherFee();
          $db = Service_Orders::getModelInstance()->getAdapter();
          $db->beginTransaction();
          try {
              $objOtherCalculte->setCoParams($coRow);
              $otherfeeArr = $objOtherCalculte->getOtherFee($otherFeeCode);
              $otherfeeGdf = $otherfeeArr['data']['otherFee'][strtolower($otherFeeCode)];//var_dump($otherfeeGdf);exit;
              $isFeeCondition = array(
                  'cbl_refer_code' => $coRow['code'],//记录订单号
                  'application_code' => $otherFeeCode,
              );
              
              $isFee = Service_CustomerBalanceLog::getByCondition($isFeeCondition, 'count(*)');
              //收取过点数分货费，将不再收取
              if($otherfeeGdf['price'] > 0 && empty($isFee)) {
                  $customerData = Service_Customer::getByField($coRow['customer_code'], 'customer_code', array('customer_id'));
                  if(empty($customerData)){
                      throw new Exception('Customer does not exist');
                  }
                  $otherParam['add_time'] = $coRow['fee_generate_time']; //交易记录时间，记录（计费）业务时间
                  //扣费
                  $deductResult = Service_CustomerBalanceProcess::deductFee($customerData['customer_id'], $otherfeeGdf, '扣'.$otherFeeInfo['fee_name'], $coRow['code'], $otherFeeCode, $otherfeeGdf['fee_id'],$otherParam);
                  if($deductResult['ask'] !=1 ){
                      throw new Exception($deductResult['error']);
                  }
                  //处理收费业务数据
                  $paymentArr = $incomeArr = $fee_cost_detail = array();
                  $businessIncomArr = self::getBusinessAndIncom($coRow['customer_code'], $coRow['reference_no'], $coRow['code'], $otherfeeGdf, $otherFeeInfo, $coRow);
                  if(!empty($businessIncomArr)){
                      if(array_key_exists('income', $businessIncomArr) && $businessIncomArr['income']){
                          $incomeArr[] = $businessIncomArr['income'];
                      }
                      if(array_key_exists('payment', $businessIncomArr) && $businessIncomArr['payment']){
                          $paymentArr[] = $businessIncomArr['payment'];
                      }
                      if(array_key_exists('cost_detail', $businessIncomArr) && $businessIncomArr['cost_detail']){
                          $fee_cost_detail[] = $businessIncomArr['cost_detail'];
                      }
                  }
                  //处理财务业务数据
                  if(!empty($incomeArr) || !empty($paymentArr)){
                      //如果是易货打包费，则没有成本，不写入
                      if($otherFeeCode == 'yhdbf'){
                          $fee_cost_detail = array();
                      }
                      self::doBusinessPaymentIncome($coRow['customer_code'], $coRow['warehouse_id'], $coRow['code'], $coRow['total_quantity'], $incomeArr, $paymentArr, $fee_cost_detail, 0);
                  }
              }else {
                  if($coRow['type_co'] == '1'){
                      $splitStr = "入区单号：";
                  }elseif($coRow['type_co'] == '2'){
                      $splitStr = "订单号:";
                  }else{
                      $splitStr = "单号"; //易货打包费是修改报错提示语
                  }
                  throw new Exception($splitStr.$coRow['code']."应收".$otherFeeInfo['fee_name']."用为0或者此".$splitStr."已收取过".$otherFeeInfo['fee_name']);
              }
              $response['status'] = '1';
              $db->commit();
              return  $response;
          }catch (Exception $e){
              $db->rollBack();
              $response['message'] = $e->getMessage();
              return $response;
          }
      }
}