<?php
/**
 * Created by PhpStorm.
 * User: z-yang
 * Date: 2018/7/16
 * Time: 16:40
 */

namespace App\Modules\Welfare\Services;

use App\Modules\Welfare\Models\WelfareUser;

class WelfareUserService
{
    public static function createUser($openid,$channel_user_id){
        $old = self::getByOpenId($openid);
        if(!$old){
            return WelfareUser::create(['openid'=>$openid,'channel_user_id'=>$channel_user_id]);
        }
        return $old;
    }

    public static function getByOpenId($openid){
        return WelfareUser::where('openid',$openid)->select('id','channel_user_id')->first();
    }

    public static function getById($id){
        //return WelfareUser::where('id',$openid)->select('id','channel_user_id')->first();
    }
}