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.

86 lines
1.8 KiB

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