| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 | <?phpnamespace App\Modules\CpUser\Services;use App\Modules\CpUser\Models\CpUser;class CpUserService{      /**     * 得到用户     *     */    public static function getCpUser($username) {        return CpUser::getCpUser($username);    }        /**     * 得到用户by id     */    public static function getCpUserById($id) {    	return CpUser::getCpUserById($id);    }        /**     * 修改Cp密码     * @param  string $username   用户名     * @param  string $password 加密后密码     * @return boolen     */    static function modifyPassword($username, $password)    {    	return CpUser::modifyPassword($username, $password);    }    static function createCp($username){        try{            $password = $username.'123456';            $pass = md5($password."^-^zhuishuyun^_^");            return CpUser::create([                'username'=>$username,                'password'=>$pass,                'is_enabled'=>1,                'is_show_total_amount'=>0            ]);        }catch (\Exception $e){        }        return false;    }    static function getAllCpUser($param,$is_all=false){        if($is_all){            return CpUser::all();        }        $where = [];        if(isset($param['cp']) && !empty(($param['cp']))){            $where[] = ['username','like','%'.trim($param['cp']).'%'];        }        return CpUser::where($where)->orderBy('id','desc')->paginate(20);    }}
 |