if($isapp == 1){
/* 微信app支付参数 */
$mch_id = '1560381801';//商户id
$data['appid']=' ';
$data['mch_id']=$mch_id;
$data['nonce_str']=createNonceStr();//签名获取字符串
$data['body']='购买商品';
$data['out_trade_no']=$orderinfo['ordersn'].'_'.date('his');
$data['total_fee']=($orderinfo['price']*100);
$data['spbill_create_ip']=getip();
$data['time_start']=date("YmdHis");
$data['time_expire']=(date("YmdHis", time() + 600));
$data['notify_url']='http://'.SITE_DOMAIN.'/payment/wxpayapp_notify.html'; //异步
$data['trade_type']='APP';
$data['sign']=tuikuan_hb_MakeSign($data,'密钥'); //生成签名 密钥
$xml=tuikuan_hb_arraytoxml($data);//转换xml格式
$url='https://api.mch.weixin.qq.com/pay/unifiedorder'; //接口连接
$res=tuikuan_hb_curl($xml,$url);
$return=tuikuan_hb_xmltoarray($res);
log_resulttest('App支付日志回调xml:'.json_encode($xml));
log_resulttest('App支付日志回调Notify:'.json_encode($data['notify_url']));
log_resulttest('App支付日志:'.json_encode($return));
/* $map['ordersn_all']=$ordersn;
$orderlist=get_model_other($map,'shop_order');*/
$ordesn = $orderinfo['ordersn_all'];
$map['ordersn_all']=$ordesn;
$orderlist=get_model_other($map,'shop_order');
if(!$orderlist){
$data11['status']=0;
$data11['msg']='订单不存在';
echo json_encode($data11);exit;
}
$idaall=onebas('id', $orderlist);
$param['from']='shop_order';//回调地址
$param['laiyuantype']='weixin';
$param['orderName']= '商城_订单支付';//订单名称
$param['price']=$orderinfo['price'];//价格
$param['addons']='shop_order';
$param['opuid']=$userinfo['uid'];
$param['actiontype']=$action;
$param['paytype']='wxpay';//支付方式
$param['trade_type']='app';//支付说明
$param['showwxpaytitle']=0;//是否显示标题
$param['status']=0;//支付状态
$param['transaction_id']='';//微信订单支付编号
$param['single_orderid']=$data['out_trade_no'];
$param['addtime']=time();
$param['paytype']='线上微信支付';
$param['mch_id']=$mch_id;
$param['actiontype']='buy';
$param['ordersn']=$orderinfo['ordersn'];
$param['orderidall']=json_encode($idaall);
$param['namepoor']='0';
$param['paytime']=time();
$param['temp_orderid']='ZFD'.date('YmdHis').mt_rand(1111, 9999).mt_rand(1111, 9999);//订单号
$param['single_orderid']=$param['temp_orderid'];//订单号
$param['sub_mch_id']=$_SESSION["PayConfig"]["wx"]["MCHID"];
payment_order_write($param);
if($return['return_code'] == 'SUCCESS' && $return['result_code'] == 'SUCCESS'){
$time=time();
$msg['appid']=$data['appid'];//appid
$msg['partnerid']=$data['mch_id'];//商户号
$msg['prepayid']=$return['prepay_id'];//微信返回的支付交易会话ID
$msg['noncestr']= $data['nonce_str'];
//$msg['signType']='MD5';
$msg['timestamp']=$time;
$msg['package']='Sign=WXPay';
$msg['sign']=$this->tuikuan_hb_MakeSign($msg,'密钥');;
$msg['timeStamp']=$time;
}
$this->msg = $msg;
/* 支付宝app支付 */
require(APP_DIR.DS.'wlb'.DS.'include'.DS.'alipayapp'.DS.'AopClient.php');
require(APP_DIR.DS.'wlb'.DS.'include'.DS.'alipayapp'.DS.'request'.DS.'AlipayTradeAppPayRequest.php');
$aop = new AopClient;
$aop->gatewayUrl = "https://openapi.alipay.com/gateway.do";
$aop->appId = " ";//Appid
$aop->rsaPrivateKey = ' ';//私钥
$aop->format = "json";
$aop->charset = "UTF-8";
$aop->signType = "RSA2";
$aop->alipayrsaPublicKey =' ';//公钥
$request = new AlipayTradeAppPayRequest();
$body="购买商品";
$money = $orderinfo['price'];
$weiyiorder=$orderinfo['ordersn'].'_'.date('his');
$bizcontent['body']=urlencode($body);
$bizcontent['subject']=urlencode($body);
$bizcontent['out_trade_no']=$weiyiorder;
$bizcontent['total_amount']=$money;
$request->setNotifyUrl($GLOBALS['http_scheme'].SITE_DOMAIN."/payment/alipayapp_notify.html");//商户外网可以访问的异步地址
$request->setBizContent(json_encode($bizcontent));
$response = $aop->sdkExecute($request);
$this->response =$response;
//$this->response = htmlspecialchars($response);
$this->display($this->c."/orderzhifudoandroid.html");
}