xxxrrrdddd 3 years ago
parent
commit
c12b33c2b6

+ 2 - 1
application/common/command/OrderExpiredCommand.php

@@ -16,10 +16,11 @@ class OrderExpiredCommand extends Command{
 
     protected function execute(Input $input, Output $output)
     {
-        $orders= MobileOrder::expired()->select();
+        $orders= MobileOrder::expired()->field('id')->select();
         foreach ($orders as $order){
             try {
                 Db::startTrans();
+                $order=MobileOrder::where('id',$order['id'])->lock(true)->find();
                 $order->cancel();
                 Db::commit();
             }catch (\Exception $e){

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

@@ -48,6 +48,9 @@ class MobileOrder extends Model
     }
 
     public function cancel(){
+        if($this['pay_time']){
+            return;
+        }
         $this['status']=50;
         $this->save();
     }