示例#1
0
 public function edit($domain, Request $request, $code)
 {
     $orderService = new orderService();
     $addressService = new addressService();
     $shipService = new shipService();
     try {
         $order = $orderService->getOrderByOrderCode($code);
         $id = $order->id;
         if ($order->user_id != $this->_user->id) {
             return redirect('/order');
         }
         if ($request->isMethod('PUT')) {
             if ($order->user_id == $this->_user->id && $order->status == KACANA_ORDER_PARTNER_STATUS_NEW) {
                 $addressService->updateAddressReceive($request->all());
             }
         }
         $buyer = $order->user;
         $user_address = $order->addressReceive;
         $hubInfos = $shipService->getPickHubs();
         $mainHub = $shipService->getPickHubMain($hubInfos);
         $serviceList = $shipService->getServiceList($user_address->district->code, $mainHub->DistrictCode);
         $shippingServiceInfos = $shipService->calculateServiceFee($user_address->district->code, $mainHub->DistrictCode, $serviceList);
         $cities = $addressService->getListCity()->lists('name', 'id');
         $wards = $addressService->getListWardByDistrictId($user_address->district_id);
         $districts = $addressService->getListDistrict();
         return view('partner.order.edit', compact('order', 'buyer', 'user_address', 'cities', 'districts', 'wards', 'shippingServiceInfos', 'hubInfos'));
     } catch (\Exception $e) {
         if ($request->ajax()) {
             $result['error'] = $e->getMessage();
             return $result;
         } else {
             return view('errors.404', ['error_message' => $e]);
         }
     }
 }
示例#2
0
 public function checkFeeShipping(Request $request)
 {
     $orderService = new orderService();
     $addressService = new addressService();
     $shipService = new shipService();
     $weight = $request->input('weight', KACANA_SHIP_DEFAULT_WEIGHT);
     $length = $request->input('length', KACANA_SHIP_DEFAULT_LENGTH);
     $width = $request->input('width', KACANA_SHIP_DEFAULT_WIDTH);
     $height = $request->input('height', KACANA_SHIP_DEFAULT_HEIGHT);
     $orderId = $request->input('orderId', 0);
     $pickDistrictCode = $request->input('pickDistrictCode', 0);
     $return['ok'] = 0;
     try {
         $order = $orderService->getOrderById($orderId);
         $user_address = $order->addressReceive;
         $serviceList = $shipService->getServiceList($user_address->district->code, $pickDistrictCode);
         $return['data'] = $shipService->calculateServiceFee($user_address->district->code, $pickDistrictCode, $serviceList, $weight, $length, $width, $height);
         $return['ok'] = 1;
     } catch (\Exception $e) {
         // @codeCoverageIgnoreStart
         $return['error'] = $e->getMessage();
         $return['errorMsg'] = $e->getMessage();
         // @codeCoverageIgnoreEnd
     }
     return response()->json($return);
 }