GiftLog.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. namespace app\admin\model\shopro\activity;
  3. use app\admin\model\shopro\Common;
  4. class GiftLog extends Common
  5. {
  6. protected $name = 'shopro_activity_gift_log';
  7. protected $type = [
  8. 'rules' => 'json',
  9. 'errors' => 'json'
  10. ];
  11. // 追加属性
  12. protected $append = [
  13. 'type_text',
  14. 'status_text'
  15. ];
  16. /**
  17. * 默认状态列表
  18. *
  19. * @return array
  20. */
  21. public function typeList()
  22. {
  23. return [
  24. 'coupon' => '优惠券',
  25. 'score' => '积分',
  26. 'money' => '余额',
  27. 'goods' => '商品',
  28. ];
  29. }
  30. /**
  31. * 默认状态列表
  32. *
  33. * @return array
  34. */
  35. public function statusList()
  36. {
  37. return [
  38. 'waiting' => '等待赠送',
  39. 'finish' => '赠送完成',
  40. 'fail' => '赠送失败',
  41. ];
  42. }
  43. public function scopeWaiting($query)
  44. {
  45. return $query->where('status', 'waiting');
  46. }
  47. public function scopeOpered($query)
  48. {
  49. return $query->whereIn('status', ['finish', 'fail']);
  50. }
  51. public function scopeFinish($query)
  52. {
  53. return $query->where('status', 'finish');
  54. }
  55. public function scopeFail($query)
  56. {
  57. return $query->where('status', 'fail');
  58. }
  59. }