#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

@ -115,6 +115,8 @@ use Illuminate\Database\Eloquent\SoftDeletes;
* @method static \Illuminate\Database\Eloquent\Builder|Product whereNoCommission($value)
* @method static \Illuminate\Database\Eloquent\Builder|Product whereShowOn($value)
* @method static \Illuminate\Database\Eloquent\Builder|Product withUniqueSlugConstraints(\Illuminate\Database\Eloquent\Model $model, string $attribute, array $config, string $slug)
* @property string|null $ean
* @method static \Illuminate\Database\Eloquent\Builder|Product whereEan($value)
*/
class Product extends Model
{
@ -208,12 +210,13 @@ class Product extends Model
];
public $showONs = [
1 => 'KundenShop',
2 => 'BeraterShop',
3 => 'Auszeitparty',
4 => 'Registrierung Berater',
5 => 'Mitgliedschaft Berater',
6 => 'Onboarding Berater',
1 => 'ShopKunde',
2 => 'ShopBerater',
3 => 'ShopBeraterKunden',
4 => 'Auszeitparty',
7 => 'Registrierung Berater',
8 => 'Mitgliedschaft Berater',
9 => 'Onboarding Berater',
10 => 'zur internen Berechnung',
];

View file

@ -152,9 +152,9 @@ class ShoppingOrder extends Model
];
public static $apiStatusTypes = [
0 => 'offen',
1 => 'offen / pre',
2 => 'bestellt',
0 => 'bestellt',
1 => 'im Prozess',
2 => 'bezahlt',
5 => 'entfernt',
];
public static $apiStatusColors = [
@ -180,7 +180,7 @@ class ShoppingOrder extends Model
5 => 'Homeparty',
6 => 'Shop',
7 => 'extern',
8 => 'Sammelbestellung',
8 => 'Sammelrechnung',
10 => '',
];
@ -259,11 +259,11 @@ class ShoppingOrder extends Model
}
public function user_sales_volume(){
return $this->hasMany('App\Models\UserSalesVolume', 'shopping_order_id');
return $this->hasOne('App\Models\UserSalesVolume', 'shopping_order_id');
}
public function user_sales_volume_no_userid(){
return $this->hasMany('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();
}
@ -318,13 +318,12 @@ class ShoppingOrder extends Model
}
public function getAPIStatusType(){
return isset(self::$apiStatusTypes[$this->api_status]) ? self::$apiStatusTypes[$this->api_status] : "offen";
return isset(self::$apiStatusTypes[$this->api_status]) ? self::$apiStatusTypes[$this->api_status] : "bestellt";
}
public function getAPIStatusColor(){
return isset(self::$apiStatusColors[$this->api_status]) ? self::$apiStatusColors[$this->api_status] : "warning";
}
public function getFormattedTotal()
{

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;
}
}
}