Exemplo n.º 1
0
 /**
  * Show the application welcome screen to the user.
  *
  * @return Response
  */
 public function index()
 {
     $orderService = new orderService();
     $totalOrder = $orderService->getTotalOrderCurrentUser();
     $totalOrderFinish = $orderService->getTotalOrderCurrentUser(12);
     return view('cus.index.index', array('total_order' => $totalOrder));
 }
Exemplo n.º 2
0
 /**
  * @param $orderDetail
  * @return string
  */
 static function getStatusOrderDetail($orderDetail)
 {
     $orderService = new orderService();
     $statusStr = '';
     $order = $orderService->getOrderByOrderCode($orderDetail->order_code);
     if ($order->status == KACANA_ORDER_STATUS_CANCEL) {
         $statusStr = '<span class="label label-danger">đơn hàng huỷ</span>';
     } else {
         if ($orderDetail->order_detail_status == KACANA_ORDER_SERVICE_STATUS_ORDERED) {
             $statusStr = '<span class="label label-info">đã mua hàng</span>';
         } elseif ($orderDetail->order_detail_status == KACANA_ORDER_SERVICE_STATUS_SOLD_OUT) {
             $statusStr = '<span class="label label-danger">hết hàng</span>';
         } elseif ($orderDetail->order_detail_status == KACANA_ORDER_SERVICE_STATUS_SHIPPING) {
             if (isset($orderDetail->payment_id)) {
                 $statusStr = '<span class="label label-success">đã chuyển tiền </span><br><span class="text-red" >code ' . $orderDetail->payment_code . '</span>';
             } else {
                 if (!isset($orderDetail->shipping_service_code)) {
                     $orderDetail->shipping_service_code = '';
                 }
                 $statusStr = \Kacana\ViewGenerateHelper::getStatusDescriptionShip($orderDetail->shipping_status, $orderDetail->shipping_service_code) . '<br><span class="text-green" >ship code ' . $orderDetail->shipping_service_code . '</span>';
             }
         } else {
             $statusStr = '<span class="label label-primary">chưa xử lý</span>';
         }
     }
     return $statusStr;
 }
Exemplo n.º 3
0
 public function sendEmailOrder($email, $orderId)
 {
     $orderService = new orderService();
     $subject = "Kacana đã nhận đơn hàng " . $orderId;
     $viewBlade = 'client.emails.send-email-order';
     $bcc = KACANA_EMAIL_DON_HANG;
     $orderData = ['order' => $orderService->getOrderById($orderId)];
     return $this->send($email, $subject, $viewBlade, $orderData, $bcc);
 }
Exemplo n.º 4
0
 public function sendOrder(Request $request)
 {
     $orderService = new orderService();
     $addressService = new addressService();
     $orderId = $request->input('orderId', 0);
     $order = $orderService->getOrderById($orderId);
     try {
         $return['data'] = $orderService->sendOrder($orderId, $this->_user->id);
         $return['ok'] = 1;
     } catch (\Exception $e) {
         if ($request->ajax()) {
             $result['error'] = $e->getMessage();
             return $result;
         } else {
             return view('errors.404', ['error_message' => $e->getMessage()]);
         }
     }
     return redirect('/order/edit/' . $order->order_code);
 }
Exemplo n.º 5
0
 public function cancelOrder(Request $request)
 {
     $orderService = new orderService();
     $addressService = new addressService();
     $orderId = $request->input('orderId', 0);
     try {
         $return['data'] = $orderService->cancelOrder($orderId, $this->_user->id, KACANA_ORDER_STATUS_CANCEL);
         $return['ok'] = 1;
     } catch (\Exception $e) {
         if ($request->ajax()) {
             $result['error'] = $e->getMessage();
             return $result;
         } else {
             return view('errors.404', ['error_message' => $e->getMessage()]);
         }
     }
     return redirect('/order');
 }
