|
|
@@ -118,9 +118,9 @@ class AuctionOrder extends BaseModel
|
|
|
*/
|
|
|
public static function deduction()
|
|
|
{
|
|
|
- $hour = strtotime(date('Y-m-d H:i:s', strtotime('-1 hour'))); // 一小时以前
|
|
|
+ $hour = strtotime(date('Y-m-d H:i:s', strtotime('-30 minute'))); // 一小时以前
|
|
|
|
|
|
- $order = AuctionOrder::where('create_time', '<', $hour)->where('status', '=', 1)->select(); // 查询不在当前一个小时内的订单
|
|
|
+ $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();
|
|
|
@@ -129,11 +129,6 @@ class AuctionOrder extends BaseModel
|
|
|
|
|
|
$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]); // 修改预约订单状态 为扣除
|
|
|
}
|
|
|
AuctionOrder::where('create_time', '<', $hour)->where('status', '=', 1)->update(['status' => 0]); // 修改为已过期订单
|
|
|
@@ -143,7 +138,7 @@ class AuctionOrder extends BaseModel
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 退回预约卷
|
|
|
+ * 退回广告值
|
|
|
* @return void
|
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
|
* @throws \think\db\exception\DbException
|
|
|
@@ -158,16 +153,18 @@ class AuctionOrder extends BaseModel
|
|
|
$booking = AuctionBooking::where([['auction_id', '=', $v['id']], ['status','=' , 1]])->select();
|
|
|
|
|
|
if ($booking){
|
|
|
+ $bf = 0.1; // 广告值扣除倍率
|
|
|
foreach ($booking as $key => $value){
|
|
|
+ $userBok = AuctionBooking::where('uid', '=',$value['uid'])->where('deduct_advert', '>', 0)->count();
|
|
|
+ $bf = (0.1*$userBok >= 1)? 1: 0.1*$userBok;
|
|
|
$find = AuctionBooking::find($value['id']);
|
|
|
$find['status'] = 0;
|
|
|
-
|
|
|
+ $find['deduct_advert'] = $value['advert']*$bf; // 扣除广告书
|
|
|
$user = User::where('uid', $value['uid'])->find();
|
|
|
- $user['anticipate'] = $user['anticipate'] + $value['anticipate'];
|
|
|
-
|
|
|
+ $user['aid_val'] = $user['aid_val'] + ($value['advert'] - ($value['advert'] * $bf)); // 增加用户广告值
|
|
|
$user->save();
|
|
|
$find->save();
|
|
|
- UserBill::income('预约卷增加',$user['uid'], 'anticipate', 'add_anticipate', $value['anticipate'], 0, $user['anticipate'], '预约卷退回');
|
|
|
+ UserBill::income('未购买解冻但扣除'. $find['deduct_advert'].'广告值',$user['uid'], 'aid_val', 'add_aid_val',$value['advert'] - ($value['advert'] * $bf), 0, $user['aid_val'], '未购买解冻但扣除'. $find['deduct_advert'].'广告值');
|
|
|
}
|
|
|
}
|
|
|
}
|