uid != 73) $this->error('暂未开通'); if (redisSetNx($this->request->action().$this->uid,3)) { $money = input('post.money',0); $pay_type = input('post.pay_type','sd_rapid'); if($money <=0 ) $this->error('充值金额有误!'); $money = bcadd($money,0,2); $user = Db::name('store_member')->where('id',$this->uid)->find(); if(!$user['true_name'] || !$user['id_card']) $this->error('请实名认证,在进行订单支付'); Db::startTrans(); try{ $voucher_order = [ 'mid' => $this->uid , 'total_price' => $money, 'order_no' =>get_order_sn(), 'pay_no' =>get_order_sn(), 'create_at' => date("Y-m-d H:i:s"), 'pay_type' => $pay_type ]; $order_id = Db::table('store_recharge_order')->insertGetId($voucher_order); $notify_url = 'https://'.$_SERVER['HTTP_HOST'] . '/api/Pay/walletNotify'; switch ($pay_type) { case 'sd': $client = new Shande(); $total_fee = $money*100; $lenth = strlen($total_fee); $total_fee = get0number($lenth).$total_fee; $result = $client->orderPay($voucher_order['order_no'],$total_fee,'订单充值',$notify_url,'https://'.$_SERVER['HTTP_HOST'].'/h5/pages/mine/mine',$user['bank_num']); $retrun_data['order_no'] = $voucher_order['order_no']; $retrun_data['extend'] = $this->uid; $retrun_data['pay'] = json_decode($result['data'],true); if( $retrun_data['pay']['head']['respCode'] != '00000')$this->error($retrun_data['pay']['head']['respMsg'].'请重新下单'); break; case 'sd_rapid': $rapid = new ShandeRapid(); $return_url ='https://'.$_SERVER['HTTP_HOST']."/h5/pages/mine/mine?id={$order_id}&orderNo={$voucher_order['order_no']}";//回调地址 $pay_extra = json_encode(['userId'=>"$this->uid",'userName'=>$user['true_name'],'idCard'=>$user['id_card']]); $pay_url = $rapid->payOrder($voucher_order['order_no'],$money,$notify_url,$return_url,$pay_extra,'余额充值'); parse_str(parse_url($pay_url)['query'],$pay_query); $retrun_data['parse_url'] = parse_url($pay_url)['query']; $retrun_data['order_no'] = $voucher_order['order_no']; $retrun_data['extend'] = $this->uid; $retrun_data['pay_url'] = $pay_url; $retrun_data['pay_query'] = $pay_query; break; } Db::commit(); }catch (\Exception $e){ Db::rollback(); DelRedisSetNx($this->request->action().$this->uid); $this->error($e->getMessage()); } DelRedisSetNx($this->request->action().$this->uid); $this->success('ok',$retrun_data); }else{ $this->error('服务器繁忙'); } } }