Пример #1
0
 /**
  * Create default user
  *
  * @return bool
  */
 public static function createManager($mobile)
 {
     $manager = new ActivityManager();
     $manager->id = UUID::v4();
     $manager->mobile = $mobile;
     $manager->created_at = Carbon::now();
     $manager->updated_at = Carbon::now();
     return $manager->save();
 }
Пример #2
0
 /**
  * Create doctor
  *
  * @param $app
  * @param $openId
  * @param $mobile
  * @return bool
  */
 public static function createDoctor($app, $openId, $mobile)
 {
     $type = UserType::where('code', 'doctor')->get()->first();
     $model = UserOpenid::where(['wechat_id' => $app['id'], 'open_id' => $openId])->get()->first();
     if ($type && $model) {
         $doctor = new Doctor();
         $doctor->id = UUID::v4();
         $doctor->mobile = $mobile;
         $doctor->created_at = Carbon::now();
         $doctor->updated_at = Carbon::now();
         if ($doctor->save()) {
             $model->user_id = $doctor->id;
             $model->user_type_id = $type['id'];
             $model->updated_at = Carbon::now();
             return $model->update();
         }
     }
     return false;
 }
Пример #3
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     //init wechat_app---------------------------------------
     DB::table('wechat_app')->insert(['app_id' => 'wxdc06d6c8ed39889e', 'app_secret' => '5921188a2889d0e7a41a842d0969b6e8', 'token' => 'suffrajetWechatToken', 'aes_key' => 'B3Qv3pjv0NE5ytOmPUZW0oCh1ssdoYLGsla1SD7ezB2', 'original_id' => 'gh_8d23d6695d07', 'name' => 'dll', 'type' => 2, 'is_auth' => 1, 'email' => '*****@*****.**', 'describe' => '个人测试使用', 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     $app = WechatApp::where('app_id', 'wxdc06d6c8ed39889e')->get()->first();
     //init table user_type----------------------------------
     DB::table('user_type')->insert(['wechat_id' => $app['id'], 'name' => '医生', 'code' => 'doctor', 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     DB::table('user_type')->insert(['wechat_id' => $app['id'], 'name' => '代表', 'code' => 'manager', 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     //init table activity_type------------------------------
     DB::table('activity_type')->insert(['name' => '科室会', 'code' => 'ksh', 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     //init manager------------------------------------------
     DB::table('activity_manager')->insert(['id' => UUID::v4(), 'name' => 'dll', 'mobile' => '18613860084', 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     //init table user_openid-------------------------------
     $userType = UserType::where('name', '代表')->get()->first();
     $manager = ActivityManager::where('name', 'dll')->get()->first();
     DB::table('user_openid')->insert(['wechat_id' => $app['id'], 'user_type_id' => $userType['id'], 'open_id' => 'oCFvTvkmM5joT-h8pr7p-q2F0Dno', 'user_id' => $manager['id'], 'activity_timeout' => 24, 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     //init reply-------------------------------------------
     $replyText = ['content' => '回复文本内容'];
     $replyNews = [array('title' => '测试标题', 'description' => '描述', 'url' => 'http://www.baidu.com', 'picUrl' => 'http://123.56.69.6/resources/640.jpg'), array('title' => '查看更多帮助', 'description' => '描述', 'url' => 'http://www.baidu.com', 'picUrl' => 'http://123.56.69.6/resources/640.jpg')];
     //init public event------------------------------------------
     DB::table('event')->insert(['wechat_id' => $app['id'], 'name' => '关注', 'code' => 'subscribe', 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     DB::table('event')->insert(['wechat_id' => $app['id'], 'name' => '取消关注', 'code' => 'unsubscribe', 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     DB::table('event')->insert(['wechat_id' => $app['id'], 'name' => '注册', 'code' => 'register', 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     DB::table('event')->insert(['wechat_id' => $app['id'], 'name' => '验证', 'code' => 'validate', 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     //init activity event-----------------------------------------
     $actType = ActivityType::where('name', '科室会')->get()->first();
     DB::table('event')->insert(['wechat_id' => $app['id'], 'activity_type_id' => $actType['id'], 'name' => '激活活动', 'code' => 'init_activity', 'sort' => 1, 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     DB::table('event')->insert(['wechat_id' => $app['id'], 'activity_type_id' => $actType['id'], 'name' => '查看题库', 'code' => 'browse_question', 'sort' => 2, 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     DB::table('event')->insert(['wechat_id' => $app['id'], 'activity_type_id' => $actType['id'], 'name' => '查看奖品库', 'code' => 'browse_prize', 'sort' => 3, 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     DB::table('event')->insert(['wechat_id' => $app['id'], 'activity_type_id' => $actType['id'], 'name' => '加入活动', 'code' => 'join_activity', 'sort' => 4]);
     DB::table('event')->insert(['wechat_id' => $app['id'], 'activity_type_id' => $actType['id'], 'name' => '活动答题', 'code' => 'answer', 'sort' => 5, 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     DB::table('event')->insert(['wechat_id' => $app['id'], 'activity_type_id' => $actType['id'], 'name' => '开奖', 'code' => 'draw', 'sort' => 6, 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     DB::table('event')->insert(['wechat_id' => $app['id'], 'activity_type_id' => $actType['id'], 'name' => '中奖查询', 'code' => 'query_winner', 'sort' => 7, 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     DB::table('event')->insert(['wechat_id' => $app['id'], 'activity_type_id' => $actType['id'], 'name' => '奖品查询', 'code' => 'query_prize', 'sort' => 8, 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     DB::table('event')->insert(['wechat_id' => $app['id'], 'activity_type_id' => $actType['id'], 'name' => '关闭活动', 'code' => 'close_activity', 'sort' => 9, 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     //init table command-----------------------------------
     $replyNews[0]['title'] = '欢迎关注';
     $type = Event::where('code', 'subscribe')->get()->first();
     DB::table('command')->insert(['wechat_id' => $app['id'], 'event_id' => $type['id'], 'cmd_type' => 'event', 'cmd_content' => 'subscribe', 'reply_type' => 'news', 'reply_json' => base64_encode(json_encode($replyNews)), 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     $type = Event::where('code', 'unsubscribe')->get()->first();
     DB::table('command')->insert(['wechat_id' => $app['id'], 'event_id' => $type['id'], 'cmd_type' => 'event', 'cmd_content' => 'unsubscribe', 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     $type = Event::where('code', 'register')->get()->first();
     DB::table('command')->insert(['wechat_id' => $app['id'], 'event_id' => $type['id'], 'cmd_type' => 'text', 'cmd_content' => '注册', 'is_prefix' => 1, 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     $replyNews[0]['title'] = '注册成功';
     $type = Event::where('code', 'validate')->get()->first();
     DB::table('command')->insert(['wechat_id' => $app['id'], 'event_id' => $type['id'], 'cmd_type' => 'text', 'cmd_content' => '验证', 'is_prefix' => 1, 'reply_type' => 'news', 'reply_json' => base64_encode(json_encode($replyNews)), 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     $type = Event::where('code', 'init_activity')->get()->first();
     DB::table('command')->insert(['wechat_id' => $app['id'], 'event_id' => $type['id'], 'cmd_type' => 'text', 'cmd_content' => '开会', 'is_prefix' => 1, 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     $replyNews[0]['title'] = '题库详情';
     $type = Event::where('code', 'browse_question')->get()->first();
     DB::table('command')->insert(['wechat_id' => $app['id'], 'event_id' => $type['id'], 'cmd_type' => 'text', 'cmd_content' => '题库', 'is_prefix' => 0, 'reply_type' => 'news', 'reply_json' => base64_encode(json_encode($replyNews)), 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     $replyNews[0]['title'] = '奖品库详情';
     $type = Event::where('code', 'browse_prize')->get()->first();
     DB::table('command')->insert(['wechat_id' => $app['id'], 'event_id' => $type['id'], 'cmd_type' => 'text', 'cmd_content' => '奖品库', 'is_prefix' => 0, 'reply_type' => 'news', 'reply_json' => base64_encode(json_encode($replyNews)), 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     $type = Event::where('code', 'join_activity')->get()->first();
     DB::table('command')->insert(['wechat_id' => $app['id'], 'event_id' => $type['id'], 'cmd_type' => 'text', 'cmd_content' => '加入', 'is_prefix' => 1, 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     $type = Event::where('code', 'answer')->get()->first();
     DB::table('command')->insert(['wechat_id' => $app['id'], 'event_id' => $type['id'], 'cmd_type' => 'text', 'cmd_content' => '我的答案', 'is_prefix' => 1, 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     $type = Event::where('code', 'draw')->get()->first();
     DB::table('command')->insert(['wechat_id' => $app['id'], 'event_id' => $type['id'], 'cmd_type' => 'text', 'cmd_content' => '开奖', 'is_prefix' => 0, 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     $type = Event::where('code', 'query_winner')->get()->first();
     DB::table('command')->insert(['wechat_id' => $app['id'], 'event_id' => $type['id'], 'cmd_type' => 'text', 'cmd_content' => '中奖情况', 'is_prefix' => 0, 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     $replyNews[0]['title'] = '奖品展示';
     $type = Event::where('code', 'query_prize')->get()->first();
     DB::table('command')->insert(['wechat_id' => $app['id'], 'event_id' => $type['id'], 'cmd_type' => 'text', 'cmd_content' => '查看奖品', 'is_prefix' => 0, 'reply_type' => 'news', 'reply_json' => base64_encode(json_encode($replyNews)), 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     $type = Event::where('code', 'close_activity')->get()->first();
     DB::table('command')->insert(['wechat_id' => $app['id'], 'event_id' => $type['id'], 'cmd_type' => 'text', 'cmd_content' => '散会', 'is_prefix' => 0, 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     //init activity questions------------------------------
     $options = ['1' => '选项1', '2' => '选项2', '3' => '选项3', '4' => '选项4'];
     DB::table('activity_question')->insert(['wechat_id' => $app['id'], 'activity_manager_id' => $manager['id'], 'name' => '问题1', 'content' => '问题1的答案是啥?', 'options_json' => base64_encode(json_encode($options)), 'right_answer' => 1, 'is_default' => 1, 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     DB::table('activity_question')->insert(['wechat_id' => $app['id'], 'activity_manager_id' => $manager['id'], 'name' => '问题2', 'content' => '问题2的答案是啥?', 'options_json' => base64_encode(json_encode($options)), 'right_answer' => 2, 'is_default' => 1, 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     DB::table('activity_question')->insert(['wechat_id' => $app['id'], 'activity_manager_id' => $manager['id'], 'name' => '问题3', 'content' => '问题3的答案是啥?', 'options_json' => base64_encode(json_encode($options)), 'right_answer' => 3, 'is_default' => 1, 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     DB::table('activity_question')->insert(['wechat_id' => $app['id'], 'activity_manager_id' => $manager['id'], 'name' => '问题4', 'content' => '问题4的答案是啥?', 'options_json' => base64_encode(json_encode($options)), 'right_answer' => 1, 'is_default' => 1, 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     DB::table('activity_question')->insert(['wechat_id' => $app['id'], 'activity_manager_id' => $manager['id'], 'name' => '问题5', 'content' => '问题5的答案是啥?', 'options_json' => base64_encode(json_encode($options)), 'right_answer' => 3, 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     DB::table('activity_question')->insert(['wechat_id' => $app['id'], 'activity_manager_id' => $manager['id'], 'name' => '问题6', 'content' => '问题6的答案是啥?', 'options_json' => base64_encode(json_encode($options)), 'right_answer' => 4, 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     //init activity prizes---------------------------------
     $prizeDefine = [array('title' => '活动奖品名称', 'description' => '描述描述描述描述描述', 'url' => 'http://www.baidu.com', 'picUrl' => 'http://123.56.69.6/resources/640.jpg')];
     DB::table('activity_prize')->insert(['wechat_id' => $app['id'], 'activity_manager_id' => $manager['id'], 'name' => '活动奖品1', 'describe_json' => base64_encode(json_encode($prizeDefine)), 'is_default' => 1, 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     DB::table('activity_prize')->insert(['wechat_id' => $app['id'], 'activity_manager_id' => $manager['id'], 'name' => '活动奖品2', 'describe_json' => base64_encode(json_encode($prizeDefine)), 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     DB::table('activity_prize')->insert(['wechat_id' => $app['id'], 'activity_manager_id' => $manager['id'], 'name' => '活动奖品3', 'describe_json' => base64_encode(json_encode($prizeDefine)), 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     //init notice-----------------------------------------
     DB::table('notice')->insert(['wechat_id' => $app['id'], 'doctor_mobile' => '18613860084', 'notice_name' => '活动延迟开展1', 'notice_content' => '由于今天临时有事, 活动开展时间推迟到明天上午10:00开始,请各位见谅!', 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     DB::table('notice')->insert(['wechat_id' => $app['id'], 'doctor_mobile' => '18613860084', 'notice_name' => '活动延迟开展2', 'notice_content' => '由于今天临时有事, 活动开展时间推迟到明天上午10:00开始,请各位见谅!', 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     DB::table('notice')->insert(['wechat_id' => $app['id'], 'doctor_mobile' => '18613860084', 'notice_name' => '活动延迟开展3', 'notice_content' => '由于今天临时有事, 活动开展时间推迟到明天上午10:00开始,请各位见谅!', 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
 }