20-02-2026
This commit is contained in:
parent
a8b395e20d
commit
a00c42e770
252 changed files with 28785 additions and 8907 deletions
|
|
@ -2,19 +2,18 @@
|
|||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\ShoppingUser;
|
||||
use App\Models\ShoppingInstance;
|
||||
use App\Models\ShoppingUser;
|
||||
use Yard;
|
||||
|
||||
class OrderPaymentService
|
||||
{
|
||||
|
||||
public static function deleteInstance($identifier)
|
||||
{
|
||||
|
||||
Yard::instance('shopping')->deleteStoredCart($identifier);
|
||||
\App\Models\ShoppingInstance::where('identifier', $identifier)->delete();
|
||||
//delete session
|
||||
\App\Models\ShoppingInstance::where('identifier', $identifier)->delete();
|
||||
// delete session
|
||||
/* if(\Session::has('user_shop_payment') && \Session::get('user_shop_payment') === 6){
|
||||
$user_shop_identifier = \Session::get('user_shop_identifier');
|
||||
Yard::instance('shopping')->deleteStoredCart($identifier);
|
||||
|
|
@ -24,7 +23,7 @@ class OrderPaymentService
|
|||
|
||||
public static function updateInstanceStatus($identifier, $status, $lower = true)
|
||||
{
|
||||
if (!ShoppingInstance::where('identifier', $identifier)->exists()) {
|
||||
if (! ShoppingInstance::where('identifier', $identifier)->exists()) {
|
||||
return false;
|
||||
}
|
||||
if ($lower) {
|
||||
|
|
@ -39,9 +38,10 @@ class OrderPaymentService
|
|||
public static function getInstanceStatus($identifier)
|
||||
{
|
||||
$shopping_instance = ShoppingInstance::where('identifier', $identifier)->first();
|
||||
if (!$shopping_instance) {
|
||||
if (! $shopping_instance) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $shopping_instance->getStatus();
|
||||
}
|
||||
|
||||
|
|
@ -49,33 +49,39 @@ class OrderPaymentService
|
|||
{
|
||||
$isFor = $shoppingInstance->shopping_data['is_for'] ?? '-';
|
||||
if ($isFor === 'abo-ot-customer') {
|
||||
return ' <span class="badge badge-pill badge-warning">' . __('abo.abo') . '</span>';
|
||||
return ' <span class="badge badge-pill badge-warning">'.__('abo.abo').'</span>';
|
||||
}
|
||||
if ($isFor === 'ot-customer') {
|
||||
return ' <span class="badge badge-pill badge-secondary">' . __('order.order') . '</span>';
|
||||
return ' <span class="badge badge-pill badge-secondary">'.__('order.order').'</span>';
|
||||
}
|
||||
return "";
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
public static function getStatusBadgeClasses()
|
||||
{
|
||||
return [
|
||||
'link_sent' => 'default',
|
||||
'link_openly' => 'info',
|
||||
'link_check' => 'warning',
|
||||
'link_pending' => 'warning',
|
||||
'link_appointed' => 'warning',
|
||||
'link_paid' => 'secondary',
|
||||
'link_failed' => 'danger',
|
||||
'link_canceled' => 'danger',
|
||||
];
|
||||
}
|
||||
|
||||
public static function getStatusBadge(ShoppingInstance $shoppingInstance)
|
||||
{
|
||||
$status = $shoppingInstance->getStatus();
|
||||
$badgeClasses = [
|
||||
'link_sent' => 'info',
|
||||
'link_openly' => 'info',
|
||||
'link_paid' => 'secondary',
|
||||
'link_check' => 'warning',
|
||||
'link_pending' => 'warning',
|
||||
'link_appointed' => 'warning',
|
||||
'link_failed' => 'danger',
|
||||
'link_canceled' => 'danger'
|
||||
];
|
||||
$badgeClasses = self::getStatusBadgeClasses();
|
||||
|
||||
if (isset($badgeClasses[$status])) {
|
||||
return sprintf(
|
||||
' <span class="badge badge-pill badge-%s">%s</span>',
|
||||
$badgeClasses[$status],
|
||||
__('payment.' . $status)
|
||||
__('payment.'.$status)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -100,7 +106,7 @@ class OrderPaymentService
|
|||
return sprintf(
|
||||
' <div class="alert alert-%s">%s</div>',
|
||||
$badgeClasses[$status],
|
||||
__('payment.alert_' . $status)
|
||||
__('payment.alert_'.$status)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -111,12 +117,12 @@ class OrderPaymentService
|
|||
{
|
||||
|
||||
$shopping_instance = ShoppingInstance::where('identifier', $identifier)->first();
|
||||
if (!$shopping_instance) {
|
||||
if (! $shopping_instance) {
|
||||
abort(403, __('msg.shopping_instance_not_found'));
|
||||
}
|
||||
$shopping_data = $shopping_instance->shopping_data;
|
||||
$shopping_user = $shopping_data['shopping_user_id'] ? ShoppingUser::find($shopping_data['shopping_user_id']) : null;
|
||||
if (!$shopping_user) {
|
||||
if (! $shopping_user) {
|
||||
abort(403, __('msg.shopping_user_not_found'));
|
||||
}
|
||||
$yard_shopping_items = self::getRestoredYardShoppingItems($shopping_instance);
|
||||
|
|
@ -130,6 +136,7 @@ class OrderPaymentService
|
|||
'is_for' => $shopping_instance->shopping_data['is_for'] ?? false,
|
||||
'backlink' => false,
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
|
@ -145,7 +152,6 @@ class OrderPaymentService
|
|||
Yard::instance('shopping')->setUserPriceInfos($shopping_instance->shopping_data['user_price_infos']);
|
||||
Yard::instance('shopping')->setShippingCountryWithPrice($shopping_instance->country_id, $is_for);
|
||||
|
||||
|
||||
$rows = Yard::instance('shopping')->getContentByOrder();
|
||||
$ret = [];
|
||||
$ret['items'] = [];
|
||||
|
|
@ -154,12 +160,12 @@ class OrderPaymentService
|
|||
|
||||
foreach ($rows as $row) {
|
||||
$product = \App\Models\Product::find($row->id);
|
||||
$item = new \stdClass();
|
||||
$item = new \stdClass;
|
||||
$item->image = $row->options->has('image') ? $row->options->image : null;
|
||||
$item->price_net = (float) Yard::instance('shopping')->rowPriceNet($row, 3, '.', '');
|
||||
$item->price_net_total = (float) Yard::instance('shopping')->rowSubtotalNet($row, 2, '.', '');
|
||||
$item->price_currency = $is_currency ? "~" . Yard::instance('shopping')->getCurrencyByKey('rowPriceNetCurrency', $row, 3) . " " . Yard::instance('shopping')->getPriceCurrencyUnit() : null;
|
||||
$item->price_currency_total = $is_currency ? "~" . Yard::instance('shopping')->getCurrencyByKey('rowSubtotalCurrency', $row, 3) . " " . Yard::instance('shopping')->getPriceCurrencyUnit() : null;
|
||||
$item->price_currency = $is_currency ? '~'.Yard::instance('shopping')->getCurrencyByKey('rowPriceNetCurrency', $row, 3).' '.Yard::instance('shopping')->getPriceCurrencyUnit() : null;
|
||||
$item->price_currency_total = $is_currency ? '~'.Yard::instance('shopping')->getCurrencyByKey('rowSubtotalCurrency', $row, 3).' '.Yard::instance('shopping')->getPriceCurrencyUnit() : null;
|
||||
$item->price = $row->price;
|
||||
$item->price_total = ($row->qty * $row->price);
|
||||
$item->qty = $row->qty;
|
||||
|
|
@ -174,16 +180,16 @@ class OrderPaymentService
|
|||
|
||||
$ret['tax_free'] = $tax_free;
|
||||
$ret['total']['subtotal'] = Yard::instance('shopping')->subtotal();
|
||||
$ret['total']['subtotal_currency'] = $is_currency ? "~" . Yard::instance('shopping')->getCurrencyByKey('subtotal') . " " . Yard::instance('shopping')->getPriceCurrencyUnit() : null;
|
||||
$ret['total']['subtotal_currency'] = $is_currency ? '~'.Yard::instance('shopping')->getCurrencyByKey('subtotal').' '.Yard::instance('shopping')->getPriceCurrencyUnit() : null;
|
||||
$ret['total']['shippingCountryName'] = Yard::instance('shopping')->getShippingCountryName();
|
||||
$ret['total']['shippingNet'] = Yard::instance('shopping')->shippingNet();
|
||||
$ret['total']['shippingNet currency'] = $is_currency ? "~" . Yard::instance('shopping')->getCurrencyByKey('shippingNet') . " " . Yard::instance('shopping')->getPriceCurrencyUnit() : null;
|
||||
$ret['total']['shippingNet currency'] = $is_currency ? '~'.Yard::instance('shopping')->getCurrencyByKey('shippingNet').' '.Yard::instance('shopping')->getPriceCurrencyUnit() : null;
|
||||
$ret['total']['subtotalWithShipping'] = Yard::instance('shopping')->subtotalWithShipping();
|
||||
$ret['total']['subtotalWithShipping_currency'] = $is_currency ? "~" . Yard::instance('shopping')->getCurrencyByKey('subtotalWithShipping') . " " . Yard::instance('shopping')->getPriceCurrencyUnit() : null;
|
||||
$ret['total']['subtotalWithShipping_currency'] = $is_currency ? '~'.Yard::instance('shopping')->getCurrencyByKey('subtotalWithShipping').' '.Yard::instance('shopping')->getPriceCurrencyUnit() : null;
|
||||
$ret['total']['taxWithShipping'] = Yard::instance('shopping')->taxWithShipping();
|
||||
$ret['total']['taxWithShipping_currency'] = $is_currency ? "~" . Yard::instance('shopping')->getCurrencyByKey('taxWithShipping') . " " . Yard::instance('shopping')->getPriceCurrencyUnit() : null;
|
||||
$ret['total']['taxWithShipping_currency'] = $is_currency ? '~'.Yard::instance('shopping')->getCurrencyByKey('taxWithShipping').' '.Yard::instance('shopping')->getPriceCurrencyUnit() : null;
|
||||
$ret['total']['totalWithShipping'] = Yard::instance('shopping')->totalWithShipping();
|
||||
$ret['total']['totalWithShipping_currency'] = $is_currency ? "~" . Yard::instance('shopping')->getCurrencyByKey('totalWithShipping') . " " . Yard::instance('shopping')->getPriceCurrencyUnit() : null;
|
||||
$ret['total']['totalWithShipping_currency'] = $is_currency ? '~'.Yard::instance('shopping')->getCurrencyByKey('totalWithShipping').' '.Yard::instance('shopping')->getPriceCurrencyUnit() : null;
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue