xxxrrrdddd 3 years ago
parent
commit
28ec2110d9
3 changed files with 41 additions and 3 deletions
  1. 5 0
      application/common/model/MobileOrder.php
  2. 33 0
      commands/mobile_order_unpay_notify.php
  3. 3 3
      work

+ 5 - 0
application/common/model/MobileOrder.php

@@ -14,6 +14,7 @@ use think\Model;
  * 配置模型
  * @method static static payed()
  * @method $this filterShow()
+ * @method $this waitPay()
  */
 class MobileOrder extends Model
 {
@@ -231,4 +232,8 @@ class MobileOrder extends Model
     public function flowOrderSubmit(){
         $this['status']=15;
     }
+
+    public function scopeWaitPay(Query $query){
+        $query->where('status',0);
+    }
 }

+ 33 - 0
commands/mobile_order_unpay_notify.php

@@ -0,0 +1,33 @@
+<?php
+use app\common\model\MobileOrder;
+use think\Db;
+use think\Log;
+use Workerman\Worker as WO;
+
+class MobileOrderUnPayNotify{
+    public static function run()
+    {
+        $work=new WO();
+        $work->onWorkerStart=function ($conn){
+            while (true){
+                $orders= MobileOrder::waitPay()
+                    ->where('type',1)
+                    ->whereRaw('create_time+300<'.time())
+                    ->field('id')
+                    ->whereNotExists('select * from mobile_order_mind where mobile_order.id=mobile_order_mind.mobile_order_id')
+                    ->select()
+                    ->toArray();
+                user_log(class_basename(__CLASS__),sprintf('%d条数据',count($orders)));
+                foreach ($orders as $orderId){
+                    $order=MobileOrder::find($orderId);
+                    if(!$order){
+                        continue;
+                    }
+
+                }
+                sleep(1);
+            }
+        };
+    }
+}
+MobileOrderUnPayNotify::run();

+ 3 - 3
work

@@ -12,8 +12,8 @@ App::initCommon();
 WO::$logFile=sprintf('%s/workerman.log',RUNTIME_PATH);
 WO::$pidFile=sprintf('%s/workerman.pid',RUNTIME_PATH);
 
-foreach (glob(__DIR__.'/commands/*.php') as $file){
-    require $file;
-}
+//require __DIR__.'/commands/mobile_activity.php';
+//require __DIR__.'/commands/mobile_order_expired.php';
+require __DIR__.'/commands/mobile_order_unpay_notify.php';
 
 WO::runAll();