feat: 第四阶段财务与人事薪资模块
- 新增2个migration(11张表): finance(6表)/hr(5表) - 新增11个Model + 11个Controller - 新增50条API路由(总计262条) - 新增2个前端API模块 + 10个管理页面 - 迁移运行通过, vite build验证通过
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Finance;
|
||||
|
||||
use App\Models\Crm\Customer;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class AccountTransaction extends Model
|
||||
{
|
||||
const UPDATED_AT = null;
|
||||
|
||||
protected $fillable = [
|
||||
'store_id', 'customer_account_id', 'customer_id', 'type',
|
||||
'amount', 'balance_after', 'related_type', 'related_id',
|
||||
'description', 'operator_id',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'type' => 'integer',
|
||||
'amount' => 'decimal:2',
|
||||
'balance_after' => 'decimal:2',
|
||||
];
|
||||
}
|
||||
|
||||
public function account(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(CustomerAccount::class, 'customer_account_id');
|
||||
}
|
||||
|
||||
public function customer(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Customer::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Finance;
|
||||
|
||||
use App\Models\Crm\Customer;
|
||||
use App\Traits\BelongsToStore;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class CustomerAccount extends Model
|
||||
{
|
||||
use BelongsToStore;
|
||||
|
||||
protected $fillable = [
|
||||
'store_id', 'customer_id', 'cash_balance', 'card_balance', 'points',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'cash_balance' => 'decimal:2',
|
||||
'card_balance' => 'decimal:2',
|
||||
'points' => 'integer',
|
||||
];
|
||||
}
|
||||
|
||||
public function customer(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Customer::class);
|
||||
}
|
||||
|
||||
public function transactions(): HasMany
|
||||
{
|
||||
return $this->hasMany(AccountTransaction::class, 'customer_account_id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Finance;
|
||||
|
||||
use App\Traits\BelongsToStore;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class FinanceCategory extends Model
|
||||
{
|
||||
use BelongsToStore;
|
||||
|
||||
protected $fillable = [
|
||||
'store_id', 'parent_id', 'name', 'type', 'level', 'sort', 'status',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'type' => 'integer',
|
||||
'level' => 'integer',
|
||||
'sort' => 'integer',
|
||||
'status' => 'integer',
|
||||
];
|
||||
}
|
||||
|
||||
public function children(): HasMany
|
||||
{
|
||||
return $this->hasMany(self::class, 'parent_id');
|
||||
}
|
||||
|
||||
public function parent(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(self::class, 'parent_id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Finance;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Traits\BelongsToStore;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class FinanceRecord extends Model
|
||||
{
|
||||
use BelongsToStore;
|
||||
|
||||
protected $fillable = [
|
||||
'store_id', 'record_no', 'category_id', 'type', 'amount',
|
||||
'pay_method', 'related_type', 'related_id', 'description',
|
||||
'audit_status', 'audit_user_id', 'audit_at', 'operator_id',
|
||||
'record_date',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'type' => 'integer',
|
||||
'pay_method' => 'integer',
|
||||
'audit_status' => 'integer',
|
||||
'amount' => 'decimal:2',
|
||||
'audit_at' => 'datetime',
|
||||
'record_date' => 'date',
|
||||
];
|
||||
}
|
||||
|
||||
public function category(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(FinanceCategory::class, 'category_id');
|
||||
}
|
||||
|
||||
public function auditor(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'audit_user_id');
|
||||
}
|
||||
|
||||
public function operator(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'operator_id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Finance;
|
||||
|
||||
use App\Models\Crm\Customer;
|
||||
use App\Models\User;
|
||||
use App\Traits\BelongsToStore;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class Invoice extends Model
|
||||
{
|
||||
use BelongsToStore;
|
||||
|
||||
protected $fillable = [
|
||||
'store_id', 'invoice_no', 'customer_id', 'type', 'amount',
|
||||
'tax_amount', 'title', 'tax_no', 'related_type', 'related_id',
|
||||
'status', 'operator_id', 'issued_at',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'type' => 'integer',
|
||||
'status' => 'integer',
|
||||
'amount' => 'decimal:2',
|
||||
'tax_amount' => 'decimal:2',
|
||||
'issued_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
public function customer(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Customer::class);
|
||||
}
|
||||
|
||||
public function operator(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'operator_id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Finance;
|
||||
|
||||
use App\Traits\BelongsToStore;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class PrepaidCard extends Model
|
||||
{
|
||||
use BelongsToStore;
|
||||
|
||||
protected $fillable = [
|
||||
'store_id', 'name', 'face_value', 'sell_price',
|
||||
'discount_rate', 'validity_days', 'status', 'sort',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'face_value' => 'decimal:2',
|
||||
'sell_price' => 'decimal:2',
|
||||
'discount_rate' => 'decimal:2',
|
||||
'validity_days' => 'integer',
|
||||
'status' => 'integer',
|
||||
'sort' => 'integer',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Hr;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Traits\BelongsToStore;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class AttendanceRecord extends Model
|
||||
{
|
||||
use BelongsToStore;
|
||||
|
||||
protected $fillable = [
|
||||
'store_id', 'user_id', 'attendance_date', 'clock_in', 'clock_out',
|
||||
'status', 'overtime_hours', 'remark',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'status' => 'integer',
|
||||
'overtime_hours' => 'decimal:1',
|
||||
'attendance_date' => 'date',
|
||||
];
|
||||
}
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Hr;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Traits\BelongsToStore;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class EmployeeProfile extends Model
|
||||
{
|
||||
use BelongsToStore;
|
||||
|
||||
protected $fillable = [
|
||||
'store_id', 'user_id', 'employee_no', 'hire_date', 'birth_date',
|
||||
'gender', 'id_card', 'education', 'emergency_contact', 'emergency_phone',
|
||||
'base_salary', 'position_salary', 'status', 'left_date',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'hire_date' => 'date',
|
||||
'birth_date' => 'date',
|
||||
'left_date' => 'date',
|
||||
'gender' => 'integer',
|
||||
'status' => 'integer',
|
||||
'base_salary' => 'decimal:2',
|
||||
'position_salary' => 'decimal:2',
|
||||
];
|
||||
}
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Hr;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Traits\BelongsToStore;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class LeaveRequest extends Model
|
||||
{
|
||||
use BelongsToStore;
|
||||
|
||||
protected $fillable = [
|
||||
'store_id', 'user_id', 'type', 'start_date', 'end_date',
|
||||
'days', 'reason', 'status', 'audit_user_id', 'audit_at',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'type' => 'integer',
|
||||
'status' => 'integer',
|
||||
'days' => 'decimal:1',
|
||||
'start_date' => 'date',
|
||||
'end_date' => 'date',
|
||||
'audit_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function auditor(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'audit_user_id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Hr;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Traits\BelongsToStore;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class SalaryRecord extends Model
|
||||
{
|
||||
use BelongsToStore;
|
||||
|
||||
protected $fillable = [
|
||||
'store_id', 'user_id', 'year_month',
|
||||
'base_salary', 'position_salary', 'performance', 'overtime_pay',
|
||||
'subsidy', 'social_insurance', 'housing_fund', 'tax',
|
||||
'absence_deduction', 'other_deduction', 'actual_amount',
|
||||
'status', 'confirmed_at', 'paid_at',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'base_salary' => 'decimal:2',
|
||||
'position_salary' => 'decimal:2',
|
||||
'performance' => 'decimal:2',
|
||||
'overtime_pay' => 'decimal:2',
|
||||
'subsidy' => 'decimal:2',
|
||||
'social_insurance' => 'decimal:2',
|
||||
'housing_fund' => 'decimal:2',
|
||||
'tax' => 'decimal:2',
|
||||
'absence_deduction' => 'decimal:2',
|
||||
'other_deduction' => 'decimal:2',
|
||||
'actual_amount' => 'decimal:2',
|
||||
'status' => 'integer',
|
||||
'confirmed_at' => 'datetime',
|
||||
'paid_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Hr;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Traits\BelongsToStore;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class Schedule extends Model
|
||||
{
|
||||
use BelongsToStore;
|
||||
|
||||
const UPDATED_AT = null;
|
||||
|
||||
protected $fillable = [
|
||||
'store_id', 'user_id', 'schedule_date', 'shift_type',
|
||||
'start_time', 'end_time',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'shift_type' => 'integer',
|
||||
'schedule_date' => 'date',
|
||||
];
|
||||
}
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user