From 17984ab5163dcf879f9c22a70ea4794126c37c9a Mon Sep 17 00:00:00 2001 From: vguanyiwgd Date: Mon, 15 Apr 2024 16:47:11 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=9B=9E=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I99dc43fff6ecc309c68d54a99dde2ef6cbfe7d84 --- show/appletpay_recv.php | 145 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 145 insertions(+) create mode 100644 show/appletpay_recv.php diff --git a/show/appletpay_recv.php b/show/appletpay_recv.php new file mode 100644 index 0000000..41ff775 --- /dev/null +++ b/show/appletpay_recv.php @@ -0,0 +1,145 @@ + + + + + + + + + + + + + +1 + + + +";*/ +//if(!$xmls) exit; +file_put_contents("appletpay.log", date("Y-m-d H:i:s").": \n".$xmls."\n\n", FILE_APPEND); +$xml = simplexml_load_string($xmls); +if(!$xml) exit; + + +$data = array(); +foreach($xml->children() as $name => $node) { + $data[$name.""] = $node.""; +} +if(!$data) exit; +if(!$wxpay_key) { + $wxpay_key = 'a8555efc5395420ae8c62483f8732f84'; + + $out_trade_no = $data['out_trade_no']; + if($out_trade_no) { + $ddInfo = $db->get_one("select a.*, c.company_name, c.wxpay_key from tb_recharge_pay_weixin a, tb_user b, tb_company c where a.uid=b.id and b.company_id=c.id and a.code = '{$out_trade_no}'"); + if(!$ddInfo) exit; + + $wxpay_key = $ddInfo['wxpay_key']; + } +} +echo "get: -----------------\n"; +echo "
";
+print_r($_GET);
+echo "
"; + +echo "post: -----------------\n"; +echo "
";
+print_r($_POST);
+echo "
"; + +echo "input: -----------------\n"; +echo "
";
+print_r(file_get_contents("php://input"));
+echo "
"; + +echo "data: -----------------\n"; +echo "
";
+print_r($data);
+echo "
"; +exit; + +$db->query("insert into tb_recharge_pay_weixin_recv set bank_type='".$data['bank_type']."',cash_fee='".$data['cash_fee']."',fee_type='".$data['fee_type']."',is_subscribe='".$data['is_subscribe']."',openid='".$data['openid']."',out_trade_no='".$data['out_trade_no']."',result_code='".$data['result_code']."',return_code='".$data['return_code']."',sign='".$data['sign']."',time_end='".$data['time_end']."',total_fee='".$data['total_fee']."',trade_type='".$data['trade_type']."',transaction_id='".$data['transaction_id']."',trade_state='".$data['trade_state']."',trade_state_desc='".addslashes($data['trade_state_desc'])."',err_code='".$data['err_code']."',err_code_des='".$data['err_code_des']."',addtime=now()"); + +$sign = $data['sign']; +if(!$sign) exit; + + + +unset($data['sign']); +ksort($data); +$s1 = ''; +foreach($data as $key => $item) { + if($item != '') { + if($s1 != '') $s1 .= "&"; + $s1 .= $key."=".$item; + } +} +$s = $s1. "&key=".$wxpay_key; +$sign2 = strtoupper(md5($s)); + +if($sign != $sign2) exit; + +$code = $data['out_trade_no']; +$orderInfo = $db->get_one("select * from tb_recharge_pay_weixin where code = '{$code}'"); +if(!$orderInfo) exit; +if($orderInfo['state'] == 1) { + if(!$wxrecv_isinclude) { + echo " + + + + + "; + } + exit; +} +$total_fee = round($orderInfo['total_fee']*100); + +if($data['result_code'] == 'SUCCESS' && $data['return_code'] == 'SUCCESS' && $data['transaction_id'] && (!$data['trade_state'] || $data['trade_state'] == 'SUCCESS') && $total_fee == $data['total_fee']) { + $db->query("insert into tb_recharge_pay_suc set ORDERSEQ='{$code}', AMOUNT='".$orderInfo['total_fee']."', addtime=now()", 'SILENT'); + if($db->affected_rows() == 1) { + + require_once("include/pay.inc.php"); + //gpay_add_user_account_uid($orderInfo['uid'], $orderInfo['total_fee'], 0, $orderInfo['id'], 3, 1, 2, 0); + + $uInfo = $db->get_one("select * from tb_user where id = ".$orderInfo['uid']); + $company_id = $uInfo['company_id']; + $dining_hall_id = $uInfo['dining_hall_id']; + + $payInfo = array( + 'oid' => $orderInfo['id'], + 'rtype' => 1, + 'ac_type' => 2, + 'recharge_fund_type' => 3, + ); + if($company_id == 58) { //韶关小岛考虑supplier_id + $supplier_id = 0; + $dInfo = $db->get_one("select * from tb_dining_hall where id = ".intval($dining_hall_id)); + if($dInfo) $supplier_id = intval($dInfo['supplier_id']); + $payInfo['supplier_id'] = $supplier_id; + } + $rs = gpay_add_user_account_uid($orderInfo['uid'], $orderInfo['total_fee'], $payInfo); + + $db->query("update tb_recharge_pay_weixin set state=1,suctime=now(),transaction_id='".$data['transaction_id']."' where id=".$orderInfo['id']); + //file_put_contents("1.txt", $_SERVER["HTTP_USER_AGENT"].": ".$UPTRANSEQ."\n\n\n", FILE_APPEND); + if(!$wxrecv_isinclude) { + echo " + + + + + "; + } + } +} else { + $db->query("update tb_recharge_pay_weixin set state=2 where id=".$orderInfo['id']); +} \ No newline at end of file