20], ]; } /** * @inheritdoc */ public function attributeLabels() { return [ 'id' => 'ID', 'supplier_id' => 'Supplier ID', 'ticket_group_id' => 'Ticket Group ID', 'ticket_id' => 'Ticket ID', 'content1' => 'Content1', 'content2' => 'Content2', 'content3' => 'Content3', 'content4' => 'Content4', 'content5' => 'Content5', 'content6' => 'Content6', 'create_user_id' => 'Create User ID', 'create_time' => 'Create Time', 'update_user_id' => 'Update User ID', 'update_time' => 'Update Time', 'template_type' => 'Template Type', 'cancel_flag' => 'Cancel Flag', ]; } /** * Function Description:OTA获取短信内容 * Function Name: otaGetMsg * @param int $order_id * @param string $type :one 预定短信, two 出行短信 * @return mixed * * @author 温依莅 */ public function otaGetMsgInfo($order_id, $type = 'one') { $json = array(); if (!$order_id) { $json["code"] = '1'; $json["info"] = '参数不正确'; return $json; } //1,根据order_id获得短信内容 $content_arr = $this->getMsgInfo($order_id, $type); //2,部分异常处理 if ($content_arr == 'noRunInfo') { $json["code"] = '2'; $json["info"] = '无出行信息'; return $json; } if ($content_arr == 'notSend') { $json["code"] = '3'; $json["info"] = '此线路票种不发送短信'; return $json; } if ($content_arr == 'noTemplate') { $json["code"] = '4'; $json["info"] = '模板信息缺失'; return $json; } if ($content_arr == 'wrongOrderId') { $json["code"] = '5'; $json["info"] = '错误订单号'; return $json; } $name = $content_arr[0]; $tel = $content_arr[1]; $content = $content_arr[2]; $json["code"] = '0'; $json["info"] = '获取成功'; $json['name'] = $name; $json['mobile'] = $tel; $json['content'] = $content; return $json; } /** * Function Description:下单发送短信 * Function Name: orderSendMsg * @param int $order_id * @param string $template_type 使用模板类型 one:预订短信1或预定短信2(根据下单时间判断),two:出行短信,three:换车提醒短信 * @return mixed * * @author 温依莅 */ public function orderSendMsg($order_id, $template_type = 'one') { if (!$order_id) { $json["code"] = '1'; $json["info"] = '参数不正确'; return $json; } $user_id = 2;//system用户 //1,获得需要发送短信的内容 $content_arr = $this->getMsgInfo($order_id, $template_type); //2,部分异常处理 if ($content_arr == 'wrongOrderId') { $json["code"] = '2'; $json["info"] = '错误订单号'; return $json; } if ($content_arr == 'noRunInfo') { $json["code"] = '2'; $json["info"] = '无出行信息'; return $json; } if ($content_arr == 'notSend') { $json["code"] = '2'; $json["info"] = '此线路票种不发送短信'; return $json; } if ($content_arr == 'noTemplate') { $json["code"] = '2'; $json["info"] = '模板信息缺失'; return $json; } //3,根据短信相关信息发送短信 $name = $content_arr[0]; $tel = $content_arr[1]; $content = $content_arr[2]; $runInfo = isset($content_arr[3]) ? $content_arr[3] : false; $main_corp_id = $runInfo['main_corp_id'] ? $runInfo['main_corp_id'] : 1; $bus_no = trim($content_arr[4]['bus_no']);//车牌号,如果为空则认为没有派车, if (!$tel) { $json["code"] = '2'; $json["info"] = '无效手机号'; return $json; } //=============出行短信只有已派车的情况才发送===============// if ($template_type != 'two' || $bus_no) { $send_success = '-100'; //若最后记录为-100,说明未执行短信发送 $send_success = Msg::sendTelMsg($tel, $content,$main_corp_id); //4,短信记录插入order_send_message表 $current_time = date("Y-m-d H:i:s"); $send_msg_values = [ 'ORDER_ID' => $order_id, 'SEND_MOBILE' => $tel, 'SEND_MESSAGE' => $content, 'SEND_TIME' => $current_time, 'SEND_ERROR' => $send_success, 'CREATE_USER_ID' => $user_id, 'CREATE_TIME' => $current_time, 'UPDATE_USER_ID' => $user_id, 'UPDATE_TIME' => $current_time, ]; $msgRecord = new OrderSendMessage(); $msgRecord->attributes = $send_msg_values; $res = $msgRecord->insert(); } //某些特殊线路发送提醒短信 if ($runInfo != false && isset($runInfo["parent_prod_id"])) { if ($runInfo["parent_prod_id"] == 451538 || $runInfo["parent_prod_id"] == 451539 || $runInfo["parent_prod_id"] == 451524 || $runInfo["parent_prod_id"] == 451525 || $runInfo["parent_prod_id"] == 451560 || $runInfo["parent_prod_id"] == 451561) { // $alert_tel = "18106523772"; // 该手机号不发送短信了 modify nizf // $alert_content = "舟山希尔顿酒店有订单了,订单号({$order_id})"; // Msg::sendTelMsg($alert_tel, $alert_content,$main_corp_id); } else if ($runInfo["parent_prod_id"] == 451928 || $runInfo["parent_prod_id"] == 451927 || $runInfo["parent_prod_id"] == 451926 || $runInfo["parent_prod_id"] == 451929 || $runInfo["parent_prod_id"] == 451930 || $runInfo["parent_prod_id"] == 451931) { $alert_tel = "18817847097"; $alert_content = "全城接送进单了,订单号({$order_id}),出发日期:{$runInfo['start_date']}"; Msg::sendTelMsg($alert_tel, $alert_content,$main_corp_id); } } $json["code"] = '0'; $json["info"] = '短信已发送'; $json['resCode'] = $send_success; return $json; } /** * Function Description:获取票种模板 * Function Name: getTemplate * @param int $prod_id * @param int $supplier_id * @param int $line_id * @return array * * @author 温依莅 */ public function getTemplate($prod_id, $supplier_id, $line_id) { //按优先级:渠道票种>线路默认>系统默认 的顺序获取 最终预定成功短信 #1,取默认模板 $default = self::find()->where(['template_type' => 0, 'cancel_flag' => 0])->asArray()->one(); $defaultContent1 = $default['content1']; $defaultContent2 = $default['content2']; $defaultContent3 = $default['content3']; $defaultContent4 = $default['content4']; $defaultContent5 = $default['content5']; $defaultContent6 = $default['content6']; #2,查询是否有该线路类型(0固定巴士线路,705动态巴士线路)的特定模板 $typeContent1 = ''; $typeContent2 = ''; $typeContent3 = ''; $res = self::find()->select(['line_id', 'tailor_type'])->from('opera_line')->where(['line_id' => $line_id])->asArray()->limit(1)->one();// 查看线路类型 if ($res) { $line_type = $res['tailor_type']; $type_res = self::find()->where(['line_type' => $line_type, 'cancel_flag' => 0, 'template_type' => 3])->asArray()->one(); $typeContent1 = isset($type_res['content1']) ? $type_res['content1'] : ''; $typeContent2 = isset($type_res['content2']) ? $type_res['content2'] : ''; $typeContent3 = isset($type_res['content3']) ? $type_res['content3'] : ''; } #3,查询是否有该线路的特定的模板 $lineContent1 = ''; $lineContent2 = ''; $lineContent3 = ''; //3.1 温州市到舟山市450588,舟山市到温州市450589的线路模板 if (in_array($line_id, array(450588, 450589))) { $lineContent1 = $defaultContent1 . '紧急联系电话:18100158199。'; $lineContent2 = $defaultContent2 . '紧急联系电话:18100158199。'; } //3.3 杭州市-普陀山450517,普陀山-杭州450522 if ($line_id == 450517) { $lineContent1 = '您已成功预定{出发日期} {出发时间} {出发地}-{目的地}汽车票{车票张数}张(请最晚提前10分钟到达)。上车地点:吴山广场西侧河坊巷8号(吴山广场旅游集散中心候车室); 上车方式:请至吴山广场旅游集散中心候车室服务台,凭预定姓名和手机号码上车。紧急电话:15888866564。'; $lineContent2 = '您已成功预定{出发日期} {出发时间} {出发地}-{目的地}汽车票{车票张数}张(请最晚提前10分钟到达)。上车地点:吴山广场西侧河坊巷8号(吴山广场旅游集散中心候车室); 上车方式:请至吴山广场旅游集散中心候车室服务台,凭预定姓名和手机号码上车。紧急电话:15888866564。'; } else if ($line_id == 450522) { $lineContent1 = '您已成功预定{出发日期} {出发时间} {出发地}-{目的地}汽车票{车票张数}张(请最晚提前10分钟到达)。上车地点:普陀城北长途客运中心;取票方式:请提前到达(学运路18号)普陀城北长途客运中心候车大厅服务台报预订名字和电话取票。紧急电话:15888866564。'; $lineContent2 = '您已成功预定{出发日期} {出发时间} {出发地}-{目的地}汽车票{车票张数}张(请最晚提前10分钟到达)。上车地点:普陀城北长途客运中心;取票方式:请提前到达(学运路18号)普陀城北长途客运中心候车大厅服务台报预订名字和电话取票。紧急电话:15888866564。'; } #4,查询是否有该票种该渠道的特定模板 $prod = self::find()->where(['ticket_id' => $prod_id, 'supplier_id' => $supplier_id, 'cancel_flag' => 0, 'template_type' => 2])->asArray()->one(); $prodContent1 = isset($prod['content1']) ? $prod['content1'] : ''; $prodContent2 = isset($prod['content2']) ? $prod['content2'] : ''; $prodContent3 = isset($prod['content3']) ? $prod['content3'] : ''; //5,按优先级:渠道票种>线路模板>线路类型模板>系统默认 的顺序 生成最终 的模板数组(包括:预订成功1,预订成功2,出行提醒短信3) $final = array(); $final['content1'] = $prodContent1 ? $prodContent1 : ($lineContent1 ? $lineContent1 : ($typeContent1 ? $typeContent1 : $defaultContent1)); $final['content2'] = $prodContent2 ? $prodContent2 : ($lineContent2 ? $lineContent2 : ($typeContent2 ? $typeContent2 : $defaultContent2)); $final['content3'] = $prodContent3 ? $prodContent3 : ($lineContent3 ? $lineContent3 : ($typeContent3 ? $typeContent3 : $defaultContent3)); $final['content4'] = $defaultContent4; $final['content5'] = $defaultContent5; $final['content6'] = $defaultContent6; return $final; } /** * Function Description:获取下单应发短信内容 * Function Name: getMsgInfo * @param int $order_id * @param string $type :one,预定短信 two,出行短信 three 新的出行短信 * @return array * * @author 温依莅 */ public function getMsgInfo($order_id, $type = 'one') { //1获取短信模板所需参数 #1.1,获取出发时间,地点run_info $runInfo = self::find()->select([ 'count(a.id) as order_count', 'a.create_time as create_time', 'a.prod_start_station_date as start_date', 'a.prod_start_station_time as start_time', 'a.prod_end_station_date as end_date', 'a.prod_end_station_time as end_time', 'a.parent_order_id as parent_order_id', 'a.prod_start_station_area_name as start_area', 'a.prod_end_station_area_name as end_area', 'a.prod_start_station_res_name as res_name', 'a.prod_end_station_res_name as end_res_name', 'a.parent_prod_id as parent_prod_id', 'a.prod_id as prod_id', 'a.outside_sale_org_id as supplier_id', 'a.prod_name as prod_name', 'group_concat(a.run_bus_seat_name) as order_seat_list', 'a.customer_name as customer_name', 'a.customer_mobile as customer_mobile', 'a.main_corp_id', 'start_station_address' => BaseResourceProperty::find()->select('property')->where('res_id = a.prod_start_station_res_id and type_id = 279')->limit(1), ])->from(OrderMain::tableName() . ' as a') ->where(['a.parent_order_id' => $order_id, 'a.cancel_flag' => 0]) ->asArray() ->one(); #1.2,获取司机信息 $driverInfo = self::find()->select([ 'a.send_bus_res_id as bus_res_id', 'a.send_bus_no as bus_no', 'a.send_driver_name as driver_name', 'a.send_driver_mobile as driver_mobile' ])->from(RunBus::tableName() . ' as a') ->innerJoin(OrderMain::tableName() . ' as b', 'a.run_id=b.run_id and a.bus_order_id=b.run_bus_order_id') ->where(['a.cancel_flag' => 0, 'b.parent_order_id' => $order_id]) ->groupBy('a.run_id') ->asArray() ->one(); #1.3,部分异常处理 if (($runInfo['order_count'] == 0 && $runInfo['prod_id'] == null) || $runInfo['parent_order_id'] == 0) { return 'wrongOrderId'; } if (!$runInfo) { return 'noRunInfo';//无出行信息 } if ($type == 'two') { $notSendLine = array(152690, 152703, 451023, 451024, 451025, 451026, 451027, 451028, 451440, 451441, 448780, 450008, 448781, 451623, 451624, 451625, 451626, 451627, 451628, 451629, 451630, 451636, 451637, 451671, 451874, 451875, 451868, 451869);//不发送出行短信的线路 } else { $notSendLine = array(451023, 451024, 451025, 451026, 451027, 451028, 451623, 451624, 451625, 451626, 451627, 451628, 451629, 451630, 451636, 451637, 451671, 451874, 451875, 451868, 451869);//不发送预定短信的线路 451926,451927,451928,451929,451930,451931 } if (in_array($runInfo['parent_prod_id'], $notSendLine)) { return 'notSend'; } //2,获取短信模板 #根据order_id获取该订单线路拥有者的售卖渠道id $supplier_id = $this->getOwnerSupplier($order_id); $final = $this->getTemplate($runInfo['prod_id'], $supplier_id, $runInfo['parent_prod_id']); if (!$final['content1'] || !$final['content2']) { return 'noTemplate';//模板信息缺失; } //3,处理短信模板,得到真实发送的短信信息 $tomorrow = date("Y-m-d", strtotime("+1 day"));//明天日期 $now_time = date('Y-m-d H:i', time()); //现在时间 $today = date('Y-m-d', time()); //今天日期 #3.1获取ticket短链接 $long_url = 'http://ticket.' . DOMAIN . '/ticket.php?orderid=' . $order_id; $shortUrl = Msg::sinaShortenUrl($long_url); #3.2不同时间下单选用不同短信模板 if ($type == 'two') { //如果是出行短信,直接采用模板3 $content = $final['content3']; } else if ($type == 'three') { //如果是出行短信,直接采用模板3 $content = $final['content4']; } else if ($type == 'four') { //如果是出行短信,直接采用模板3 $content = $final['content5']; } else if ($type == 'five') { //如果是出行短信,直接采用模板3 $content = $final['content6']; } else { $pre_hour = date("Y-m-d H:i", strtotime($runInfo['start_date'] . " " . $runInfo['start_time'] . " -1 hours")); if ($now_time > $pre_hour) { //发车前1小时之内才会发送带有座位参数的短信 $content = $final['content2']; } else { $content = $final['content1']; } } #3.3根据runInfo替换短信模板信息 //{订单号}{出发地}{上车站点}{目的地}{下车站点}){车票张数}{出发日期}{出发时间}{车牌号}{司机姓司机电话}{上车站点详细地址}{车票链接} $order_count = $runInfo['order_count'] ? $runInfo['order_count'] : '';//订单数 $start_date = $runInfo['start_date'] ? $runInfo['start_date'] : ''; //出发日期 $start_time = $runInfo['start_time'] ? $runInfo['start_time'] : ''; //出发时间 $start_area = $runInfo['start_area'] ? $runInfo['start_area'] : ''; //出发地 $end_area = $runInfo['end_area'] ? $runInfo['end_area'] : ''; //目的地 $res_name = $runInfo['res_name'] ? $runInfo['res_name'] : ''; //上车站点 $end_res_name = $runInfo['end_res_name'] ? $runInfo['end_res_name'] : ''; //下车站点 $start_station_address = $runInfo['start_station_address'] ? $runInfo['start_station_address'] : '';//上车详细地址 $customer_name = $runInfo['customer_name']; $customer_mobile = $runInfo['customer_mobile']; $content = str_replace("{下车站点}", $end_res_name, $content); $content = str_replace("{出发日期}", $start_date, $content); $content = str_replace("{出发时间}", $start_time, $content); $content = str_replace("{上车站点}", $res_name, $content); $content = str_replace("{出发地}", $start_area, $content); $content = str_replace("{目的地}", $end_area, $content); $content = str_replace("{车票张数}", $order_count, $content); $content = str_replace("{上车站点详细地址}", $start_station_address, $content); $content = str_replace("{订单号}", $order_id, $content); $content = str_replace("{车票链接}", $shortUrl, $content); $order_seat_list = str_replace(",", "/", $runInfo["order_seat_list"]); $content = str_replace("{座位号}", $order_seat_list, $content); if ($driverInfo) { $bus_no = $driverInfo['bus_no'] ? $driverInfo['bus_no'] : ""; $driver_name = $driverInfo['driver_name'] ? $driverInfo['driver_name'] : ""; $driver_mobile = $driverInfo['driver_mobile'] ? $driverInfo['driver_mobile'] : ""; if ($bus_no == "") { $content = str_replace("车牌号{车牌号}", "", $content); } else { $content = str_replace("{车牌号}", $bus_no, $content); } if ($driver_name == "") { $content = str_replace(",司机电话{司机姓司机电话},", "", $content); } else { $driver_xing = mb_substr($driver_name, 0, 1, 'utf-8'); $driver_name_mobile = $driver_xing . $driver_mobile; $content = str_replace("{司机姓司机电话}", $driver_name_mobile, $content); $content = str_replace("{司机号码}", $driver_name_mobile, $content); } } else { $content = str_replace("车牌号{车牌号},", "", $content); $content = str_replace("司机电话{司机姓司机电话},", "", $content); } #4,返回发送短信相关信息 return array($customer_name, $customer_mobile, $content, $runInfo, $driverInfo); } /** * Function Description:获取该订单对应的线路实际拥有者 * Function Name: getOwnerSupplier * @param int $order_id 订单号 * * @return int * * @author 温依莅 */ public function getOwnerSupplier($order_id) { //订单基本信息 $order_res = self::find()->select([ 'parent_order_id', 'outside_sale_org_id', 'sale_path', 'agent_level' ])->from(OrderMain::tableName()) ->where(['parent_order_id' => $order_id, 'cancel_flag' => 0]) ->asArray() ->one(); $supplier_id = $order_res['outside_sale_org_id']; //判断是否是代售,如果是代售,更新渠道为 线路拥有者的售卖渠道 if ($order_res['sale_path']) { $sale_path_arr = explode(',', $order_res['sale_path']); $owner_order_id = end($sale_path_arr); $res = self::find()->select([ 'parent_order_id', 'outside_sale_org_id', 'sale_path', 'agent_level' ])->from(OrderMain::tableName()) ->where(['parent_order_id' => $owner_order_id, 'cancel_flag' => 0]) ->asArray() ->one(); $owner_supplier_id = $res['outside_sale_org_id']; $supplier_id = $owner_supplier_id; } return $supplier_id; } public function getGroupSuccessMsgInfo($order_id) { //1获取短信模板所需参数 #1.1,获取组合订单信息 $orderInfo = self::find()->select([ 'order_title_id', 'cus_name', 'cus_phone' ])->from(OrderTitle::tableName()) ->where(['order_title_id' => $order_id]) ->asArray() ->one(); #1.3,部分异常处理 if (!$orderInfo) { return false;//无出行信息 } //2,获取短信模板 $final = $this->getTemplate(0, 0, 0); if (!$final || !isset($final['content5'])) { return false;//模板信息缺失; } $content = $final['content5']; $customer_name = $orderInfo["cus_name"]; $customer_mobile = $orderInfo["cus_phone"]; #3.3根据runInfo替换短信模板信息 //{订单号}{出发地}{上车站点}{目的地}{下车站点}){车票张数}{出发日期}{出发时间}{车牌号}{司机姓司机电话}{上车站点详细地址}{车票链接} $content = str_replace("{订单号}", $order_id, $content); #4,返回发送短信相关信息 return array($customer_name, $customer_mobile, $content); } public function sendBusChangeRemindMsg($run_start_time, $itinerary_name, $new_bus_no) { $send_txt = "出行车辆变更通知:{$run_start_time}出发的{$itinerary_name}的车辆已变更为{$new_bus_no},请及时和车调人员进行确认!"; $send_mobile = "18817847097,13625816476"; Msg::sendTelMsg($send_mobile, $send_txt); } public function sendNewUserRemindMsg($run_id, $bus_order_id, $send_bus_count = 1) { $model_order_main = new OrderMain(); $need_send_id_array = $model_order_main->getOrderArrayFromRunbus($run_id, $bus_order_id); $message_template = $send_bus_count <= 1 ? "two" : "three"; foreach ($need_send_id_array as $order_info) { $order_id = $order_info["parent_order_id"]; $send_mobile = $order_info["customer_mobile"]; $send_message = $this->getMsgInfo($order_id, $message_template); if ($send_message == "notSend") { continue; } $send_success = Msg::sendTelMsg($send_message[1], $send_message[2],$order_info['main_corp_id']); //短信记录插入order_send_message表 $current_time = date("Y-m-d H:i:s"); $send_msg_values = [ 'ORDER_ID' => $order_id, 'SEND_MOBILE' => $send_message[1], 'SEND_MESSAGE' => $send_message[2], 'SEND_TIME' => $current_time, 'SEND_ERROR' => $send_success, 'CREATE_USER_ID' => 2, 'CREATE_TIME' => $current_time, 'UPDATE_USER_ID' => 2, 'UPDATE_TIME' => $current_time, ]; $msgRecord = new OrderSendMessage(); $msgRecord->attributes = $send_msg_values; $res = $msgRecord->insert(); } } public function addSuccessMessage($order_id, $send_mobile, $send_txt) { $insert_sql = " INSERT INTO send_bus_success_message (id, order_id, create_time,send_flag,send_mobile,send_message ) VALUES (NULL,{$order_id},now(),0,'{$send_mobile}','{$send_txt}');"; $res = Yii::$app->db->createCommand($insert_sql)->execute(); } /** * Function Description:发送短信白名单添加 * Function Name: insertAppointSendMessage * @param $order_id * * @return mixed * * @author LUOCJ */ public function insertAppointSendMessage($order_id) { $model = AppointSendMessage::findOne(['order_id' => $order_id, 'cancel_flag' => 0]); if ($model) { $json['code'] = '1'; $json['info'] = '该数据已存在,不能重复添加'; return $json; } $model = new AppointSendMessage(); $now = date('Y-m-d H:i:s'); $user = 1; $model->create_time = $model->update_time = $now; $model->create_user_id = $model->update_user_id = $user; $model->cancel_flag = 0; $model->order_id = $order_id; if (!$model->save()) { $json['code'] = '2'; $json['info'] = '保存失败,请检查数据' . $model->getFirstError(); return $json; } $json['code'] = '0'; $json['info'] = '保存成功'; return $json; } public function cancelAppointSendMessage($order_id) { $model = AppointSendMessage::findOne(['order_id' => $order_id, 'cancel_flag' => 0]); if (!$model) { $json['code'] = '1'; $json['info'] = '该数据不存在,请检查订单号'; return $json; } $model->cancel_flag = 1; if (!$model->save()) { $json['code'] = '2'; $json['info'] = '删除白名单失败,请检查数据'; return $json; } $json['code'] = '0'; $json['info'] = '刪除成功'; return $json; } /** * Function Description:发送短信白名单添加 * Function Name: insertAppointSendMessage * @param $order_id * * @return mixed * * @author LUOCJ */ public function insertWechatClickMessage($order_id) { $model = WechatClickMessage::findOne(['order_id' => $order_id, 'cancel_flag' => 0]); if ($model) { $json['code'] = '1'; $json['info'] = '该数据已存在,不能重复添加'; return $json; } $model = new WechatClickMessage(); $now = date('Y-m-d H:i:s'); $user = 1; $model->create_time = $model->update_time = $now; $model->create_user_id = $model->update_user_id = $user; $model->cancel_flag = 0; $model->order_id = $order_id; if (!$model->save()) { $json['code'] = '2'; $json['info'] = '保存失败,请检查数据'; return $json; } $json['code'] = '0'; $json['info'] = '保存成功'; return $json; } public function cancelWechatClickMessage($order_id) { $model = WechatClickMessage::findOne(['order_id' => $order_id, 'cancel_flag' => 0]); if (!$model) { $json['code'] = '1'; $json['info'] = '该数据不存在,请检查订单号'; return $json; } $model->cancel_flag = 1; if (!$model->save()) { $json['code'] = '2'; $json['info'] = '删除失败,请检查数据'; return $json; } $json['code'] = '0'; $json['info'] = '刪除成功'; return $json; } /** * Function Description:下单发送短信 * Function Name: orderSendMsg * @param int $order_id * @param string $template_type 使用模板类型 one:预订短信1或预定短信2(根据下单时间判断),two:出行短信,three:换车提醒短信 * @return mixed * * @author 邱颂 */ public function orderSendFreeMsg($order_id, $user_id, $send_message) { if (!$order_id) { $json["code"] = '1'; $json["info"] = '参数不正确'; return $json; } //1,获得需要发送的手机号码 $order_main_info = OrderMain::findOne(["ORDER_ID" => $order_id]); if (!$order_main_info) { $json["code"] = '1'; $json["info"] = '参数不正确'; return $json; } $send_tel = $order_main_info->CUSTOMER_MOBILE; $send_success = '-100'; //若最后记录为-100,说明未执行短信发送 $send_success = Msg::sendTelMsg($send_tel, $send_message,$order_main_info->MAIN_CORP_ID); //2,短信记录插入order_send_message表 $current_time = date("Y-m-d H:i:s"); $send_msg_values = [ 'ORDER_ID' => $order_id, 'SEND_MOBILE' => $send_tel, 'SEND_MESSAGE' => $send_message, 'SEND_TIME' => $current_time, 'SEND_ERROR' => $send_success, 'CREATE_USER_ID' => $user_id, 'CREATE_TIME' => $current_time, 'UPDATE_USER_ID' => $user_id, 'UPDATE_TIME' => $current_time, ]; $msgRecord = new OrderSendMessage(); $msgRecord->attributes = $send_msg_values; $res = $msgRecord->insert(); $json["code"] = '0'; $json["info"] = '短信已发送'; $json['resCode'] = $send_success; return $json; } }