Commit 8b578481 authored by jianghaiming's avatar jianghaiming

update:set

parent 353ef9f1
......@@ -26,6 +26,14 @@ class UserWechatBind extends MysqlBase
return self::get($columns, $where);
}
public static function getRecords($where, $columns = [])
{
if (empty($columns)) {
$columns = '*';
}
return self::select($columns, $where);
}
public static function getRecordMaster($where, $columns = [])
{
if (empty($columns)) {
......
......@@ -27,4 +27,13 @@ class UserController extends Base
$this->success($userInfo);
}
public function user_wechat_bindAction()
{
$params = $this->params;
$user = UserService::userWechatBind($params);
$userInfo['result'] = $user;
$this->success($userInfo);
}
}
\ No newline at end of file
......@@ -28,9 +28,9 @@ class UserService
throw new UserException(['cus' => 0]);
}
//需要授权微信
if (empty($openid)) {
$appid = \Yaf\Registry::get('config')->wechat->appid;
$secret = \Yaf\Registry::get('config')->wechat->secret;
$grant_type = 'authorization_code';
......@@ -61,8 +61,10 @@ class UserService
//如果系统不存在,用户信息,则注册新用户
if (empty($user) && !empty($response)) {
$insert = [
'openid' => $response['openid'],
'session_key' => $response['session_key'], //默认7200有效期
'openid' => !empty($response['openid']) ? $response['openid'] : '',
'union_id' => !empty($response['unionid']) ? $response['unionid'] : '',
'session_key' => !empty($response['session_key']) ? $response['session_key'] : '', //默认7200有效期
'create_time' => date("Y-m-d H:i:s")
];
$newWechatId = UserWechatBind::save($insert);
......@@ -146,6 +148,24 @@ class UserService
return $userInfo;
}
public static function userWechatBind($params)
{
$data['wechat_id[>]'] = 0;
if (!empty($params['openid'])) {
$data['openid'] = $params['openid'];
}
if (!empty($params['user_id'])) {
$data['user_id'] = $params['user_id'];
}
$userList = UserWechatBind::getRecords($data);
return $userList;
}
private static function generate3rdSession($openid) {
return md5(mt_rand() . $openid);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment