GroupBuyActivity.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace app\common\model\groupbuy;
  3. use app\common\model\BaseModel;
  4. use app\common\model\groupbuy\GroupBuyGoods as GroupBuyGoodsModel;
  5. /**
  6. * 满件送赠品活动模型
  7. * @package app\store\model\coupon
  8. */
  9. class GroupBuyActivity extends BaseModel
  10. {
  11. //审核状态
  12. const AUDIT_STATUS = [0=>'待审核',1=>'审核通过',2=>'审核不通过'];
  13. //活动状态
  14. const STATUS = [0=>'禁用',1=>'启用'];
  15. protected $name = 'group_buy_activity';
  16. protected $append = ['goods_info','fmt_end_time'];
  17. public function getFmtEndTimeAttr($value){
  18. $t = strtotime($this->end_time) -time();
  19. if($t>0){
  20. return $t;
  21. }
  22. return 0;
  23. }
  24. /**
  25. * 优惠券详情
  26. * @param int $couponId
  27. * @return null|static
  28. */
  29. public static function detail(int $couponId,$with =[])
  30. {
  31. return self::get($couponId,$with);
  32. }
  33. //行为操作关联
  34. public function goodsExcept(){
  35. return $this->hasOne(GroupBuyGoodsModel::class,'group_buy_activity_id','id');
  36. }
  37. }