コード例 #1
0
ファイル: RcController.php プロジェクト: lovecheng/brs-demo2
 /**
  * 12 预订租赁车
  * @param json json_params{}
  * $return $arr_result ||$return_status
  * url:/index.php?r=CarrentalApi/rc/MakeBookingRQ
  * /index.php?r=CarrentalApi/rc/GetHotAreaMatchListRQ\&update=crontabRedis
  * /index.php?r=CarrentalApi/rc/GetHotAreaMatchListRQ\&update=crontabShow
  **/
 public function actionMakeBookingRQ()
 {
     $json_params = Yii::app()->request->getParam('json_params');
     //客户端请求的json参数
     $request_time = time();
     //测试用例[S]
     $json_params_go = Yii::app()->request->getParam('go');
     if ($json_params_go == 'go') {
         // $json_params='{"ExtraList":{"Extra":[{"id":"11590698223010","name":"\u5a74\u513f\u5ea7\u6905","amount":"2","value":"1.31"},{"id":"11590698218010","name":"\u8ffd\u52a0\u9a7e\u9a76\u4eba","amount":"2","value":"1.31"}]},"Vehicle":{"id":"272851603","automatic":"Manual","doors":"2","seats":"4","group":"MBMR","imageURL":"http:\/\/brs.test.baicheng.com\/uploads\/brs\/imgs\/carrental\/images\/car_images\/newsite\/B\/ford_ka.jpg","petrol":"N\/A","airbag":"false","aircon":"Yes","fuelPolicy":"1","companyLogo":"http:\/\/brs.test.baicheng.com\/uploads\/brs\/imgs\/carrental\/images\/suppliers\/atesa_logo_lrg.gif","company":"Atesa (flex)","unlimitedMileage":"\u4ee5\u5230\u5e97\u4e3a\u51c6","CarType":"MINI\u8ff7\u4f60\/\u5c0f\u578b","insurance":["\u7834\u649e\u9669","\u7a83\u76d7\u9669","\u7b2c\u4e09\u8d23\u4efb\u9669"],"currencyCode":"CNY","price":"785.41","prefcurr":"USD","prefPrice":"128.31","discount":"0.00"},"DriverInfo":{"DriverName":{"title":"mr","firstname":"test","lastname":"test","passportNum":"110227001","name":"test","birthday":"1984-11-01"},"Address":{"country":"\u4e2d\u56fd","city":"\u5317\u4eac","street":"\u5317\u4eac\u5e02\u671d\u9633\u533a\u901a\u60e0\u6cb3\u7554\u6587\u5316\u521b\u4e1a\u56ed1131\u53f7\u541b\u5929\u5927\u53a6\u4e8c\u5c42","postcode":"100023"},"Email":"*****@*****.**","Telephone":"18618291010","DriverAge":31},"PickUp":{"location_id":"1024998","shopName":"Madrid - Gran Via - \u9a6c\u5fb7\u91cc - \u683c\u5170\u7ef4\u4e9a","Date":{"year":"2015","month":"03","day":"04","hour":"10","minute":"30"}},"DropOff":{"location_id":"1024998","shopName":"Madrid - Gran Via - \u9a6c\u5fb7\u91cc - \u683c\u5170\u7ef4\u4e9a","Date":{"year":"2015","month":"03","day":"05","hour":"14","minute":"30"}},"PaymentInfo":["\u7528\u6237\u4fe1\u7528\u5361\u6570\u636e\u4e0d\u53ef\u8bb0\u5f55\uff01"],"AdditionalInfo":{"Comments":"","PickUpService":"","DropOffService":""},"AirlineInfo":{"flightNo":""},"Tracking":{"adcamp":"","adplat":""},"remoteIp":"106.2.184.106","ContactMan":"test","ContactMobile":"18618291010","ContactEmail":"*****@*****.**","CustSource":331692,"CustName":"13621086031"}';
         $json_params = '{"ExtraList":{"Extra":[{"id":"11590698223010","name":"\\u5a74\\u513f\\u5ea7\\u6905","amount":"2","value":"1.31"},{"id":"11590698218010","name":"\\u8ffd\\u52a0\\u9a7e\\u9a76\\u4eba","amount":"2","value":"1.31"}]},"Vehicle":{"id":"272851603","automatic":"Manual","doors":"2","seats":"4","group":"MBMR","imageURL":"http:\\/\\/brs.test.baicheng.com\\/uploads\\/brs\\/imgs\\/carrental\\/images\\/car_images\\/newsite\\/B\\/ford_ka.jpg","petrol":"N\\/A","airbag":"false","aircon":"Yes","fuelPolicy":"1","companyLogo":"http:\\/\\/brs.test.baicheng.com\\/uploads\\/brs\\/imgs\\/carrental\\/images\\/suppliers\\/atesa_logo_lrg.gif","company":"Atesa (flex)","unlimitedMileage":"\\u4ee5\\u5230\\u5e97\\u4e3a\\u51c6","CarType":"MINI\\u8ff7\\u4f60\\/\\u5c0f\\u578b","insurance":["\\u7834\\u649e\\u9669","\\u7a83\\u76d7\\u9669","\\u7b2c\\u4e09\\u8d23\\u4efb\\u9669"],"currencyCode":"CNY","price":"785.41","prefcurr":"USD","prefPrice":"128.31","discount":"0.00"},"DriverInfo":{"DriverName":{"title":"mr","firstname":"test","lastname":"test","passportNum":"110227001","name":"test","birthday":"1984-11-01"},"Address":{"country":"\\u4e2d\\u56fd","city":"\\u5317\\u4eac","street":"\\u5317\\u4eac\\u5e02\\u671d\\u9633\\u533a\\u901a\\u60e0\\u6cb3\\u7554\\u6587\\u5316\\u521b\\u4e1a\\u56ed1131\\u53f7\\u541b\\u5929\\u5927\\u53a6\\u4e8c\\u5c42","postcode":"100023"},"Email":"*****@*****.**","Telephone":"18618291010","DriverAge":31},
         "PickUp":{"location_id":"1024998","location_id_search":"440618","shopName":"Madrid - Gran Via - \\u9a6c\\u5fb7\\u91cc - \\u683c\\u5170\\u7ef4\\u4e9a","Date":{"year":"2015","month":"03","day":"04","hour":"10","minute":"30"}},
         "DropOff":{"location_id":"1024998","location_id_search":"294329","shopName":"Madrid - Gran Via - \\u9a6c\\u5fb7\\u91cc - \\u683c\\u5170\\u7ef4\\u4e9a","Date":{"year":"2015","month":"03","day":"05","hour":"14","minute":"30"}},"PaymentInfo":["\\u7528\\u6237\\u4fe1\\u7528\\u5361\\u6570\\u636e\\u4e0d\\u53ef\\u8bb0\\u5f55\\uff01"],"AdditionalInfo":{"Comments":"","PickUpService":"","DropOffService":""},"AirlineInfo":{"flightNo":""},"Tracking":{"adcamp":"","adplat":""},"remoteIp":"106.2.184.106","ContactMan":"test","ContactMobile":"18618291010","ContactEmail":"*****@*****.**","CustSource":331692,"CustName":"13621086031"}';
     }
     //测试用例[E]
     //对增加的属性进行判断[S]
     $array_params = json_decode($json_params, true);
     if (empty($array_params['PickUp']['shopName'])) {
         $return_json = json_encode(array('status' => false, 'error_msg' => '0x120030_PickUp.shopName不可为空'));
         exit($return_json);
     }
     if (empty($array_params['PickUp']['location_id_search'])) {
         $return_json = json_encode(array('status' => false, 'error_msg' => '0x120059_PickUp.location_id_search不可为空'));
         exit($return_json);
     }
     if (empty($array_params['DropOff']['shopName'])) {
         $return_json = json_encode(array('status' => false, 'error_msg' => '0x120031_DropOff.shopName不可为空'));
         exit($return_json);
     }
     if (empty($array_params['DropOff']['location_id_search'])) {
         $return_json = json_encode(array('status' => false, 'error_msg' => '0x120060_DropOff.location_id_search不可为空'));
         exit($return_json);
     }
     if (empty($array_params['Vehicle']['currencyCode'])) {
         $return_json = json_encode(array('status' => false, 'error_msg' => '0x120032_Vehicle.currencyCode不可为空'));
         exit($return_json);
     }
     if (empty($array_params['Vehicle']['price']) || intval($array_params['Vehicle']['price']) < 1) {
         $return_json = json_encode(array('status' => false, 'error_msg' => '0x120033_Vehicle.price不可为空,价格有误'));
         exit($return_json);
     }
     if (empty($array_params['Vehicle']['prefcurr'])) {
         $return_json = json_encode(array('status' => false, 'error_msg' => '0x120034_Vehicle.prefcurr不可为空'));
         exit($return_json);
     }
     if (empty($array_params['Vehicle']['prefPrice'])) {
         $return_json = json_encode(array('status' => false, 'error_msg' => '0x120035_Vehicle.prefPrice不可为空'));
         exit($return_json);
     }
     if (empty($array_params['Vehicle']['discount'])) {
         $return_json = json_encode(array('status' => false, 'error_msg' => '0x120036_Vehicle.discount不可为空'));
         exit($return_json);
     }
     if (empty($array_params['Vehicle']['imageURL'])) {
         $return_json = json_encode(array('status' => false, 'error_msg' => '0x120037_Vehicle.imageURL不可为空'));
         exit($return_json);
     }
     if (empty($array_params['Vehicle']['group'])) {
         $return_json = json_encode(array('status' => false, 'error_msg' => '0x120038_Vehicle.group不可为空'));
         exit($return_json);
     }
     if (empty($array_params['Vehicle']['automatic'])) {
         $return_json = json_encode(array('status' => false, 'error_msg' => '0x120039_Vehicle.automatic不可为空'));
         exit($return_json);
     }
     if (empty($array_params['Vehicle']['airbag'])) {
         $return_json = json_encode(array('status' => false, 'error_msg' => '0x120040_Vehicle.airbag不可为空'));
         exit($return_json);
     }
     if (empty($array_params['Vehicle']['aircon'])) {
         $return_json = json_encode(array('status' => false, 'error_msg' => '0x120057_Vehicle.aircon不可为空'));
         exit($return_json);
     }
     if (empty($array_params['Vehicle']['petrol'])) {
         $return_json = json_encode(array('status' => false, 'error_msg' => '0x120041_Vehicle.petrol不可为空'));
         exit($return_json);
     }
     if (empty($array_params['Vehicle']['doors'])) {
         $return_json = json_encode(array('status' => false, 'error_msg' => '0x120042_Vehicle.doors不可为空'));
         exit($return_json);
     }
     if (empty($array_params['Vehicle']['seats'])) {
         $return_json = json_encode(array('status' => false, 'error_msg' => '0x120043_Vehicle.seats不可为空'));
         exit($return_json);
     }
     if (empty($array_params['Vehicle']['fuelPolicy'])) {
         $return_json = json_encode(array('status' => false, 'error_msg' => '0x120044_Vehicle.fuelPolicy不可为空'));
         exit($return_json);
     }
     if (empty($array_params['Vehicle']['company'])) {
         $return_json = json_encode(array('status' => false, 'error_msg' => '0x120047_Vehicle.company不可为空'));
         exit($return_json);
     }
     if (empty($array_params['Vehicle']['companyLogo'])) {
         $return_json = json_encode(array('status' => false, 'error_msg' => '0x120048_Vehicle.companyLogo不可为空'));
         exit($return_json);
     }
     if (empty($array_params['DriverInfo']['DriverName']['passportNum'])) {
         $array_params['DriverInfo']['DriverName']['passportNum'] = '';
         //$return_json=json_encode(array( 'status'=>false, 'error_msg'=>'0x120049_DriverInfo.DriverName.passportNum驾驶人护照号不可为空'));
         // exit($return_json);
     }
     if (empty($array_params['DriverInfo']['DriverName']['name'])) {
         $return_json = json_encode(array('status' => false, 'error_msg' => '0x120050_DriverInfo.DriverName.name驾驶人中文名称不可为空'));
         exit($return_json);
     }
     if (empty($array_params['DriverInfo']['DriverName']['birthday'])) {
         $return_json = json_encode(array('status' => false, 'error_msg' => '0x120051_DriverInfo.DriverName.birthday驾驶员的出生日期不可为空'));
         exit($return_json);
     }
     if (empty($array_params['ContactMan'])) {
         $return_json = json_encode(array('status' => false, 'error_msg' => '0x120052_ContactMan联系人姓名不可为空'));
         exit($return_json);
     }
     if (empty($array_params['ContactMobile'])) {
         $return_json = json_encode(array('status' => false, 'error_msg' => '0x120053_ContactMobile联系人手机不可为空'));
         exit($return_json);
     }
     if (empty($array_params['ContactEmail'])) {
         $return_json = json_encode(array('status' => false, 'error_msg' => '0x120054_ContactEmail联系人邮箱不可为空'));
         exit($return_json);
     }
     if (empty($array_params['CustSource'])) {
         $return_json = json_encode(array('status' => false, 'error_msg' => '0x120055_CustSource会员ID不可为空'));
         exit($return_json);
     }
     if (empty($array_params['CustName'])) {
         $return_json = json_encode(array('status' => false, 'error_msg' => '0x120056_CustName会员名称不可为空'));
         exit($return_json);
     }
     if (empty($array_params['Vehicle']['CarType'])) {
         $return_json = json_encode(array('status' => false, 'error_msg' => '0x120058_CarType车型名称不可为空'));
         exit($return_json);
     }
     if (!is_int($array_params['Chn'])) {
         $return_json = json_encode(array('status' => false, 'error_msg' => '0x120061_Chn渠道必须为INT类型'));
         exit($return_json);
     }
     //对增加的属性进行判断[S]
     //给rentalcars下单
     $Rs = RcManager::MakeBookingRQ($json_params);
     //$Rs='{"status":true,"data":{"Booking":{"@attributes":{"id":"200'.time().'"}}}}';
     // $Rs='{"status":true,"data":{"Booking":{"@attributes":{"id":"521321723"}}}}';
     // $Rs= '{"status":true,"data":{"Booking":{"@attributes":{"id":"597633004"}}}}';
     $Rs_array = json_decode($Rs, true);
     $bookingRQ = array();
     //不记录用户信息卡信息[S]
     $arr_params_filter = json_decode($json_params, true);
     if (isset($arr_params_filter['PaymentInfo'])) {
         $arr_params_filter['PaymentInfo'] = array('用户信用卡数据不可记录!');
     }
     $json_params = json_encode($arr_params_filter);
     //去除用户信息卡信息[E]
     if ($Rs_array['status'] && !empty($Rs_array['data']['Booking']['@attributes']['id'])) {
         //下单成功后给bos下单
         //查询订单状态[S]
         $bookingID = $Rs_array['data']['Booking']['@attributes']['id'];
         //rentalcars下单成功后返回的订单号
         //查询订单状态[S]
         $bookArr = json_decode($json_params, true);
         $bookArr['bookingID'] = $bookingID;
         //写入brs订单日志
         if (!RcManager::MakebookingToBrs($bookArr)) {
             ApiLogManage::addRentalcars('MakebookingToBrs', json_encode($bookArr), '', '', $request_time, time(), 10);
             //记录日志
         } else {
             ApiLogManage::addRentalcars('MakebookingToBrs', json_encode($bookArr), '', '', $request_time, time(), 1);
             //记录日志
         }
         //rentalcars生成订单号后写订单到bos[S]
         $bos_rs_json = RcManager::MakeBookingToBos($bookArr);
         //rentalcars生成订单号后写订单到bos
         if (!empty($bos_rs_json->FinishPayResult)) {
             $bos_rs_finishPayResult = $bos_rs_json->FinishPayResult;
             $bos_rs_arr = json_decode($bos_rs_finishPayResult, true);
             if (!empty($bos_rs_arr['ErrorCode']) && $bos_rs_arr['ErrorCode'] !== 0) {
                 //给bos下单失败
                 ApiLogManage::addRentalcars('MakeBookingToBos', json_encode($bookArr), '', $bos_rs_finishPayResult, $request_time, time(), 10);
                 //记录日志
             } else {
                 ApiLogManage::addRentalcars('MakeBookingToBos', json_encode($bookArr), '', $bos_rs_finishPayResult, $request_time, time(), 1);
                 //记录日志
             }
         } else {
             ApiLogManage::addRentalcars('MakeBookingToBos', json_encode($bookArr), '', json_encode($bos_rs_json), $request_time, time(), 11);
             //记录日志
         }
         //rentalcars生成订单号后写订单到bos[E]
         ApiLogManage::addRentalcars('MakeBookingToRentalcars', $json_params, '', $Rs, $request_time, time(), 1);
         //记录日志
         echo $Rs;
     } else {
         ApiLogManage::addRentalcars('MakeBookingToRentalcars', $json_params, '', $Rs, $request_time, time(), 10);
         //记录日志
         echo $Rs;
     }
 }