From 97129adf88fc56e58530f0ab1506c92f933749f0 Mon Sep 17 00:00:00 2001 From: vguanyiwgd Date: Tue, 16 Apr 2024 10:13:40 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=B0=8F=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F=E7=99=BB=E5=BD=95=E5=90=8E=EF=BC=8C=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E6=9B=B4=E6=96=B0openid=20=E5=88=B0=20tb=5Fuser.applet=5Fopeni?= =?UTF-8?q?d?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Id41635e4ab2fbdc2cf845f96825b5144adcf2287 --- .../api/controllers/api/Applet.php | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/backstage/application/api/controllers/api/Applet.php b/backstage/application/api/controllers/api/Applet.php index 1052830..99f8aaa 100644 --- a/backstage/application/api/controllers/api/Applet.php +++ b/backstage/application/api/controllers/api/Applet.php @@ -180,4 +180,30 @@ class Applet extends REST_Controller { ) ), REST_Controller::HTTP_OK); } + + public function updateAppletOpenid_post(){ + $user_id = $this->user->id; + $uid = $this->input->post("uid", true); + if($user_id != $uid){ + $this->response(array( + 'status' => 0, + 'message' => 'token和uid不匹配', + + ), REST_Controller::HTTP_OK); + } + $applet_openid = $this->input->post("applet_openid", true); + + $res = $this->User_model->update_user(array('applet_openid' => $applet_openid), $user_id); + if($res){ + $this->response(array( + 'status' => 1, + 'message' => '更新成功', + ), REST_Controller::HTTP_OK); + }else{ + $this->response(array( + 'status' => 0, + 'message' => '更新失败', + ), REST_Controller::HTTP_OK); + } + } } From c51be8f2cc0913e84625864b474395607572a127 Mon Sep 17 00:00:00 2001 From: vguanyiwgd Date: Tue, 16 Apr 2024 11:27:03 +0800 Subject: [PATCH 2/4] update Change-Id: I455ff4d80083f7a52f141083a0e761e24949fa32 --- backstage/application/api/controllers/api/Applet.php | 3 +++ backstage/application/api/models/User_model.php | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/backstage/application/api/controllers/api/Applet.php b/backstage/application/api/controllers/api/Applet.php index 99f8aaa..6057c46 100644 --- a/backstage/application/api/controllers/api/Applet.php +++ b/backstage/application/api/controllers/api/Applet.php @@ -193,6 +193,9 @@ class Applet extends REST_Controller { } $applet_openid = $this->input->post("applet_openid", true); + // 先清空关于这个openid的数据 + $this->User_model->clearAppletOpenid($applet_openid); + $res = $this->User_model->update_user(array('applet_openid' => $applet_openid), $user_id); if($res){ $this->response(array( diff --git a/backstage/application/api/models/User_model.php b/backstage/application/api/models/User_model.php index 73b0f74..e1d51d8 100644 --- a/backstage/application/api/models/User_model.php +++ b/backstage/application/api/models/User_model.php @@ -1174,4 +1174,11 @@ class User_model extends CI_Model $rs = $this->db->query($sql)->result_array(); return $rs[0]; } + + // 清空指定applet_openid + public function clearAppletOpenid($openid){ + $this->db->where('applet_openid', $openid); + $data = array('applet_openid' => ''); + return $this->db->update('tb_user', $data); + } } From 01ed6b4b24cef1a3967a6ac9c1aab237a77dc69a Mon Sep 17 00:00:00 2001 From: vguanyiwgd Date: Tue, 16 Apr 2024 14:24:50 +0800 Subject: [PATCH 3/4] update Change-Id: I6bb9da09186f0380dc322c5527a97728c1f9fc37 --- backstage/application/api/models/User_model.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backstage/application/api/models/User_model.php b/backstage/application/api/models/User_model.php index e1d51d8..471ef61 100644 --- a/backstage/application/api/models/User_model.php +++ b/backstage/application/api/models/User_model.php @@ -1178,7 +1178,7 @@ class User_model extends CI_Model // 清空指定applet_openid public function clearAppletOpenid($openid){ $this->db->where('applet_openid', $openid); - $data = array('applet_openid' => ''); + $data = array('applet_openid' => null); return $this->db->update('tb_user', $data); } } From 93bdefc75fa004cc50fa499c78abb1050f12118b Mon Sep 17 00:00:00 2001 From: vguanyiwgd Date: Tue, 16 Apr 2024 14:33:44 +0800 Subject: [PATCH 4/4] update Change-Id: Iae61662563bce6b50d5b8a551ecb22c3f3abf97f --- show/get.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/show/get.php b/show/get.php index 64e1674..bd00716 100644 --- a/show/get.php +++ b/show/get.php @@ -228,7 +228,7 @@ if($act == 'applet_unifiedorder') { if($isjsapi) { $openid = $user['applet_openid']; if(!$openid) { - echoRs(0, '非小程序注册用户!不能使用小程序支付!'); + echoRs(0, '获取openid失败,请在小程序里重新登录再试!'); } } $host = $_SERVER['HTTP_HOST'];