WelfareUserService.php 754 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: z-yang
  5. * Date: 2018/7/16
  6. * Time: 16:40
  7. */
  8. namespace App\Modules\Welfare\Services;
  9. use App\Modules\Welfare\Models\WelfareUser;
  10. class WelfareUserService
  11. {
  12. public static function createUser($openid,$channel_user_id){
  13. $old = self::getByOpenId($openid);
  14. if(!$old){
  15. return WelfareUser::create(['openid'=>$openid,'channel_user_id'=>$channel_user_id]);
  16. }
  17. return $old;
  18. }
  19. public static function getByOpenId($openid){
  20. return WelfareUser::where('openid',$openid)->select('id','channel_user_id')->first();
  21. }
  22. public static function getById($id){
  23. //return WelfareUser::where('id',$openid)->select('id','channel_user_id')->first();
  24. }
  25. }