StorePink.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\model\activity\combination;
  12. use app\model\user\User;
  13. use crmeb\basic\BaseModel;
  14. use crmeb\traits\ModelTrait;
  15. use think\Model;
  16. /**
  17. * TODO 拼团Model
  18. * Class StorePink
  19. * @package app\model\activity
  20. */
  21. class StorePink extends BaseModel
  22. {
  23. /**
  24. * 数据表主键
  25. * @var string
  26. */
  27. protected $pk = 'id';
  28. /**
  29. * 模型名称
  30. * @var string
  31. */
  32. protected $name = 'store_pink';
  33. use ModelTrait;
  34. /**
  35. * 用户一对一关联
  36. * @return \think\model\relation\HasOne
  37. */
  38. public function getUser()
  39. {
  40. return $this->hasOne(User::class, 'uid', 'uid')->bind(['nickname', 'avatar']);
  41. }
  42. public function getProduct()
  43. {
  44. return $this->hasOne(StoreCombination::class, 'id', 'cid')->bind(['title']);
  45. }
  46. /**
  47. * 订单号搜索器
  48. * @param Model $query
  49. * @param $value
  50. * @param $data
  51. */
  52. public function searchOrderIdAttr($query, $value, $data)
  53. {
  54. $query->where('order_id', $value);
  55. }
  56. /**
  57. * 订单编号搜索器
  58. * @param Model $query
  59. * @param $value
  60. * @param $data
  61. */
  62. public function searchOrderIdKeyAttr($query, $value, $data)
  63. {
  64. $query->where('order_id_key', $value);
  65. }
  66. /**
  67. * 拼团商品ID搜索器
  68. * @param Model $query
  69. * @param $value
  70. * @param $data
  71. */
  72. public function searchCidAttr($query, $value, $data)
  73. {
  74. $query->where('cid', $value);
  75. }
  76. /**
  77. * 商品ID搜索器
  78. * @param Model $query
  79. * @param $value
  80. * @param $data
  81. */
  82. public function searchPidAttr($query, $value, $data)
  83. {
  84. $query->where('pid', $value);
  85. }
  86. /**
  87. * 是否团长搜索器
  88. * @param Model $query
  89. * @param $value
  90. * @param $data
  91. */
  92. public function searchKIdAttr($query, $value, $data)
  93. {
  94. $query->where('k_id', $value);
  95. }
  96. /**
  97. * 是否退款搜索器
  98. * @param Model $query
  99. * @param $value
  100. * @param $data
  101. */
  102. public function searchIsRefundAttr($query, $value, $data)
  103. {
  104. $query->where('is_refund', $value ?? 0);
  105. }
  106. /**
  107. * 状态搜索器
  108. * @param Model $query
  109. * @param $value
  110. * @param $data
  111. */
  112. public function searchStatusAttr($query, $value, $data)
  113. {
  114. if ($value != '') $query->where('status', $value);
  115. }
  116. }