$openid]; $query = $this->app->db->name($this->table)->where(['deleted' => 0]); $member = $query->withoutField('status,deleted')->where($map)->find(); if (empty($member)) throw new \think\Exception('会员查询失败'); return array_merge($member, $data); } /** * 刷新会员授权token * @param string $openid * @param array $data * @return array * @throws \think\Exception * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public function token($openid, $data = []) { $this->app->db->name($this->table)->where(['id|openid' => $openid])->update([ 'token' => CodeExtend::random(20, 3, 't'), ]); return $this->get($openid, $data); } /** * 获取会员数据统计 * @param integer $mid * @return array */ public function total($mid) { return [ 'myinvited' => $this->app->db->name('DataMember')->where(['from' => $mid])->count(), ]; } }