StoreDiscountsProducts.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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\activity\discounts;
  12. use app\model\product\product\StoreProduct;
  13. use crmeb\basic\BaseModel;
  14. use crmeb\traits\ModelTrait;
  15. use think\Model;
  16. /**
  17. * 优惠套餐商品
  18. * Class StoreDiscountsProducts
  19. * @package app\model\activity\discounts
  20. */
  21. class StoreDiscountsProducts extends BaseModel
  22. {
  23. /**
  24. * 数据表主键
  25. * @var string
  26. */
  27. protected $pk = 'id';
  28. /**
  29. * 模型名称
  30. * @var string
  31. */
  32. protected $name = 'store_discounts_products';
  33. use ModelTrait;
  34. /**
  35. * 一对一关联商品表
  36. * @return \think\model\relation\HasOne
  37. */
  38. public function product()
  39. {
  40. return $this->hasOne(StoreProduct::class, 'id', 'product_id')->field(['id', 'pid', 'type', 'cate_id', 'relation_id', 'freight', 'postage', 'temp_id', 'delivery_type'])->bind([
  41. 'pid',
  42. 'cate_id',
  43. 'plat_type' => 'type',
  44. 'relation_id' => 'relation_id',
  45. 'freight' => 'freight',
  46. 'postage' => 'postage',
  47. 'p_temp_id' => 'temp_id',
  48. 'delivery_type'
  49. ]);
  50. }
  51. /**
  52. * 状态搜索器
  53. * @param Model $query
  54. * @param $value
  55. * @param $data
  56. */
  57. public function searchDiscountIdAttr($query, $value)
  58. {
  59. if ($value != '') $query->where('discount_id', $value);
  60. }
  61. }