hrjy 3 years ago
parent
commit
2b111b1c01
2 changed files with 25 additions and 26 deletions
  1. 24 25
      app/models/auction/Auction.php
  2. 1 1
      app/models/auction/AuctionOrder.php

+ 24 - 25
app/models/auction/Auction.php

@@ -102,32 +102,31 @@ class Auction extends BaseModel
             foreach ($auction as $k => $v) {
                 if (strtotime($v['rend_time'])-600 < time()){
                     //关闭场次五分钟前
-                    $orderCount = AuctionOrder::where('auction_id', '=', $v['id'])->where('frequency', '=', $v['frequency'])->where('status', '>',0)->where('price', '<', $recovery)->count();// 当前订单数量
-                    $bok = AuctionBooking::where([['auction_id', '=', $v['id']], ['frequency', '=', $v['frequency']]])->count();
-                    $count = ceil($bok * ($v['dispatch']/100));
+//                    $orderCount = AuctionOrder::where('auction_id', '=', $v['id'])->where('frequency', '=', $v['frequency'])->where('status', '>',0)->where('price', '<', $recovery)->count();// 当前订单数量
+//                    $bok = AuctionBooking::where([['auction_id', '=', $v['id']], ['frequency', '=', $v['frequency']]])->count();
+//                    $count = ceil($bok * ($v['dispatch']/100));
                     $orderId = AuctionOrder::where([['auction_id', '=', $v['id']], ['frequency', '=', $v['frequency']], ['status', '>', 0]])->column('product_id');
-                    if ($orderCount < $count){;
-                        // 如果购买人数没有到放单人数
-                        $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], ['price', '<', $recovery], ['auction_id', '=', $v['id']]])->select();
-                        if ($product){
-                            foreach ($product as &$item){
-                                $orderData = [
-                                    'uid' => 1,
-                                    'collection_id' => $item['uid']? $item['uid']: 0,
-                                    'order_id' => getNewOrderId(),
-                                    'auction_id' => $v['id'],
-                                    'product_id' => $item['id'],
-                                    'name' => $item['name'],
-                                    'image' => $item['image'],
-                                    'price' => $item['hanging_price'],
-                                    'actual_price' => $item['hanging_price'] - $item['price'],
-                                    'create_time' => time(),
-                                    'frequency' => $v['frequency']
-                                ];
-                                AuctionOrder::create($orderData);
-                                unset($orderData);// 清空数组
-                            }
+                    // 如果购买人数没有到放单人数
+                    $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], ['price', '<', $recovery], ['auction_id', '=', $v['id']]])->select();
+                    if ($product){
+                        // 存在挂售没卖出的订单
+                        foreach ($product as &$item){
+                            $orderData = [
+                                'uid' => 1,
+                                'collection_id' => $item['uid']? $item['uid']: 0,
+                                'order_id' => getNewOrderId(),
+                                'auction_id' => $v['id'],
+                                'product_id' => $item['id'],
+                                'name' => $item['name'],
+                                'image' => $item['image'],
+                                'price' => $item['hanging_price'],
+                                'actual_price' => $item['hanging_price'] - $item['price'],
+                                'create_time' => time(),
+                                'frequency' => $v['frequency']
+                            ];
+                            AuctionOrder::create($orderData);
+                            unset($orderData);// 清空数组
                         }
                     }
                     $auctionProduct = AuctionProduct::where([['auction_id', '=', $v['id']], ['is_show', '=', 1],['id', 'notIn', $orderId],['hanging_price', '>', $recovery]])->select();// 如果又商品成功回收价格

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

@@ -140,7 +140,7 @@ class AuctionOrder extends BaseModel
                 if ($booking){
                     AuctionBooking::where('id', $booking['id'])->update(['status' => 2]); // 修改预约订单状态 为扣除
                 }
-                AuctionOrder::where('create_time', '<', $hour)->where('status', '=', 1)->update(['status' => 0]); // 修改为已过期订单
+                AuctionOrder::where('create_time', '<', $hour)->where('status', '=', 1)->update(['uid' => 1]); // 修改为已过期订单
             }
 
         }