|
@@ -208,11 +208,14 @@ class AuctionOrder extends BaseModel
|
|
|
}
|
|
|
$product = $productModel->where('id', $data['product_id'])->find();
|
|
|
$auction = $auctionModel->where('id', $product['auction_id'])->find();
|
|
|
- $booking = $bookingModel->where('auction_id', $auction['id'])->where('uid', $user['uid'])->whereBetweenTime('create_time', date('Y-m-d H:i:s', strtotime(date('Y-m-d'))), date('Y-m-d H:i:s', strtotime('+1 day')))->find();
|
|
|
+ $time = strtotime(date('Y-m-d' ,strtotime($data['create_time'])));
|
|
|
+ $totime = strtotime(date('Y-m-d' ,strtotime($data['create_time']))) + 86400;
|
|
|
+ $booking = $bookingModel->where('auction_id', $auction['id'])->where('uid', $user['uid'])->whereBetweenTime('create_time', $time, $totime)->find();
|
|
|
if ($booking['status'] > 0){
|
|
|
$booking['status'] = 0;
|
|
|
$booking->save();
|
|
|
- $user['anticipate'] = $user['anticipate'] + $auction['anticipate'];
|
|
|
+ $anticipate = $booking['anticipate'] - $booking['deduction'];
|
|
|
+ $user['anticipate'] = $user['anticipate'] + $anticipate;
|
|
|
$user->save();
|
|
|
|
|
|
|
|
@@ -222,9 +225,9 @@ class AuctionOrder extends BaseModel
|
|
|
'title' => '预约卷退还',
|
|
|
'category' => 'anticipate',
|
|
|
'type' => 'add_anticipate',
|
|
|
- 'mark' => '退还'.number_format($auction['anticipate'],2).'预约卷',
|
|
|
+ 'mark' => '退还'.$anticipate.'预约卷扣除'.$booking['deduction'],
|
|
|
'add_time' => time(),
|
|
|
- 'number' => number_format($auction['anticipate'],2),
|
|
|
+ 'number' => $anticipate,
|
|
|
'balance' => $user['anticipate']
|
|
|
]);
|
|
|
}
|
|
@@ -240,24 +243,37 @@ class AuctionOrder extends BaseModel
|
|
|
public static function deduction()
|
|
|
{
|
|
|
$hour = strtotime(date('Y-m-d H:i:s', strtotime('-1 hour')));
|
|
|
-
|
|
|
- $order = AuctionOrder::where('create_time', '<', $hour)->where('status', '=', 1)->select();
|
|
|
+ $time = $hour - 1800;
|
|
|
+ $order = AuctionOrder::where('create_time', '<', $hour)->where('status', '=', 1)->select();
|
|
|
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){
|
|
|
- $user = \app\models\user\User::where('uid', $v['collection_id'])->find();
|
|
|
- $user['anticipate'] = $user['anticipate'] + $auction['anticipate'];
|
|
|
- UserBill::income('增加预约卷', $v['collection_id'], 'anticipate', 'add_anticipate', $auction['anticipate'], $v['uid'], $user['anticipate'], '卖出订单未上传支付凭证,增加'.$auction['anticipate'].'预约卷');
|
|
|
-
|
|
|
- $user->save();
|
|
|
- AuctionBooking::where('id', $booking['id'])->update(['status' => 2]);
|
|
|
+ $booking = AuctionBooking::where([['uid', '=', $v['uid']], ['status', '=', 1], ['auction_id', '=', $auction['id']]])->find();
|
|
|
+ if (strtotime($v['create_time']) <= $hour and strtotime($v['create_time']) > $time){
|
|
|
+
|
|
|
+ if ($booking){
|
|
|
+ if ($booking['deduction'] == 0){
|
|
|
+ $user = \app\models\user\User::where('uid', $v['collection_id'])->find();
|
|
|
+ $user['anticipate'] = $user['anticipate'] + $auction['anticipate']/2;
|
|
|
+ $booking['deduction'] = $auction['anticipate']/2;
|
|
|
+ UserBill::income('增加预约卷', $v['collection_id'], 'anticipate', 'add_anticipate', $auction['anticipate']/2, $v['uid'], $user['anticipate'], '卖出订单未上传支付凭证,增加'.($auction['anticipate']/2).'预约卷');
|
|
|
+ $booking->save();
|
|
|
+ $user->save();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }elseif (strtotime($v['create_time']) <= $time){
|
|
|
+ if ($booking) {
|
|
|
+ $user = \app\models\user\User::where('uid', $v['collection_id'])->find();
|
|
|
+ $user['anticipate'] = $user['anticipate'] + ($auction['anticipate'] - $auction['deduction']);
|
|
|
+ $booking['deduction'] = $auction['anticipate'];
|
|
|
+ UserBill::income('增加预约卷', $v['collection_id'], 'anticipate', 'add_anticipate', $auction['anticipate'] - $auction['deduction'], $v['uid'], $user['anticipate'], '卖出订单未上传支付凭证,增加' . ($auction['anticipate'] - $auction['deduction']) . '预约卷');
|
|
|
+ $booking->save();
|
|
|
+ $user->save();
|
|
|
+ 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(['status' => 0]);
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -280,7 +296,7 @@ class AuctionOrder extends BaseModel
|
|
|
if ($booking){
|
|
|
foreach ($booking as $key => $value){
|
|
|
$product = AuctionProduct::where('auction_id', $value['auction_id'])->column('id');
|
|
|
- $order = AuctionOrder::where([['product_id', 'in', $product], ['frequency', '=', $value['frequency']], ['uid', '=', $value['uid']]])->where('status','>', 0)->find();
|
|
|
+ $order = AuctionOrder::where([['product_id', 'in', $product], ['frequency', '=', $value['frequency']], ['uid', '=', $value['uid']]])->find();
|
|
|
if (!$order){
|
|
|
$find = AuctionBooking::find($value['id']);
|
|
|
$find['status'] = 0;
|