TalentController.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | 文件说明:幻灯片
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2013-2017 http://www.thinkcmf.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Author: wuwu <15093565100@163.com>
  8. // +----------------------------------------------------------------------
  9. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  10. // +----------------------------------------------------------------------
  11. // | Date: 2017-5-25
  12. // +----------------------------------------------------------------------
  13. namespace api\crontab\controller;
  14. use api\common\Sms;
  15. use app\talent\model\TalentAppointmentLogModel;
  16. use app\talent\model\TalentAppointmentModel;
  17. class TalentController
  18. {
  19. /**
  20. * 主方法
  21. */
  22. public function index()
  23. {
  24. $this->_dealRateMsg();
  25. // $this->_test();
  26. }
  27. /**
  28. * 发送短信
  29. */
  30. public function _dealRateMsg()
  31. {
  32. $yesterday = date('Y-m-d', strtotime('-1 day'));
  33. $list = TalentAppointmentLogModel::with(['appointment.talent'])
  34. ->where(function($query){
  35. $query->where('content', '通过手机号接站,接到了人才')->whereOr('content','通过扫码接站,接到了人才');
  36. })
  37. ->whereBetween('create_time', [$yesterday . ' 00:00:00', $yesterday . ' 23:59:59'])
  38. ->select();
  39. //短信
  40. $sms = new Sms();
  41. if (!$list->isEmpty()) {
  42. foreach ($list as $v) {
  43. $sms->send($v['appointment']['talent']['mobile'],'talent_appointment_end');
  44. }
  45. }
  46. }
  47. public function _test()
  48. {
  49. $today = date('Y-m-d');
  50. $list = TalentAppointmentModel::where('out_time','between',[$today.' 00:00:00',$today.' 23:59:59'])->order('out_time asc')->select();
  51. $res = [];
  52. foreach ($list as $v) {
  53. $hour = date('H:00',strtotime($v['out_time']));
  54. if (empty($res)) {
  55. $res[$hour] = [
  56. 'hour' => $hour,
  57. 'list' => [],
  58. ];
  59. }
  60. $res[$hour]['list'][] = $v->toArray();
  61. }
  62. halt(array_values($res));
  63. }
  64. }