|
|
@@ -127,23 +127,24 @@ class AuctionOrder extends BaseModel
|
|
|
*/
|
|
|
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]); // 修改为已过期订单
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|