update: order service

This commit is contained in:
Tokumeikoi 2020-10-11 01:22:43 +08:00
parent 8213dd3a73
commit c984fa2e0b

View File

@ -9,7 +9,7 @@ use Illuminate\Support\Facades\DB;
class OrderService class OrderService
{ {
CONST STRTOTIME = [ CONST STR_TO_TIME = [
'month_price' => 1, 'month_price' => 1,
'quarter_price' => 3, 'quarter_price' => 3,
'half_year_price' => 6, 'half_year_price' => 6,
@ -164,7 +164,7 @@ class OrderService
private function orderIsUsed(Order $order):bool private function orderIsUsed(Order $order):bool
{ {
$month = self::STRTOTIME[$order->cycle]; $month = self::STR_TO_TIME[$order->cycle];
$orderExpireDay = strtotime('+' . $month . ' month', $order->created_at->timestamp); $orderExpireDay = strtotime('+' . $month . ' month', $order->created_at->timestamp);
if ($orderExpireDay < time()) return true; if ($orderExpireDay < time()) return true;
return false; return false;
@ -183,7 +183,7 @@ class OrderService
// 兼容历史余留问题 // 兼容历史余留问题
if ($item->cycle === 'onetime_price') continue; if ($item->cycle === 'onetime_price') continue;
if ($this->orderIsUsed($item)) continue; if ($this->orderIsUsed($item)) continue;
$orderSurplusMonth = $orderSurplusMonth + self::STRTOTIME[$item->cycle]; $orderSurplusMonth = $orderSurplusMonth + self::STR_TO_TIME[$item->cycle];
$orderSurplusAmount = $orderSurplusAmount + ($item['total_amount'] + $item['balance_amount']); $orderSurplusAmount = $orderSurplusAmount + ($item['total_amount'] + $item['balance_amount']);
} }
if (!$orderSurplusMonth || !$orderSurplusAmount) return; if (!$orderSurplusMonth || !$orderSurplusAmount) return;