ShopScope.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * Author: 芸众商城 www.yunzshop.com
  5. * Date: 2017/3/28
  6. * Time: 下午2:44
  7. */
  8. namespace app\frontend\modules\coupon\services\models\UseScope;
  9. use app\common\exceptions\AppException;
  10. use app\frontend\modules\orderGoods\models\PreOrderGoods;
  11. class ShopScope extends CouponUseScope
  12. {
  13. /**
  14. * @return static
  15. * @throws AppException
  16. */
  17. protected function _getOrderGoodsOfUsedCoupon()
  18. {
  19. $orderGoods = $this->coupon->getPreOrder()->orderGoods->filter(
  20. function ($orderGoods) {
  21. /**
  22. * @var $orderGoods PreOrderGoods
  23. */
  24. return !$orderGoods->goods->is_plugin && !in_array($orderGoods->goods->plugin_id,[31,32,33,36,101]);
  25. });
  26. // if ($orderGoods->count() > 1) {
  27. // trace_log()->coupon("优惠券{$this->coupon->getMemberCoupon()->id}","优惠券范围为自营,商品id{$orderGoods->goods_id}是供应商商品");
  28. // throw new AppException('自营商品与第三方商品不能共用一张优惠券');
  29. // }
  30. return $orderGoods;
  31. }
  32. }