fetchAll($sql); if ($result === false) { return Util::returnArrEr('获取周边游数据失败!'); } else { $results['list'] = $result; $results['page'] = $page + 1; $results['limit'] = $limit; return Util::returnArrSu('', $results); } } /** * Function Description:构造周边游详情返回的数据 * Function Name: getdetailes * @param $pro_id * * @return array * * @author 娄梦宁 */ function getdetailes($pro_id) { $sql = '' . "SELECT a.line_id AS pro_id, a.LINE_DESCRIBE AS tickdes, a.line_name AS zname, a.line_sub_type AS type, floor(c.CUS_PRICE) AS price FROM opera_line a LEFT JOIN opera_tickets c ON c.LINE_ID = a.LINE_ID WHERE c.cancel_flag=0 and c.cancel_flag=0 and a.line_id = $pro_id"; $result1 = $this->fetchAll($sql); $sql = '' . "SELECT img_url FROM base_img WHERE product_id = $pro_id AND IMG_TYPE = 369 ORDER BY seq_id desc"; $result2 = $this->fetchAll($sql); $sql = '' . "SELECT img_url FROM base_img WHERE product_id = $pro_id AND IMG_TYPE = 374 ORDER BY seq_id desc "; $result3 = $this->fetchAll($sql); $sql = '' . "SELECT img_url FROM base_img WHERE product_id = $pro_id AND IMG_TYPE = 375 ORDER BY seq_id desc"; $result4 = $this->fetchAll($sql); if ($result1 === false || $result2 === false || $result3 === false) { return Util::returnArrEr("数据错误"); } else { $result = $result1[0]; foreach ($result2 as $key => $val) { $result2[$key] = $val['img_url']; } foreach ($result3 as $key => $val) { $result3[$key] = $val['img_url']; } foreach ($result4 as $key => $val) { $result4[$key] = $val['img_url']; } $result['topimg'] = $result2; $result['otherimg'] = $result3; $result['notice'] = $result4; return Util::returnArrSu("", $result); } } /** * Function Description:获取周边游下单详细数据 * Function Name: getorders * @param $pro_id * @param $date * @param $pnum * * @return array * * @author 娄梦宁 */ function getorders($pro_id, $date, $pnum) { //周一至周四使用零售价CUS_PRICE,周567使用分销价PROD_PRICE $week1 = date('w', strtotime($date)); if ($week1 >= 5 || $week1 === 0) { $pricetype = 'c.PROD_PRICE'; } else { $pricetype = 'c.CUS_PRICE'; } $sql = '' . "SELECT a.line_id AS pro_id, a.LINE_DESCRIBE AS tickdes, a.line_name AS zname, $pricetype AS price FROM opera_line a LEFT JOIN opera_tickets c ON c.LINE_ID = a.LINE_ID WHERE a.line_id = $pro_id and a.cancel_flag=0 and c.cancel_flag=0 "; $result1 = $this->fetchAll($sql); $sql = '' . "SELECT a.START_TIME, b.res_name, day_num FROM opera_line_group a LEFT JOIN base_resource b ON a.start_res_id = b.res_id WHERE a.line_id = $pro_id and a.cancel_flag=0 and b.cancel_flag=0 GROUP BY b.area_id ORDER BY day_num,seq_id "; $result2 = $this->fetchAll($sql); if ($result1 === false || $result2 === false) { return Util::returnArrEr("数据错误"); } else { $result = $result1[0]; $result['start_date'] = date("Y年m月d日", strtotime($date)); $cnt = count($result2) - 1; $datenum = $result2[1]['day_num'] - 1; $result['end_date'] = date("Y年m月d日", strtotime("$date +$datenum day")); $result['price'] = $result['price'] * $pnum; $result['start_time'] = $result2[0]['START_TIME']; $result['start_area'] = $result2[0]['res_name']; $result['end_area'] = $result2[$cnt]['res_name']; $result['end_time'] = $result2[$cnt]['START_TIME']; return Util::returnArrSu("", $result); } } /** * Function Description:构造12.29之前的日期价格数组 * Function Name: getdate * @param $pro_id * * @return array * * @author 娄梦宁 */ public function getdate($pro_id) { $sql = '' . "select CUS_PRICE,PROD_PRICE from opera_tickets where line_id=$pro_id and cancel_flag=0"; $price = $this->fetchRow($sql); if ($price === false) { return Util::returnArrEr("数据查询错误"); } else { $price1 = $price['CUS_PRICE']; $price2 = $price['PROD_PRICE']; $result = array(); $timer = date('H', time()); if ($timer > 13) { $timer1 = strtotime('+2 day'); } else { $timer1 = strtotime('+1 day'); } for ($i = $timer1; $i < strtotime('2018-01-01'); $i += 86400) { $thisdate = date('Y-m-d', $i); $week = date('w', $i); if ($week >= 5 || $week == 0) { $result[] = array( 'date' => $thisdate, 'price' => $price2 ); } else { $result[] = array( 'date' => $thisdate, 'price' => $price1 ); } } return Util::returnArrSu("", $result); } } public function makeorders($arr) { //判断价格是否正确 $start_date = $arr['para_start_date']; $week_type = date('w', $start_date); if ($week_type < 5 || $week_type > 0) { $price_str = 'cus_price'; } else { $price_str = 'prod_price'; }; $sql = '' . "select $price_str from opera_tickets where line_id=$arr[para_line_id] and cancel_flag=0"; $check_price = $this->fetchOne($sql); if ($check_price != $arr['para_price']) { return Util::returnArrEr("数据错误"); } //判断剩余座位是否足够 $pro_id = $arr['para_line_id']; $p_num = $arr['para_count']; $sql = '' . "SELECT seat_count - saled_count as seat FROM run_bus WHERE run_id IN ( SELECT run_id FROM run_main WHERE prod_id IN ( SELECT sub_line_id FROM opera_line_group WHERE line_id = $pro_id ) AND run_date = '$start_date' and run_status=138 and cancel_flag=0 ) "; $seat_count = $this->fetchAll($sql); foreach ($seat_count as $val) { if ($val['seat'] < $p_num) { return Util::returnArrEr('剩余座位不够'); } } $sql = '' . "SELECT DISTINCT start_res_id, end_res_id FROM opera_line_group WHERE line_id = $pro_id and cancel_flag=0 "; $res_id = $this->fetchAll($sql); $res_id_go = $res_id[0]['start_res_id']; $cnt = count($res_id) - 1; $res_back_id = $res_id[$cnt]['start_res_id']; $contacts = $arr['para_remark']; $sql = '' . "select `name`,id_num from wechat_customer where id in ($contacts)"; $contacts = $this->fetchAll($sql); $count = count($contacts); while ($count < $p_num) { $contacts[] = $contacts[0]; $count++; } $para_contact = '{'; foreach ($contacts as $val) { $para_contact .= $val['name'] . ',' . $val['id_num'] . '|'; } $para_contact = "'" . substr_replace($para_contact, '}', -1, 1) . "'"; $sql = "call sp_make_order_wechat(2,$arr[para_line_id],'$arr[para_start_date]',$res_id_go,$res_back_id,$arr[para_count],'$arr[para_contact]',$para_contact,$arr[para_price]) "; $result = $this->procQuery($sql); if ($result['code'] === 0) { $newid = $result['data'][0][0]['order_id']; $user_id = LoginTool::$userId; $sql = '' . "update order_main set OUTSIDE_SALE_ORG_ID=164,SALES_MAN='吴昊',MEMBER_ID=$user_id,order_prod_type=369 where (order_id=$newid or parent_order_id=$newid)"; $result1 = $this->execSql($sql); $orderMain = new OrderMain(); $result2 = $orderMain->updateBookStatus($newid); if ($result2['flag']) { if ($result1) { $siteConfig = Util::getSiteConfig(); $url = "{$siteConfig['host_name']}/wechat/WxPay/realpay/weChatShopPay.php?order_id={$newid}"; return Util::returnArrSu('', '', $url); } else { return Util::returnArrEr("修改订单状态出错"); } } } return Util::returnArrEr("订单提交失败"); } }