20-02-2026
This commit is contained in:
parent
a8b395e20d
commit
a00c42e770
252 changed files with 28785 additions and 8907 deletions
|
|
@ -6,10 +6,9 @@
|
|||
|
||||
namespace App\Models;
|
||||
|
||||
use App\User;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Models\ShoppingOrder;
|
||||
use App\User;
|
||||
|
||||
/**
|
||||
* Class UserSalesVolume
|
||||
|
|
@ -32,11 +31,11 @@ use App\User;
|
|||
* @property Carbon|null $updated_at
|
||||
* @property ShoppingOrder|null $shopping_order
|
||||
* @property User $user
|
||||
* @package App\Models
|
||||
* @property int|null $user_invoice_id
|
||||
* @property int|null $month_shop_points
|
||||
* @property float|null $month_shop_total_net
|
||||
* @property-read \App\Models\UserInvoice|null $user_invoice
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserSalesVolume newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserSalesVolume newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserSalesVolume query()
|
||||
|
|
@ -57,275 +56,293 @@ use App\User;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|UserSalesVolume whereUserId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserSalesVolume whereUserInvoiceId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserSalesVolume whereYear($value)
|
||||
*
|
||||
* @property array|null $syslog
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserSalesVolume whereSyslog($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserSalesVolume whereInfo($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserSalesVolume whereStatusPoints($value)
|
||||
*
|
||||
* @property int|null $month_KP_points
|
||||
* @property int|null $month_TP_points
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserSalesVolume whereMonthKPPoints($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserSalesVolume whereMonthTPPoints($value)
|
||||
*
|
||||
* @property int|null $status_turnover
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserSalesVolume whereStatusTurnover($value)
|
||||
*
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class UserSalesVolume extends Model
|
||||
{
|
||||
protected $table = 'user_sales_volumes';
|
||||
protected $table = 'user_sales_volumes';
|
||||
|
||||
protected $casts = [
|
||||
'user_id' => 'int',
|
||||
'shopping_order_id' => 'int',
|
||||
'user_invoice_id' => 'int',
|
||||
'month' => 'int',
|
||||
'year' => 'int',
|
||||
'points' => 'float',
|
||||
'month_KP_points' => 'float',
|
||||
'month_TP_points' => 'float',
|
||||
'month_shop_points' => 'float',
|
||||
'status_points' => 'int',
|
||||
'status_turnover' => 'int',
|
||||
'total_net' => 'float',
|
||||
'month_total_net' => 'float',
|
||||
'month_shop_total_net' => 'float',
|
||||
'status' => 'int',
|
||||
'syslog' => 'array'
|
||||
];
|
||||
protected $casts = [
|
||||
'user_id' => 'int',
|
||||
'shopping_order_id' => 'int',
|
||||
'user_invoice_id' => 'int',
|
||||
'month' => 'int',
|
||||
'year' => 'int',
|
||||
'points' => 'float',
|
||||
'month_KP_points' => 'float',
|
||||
'month_TP_points' => 'float',
|
||||
'month_shop_points' => 'float',
|
||||
'status_points' => 'int',
|
||||
'status_turnover' => 'int',
|
||||
'total_net' => 'float',
|
||||
'month_total_net' => 'float',
|
||||
'month_shop_total_net' => 'float',
|
||||
'status' => 'int',
|
||||
'syslog' => 'array',
|
||||
];
|
||||
|
||||
protected $dates = [
|
||||
'date'
|
||||
];
|
||||
protected $dates = [
|
||||
'date',
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'shopping_order_id',
|
||||
'user_invoice_id',
|
||||
'month',
|
||||
'year',
|
||||
'date',
|
||||
'points',
|
||||
'month_KP_points',
|
||||
'month_TP_points',
|
||||
'month_shop_points',
|
||||
'status_points',
|
||||
'status_turnover',
|
||||
'total_net',
|
||||
'month_total_net',
|
||||
'month_shop_total_net',
|
||||
'message',
|
||||
'info',
|
||||
'status',
|
||||
'syslog'
|
||||
];
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'shopping_order_id',
|
||||
'user_invoice_id',
|
||||
'month',
|
||||
'year',
|
||||
'date',
|
||||
'points',
|
||||
'month_KP_points',
|
||||
'month_TP_points',
|
||||
'month_shop_points',
|
||||
'status_points',
|
||||
'status_turnover',
|
||||
'total_net',
|
||||
'month_total_net',
|
||||
'month_shop_total_net',
|
||||
'message',
|
||||
'info',
|
||||
'status',
|
||||
'syslog',
|
||||
];
|
||||
|
||||
public static $statusPointsTypes = [
|
||||
1 => 'KU + TP', // Eigene + Team
|
||||
2 => 'KU', // nur Eigene nicht Team
|
||||
];
|
||||
|
||||
public static $statusPointsTypes = [
|
||||
1 => 'KU + TP', //Eigene + Team
|
||||
2 => 'KU', //nur Eigene nicht Team
|
||||
];
|
||||
public static $statusTurnoverTypes = [
|
||||
1 => 'advisor_order', // hinzugefügt aus
|
||||
2 => 'shoporder', // hinzugefügt aus
|
||||
];
|
||||
|
||||
public static $statusTurnoverTypes = [
|
||||
1 => 'advisor_order', //hinzugefügt aus
|
||||
2 => 'shoporder', //hinzugefügt aus
|
||||
];
|
||||
public static $statusTypes = [
|
||||
0 => 'not_assigned',
|
||||
1 => 'advisor_order', // hinzugefügt aus
|
||||
2 => 'shoporder', // hinzugefügt aus
|
||||
3 => 'shoporder_pending', // hinzugefügt aus
|
||||
4 => 'credit', // hinzugefügt aus
|
||||
5 => 'registration', // hinzugefügt aus
|
||||
6 => 'cancelled', // Stornorechnung
|
||||
// 10 => ''
|
||||
];
|
||||
|
||||
public static $statusTypes = [
|
||||
0 => 'not_assigned',
|
||||
1 => 'advisor_order', //hinzugefügt aus
|
||||
2 => 'shoporder', //hinzugefügt aus
|
||||
3 => 'shoporder_pending', //hinzugefügt aus
|
||||
4 => 'credit', //hinzugefügt aus
|
||||
5 => 'registration', //hinzugefügt aus
|
||||
// 10 => ''
|
||||
];
|
||||
public static $statusColors = [
|
||||
0 => 'warning',
|
||||
1 => 'success',
|
||||
2 => 'secondary',
|
||||
3 => 'warning',
|
||||
4 => 'info',
|
||||
5 => 'info',
|
||||
6 => 'danger',
|
||||
10 => 'danger',
|
||||
];
|
||||
|
||||
public static $statusColors = [
|
||||
0 => 'warning',
|
||||
1 => 'success',
|
||||
2 => 'secondary',
|
||||
3 => 'warning',
|
||||
4 => 'info',
|
||||
5 => 'info',
|
||||
10 => 'danger',
|
||||
];
|
||||
public function shopping_order()
|
||||
{
|
||||
return $this->belongsTo(ShoppingOrder::class);
|
||||
}
|
||||
|
||||
public function shopping_order()
|
||||
{
|
||||
return $this->belongsTo(ShoppingOrder::class);
|
||||
}
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
public function user_invoice()
|
||||
{
|
||||
return $this->belongsTo(UserInvoice::class);
|
||||
}
|
||||
|
||||
public function user_invoice()
|
||||
{
|
||||
return $this->belongsTo(UserInvoice::class);
|
||||
}
|
||||
public function getDateAttribute()
|
||||
{
|
||||
return $this->attributes['date'] ? Carbon::parse($this->attributes['date'])->format(\Util::formatDateDB()) : '';
|
||||
}
|
||||
|
||||
public function getDateAttribute()
|
||||
{
|
||||
return $this->attributes['date'] ? Carbon::parse($this->attributes['date'])->format(\Util::formatDateDB()) : '';
|
||||
}
|
||||
public function setDateAttribute($value)
|
||||
{
|
||||
$this->attributes['date'] = isset($value) ? (new Carbon($value))->format('Y-m-d') : NULL;
|
||||
}
|
||||
public function getDateRaw()
|
||||
{
|
||||
return isset($this->attributes['date']) ? $this->attributes['date'] : NULL;
|
||||
}
|
||||
public function setDateAttribute($value)
|
||||
{
|
||||
$this->attributes['date'] = isset($value) ? (new Carbon($value))->format('Y-m-d') : null;
|
||||
}
|
||||
|
||||
// Points Setter/Getter für deutsches Zahlenformat
|
||||
public function setPointsAttribute($value)
|
||||
{
|
||||
$this->attributes['points'] = $value !== null ? \Util::reFormatNumber($value) : null;
|
||||
}
|
||||
public function getDateRaw()
|
||||
{
|
||||
return isset($this->attributes['date']) ? $this->attributes['date'] : null;
|
||||
}
|
||||
|
||||
public function setMonthKPPointsAttribute($value)
|
||||
{
|
||||
$this->attributes['month_KP_points'] = $value !== null ? \Util::reFormatNumber($value) : null;
|
||||
}
|
||||
// Points Setter/Getter für deutsches Zahlenformat
|
||||
public function setPointsAttribute($value)
|
||||
{
|
||||
$this->attributes['points'] = $value !== null ? \Util::reFormatNumber($value) : null;
|
||||
}
|
||||
|
||||
public function setMonthTPPointsAttribute($value)
|
||||
{
|
||||
$this->attributes['month_TP_points'] = $value !== null ? \Util::reFormatNumber($value) : null;
|
||||
}
|
||||
public function setMonthKPPointsAttribute($value)
|
||||
{
|
||||
$this->attributes['month_KP_points'] = $value !== null ? \Util::reFormatNumber($value) : null;
|
||||
}
|
||||
|
||||
public function setMonthShopPointsAttribute($value)
|
||||
{
|
||||
$this->attributes['month_shop_points'] = $value !== null ? \Util::reFormatNumber($value) : null;
|
||||
}
|
||||
public function setMonthTPPointsAttribute($value)
|
||||
{
|
||||
$this->attributes['month_TP_points'] = $value !== null ? \Util::reFormatNumber($value) : null;
|
||||
}
|
||||
|
||||
public function getFormattedPoints()
|
||||
{
|
||||
return isset($this->attributes['points']) ? \Util::formatNumber($this->attributes['points']) : "";
|
||||
}
|
||||
public function setMonthShopPointsAttribute($value)
|
||||
{
|
||||
$this->attributes['month_shop_points'] = $value !== null ? \Util::reFormatNumber($value) : null;
|
||||
}
|
||||
|
||||
public function getFormattedMonthKPPoints()
|
||||
{
|
||||
return isset($this->attributes['month_KP_points']) ? \Util::formatNumber($this->attributes['month_KP_points']) : 0;
|
||||
}
|
||||
public function getFormattedPoints()
|
||||
{
|
||||
return isset($this->attributes['points']) ? \Util::formatNumber($this->attributes['points']) : '';
|
||||
}
|
||||
|
||||
public function getFormattedMonthTPPoints()
|
||||
{
|
||||
return isset($this->attributes['month_TP_points']) ? \Util::formatNumber($this->attributes['month_TP_points']) : 0;
|
||||
}
|
||||
public function getFormattedMonthKPPoints()
|
||||
{
|
||||
return isset($this->attributes['month_KP_points']) ? \Util::formatNumber($this->attributes['month_KP_points']) : 0;
|
||||
}
|
||||
|
||||
public function getFormattedMonthShopPoints()
|
||||
{
|
||||
return isset($this->attributes['month_shop_points']) ? \Util::formatNumber($this->attributes['month_shop_points']) : 0;
|
||||
}
|
||||
public function getFormattedMonthTPPoints()
|
||||
{
|
||||
return isset($this->attributes['month_TP_points']) ? \Util::formatNumber($this->attributes['month_TP_points']) : 0;
|
||||
}
|
||||
|
||||
public function getPointsKPSum()
|
||||
{
|
||||
return $this->month_KP_points + $this->month_shop_points; //only KP für SUM - KP is for User
|
||||
}
|
||||
public function getPointsTPSum()
|
||||
{
|
||||
return $this->month_TP_points + $this->month_shop_points; //only TP für SUM - TP is only for Payline
|
||||
}
|
||||
public function getFormattedMonthShopPoints()
|
||||
{
|
||||
return isset($this->attributes['month_shop_points']) ? \Util::formatNumber($this->attributes['month_shop_points']) : 0;
|
||||
}
|
||||
|
||||
public function getTotalNetSum()
|
||||
{
|
||||
return $this->month_total_net + $this->month_shop_total_net;
|
||||
}
|
||||
public function getPointsKPSum()
|
||||
{
|
||||
return $this->month_KP_points + $this->month_shop_points; // only KP für SUM - KP is for User
|
||||
}
|
||||
|
||||
public function getStatusType()
|
||||
{
|
||||
return isset(self::$statusTypes[$this->status]) ? __('payment.' . self::$statusTypes[$this->status]) : "";
|
||||
}
|
||||
public function getPointsTPSum()
|
||||
{
|
||||
return $this->month_TP_points + $this->month_shop_points; // only TP für SUM - TP is only for Payline
|
||||
}
|
||||
|
||||
public static function getTransStatusType()
|
||||
{
|
||||
$ret = [];
|
||||
foreach (self::$statusTypes as $key => $val) {
|
||||
$ret[$key] = trans('payment.' . $val);
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
public function getTotalNetSum()
|
||||
{
|
||||
return $this->month_total_net + $this->month_shop_total_net;
|
||||
}
|
||||
|
||||
public static function getTransTurnoverTypes()
|
||||
{
|
||||
$ret = [];
|
||||
foreach (self::$statusTurnoverTypes as $key => $val) {
|
||||
$ret[$key] = trans('payment.' . $val);
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
public function getStatusType()
|
||||
{
|
||||
return isset(self::$statusTypes[$this->status]) ? __('payment.'.self::$statusTypes[$this->status]) : '';
|
||||
}
|
||||
|
||||
public function getStatusColor()
|
||||
{
|
||||
return isset(self::$statusColors[$this->status]) ? self::$statusColors[$this->status] : "default";
|
||||
}
|
||||
public static function getTransStatusType()
|
||||
{
|
||||
$ret = [];
|
||||
foreach (self::$statusTypes as $key => $val) {
|
||||
$ret[$key] = trans('payment.'.$val);
|
||||
}
|
||||
|
||||
public function getStatusPointsType()
|
||||
{
|
||||
return isset(self::$statusPointsTypes[$this->status_points]) ? self::$statusPointsTypes[$this->status_points] : "";
|
||||
}
|
||||
public function getStatusPointsColor()
|
||||
{
|
||||
return isset(self::$statusColors[$this->status_points]) ? self::$statusColors[$this->status_points] : "default";
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function getStatusTurnoverType()
|
||||
{
|
||||
switch ($this->status) {
|
||||
case 1: //Bestellung Berater
|
||||
return 'E';
|
||||
case 2: //Shop
|
||||
return 'S';
|
||||
case 4: //Gutschrift
|
||||
if ($this->status_turnover === 2) {
|
||||
return 'S';
|
||||
} else {
|
||||
return 'E';
|
||||
}
|
||||
case 5: //Registrierung
|
||||
return 'E';
|
||||
}
|
||||
return "";
|
||||
}
|
||||
public function getStatusTurnoverColor()
|
||||
{
|
||||
public static function getTransTurnoverTypes()
|
||||
{
|
||||
$ret = [];
|
||||
foreach (self::$statusTurnoverTypes as $key => $val) {
|
||||
$ret[$key] = trans('payment.'.$val);
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
switch ($this->status) {
|
||||
case 1: //Bestellung Berater
|
||||
return 'success';
|
||||
case 2: //Shop
|
||||
return 'secondary';
|
||||
case 4: //Gutschrift
|
||||
if ($this->status_turnover === 2) {
|
||||
return 'secondary';
|
||||
} else {
|
||||
return 'success';
|
||||
}
|
||||
case 5: //Registrierung
|
||||
return 'success';
|
||||
}
|
||||
return "default";
|
||||
}
|
||||
public function getStatusColor()
|
||||
{
|
||||
return isset(self::$statusColors[$this->status]) ? self::$statusColors[$this->status] : 'default';
|
||||
}
|
||||
|
||||
public function getFormatedMonthYear()
|
||||
{
|
||||
return str_pad($this->month, 2, "0", STR_PAD_LEFT) . "/" . $this->year;
|
||||
}
|
||||
public function getStatusPointsType()
|
||||
{
|
||||
return isset(self::$statusPointsTypes[$this->status_points]) ? self::$statusPointsTypes[$this->status_points] : '';
|
||||
}
|
||||
|
||||
public function isCurrentMonthYear()
|
||||
{
|
||||
if ($this->month === intval(date('m')) && $this->year === intval(date('Y'))) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public function getStatusPointsColor()
|
||||
{
|
||||
return isset(self::$statusColors[$this->status_points]) ? self::$statusColors[$this->status_points] : 'default';
|
||||
}
|
||||
|
||||
public function caluCommissonTotalNet($margin)
|
||||
{
|
||||
if ($this->total_net > 0 && $margin > 0) {
|
||||
return $this->total_net / 100 * $margin;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
public function getStatusTurnoverType()
|
||||
{
|
||||
switch ($this->status) {
|
||||
case 1: // Bestellung Berater
|
||||
return 'E';
|
||||
case 2: // Shop
|
||||
return 'S';
|
||||
case 4: // Gutschrift
|
||||
if ($this->status_turnover === 2) {
|
||||
return 'S';
|
||||
} else {
|
||||
return 'E';
|
||||
}
|
||||
case 5: // Registrierung
|
||||
return 'E';
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
public function getStatusTurnoverColor()
|
||||
{
|
||||
|
||||
switch ($this->status) {
|
||||
case 1: // Bestellung Berater
|
||||
return 'success';
|
||||
case 2: // Shop
|
||||
return 'secondary';
|
||||
case 4: // Gutschrift
|
||||
if ($this->status_turnover === 2) {
|
||||
return 'secondary';
|
||||
} else {
|
||||
return 'success';
|
||||
}
|
||||
case 5: // Registrierung
|
||||
return 'success';
|
||||
}
|
||||
|
||||
return 'default';
|
||||
}
|
||||
|
||||
public function getFormatedMonthYear()
|
||||
{
|
||||
return str_pad($this->month, 2, '0', STR_PAD_LEFT).'/'.$this->year;
|
||||
}
|
||||
|
||||
public function isCurrentMonthYear()
|
||||
{
|
||||
if ($this->month === intval(date('m')) && $this->year === intval(date('Y'))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function caluCommissonTotalNet($margin)
|
||||
{
|
||||
if ($this->total_net > 0 && $margin > 0) {
|
||||
return $this->total_net / 100 * $margin;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue