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位 +}