#53, #52, #51 change Points

This commit is contained in:
Kevin Adametz 2022-07-21 10:37:34 +02:00
parent 582ca8299d
commit 263cf93a1e
41 changed files with 812 additions and 288 deletions

View file

@ -73,7 +73,8 @@ class UserSalesVolume extends Model
'total_net' => 'float',
'month_total_net' => 'float',
'month_shop_total_net' => 'float',
'status' => 'int'
'status' => 'int',
'syslog' => 'array'
];
protected $dates = [
@ -94,15 +95,16 @@ class UserSalesVolume extends Model
'month_total_net',
'month_shop_total_net',
'message',
'status'
'status',
'syslog'
];
public static $statusTypes = [
0 => 'nicht zugewiesen',
1 => 'hinzugefügt aus Bestellung',
2 => 'hinzugefügt aus Shop',
3 => 'hinzugefügt aus Shop / pending',
1 => 'hinzugefügt aus Beraterbestellung',
2 => 'hinzugefügt aus Shopbestellung',
3 => 'hinzugefügt aus Shopbestellung / pending',
10 => ''
];
@ -135,42 +137,14 @@ class UserSalesVolume extends Model
return isset(self::$statusTypes[$this->status]) ? self::$statusTypes[$this->status] : "";
}
public static function getStatusByOrder($ShoppingOrder){
if($ShoppingOrder->payment_for){
if($ShoppingOrder->payment_for === 6){ //Kunde-Shop
if($ShoppingOrder->shopping_user && $ShoppingOrder->shopping_user->is_like){
return 3; //shop Kunden, berater zuordnen
}
return 2;
}
return 1;
}
return 0;
}
public function getFormatedMonthYear(){
return str_pad($this->month, 2, "0", STR_PAD_LEFT)."/".$this->year;
}
public function setToUserAndCalculate($user_id){
$month = $this->month;
$year = $this->year;
$month_shop_points = UserSalesVolume::where('user_id', $user_id)->where('status', 2)->where('month', $month)->where('year', $year)->sum('points');
$month_shop_total_net = UserSalesVolume::where('user_id', $user_id)->where('status', 2)->where('month', $month)->where('year', $year)->sum('total_net');
$month_points = UserSalesVolume::where('user_id', $user_id)->where('status', 1)->where('month', $month)->where('year', $year)->sum('points');
$month_total_net = UserSalesVolume::where('user_id', $user_id)->where('status', 1)->where('month', $month)->where('year', $year)->sum('total_net');
$month_shop_points += $this->points;
$month_shop_total_net += $this->total_net;
$this->user_id = $user_id;
$this->month_shop_points = $month_shop_points;
$this->month_shop_total_net = $month_shop_total_net;
$this->month_points = $month_points;
$this->month_total_net = $month_total_net;
$this->status = 2;
$this->save();
public function isCurrentMonthYear(){
if($this->month === intval(date('m')) && $this->year === intval(date('Y'))){
return true;
}
return false;
}
}
}