瀏覽代碼

充值到账

lizhen_gitee 3 年之前
父節點
當前提交
5dc991b144

+ 2 - 9
application/admin/controller/Payment.php

@@ -10,7 +10,6 @@ class Payment extends \think\Controller
 {
     public function notify(){
         $paytype = input('paytype','wechat');
-        $paytype = 'alipay';
 
         $pay = Service::checkNotify($paytype);
         filePut('[payment][receive]异步回调开始:'.json_encode($pay));
@@ -18,19 +17,13 @@ class Payment extends \think\Controller
             filePut('[payment][receive]异步回调开始:签名错误');
             return;
         }
-        filePut('[payment][receive]异步回调开始21');
         $data = $pay->verify();
-        filePut('[payment][receive]异步回调开始23');
-        if($paytype == 'wechat'){
-            //$payamount = $data['total_fee'] / 100;
-        }
+
         $out_trade_no = $data['out_trade_no'];
         filePut('[payment][receive]异步回调开始'.$out_trade_no);
         //你可以在此编写订单逻辑
         $paymentdo = new \app\common\model\Paymentdo();
-        filePut('[payment][receive]异步回调开始Paymentdo');
-        $rs = $paymentdo->receive($out_trade_no,'123');
-        filePut('[payment][receive]异步回调开始Paymentdoreceive');
+        $rs = $paymentdo->receive($out_trade_no);
         if(!$rs){
             filePut('[payment][receive]异步回调结果:逻辑false');
             exit;

+ 2 - 2
application/api/controller/Pay.php

@@ -93,7 +93,7 @@ class Pay extends Api
             //'method'       => 'miniapp',
             'method'       => 'app',
             //'openid'       => $openid,
-            'notifyurl' => $this->request->root(true) . '/notify.php?paytype='.$pay_type,
+            'notifyurl' => $this->request->root(true) . '/notify.php/paytype/alipay',
             'returnurl' => '',
         ];
         $res = Service::submitOrder($params);
@@ -198,7 +198,7 @@ class Pay extends Api
             'amount'       => $data['money'],
             'amount'       => 0.01,
             'method'       => 'app',
-            'notifyurl' => $this->request->root(true) . '/notify.php',
+            'notifyurl' => $this->request->root(true) . '/notify.php/paytype/alipay',
             'returnurl' => '',
         ];
         $res = Service::submitOrder($params);

+ 9 - 14
application/common/model/Paymentdo.php

@@ -1,20 +1,18 @@
 <?php
 namespace app\common\model;
-use think\Model;
-use think\Db;
-use app\common\model\Wallet;
+use \think\Db;
 /*
  *处理支付结果 接受服务器和服务器之间的通知
  */
-class Paymentdo extends Model
+class Paymentdo
 {
 
 
     //接受服务器的通知
-    public function receive($orderId,$payamount)
+    public function receive($orderId,$payamount = 0)
     {
 
-        filePut('[payment][receive]异步回调开始17:'.$orderId);
+        filePut('[payment][receive]异步回调开始'.$orderId);
         //$orderId = Pay::getOrderId();
         if (!$orderId)
         {
@@ -74,20 +72,17 @@ class Paymentdo extends Model
     public function touchEvent($event, $orderId)
     {
         //检查该订单是否已绑定事件
-        $pay_event = Db::name('pay_event');
-        $pay_order = Db::name('pay_order');
-
         $where = [];
         $where['pay_no'] = $orderId;
         $where['event'] = $event;
-        $info = $pay_event->where($where)->find();
+        $info = Db::name('pay_event')->where($where)->find();
         if(!$info||!isset($info['class']))
         {return;}
 
         $class = new $info['class'];
 
-        db()->startTrans();
-        $orderInfo = $pay_order->where(['pay_no' => $orderId])->lock(true)->find();
+        Db::startTrans();
+        $orderInfo = Db::name('pay_order')->where(['pay_no' => $orderId])->lock(true)->find();
         filePut("[PAY][touchEvent] STRAT" . $orderId);
 
         //如果找到了绑定的事件
@@ -97,8 +92,8 @@ class Paymentdo extends Model
             if ($event === 'success') {
                 if($orderInfo['status'] === 0)//成功事件只触发1次
                 {
-                    $pay_order->where(['pay_no' => $orderId])->update(['status'=>2]);
-                    db()->commit();
+                    Db::name('pay_order')->where(['pay_no' => $orderId])->update(['status'=>2]);
+                    Db::commit();
                     filePut('[PAY][touchEvent] success start'.$orderId);//.$info['args']
                     call_user_func_array([$class, $info['method']], [$orderId, $args]);
                     //得到事件模型类

+ 1 - 3
application/common/model/Recharge.php

@@ -1,9 +1,6 @@
 <?php
 namespace app\common\model;
-
 use \think\Db;
-
-//use \com\Pay\Pay;
 /**
  * 订单支付模型
  */
@@ -50,6 +47,7 @@ class Recharge
             if(empty($first_check)){
 
                 //首充日志
+                $first_map['createtime'] = time();
                 $first_log_id = Db::name('user_paygold_log')->insertGetId($first_map);
                 if(!$first_log_id){
                     Db::rollback();