Exemplo n.º 6
0
 public function processCartWithAddressId($userEmail, $addressId)
 {
     $addressService = new addressService();
     $userService = new userService();
     $orderService = new orderService();
     $cart = $this->cartInformation();
     if (!$cart) {
         throw new \Exception('bad Cart items');
     }
     $checkAddressUser = false;
     $user = $userService->getUserByEmail($userEmail);
     foreach ($user->userAddress as $userAddres) {
         if ($userAddres->id == $addressId) {
             $checkAddressUser = true;
         }
     }
     if (!$checkAddressUser) {
         throw new \Exception('bad address id');
     }
     // create new order for user
     $order = $orderService->createOrder($user->id, $addressId, $cart->total, $cart->quantity, $cart->originTotal, $cart->discount);
     $items = $cart->items;
     foreach ($items as $item) {
         $orderService->createOrderDetail($order->id, $item);
     }
     // destroy CART
     Cart::destroy();
     //send email for user
     $mailService = new mailService();
     if ($mailService->sendEmailOrder($user->email, $order->id)) {
         return $order;
     } else {
         throw new \Exception('Bị lỗi trong quá trình gửi mail');
     }
     // send zalo message for user
     return $order;
 }
Exemplo n.º 7
0
 public function reportDetailTableOrder(Request $request)
 {
     $params = $request->all();
     $orderService = new orderService();
     try {
         $return = $orderService->reportDetailTableOrder($params);
     } catch (\Exception $e) {
         // @codeCoverageIgnoreStart
         $return['error'] = $e->getMessage();
         $return['errorMsg'] = $e->getMessage();
         // @codeCoverageIgnoreEnd
     }
     return response()->json($return);
 }
Exemplo n.º 8
0
 /**
  * @param $shipping
  * @param $orderDetailIds
  * @param $order
  * @param $subtotal
  * @param $shipFee
  * @param $extraDiscount
  * @param $extraDiscountDesc
  * @return bool
  */
 public function createShippingRow($shipping, $orderDetailIds, $order, $subtotal, $shipFee, $extraDiscount, $extraDiscountDesc, $paid)
 {
     $orderService = new orderService();
     $address = $order->addressReceive->name . ' - ' . $order->address;
     $this->_shippingModel->createShippingRow($shipping, $address, $subtotal, $order->addressReceive->id, $shipFee, $extraDiscount, $extraDiscountDesc, $paid);
     $orderDetails = $orderService->getOrderDetailByIds($orderDetailIds);
     foreach ($orderDetails as $orderDetail) {
         $orderService->updateOrderDetail($orderDetail->id, ['shipping_service_code' => $shipping->OrderCode, 'order_service_status' => KACANA_ORDER_SERVICE_STATUS_SHIPPING, 'order_id' => $orderDetail->order_id]);
     }
     return true;
 }
Exemplo n.º 9
0
 public function generateAllOrderDetailByUserTable($domain, Request $request, $userId)
 {
     $params = $request->all();
     $orderService = new orderService();
     try {
         $return = $orderService->generateAllOrderDetailByUserTable($params, $userId);
     } catch (\Exception $e) {
         // @codeCoverageIgnoreStart
         $return['error'] = $e->getMessage();
         $return['errorMsg'] = $e->getMessage();
         // @codeCoverageIgnoreEnd
     }
     return response()->json($return);
 }
Exemplo n.º 10
0
 public function trackingMyOrder($domain, $orderCode, Request $request)
 {
     $orderService = new orderService();
     try {
         $email = $this->_user->email;
         $result = $orderService->checkTrackingOrderCode($email, $orderCode);
         if (!$result['ok']) {
             return view('client.customer.tracking-order', $result);
         } else {
             return view('client.customer.detail-tracking-order', $result);
         }
         return view('client.customer.tracking-order');
     } catch (\Exception $e) {
         // @codeCoverageIgnoreStart
         $return['error'] = $e->getMessage();
         // @codeCoverageIgnoreEnd
     }
 }