You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

199 lines
6.7 KiB

  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: wangxj
  5. * Date: 2017/7/5
  6. * Time: 15:25
  7. */
  8. namespace backend\modules\hotel\models;
  9. use backend\common\Utils;
  10. use yii\data\ArrayDataProvider;
  11. use yii\debug\components\search\Filter;
  12. use yii\debug\models\search\Base;
  13. class SoapLog extends Base
  14. {
  15. const ATTRIBUTES = [
  16. 'date' => true,
  17. 'time' => true,
  18. 'action' => true,
  19. 'ctrip_request' => true,
  20. 'ctrip_new_hotel_name' => true,
  21. 'ctrip_hotel_id' => true,
  22. 'ctrip_new_hotel_id' => true,
  23. 'ctrip_room_id' => true,
  24. 'ctrip_new_room_id' => true,
  25. 'ctrip_new_room_name' => true,
  26. 'ctrip_arrival' => true,
  27. 'ctrip_departure' => true,
  28. 'ctrip_new_order_id' => true,
  29. 'ctrip_new_arrival' => true,
  30. 'ctrip_new_departure' => true,
  31. 'ctrip_prices' => true,
  32. 'ctrip_new_prices' => true,
  33. 'ctrip_number' => true,
  34. 'ctrip_new_number' => true,
  35. 'ctrip_new_guests' => true,
  36. 'ctrip_new_notice' => true,
  37. 'ctrip_hold' => true,
  38. 'ctrip_new_hold' => true,
  39. 'ctrip_new_free_sale' => true,
  40. 'ctrip_new_request' => true,
  41. 'ctrip_cancel_order_id' => true,
  42. 'ctrip_cancel_hotel_id' => true,
  43. 'ctrip_cancel_hotel_name' => true,
  44. 'ctrip_cancel_arrival' => true,
  45. 'ctrip_cancel_departure' => true,
  46. 'ctrip_cancel_room_id' => true,
  47. 'ctrip_cancel_guests' => true,
  48. 'ctrip_cancel_number' => true,
  49. 'ctrip_cancel_request' => true,
  50. 'spider_response' => true,
  51. 'spider_status' => true,
  52. 'spider_new_response' => true,
  53. 'spider_new_status' => true,
  54. 'spider_new_status_desc' => true,
  55. 'spider_cancel_response' => true,
  56. 'spider_cancel_status' => true,
  57. 'spider_cancel_status_desc' => true,
  58. ];
  59. const ACTION_ARRAY = [
  60. 'DomesticCheckRoomAvail' => '可订检查',
  61. 'DomesticSubmitNewHotelOrder' => '新订',
  62. 'DomesticCancelHotelOrder' => '取消订单',
  63. 'DomesticGetOrderStatus' => '状态查询',
  64. ];
  65. public $date;
  66. public $time;
  67. public $action;
  68. public $ctrip_new_hotel_name;
  69. public $ctrip_hotel_id;
  70. public $ctrip_new_hotel_id; //新订的酒店id
  71. public $ctrip_room_id;
  72. public $ctrip_new_room_id;
  73. public $ctrip_new_room_name;
  74. public $ctrip_arrival;
  75. public $ctrip_departure;
  76. public $ctrip_new_order_id;
  77. public $ctrip_new_arrival;
  78. public $ctrip_new_departure;
  79. public $ctrip_prices; //价格构成
  80. public $ctrip_new_prices; //价格构成
  81. public $ctrip_new_guests; //客人信息
  82. public $ctrip_number; //间数
  83. public $ctrip_new_number; //间数
  84. public $ctrip_new_notice; //间数
  85. public $ctrip_hold; //是否保留房
  86. public $ctrip_new_hold; //是否保留房
  87. public $ctrip_new_free_sale; //是否超卖
  88. public $ctrip_request; //
  89. public $ctrip_new_request; //
  90. public $ctrip_cancel_order_id;
  91. public $ctrip_cancel_hotel_id;
  92. public $ctrip_cancel_hotel_name;
  93. public $ctrip_cancel_arrival;
  94. public $ctrip_cancel_departure;
  95. public $ctrip_cancel_room_id;
  96. public $ctrip_cancel_number;
  97. public $ctrip_cancel_guests;
  98. public $ctrip_cancel_room_name;
  99. public $ctrip_cancel_request;
  100. public $spider_response;
  101. public $spider_new_response;
  102. public $spider_cancel_response;
  103. public $spider_avail;
  104. public $spider_status;
  105. public $spider_new_status;
  106. public $spider_cancel_status;
  107. public $spider_new_status_desc;
  108. public $spider_cancel_status_desc;
  109. public $search_room_id;
  110. public function rules()
  111. {
  112. return [
  113. [['action', 'date', 'ctrip_hotel_id', 'search_room_id', 'ctrip_room_id', 'ctrip_hold', 'ctrip_arrival', 'ctrip_departure', 'ctrip_new_guests', 'spider_status'], 'safe'],
  114. ];
  115. }
  116. public function search($params, $models)
  117. {
  118. $dataProvider = new ArrayDataProvider([
  119. 'allModels' => $models,
  120. 'sort' => false,
  121. 'pagination' => [
  122. 'pageSize' => 25,
  123. ],
  124. ]);
  125. $this->load($params);
  126. $filter = new Filter();
  127. $attributes = self::ATTRIBUTES;
  128. foreach ($attributes as $attribute => $filterType) {
  129. $this->addCondition($filter, $attribute, $filterType);
  130. }
  131. $dataProvider->allModels = $filter->filter($models);
  132. return $dataProvider;
  133. }
  134. public function attributeLabels()
  135. {
  136. return [
  137. 'date'=> '请求时间',
  138. 'action' => '请求操作',
  139. 'time' => true,
  140. 'ctrip_new_hotel_name' => true,
  141. 'ctrip_hotel_id' => true,
  142. 'ctrip_new_hotel_id' => true,
  143. 'ctrip_room_id' => '房型',
  144. 'ctrip_new_room_id' => true,
  145. 'ctrip_new_room_name' => '房型',
  146. 'search_room_id' => '房型',
  147. 'ctrip_arrival' => '入住时间',
  148. 'ctrip_departure' => '离店时间',
  149. 'ctrip_new_order_id' => '订单号',
  150. 'ctrip_new_arrival' => true,
  151. 'ctrip_new_departure' => true,
  152. 'ctrip_new_guests' => true,
  153. 'ctrip_prices' => '价格组成',
  154. 'ctrip_number' => '间数',
  155. 'ctrip_hold' => '保留房',
  156. 'ctrip_new_notice' => '备注',
  157. 'ctrip_new_hold' => true,
  158. 'ctrip_new_free_sale' => '超卖',
  159. 'spider_response' => '返回数据',
  160. 'spider_avail' => '可订状态',
  161. 'spider_status' => '返回状态',
  162. 'spider_new_response' => true,
  163. 'spider_new_status' => true,
  164. 'spider_new_status_desc' => '返回信息',
  165. ];
  166. }
  167. public static function titleFormat($str){
  168. return preg_replace('/RoomPrice><RoomPrice/', 'RoomPrice>&#013;<RoomPrice', $str);
  169. }
  170. public static function getGuestName($array){
  171. $customer_name = '';
  172. $guests = isset($array['GuestEntity'][0]) ? $array['GuestEntity'] : $array;
  173. if (is_array($guests)) {
  174. foreach ($guests as $GuestEntity) {
  175. $FirstName = empty($GuestEntity['FirstName']) ? '' : $GuestEntity['FirstName'];
  176. $LastName = empty($GuestEntity['LastName']) ? '' : $GuestEntity['LastName'];
  177. if ($customer_name == '' || (strstr($GuestEntity['ChinesName'], trim($customer_name)) == false && strstr(($FirstName . ' ' . $LastName), trim($customer_name)) == false)) {
  178. $customer_name .= empty($GuestEntity['ChinesName']) ? ($FirstName . ' ' . $LastName) : $GuestEntity['ChinesName'] . ' ';
  179. }
  180. }
  181. }
  182. return $customer_name;
  183. }
  184. }