|
|
|
@ -58,7 +58,7 @@ class OrderController extends Controller |
|
|
|
->toArray(); |
|
|
|
|
|
|
|
$time = time(); |
|
|
|
$timeout_ids = []; |
|
|
|
|
|
|
|
$prefix = Storage::disk('public')->url(''); |
|
|
|
foreach ($order_list['data'] as &$v) { |
|
|
|
//图片加上域名
|
|
|
|
@ -77,26 +77,23 @@ class OrderController extends Controller |
|
|
|
} |
|
|
|
|
|
|
|
//未付款订单提示剩余付款时间
|
|
|
|
if ($v['timeout'] !== null && $v['status'] == Status::UNPAID) { |
|
|
|
if ($v['timeout'] !== null) { |
|
|
|
$second = strtotime($v['timeout']) - $time; |
|
|
|
|
|
|
|
if ($second > 0) { |
|
|
|
if ($second > 0 && $v['status'] == Status::UNPAID) { |
|
|
|
$v['status_text'] = '请在' . ceil($second / 60) . '分钟内付款'; |
|
|
|
} /*else { //TODO 此部分由定时
|
|
|
|
} else if ($second < 0 && $v['status'] == Status::PAY_EARNEST) { |
|
|
|
$v['status_text'] = '尾款支付已超时'; |
|
|
|
} /*else { //此部分由定时处理
|
|
|
|
$timeout_ids[] = $v['id']; |
|
|
|
$v['status'] = Status::CANCEL; |
|
|
|
$v['status_text'] = '已取消'; |
|
|
|
//TODO 加回库存,未考虑到几天/几个月后再打开订单列表页的情况,需要定时任务处理
|
|
|
|
//此部分已由定时任务处理
|
|
|
|
Product::query()->find($v['product_id'])->increment('stock', $v['num']); |
|
|
|
}*/ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//超时订单设置为已取消 TODO 测试阶段暂时注释
|
|
|
|
if ($timeout_ids) { |
|
|
|
Order::query()->whereIn('id', $timeout_ids)->update(['status' => Status::CANCEL]); |
|
|
|
} |
|
|
|
|
|
|
|
return $this->success($order_list); |
|
|
|
} |
|
|
|
|
|
|
|
@ -325,10 +322,11 @@ class OrderController extends Controller |
|
|
|
$order = Order::query() |
|
|
|
->with('agentProduct') |
|
|
|
->where(['user_id' => $this->user_id, 'agent_id' => $this->agent_id]) |
|
|
|
->whereRaw('`timeout` >= NOW()') |
|
|
|
->whereIn('status', [Status::UNPAID, Status::PAY_EARNEST]) |
|
|
|
->find($id); |
|
|
|
if (!$order) { |
|
|
|
return $this->error('订单不存在或已支付'); |
|
|
|
return $this->error('订单已支付或已超时'); |
|
|
|
} |
|
|
|
|
|
|
|
$ap = AgentProduct::with('coupon')->find($order->agent_product_id); |
|
|
|
|