qq807722947
2021-08-03 13:26
采纳率: 94.3%
浏览 44

这个json_decode判断怎么改才能正确

if (isset($resArr['status']) && $resArr['status']=='ok') {
    include dirname(__FILE__) .'/phpqrcode/phpqrcode.php';
    $data['code']=200;
    $data['qrcode']=isset($resArr['code_url'])?$resArr['code_url']:'';
    require dirname(__FILE__) . '/mobile/mobile.php';
    $detect = new Mobile_Detect();
    $imgInfo = '';
    if (!$detect->isMobile()) {
        ob_start();
        //开启缓冲区
        QRcode::png($data['qrcode'], false, 'L', 10, 1);
        //生成二维码
        $img = ob_get_contents();
        //获取缓冲区内容
        ob_end_clean();
        //清除缓冲区内容
        $imgInfo = 'data:png;base64,' . chunk_split(base64_encode($img));
        //转base64
        $data['loadUri']=2;
    } else {
        $data['loadUri']=1;
    }
    $data['qqrcode']=$data['qrcode'];
    $data['qrcode']=$imgInfo;
    $data['money']=$row['money'];
    $data['expireTime']=isset($resArr['addtime'])?$resArr['addtime']:7200;
    $data['msg']='下单成功!';
    $_SESSION['paySign']=$params['sign'];
    $_SESSION['xorPayId']=$resArr['aoid'];
    //记录订单信息
    $payTime=date('Y-m-d H:i:s');
    $db->query("INSERT INTO " . DB_PREFIX . "pay_log (`bid`,`phone`,`pay_id`,`pay_time`,`user_info`,`money`,`xpay_id`,`ip`,`created`,`updated`,`status`) VALUES ('".$bid."','".$userId."','".$params['order_id']."','".$payTime."','".(isset($_SERVER['HTTP_USER_AGENT'])?base64_encode($_SERVER['HTTP_USER_AGENT']):'')."','".$params['price']."','".$resArr['aoid']."','".pay_func::getIp()."','".$payTime."','".$payTime."',2)");
    pay_func::json($data);
} else {
    $data['msg']='支付接口未能返回正确参数!';
    pay_func::json($data);
}

json_decode生成得数据是

array(8) {
  ["code"]=>
  int(1)
  ["msg"]=>
  string(13) "下单成功!"
  ["trade_no"]=>
  string(19) "2021080313122889980"
  ["money"]=>
  string(4) "0.01"
  ["out_trade_no"]=>
  string(17) "20210803131229630"
  ["addtime"]=>
  string(19) "2021-08-03 13:12:28"
  ["endtime"]=>
  string(19) "2021-08-03 13:17:28"
  ["code_url"]=>
  string(59) "https://www.huluwl.cn/user/wxqrcode/5828_20210713124648.jpg"
}

现在一直提示支付接口未能返回正确参数

1条回答 默认 最新

相关推荐 更多相似问题