User.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. /**
  3. *
  4. * @copyright ©2020 点小铺
  5. * @author hanj
  6. * @link: https://dyuit.com
  7. * Created by VSCode
  8. */
  9. namespace app\api\model\dealer;
  10. use app\common\model\dealer\User as UserModel;
  11. /**
  12. * 分销商用户模型
  13. * Class User
  14. * @package app\api\model\dealer
  15. */
  16. class User extends UserModel
  17. {
  18. /**
  19. * 隐藏字段
  20. * @var array
  21. */
  22. protected $hidden = [
  23. 'create_time',
  24. 'update_time',
  25. ];
  26. /**
  27. * 资金冻结
  28. * @param $money
  29. * @return false|int
  30. */
  31. public function freezeMoney($money)
  32. {
  33. return $this->save([
  34. 'money' => $this['money'] - $money,
  35. 'freeze_money' => $this['freeze_money'] + $money,
  36. ]);
  37. }
  38. /**
  39. * 累计分销商成员数量
  40. * @param $dealer_id
  41. * @param $level
  42. * @return int|true
  43. * @throws \think\Exception
  44. * @throws \think\exception\DbException
  45. */
  46. public static function setMemberInc($dealer_id, $level)
  47. {
  48. $fields = [1 => 'first_num', 2 => 'second_num', 3 => 'third_num'];
  49. $model = static::detail($dealer_id);
  50. return $model->setInc($fields[$level]);
  51. }
  52. }