You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

111 lines
3.8 KiB

  1. <?php
  2. /**
  3. *
  4. * ============================================================================
  5. * * 版权所有 蜘蛛出行 * *
  6. * 网站地址: http://www.zhizhuchuxing.com
  7. * ----------------------------------------------------------------------------
  8. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和
  9. * 使用;不允许对程序代码以任何形式任何目的的再发布。
  10. * ============================================================================
  11. * Author By: 温依莅
  12. * PhpStorm GroupOrder.php
  13. * Create By 2017/7/13 17:26 $
  14. */
  15. namespace console\models;
  16. use backend\modules\api\util\Util;
  17. use backend\modules\zzcs\models\OrderTitleCancelRequest;
  18. use common\models\Msg;
  19. use backend\modules\api\models\OrderTitle;
  20. use backend\modules\api\models\OperaTouristCommon;
  21. use backend\modules\api\models\OrderSendMessage;
  22. use common\util\CtripUtil;
  23. use Yii;
  24. class GroupOrder
  25. {
  26. /**
  27. * Function Description:对自由行产品已确认订单发送预订成功短信
  28. * Function Name: sendBookMsg
  29. *
  30. * @author 温依莅
  31. */
  32. public function sendBookMsg()
  33. {
  34. //1,获取需要发送短信的自由行组合订单
  35. $order_title = new OrderTitle();
  36. $order_arr = $order_title->getConfirmedOrders();
  37. if (!$order_arr) {
  38. return;
  39. }
  40. //2,循环自由行订单组发送短信
  41. foreach ($order_arr as $k => $v) {
  42. //2.1,获取需要发送的短信内容
  43. $res_arr = $this->getMsgContent($v['tourist_id'], $v['order_title_id']);
  44. if ($res_arr) {
  45. //2.2,发送短信
  46. $tmp = $order_title->updateMsgStatus($v['order_title_id']);
  47. if (!$tmp) {
  48. return;
  49. }
  50. $send_res = Msg::sendTelMsg($res_arr['phone'], $res_arr['content'],$v['main_corp_id']);
  51. //2.3,短信发送记录存入数据库
  52. OrderSendMessage::addTouristMsg($v['order_title_id'], $res_arr['phone'], $res_arr['content'], $send_res, 1);
  53. }
  54. }
  55. }
  56. /**
  57. * Function Description:获取该自由行产品需要发送的短信内容
  58. * Function Name: getMsgContent
  59. * @param int $tourist_id 自由行产品id
  60. *
  61. * @return array
  62. *
  63. * @author 温依莅
  64. */
  65. public function getMsgContent($tourist_id, $order_title_id)
  66. {
  67. $order_title = new OrderTitle();
  68. //1,获取短信模板内容
  69. $tourist_res = OperaTouristCommon::getTouristMsg($tourist_id);
  70. if (!isset($tourist_res['message'])) {
  71. return array();
  72. }
  73. $content = $tourist_res['message'];
  74. //2,根据自由行订单新替换通配符得到短信发送内容
  75. $title_res = $order_title->getTitleInfo($order_title_id);
  76. $phone = $title_res['cus_phone'];
  77. $content = str_replace("{成人数}", $title_res['adult_num'], $content);
  78. $content = str_replace("{儿童数}", $title_res['child_num'], $content);
  79. $content = str_replace("{出发日期}", $title_res['start_date'], $content);
  80. $content = str_replace("{产品名}", $title_res['order_title_prod_name'], $content);
  81. return array('phone' => $phone, 'content' => $content);
  82. }
  83. public function ctripNoticeOrderCancel()
  84. {
  85. $orderTitleCancelRequest = new OrderTitleCancelRequest();
  86. $getCancelOutTimes = $orderTitleCancelRequest->getCancelOutTimes();
  87. if (empty($getCancelOutTimes['0']['order_title_id'])) {
  88. return Util::returnArrSu('no doing');
  89. }
  90. foreach ($getCancelOutTimes as $val) {
  91. $order_id = $val['order_title_id'];
  92. CtripUtil::NoticeOrderCancel($order_id, 4);
  93. }
  94. return Util::returnArrSu();
  95. }
  96. }