<?php
namespace app\admin\controller;
use \think\Db;
use addons\epay\library\Service;

/*
 *处理支付结果 接受服务器和服务器之间的通知
 */
class Payment extends \think\Controller
{
    public function notify(){
        $paytype = input('paytype','wechat');

        $pay = Service::checkNotify($paytype);
        filePut('[payment][receive]异步回调开始:'.json_encode($pay));
        if (!$pay) {
            filePut('[payment][receive]异步回调开始:签名错误');
            return;
        }
        $data = $pay->verify();

        $out_trade_no = $data['out_trade_no'];
        filePut('[payment][receive]异步回调开始'.$out_trade_no);
        //你可以在此编写订单逻辑
        $paymentdo = new \app\common\model\Paymentdo();
        $rs = $paymentdo->receive($out_trade_no);
        if(!$rs){
            filePut('[payment][receive]异步回调结果:逻辑false');
            exit;
        }

        filePut('[payment][receive]异步回调结果:Allsuccess');

        echo $pay->success();
    }




}
?>