Commit 3c7c453f authored by clone's avatar clone

绑定微信

parent ac0557d0
...@@ -12,17 +12,20 @@ namespace app\api\controller; ...@@ -12,17 +12,20 @@ namespace app\api\controller;
*/ */
use app\api\extend\Basic; use app\api\extend\Basic;
use app\model\Users;
use app\model\UWxInfo; use app\model\UWxInfo;
use think\Exception; use think\Exception;
class WxSdk extends Basic class WxSdk extends Basic
{ {
private $wxInfoModel; private $wxInfoModel;
private $userModel
public function __construct($request = null) public function __construct($request = null)
{ {
parent::__construct($request); parent::__construct($request);
$this->wxInfoModel = new UWxInfo(); $this->wxInfoModel = new UWxInfo();
$this->userModel = new Users();
} }
/** /**
...@@ -61,10 +64,12 @@ class WxSdk extends Basic ...@@ -61,10 +64,12 @@ class WxSdk extends Basic
} catch (Exception $exception) { } catch (Exception $exception) {
return $this->response("101", "request error:" . $exception); return $this->response("101", "request error:" . $exception);
} }
$conditions["buyer_id"] = $id;
$fields = "id";
$user_info = $this->userModel->getUserByWhere($conditions, $fields);
if ($id > 0) { if ($id > 0) {
return $this->response("200", "request success", [ "user_id" => $wxInfoObj[0]["user_id"] ]); return $this->response("200", "request success", [ "user_id" => $user_info[0]["id"] ]);
} else { } else {
return $this->response("101", "request exception"); return $this->response("101", "request exception");
} }
......
...@@ -67,7 +67,7 @@ class UWxInfo extends Model ...@@ -67,7 +67,7 @@ class UWxInfo extends Model
* @param string $field * @param string $field
* @return false|\PDOStatement|string|\think\Collection * @return false|\PDOStatement|string|\think\Collection
*/ */
public function getWxInfoByOpenId(string $open_id , string $field = "id,user_id") public function getWxInfoByOpenId(string $open_id , string $field = "id")
{ {
$where_["wx_union_id"] = $open_id; $where_["wx_union_id"] = $open_id;
$where_["is_del"] = 0; $where_["is_del"] = 0;
......
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