20-02-2026
This commit is contained in:
parent
a8b395e20d
commit
a00c42e770
252 changed files with 28785 additions and 8907 deletions
|
|
@ -32,6 +32,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||
* @property-read int|null $shopping_payments_count
|
||||
* @property-read \App\Models\ShoppingUser $shopping_user
|
||||
* @property-read \App\Models\UserShop $user_shop
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder query()
|
||||
|
|
@ -51,21 +52,28 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder whereUserShopId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder whereWeight($value)
|
||||
*
|
||||
* @property int|null $payment_for
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder wherePaymentFor($value)
|
||||
*
|
||||
* @property int|null $member_id
|
||||
* @property string|null $mode
|
||||
* @property-read \App\User|null $member
|
||||
* @property-read \App\Models\UserHistory|null $user_history
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder whereMemberId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder whereMode($value)
|
||||
*
|
||||
* @property \Illuminate\Support\Carbon|null $deleted_at
|
||||
* @property string|null $user_deleted_at
|
||||
*
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\Models\ShoppingOrder onlyTrashed()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder whereDeletedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder whereUserDeletedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\Models\ShoppingOrder withTrashed()
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\Models\ShoppingOrder withoutTrashed()
|
||||
*
|
||||
* @property-read \App\Models\ShippingCountry $shipping_country
|
||||
* @property float|null $shipping_net
|
||||
* @property float|null $subtotal_ws
|
||||
|
|
@ -73,40 +81,53 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||
* @property int|null $shipped
|
||||
* @property string|null $tracking
|
||||
* @property string|null $wp_invoice_path
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder wherePoints($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder whereShipped($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder whereShippingNet($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder whereSubtotalWs($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder whereTracking($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder whereWpInvoicePath($value)
|
||||
*
|
||||
* @property int|null $homeparty_id
|
||||
* @property array|null $api_notice
|
||||
* @property int|null $api_status
|
||||
* @property-read \App\Models\Homeparty|null $homeparty
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrder whereHomepartyId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrder whereWpNotice($value)
|
||||
*
|
||||
* @property array|null $tax_split
|
||||
* @property-read \App\Models\UserInvoice|null $user_invoice
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\UserSalesVolume[] $user_sales_volume
|
||||
* @property-read int|null $user_sales_volume_count
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrder whereTaxSplit($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrder whereApiNotice($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrder whereApiStatus($value)
|
||||
*
|
||||
* @property-read \App\Models\ShoppingCollectOrder|null $shopping_collect_order
|
||||
* @property array|null $net_split
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrder whereNetSplit($value)
|
||||
*
|
||||
* @property string|null $language
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrder whereLanguage($value)
|
||||
*
|
||||
* @property bool|null $is_abo
|
||||
* @property int|null $abo_interval
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrder whereAboInterval($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrder whereIsAbo($value)
|
||||
*
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \Acme\Dhl\Models\DhlShipment> $dhlOutboundShipments
|
||||
* @property-read int|null $dhl_outbound_shipments_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \Acme\Dhl\Models\DhlShipment> $dhlReturnShipments
|
||||
* @property-read int|null $dhl_return_shipments_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \Acme\Dhl\Models\DhlShipment> $dhlShipments
|
||||
* @property-read int|null $dhl_shipments_count
|
||||
*
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class ShoppingOrder extends Model
|
||||
|
|
@ -114,6 +135,7 @@ class ShoppingOrder extends Model
|
|||
protected $table = 'shopping_orders';
|
||||
|
||||
use SoftDeletes;
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
protected $fillable = [
|
||||
|
|
@ -145,7 +167,7 @@ class ShoppingOrder extends Model
|
|||
'api_status',
|
||||
'mode',
|
||||
'shipped',
|
||||
'tracking'
|
||||
'tracking',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
|
|
@ -163,16 +185,16 @@ class ShoppingOrder extends Model
|
|||
2 => 'shipped',
|
||||
3 => 'completed',
|
||||
4 => 'trade_fair',
|
||||
10 => 'cancelled'
|
||||
10 => 'cancelled',
|
||||
];
|
||||
|
||||
public static $apiShippedTypes = [
|
||||
0 => 'open', //(Fullfilment durch Händler)',
|
||||
1 => 'process', //(Fullfilment durch MIVITA: nicht Versand)
|
||||
2 => 'sent', //(Fullfilment durch MIVITA: Versand erfolgt)'
|
||||
3 => 'close', //(Fullfilment durch MIVITA: Versand erfolgt)',
|
||||
4 => 'trade', //(Fullfilment durch MIVITA: Versand erfolgt)',
|
||||
10 => 'cancel'
|
||||
0 => 'open', // (Fullfilment durch Händler)',
|
||||
1 => 'process', // (Fullfilment durch MIVITA: nicht Versand)
|
||||
2 => 'sent', // (Fullfilment durch MIVITA: Versand erfolgt)'
|
||||
3 => 'close', // (Fullfilment durch MIVITA: Versand erfolgt)',
|
||||
4 => 'trade', // (Fullfilment durch MIVITA: Versand erfolgt)',
|
||||
10 => 'cancel',
|
||||
];
|
||||
|
||||
public static $apiStatusTypes = [
|
||||
|
|
@ -181,12 +203,14 @@ class ShoppingOrder extends Model
|
|||
2 => 'paid',
|
||||
5 => 'removed',
|
||||
];
|
||||
|
||||
public static $apiStatusColors = [
|
||||
0 => 'warning',
|
||||
1 => 'warning',
|
||||
2 => 'success',
|
||||
5 => 'danger',
|
||||
];
|
||||
|
||||
public static $shippedColors = [
|
||||
0 => 'warning',
|
||||
1 => 'info',
|
||||
|
|
@ -221,11 +245,10 @@ class ShoppingOrder extends Model
|
|||
8 => 'info',
|
||||
9 => 'default',
|
||||
10 => 'info',
|
||||
11 => 'default'
|
||||
11 => 'default',
|
||||
|
||||
];
|
||||
|
||||
|
||||
public function shopping_user()
|
||||
{
|
||||
return $this->belongsTo('App\Models\ShoppingUser', 'shopping_user_id');
|
||||
|
|
@ -251,12 +274,13 @@ class ShoppingOrder extends Model
|
|||
return $this->belongsTo('App\Models\UserShop', 'user_shop_id');
|
||||
}
|
||||
|
||||
//can null
|
||||
// can null
|
||||
public function member()
|
||||
{
|
||||
return $this->belongsTo('App\User', 'member_id');
|
||||
}
|
||||
//can null
|
||||
|
||||
// can null
|
||||
public function auth_user()
|
||||
{
|
||||
return $this->belongsTo('App\User', 'auth_user_id');
|
||||
|
|
@ -267,9 +291,42 @@ class ShoppingOrder extends Model
|
|||
return $this->hasOne('App\Models\UserHistory', 'shopping_order_id')->latest();
|
||||
}
|
||||
|
||||
/**
|
||||
* Original-Rechnung (nicht die Stornorechnung)
|
||||
*
|
||||
* Unterscheidung: Die Original-Rechnung hat entweder cancellation=false/null (vor Storno)
|
||||
* oder cancellation_id gesetzt (nach Storno, zeigt auf die Stornorechnung).
|
||||
* Die Stornorechnung hat cancellation=true UND cancellation_id=null.
|
||||
*/
|
||||
public function user_invoice()
|
||||
{
|
||||
return $this->hasOne('App\Models\UserInvoice', 'shopping_order_id', '');
|
||||
return $this->hasOne('App\Models\UserInvoice', 'shopping_order_id', 'id')
|
||||
->where(function ($query) {
|
||||
$query->where('cancellation', false)
|
||||
->orWhereNull('cancellation')
|
||||
->orWhereNotNull('cancellation_id');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Stornorechnung für diese Bestellung
|
||||
*
|
||||
* Die Stornorechnung hat cancellation=true und KEINEN cancellation_id
|
||||
* (cancellation_id wird nur auf der Original-Rechnung gesetzt).
|
||||
*/
|
||||
public function user_cancellation_invoice()
|
||||
{
|
||||
return $this->hasOne('App\Models\UserInvoice', 'shopping_order_id', 'id')
|
||||
->where('cancellation', true)
|
||||
->whereNull('cancellation_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Alle Rechnungen (Original + Storno) für diese Bestellung
|
||||
*/
|
||||
public function user_invoices()
|
||||
{
|
||||
return $this->hasMany('App\Models\UserInvoice', 'shopping_order_id', 'id');
|
||||
}
|
||||
|
||||
public function shopping_collect_order()
|
||||
|
|
@ -294,7 +351,7 @@ class ShoppingOrder extends Model
|
|||
|
||||
public function user_sales_volume_no_userid()
|
||||
{
|
||||
return $this->hasOne('App\Models\UserSalesVolume', 'shopping_order_id')->where('user_id', '=', NULL)->first();
|
||||
return $this->hasOne('App\Models\UserSalesVolume', 'shopping_order_id')->where('user_id', '=', null)->first();
|
||||
}
|
||||
|
||||
public function getUserAbo()
|
||||
|
|
@ -303,6 +360,7 @@ class ShoppingOrder extends Model
|
|||
if ($UserAboOrder && $UserAboOrder->user_abo) {
|
||||
return $UserAboOrder->user_abo;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
@ -332,7 +390,8 @@ class ShoppingOrder extends Model
|
|||
return $shopping_payment->reference;
|
||||
}
|
||||
}
|
||||
return "";
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
public function getLastShoppingPaymentTransaction()
|
||||
|
|
@ -346,40 +405,43 @@ class ShoppingOrder extends Model
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getShippedType()
|
||||
{
|
||||
return isset(self::$shippedTypes[$this->shipped]) ? __('payment.' . self::$shippedTypes[$this->shipped]) : "";
|
||||
return isset(self::$shippedTypes[$this->shipped]) ? __('payment.'.self::$shippedTypes[$this->shipped]) : '';
|
||||
}
|
||||
|
||||
public static function getTransShippedType()
|
||||
{
|
||||
$ret = [];
|
||||
foreach (self::$shippedTypes as $key => $val) {
|
||||
$ret[$key] = trans('payment.' . $val);
|
||||
$ret[$key] = trans('payment.'.$val);
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function getAPIShippedType()
|
||||
{
|
||||
return isset(self::$apiShippedTypes[$this->shipped]) ? self::$apiShippedTypes[$this->shipped] : "free";
|
||||
return isset(self::$apiShippedTypes[$this->shipped]) ? self::$apiShippedTypes[$this->shipped] : 'free';
|
||||
}
|
||||
|
||||
public function getShippedColor()
|
||||
{
|
||||
return isset(self::$shippedColors[$this->shipped]) ? self::$shippedColors[$this->shipped] : "default";
|
||||
return isset(self::$shippedColors[$this->shipped]) ? self::$shippedColors[$this->shipped] : 'default';
|
||||
}
|
||||
|
||||
public function getAPIStatusType()
|
||||
{
|
||||
return isset(self::$apiStatusTypes[$this->api_status]) ? __('payment.' . self::$apiStatusTypes[$this->api_status]) : "bestellt";
|
||||
return isset(self::$apiStatusTypes[$this->api_status]) ? __('payment.'.self::$apiStatusTypes[$this->api_status]) : 'bestellt';
|
||||
}
|
||||
|
||||
public function getAPIStatusColor()
|
||||
{
|
||||
return isset(self::$apiStatusColors[$this->api_status]) ? self::$apiStatusColors[$this->api_status] : "warning";
|
||||
return isset(self::$apiStatusColors[$this->api_status]) ? self::$apiStatusColors[$this->api_status] : 'warning';
|
||||
}
|
||||
|
||||
public function getFormattedTotal()
|
||||
|
|
@ -429,7 +491,7 @@ class ShoppingOrder extends Model
|
|||
|
||||
public function getFormattedPoints()
|
||||
{
|
||||
return isset($this->attributes['points']) ? formatNumber($this->attributes['points']) : "";
|
||||
return isset($this->attributes['points']) ? formatNumber($this->attributes['points']) : '';
|
||||
}
|
||||
|
||||
public function getPriceVkNetBy($product_id)
|
||||
|
|
@ -439,16 +501,18 @@ class ShoppingOrder extends Model
|
|||
return $product->getPriceWith(true, false, $this->shipping_country->country);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getPaymentForType()
|
||||
{
|
||||
return isset(self::$paymentForTypes[$this->payment_for]) ? __('payment.' . self::$paymentForTypes[$this->payment_for]) : "";
|
||||
return isset(self::$paymentForTypes[$this->payment_for]) ? __('payment.'.self::$paymentForTypes[$this->payment_for]) : '';
|
||||
}
|
||||
|
||||
public function getPaymentForColor()
|
||||
{
|
||||
return isset(self::$paymentForColors[$this->payment_for]) ? self::$paymentForColors[$this->payment_for] : "";
|
||||
return isset(self::$paymentForColors[$this->payment_for]) ? self::$paymentForColors[$this->payment_for] : '';
|
||||
}
|
||||
|
||||
public function getUserDiscount()
|
||||
|
|
@ -459,6 +523,7 @@ class ShoppingOrder extends Model
|
|||
if ($this->member && $this->member->user_level) {
|
||||
return $this->member->user_level->getFormattedMargin();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -470,21 +535,49 @@ class ShoppingOrder extends Model
|
|||
$count += $shopping_order_item->qty;
|
||||
}
|
||||
}
|
||||
|
||||
return $count;
|
||||
}
|
||||
|
||||
public function isInvoice()
|
||||
{
|
||||
return $this->user_invoice ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prüft ob eine Stornorechnung für diese Bestellung existiert.
|
||||
* Die echte Stornorechnung hat cancellation=true und cancellation_id=null.
|
||||
*/
|
||||
public function isCancellationInvoice()
|
||||
{
|
||||
return \App\Models\UserInvoice::where('shopping_order_id', $this->id)
|
||||
->where('cancellation', true)
|
||||
->whereNull('cancellation_id')
|
||||
->exists();
|
||||
}
|
||||
|
||||
/**
|
||||
* Holt die Stornorechnung für diese Bestellung.
|
||||
* Die echte Stornorechnung hat cancellation=true und cancellation_id=null.
|
||||
*/
|
||||
public function getCancellationInvoice()
|
||||
{
|
||||
return \App\Models\UserInvoice::where('shopping_order_id', $this->id)
|
||||
->where('cancellation', true)
|
||||
->whereNull('cancellation_id')
|
||||
->first();
|
||||
}
|
||||
|
||||
public function getStatusByOrder()
|
||||
{
|
||||
if ($this->payment_for) {
|
||||
if ($this->payment_for === 6) { //Kunde-Shop
|
||||
if ($this->payment_for === 6) { // Kunde-Shop
|
||||
return 2;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -538,7 +631,7 @@ class ShoppingOrder extends Model
|
|||
}
|
||||
|
||||
if (isset($tax_split[5])) {
|
||||
if (!isset($tax_split[16])) {
|
||||
if (! isset($tax_split[16])) {
|
||||
$tax_split[16] = ['vk_tax' => $order_vk_tax, 'ek_tax' => $order_ek_tax];
|
||||
$net_split[16] = ['vk_net' => $order_vk_net, 'ek_net' => $order_ek_net];
|
||||
}
|
||||
|
|
@ -548,7 +641,7 @@ class ShoppingOrder extends Model
|
|||
$net_split[16]['ek_net'] = round($net_split[16]['ek_net'] - $net_split[5]['ek_net'], 2);
|
||||
}
|
||||
if (isset($tax_split[7])) {
|
||||
if (!isset($tax_split[19])) {
|
||||
if (! isset($tax_split[19])) {
|
||||
$tax_split[19] = ['vk_tax' => $order_vk_tax, 'ek_tax' => $order_ek_tax];
|
||||
$net_split[19] = ['vk_net' => $order_vk_net, 'ek_net' => $order_ek_net];
|
||||
}
|
||||
|
|
@ -558,7 +651,6 @@ class ShoppingOrder extends Model
|
|||
$net_split[19]['ek_net'] = round($net_split[19]['ek_net'] - $net_split[7]['ek_net'], 2);
|
||||
}
|
||||
|
||||
|
||||
foreach ($tax_split as $key => $value) {
|
||||
$tax_split[$key]['vk_tax'] = number_format($value['vk_tax'], 2);
|
||||
$tax_split[$key]['ek_tax'] = number_format($value['ek_tax'], 2);
|
||||
|
|
@ -569,14 +661,13 @@ class ShoppingOrder extends Model
|
|||
$net_split[$key]['ek_net'] = number_format($value['ek_net'], 2);
|
||||
}
|
||||
}
|
||||
if (!isset($tax_split[16]) && !isset($tax_split[19])) {
|
||||
$tax_split = NULL;
|
||||
if (! isset($tax_split[16]) && ! isset($tax_split[19])) {
|
||||
$tax_split = null;
|
||||
}
|
||||
if (!isset($net_split[16]) && !isset($net_split[19])) {
|
||||
$net_split = NULL;
|
||||
if (! isset($net_split[16]) && ! isset($net_split[19])) {
|
||||
$net_split = null;
|
||||
}
|
||||
|
||||
|
||||
$this->tax_split = $tax_split;
|
||||
$this->net_split = $net_split;
|
||||
$this->save();
|
||||
|
|
@ -584,8 +675,8 @@ class ShoppingOrder extends Model
|
|||
|
||||
public function makeTaxSplit()
|
||||
{
|
||||
$tax_split = NULL;
|
||||
$net_split = NULL;
|
||||
$tax_split = null;
|
||||
$net_split = null;
|
||||
|
||||
if ($this->tax > 0) {
|
||||
$tax_split = [];
|
||||
|
|
@ -613,7 +704,7 @@ class ShoppingOrder extends Model
|
|||
}
|
||||
|
||||
if (isset($tax_split[5])) {
|
||||
if (!isset($tax_split[16])) {
|
||||
if (! isset($tax_split[16])) {
|
||||
$tax_split[16] = $this->tax;
|
||||
$net_split[16] = $this->subtotal_ws;
|
||||
}
|
||||
|
|
@ -621,7 +712,7 @@ class ShoppingOrder extends Model
|
|||
$net_split[16] = round($net_split[16] - $net_split[5], 2);
|
||||
}
|
||||
if (isset($tax_split[7])) {
|
||||
if (!isset($tax_split[19])) {
|
||||
if (! isset($tax_split[19])) {
|
||||
$tax_split[19] = $this->tax;
|
||||
$net_split[19] = $this->subtotal_ws;
|
||||
}
|
||||
|
|
@ -647,12 +738,12 @@ class ShoppingOrder extends Model
|
|||
|
||||
if ($this->shopping_user) {
|
||||
$fullname = $this->shopping_user->getFullNameAsArray();
|
||||
$ret = "";
|
||||
$ret .= $fullname['company'] ? $fullname['company'] . ' | ' : '';
|
||||
$ret .= $fullname['salutation'] ? \App\Services\HTMLHelper::getSalutationLang($fullname['salutation']) . ' ' : '';
|
||||
$ret .= $fullname['firstname'] ? $fullname['firstname'] . ' ' : '';
|
||||
$ret = '';
|
||||
$ret .= $fullname['company'] ? $fullname['company'].' | ' : '';
|
||||
$ret .= $fullname['salutation'] ? \App\Services\HTMLHelper::getSalutationLang($fullname['salutation']).' ' : '';
|
||||
$ret .= $fullname['firstname'] ? $fullname['firstname'].' ' : '';
|
||||
$ret .= $fullname['lastname'] ? $fullname['lastname'] : '';
|
||||
$ret .= $fullname['email'] ? ' | ' . $fullname['email'] . '' : '';
|
||||
$ret .= $fullname['email'] ? ' | '.$fullname['email'].'' : '';
|
||||
}
|
||||
|
||||
return $ret;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue