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.

92 lines
2.0 KiB

8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 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. $limit = isset($limit) ? $limit : 10;
  21. $offset = isset($offset) ? $offset : 0;
  22. $where['user_id'] = $user_id;
  23. $where['is_delete'] = 0;
  24. $model = new self;
  25. if(isset($status) && !empty($status)){if($status==-1){}else{$where['status'] = $status;}}
  26. if(isset($method)){$where['method'] = $method;}
  27. $model = $model->where($where);
  28. $res['count'] = $model->count();
  29. $res['list'] = array();
  30. if($res['count']>0)
  31. {
  32. $res['list'] = $model->skip($offset)->take($limit)->orderBy('id','desc')->get();
  33. }
  34. else
  35. {
  36. return false;
  37. }
  38. return $res;
  39. }
  40. public static function getOne(array $param)
  41. {
  42. extract($param);
  43. $where['id'] = $id;
  44. $where['is_delete'] = 0;
  45. return self::where($where)->first();
  46. }
  47. public static function add(array $data)
  48. {
  49. if ($id = self::insertGetId($data))
  50. {
  51. return $id;
  52. }
  53. return false;
  54. }
  55. public static function modify($where, array $data)
  56. {
  57. if (self::where($where)->update($data))
  58. {
  59. return true;
  60. }
  61. return false;
  62. }
  63. //删除一条记录
  64. public static function remove($id,$user_id)
  65. {
  66. if (!self::whereIn('id', explode(',', $id))->where('user_id',$user_id)->update(array('is_delete'=>1)))
  67. {
  68. return false;
  69. }
  70. return true;
  71. }
  72. }