TalentController.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. return 'OK';
  27. }
  28. /**
  29. * 发送短信
  30. */
  31. public function _dealRateMsg()
  32. {
  33. $yesterday = date('Y-m-d', strtotime('-1 day'));
  34. $list = TalentAppointmentLogModel::with(['appointment.talent'])
  35. ->where(function($query){
  36. $query->where('content', '通过手机号接站,接到了人才')->whereOr('content','通过扫码接站,接到了人才');
  37. })
  38. ->whereBetween('create_time', [$yesterday . ' 00:00:00', $yesterday . ' 23:59:59'])
  39. ->select();
  40. if (!$list->isEmpty()) {
  41. //短信
  42. $sms = new Sms();
  43. foreach ($list as $v) {
  44. $sms->send($v['appointment']['talent']['mobile'],'talent_appointment_end');
  45. }
  46. }
  47. }
  48. public function _test()
  49. {
  50. $today = date('Y-m-d');
  51. $list = TalentAppointmentModel::where('out_time','between',[$today.' 00:00:00',$today.' 23:59:59'])->order('out_time asc')->select();
  52. $res = [];
  53. foreach ($list as $v) {
  54. $hour = date('H:00',strtotime($v['out_time']));
  55. if (empty($res)) {
  56. $res[$hour] = [
  57. 'hour' => $hour,
  58. 'list' => [],
  59. ];
  60. }
  61. $res[$hour]['list'][] = $v->toArray();
  62. }
  63. halt(array_values($res));
  64. }
  65. }