ScheduleNotice.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 = '排班提醒';
  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. $data = [$d->openid,'',$d->name,$time, $teams];
  47. $ret = send_wechatSubscription_message('schedule_notice',$data);
  48. }
  49. }
  50. public function test()
  51. {
  52. $openid = 'oflME5eixHMij2TIVyy52WbfaQvA';
  53. $data = [
  54. 'touser' => $openid,
  55. 'mp_template_msg' => [
  56. 'appid' => env('OFFICE_APPID'),
  57. 'template_id' => 'Bd12nbwEtcrsN2IsVA2URiPH1qVGk3uyCemLyxBa-4U',
  58. 'url' => '',
  59. 'miniprogram' => [
  60. 'appid' => env('WECHAT_APPID', 'wx6131f74e623bf6bf'),
  61. 'page' => '',
  62. ],
  63. 'data' => [
  64. 'first' => [
  65. 'value' => '尊敬的大哥,你下周的排班已经完成,具体如下!',
  66. ]
  67. ,'keyword1' => [
  68. 'value' => '2021-01-18 - 2021-01-24',
  69. ],
  70. 'keyword2' => [
  71. 'value' => '测试团队',
  72. ],
  73. 'keyword3' => [
  74. 'value' => '总后台',
  75. ],
  76. 'remark' => [
  77. 'value' => '点击进入小程序查看详情,有疑问请联系客服',
  78. ],
  79. ]
  80. ],
  81. ];
  82. $app = Factory::miniProgram(config('config.docter_small_program'));
  83. //先发送模板消息
  84. $ret = $app->uniform_message->send($data);
  85. }
  86. }