StoreOrderPromotions.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 crmeb\basic\BaseModel;
  13. use crmeb\traits\ModelTrait;
  14. use app\model\activity\promotions\StorePromotions;
  15. use think\Model;
  16. /**
  17. * 订单优惠活动记录Model
  18. * Class SoreOrderPromotions
  19. * @package app\model\order
  20. */
  21. class StoreOrderPromotions 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 = 'store_order_promotions';
  34. /**
  35. * 一对一关联优惠活动
  36. * @return \think\model\relation\hasMany
  37. */
  38. public function promotions()
  39. {
  40. return $this->hasOne(StorePromotions::class, 'id', 'promotions_id');
  41. }
  42. /**
  43. * 订单ID搜索器
  44. * @param Model $query
  45. * @param $value
  46. * @param $data
  47. */
  48. public function searchOidAttr($query, $value, $data)
  49. {
  50. if ($value) {
  51. if (is_array($value)) {
  52. $query->whereIn('oid', $value);
  53. } else {
  54. $query->where('oid', $value);
  55. }
  56. }
  57. }
  58. /**
  59. * UID搜索器
  60. * @param Model $query
  61. * @param $value
  62. */
  63. public function searchUidIdAttr($query, $value)
  64. {
  65. if ($value) {
  66. if (is_array($value)) {
  67. $query->whereIn('uid', $value);
  68. } else {
  69. $query->where('uid', $value);
  70. }
  71. }
  72. }
  73. /**
  74. * 优惠活动ID搜索器
  75. * @param Model $query
  76. * @param $value
  77. */
  78. public function searchPromotionsIdAttr($query, $value)
  79. {
  80. if ($value) {
  81. if (is_array($value)) {
  82. $query->whereIn('promotions_id', $value);
  83. } else {
  84. $query->where('promotions_id', $value);
  85. }
  86. }
  87. }
  88. }