CapitalFlow.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2021 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\system;
  12. use crmeb\basic\BaseModel;
  13. use crmeb\traits\ModelTrait;
  14. use think\Model;
  15. class CapitalFlow extends BaseModel
  16. {
  17. use ModelTrait;
  18. /**
  19. * 数据表主键
  20. * @var string
  21. */
  22. protected $pk = 'id';
  23. /**
  24. * 模型名称
  25. * @var string
  26. */
  27. protected $name = 'capital_flow';
  28. /**
  29. * 交易类型搜索器
  30. * @param $query
  31. * @param $value
  32. */
  33. public function searchTradingTypeAttr($query, $value)
  34. {
  35. if (is_array($value)) {
  36. if ($value) $query->whereIn('trading_type', $value);
  37. } else {
  38. if ($value) $query->where('trading_type', $value);
  39. }
  40. }
  41. /**
  42. * 门店搜索器
  43. * @param $query
  44. * @param $value
  45. */
  46. public function searchStoreIdAttr($query, $value)
  47. {
  48. if ($value !== '') $query->where('store_id', $value);
  49. }
  50. /**
  51. * 关键字搜索器
  52. * @param $query
  53. * @param $value
  54. */
  55. public function searchKeywordsAttr($query, $value)
  56. {
  57. if ($value !== '') $query->where('order_id|uid|nickname|phone', 'like', '%' . $value . '%');
  58. }
  59. /**
  60. * 批量id搜索器
  61. * @param $query
  62. * @param $value
  63. */
  64. public function searchIdsAttr($query, $value)
  65. {
  66. if ($value != '') $query->whereIn('id', $value);
  67. }
  68. /**
  69. * UID搜索器
  70. * @param Model $query
  71. * @param $value
  72. */
  73. public function searchUidAttr($query, $value)
  74. {
  75. if (is_array($value)) {
  76. if ($value) $query->whereIn('uid', $value);
  77. } else {
  78. if ($value !== '') $query->where('uid', $value);
  79. }
  80. }
  81. }