链街Dcat后台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.3 KiB

  1. <?php
  2. namespace App\Models;
  3. use Dcat\Admin\Traits\HasDateTimeFormatter;
  4. use Illuminate\Database\Eloquent\Model;
  5. class MpBalance extends Model
  6. {
  7. protected $table = 'lanzu_user_balance';
  8. protected $dateFormat = 'U';
  9. /**
  10. * 获取可提现金额
  11. * @param $uid
  12. * @param $uType 0/1 普通用户/服务商
  13. */
  14. public static function getBalance($uid,$uType=0)
  15. {
  16. $row = self::where(['user_id'=>$uid,'user_type'=>$uType])->first();
  17. if ($row){
  18. return $row->balance;
  19. }else{
  20. return '0.00';
  21. }
  22. }
  23. /**
  24. * 扣减可提现金额
  25. */
  26. public static function reduceBalance($uid,$uType,$reduceMoney)
  27. {
  28. $row = self::where(['user_id'=>$uid,'user_type'=>$uType])->first();
  29. if ($row){
  30. $row->balance = $row->balance-$reduceMoney;
  31. return $row->save();
  32. }else{
  33. return false;
  34. }
  35. }
  36. /**
  37. * 回退审核未通过时的提现金额
  38. */
  39. public static function returnBalance($uid,$uType,$returnMoney)
  40. {
  41. $row = self::where(['user_id'=>$uid,'user_type'=>$uType])->first();
  42. if ($row){
  43. $row->balance = $row->balance+$returnMoney;
  44. return $row->save();
  45. }else{
  46. return false;
  47. }
  48. }
  49. }