From 9ad9cc29f17ef452a79b4df51f19615f0991b54f Mon Sep 17 00:00:00 2001 From: tk Date: Wed, 12 Jun 2024 16:01:16 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E7=B1=BB=09=E5=9E=8B=E3=80=91?= =?UTF-8?q?=EF=BC=9Arefactor=20=E3=80=90=E4=B8=BB=09=E9=A2=98=E3=80=91?= =?UTF-8?q?=EF=BC=9A=E5=BE=AE=E4=BF=A1=E5=89=8D=E7=AB=AF=E8=AE=A2=E9=98=85?= =?UTF-8?q?=E5=89=8D=E7=BC=80=20=E6=9E=84=E5=BB=BA=E5=87=BD=E6=95=B0=20=20?= =?UTF-8?q?=E4=BB=8E=E7=A7=81=E6=9C=89=E6=96=B9=E6=B3=95=20=E6=94=B9?= =?UTF-8?q?=E6=88=90=20=E5=85=AC=E5=85=B1=E6=96=B9=E6=B3=95=20=E3=80=90?= =?UTF-8?q?=E6=8F=8F=09=E8=BF=B0=E3=80=91=EF=BC=9A=20=09[=E5=8E=9F?= =?UTF-8?q?=E5=9B=A0]=EF=BC=9A=E5=9C=B0=E9=9D=A2=E6=8E=A7=E5=88=B6?= =?UTF-8?q?=E7=AB=AF=E6=8E=A5=E5=8F=A3=20=E4=B9=9F=E8=A6=81=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E6=AD=A4=E6=96=B9=E6=B3=95=20=09[=E8=BF=87=E7=A8=8B]?= =?UTF-8?q?=EF=BC=9A=20=09[=E5=BD=B1=E5=93=8D]=EF=BC=9A=20=E3=80=90?= =?UTF-8?q?=E7=BB=93=09=E6=9D=9F=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # 类型 包含: # feat:新功能(feature) # fix:修补bug # docs:文档(documentation) # style: 格式(不影响代码运行的变动) # refactor:重构(即不是新增功能,也不是修改bug的代码变动) # test:增加测试 # chore:构建过程或辅助工具的变动 --- .../Api/Controller/LoginController.class.php | 4 +- FlyCube/Common/Common/functions.php | 95 ++----------------- 2 files changed, 9 insertions(+), 90 deletions(-) diff --git a/FlyCube/Api/Controller/LoginController.class.php b/FlyCube/Api/Controller/LoginController.class.php index f2d09f4..02296f9 100644 --- a/FlyCube/Api/Controller/LoginController.class.php +++ b/FlyCube/Api/Controller/LoginController.class.php @@ -47,7 +47,7 @@ class LoginController extends PublicController if ($user['tel'] != null) { $user['tel'] = $this->maskPhoneNumber($user['tel']); //用户已经填写过 电话的话 给前端返回 截取替换* 之后的电话号 } - $userInfo = array('token' => $token, 'name' => $user['name'], 'photo' => $user['photo'], 'sex' => $user['sex'], 'tel' => $user['tel'], 'topic_prefix' => $this->makeTopicPrefix($getAuth['openid'])); + $userInfo = array('token' => $token, 'name' => $user['name'], 'photo' => $user['photo'], 'sex' => $user['sex'], 'tel' => $user['tel'], 'topic_prefix' => makeTopicPrefix($getAuth['openid'])); echo json_encode(array('status' => 1, 'userInfo' => $userInfo)); } else { //用户首次登录 先进行注册 再分发token给前端 @@ -57,7 +57,7 @@ class LoginController extends PublicController $user = $userDb->find($id); //获取刚刚插入的记录 //分发token等用户信息给前端 $token = $this->makeToken($getAuth['openid'], $getAuth['session_key']); - $userInfo = array('token' => $token, 'name' => $user['name'], 'photo' => $user['photo'], 'sex' => $user['sex'], 'tel' => $user['tel'], 'topic_prefix' => $this->makeTopicPrefix($getAuth['openid'])); + $userInfo = array('token' => $token, 'name' => $user['name'], 'photo' => $user['photo'], 'sex' => $user['sex'], 'tel' => $user['tel'], 'topic_prefix' => makeTopicPrefix($getAuth['openid'])); } else { //数据库写入失败 echo json_encode(array('status' => 0, 'msg' => '系统出错')); diff --git a/FlyCube/Common/Common/functions.php b/FlyCube/Common/Common/functions.php index 685fba9..8dcf2c0 100644 --- a/FlyCube/Common/Common/functions.php +++ b/FlyCube/Common/Common/functions.php @@ -1,95 +1,14 @@ -// +---------------------------------------------------------------------- /** * Think 系统函数库 */ - /** - * 获取和设置配置参数 支持批量定义 - * @param string|array $name 配置变量 - * @param mixed $value 配置值 - * @param mixed $default 默认值 - * @return mixed + * @description: 构建加密 微信用户订阅对应主题的前缀 + * @param {*} openid 微信用户唯一凭证 + * @return {*} topicPrefix 主题前缀 */ -//在线交易订单支付处理函数 -//函数功能:根据支付接口传回的数据判断该订单是否已经支付成功; -//返回值:如果订单已经成功支付,返回true,否则返回false; - function checkorderstatus($ordid,$parameter){ - $row=M('order')->field('price,status')->where('ordernum='.$ordid)->select(); - file_put_contents("w.txt",$row[0]['price']); - file_put_contents("ww.txt",$row[0]['status']); - if($parameter==$row[0]['price']){//实际支付与订单价格相等 - //并且订单未支付 - return true; - }else{ - return false; - } - } - //处理订单函数 - //更新订单状态,写入订单支付后返回的数据 - function orderhandle($parameter){ - $ordid=$parameter['out_trade_no']; - $data['payment_trade_no'] =$parameter['trade_no']; - $data['payment_trade_status'] =$parameter['trade_status']; - $data['payment_notify_id'] =$parameter['notify_id']; - $data['payment_notify_time'] =$parameter['notify_time']; - $data['payment_buyer_email'] =$parameter['buyer_email']; - $data['ordstatus'] =1; - $datas['status']=1; - $datas['price_h']=$parameter['total_fee']; - /*******解决屠涂同一订单重复支付问题 lisa**********/ - if(strlen($ordid)==16){//屠涂修改订单号唯一 - $ordstatus=M('order')->where('order_sn='.$ordid)->save($datas); - }else{ - $ordstatus=M('order')->where('id='.$ordid)->save($datas); - } - } - function i_array_column($input, $columnKey, $indexKey=null){ - if(!function_exists('array_column')){ - $columnKeyIsNumber = (is_numeric($columnKey))?true:false; - $indexKeyIsNull = (is_null($indexKey))?true :false; - $indexKeyIsNumber = (is_numeric($indexKey))?true:false; - $result = array(); - foreach((array)$input as $key=>$row){ - if($columnKeyIsNumber){ - $tmp= array_slice($row, $columnKey, 1); - $tmp= (is_array($tmp) && !empty($tmp))?current($tmp):null; - }else{ - $tmp= isset($row[$columnKey])?$row[$columnKey]:null; - } - if(!$indexKeyIsNull){ - if($indexKeyIsNumber){ - $key = array_slice($row, $indexKey, 1); - $key = (is_array($key) && !empty($key))?current($key):null; - $key = is_null($key)?0:$key; - }else{ - $key = isset($row[$indexKey])?$row[$indexKey]:0; - } - } - $result[$key] = $tmp; - } - return $result; - }else{ - return array_column($input, $columnKey, $indexKey); - } - } - - - - -?> \ No newline at end of file +function makeTopicPrefix($openid) +{ + return substr(md5($openid . date("j")), 0, 8); //用户id+当天日 加密 截取前8位 +}