$value){
echo "$key : $value
";
}
}
function NumToStr($num){
if (stripos($num,'e')===false) return $num;
$num = trim(preg_replace('/[=\'"]/','',$num,1),'"');//出现科学计数法,还原成字符串
$result = "";
while ($num > 0){
$v = $num - floor($num / 10)*10;
$num = floor($num / 10);
$result = $v . $result;
}
return $result;
}
//①、获取用户openid
$tools = new JsApiPay();
// exit();
$openId = $tools->GetOpenid();
session_start();
//获取金额
$pFee = $_SESSION['premoney'];
// echo "".$pFee."";
$pBody = $_SESSION['body'];
$pCardNo = $_SESSION['cardno'];
$pRegID = $_SESSION['regId'];
$pRepeiceNo = $_SESSION['repeiceNo'];
$pOrder = $_SESSION['order'];
$pPatientID = $_SESSION['patientid'];
$pName = $_SESSION['name'];
$pPatientNO = $_SESSION['patientno'];
$tradeNo = NumToStr(WxPayConfig::MCHID.date("YmdHis"));
// echo "".$pCardNo."";
//微信订单表初始化
$tMO = new Model('wxorder');
$tTime = time();
$tDatas = $tMO->field('id')->where('out_trade_no = \''.$tradeNo.'\'')->select();
//查询卡号
$tMCMO = new Model('medical_card');
$tMCDatas = $tMCMO->field('med_c_card_no')->where('med_c_uid = '.$_SESSION['uid'])->select();
if(empty($pCardNo)) {
$tCardNo = $tMCDatas[0]['med_c_card_no'];
}else{
$tCardNo = $pCardNo;
}
if(empty($tDatas)) {
$tData = array(
'name' => $pName,
'total_fee' => $pFee/100,
'uid' => $_SESSION['uid'],
'prepay_id' => $pOrder,
'out_trade_no' => $tradeNo,
'created' => $tTime,
'status' => 1,
'patientid' => $pPatientID,
'regid' => $pRegID,
'repeiceno' => $pRepeiceNo,
'cardno' => $tCardNo,
);
$id = $tMO->insert($tData);
if(!$id){
return true;
}
}else{
$id = $tDatas[0]['id'];
}
switch($pBody) {
case 'zyyj': $pBody = '住院押金';break;
case 'mzjf': $pBody = '门诊缴费';break;
}
// var_dump($f);
//②、统一下单
$input = new WxPayUnifiedOrder();
$input->SetBody($pBody);
$input->SetAttach("test");
// $tradeNo = $input->SetOut_trade_no(WxPayConfig::MCHID.date("YmdHis"));
$input->SetOut_trade_no($tradeNo);
$input->SetTotal_fee($pFee);
$timestamp = date("YmdHis");
$input->SetTime_expire(date("YmdHis", time() + 600));
$input->SetGoods_tag("test");
$input->SetNotify_url("http://lyl.medical.91paiyipai.com/wxpay/example/notify.php");
$input->SetTrade_type("JSAPI");
$input->SetOpenid($openId);
$order = WxPayApi::unifiedOrder($input);
// echo '统一下单支付单信息
';
// var_dump($order);exit();
// printf_info($input);
$jsApiParameters = $tools->GetJsApiParameters($order);
//获取共享收货地址js函数参数
$editAddress = $tools->GetEditAddressParameters();
//③、在支持成功回调通知中处理成功之后的事宜,见 notify.php
/**
* 注意:
* 1、当你的回调地址不可访问的时候,回调通知会失败,可以通过查询订单来确认支付是否成功
* 2、jsapi支付时需要填入用户openid,WxPay.JsApiPay.php中有获取openid流程 (文档可以参考微信公众平台“网页授权接口”,
* 参考http://mp.weixin.qq.com/wiki/17/c0f37d5704f0b64713d5d2c37b468d75.html)
*/
?>
收款方郴州市中医医院
商 品