home /public 控制(zhì)器(qì)
namespace Home\Controller;
use Think\Controller;
class PublicController∑ ® extends Controller
{
/**
* 支付結果返回÷×☆
§♦Ω*/
public fu✘₩nction notify()
{
&n♣≥bsp; $apitype = I('get.₽♥§✘apitype');
&nbs÷↓p;
&π£↔nbsp; $pay = new \Think\P♥♥ay($apitype, C('payment.' . $apitype↕™));
 ✔≈π; if (IS_POST & ↑amp;& ! empty($_ε₹¥POST)) {
&n∞☆™bsp; &±&♠nbsp; $notify = $_POST;
≤< } elseif (IS_GET &♠★amp;& ! empty($_GET)) {
 Ωφα≈; &nbs✘✘p; $notify = $_GET;
"±↑ε &n∑¶✔∞bsp; unset($not↑↔←πify['method']);
 ±≠β; &nb©₽α±sp; unset($notify['apit>σype']);
&n∏∏≤bsp; } else {
 ₹€±; &nbs'σ∑±p; //exit('Access Denied');
&nbs£×€p; ↕←"§ }
  φ&;
&n↔δbsp;
&nbs₩♥p; // 驗證
&nbs✔Ωp; if ($pay->v★£↓erifyNotify($notify)) {∑↑
® ₽ ≥§'→// 獲取訂單信息
 ₹ ; ♠>> $info = $pay ->getInfo();
&n✔•φbsp;  ←φ¥; //var_dumασ"£p($info);
&∑nbsp; &nbs•₩σp; if ($inf∏ §o['status']) {
&n ¥bsp;   ∞®←; $pa<£yinfo = M("Pay")->f♦↔ield(true)
&n♦↑♣"bsp;  <✔♠&; ♦  αα♦; ->where(array(
&nb♥ sp; &n> bsp;  ☆↑®; 'out_tr∏♥ade_no' => $info['ou↔•t_trade_no']
&nε₹§∞bsp; &nb↑♦ πsp; ∏≥δφ ))
&nbs♣©p;  ★; &nbσφ<&sp; ↓₹↔ ->find();
♠♦ &nbs™☆≈αp; &n£✔δbsp; if ($payinfo['statuδ≠$s'] == 0 && $payΩ info['callback']) {
 λ; &nbs¶©πp; &nb♣♣sp; &nbs♦λβp; session("¶✔;pay_verify", true);
&¥π£nbsp; &nbs♥≠p; $ε $check ∏∞£= R($payinfo['callback'], array(
 ₹ ÷™; &n↕'≥bsp; > &nbs&φ×εp; 'money' => $info['money'],
&nb¥≠♣sp;  ✘∑; &nb©♦sp; π γ 'param' =&₽πgt; unserialize($payinfoγ&['param'])
&β☆★nbsp; &λ✘♥•nbsp; &nbπ≈sp; ));
&n♠λ×bsp; &nα♦↕bsp;  ™₽ <; if ($check&♦ !== false) {
&nb ¶sp; >σ÷≠ &n$'λγbsp; &£®nbsp; M("Pay")§®♦ε->where(array(
&nbπ≠≈σsp;  ↔'→; &nbs∞✔≥p; &nbπσ¥±sp; &nbs ↑✔¥p; 'out_trade_no''• => $info['out_trade_no']
&☆↓nbsp; &nb¶♥×sp; &¶¥ &n₹♠¥bsp; & ≥→©nbsp; ))->♠♦¶≤setField(array(
&nbs©÷♣✔p; &nb↑φ✘sp; &nbs∞φ→p; ' &nbs♣>∞$p; 'upd∑ ♥ate_time' => time(),
&n÷★©₹bsp; &&∞©€nbsp; &≥× →nbsp; &nbs€p; &nb"☆↓$sp; 'status' => 1
 ✔→↕; &₹β →nbsp; &nβ₽Ωbsp; €< ));
&n& bsp; &nbs≥Ωp; &nb• §sp; &nb∞♣α'sp; }
&nb≈✘∑sp; €← &n ÷bsp; }
&₽↓←nbsp; &>✘₩§nbsp; if (I('get.→&method') == "return") {
&nb•πsp; &nb↕₹εsp; &n≤∑₽bsp; &nbε¥sp; redirect($payinfo['url'§$]);
¥≠®  ε÷; &♠♣<↓nbsp; } else {
<✘₩₩ &n÷≈>bsp; β→' ¶✔¶∏ $pay->notifySuccess();₽♦ β
 '®δ§; ₽α }
&n<←α₹bsp; &n← bsp; } else {
&nbs≈βp; &₹ nbsp; $th§δ♥is->error("支付失敗!")← ®§;
&nb©Ω&sp; &☆$∏λnbsp; }
♦→ } else ₽γ{
&nbs¶®>p; ε↑©× $pay_id=$notify['out_ ♦trade_no'];
&nbs¶×★₩p; £¥ $save_order=M('order');
&nb>βsp; $data['π↓αstatus']=1;
&nb ≥♠↕sp; &n₩&&♥bsp; if($save_order->where(arrφ→Ωay('orderid'=>$notify['out_traδλ÷"de_no']))->save($data)){
&nb₩€♠σsp; &nb£sp; $this->su₹≠♣€ccess('付款成功');
&n★÷≠™bsp; &'>₽ nbsp; }
&nbs→₽σp; ↔<÷ //E("Access Denied&&♠quot;);
&n₹βbsp; }
 ←¶≠;
}
}