|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215 |
- <?php
- /**
- *
- * ============================================================================
- * * 版权所有 蜘蛛出行 * *
- * 网站地址: http://www.zhizhuchuxing.com
- * ----------------------------------------------------------------------------
- * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和
- * 使用;不允许对程序代码以任何形式任何目的的再发布。
- * ============================================================================
- * Author By: 娄梦宁
- * PhpStorm MyTripService.php
- * Create By 2016/11/29 9:35 $
- */
-
-
- namespace MyTrip\Service;
-
-
- use Base\Tool\Tool;
- use MyTrip\Model\MyTrip;
- use Order\Model\OrdersModel;
- use Order\Service\OrderService;
- use Trip\Model\TripModel;
- use Util\Util\Util;
-
- class MyTripService
- {
- /**
- * Function Description:我的行程列表
- * Function Name: getTripList
- * @param $arr
- *
- * @return array
- *
- * @author 娄梦宁
- */
- public function indexList($arr)
- {
- $checkParam = self::checkParamList($arr);
- $minToStr = new TripModel();
- if ($checkParam == false) {
- return Util::returnArrEr('参数错误');
- }
- $getResult = new MyTrip();
- //获取当前用户可用行程订单id
- $orderArr = $getResult->getOrderArr($arr);
- if (!$orderArr) {
- return Util::returnArrEr('没有行程');
- }
- $aroundOrderId = '';
- $normalOrderId = '';
- foreach ($orderArr as $key => $val) {
- if ($val['type'] == 369) {
- $aroundOrderId .= $val['order_id'] . ',';
- } else {
- $normalOrderId .= $val['order_id'] . ',';
- }
- }
- //普通订单数据查询
- if ($normalOrderId != '') {
- $normalOrderId = rtrim($normalOrderId, ',');
- $normalDate = $getResult->normalDate($normalOrderId);
- if ($normalDate) {
- foreach ($normalDate as $key => $val) {
- $normalDate[$key]['minutes'] = $minToStr->minstr($val['minutes']);
- }
- }
- } else {
- $normalDate = array();
- }
- //周边游订单数据查询
- if ($aroundOrderId != '') {
- $aroundOrderId = rtrim($aroundOrderId, ',');
- $aroundDate = $getResult->aroundDate($aroundOrderId);
- } else {
- $aroundDate = array();
- }
- $result = array_merge($normalDate, $aroundDate);
- if ($result) {
- //按出行时间重新排序
- $newResult = array();
- foreach ($result as $key => $val) {
- $run_date = $val['run_date'] . ' ' . $val['run_time'];
-
- $k = strtotime("$run_date") . $val['order_id'];
- $newResult[$k] = $result[$key];
- }
- if ($arr['type'] == 147) {
- krsort($newResult);
- } else {
- ksort($newResult);
- }
- $newResult = array_values($newResult);
- $result1 = array(
- 'list' => $newResult
- );
- $result1['page'] = array(
- 'page_size' => $arr['limit'],
- 'current_page' => $arr['page']
- );
- return Util::returnArrSu('', $result1);
- }
- return Util::returnArrEr('数据错误');
- }
-
- /**
- * Function Description:电子票
- * Function Name: getEticket
- * @param $arr
- *
- * @return array
- *
- * @author 娄梦宁
- */
- public function getEticket($arr)
- {
- $checkParam = Util::checkPattern('intVal', $arr['order_id']);
- if ($checkParam == false) {
- return Util::returnArrEr('参数错误');
- }
- $getResult = new MyTrip();
- $result = $getResult->getEticket($arr);
- if ($result) {
- $today = date('Y-m-d', time());
- if ($today == $result['date']) {
- $result['week'] = '今天';
- } else {
- $result['week'] = Tool::getWeek($result['date']);
- };
- //是否检票
- $isCheck = $getResult->isCheck($result['order_id']);
- if (count($isCheck)) {
- $result['status'] = 1;
- } else {
- $result['status'] = 0;
- }
- //生成电子票图片
- $ser = new OrderService();
- $result['eurl'] = $ser->getETicket($arr['order_id']);
- $config = Util::getSiteConfig();
- $result['eurl'] = $config['host_name'] . $result['eurl'];
- $go_back = new OrdersModel();
- $go_back1 = $go_back->getBack($arr['order_id']);
- if ($go_back1) {
- $result['trip_type'] = '往返程';
- } else {
- $result['trip_type'] = '单程';
- }
- return Util::returnArrSu("", $result);
- }
- return Util::returnArrEr("没有数据");
- }
-
- /**
- * Function Description:行程列表参数校验
- * Function Name: checkParamList
- * @param $arr
- *
- * @return bool
- *
- * @author 娄梦宁
- */
- public function checkParamList($arr)
- {
- if (Util::checkPattern('intVal', $arr['page']) == false) {
- return false;
- } elseif (Util::checkPattern('intVal', $arr['userId']) == false) {
- return false;
- } elseif (Util::checkPattern('intVal', $arr['limit']) == false) {
- return false;
- } elseif (Util::checkPattern('', $arr['type'], '/146|147/') == false) {
- return false;
- }
- return true;
- }
-
- /**
- * Function Description:绑定订单
- * Function Name: tripBind
- * @param $arr
- *
- * @return array
- *
- * @author 娄梦宁
- */
- public function tripBind($arr)
- {
- if (Util::checkPattern('mobile', $arr['tel']) == false) {
- return Util::returnArrEr('参数错误');
- }
- //获取该手机号下所有订单
- $getResult = new MyTrip();
- $getAllOrder = $getResult->getAllOrder($arr['tel']);
- if (!$getAllOrder) {
- return Util::returnArrEr("该手机号没有可绑定行程");
- }
- //绑定
- $tripBind = $getResult->tripBind($arr);
- if ($tripBind == 0) {
- return Util::returnArrEr("没有可绑定的行程");
- }
- //将member_id为空的置换为当前用户id
- // $orderStr = "";
- // foreach ($getAllOrder as $val) {
- // $orderStr .= ',' . $val['order_id'];
- // }
- // $orderStr = ltrim($orderStr, ',');
- // $uptOrder = $getResult->uptOrder($orderStr, $arr['userId']);
- // if ($uptOrder['flag'] == false) {
- // return Util::returnArrEr('绑定失败');
- // }
- return Util::returnArrSu("绑定成功");
- }
- }
|