UserPackageLog.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. namespace app\admin\model;
  3. use support\Model;
  4. /**
  5. * 悦享家会员套餐包记录模型
  6. * Class UserPackageLog
  7. * @package app\api\model
  8. */
  9. class UserPackageLog extends Model
  10. {
  11. const NORMAL = '0';
  12. const RETURN = '1';
  13. const STOP = '2';
  14. const PACKAGE_STATUS = [
  15. self::NORMAL => '正常',
  16. self::RETURN => '退款',
  17. self::STOP => '停止'
  18. ];
  19. const UPDATED_AT = 'log_update_time';
  20. /**
  21. * The table associated with the model.
  22. *
  23. * @var string
  24. */
  25. protected $table = 'user_package_log';
  26. protected $dateFormat = 'U';
  27. /**
  28. * Notes:获取指定条件一列
  29. * @param string $status
  30. * @return array
  31. * User: yym
  32. * Date: 2022/8/4
  33. */
  34. public static function getListIds(string $status)
  35. {
  36. return static::select('log_user_id')->where(['log_package_status' => $status])->get()->toArray();
  37. }
  38. /**
  39. * Notes:获取会员单条记录
  40. * @param int $package_id
  41. * @param int $user_id
  42. * @return array
  43. * User: yym
  44. * Date: 2022/11/21
  45. */
  46. public static function getInfo(int $package_id, int $user_id)
  47. {
  48. return static::where(['log_user_id' => $user_id, 'log_package_id' => $package_id, 'log_package_status' => static::NORMAL])
  49. ->get()
  50. ->toArray();
  51. }
  52. /**
  53. * Notes:插入记录
  54. * @param array $data
  55. * @return int
  56. * User: yym
  57. * Date: 2022/8/5
  58. */
  59. public static function insertData(array $data)
  60. {
  61. return static::insertGetId($data);
  62. }
  63. }