StoreDeliveryOrder.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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. namespace app\model\order;
  12. use app\model\store\SystemStore;
  13. use app\model\user\User;
  14. use crmeb\basic\BaseModel;
  15. use crmeb\traits\ModelTrait;
  16. use think\Model;
  17. class StoreDeliveryOrder extends BaseModel
  18. {
  19. use ModelTrait;
  20. /**
  21. * 数据表主键
  22. * @var string
  23. */
  24. protected $pk = 'id';
  25. /**
  26. * 模型名称
  27. * @var string
  28. */
  29. protected $name = 'store_delivery_order';
  30. protected $updateTime = false;
  31. /**
  32. * @return \think\model\relation\HasOne
  33. */
  34. public function user()
  35. {
  36. return $this->hasOne(User::class, 'uid', 'uid');
  37. }
  38. /**
  39. * @return \think\model\relation\HasOne
  40. */
  41. public function orderInfo()
  42. {
  43. return $this->hasOne(StoreOrder::class, 'id', 'oid');
  44. }
  45. /**
  46. * @return \think\model\relation\HasOne
  47. */
  48. public function storeInfo()
  49. {
  50. return $this->hasOne(SystemStore::class, 'id', 'relation_id')->where(['is_show' => 1, 'is_del' => 0]);
  51. }
  52. /**
  53. * @param $query
  54. * @param $value
  55. * @return void
  56. */
  57. public function searchKeywordAttr($query, $value)
  58. {
  59. $query->where('');
  60. }
  61. /**
  62. * 商户搜索器
  63. * @param Model $query
  64. * @param $value
  65. */
  66. public function searchTypeAttr($query, $value)
  67. {
  68. if (is_array($value)) {
  69. if ($value) $query->whereIn('type', $value);
  70. } else {
  71. if ($value !== '') $query->where('type', $value);
  72. }
  73. }
  74. /**
  75. * 关联门店ID、供应商ID搜索器
  76. * @param Model $query
  77. * @param $value
  78. */
  79. public function searchRelationIdAttr($query, $value)
  80. {
  81. if (is_array($value)) {
  82. if ($value) $query->whereIn('relation_id', $value);
  83. } else {
  84. if ($value !== '') $query->where('relation_id', $value);
  85. }
  86. }
  87. /**
  88. * 订单ID搜索器
  89. * @param Model $query
  90. * @param $value
  91. */
  92. public function searchOidAttr($query, $value)
  93. {
  94. if (is_array($value)) {
  95. if ($value) $query->whereIn('oid', $value);
  96. } else {
  97. if ($value !== '') $query->where('oid', $value);
  98. }
  99. }
  100. /**
  101. * UID搜索器
  102. * @param Model $query
  103. * @param $value
  104. */
  105. public function searchUidAttr($query, $value)
  106. {
  107. if (is_array($value)) {
  108. if ($value) $query->whereIn('uid', $value);
  109. } else {
  110. if ($value !== '') $query->where('uid', $value);
  111. }
  112. }
  113. /**
  114. * 平台类型搜索器
  115. * @param $query
  116. * @param $value
  117. * @return void
  118. */
  119. public function searchStationTypeAttr($query, $value)
  120. {
  121. if ($value !== '') $query->where('station_type', $value);
  122. }
  123. /**
  124. * status搜索器
  125. * @param Model $query
  126. * @param $value
  127. */
  128. public function searchStatusAttr($query, $value)
  129. {
  130. if (is_array($value)) {
  131. if ($value) $query->whereIn('status', $value);
  132. } else {
  133. if ($value !== '') $query->where('status', $value);
  134. }
  135. }
  136. }