User.php 888 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace app\api\model\plus\agent;
  3. use app\common\model\plus\agent\User as UserModel;
  4. /**
  5. * 分销商用户模型
  6. */
  7. class User extends UserModel
  8. {
  9. /**
  10. * 隐藏字段
  11. */
  12. protected $hidden = [
  13. 'create_time',
  14. 'update_time',
  15. ];
  16. /**
  17. * 资金冻结
  18. */
  19. public function freezeMoney($money)
  20. {
  21. return $this->save([
  22. 'money' => $this['money'] - $money,
  23. 'freeze_money' => $this['freeze_money'] + $money,
  24. ]);
  25. }
  26. /**
  27. * 累计分销商成员数量
  28. */
  29. public static function setMemberInc($agent_id, $level)
  30. {
  31. $fields = [1 => 'first_num', 2 => 'second_num', 3 => 'third_num'];
  32. $model = static::detail($agent_id);
  33. return $model->where('user_id', '=', $agent_id)->inc($fields[$level])->update();
  34. }
  35. }