parent
582ca8299d
commit
263cf93a1e
41 changed files with 812 additions and 288 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue