yzms/show/pay_yzf_pc.php

731 lines
28 KiB
PHP
Raw Normal View History

2024-04-01 15:54:27 +08:00
<?
require_once("common.php");
$act = $_GET['act'];
$ftid = intval($_GET['ftid']);
$channelid = intval($_GET['channelid']);
if(!$ftid) {
die("no ftid!");
}
if(!$channelid) {
die("no channelid!");
}
function createSign($str, $p12data, $p12pass)
{
$s = openssl_pkcs12_read($p12data, $cinfo, $p12pass);
$pkey = $cinfo['pkey'];
$pkey = openssl_pkey_get_private($pkey);
$r = openssl_sign($str, $sign, $pkey, "SHA256" );
return base64_encode($sign);
}
$iscomplete = $_GET['iscomplete'];
if(!$act && !$iscomplete && !$_GET['code']) {
header("Location: ?".$_SERVER['QUERY_STRING']."&iscomplete=1");
exit;
}
$ftInfo = $db->get_one("select * from tb_dining_hall where id=".$ftid);
if(!$ftInfo) {
die("no ftid dining_hall!");
}
$company_id = intval($ftInfo['company_id']);
$companyInfo = $db->get_one("select * from tb_company where id=".$company_id);
if(!$companyInfo) {
die("company error!");
}
$pay_values = trim($ftInfo['pay_values']);
$cList = $db->get_all("select * from tb_pos_channel where dining_hall_id=".$ftid." and enabled=1 order by id");
if($channelid) {
$cInfo = $db->get_one("select * from tb_pos_channel where id=".$channelid);
if(!$cInfo || $cInfo['dining_hall_id'] != $ftid) {
header("Content-Type: text/html; charset=utf-8");
die("消费机和饭堂不对应!");
}
$storeId = $cInfo['storeId'];
}
if(!$storeId) $storeId = '01';
$merchantId = $companyInfo['yzf_merchantId'];
$yzf_version = $companyInfo['yzf_version'];
if($yzf_version == 2) {
$cer = $companyInfo['yzfcz_cer'];
$p12 = $companyInfo['yzfcz_p12'];
$p12_pass = $companyInfo['yzfcz_p12_pass'];
} else {
$mpw = $companyInfo['yzf_mpw'];
$mkey = $companyInfo['yzf_mkey'];
}
if($act == 'pay') {
$fee = $_POST['fee'];
$code = $_POST['code'];
if(!$fee || !$code) exit;
//sleep(1);echoRs(1, 'ok', array('transPhone' => '18988888888', 'paytime' => date("Y-m-d H:i:s")));
$N = 0;
$rid = 0;
while(1) {
$orderNo = date("YmdHis")."".mt_rand(100000,999999);
$db->query("insert into tb_yzf_paylog set orderNo='{$orderNo}', ftid={$ftid}, channelid={$channelid}, payfee='{$fee}', code='{$code}', ip='".$_SERVER['REMOTE_ADDR']."', addtime=now()");
if($db->affected_rows() == 1) {
$rid = $db->insert_id();
break;
}
$N++;
if($N >= 100) break;
}
if(!$rid) {
exit;
}
if($yzf_version == 2) {
$time = date("Y-m-d H:i:s");
//$ddh = date("YmdHis")."".mt_rand(100000,999999);
$post = array(
'merchantNo' => $merchantId,
'outTradeNo' => $orderNo,
'tradeAmt' => round($fee*100)."",
'ccy' => '156',
'requestDate' => $time,
'tradeChannel' => 'APP',
'accessCode' => 'EXTERNAL_PAYMENT',
'subject' => '云中美食',
'goodsInfo' => '云中美食消费',
'operator' => $merchantId,
'storeCode' => $storeId,
'authCode' => $code,
);
ksort($post);
$tosign = get_kvstr($post);
//echo "签名原串: \n".$tosign."\n\n";
$sign = createSign($tosign, $p12, $p12_pass);
//echo "签名: \n".$sign."\n\n";
$post['sign'] = $sign;
$json = json_encode($post);
$s = gquery("https://mapi.bestpay.com.cn/mapi/uniformReceipt/barCodePay", $json , array("Content-Type: application/json"));
$a = json_decode($s, true);
$db->query("update tb_yzf_paylog set success='".intval($a['success'])."',transStatus='".addslashes($a['result']['tradeStatus'])."',transPhone='".addslashes($a['result']['buyerLoginNo'])."',respDesc='".addslashes($a['result']['tradeResultDesc'])."',errorMsg='".addslashes($a['errorMsg'])."', raw_str='".addslashes($s)."' where id=". $rid);
if(!$a) {
echoRs(0, '支付失败1');
}
if($a['success'] && $a['result'] && $a['result']['tradeStatus']) {
if($a['result']['tradeStatus'] == 'WAITFORPAY') {
echoRs_n(2, '支付中', array('transPhone' => $a['result']['buyerLoginNo'], 'orderNo' => $orderNo));
} else if($a['result']['tradeStatus'] == 'SUCCESS') {
echoRs_n(1, 'ok', array('transPhone' => $a['result']['buyerLoginNo'], 'paytime' => date("Y-m-d H:i:s")));
} else if($a['result']['tradeStatus'] == 'FAIL') {
if($a['result']['tradeResultDesc']) echoRs(0, $a['result']['buyerLoginNo'].": ".$a['result']['tradeResultDesc']);
else echoRs(0, '支付失败4');
} else {
echoRs(0, '支付失败3');
}
} else {
if($a['errorMsg']) echoRs(0, $a['errorMsg']);
else echoRs(0, '支付失败2');
}
} else {
$post = array();
$post['merchantId'] = $merchantId;
$post['barcode'] = $code;
$post['orderNo'] = $orderNo;
$post['orderReqNo'] = $post['orderNo']."_seq";
$post['channel'] = "05";
$post['busiType'] = "0000001";
$post['orderDate'] = date("YmdHis");
$post['orderAmt'] = round($fee*100);
$post['productAmt'] = $post['orderAmt'];
$post['attachAmt'] = "0";
$post['goodsName'] = "饭堂消费";
$post['storeId'] = $storeId;
$tosign = "MERCHANTID=".$post['merchantId']."&ORDERNO=".$post['orderNo']."&ORDERREQNO=".$post['orderReqNo']."&ORDERDATE=".$post['orderDate']."&BARCODE=".$post['barcode']."&ORDERAMT=".$post['orderAmt']."&KEY=". $mkey;
$post['mac'] = strtoupper(md5($tosign));
$qs = '';
foreach($post as $key => $v) {
if($qs != '') $qs .= "&";
$qs .= $key . "=" . urlencode($v);
}
$url = "https://webpaywg.bestpay.com.cn/barcode/placeOrder?".$qs;
//echo $url;exit;
$s = gquery($url);
$a = json_decode($s, true);
$db->query("update tb_yzf_paylog set success='".addslashes($a['success'])."',transStatus='".addslashes($a['result']['transStatus'])."',transPhone='".addslashes($a['result']['transPhone'])."',respDesc='".addslashes($a['result']['respDesc'])."',errorMsg='".addslashes($a['errorMsg'])."', raw_str='".addslashes($s)."' where id=". $rid);
if(!$a) {
echoRs(0, '支付失败1');
}
//file_put_contents("yzf.txt", date("Y-m-d H:i:s").":".print_r($a, 1)."\n", FILE_APPEND);
if($a['success'] && $a['result'] && $a['result']['transStatus']) {
if($a['result']['transStatus'] == 'A') {
echoRs_n(2, '支付中', array('transPhone' => $a['result']['transPhone'], 'orderNo' => $orderNo));
} else if($a['result']['transStatus'] == 'B') {
echoRs_n(1, 'ok', array('transPhone' => $a['result']['transPhone'], 'paytime' => date("Y-m-d H:i:s")));
} else if($a['result']['transStatus'] == 'C') {
if($a['result']['respDesc']) echoRs(0, $a['result']['transPhone'].": ".$a['result']['respDesc']);
else echoRs(0, '支付失败4');
} else {
echoRs(0, '支付失败3');
}
} else {
if($a['errorMsg']) echoRs(0, $a['errorMsg']);
else echoRs(0, '支付失败2');
}
}
exit;
}
if($act == 'getPayStatus') {
$orderNo = trim($_POST['orderNo']);
//$orderNo = '20191011153939951369';
if(!$orderNo) exit;
if($yzf_version == 2) {
$row = $db->get_one("select * from tb_yzf_paylog where orderNo = '{$orderNo}'");
if(!$row) {
echoRs(0, '订单不存在!');
}
$post = array();
$post['merchantNo'] = $merchantId;
$post['outTradeNo'] = $orderNo;
$post['tradeDate'] = $row['addtime'];
ksort($post);
$tosign = get_kvstr($post);
//echo "签名原串: \n".$tosign."\n\n";
$sign = createSign($tosign, $p12, $p12_pass);
//echo "签名: \n".$sign."\n\n";
$post['sign'] = $sign;
$json = json_encode($post);
$s = gquery("https://mapi.bestpay.com.cn/mapi/uniformReceipt/tradeQuery", $json , array("Content-Type: application/json"));
$a = json_decode($s, true);
if(!$a) {
echoRs(2, '未知');
}
$db->query("update tb_yzf_paylog set transStatus='".addslashes($a['result']['tradeStatus'])."',respDesc='".addslashes($a['result']['tradeResultDesc'])."',errorMsg='".addslashes($a['errorMsg'])."', raw_str2='".addslashes($s)."' where orderNo='{$orderNo}' and transStatus = 'WAITFORPAY'");
if($a['success'] && $a['result'] && $a['result']['tradeStatus']) {
if($a['result']['tradeStatus'] == 'WAITFORPAY') {
echoRs(2, '支付中', array('transPhone' => $a['result']['buyerLoginNo'], 'orderNo' => $orderNo));
} else if($a['result']['tradeStatus'] == 'SUCCESS') {
echoRs(1, 'ok', array('transPhone' => $a['result']['buyerLoginNo'], 'paytime' => date("Y-m-d H:i:s")));
} else if($a['result']['tradeStatus'] == 'FAIL') {
if($a['result']['tradeResultDesc']) echoRs(0, $a['result']['buyerLoginNo'].": ".$a['result']['tradeResultDesc']);
else echoRs(0, '支付失败4');
} else {
echoRs(0, '支付失败3');
}
} else {
if($a['errorMsg']) echoRs(0, $a['errorMsg']);
else echoRs(0, '支付失败2');
}
} else {
$post = array();
$post['merchantId'] = $merchantId;
$post['orderNo'] = $orderNo;
$post['orderReqNo'] = $post['orderNo']."_seq";
$post['orderDate'] = date("YmdHis");
$tosign = "MERCHANTID=".$post['merchantId']."&ORDERNO=".$post['orderNo']."&ORDERREQNO=".$post['orderReqNo']."&ORDERDATE=".$post['orderDate']."&KEY=". $mkey;
$post['mac'] = strtoupper(md5($tosign));
$qs = '';
foreach($post as $key => $v) {
if($qs != '') $qs .= "&";
$qs .= $key . "=" . urlencode($v);
}
$url = "https://webpaywg.bestpay.com.cn/query/queryOrder?".$qs;
$s = gquery($url);
$a = json_decode($s, true);
if(!$a) {
echoRs(2, '未知');
}
$db->query("update tb_yzf_paylog set transStatus='".addslashes($a['result']['transStatus'])."',respDesc='".addslashes($a['result']['respDesc'])."',errorMsg='".addslashes($a['errorMsg'])."', raw_str2='".addslashes($s)."' where orderNo='{$orderNo}' and transStatus = 'A'");
if($a['success'] && $a['result'] && $a['result']['transStatus']) {
if($a['result']['transStatus'] == 'A') {
echoRs(2, '支付中', array('transPhone' => $a['result']['transPhone'], 'orderNo' => $orderNo));
} else if($a['result']['transStatus'] == 'B') {
echoRs(1, 'ok', array('transPhone' => $a['result']['transPhone'], 'paytime' => date("Y-m-d H:i:s")));
} else if($a['result']['transStatus'] == 'C') {
if($a['result']['respDesc']) echoRs(0, $a['result']['transPhone'].": ".$a['result']['respDesc']);
else echoRs(0, '支付失败4');
} else {
echoRs(0, '支付失败3');
}
} else {
if($a['errorMsg']) echoRs(0, $a['errorMsg']);
else echoRs(0, '支付失败2');
}
}
exit;
}
if($act == 'cancalPay') {
$orderNo = trim($_POST['orderNo']);
if(!$orderNo) exit;
$orderInfo = $db->get_one("select * from tb_yzf_paylog where orderNo='{$orderNo}'");
if(!$orderInfo) exit;
if($yzf_version == 2) {
$s = 'ok';
$status = 'cancel_ok';
} else {
$post = array();
$post['merchantId'] = $merchantId;
$post['merchantPwd'] = $mpw;
$post['oldOrderNo'] = $orderNo;
$post['oldOrderReqNo'] = $post['oldOrderNo']."_seq";
$post['refundReqNo'] = $post['oldOrderNo']."_cancel";
$post['refundReqDate'] = date("Ymd");
$post['transAmt'] = round($orderInfo['payfee']*100);
$post['channel'] = '05';
$tosign = "MERCHANTID=".$post['merchantId']."&MERCHANTPWD=".$post['merchantPwd']."&OLDORDERNO=".$post['oldOrderNo']."&OLDORDERREQNO=".$post['oldOrderReqNo']."&REFUNDREQNO=".$post['refundReqNo']."&REFUNDREQDATE=".$post['refundReqDate']."&TRANSAMT=".$post['transAmt']."&KEY=". $mkey;
$post['mac'] = strtoupper(md5($tosign));
$qs = '';
foreach($post as $key => $v) {
if($qs != '') $qs .= "&";
$qs .= $key . "=" . urlencode($v);
}
$url = "https://webpaywg.bestpay.com.cn/reverse/reverse";
$s = gquery($url, $qs);
$a = json_decode($s, true);
$status = 'cancel_ok';
if(!$a) {
$status = 'cancel_error';
} else if($a['success'] != 1) {
$status = 'cancel_fail';
}
}
$db->query("update tb_yzf_paylog set transStatus='{$status}', raw_str_cancel='".addslashes($s)."' where id=".$orderInfo['id']);
exit;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>翼支付付款</title>
<script src="js/func.js"></script>
<script>
function fromKeyCode(code) {
if((code >= 48 && code <= 57) || (code >= 65 && code <= 90)) return String.fromCharCode(code);
var keys = {186: ';', 188: ',', 189: '-', 190: '.', 191: '/', 222: "'", 219: '[', 221: ']', 187: '=',
96:'Num 0', 97:'Num 1', 98:'Num 2', 99:'Num 3', 100:'Num 4', 101:'Num 5', 102:'Num 6', 103:'Num 7', 104:'Num 8', 105:'Num 9',
111:'Num /', 106:'Num *', 109:'Num -', 111:'Num /', 107:'Num +',13:'[enter]',8:'[back]',110:'Num .'
};
if(keys[code]) return keys[code];
return '*err*';
}
var kb_status = '1';
var kb_readStr = '';
/*document.onkeydown = function() {
var code = event.keyCode;
if(code == 16) return ;
//$("div1").innerHTML += fromKeyCode(code)+"<br />"; return ;
kb_dealKey(fromKeyCode(code));
}*/
function kb_dealKey(c) {
if(kb_status == '1') { //开始
if(c >= '0' && c <= '9') {
kb_readStr = c;
kb_status = '2';
} else kb_readErr(2);
} else if(kb_status == '2') { //读取s
if(c == '[enter]') {
kb_readContent(kb_readStr);
kb_status = '1';
kb_readStr = '';
} else if(c >= '0' && c <= '9') {
kb_readStr += c;
} else {
kb_status = '1';
kb_readErr(3);
}
}
}
function kb_readErr(rs, type) {
kb_status = '1';
kb_readStr = '';
}
function kb_readContent(str) {
//$("div1").innerHTML += str+"<br />";
if(!isshowQR) return ;
addOrder(str);
}
var itvList = {};
var djsNow = {};
function showDjs(id, tid, time, func) {
if(itvList[id]) return ;
djsNow[id] = time;
$(tid).innerHTML = djsNow[id];
itvList[id] = setInterval(function() {
djsNow[id]--;
if(djsNow[id] <= 0) {
try{clearInterval(itvList[id]);} catch(e){}
delete(itvList[id]);
func();
return ;
}
$(tid).innerHTML = djsNow[id];
}, 1000);
}
function closeAlert() {
if(itvList['fdiv_alert']) { try{clearInterval(itvList['fdiv_alert']);} catch(e){} delete(itvList['fdiv_alert']); }
$G.hide_div("fdiv_alert");
}
function myalert(str) {
$("alert_msg").innerHTML = str;
$G.show_div("fdiv_alert", 600, 250);
showDjs('fdiv_alert', 'alert_close_time', 10, closeAlert);
}
var nowNum = '';
function doInput(c) {
if(c == '0') {
if(nowNum.substr(0, 1) == '0' && nowNum.substr(1, 1) != '.') {
} else {
if(nowNum.indexOf(".") != -1) {
var a = nowNum.split(".");
if(a[1].length < 2)
nowNum += c;
} else nowNum += c;
}
} else if(c >= '1' && c <= '9') {
if(nowNum.indexOf(".") != -1) {
var a = nowNum.split(".");
if(a[1].length < 2)
nowNum += c;
} else nowNum += c;
} else if(c == '.') {
if(nowNum != '' && nowNum.indexOf(".") == -1) nowNum += c;
} else if(c == 'C') {
nowNum = '';
} else if(c == 'S') {
if(nowNum == '') {
myalert("请输入金额!");
} else {
if(nowNum.substr(nowNum.length-1) == '.') nowNum = nowNum.substr(0, nowNum.length-1);
if(nowNum > 50000) {
myalert("金额不能大于50000");
} else {
payfee = nowNum;
nowNum = '';
showQR();
}
}
} else if(c == 'B') {
if(nowNum != '') nowNum = nowNum.substr(0, nowNum.length-1);
}
if(nowNum == '') {
$("feeDiv").style.color = 'blue';
$("feeDiv").innerHTML = "请输入要支付的金额";
} else {
$("feeDiv").style.color = 'red';
$("feeDiv").innerHTML = nowNum;
}
}
function setMsg2(str) {
$("qrmsgdiv").innerHTML = str;
}
var isshowQR = false;
var payfee = 0;
var reshowfee = ''; //连续显示付款金额
var channelid = '<?=$channelid?>';
var checkqritv = null;
function showQR() {
if(isshowQR) return ;
if(payfee == 0) {
myalert("请输入金额!");
return ;
}
var html = payfee + "";
setMsg2("请刷付款二维码");
$("dishListTd").innerHTML = html;
$G.show_div("fdiv", 800, 450);
isshowQR = true;
$("qrcode").value = '';
try{$("qrcode").focus();}catch(e){}
checkqritv = setInterval(function() {
if(document.activeElement != $("qrcode")) {
$("qrcode").value = '';
try{$("qrcode").focus();}catch(e){}
}
var s = $G.trim($("qrcode").value);
if(s.length >= 18) {
s = s.substr(0, 18);
if(s.match(/^\d+$/)) {
kb_readContent(s);
$("qrcode").value = '';
}
}
}, 10);
}
function closeQR() {
if(itvList['fdiv']) { try{clearInterval(itvList['fdiv']);} catch(e){} delete(itvList['fdiv']); }
if(checkqritv) { try{clearInterval(checkqritv);} catch(e){} checkqritv = null; }
isshowQR = false;
$G.hide_div("fdiv");
if(reshowfee != '') {
setInput(reshowfee);
}
}
var getting = false;
var lastGetStatusTime = 0;
function getPayStatus(orderNo) {
$G.ajax("?act=getPayStatus&ftid=<?=$ftid?>&channelid="+channelid, {'orderNo': orderNo}, function(rs) {
if(rs.status != 2) {
getting = false;
$("closeQrBt").disabled = false;
$("qrcode").disabled = false;
}
if(rs.status == 0) {
if(rs.message) {
setMsg2(rs.message);
}
else setMsg2("系统错误,请重试!");
} else if(rs.status == 1) {
setMsg2('<div style="color:#009900; font-size:30px"><img src="images/payok.png" style="vertical-align:middle" width="100" height="100" />支付成功!</div>');
setMsg2('<div style="color:#009900; font-size:30px"><img src="images/payok.png" style="vertical-align:middle" width="100" height="100" />支付成功!</div><div style="color:#666666; font-size:20px;margin-top:10px;line-height:1.5">支付账号: ' + rs.transPhone + '<br />支付时间: ' + rs.paytime + '</div>');
} else if(rs.status == 2) {
if(new Date().getTime() - lastGetStatusTime > 40000) { //40秒无结果
cancalPay(orderNo);
setMsg2("支付超时,已取消!");
} else {
setTimeout(function(){getPayStatus(orderNo);}, 3000);
}
} else {
setTimeout(function(){getPayStatus(orderNo);}, 3000);
}
}, 'json', 'POST');
}
function cancalPay(orderNo) {
$G.ajax("?act=cancalPay&ftid=<?=$ftid?>&channelid="+channelid, {'orderNo': orderNo}, function(rs) {
getting = false;
$("closeQrBt").disabled = false;
$("qrcode").disabled = false;
}, 'json', 'POST');
}
function addOrder(code) {
if(getting) return ;
setMsg2('<span style="color:blue">已扫描二维码,请稍候...</span>');
getting = true;
$("closeQrBt").disabled = true;
$("qrcode").disabled = true;
$G.ajax("?act=pay&ftid=<?=$ftid?>&channelid="+channelid, {'fee': payfee, 'code': code}, function(rs) {
if(rs.status != 2) {
getting = false;
$("closeQrBt").disabled = false;
$("qrcode").disabled = false;
}
if(rs.status == 0) {
if(rs.message) {
setMsg2(rs.message);
}
else setMsg2("系统错误,请重试!");
} else if(rs.status == 1) {
setMsg2('<div style="color:#009900; font-size:30px"><img src="images/payok.png" style="vertical-align:middle" width="100" height="100" />支付成功!</div><div style="color:#666666; font-size:20px;margin-top:10px;line-height:1.5">支付账号: ' + rs.transPhone + '<br />支付时间: ' + rs.paytime + '</div>');
} else if(rs.status == 2) {
setMsg2('<div style="color:blue; font-size:27px">'+rs.transPhone+'支付中,请稍候...</div>');
lastGetStatusTime = new Date().getTime();
getPayStatus(rs.orderNo);
} else {
setMsg2("系统错误,请重试!");
}
}, 'json', 'POST');
}
function showChannels() {
<? if(!$cList) { ?>
myalert("该饭堂未配置消费机!");
<? } else { ?>
$G.show_div("fdiv_channel", 700, 350);
<? } ?>
}
function setChannelId(cid, cname) {
channelid = cid;
$("now_channel_id").innerHTML = decodeURIComponent(cname);
$G.hide_div("fdiv_channel");
}
function setInput(y) {
nowNum = y;
reshowfee = y;
doInput('S');
}
window.onload = function() {
<? if($companyInfo['show_qr']) { ?>
var width = document.documentElement.clientWidth;
var height = document.documentElement.clientHeight;
var owidth = $("qiehuan").offsetWidth;
var oheight = $("qiehuan").offsetHeight;
$("qiehuan").style.top = (height - oheight - 10) + 'px';
$("qiehuan").style.left = (width - owidth - 10) + 'px';
<? } ?>
<?
$payfee = floatval($_GET['payfee']);
$code = trim($_GET['code']);
if($payfee > 0 && $code != '') {
?>
payfee = '<?=$payfee?>';
nowNum = '';
showQR();
addOrder('<?=$code?>');
<?
}
?>
//payfee = '0.01';
//nowNum = '';
//showQR();
//readContent('1', 'b6b63d16b8a');
}
</script>
<style type="text/css">
.numDiv {
position:absolute; width:100px; height:90px; border:1px solid #dddddd; background:#f9f9f9;
}
.textDiv {
text-align:center; font-size:60px; font-weight:bold; color:#666666; margin-top:10px;
}
</style>
</head>
<body style="margin:0px">
<div style="width:550px; height:520px; border:1px solid #dddddd; margin:10px; position:relative;">
<div style="position:absolute; width:100%; height:60px; top:0px; left:0px; background:#f9f9f9; border-bottom:1px solid #dddddd;"><div id="feeDiv" style="font-size:35px; margin-left:10px; margin-top:12px; color:blue; font-weight:bold">请输入要支付的金额</div></div>
<div class="numDiv" style="left:15px; top:80px;" onmousedown="this.style.backgroundColor='#eeeeee';" onmouseup="this.style.backgroundColor='#f9f9f9';" onclick="doInput('1')"><div class="textDiv">1</div></div>
<div class="numDiv" style="left:145px; top:80px;" onmousedown="this.style.backgroundColor='#eeeeee';" onmouseup="this.style.backgroundColor='#f9f9f9';" onclick="doInput('2')"><div class="textDiv">2</div></div>
<div class="numDiv" style="left:275px; top:80px;" onmousedown="this.style.backgroundColor='#eeeeee';" onmouseup="this.style.backgroundColor='#f9f9f9';" onclick="doInput('3')"><div class="textDiv">3</div></div>
<div class="numDiv" style="left:15px; top:190px;" onmousedown="this.style.backgroundColor='#eeeeee';" onmouseup="this.style.backgroundColor='#f9f9f9';" onclick="doInput('4')"><div class="textDiv">4</div></div>
<div class="numDiv" style="left:145px; top:190px;" onmousedown="this.style.backgroundColor='#eeeeee';" onmouseup="this.style.backgroundColor='#f9f9f9';" onclick="doInput('5')"><div class="textDiv">5</div></div>
<div class="numDiv" style="left:275px; top:190px;" onmousedown="this.style.backgroundColor='#eeeeee';" onmouseup="this.style.backgroundColor='#f9f9f9';" onclick="doInput('6')"><div class="textDiv">6</div></div>
<div class="numDiv" style="left:15px; top:300px;" onmousedown="this.style.backgroundColor='#eeeeee';" onmouseup="this.style.backgroundColor='#f9f9f9';" onclick="doInput('7')"><div class="textDiv">7</div></div>
<div class="numDiv" style="left:145px; top:300px;" onmousedown="this.style.backgroundColor='#eeeeee';" onmouseup="this.style.backgroundColor='#f9f9f9';" onclick="doInput('8')"><div class="textDiv">8</div></div>
<div class="numDiv" style="left:275px; top:300px;" onmousedown="this.style.backgroundColor='#eeeeee';" onmouseup="this.style.backgroundColor='#f9f9f9';" onclick="doInput('9')"><div class="textDiv">9</div></div>
<div class="numDiv" style="left:15px; top:410px; width:232px" onmousedown="this.style.backgroundColor='#eeeeee';" onmouseup="this.style.backgroundColor='#f9f9f9';" onclick="doInput('0')"><div class="textDiv">0</div></div>
<div class="numDiv" style="left:275px; top:410px;" onmousedown="this.style.backgroundColor='#eeeeee';" onmouseup="this.style.backgroundColor='#f9f9f9';" onclick="doInput('.')"><div class="textDiv">.</div></div>
<div class="numDiv" style="left:405px; top:300px; width:120px;" onmousedown="this.style.backgroundColor='#eeeeee';" onmouseup="this.style.backgroundColor='#f9f9f9';" onclick="doInput('C')"><div class="textDiv" style="font-size:50px; margin-top:15px">归零</div></div>
<div class="numDiv" style="left:405px; top:410px; width:120px;" onmousedown="this.style.backgroundColor='#eeeeee';" onmouseup="this.style.backgroundColor='#f9f9f9';" onclick="doInput('S')"><div class="textDiv" style="font-size:50px; margin-top:15px">确定</div></div>
<div class="numDiv" style="left:405px; top:190px; width:120px;" onmousedown="this.style.backgroundColor='#eeeeee';" onmouseup="this.style.backgroundColor='#f9f9f9';" onclick="doInput('B')"><div class="textDiv" style="font-size:50px; margin-top:15px"></div></div>
<div class="numDiv" style="left:405px; top:80px; width:120px;" onmousedown="this.style.backgroundColor='#eeeeee';" onmouseup="this.style.backgroundColor='#f9f9f9';" onclick="showChannels()"><div class="textDiv" style="font-size:30px; margin-top:11px;color:red">切换<br />消费机</div></div>
</div>
<!-- 刘伟添加价格标签 -->
<div style="position: absolute;width: 200px;height: 520px;border:1px solid #dddddd;left: 575px;top: 10px;">
<div style="position:absolute; width:100%; height:60px; top:0px; left:0px; background:#f9f9f9; border-bottom:1px solid #dddddd;"><div id="feeDiv" style="font-size:35px; margin-left:10px; margin-top:12px; color:blue; font-weight:bold">标签</div></div>
<?
if(!$pay_values) $pay_values = '5,10,15';
$a = explode(",", $pay_values);
$n = count($a);
$total_h = 450;
$padding = 20;
if($n >= 4) $padding = 10;
$height = intval(($total_h - ($n+1)*$padding)/$n);
if($height > 90) $height = 90;
$fontsize = intval($height*0.666);
if($fontsize >= 60) $fontsize = 60;
foreach($a as $key => $value) { ?>
<div class="numDiv" style="left:20px; top:<?=((60+$padding)+intval($key*($height+$padding)))?>px; width:160px; height:<?=$height?>px;" onmousedown="this.style.backgroundColor='#eeeeee';" onmouseup="this.style.backgroundColor='#f9f9f9';" onclick="setInput('<?=$value?>')"><div class="textDiv" style="font-size:<?=$fontsize?>px; line-height:<?=$height?>px; height:<?=$height?>px;margin-top:0px"><?=$value?>元</div></div>
<? }?>
</div>
<div style="margin-left:10px;font-weight:bold">当前饭堂: <span style="color:red;"><?=$ftInfo['name']?></span> 消费机: <span id="now_channel_id" style="color:red;"><?=$cInfo?$cInfo['channel_name']:"未选择"?></span></div>
<div id="testdiv"></div>
<div id="fdiv" style="position:absolute; z-index:15; width:800px; height:450px; display:none; background:#FFFFFF; border:1px solid #dddddd;">
<div style="border-bottom:1px solid #dddddd; height:28px; background:#f5f5f5">
<div style="float:left; padding:5px 5px"><span style="color:#666666">请刷二维码</span></div>
<div style="float:right; padding:5px 5px; font-size:13px; color:#666666"><span id="qr_close_time" style="color:#666666"></span>&nbsp;</div>
</div>
<div style="height:390px; overflow:hidden;text-align:center;width:798px;">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td width="500" style="padding:10px; text-align:left" valign="top" align="left">
<div id="dishListTd" style="color:red; font-size:80px; font-weight:bold"></div>
<div style="color:red;font-size:25px;font-weight:bold; margin-top:80px" id="qrmsgdiv"></div>
</td>
<td width="300" style="padding:10px" valign="top">
<div><img src="images/showqr.jpg" width="280" /></div>
<div><input id="closeQrBt" type="button" style="width:140px; height:50px; font-size:30px;margin-top:30px" value="关闭" onclick="reshowfee='';closeQR()" /></div>
<div><input type="text" id="qrcode" style="filter:alpha(opacity=5); opacity:0.05; height:2px; border:0px" /></div>
</td>
</tr>
</table>
</div>
</div>
<div id="fdiv_alert" style="position:absolute; z-index:15; width:600px; height:250px; display:none; background:#FFFFFF; border:1px solid #dddddd;">
<div style="border-bottom:1px solid #dddddd; height:28px; background:#f5f5f5">
<div style="float:left; padding:5px 5px"><span style="color:#666666">提示</span></div>
<div style="float:right; padding:5px 5px; font-size:13px; color:#666666"><span id="alert_close_time" style="color:#666666"></span>&nbsp;秒后关闭</div>
</div>
<div style="height:410px; overflow:hidden;text-align:center">
<div id="alert_msg" style="font-size:50px; color:red;font-weight:bold; text-align:center;height:115px;padding-top:30px"></div>
<div style="text-align:center;margin-top:5px"><input type="button" style="width:140px; height:50px; font-size:30px;" value="关闭" onclick="closeAlert()" /></div>
</div>
</div>
<div id="fdiv_channel" style="position:absolute; z-index:15; width:700px; height:350px; display:none; background:#FFFFFF; border:1px solid #dddddd;">
<div style="border-bottom:1px solid #dddddd; height:28px; background:#f5f5f5">
<div style="float:left; padding:5px 5px"><span style="color:#666666">请选择消费机</span></div>
</div>
<div style="height:310px; overflow:hidden;text-align:center;width:698px;padding:10px 10px 0px 10px">
<? foreach($cList as $item) { ?>
<a style="display:block; height:30px; float:left; border: 1px solid #DDDDDD; background-color:#F5F5F5; color:#666666; margin:5px; height:30px; padding:10px 5px 0px 5px;cursor:pointer" onclick="setChannelId(<?=$item['id']?>, '<?=rawurlencode($item['channel_name'])?>')"><nobr><?=$item['channel_name']?></nobr></a>
<? } ?>
</div>
</div>
<? if($companyInfo['show_qr']) { ?>
<div id="qiehuan" style="position:absolute; z-index:4;width:150px; height:60px; top:500px; left:700px"><input type="button" style="width:150px; height:60px;font-size:25px;font-weight:bold;color:blue" value="付款码支付" onclick="location.href = 'qc_pay.php?<?=$_SERVER['QUERY_STRING']?>';" /></div>
<? } ?>
</body>
</html>