|
- <?php
- /**
- * Created by PhpStorm.
- * User: wangxj
- * Date: 2017/7/5
- * Time: 15:25
- */
-
- namespace backend\modules\hotel\models;
-
- use backend\common\Utils;
- use yii\data\ArrayDataProvider;
- use yii\debug\components\search\Filter;
- use yii\debug\models\search\Base;
-
- class SoapLog extends Base
- {
- const ATTRIBUTES = [
- 'date' => true,
- 'time' => true,
- 'action' => true,
- 'ctrip_request' => true,
- 'ctrip_new_hotel_name' => true,
- 'ctrip_hotel_id' => true,
- 'ctrip_new_hotel_id' => true,
- 'ctrip_room_id' => true,
- 'ctrip_new_room_id' => true,
- 'ctrip_new_room_name' => true,
- 'ctrip_arrival' => true,
- 'ctrip_departure' => true,
- 'ctrip_new_order_id' => true,
- 'ctrip_new_arrival' => true,
- 'ctrip_new_departure' => true,
- 'ctrip_prices' => true,
- 'ctrip_new_prices' => true,
- 'ctrip_number' => true,
- 'ctrip_new_number' => true,
- 'ctrip_new_guests' => true,
- 'ctrip_new_notice' => true,
- 'ctrip_hold' => true,
- 'ctrip_new_hold' => true,
- 'ctrip_new_free_sale' => true,
- 'ctrip_new_request' => true,
-
- 'ctrip_cancel_order_id' => true,
- 'ctrip_cancel_hotel_id' => true,
- 'ctrip_cancel_hotel_name' => true,
- 'ctrip_cancel_arrival' => true,
- 'ctrip_cancel_departure' => true,
- 'ctrip_cancel_room_id' => true,
- 'ctrip_cancel_guests' => true,
- 'ctrip_cancel_number' => true,
- 'ctrip_cancel_request' => true,
-
- 'spider_response' => true,
- 'spider_status' => true,
- 'spider_new_response' => true,
- 'spider_new_status' => true,
- 'spider_new_status_desc' => true,
- 'spider_cancel_response' => true,
- 'spider_cancel_status' => true,
- 'spider_cancel_status_desc' => true,
- ];
- const ACTION_ARRAY = [
- 'DomesticCheckRoomAvail' => '可订检查',
- 'DomesticSubmitNewHotelOrder' => '新订',
- 'DomesticCancelHotelOrder' => '取消订单',
- 'DomesticGetOrderStatus' => '状态查询',
- ];
- public $date;
- public $time;
- public $action;
- public $ctrip_new_hotel_name;
- public $ctrip_hotel_id;
- public $ctrip_new_hotel_id; //新订的酒店id
- public $ctrip_room_id;
- public $ctrip_new_room_id;
- public $ctrip_new_room_name;
- public $ctrip_arrival;
- public $ctrip_departure;
- public $ctrip_new_order_id;
- public $ctrip_new_arrival;
- public $ctrip_new_departure;
- public $ctrip_prices; //价格构成
- public $ctrip_new_prices; //价格构成
- public $ctrip_new_guests; //客人信息
- public $ctrip_number; //间数
- public $ctrip_new_number; //间数
- public $ctrip_new_notice; //间数
- public $ctrip_hold; //是否保留房
- public $ctrip_new_hold; //是否保留房
- public $ctrip_new_free_sale; //是否超卖
- public $ctrip_request; //
- public $ctrip_new_request; //
-
- public $ctrip_cancel_order_id;
- public $ctrip_cancel_hotel_id;
- public $ctrip_cancel_hotel_name;
- public $ctrip_cancel_arrival;
- public $ctrip_cancel_departure;
- public $ctrip_cancel_room_id;
- public $ctrip_cancel_number;
- public $ctrip_cancel_guests;
- public $ctrip_cancel_room_name;
- public $ctrip_cancel_request;
-
- public $spider_response;
- public $spider_new_response;
- public $spider_cancel_response;
- public $spider_avail;
- public $spider_status;
- public $spider_new_status;
- public $spider_cancel_status;
- public $spider_new_status_desc;
- public $spider_cancel_status_desc;
-
- public $search_room_id;
-
- public function rules()
- {
- return [
- [['action', 'date', 'ctrip_hotel_id', 'search_room_id', 'ctrip_room_id', 'ctrip_hold', 'ctrip_arrival', 'ctrip_departure', 'ctrip_new_guests', 'spider_status'], 'safe'],
- ];
- }
-
- public function search($params, $models)
- {
- $dataProvider = new ArrayDataProvider([
- 'allModels' => $models,
- 'sort' => false,
- 'pagination' => [
- 'pageSize' => 25,
- ],
- ]);
- $this->load($params);
- $filter = new Filter();
- $attributes = self::ATTRIBUTES;
- foreach ($attributes as $attribute => $filterType) {
- $this->addCondition($filter, $attribute, $filterType);
- }
-
- $dataProvider->allModels = $filter->filter($models);
-
- return $dataProvider;
- }
-
- public function attributeLabels()
- {
- return [
- 'date'=> '请求时间',
- 'action' => '请求操作',
- 'time' => true,
- 'ctrip_new_hotel_name' => true,
- 'ctrip_hotel_id' => true,
- 'ctrip_new_hotel_id' => true,
- 'ctrip_room_id' => '房型',
- 'ctrip_new_room_id' => true,
- 'ctrip_new_room_name' => '房型',
- 'search_room_id' => '房型',
- 'ctrip_arrival' => '入住时间',
- 'ctrip_departure' => '离店时间',
- 'ctrip_new_order_id' => '订单号',
- 'ctrip_new_arrival' => true,
- 'ctrip_new_departure' => true,
- 'ctrip_new_guests' => true,
- 'ctrip_prices' => '价格组成',
- 'ctrip_number' => '间数',
- 'ctrip_hold' => '保留房',
- 'ctrip_new_notice' => '备注',
- 'ctrip_new_hold' => true,
- 'ctrip_new_free_sale' => '超卖',
- 'spider_response' => '返回数据',
- 'spider_avail' => '可订状态',
- 'spider_status' => '返回状态',
- 'spider_new_response' => true,
- 'spider_new_status' => true,
- 'spider_new_status_desc' => '返回信息',
- ];
- }
-
- public static function titleFormat($str){
- return preg_replace('/RoomPrice><RoomPrice/', 'RoomPrice>
<RoomPrice', $str);
- }
-
- public static function getGuestName($array){
- $customer_name = '';
- $guests = isset($array['GuestEntity'][0]) ? $array['GuestEntity'] : $array;
- if (is_array($guests)) {
- foreach ($guests as $GuestEntity) {
- $FirstName = empty($GuestEntity['FirstName']) ? '' : $GuestEntity['FirstName'];
- $LastName = empty($GuestEntity['LastName']) ? '' : $GuestEntity['LastName'];
- if ($customer_name == '' || (strstr($GuestEntity['ChinesName'], trim($customer_name)) == false && strstr(($FirstName . ' ' . $LastName), trim($customer_name)) == false)) {
- $customer_name .= empty($GuestEntity['ChinesName']) ? ($FirstName . ' ' . $LastName) : $GuestEntity['ChinesName'] . ' ';
- }
- }
- }
- return $customer_name;
- }
- }
|