AgentSetting.php 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. namespace App\Models\Agent;
  3. use App\Models\BaseModel;
  4. /** 代理全局配置(单行 id=1):停止分成阈值、入股、公司持股、入股充值锁定天数、充值通道组合。 */
  5. class AgentSetting extends BaseModel
  6. {
  7. protected $table = 'agent_settings';
  8. protected $guarded = ['id'];
  9. protected $hidden = ['created_at'];
  10. protected $casts = [
  11. 'margin_stop_percent' => 'decimal:4', 'equity_enabled' => 'integer',
  12. 'equity_price_per_percent' => 'decimal:4', 'equity_min_percent' => 'decimal:4',
  13. 'company_equity_percent' => 'decimal:4',
  14. 'equity_max_percent' => 'decimal:4', 'updated_by' => 'integer',
  15. 'recharge_channel_group_id' => 'integer', 'equity_recharge_lock_days' => 'integer',
  16. ];
  17. public static function current(): self
  18. {
  19. return static::query()->firstOrCreate(['id' => 1]);
  20. }
  21. /** 在事务中调用,以串行处理公司持股调整和股份分配。 */
  22. public static function lockCurrent(): self
  23. {
  24. return static::query()->lockForUpdate()->findOrFail(1);
  25. }
  26. }