AgentLevelTaskRecord.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. declare (strict_types=1);
  12. namespace app\model\agent;
  13. use crmeb\basic\BaseModel;
  14. use crmeb\traits\ModelTrait;
  15. use think\Model;
  16. /**
  17. * 分销员完成等级任务记录
  18. * Class AgentLevelTaskRecord
  19. * @package app\model\agent
  20. */
  21. class AgentLevelTaskRecord extends BaseModel
  22. {
  23. use ModelTrait;
  24. /**
  25. * 数据表主键
  26. * @var string
  27. */
  28. protected $pk = 'id';
  29. /**
  30. * 模型名称
  31. * @var string
  32. */
  33. protected $name = 'agent_level_task_record';
  34. /**
  35. * 关联分销员等级
  36. * @return \think\model\relation\HasOne
  37. */
  38. public function level()
  39. {
  40. return $this->hasOne(AgentLevel::class, 'id', 'level_id');
  41. }
  42. /**
  43. * 关联分销员等级任务
  44. * @return \think\model\relation\HasOne
  45. */
  46. public function task()
  47. {
  48. return $this->hasOne(AgentLevelTask::class, 'id', 'task_id');
  49. }
  50. /**
  51. * 分销员等级搜索器
  52. * @param $query Model
  53. * @param $value
  54. */
  55. public function searchLevelIdAttr($query, $value)
  56. {
  57. if ($value !== '') $query->where('level_id', $value);
  58. }
  59. /**
  60. * 等级任务搜索器
  61. * @param $query Model
  62. * @param $value
  63. */
  64. public function searchTaskIdAttr($query, $value)
  65. {
  66. if (is_array($value)) {
  67. $query->whereIn('task_id', $value);
  68. } else {
  69. if ($value !== '') $query->where('task_id', $value);
  70. }
  71. }
  72. /**
  73. * 用户搜索器
  74. * @param $query Model
  75. * @param $value
  76. */
  77. public function searchUidAttr($query, $value)
  78. {
  79. if ($value !== '') $query->where('uid', $value);
  80. }
  81. /**
  82. * 状态搜索器
  83. * @param $query Model
  84. * @param $value
  85. */
  86. public function searchStatusAttr($query, $value)
  87. {
  88. if ($value !== '') $query->where('status', $value);
  89. }
  90. }