23-01-2026
This commit is contained in:
parent
a939cd51ef
commit
a8b395e20d
248 changed files with 29342 additions and 4805 deletions
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\ShoppingUser;
|
||||
|
|
@ -8,7 +9,8 @@ use Yard;
|
|||
class OrderPaymentService
|
||||
{
|
||||
|
||||
public static function deleteInstance($identifier){
|
||||
public static function deleteInstance($identifier)
|
||||
{
|
||||
|
||||
Yard::instance('shopping')->deleteStoredCart($identifier);
|
||||
\App\Models\ShoppingInstance::where('identifier', $identifier)->delete();
|
||||
|
|
@ -20,53 +22,58 @@ class OrderPaymentService
|
|||
}*/
|
||||
}
|
||||
|
||||
public static function updateInstanceStatus($identifier, $status, $lower = true){
|
||||
if(!ShoppingInstance::where('identifier', $identifier)->exists()){
|
||||
public static function updateInstanceStatus($identifier, $status, $lower = true)
|
||||
{
|
||||
if (!ShoppingInstance::where('identifier', $identifier)->exists()) {
|
||||
return false;
|
||||
}
|
||||
if($lower){
|
||||
if ($lower) {
|
||||
ShoppingInstance::where('identifier', $identifier)->where('status', '<', $status)
|
||||
->update(['status' => $status]);
|
||||
}else{
|
||||
->update(['status' => $status]);
|
||||
} else {
|
||||
ShoppingInstance::where('identifier', $identifier)
|
||||
->update(['status' => $status]);
|
||||
->update(['status' => $status]);
|
||||
}
|
||||
}
|
||||
|
||||
public static function getInstanceStatus($identifier){
|
||||
public static function getInstanceStatus($identifier)
|
||||
{
|
||||
$shopping_instance = ShoppingInstance::where('identifier', $identifier)->first();
|
||||
if(!$shopping_instance){
|
||||
if (!$shopping_instance) {
|
||||
return false;
|
||||
}
|
||||
return $shopping_instance->getStatus();
|
||||
}
|
||||
|
||||
public static function getTypeBadge(ShoppingInstance $shoppingInstance){
|
||||
public static function getTypeBadge(ShoppingInstance $shoppingInstance)
|
||||
{
|
||||
$isFor = $shoppingInstance->shopping_data['is_for'] ?? '-';
|
||||
if ($isFor === 'abo-ot-customer' ) {
|
||||
return ' <span class="badge badge-pill badge-warning">'.__('abo.abo').'</span>';
|
||||
if ($isFor === 'abo-ot-customer') {
|
||||
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>';
|
||||
if ($isFor === 'ot-customer') {
|
||||
return ' <span class="badge badge-pill badge-secondary">' . __('order.order') . '</span>';
|
||||
}
|
||||
return "";
|
||||
return "";
|
||||
}
|
||||
|
||||
public static function getStatusBadge(ShoppingInstance $shoppingInstance){
|
||||
public static function getStatusBadge(ShoppingInstance $shoppingInstance)
|
||||
{
|
||||
$status = $shoppingInstance->getStatus();
|
||||
$badgeClasses = [
|
||||
'link_sent' => 'success',
|
||||
'link_openly' => 'warning',
|
||||
'link_sent' => 'info',
|
||||
'link_openly' => 'info',
|
||||
'link_paid' => 'secondary',
|
||||
'link_check' => 'warning',
|
||||
'link_pending' => 'warning',
|
||||
'link_appointed' => 'secondary',
|
||||
'link_appointed' => 'warning',
|
||||
'link_failed' => 'danger',
|
||||
'link_canceled' => 'danger'
|
||||
];
|
||||
|
||||
if (isset($badgeClasses[$status])) {
|
||||
return sprintf(' <span class="badge badge-pill badge-%s">%s</span>',
|
||||
return sprintf(
|
||||
' <span class="badge badge-pill badge-%s">%s</span>',
|
||||
$badgeClasses[$status],
|
||||
__('payment.' . $status)
|
||||
);
|
||||
|
|
@ -75,21 +82,23 @@ class OrderPaymentService
|
|||
return '';
|
||||
}
|
||||
|
||||
public static function getStatusAlert($status){
|
||||
public static function getStatusAlert($status)
|
||||
{
|
||||
$badgeClasses = [
|
||||
'link_sent' => 'success',
|
||||
'link_openly' => 'success',
|
||||
'link_sent' => 'info',
|
||||
'link_openly' => 'info',
|
||||
'link_check' => 'warning',
|
||||
'link_pending' => 'warning',
|
||||
'link_failed' => 'danger',
|
||||
'link_canceled' => 'danger',
|
||||
'link_appointed' => 'success',
|
||||
'link_appointed' => 'warning',
|
||||
'link_paid' => 'success',
|
||||
|
||||
];
|
||||
|
||||
if (isset($badgeClasses[$status])) {
|
||||
return sprintf(' <div class="alert alert-%s">%s</div>',
|
||||
return sprintf(
|
||||
' <div class="alert alert-%s">%s</div>',
|
||||
$badgeClasses[$status],
|
||||
__('payment.alert_' . $status)
|
||||
);
|
||||
|
|
@ -98,19 +107,20 @@ class OrderPaymentService
|
|||
return '';
|
||||
}
|
||||
|
||||
public static function getCustomPayment($identifier){
|
||||
|
||||
public static function getCustomPayment($identifier)
|
||||
{
|
||||
|
||||
$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);
|
||||
|
||||
|
||||
$data = [
|
||||
'shopping_instance' => $shopping_instance,
|
||||
'shopping_user' => $shopping_user,
|
||||
|
|
@ -123,7 +133,8 @@ class OrderPaymentService
|
|||
return $data;
|
||||
}
|
||||
|
||||
public static function getRestoredYardShoppingItems($shopping_instance){
|
||||
public static function getRestoredYardShoppingItems($shopping_instance)
|
||||
{
|
||||
|
||||
Yard::instance('shopping')->destroy();
|
||||
Yard::instance('shopping')->restore($shopping_instance->identifier, [], false);
|
||||
|
|
@ -141,14 +152,14 @@ class OrderPaymentService
|
|||
$is_currency = Yard::instance('shopping')->isPriceCurrency();
|
||||
$tax_free = Yard::instance('shopping')->getUserTaxFree();
|
||||
|
||||
foreach($rows as $row){
|
||||
foreach ($rows as $row) {
|
||||
$product = \App\Models\Product::find($row->id);
|
||||
$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;
|
||||
|
|
@ -158,23 +169,22 @@ class OrderPaymentService
|
|||
$item->abo_type = AboHelper::getAboShowOn($product);
|
||||
$item->number = $product->number;
|
||||
$item->contents = $product->contents;
|
||||
$ret['items'][] = $item;
|
||||
$ret['items'][] = $item;
|
||||
}
|
||||
|
||||
|
||||
$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