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.

82 lines
1.7 KiB

7 years ago
7 years ago
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 self();
  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. return $res;
  34. }
  35. public static function getOne($where)
  36. {
  37. return self::where($where)->first();
  38. }
  39. public static function add(array $data)
  40. {
  41. if ($id = self::insertGetId($data))
  42. {
  43. return $id;
  44. }
  45. return false;
  46. }
  47. public static function modify($where, array $data)
  48. {
  49. if (self::where($where)->update($data) === false)
  50. {
  51. return false;
  52. }
  53. return true;
  54. }
  55. //删除一条记录
  56. public static function remove($id)
  57. {
  58. if (!self::whereIn('id', explode(',', $id))->delete())
  59. {
  60. return false;
  61. }
  62. return true;
  63. }
  64. }