You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

StoreOrderPromotions.php 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. namespace app\model\order;
  3. use crmeb\basic\BaseModel;
  4. use crmeb\traits\ModelTrait;
  5. use app\model\activity\promotions\StorePromotions;
  6. use think\Model;
  7. /**
  8. * 订单优惠活动记录Model
  9. * Class SoreOrderPromotions
  10. * @package app\model\order
  11. */
  12. class StoreOrderPromotions extends BaseModel
  13. {
  14. use ModelTrait;
  15. /**
  16. * 数据表主键
  17. * @var string
  18. */
  19. protected $pk = 'id';
  20. /**
  21. * 模型名称
  22. * @var string
  23. */
  24. protected $name = 'store_order_promotions';
  25. /**
  26. * 一对一关联优惠活动
  27. * @return \think\model\relation\hasMany
  28. */
  29. public function promotions()
  30. {
  31. return $this->hasOne(StorePromotions::class, 'id', 'promotions_id');
  32. }
  33. /**
  34. * 订单ID搜索器
  35. * @param Model $query
  36. * @param $value
  37. * @param $data
  38. */
  39. public function searchOidAttr($query, $value, $data)
  40. {
  41. if ($value) {
  42. if (is_array($value)) {
  43. $query->whereIn('oid', $value);
  44. } else {
  45. $query->where('oid', $value);
  46. }
  47. }
  48. }
  49. /**
  50. * UID搜索器
  51. * @param Model $query
  52. * @param $value
  53. */
  54. public function searchUidIdAttr($query, $value)
  55. {
  56. if ($value) {
  57. if (is_array($value)) {
  58. $query->whereIn('uid', $value);
  59. } else {
  60. $query->where('uid', $value);
  61. }
  62. }
  63. }
  64. /**
  65. * 优惠活动ID搜索器
  66. * @param Model $query
  67. * @param $value
  68. */
  69. public function searchPromotionsIdAttr($query, $value)
  70. {
  71. if ($value) {
  72. if (is_array($value)) {
  73. $query->whereIn('promotions_id', $value);
  74. } else {
  75. $query->where('promotions_id', $value);
  76. }
  77. }
  78. }
  79. }