#51 Festschreiben der Points, Gutschriftenmodul
This commit is contained in:
parent
dfd049aaa9
commit
3f2fbd6d5b
63 changed files with 4610 additions and 971 deletions
104
app/Models/UserBusiness.php
Normal file
104
app/Models/UserBusiness.php
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Casts\AsArrayObject;
|
||||
|
||||
class UserBusiness extends Model
|
||||
{
|
||||
protected $table = 'user_businesses';
|
||||
|
||||
protected $casts = [
|
||||
'user_id' => 'int',
|
||||
'month' => 'int',
|
||||
'year' => 'int',
|
||||
'b_structure_id' => 'int',
|
||||
'm_level_id' => 'int',
|
||||
'active_account' => 'bool',
|
||||
'm_account' => 'int',
|
||||
'sales_volume_points' => 'int',
|
||||
'sales_volume_points_shop' => 'int',
|
||||
'sales_volume_points_sum' => 'int',
|
||||
'sales_volume_total' => 'float',
|
||||
'sales_volume_total_shop' => 'float',
|
||||
'sales_volume_total_sum' => 'float',
|
||||
'margin' => 'int',
|
||||
'margin_shop' => 'int',
|
||||
'qual_kp' => 'int',
|
||||
'qual_tp' => 'int',
|
||||
'total_tp' => 'int',
|
||||
'total_qual_tp' => 'int',
|
||||
'commission_team_total' => 'float',
|
||||
'commission_shop_sales' => 'float',
|
||||
'qual_user_level' => 'array',
|
||||
'sponsor' => 'object',
|
||||
'business_lines' => AsArrayObject::class,
|
||||
'user_items' => AsArrayObject::class
|
||||
];
|
||||
|
||||
protected $dates = [
|
||||
'payment_account_date',
|
||||
'active_date'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'month',
|
||||
'year',
|
||||
'b_structure_id',
|
||||
'm_level_id',
|
||||
'sponsor',
|
||||
'user_level_name',
|
||||
'active_account',
|
||||
'payment_account_date',
|
||||
'active_date',
|
||||
'm_account',
|
||||
'email',
|
||||
'first_name',
|
||||
'last_name',
|
||||
'sales_volume_points',
|
||||
'sales_volume_points_shop',
|
||||
'sales_volume_points_sum',
|
||||
'sales_volume_total',
|
||||
'sales_volume_total_shop',
|
||||
'sales_volume_total_sum',
|
||||
'margin',
|
||||
'margin_shop',
|
||||
'qual_kp',
|
||||
'qual_tp',
|
||||
'qual_user_level',
|
||||
'total_tp',
|
||||
'total_qual_tp',
|
||||
'commission_team_total',
|
||||
'commission_shop_sales',
|
||||
'business_lines',
|
||||
'user_items',
|
||||
];
|
||||
|
||||
public function user_business_structure()
|
||||
{
|
||||
return $this->belongsTo(UserBusinessStructure::class, 'b_structure_id');
|
||||
}
|
||||
|
||||
public function isSave(){
|
||||
return $this->id !== null ? true : false;
|
||||
}
|
||||
|
||||
public function setPaymentAccountDateAttribute( $value ) {
|
||||
$this->attributes['payment_account_date'] = isset($value) ? (new Carbon($value))->format('Y-m-d') : NULL;
|
||||
}
|
||||
|
||||
|
||||
public function setActiveDateAttribute( $value ) {
|
||||
$this->attributes['active_date'] = isset($value) ? (new Carbon($value))->format('Y-m-d') : NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
73
app/Models/UserBusinessStructure.php
Normal file
73
app/Models/UserBusinessStructure.php
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Casts\AsArrayObject;
|
||||
|
||||
|
||||
/**
|
||||
* Class UserBusinessStructure
|
||||
*
|
||||
* @property int $id
|
||||
* @property int|null $month
|
||||
* @property int|null $year
|
||||
* @property object|null $structure
|
||||
* @property object|null $parentless
|
||||
* @property array|null $users
|
||||
* @property bool $completed
|
||||
* @property int $status
|
||||
* @package App\Models
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\UserBusiness[] $user_businesses
|
||||
* @property-read int|null $user_businesses_count
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserBusinessStructure newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserBusinessStructure newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserBusinessStructure query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserBusinessStructure whereCompleted($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserBusinessStructure whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserBusinessStructure whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserBusinessStructure whereMonth($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserBusinessStructure whereParentless($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserBusinessStructure whereStatus($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserBusinessStructure whereStructure($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserBusinessStructure whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserBusinessStructure whereUsers($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserBusinessStructure whereYear($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class UserBusinessStructure extends Model
|
||||
{
|
||||
protected $table = 'user_business_structures';
|
||||
|
||||
protected $casts = [
|
||||
'month' => 'int',
|
||||
'year' => 'int',
|
||||
'completed' => 'bool',
|
||||
'status' => 'int',
|
||||
'structure' => 'object',
|
||||
'parentless' => 'object',
|
||||
'users' => 'array',
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'month',
|
||||
'year',
|
||||
'structure',
|
||||
'parentless',
|
||||
'users',
|
||||
'completed',
|
||||
'status'
|
||||
];
|
||||
|
||||
|
||||
public function user_businesses()
|
||||
{
|
||||
return $this->hasMany(UserBusiness::class, 'b_structure_id');
|
||||
}
|
||||
}
|
||||
172
app/Models/UserCredit.php
Normal file
172
app/Models/UserCredit.php
Normal file
|
|
@ -0,0 +1,172 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\User;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
/**
|
||||
* Class UserCredit
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $user_id
|
||||
* @property int|null $month
|
||||
* @property int|null $year
|
||||
* @property Carbon|null $date
|
||||
* @property string|null $full_number
|
||||
* @property int|null $number
|
||||
* @property float|null $net
|
||||
* @property float|null $tax_rate
|
||||
* @property float|null $tax
|
||||
* @property float|null $total
|
||||
* @property string|null $filename
|
||||
* @property string|null $dir
|
||||
* @property string|null $disk
|
||||
* @property array|null $infos
|
||||
* @property bool $paid_out
|
||||
* @property Carbon|null $paid_out_date
|
||||
* @property bool $cancellation
|
||||
* @property int|null $cancellation_id
|
||||
* @property Carbon|null $cancellation_date
|
||||
* @property int $status
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property string|null $deleted_at
|
||||
*
|
||||
* @property User $user
|
||||
* @property Collection|UserCreditItem[] $user_credit_items
|
||||
*
|
||||
* @package App\Models
|
||||
*/
|
||||
class UserCredit extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
protected $table = 'user_credits';
|
||||
|
||||
protected $casts = [
|
||||
'user_id' => 'int',
|
||||
'month' => 'int',
|
||||
'year' => 'int',
|
||||
'number' => 'int',
|
||||
'net' => 'float',
|
||||
'tax_rate' => 'float',
|
||||
'tax' => 'float',
|
||||
'taxable' => 'bool',
|
||||
'total' => 'float',
|
||||
'paid_out' => 'bool',
|
||||
'cancellation' => 'bool',
|
||||
'cancellation_id' => 'int',
|
||||
'status' => 'int',
|
||||
'infos' => 'array'
|
||||
];
|
||||
|
||||
protected $dates = [
|
||||
'date',
|
||||
'paid_out_date',
|
||||
'cancellation_date'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'month',
|
||||
'year',
|
||||
'date',
|
||||
'full_number',
|
||||
'number',
|
||||
'net',
|
||||
'tax_rate',
|
||||
'tax',
|
||||
'total',
|
||||
'taxable',
|
||||
'filename',
|
||||
'dir',
|
||||
'disk',
|
||||
'infos',
|
||||
'paid_out',
|
||||
'paid_out_date',
|
||||
'cancellation',
|
||||
'cancellation_id',
|
||||
'cancellation_date',
|
||||
'status'
|
||||
];
|
||||
|
||||
public static $statusTypes = [
|
||||
0 => 'offen',
|
||||
1 => 'bezahlt',
|
||||
2 => 'prüfen',
|
||||
10 => 'storniert'
|
||||
];
|
||||
|
||||
public static $statusColors = [
|
||||
0 => 'warning',
|
||||
1 => 'success',
|
||||
2 => 'secondary',
|
||||
10 => 'danger',
|
||||
];
|
||||
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function user_credit_items()
|
||||
{
|
||||
return $this->hasMany(UserCreditItem::class);
|
||||
}
|
||||
|
||||
public function isCredit(){
|
||||
return $this->filename ? true : false;
|
||||
}
|
||||
|
||||
public function getDateAttribute($value)
|
||||
{
|
||||
return $value ? Carbon::parse($value)->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 getFormattedTax()
|
||||
{
|
||||
return formatNumber($this->attributes['tax']);
|
||||
}
|
||||
|
||||
public function getFormattedNet()
|
||||
{
|
||||
return formatNumber($this->attributes['net']);
|
||||
}
|
||||
|
||||
public function getFormattedTotal()
|
||||
{
|
||||
return formatNumber($this->attributes['total']);
|
||||
}
|
||||
|
||||
|
||||
public function getStatusType(){
|
||||
return isset(self::$statusTypes[$this->status]) ? self::$statusTypes[$this->status] : "";
|
||||
}
|
||||
|
||||
public function getStatusColor(){
|
||||
return isset(self::$statusColors[$this->status]) ? self::$statusColors[$this->status] : "default";
|
||||
}
|
||||
|
||||
public function getDownloadPath($full = false){
|
||||
if(!$full){
|
||||
return $this->dir.$this->filename;
|
||||
}
|
||||
return \Storage::disk($this->disk)->path($this->dir.$this->filename);
|
||||
}
|
||||
}
|
||||
99
app/Models/UserCreditItem.php
Normal file
99
app/Models/UserCreditItem.php
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\User;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class UserCreditItem
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $user_id
|
||||
* @property int|null $user_credit_id
|
||||
* @property float|null $credit
|
||||
* @property string|null $message
|
||||
* @property int $status
|
||||
* @property bool $paid
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
*
|
||||
* @property UserCredit|null $user_credit
|
||||
* @property User $user
|
||||
*
|
||||
* @package App\Models
|
||||
*/
|
||||
class UserCreditItem extends Model
|
||||
{
|
||||
|
||||
|
||||
public static $statusTypes = [
|
||||
1 => 'Provision Shop',
|
||||
2 => 'Provision Team',
|
||||
3 => 'Guthaben hinzugefügt',
|
||||
4 => 'commission ...',
|
||||
];
|
||||
|
||||
public static $statusColors = [
|
||||
0 => 'warning',
|
||||
1 => 'success',
|
||||
2 => 'secondary',
|
||||
3 => 'warning',
|
||||
4 => 'info',
|
||||
10 => 'danger',
|
||||
];
|
||||
|
||||
|
||||
protected $table = 'user_credit_items';
|
||||
|
||||
protected $casts = [
|
||||
'user_id' => 'int',
|
||||
'user_credit_id' => 'int',
|
||||
'credit' => 'float',
|
||||
'status' => 'int',
|
||||
'paid' => 'bool'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'user_credit_id',
|
||||
'credit',
|
||||
'message',
|
||||
'status',
|
||||
'paid'
|
||||
];
|
||||
|
||||
public function user_credit()
|
||||
{
|
||||
return $this->belongsTo(UserCredit::class);
|
||||
}
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
|
||||
public function deleteTime(){
|
||||
$time = '+100 min';
|
||||
if(Carbon::parse($this->created_at)->modify($time)->gt(Carbon::now())){
|
||||
return Carbon::now()->diffInMinutes(Carbon::parse($this->created_at)->modify($time));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getStatusType(){
|
||||
return isset(self::$statusTypes[$this->status]) ? self::$statusTypes[$this->status] : "";
|
||||
}
|
||||
|
||||
public function getStatusColor(){
|
||||
return isset(self::$statusColors[$this->status]) ? self::$statusColors[$this->status] : "default";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -56,6 +56,8 @@ use App\User;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|UserSalesVolume whereUserInvoiceId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserSalesVolume whereYear($value)
|
||||
* @mixin \Eloquent
|
||||
* @property array|null $syslog
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserSalesVolume whereSyslog($value)
|
||||
*/
|
||||
class UserSalesVolume extends Model
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue