Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 
 

215 wiersze
6.8 KiB

  1. <?php
  2. /**
  3. *
  4. * ============================================================================
  5. * * 版权所有 蜘蛛出行 * *
  6. * 网站地址: http://www.zhizhuchuxing.com
  7. * ----------------------------------------------------------------------------
  8. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和
  9. * 使用;不允许对程序代码以任何形式任何目的的再发布。
  10. * ============================================================================
  11. * Author By: 娄梦宁
  12. * PhpStorm MyTripService.php
  13. * Create By 2016/11/29 9:35 $
  14. */
  15. namespace MyTrip\Service;
  16. use Base\Tool\Tool;
  17. use MyTrip\Model\MyTrip;
  18. use Order\Model\OrdersModel;
  19. use Order\Service\OrderService;
  20. use Trip\Model\TripModel;
  21. use Util\Util\Util;
  22. class MyTripService
  23. {
  24. /**
  25. * Function Description:我的行程列表
  26. * Function Name: getTripList
  27. * @param $arr
  28. *
  29. * @return array
  30. *
  31. * @author 娄梦宁
  32. */
  33. public function indexList($arr)
  34. {
  35. $checkParam = self::checkParamList($arr);
  36. $minToStr = new TripModel();
  37. if ($checkParam == false) {
  38. return Util::returnArrEr('参数错误');
  39. }
  40. $getResult = new MyTrip();
  41. //获取当前用户可用行程订单id
  42. $orderArr = $getResult->getOrderArr($arr);
  43. if (!$orderArr) {
  44. return Util::returnArrEr('没有行程');
  45. }
  46. $aroundOrderId = '';
  47. $normalOrderId = '';
  48. foreach ($orderArr as $key => $val) {
  49. if ($val['type'] == 369) {
  50. $aroundOrderId .= $val['order_id'] . ',';
  51. } else {
  52. $normalOrderId .= $val['order_id'] . ',';
  53. }
  54. }
  55. //普通订单数据查询
  56. if ($normalOrderId != '') {
  57. $normalOrderId = rtrim($normalOrderId, ',');
  58. $normalDate = $getResult->normalDate($normalOrderId);
  59. if ($normalDate) {
  60. foreach ($normalDate as $key => $val) {
  61. $normalDate[$key]['minutes'] = $minToStr->minstr($val['minutes']);
  62. }
  63. }
  64. } else {
  65. $normalDate = array();
  66. }
  67. //周边游订单数据查询
  68. if ($aroundOrderId != '') {
  69. $aroundOrderId = rtrim($aroundOrderId, ',');
  70. $aroundDate = $getResult->aroundDate($aroundOrderId);
  71. } else {
  72. $aroundDate = array();
  73. }
  74. $result = array_merge($normalDate, $aroundDate);
  75. if ($result) {
  76. //按出行时间重新排序
  77. $newResult = array();
  78. foreach ($result as $key => $val) {
  79. $run_date = $val['run_date'] . ' ' . $val['run_time'];
  80. $k = strtotime("$run_date") . $val['order_id'];
  81. $newResult[$k] = $result[$key];
  82. }
  83. if ($arr['type'] == 147) {
  84. krsort($newResult);
  85. } else {
  86. ksort($newResult);
  87. }
  88. $newResult = array_values($newResult);
  89. $result1 = array(
  90. 'list' => $newResult
  91. );
  92. $result1['page'] = array(
  93. 'page_size' => $arr['limit'],
  94. 'current_page' => $arr['page']
  95. );
  96. return Util::returnArrSu('', $result1);
  97. }
  98. return Util::returnArrEr('数据错误');
  99. }
  100. /**
  101. * Function Description:电子票
  102. * Function Name: getEticket
  103. * @param $arr
  104. *
  105. * @return array
  106. *
  107. * @author 娄梦宁
  108. */
  109. public function getEticket($arr)
  110. {
  111. $checkParam = Util::checkPattern('intVal', $arr['order_id']);
  112. if ($checkParam == false) {
  113. return Util::returnArrEr('参数错误');
  114. }
  115. $getResult = new MyTrip();
  116. $result = $getResult->getEticket($arr);
  117. if ($result) {
  118. $today = date('Y-m-d', time());
  119. if ($today == $result['date']) {
  120. $result['week'] = '今天';
  121. } else {
  122. $result['week'] = Tool::getWeek($result['date']);
  123. };
  124. //是否检票
  125. $isCheck = $getResult->isCheck($result['order_id']);
  126. if (count($isCheck)) {
  127. $result['status'] = 1;
  128. } else {
  129. $result['status'] = 0;
  130. }
  131. //生成电子票图片
  132. $ser = new OrderService();
  133. $result['eurl'] = $ser->getETicket($arr['order_id']);
  134. $config = Util::getSiteConfig();
  135. $result['eurl'] = $config['host_name'] . $result['eurl'];
  136. $go_back = new OrdersModel();
  137. $go_back1 = $go_back->getBack($arr['order_id']);
  138. if ($go_back1) {
  139. $result['trip_type'] = '往返程';
  140. } else {
  141. $result['trip_type'] = '单程';
  142. }
  143. return Util::returnArrSu("", $result);
  144. }
  145. return Util::returnArrEr("没有数据");
  146. }
  147. /**
  148. * Function Description:行程列表参数校验
  149. * Function Name: checkParamList
  150. * @param $arr
  151. *
  152. * @return bool
  153. *
  154. * @author 娄梦宁
  155. */
  156. public function checkParamList($arr)
  157. {
  158. if (Util::checkPattern('intVal', $arr['page']) == false) {
  159. return false;
  160. } elseif (Util::checkPattern('intVal', $arr['userId']) == false) {
  161. return false;
  162. } elseif (Util::checkPattern('intVal', $arr['limit']) == false) {
  163. return false;
  164. } elseif (Util::checkPattern('', $arr['type'], '/146|147/') == false) {
  165. return false;
  166. }
  167. return true;
  168. }
  169. /**
  170. * Function Description:绑定订单
  171. * Function Name: tripBind
  172. * @param $arr
  173. *
  174. * @return array
  175. *
  176. * @author 娄梦宁
  177. */
  178. public function tripBind($arr)
  179. {
  180. if (Util::checkPattern('mobile', $arr['tel']) == false) {
  181. return Util::returnArrEr('参数错误');
  182. }
  183. //获取该手机号下所有订单
  184. $getResult = new MyTrip();
  185. $getAllOrder = $getResult->getAllOrder($arr['tel']);
  186. if (!$getAllOrder) {
  187. return Util::returnArrEr("该手机号没有可绑定行程");
  188. }
  189. //绑定
  190. $tripBind = $getResult->tripBind($arr);
  191. if ($tripBind == 0) {
  192. return Util::returnArrEr("没有可绑定的行程");
  193. }
  194. //将member_id为空的置换为当前用户id
  195. // $orderStr = "";
  196. // foreach ($getAllOrder as $val) {
  197. // $orderStr .= ',' . $val['order_id'];
  198. // }
  199. // $orderStr = ltrim($orderStr, ',');
  200. // $uptOrder = $getResult->uptOrder($orderStr, $arr['userId']);
  201. // if ($uptOrder['flag'] == false) {
  202. // return Util::returnArrEr('绑定失败');
  203. // }
  204. return Util::returnArrSu("绑定成功");
  205. }
  206. }