|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- <?php
- /**
- *
- * ============================================================================
- * * 版权所有 蜘蛛出行 * *
- * 网站地址: http://www.zhizhuchuxing.com
- * ----------------------------------------------------------------------------
- * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和
- * 使用;不允许对程序代码以任何形式任何目的的再发布。
- * ============================================================================
- * Author By: 温依莅
- * PhpStorm GroupOrder.php
- * Create By 2017/7/13 17:26 $
- */
-
-
- namespace console\models;
-
- use backend\modules\api\util\Util;
- use backend\modules\zzcs\models\OrderTitleCancelRequest;
- use common\models\Msg;
- use backend\modules\api\models\OrderTitle;
- use backend\modules\api\models\OperaTouristCommon;
- use backend\modules\api\models\OrderSendMessage;
- use common\util\CtripUtil;
- use Yii;
-
-
- class GroupOrder
- {
- /**
- * Function Description:对自由行产品已确认订单发送预订成功短信
- * Function Name: sendBookMsg
- *
- * @author 温依莅
- */
- public function sendBookMsg()
- {
- //1,获取需要发送短信的自由行组合订单
- $order_title = new OrderTitle();
- $order_arr = $order_title->getConfirmedOrders();
- if (!$order_arr) {
- return;
- }
- //2,循环自由行订单组发送短信
- foreach ($order_arr as $k => $v) {
- //2.1,获取需要发送的短信内容
- $res_arr = $this->getMsgContent($v['tourist_id'], $v['order_title_id']);
- if ($res_arr) {
- //2.2,发送短信
- $tmp = $order_title->updateMsgStatus($v['order_title_id']);
- if (!$tmp) {
- return;
- }
- $send_res = Msg::sendTelMsg($res_arr['phone'], $res_arr['content'],$v['main_corp_id']);
- //2.3,短信发送记录存入数据库
- OrderSendMessage::addTouristMsg($v['order_title_id'], $res_arr['phone'], $res_arr['content'], $send_res, 1);
-
- }
- }
-
-
- }
-
- /**
- * Function Description:获取该自由行产品需要发送的短信内容
- * Function Name: getMsgContent
- * @param int $tourist_id 自由行产品id
- *
- * @return array
- *
- * @author 温依莅
- */
- public function getMsgContent($tourist_id, $order_title_id)
- {
- $order_title = new OrderTitle();
- //1,获取短信模板内容
- $tourist_res = OperaTouristCommon::getTouristMsg($tourist_id);
- if (!isset($tourist_res['message'])) {
- return array();
- }
- $content = $tourist_res['message'];
- //2,根据自由行订单新替换通配符得到短信发送内容
- $title_res = $order_title->getTitleInfo($order_title_id);
- $phone = $title_res['cus_phone'];
-
- $content = str_replace("{成人数}", $title_res['adult_num'], $content);
- $content = str_replace("{儿童数}", $title_res['child_num'], $content);
- $content = str_replace("{出发日期}", $title_res['start_date'], $content);
- $content = str_replace("{产品名}", $title_res['order_title_prod_name'], $content);
-
-
- return array('phone' => $phone, 'content' => $content);
-
- }
-
- public function ctripNoticeOrderCancel()
- {
- $orderTitleCancelRequest = new OrderTitleCancelRequest();
- $getCancelOutTimes = $orderTitleCancelRequest->getCancelOutTimes();
- if (empty($getCancelOutTimes['0']['order_title_id'])) {
- return Util::returnArrSu('no doing');
- }
- foreach ($getCancelOutTimes as $val) {
- $order_id = $val['order_title_id'];
- CtripUtil::NoticeOrderCancel($order_id, 4);
- }
- return Util::returnArrSu();
-
- }
- }
|