ScheduleNotice.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <?php
  2. namespace App\Console\Commands;
  3. use App\Models\Docter;
  4. use App\Models\DocterOrganization;
  5. use App\Models\OrganizationVaccine;
  6. use EasyWeChat\Factory;
  7. use Illuminate\Console\Command;
  8. class ScheduleNotice extends Command
  9. {
  10. /**
  11. * The name and signature of the console command.
  12. *
  13. * @var string
  14. */
  15. protected $signature = 'scheduleNotice';
  16. /**
  17. * The console command description.
  18. *
  19. * @var string
  20. */
  21. protected $description = '排班提醒 每周六18:00 提醒一次';
  22. /**
  23. * Create a new command instance.
  24. *
  25. * @return void
  26. */
  27. public function __construct()
  28. {
  29. parent::__construct();
  30. }
  31. /**
  32. * Execute the console command.
  33. *
  34. * @return mixed
  35. */
  36. public function handle()
  37. {
  38. //门诊医生排班提醒
  39. $docters = Docter::where(['type'=>1])->get();
  40. $nowDay = intval(date('N',time()));
  41. $endDay = (7-$nowDay)*86400 +time();
  42. $time = date('Y-m-d',strtotime('this week')).'至'.date('Y-m-d',$endDay);
  43. foreach ($docters as $d){
  44. if(empty($d->openid)) continue;
  45. $teams = get_docter_organization($d->id);
  46. //$openid = 'oflME5eixHMij2TIVyy52WbfaQvA';
  47. $data = [$d->openid,'',$d->name,$time, $teams];
  48. $ret = admin_send_docter_message('schedule_notice',$data);
  49. dd($ret);
  50. }
  51. }
  52. public function test()
  53. {
  54. $openid = 'oflME5eixHMij2TIVyy52WbfaQvA';
  55. $data = [
  56. 'touser' => $openid,
  57. 'mp_template_msg' => [
  58. 'appid' => env('OFFICE_APPID'),
  59. 'template_id' => 'Bd12nbwEtcrsN2IsVA2URiPH1qVGk3uyCemLyxBa-4U',
  60. 'url' => '',
  61. 'miniprogram' => [
  62. 'appid' => env('WECHAT_APPID', 'wx6131f74e623bf6bf'),
  63. 'page' => '',
  64. ],
  65. 'data' => [
  66. 'first' => [
  67. 'value' => '尊敬的大哥,你下周的排班已经完成,具体如下!',
  68. ]
  69. ,'keyword1' => [
  70. 'value' => '2021-01-18 - 2021-01-24',
  71. ],
  72. 'keyword2' => [
  73. 'value' => '测试团队',
  74. ],
  75. 'keyword3' => [
  76. 'value' => '总后台',
  77. ],
  78. 'remark' => [
  79. 'value' => '点击进入小程序查看详情,有疑问请联系客服',
  80. ],
  81. ]
  82. ],
  83. ];
  84. $app = Factory::miniProgram(config('config.docter_small_program'));
  85. //先发送模板消息
  86. $ret = $app->uniform_message->send($data);
  87. }
  88. }