<?php
/**
 * Created by PhpStorm.
 * User: sicilon_IT
 * Date: 2019/12/7
 * Time: 11:11
 */

namespace  app\common\model;
use think\Model;


class memodel extends Model{
  // private $me_tabel;
    protected $table = 't_wxuser';

//   public function initialize(){
//       //echo "in";
//       $this->me_tabel=model("tEquipmentMe");
//       echo 'init';
//   }

    public function saveme($userinfo){
        $r_id=$this->allowField(true)->save($userinfo);
        return $r_id;
    }

    public function getinfobyopenid($openid){
        $record=$this->where("open_id",$openid)->find();
        return $record;
    }

    public function updatetelbyoopenid($openid,$tel){
        $r_id=$this->where("open_id",$openid)->update(['tel'=>$tel]);
        return $r_id;
    }

    public function insopenid($insinfo){

        $r_id=$this->isUpdate(false)->save($insinfo);

        return $this->id;
    }
    /*
     * 20200226
     * steelxu5
     * 增加了根据openid更新信息的
     */

    public function updateinfobyopenid($openid,$arr){
        $r_id=$this->where("open_id",$openid)->update($arr);
        return $r_id;
    }

    /*
     * 20200401
     * 根据ID获取呢称
     */

    public function selnamebyid($id){
        $where_arr['id']=$id;
        $cinfo=$this->where($where_arr)->find();
        return $cinfo;
    }

    /*
     * 20200927
     * 根据UNIONID获取信息,openid,uid
     */
    public function selinfobyunionid($unionid){
        $where_arr['union_id']=$unionid;
        $cinfo=$this->where($where_arr)->field('id,open_id')->find();
        return $cinfo;
    }
    /*
     * 20200927
     * 根据openid 更新unionid
     */
    public function updunionidbyopenid($openid,$unionid){
        $this->where("open_id",$openid)->update(['union_id'=>$unionid]);
    }

    /*
     * 20200928
     * 根据unionid 获取openid
     */
    public function selopenidbyunionid($unionid){
        $rec=$this->where("union_id",$unionid)->field('id,open_id')->find();
        return $rec['open_id'];
    }

} 