giveCoupon() && $this->giveCoupon()->isNotEmpty(); } public function _getAmount() { return 0; } public function afterPayGive() { return 0; } public function getTitle() { return '优惠券'; } public function getDesc() { return '优惠券'; } public function giveCoupon() { if (isset($this->giveCoupon)) { return $this->giveCoupon; } $order_goods_ids = $this->getOrder()->orderGoods->pluck('id')->all(); $records = OrderGoodsCoupon::uniacid() ->where('status','>=',OrderGoodsCoupon::WAIT_STATUS) ->whereIn('order_goods_id', $order_goods_ids) ->with(['hasOneCoupon']) ->get(); $records->filter(function ($record) { return $record->hasOneCoupon; })->values(); return $this->giveCoupon = $records; } public function arrayData() { $array = []; foreach ($this->giveCoupon() as $record) { $array[] = [ 'is_give' => $record->status == 1 ? 1 : 0, //不等于1为未赠送 'id' =>$record->hasOneCoupon->id, 'title' => $record->hasOneCoupon->name, 'coupon_method' => $record->hasOneCoupon->coupon_method, 'value' => $record->hasOneCoupon->coupon_method == 1 ? $record->hasOneCoupon->deduct : $record->hasOneCoupon->discount, 'enough' => $record->hasOneCoupon->enough, ]; } return $array; } public function getIcon() { return ''; } public function getUrl() { return ''; } public function getMiniUrl() { return ''; } }