瀏覽代碼

Merge branch 'pay_alert' into stabble

songdb 6 年之前
父節點
當前提交
40e29b4dfe
共有 1 個文件被更改,包括 49 次插入2 次删除
  1. 49 2
      app/Http/Controllers/Wap/Pay/OrdersController.php

+ 49 - 2
app/Http/Controllers/Wap/Pay/OrdersController.php

@@ -270,7 +270,7 @@ class OrdersController extends Controller
         }
         $from_bid = ReadRecordService::getSimpleFirstReadRecord($uid);
         $inner_send_order_id = ReadRecordService::getInnerSendOrderId($uid);
-        $result = $this->createUnPayOrder([
+        $init_order = [
             'distribution_channel_id' => $distribution_channel_id,
             'uid' => $uid,
             'product_id' => $product_id,
@@ -287,7 +287,14 @@ class OrdersController extends Controller
             'from_type' => $fromtype,
             'activity_id' => $activity_id,
             'inner_send_order_id'=>$inner_send_order_id
-        ]);
+        ];
+        $result = $this->createUnPayOrder($init_order);
+
+        //订单创建成功后增加统计
+        if($result)
+        {
+            $this->orderCreated($init_order);
+        }
 
         if ($request->get('suid')) {
             $this->createSubstituteOrder($result->id, $uid, $request->get('suid'));
@@ -357,6 +364,40 @@ class OrdersController extends Controller
         }
         return false;
     }
+
+    //订单创建后统计
+    private function orderCreated($init_order)
+    {
+        try {
+            if(isset($init_order['pay_merchant_id']))
+            {
+                $key = 'pay_merchant:'.$init_order['pay_merchant_id'];
+                Redis::hincrby($key,'unpaid_num',1);
+                Redis::hset($key,'last_create_time', time());
+            }
+
+        }catch (\Exception $e)
+        {
+
+        }
+    }
+
+    //订单回调后统计
+    private function orderPaid($init_order)
+    {
+        try {
+            if(isset($init_order['pay_merchant_id']))
+            {
+                $key = 'pay_merchant:'.$init_order['pay_merchant_id'];
+                Redis::hset($key,'unpaid_num',0);
+            }
+
+        }catch (\Exception $e)
+        {
+
+        }
+    }
+
     public function reportError(Request $request)
     {
         $data = $request->post('data');
@@ -1191,6 +1232,12 @@ class OrdersController extends Controller
                     }
                 }
             }
+
+            if(isset($order->pay_merchant_id) && $order->pay_merchant_id)//临时统计队列清0 用于报警
+            {
+                $key = 'pay_merchant:'.$order->pay_merchant_id;
+                Redis::hset($key,'unpaid_num',0);
+            }
         }catch (\Exception $e){}
 
     }