Merge branch 'master' of ssh://code.srdcloud.cn:29418/fsdxszhpt/yzms

This commit is contained in:
fengjh5 2024-04-16 16:38:09 +08:00
commit a9faff847a
3 changed files with 37 additions and 1 deletions

View File

@ -180,4 +180,33 @@ 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);
// 先清空关于这个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(
'status' => 1,
'message' => '更新成功',
), REST_Controller::HTTP_OK);
}else{
$this->response(array(
'status' => 0,
'message' => '更新失败',
), REST_Controller::HTTP_OK);
}
}
}

View File

@ -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' => null);
return $this->db->update('tb_user', $data);
}
}

View File

@ -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'];