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.8 KiB

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 COMPLETE_PAY = 1;
  16. //获取列表
  17. public static function getList(array $param)
  18. {
  19. extract($param); //参数:limit,offset
  20. $where['user_id'] = $user_id;
  21. $limit = isset($limit) ? $limit : 10;
  22. $offset = isset($offset) ? $offset : 0;
  23. $model = new UserRecharge;
  24. if(isset($status) && $status!=-1){$where['status'] = $status;} //-1表示获取所有
  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();
  31. }
  32. else
  33. {
  34. return false;
  35. }
  36. return $res;
  37. }
  38. public static function getOne($where)
  39. {
  40. return self::where($where)->first();
  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) === false)
  53. {
  54. return false;
  55. }
  56. return true;
  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. }