Esempio n. 1
0
 public function canBeReviewed(Order $order)
 {
     if (!$order->isComplete()) {
         return false;
     }
     return !$this->reviewFromOrder($order);
 }
Esempio n. 2
0
 public function changeStatus(Order $order, $status)
 {
     $order->setStatusKey($status);
     list($updated, $order) = $this->save($order);
     if (!$order->isCancelled()) {
         event(new OrderStatusUpdated($order));
     }
     return $order;
 }
Esempio n. 3
0
 public function creating(Order $order)
 {
     // set default status of pending
     if (!$order->getStatusKey()) {
         $order->setAsPending();
     }
     if (!$order->reference) {
         $order->reference = $order->generateReference();
     }
 }
 public function decide(Request $request, Order $order)
 {
     $cancellation = $order->getCancellation();
     $this->authorize('decide', $cancellation);
     if (is_null($cancellation)) {
         return $this->error(OrderCancellation::CAN_NOT_FIND);
     }
     $approved = $request->input('approved') ?: false;
     DB::transaction(function () use($cancellation, $order, $approved) {
         $this->orderManager->decideCancellation($cancellation, $approved);
         if ($approved) {
             $this->orderManager->getOrderRepository()->cancel($order);
         }
     });
     return $this->success();
 }
 public function update(OrderUpdateRequest $request, Order $order)
 {
     $productsTotalChanged = $request->input('products_total') != $order->products_total;
     $shippingTotalChanged = $request->input('shipping_total') != $order->shipping_total;
     if (!$productsTotalChanged and !$shippingTotalChanged) {
         Flash::warning(trans('order::revision.no_change'));
         return back();
     }
     DB::transaction(function () use($order, $request, $productsTotalChanged, $shippingTotalChanged) {
         $orderRevision = new OrderRevision(['products_total' => $productsTotalChanged ? $request->input('products_total') : null, 'shipping_total' => $shippingTotalChanged ? $request->input('shipping_total') : null]);
         $orderRevision->setPerformer($this->account());
         $orderRevision->setReactor($order->getBuyer());
         $order->revisions()->save($orderRevision);
         event(new OrderRevisionEvent($orderRevision));
     });
     Flash::success('订单修改已提交,等待买家同意');
     return back();
 }
Esempio n. 6
0
 public function review(User $user, Shop $shop, Order $order)
 {
     return $user->is($order->getUser()) and $shop->is($order->getSeller()) and $shop->canBeReviewed($order);
 }
 protected function asUser(User $user = null)
 {
     return parent::asUser($user ?: ($this->order ? $this->order->getBuyer() : null));
 }
Esempio n. 8
0
 public function isOrderSeller(Order $order)
 {
     // either user is seller or, if user has shop, shop is seller
     return $this->is($order->getSeller()) or $this->hasShop() and $this->getShop()->is($order->getSeller());
 }
Esempio n. 9
0
 public function getOrderRole(Order $order = null, $self = true)
 {
     if (!$order) {
         return $self ? '卖家' : '买家';
     }
     if ($this->is($order->getUser())) {
         return $self ? '买家' : '卖家';
     }
     if ($this->is($order->getSeller())) {
         return $self ? '卖家' : '买家';
     }
     return null;
 }
Esempio n. 10
0
 protected function title($notifiable)
 {
     return '来自' . bracketed($this->order->getUser()->name) . '的订单';
 }
Esempio n. 11
0
 public function review(User $user, Product $product, Order $order)
 {
     return $order->isComplete() and $user->isOrderBuyer($order) and $order->hasProduct($product) and !$order->reviews()->whereMorph('reviewable', $product)->exists();
 }
Esempio n. 12
0
 protected function setSeller(Order $order, Seller $seller)
 {
     $order->setSeller($seller)->save();
     return $order;
 }