hrjy 3 years ago
parent
commit
e586eb69d3
2 changed files with 16 additions and 15 deletions
  1. 1 1
      app/models/auction/Auction.php
  2. 15 14
      app/models/auction/AuctionOrder.php

+ 1 - 1
app/models/auction/Auction.php

@@ -108,7 +108,7 @@ class Auction extends BaseModel
                     $orderId = AuctionOrder::where([['auction_id', '=', $v['id']], ['frequency', '=', $v['frequency']], ['status', '>', 0]])->column('product_id');
                     $orderId = AuctionOrder::where([['auction_id', '=', $v['id']], ['frequency', '=', $v['frequency']], ['status', '>', 0]])->column('product_id');
                     // 如果购买人数没有到放单人数
                     // 如果购买人数没有到放单人数
                     $dayo = AuctionOrder::where('auction_id', '=', $v['id'])->where('frequency', '=', $v['frequency'])->where('status', '>',0)->where('price', '<', $recovery)->column('product_id');// 当前出售商品
                     $dayo = AuctionOrder::where('auction_id', '=', $v['id'])->where('frequency', '=', $v['frequency'])->where('status', '>',0)->where('price', '<', $recovery)->column('product_id');// 当前出售商品
-                    $product = AuctionProduct::where([['id', 'notIn', $dayo], ['uid', '>', 1], ['is_show', '=', 1],['hanging_price', '<', $recovery], ['auction_id', '=', $v['id']]])->select();
+                    $product = AuctionProduct::where([['id', 'notIn', $dayo], ['is_show', '=', 1],['hanging_price', '<', $recovery], ['auction_id', '=', $v['id']]])->select();
                     if ($product){
                     if ($product){
                         // 存在挂售没卖出的订单
                         // 存在挂售没卖出的订单
                         foreach ($product as &$item){
                         foreach ($product as &$item){

+ 15 - 14
app/models/auction/AuctionOrder.php

@@ -127,23 +127,24 @@ class AuctionOrder extends BaseModel
      */
      */
     public static function deduction()
     public static function deduction()
     {
     {
-        $hour = strtotime(date('Y-m-d H:i:s', strtotime('-30 minute'))); // 30分钟以前
-
-        $order = AuctionOrder::where('create_time', '<', $hour)->where('status', '=', 1)->select(); // 查询不在当前30分钟前的订单
-        if ($order){
-            foreach ($order as $K => $v){
-                $product = AuctionProduct::where('id', $v['product_id'])->find();
-
-                $auction = Auction::where('id', $product['auction_id'])->find();
-
-                $booking = AuctionBooking::where([['uid', '=', $v['uid']], ['status', '=', 1], ['auction_id', '=', $auction['id']]])->where('status', '=', 1)->find(); // 找到预约订单
-                if ($booking){
-                    AuctionBooking::where('id', $booking['id'])->update(['status' => 2]); // 修改预约订单状态 为扣除
+        $auction = Auction::select();
+        if ($auction) {
+            foreach ($auction as $k => $v) {
+                if (strtotime($v['rend_time']) < time()) {
+                    $order = AuctionOrder::where('status', '=', 1)->where('uid', '>', 1)->where('auction_id', $v['id'])->where('frequency', $v['frequency'])->select(); // 查询不在当前30分钟前的订单
+                    if ($order){
+                        foreach ($order as $item){
+                            $booking = AuctionBooking::where([['uid', '=', $item['uid']], ['status', '=', 1], ['auction_id', '=', $v['id']]], ['frequency', '=', $v['frequency']])->find(); // 找到预约订单
+                            if ($booking){
+                                AuctionBooking::where('id', $booking['id'])->update(['status' => 2]); // 修改预约订单状态 为扣除
+                            }
+                            AuctionOrder::where('id', '=', $item['id'])->where('status', '=', 1)->update(['uid' => 1]); // 修改为已过期订单
+                        }
+                    }
                 }
                 }
-                AuctionOrder::where('create_time', '<', $hour)->where('status', '=', 1)->update(['uid' => 1]); // 修改为已过期订单
             }
             }
-
         }
         }
+
     }
     }
 
 
     /**
     /**