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.

85 lines
1.7 KiB

7 years ago
  1. <?php
  2. namespace App\Http\Model;
  3. use App\Common\Token;
  4. use DB;
  5. class UserWithdraw extends BaseModel
  6. {
  7. //用户余额明细
  8. protected $table = 'user_withdraw';
  9. public $timestamps = false;
  10. /**
  11. * 不能被批量赋值的属性
  12. *
  13. * @var array
  14. */
  15. protected $guarded = [];
  16. //获取列表
  17. public static function getList(array $param)
  18. {
  19. extract($param); //参数:limit,offset
  20. $where['user_id'] = Token::$uid;
  21. $limit = isset($limit) ? $limit : 10;
  22. $offset = isset($offset) ? $offset : 0;
  23. $model = new UserWithdraw;
  24. if(isset($type)){$where['type'] = $type;}
  25. $model = $model->where($where);
  26. $res['count'] = $model->count();
  27. $res['list'] = array();
  28. if($res['count']>0)
  29. {
  30. $res['list'] = $model->skip($offset)->take($limit)->orderBy('id','desc')->get()->toArray();
  31. }
  32. else
  33. {
  34. return false;
  35. }
  36. return $res;
  37. }
  38. public static function getOne($id)
  39. {
  40. return self::where('id', $id)->first()->toArray();
  41. }
  42. public static function add(array $data)
  43. {
  44. if ($id = self::insertGetId($data))
  45. {
  46. return $id;
  47. }
  48. return false;
  49. }
  50. public static function modify($where, array $data)
  51. {
  52. if (self::where($where)->update($data))
  53. {
  54. return true;
  55. }
  56. return false;
  57. }
  58. //删除一条记录
  59. public static function remove($id)
  60. {
  61. if (!self::whereIn('id', explode(',', $id))->delete())
  62. {
  63. return false;
  64. }
  65. return true;
  66. }
  67. }