Inheritance: extends yupe\models\YModel
コード例 #1
0
ファイル: PdfController.php プロジェクト: buildshop/bs-common
 public function actionNormal()
 {
     $params = array();
     $model = new OrderProduct('search_pdf');
     if (!empty($_GET['OrderProduct'])) {
         $model->attributes = $_GET['OrderProduct'];
     }
     if (isset($_GET['orderid'])) {
         $params['orderid'] = $_GET['orderid'];
     }
     $dataProvider = $model->search_pdf($params);
     $this->render('index', array('dataProvider' => $dataProvider, 'model' => $model));
 }
コード例 #2
0
ファイル: OrderProduct.php プロジェクト: conghua1013/yii
 /**
  * 获取订单的商品列表.
  * @param $orderId
  */
 public function getOrderProductByOrderId($orderId)
 {
     if (empty($orderId)) {
         return '';
     }
     $list = OrderProduct::model()->findAllByAttributes(array('order_id' => $orderId));
     if (empty($list)) {
         return '';
     }
     // todo 图片待处理
     $newList = array();
     foreach ($list as $row) {
         $temp = $row->getAttributes();
         if ($row->type == 1) {
             $temp['images']['cover'] = '/images/public/tab.png';
         } elseif ($row->type == 2) {
             $zineInfo = Zine::model()->findByPk($row['product_id']);
             if ($zineInfo) {
                 $temp['images']['cover'] = '/images/zine/' . $zineInfo['mcover'];
             } else {
                 $temp['images']['cover'] = '';
             }
         } else {
             $temp['images'] = Product::model()->getProductFaceImageByProductId($row->product_id);
         }
         $temp['total_price'] = $temp['sell_price'] * $temp['quantity'];
         $newList[$row->id] = $temp;
     }
     return $newList;
 }
コード例 #3
0
ファイル: CReservation.php プロジェクト: itliuchang/test
 public function createReservation($data)
 {
     $result = new Reservations();
     $result->createTime = date('Y-m-d H:i:s', time());
     foreach ($data as $k => $v) {
         $result->{$k} = $v;
     }
     $type = User::model()->findByAttributes(array('id' => $data['userId']));
     if ($data['type'] == 1 && $type == 1) {
         $orderid = Order::model()->findAllByAttributes(array('status' => 1, 'userId' => Yii::app()->user->id, 'type' => 1));
         if ($orderid) {
             $now = date('Ymd', strtotime(substr($data['startTime'], 0, 10)));
             foreach ($orderid as $list) {
                 $dp = OrderProduct::model()->find('endDate>=' . $now . ' and orderId=' . $list['id'] . ' and startDate<=' . $now);
                 if ($dp) {
                     break;
                 }
             }
             $dp->usedTimes++;
             $dp->save();
             $result->orderId = $dp['orderId'];
             $result->save();
         }
     }
     if ($result->save()) {
         $data = array('code' => 200, 'message' => 'SUCCESS');
     }
     return $data;
 }
コード例 #4
0
ファイル: Order.php プロジェクト: mrDumay/demoshop
 /**
  * @return OrderProduct[]
  */
 public function getOrderedProducts()
 {
     if ($this->products === null) {
         $this->products = OrderProduct::getAll(array('order_id' => $this->id));
     }
     return $this->products;
 }
コード例 #5
0
 public function run()
 {
     $this->controller->pageTitle = 'Book a Workspace';
     $now = date('Y-m-d', time());
     $date = Yii::app()->request->getParam('date');
     $date = $date == '' ? $now : $date;
     $proxy = new CHub();
     $result = $proxy->getHubList();
     if (Yii::app()->request->isAjaxRequest) {
         $id = Yii::app()->request->getParam('id');
         $hub = Yii::app()->request->getParam('hub');
         $date = Yii::app()->request->getParam('date');
         if ($id) {
             $date = date('Ymd', strtotime($date));
             $record = Reservations::model()->findAll('startTime =' . date('Ymd', strtotime($date)) . '100000' . ' and userId=' . Yii::app()->user->id . ' and type=1 and status=1');
             $orderid = Order::model()->findAllByAttributes(array('status' => 1, 'userId' => Yii::app()->user->id, 'type' => 1));
             if ($orderid) {
                 foreach ($orderid as $list) {
                     $order = OrderProduct::model()->find('endDate>=' . $date . ' and orderId=' . $list['id'] . ' and startDate<=' . $date);
                     if ($order) {
                         break;
                     }
                 }
                 if ($order) {
                     echo CJSON::encode(array('code' => 200, 'data' => array('num' => $order['totalTimes'] - $order['usedTimes'], 'count' => count($record))));
                 } else {
                     echo CJSON::encode(array('code' => 200, 'data' => array('num' => 0)));
                 }
             } else {
                 $code = CodeUsed::model()->findAll('userId=' . Yii::app()->user->id);
                 if ($code) {
                     foreach ($code as $list) {
                         $value = Code::model()->find('endDate>=' . $date . ' and id=' . $list['codeId'] . ' and startDate<=' . $date);
                         if ($value) {
                             break;
                         }
                     }
                     if ($value) {
                         echo CJSON::encode(array('code' => 200, 'data' => array('num' => 1, 'count' => count($record))));
                     } else {
                         echo CJSON::encode(array('code' => 200, 'data' => array('num' => 0)));
                     }
                 } else {
                     echo CJSON::encode(array('code' => 200, 'data' => array('num' => 0)));
                 }
             }
         } else {
             $proxy = new CReservation();
             $result = $proxy->getNumber($date);
             if ($result['code'] == 200) {
                 $data = array('code' => 200, 'data' => $result);
                 echo CJSON::encode($data);
             }
         }
     } else {
         $this->controller->render('workspacelist', array('data' => $result['data'], 'date' => $date));
     }
 }
コード例 #6
0
ファイル: CartModule.php プロジェクト: buildshop/bs-common
 public function afterUninstall()
 {
     Yii::app()->settings->clear($this->id);
     //Yii::app()->unintallComponent('cart');
     $db = Yii::app()->db;
     $tablesArray = array(Order::model()->tableName(), OrderHistory::model()->tableName(), OrderProduct::model()->tableName(), OrderStatus::model()->tableName(), OrderProductHistroy::model()->tableName(), ShopPaymentMethod::model()->tableName(), ShopPaymentMethodTranslate::model()->tableName(), ShopDeliveryMethod::model()->tableName(), ShopDeliveryMethodTranslate::model()->tableName(), ShopDeliveryPayment::model()->tableName(), ProductNotifications::model()->tableName());
     foreach ($tablesArray as $table) {
         $db->createCommand()->dropTable($table);
     }
     return parent::afterInstall();
 }
コード例 #7
0
 public static function getProductsByOrderID($orderID)
 {
     if (!$orderID) {
         return array();
     }
     self::$_msql = SafeMySQL::getInstance();
     $sql = "\n\t\t\tSELECT\n\t\t\t\top.`order_product_id`,\n\t\t\t\top.`order_id`,\n\t\t\t\top.`product_id`,\n\t\t\t\top.`flags`,\n\t\t\t\top.`recurring_next`,\n\t\t\t\top.`discount_next`,\n\t\t\t\top.`shipping_id`,\n\t\t\t\top.`next_gateway_id`,\n\t\t\t\tp.`product_price`,\n\t\t\t\tp.`product_sku`,\n\t\t\t\tp.`product_name`\n\t\t\tFROM `orders_products` as op\n\t\t\tJOIN `products` as p on p.`product_id` = op.`product_id`\t\t\n\t\t\tWHERE `order_id`=?i";
     $result = self::$_msql->getAll($sql, $orderID);
     if (!$result) {
         return array();
     }
     $orderProductsArr = array();
     foreach ($result as $item) {
         $t = new OrderProduct();
         //$t->allFIelds = true;
         $t->fillFromEnterArray($item);
         $t->IsNewRecord = false;
         $orderProductsArr[] = $t;
         unset($t);
     }
     return $orderProductsArr;
 }
コード例 #8
0
ファイル: OrderController.php プロジェクト: conghua1013/yii
 /**
  * 订单详情页面
  */
 public function actionInfo()
 {
     $oInfo = Order::model()->getOrderInfo($_REQUEST['id']);
     $opList = OrderProduct::model()->findAllByAttributes(array('order_id' => $_REQUEST['id']));
     $oLog = OrderLog::model()->findAllByAttributes(array('order_id' => $_REQUEST['id']));
     $oShipping = OrderShipping::model()->findAllByAttributes(array('order_id' => $_REQUEST['id']));
     $shippingList = Shipping::model()->getShippingList();
     $viewData = array();
     $viewData['oInfo'] = $oInfo;
     $viewData['opList'] = $opList;
     $viewData['oLog'] = $oLog;
     $viewData['oShipping'] = $oShipping;
     $viewData['shippingList'] = $shippingList;
     $this->render('info', $viewData);
 }
コード例 #9
0
ファイル: OrderController.php プロジェクト: nellka/mebel
 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     $model = $this->loadModel($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     $dataProvider = new CActiveDataProvider('Order');
     $products = OrderProduct::model()->orderProducts($id);
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Order'])) {
         $model->order_status_id = $_POST['Order']['order_status_id'];
         $model->save();
         Yii::app()->user->setFlash('error', "Статус заказа изменен!");
     }
     $this->render('update', compact('model', 'products'));
 }
コード例 #10
0
 public static function getReturnUrlByOrder($model)
 {
     if (!$model instanceof Order) {
         $model = Order::model()->with('campaign', 'click')->findByPk($model);
     }
     if (!$model->order_id) {
         return null;
     }
     $sql = 'SELECT *
             FROM `orders_products`
             WHERE `order_id`=:order_id
             ORDER BY `created`
             LIMIT 1';
     $productModel = OrderProduct::model()->findBySql($sql, array(':order_id' => $model->order_id));
     $array = array('order_id' => $model->order_id, 'amount' => number_format($model->amount_product + $model->amount_shipping, 2, '.', ''), 'e_mail' => $model->customer->email, 'Bill_First' => $model->billingAddress->fname, 'Bill_Last' => $model->billingAddress->lname, 'Bill_Address1' => $model->billingAddress->address1, 'Bill_Address2' => $model->billingAddress->address2, 'Bill_City' => $model->billingAddress->city, 'Bill_State' => $model->billingAddress->state_id, 'Bill_Zip' => $model->billingAddress->zip, 'Bill_Country' => $model->billingAddress->country->country_name, 'Bill_Phone' => $model->billingAddress->phone, 'Bill_Email' => $model->customer->email, 'Ship_First' => $model->address->fname, 'Ship_Last' => $model->address->lname, 'Ship_Address1' => $model->address->address1, 'Ship_Address2' => $model->address->address2, 'Ship_City' => $model->address->city, 'Ship_State' => $model->address->state_id, 'Ship_Zip' => $model->address->zip, 'Ship_Country' => $model->address->country->country_name, 'Ship_Phone' => $model->address->phone, 'ShippingId' => $model->shipping_id, 'ShippingPrice' => number_format($model->amount_shipping, 2, '.', ''), 'SubTotal' => number_format($model->amount_product, 2, '.', ''), 'ipAddress' => long2ip($model->ip), 'product1Id' => $productModel->product_id, 'AFID' => $model->aff_id, 'SID' => $model->click->SID, 'c1' => $model->click->c1, 'c2' => $model->click->c2, 'c3' => $model->click->c3);
     return 'https://' . $model->campaign->return_url . '?' . http_build_query($array);
 }
コード例 #11
0
ファイル: Checkout.php プロジェクト: SerdarSanri/VaneMart
 function ajax_post_index()
 {
     $input = $this->in();
     $rules = array('email' => 'required|email', 'name' => 'required', 'surname' => 'required', 'address' => 'min:5', 'phone' => 'required|min:7|vanemart_phone');
     $rules += (array) \Vane\Current::config('general.user_fields.order');
     $valid = Validator::make($input, $rules);
     if ($this->can('checkout.deny')) {
         return false;
     } elseif (!Cart::has() or Cart::isTooSmall()) {
         return E_INPUT;
     } elseif ($valid->fails()) {
         return $valid;
     } else {
         \DB::transaction(function () use(&$input, &$user, &$order) {
             $user = User::findOrCreate($input);
             $order = Order::createBy(head(arrize($user)), $input);
             $goods = S(Cart::all(), function ($qty, $product) use($order) {
                 return compact('qty', 'product') + array('order' => $order->id);
             });
             OrderProduct::insert($goods);
         });
         $newUser = is_array($user);
         if ($newUser) {
             list($user, $password) = $user;
         }
         $options = compact('user', 'order') + array('block' => $this);
         if ($newUser) {
             $options += compact('password');
             $event = 'checkout.reg_user';
         } else {
             $event = 'checkout.old_user';
         }
         Event::fire($event, array($user, &$options));
         Event::fire('checkout.done', array($user, &$options));
         return $order;
     }
 }
コード例 #12
0
 public function checkout_step3()
 {
     // Processing Cart
     $cart_id = $this->cart_id;
     if (!$cart_id) {
         $cart_id = Input::get('cart_id');
     }
     $address_id = Input::get('address_id');
     $payment_id = Input::get('payment_id');
     $cart_products = DB::table('cart_products')->where('cart_id', $cart_id)->leftJoin('products', 'cart_products.product_id', '=', 'products.id')->leftJoin('users', 'cart_products.added_by', '=', 'users.id')->select('products.*', 'cart_products.quantity as cart_quantity', 'users.first_name as added_by')->orderBy('store_id')->get();
     $cart_users = DB::table('cart_users')->leftJoin('users', 'cart_users.user_id', '=', 'users.id')->select('users.*')->get();
     $response_array['cart'] = Cart::find($cart_id)->toArray();
     $response_array['cart']['total_amount'] = 0;
     $response_array['cart']['total_quantity'] = 0;
     $response_array['cart']['users'] = array();
     $response_array['cart']['stores'] = array();
     $store_id = 0;
     if ($cart_products) {
         $response_array['cart']['is_minimum_reached'] = 1;
         foreach ($cart_products as $cart_product) {
             if ($store_id != $cart_product->store_id) {
                 $store_id = $cart_product->store_id;
                 // Retriving Store
                 $store = Store::find($store_id)->toArray();
                 // Retriving Delivery Slot
                 $time = date("Y-m-d H:i:s");
                 $slot = Slot::where('store_id', $store_id)->where('start_time', '>', $time)->where('is_available', 1)->orderBy('start_time')->first();
                 if ($slot) {
                     $next_slot_start = date("D, jS M, H a", strtotime($slot->start_time));
                     $next_slot_end = date("h a", strtotime($slot->end_time));
                     $next_slot = $next_slot_start . " - " . $next_slot_end;
                 } else {
                     $next_slot = "No Slots available";
                 }
                 $store['slot'] = $next_slot;
                 $store['count'] = 1;
                 $store['sub_total'] = 0;
                 $response_array['cart']['stores'][$store_id] = $store;
                 $response_array['cart']['stores'][$store_id]['products'] = array();
             } else {
                 $response_array['cart']['stores'][$store_id]['count'] += 1;
             }
             $product = json_decode(json_encode($cart_product), true);
             $product['sub_total'] = $product['cart_quantity'] * $product['price'];
             $response_array['cart']['stores'][$store_id]['sub_total'] += $product['sub_total'];
             $response_array['cart']['total_amount'] += $product['sub_total'];
             $response_array['cart']['total_quantity']++;
             array_push($response_array['cart']['stores'][$store_id]['products'], $product);
         }
     }
     if ($cart_users) {
         foreach ($cart_users as $cart_user) {
             $product = json_decode(json_encode($cart_user), true);
             array_push($response_array['cart']['users'], $cart_user);
         }
     }
     foreach ($response_array['cart']['stores'] as $st) {
         if ($st['sub_total'] < $st['minimum_order_amount']) {
             $response_array['cart']['is_minimum_reached'] = 0;
         }
     }
     if (isset($response_array['cart']['is_minimum_reached']) && $response_array['cart']['is_minimum_reached'] == 1) {
         $order = new Order();
         $order->user_id = $this->user_id;
         $order->date = date("Y-m-d H:i:s");
         $order->total_products = $response_array['cart']['total_quantity'];
         $order->total_amount = $response_array['cart']['total_amount'];
         $order->payment_id = $payment_id;
         $order->address_id = $address_id;
         $payment = Payment::find($payment_id);
         $order->payment_customer_id = $payment->customer_id;
         $address = UserAddress::find($address_id);
         $order->address = $address->address . " " . $address->zipcode;
         $order->status = "Initiated";
         $order->save();
         foreach ($cart_products as $cart_product) {
             $order_product = new OrderProduct();
             $order_product->order_id = $order->id;
             $product = Product::find($cart_product->id);
             $product->total_sale += $cart_product->cart_quantity;
             $product->save();
             $order_product->price = $cart_product->price;
             $order_product->quantity = $cart_product->cart_quantity;
             $order_product->fulfilment_status = "Pending";
             $order_product->type = "Product";
             $order_product->parent_id = 0;
             $order_product->product_name = $product->name;
             $order_product->product_image_url = $product->image_url;
             $order_product->product_quantity = $product->quantity;
             $order_product->product_unit = $product->unit;
             $order_product->store_id = $product->store_id;
             $order_product->save();
         }
         // removing products from cart
         CartProduct::where('cart_id', $cart_id)->delete();
         // Order Placement Mail
         $user = User::find($this->user_id);
         Mail::send('emails.order_success', array('user' => $user, 'order' => $order), function ($message) use($user) {
             $message->to($user->email, $user->first_name)->subject('Thanks for placing the order!');
         });
         // Order Placement Mail to Admin
         $admin_email = Config::get('app.admin_email');
         Mail::send('emails.admin_order_success', array('user' => $user, 'order' => $order), function ($message) use($admin_email) {
             $message->to($admin_email, "Admin")->subject('New Order!');
         });
     } else {
         $message = "Minimum order amount not reached";
         if (Request::format() == 'html') {
             return View::make('checkout_step3')->with('store', $this->store)->with('departments', $this->departments)->with('zipcode', $this->zipcode)->with('city', $this->city)->with('stores1', $this->stores)->with('message', $message);
         } else {
             $response_array = array('success' => false, 'error_code' => 411, 'error' => $message);
             $response_code = 200;
             $response = Response::json($response_array, $response_code);
             return $response;
         }
     }
     if (Request::format() == 'html') {
         return View::make('checkout_step3')->with('store', $this->store)->with('departments', $this->departments)->with('zipcode', $this->zipcode)->with('city', $this->city)->with('stores1', $this->stores)->with('message', 'Thanks for placing your Order!!');
     } else {
         $response_array = array('success' => true);
         $response_code = 200;
         $response = Response::json($response_array, $response_code);
         return $response;
     }
 }
コード例 #13
0
ファイル: FeedBackClass.php プロジェクト: song-yuan/wymenujp
 public static function getFeedbackSite($companyId, $siteId, $istemp, $orderId, $isOrder)
 {
     if ($siteId !== '0000000000') {
         return SiteClass::getSiteNmae($companyId, $siteId, $istemp);
     }
     if ($orderId !== '0000000000') {
         if ($isOrder == '1') {
             $order = Order::model()->find(" dpid=:dpid and lid=:orderid", array(':dpid' => $companyId, ':orderid' => $orderId));
             return SiteClass::getSiteNmae($companyId, $order->site_id, $order->istemp);
         } else {
             $orderProduct = OrderProduct::model()->with("order")->find(" dpid=:dpid and lid=:orderid", array(':dpid' => $companyId, ':orderid' => $orderId));
             return SiteClass::getSiteNmae($companyId, $orderProduct->order->site_id, $orderProduct->order->istemp);
         }
     }
 }
コード例 #14
0
ファイル: order.m.php プロジェクト: lotcz/zshop
 public function loadProducts()
 {
     $this->products = OrderProduct::select($this->db, 'viewOrderProducts', 'order_product_order_id = ?', [$this->ival('order_id')], 'i', null, 'order_product_name');
 }
コード例 #15
0
 public function actionPayment($id)
 {
     $cart = $this->getCart();
     $add = CheckoutAddress::model()->findByPk($id);
     $link;
     $onlinePaymentMethodName;
     $extrapObj = array();
     $orderArray = array();
     $classArray = array();
     if (!empty($add) && !empty($cart['items'])) {
         if (isset($_POST['Payment']['payment_method'])) {
             $pay_method = $_POST['Payment']['payment_method'];
             $cart['payment'] = $pay_method == 4 ? 2 : $pay_method;
             $paymentType = is_numeric($pay_method) ? 'others' : 'online';
             $order = new Order();
             $order->order_status_id = 1;
             $order->total = $this->getCartTotal();
             $order->ip = Yii::app()->request->userHostAddress;
             $order->user_agent = Yii::app()->request->userAgent;
             $order->firstname = $add->firstname;
             $order->lastname = $add->lastname;
             $order->email = $add->email;
             $order->telephone = $add->telephone;
             $order->payment_firstname = $add->firstname;
             $order->payment_lastname = $add->lastname;
             $order->payment_company = '';
             $order->payment_tax_id = 0;
             $order->payment_address_1 = $add->address_1;
             $order->payment_address_2 = $add->address_2;
             $order->payment_city = $add->city;
             $order->payment_postcode = $add->postal_code;
             $order->payment_country_id = $add->country_id;
             $order->payment_zone_id = $add->zone_id;
             $order->payment_method = $cart['payment'];
             $order->payment_code = uniqid() . rand(1, 9);
             $order->shipping_firstname = $add->firstname;
             $order->shipping_lastname = $add->lastname;
             $order->shipping_company = '';
             $order->shipping_address_1 = $add->address_1;
             $order->shipping_address_2 = $add->address_2;
             $order->shipping_city = $add->city;
             $order->shipping_postcode = $add->postal_code;
             $order->shipping_country_id = $add->country_id;
             $order->shipping_zone_id = $add->zone_id;
             $order->shipping_method = 2;
             if ($add->zone_id == 2412) {
                 $order->shipping_method = 1;
             }
             $storeid = UtilityHelper::yiiparam('storeID');
             $store = Store::model()->findByPk($storeid);
             $order->store_id = $storeid;
             $order->store_name = $store->name;
             $order->store_url = $store->url;
             $order->payment_country = Country::model()->findByPk($order->payment_country_id)->name;
             $order->payment_zone = Zone::model()->findByPk($order->payment_zone_id)->name;
             $order->shipping_country = $order->payment_country;
             $order->shipping_zone = $order->payment_zone;
             if ($order->save()) {
                 foreach ($cart['items'] as $product) {
                     $orderproduct = new OrderProduct();
                     $orderproduct->order_id = $order->id;
                     $orderproduct->product_id = $product['product_id'];
                     $orderproduct->name = $product['name'];
                     $orderproduct->model = $product['model'];
                     $orderproduct->quantity = $product['quantity'];
                     $orderproduct->price = $product['price'];
                     $orderproduct->total = $product['total'];
                     $orderproduct->tax = 0;
                     if ($orderproduct->save()) {
                         if (!empty($product['option'])) {
                             foreach ($product['option'] as $orderoption) {
                                 $orderoption->order_id = $order->id;
                                 $orderoption->order_product_id = $orderproduct->id;
                                 $orderoption->save();
                             }
                         }
                     } else {
                         Yii::log("CartPaymentOrderProductErrors: " . CVarDumper::dumpAsString($orderproduct->getErrors()), CLogger::LEVEL_ERROR, "cart.actions.payment");
                     }
                 }
                 //Yii::app()->user->setState('user_cart', NULL);
                 $extrap = array();
                 //
                 switch ($paymentType) {
                     case 'others':
                         // Will need to loop through the ids for non online payment to do this properly
                         if ($pay_method == 1) {
                             $link = '_cash';
                             $extrap = array('orderID' => $order->id, 'total' => $order->total);
                             UtilityHelper::changeOrderStatus($order->id);
                         } else {
                             if ($pay_method == 3) {
                                 $link = '_bank';
                                 $extrap = array('orderID' => $order->id, 'total' => $order->total);
                             }
                         }
                         break;
                     case 'online':
                         $subClasses = new PaymentGatewayHelper();
                         $subClassesArray = $subClasses->getSubClasses();
                         foreach ($subClassesArray as $class => $payOption) {
                             ${$class} = new $class();
                             $onlinePaymentMethodName = ${$class}->getPaymentName();
                             if ($pay_method == $onlinePaymentMethodName) {
                                 $link = ${$class}->getViewLink();
                                 ${$class}->setOrderObj($order);
                                 $extrapObj = ${$class}->getOrderObj();
                                 foreach ($extrapObj as $field => $value) {
                                     $orderArray[$field] = $value;
                                 }
                                 $link = ${$class}->getViewLink();
                                 $extrap = array('orderID' => $orderArray['id'], 'total' => $orderArray['total']);
                                 ${$class}->regPaymentTransaction($order);
                                 $classArray['pay_method'] = $pay_method;
                             } else {
                                 continue;
                             }
                         }
                         break;
                     default:
                         break;
                 }
                 if (Yii::app()->getRequest()->getIsAjaxRequest()) {
                     $this->renderPartial($link, array_merge(array('ref' => $order->payment_code), $extrap, $classArray), false, true);
                     Yii::app()->end();
                 }
                 $this->render($link, array_merge(array('ref' => $order->payment_code), $extrap, $classArray));
                 Yii::app()->end();
             } else {
                 Yii::log("CartPaymentErrors: " . CVarDumper::dumpAsString($order->getErrors()), CLogger::LEVEL_ERROR, "cart.actions.payment");
             }
         }
         if (Yii::app()->getRequest()->getIsAjaxRequest()) {
             $this->renderPartial('_payment', array('app' => $add), false, true);
             Yii::app()->end();
         }
         $this->render('payment', array('app' => $add));
         Yii::app()->end();
     }
     $this->redirect(array('cart'));
 }
コード例 #16
0
 public function updateTotalOrder($orderProductID = 0)
 {
     try {
         if (0 !== $orderProductID) {
             $OrderModel = new Order();
             $OrderProductModel = new OrderProduct();
             $orderProduct = $OrderProductModel->read(null, $orderProductID);
             if (!empty($orderProduct)) {
                 $order = $OrderModel->read(null, $orderProduct["OrderProduct"]["order_id"]);
                 $allProducts = $orderProducts = $OrderProductModel->find('all', array('conditions' => array('OrderProduct.id >=' => 1, 'OrderProduct.order_id' => $orderProduct["OrderProduct"]["order_id"], 'OrderProduct.status' => 'active')));
                 $pSum = 0;
                 $pUnit = 0;
                 $tTax = 0;
                 $tDisc = 0;
                 $tSub = 0;
                 foreach ($allProducts as $value) {
                     $orderProduct = $value["OrderProduct"];
                     $pUnit = $orderProduct["product_price"] * $orderProduct["product_qty"];
                     $pUnit = $pUnit - $pUnit * $orderProduct["product_disc"] / 100;
                     $pUnit = $pUnit + $pUnit * $orderProduct["product_tax"] / 100;
                     $pSum += $pUnit;
                 }
                 $order["Order"]["price"] = $pSum;
                 $order["Order"]["tax"] = 0;
                 $order["Order"]["tax_amt"] = 0;
                 $order["Order"]["subtotal_amt"] = $pSum;
                 $order["Order"]["total_amt"] = $pSum;
                 if (0 < $pSum) {
                     $order["Order"]["status"] = 'pending';
                 }
                 $order["Order"]["disc"] = 0;
                 $order["Order"]["disc_amt"] = 0;
                 $OrderModel->recursive = -1;
                 if (!$OrderModel->save($order["Order"])) {
                     $this->log('No se pudo actualizar el total de la orden');
                     $this->log($OrderModel->validationErrors);
                 }
             }
         }
     } catch (Exception $ex) {
         $this->log('Error al guardar el total de productos a la orden');
         $this->log($ex->getMessage());
     }
 }
コード例 #17
0
 public function actionDeleteProduct()
 {
     $id = Yii::app()->request->getParam('id');
     $orderProduct = OrderProduct::model()->findByPk($id);
     if ($orderProduct) {
         if ($orderProduct->amount > 1) {
             $restNum = $orderProduct->amount - 1;
             $orderProduct->saveAttributes(array('amount' => $restNum));
             $data = array('status' => true, 'amount' => $restNum, 'price' => $orderProduct->price);
         } else {
             $orderProduct->delete();
             $data = array('status' => true, 'amount' => 0, 'price' => 0);
         }
         $data['total'] = OrderProduct::getTotal($orderProduct->order_id);
         echo json_encode($data);
         exit;
     }
     echo json_encode(array('status' => false));
     exit;
 }
コード例 #18
0
 function newOrderAdd()
 {
     $order = Order::create(array('strOrdersID' => Input::get('orderID'), 'strSupplID' => Input::get('supplierID'), 'dtOrdDate' => date('Y-m-d'), 'strPlacedBy' => Input::get('empID')));
     $order->save();
     $ids = DB::table('tblOrdNotes')->select('strOrdNotesID')->orderBy('updated_at', 'desc')->orderBy('strOrdNotesID', 'desc')->take(1)->get();
     $ID = $ids["0"]->strOrdNotesID;
     $newID = $this->smart($ID);
     $notes = OrderNotes::create(array('strOrdNotesID' => $newID, 'strOrderID' => Input::get('orderID'), 'strOrdNotesStat' => 'Pending'));
     $notes->save();
     $item = Input::get('itemsOrd');
     // 'strOPOrdersID', 'strOPProdID', 'intOPQuantity'
     for ($i = 0; $i < count($item); $i++) {
         $ordItem = OrderProduct::create(array('strOPOrdersID' => Input::get('orderID'), 'strOPProdID' => $item[$i][0], 'intOPQuantity' => $item[$i][2]));
         $ordItem->save();
     }
 }
コード例 #19
0
ファイル: Cart.php プロジェクト: conghua1013/yii
 /**
  * 保存订单商品信息
  * @param $oid
  * @param $cartinfo
  * @return bool
  * @throws Exception
  */
 protected function saveOrderProduct($userId, $order_id, $cartInfo)
 {
     $list = $cartInfo['list'];
     foreach ($list as $row) {
         if ($row['type'] == 1) {
             $pInfo = Tab::model()->findByPk($row['product_id']);
             if (empty($pInfo)) {
                 throw new Exception("谱子不存在!", 500);
             }
         } elseif ($row['type'] == 2) {
             $pInfo = Zine::model()->findByPk($row['product_id']);
             if (empty($pInfo)) {
                 throw new Exception("杂志商品不存在!", 500);
             }
         } else {
             $pInfo = Product::model()->findByPk($row['product_id']);
             if (empty($pInfo)) {
                 throw new Exception("订单商品不存在!", 500);
             }
         }
         if ($row['sell_price'] != $pInfo['sell_price']) {
             throw new exception('价格错误,请重试');
         }
         $m = new OrderProduct();
         $m->order_id = $order_id;
         $m->user_id = $userId;
         $m->product_id = $row['product_id'];
         $m->type = $row['type'];
         $m->product_sn = empty($row['type']) ? $pInfo['product_sn'] : '';
         $m->product_name = empty($row['type']) ? $pInfo['product_name'] : ($row['type'] == 1 ? $pInfo['tabname'] : $pInfo['name']);
         $m->size_id = $row['size_id'];
         $m->brand_id = $row['type'] == 0 ? $pInfo['brand_id'] : 0;
         $m->sell_price = $row['sell_price'];
         $m->quantity = $row['quantity'];
         //$m->shipping_id 	= 0;
         //$m->shipping_code 	= '';
         //$m->shipping_time 	= 0;
         $opid = $m->save();
         if (empty($opid)) {
             throw new Exception("订单商品生成失败!", 1);
         }
         $this->updateProductStock($pInfo, $row);
         //更新商品的库存
     }
     return true;
 }
コード例 #20
0
ファイル: UserController.php プロジェクト: conghua1013/yii
 /**
  * 订单详情
  */
 public function actionOrder()
 {
     $userId = $this->user_id;
     if (empty($userId)) {
         $this->redirect('/user/login');
     }
     $orderSn = addslashes(trim($_REQUEST['ordersn']));
     try {
         $oInfo = Order::model()->getUserOrderInfoBySn($userId, $orderSn);
         if (empty($oInfo) || !$oInfo['id']) {
             $this->redirect('/?from=no_order');
         }
         $orderProduct = OrderProduct::model()->getOrderProductByOrderId($oInfo['id']);
         $status = Order::model()->getOrderStatusForUserPage($oInfo);
         $logs = OrderLog::model()->findAllByAttributes(array('order_id' => $oInfo['id']));
     } catch (exception $e) {
         $this->redirect('/?from=order_error');
     }
     $viewData = array();
     $viewData['info'] = $oInfo;
     $viewData['status'] = $status;
     $viewData['logs'] = $logs;
     $viewData['orderProduct'] = $orderProduct;
     $this->render('/user/order', $viewData);
 }
コード例 #21
0
ファイル: OrderController.php プロジェクト: nellka/mebel
 public function actionDoOrder()
 {
     if (Yii::app()->user->isGuest || empty($_POST)) {
         throw new CHttpException(404, 'Страница не найдена');
     }
     $product_ids = Yii::app()->request->getPost('id');
     if (empty($product_ids) || !is_array($product_ids)) {
         throw new CHttpException(404, 'Не выбраны товары для заказа');
     }
     $model_order = new Order();
     if (count($product_ids)) {
         $model_order->order_status_id = Order::STATUS_CREATED;
         $model_order->user_id = Yii::app()->user->id;
         $model_order->ip = $_SERVER['REMOTE_ADDR'];
         $model_order->comment = $_POST['comment'];
         $model_order->date = date('Y-m-d H:i:s', time());
         $model_order->save();
         $order_id = $model_order->order_id;
     }
     $products = array();
     foreach ($product_ids as $pid) {
         if (!isset($_POST["quantity{$pid}"]) || !$_POST["quantity{$pid}"]) {
             continue;
         }
         $model_order_product = new OrderProduct();
         $model_order_product->product_id = $pid;
         $model_order_product->order_id = $order_id;
         $model_order_product->quantity = $_POST["quantity{$pid}"];
         $products[$pid] = $_POST["quantity{$pid}"];
         $model_order_product->save();
     }
     //Отпраляем письмо с заказом
     $message = new YiiMailMessage();
     $message->view = 'orderinfo';
     $message->setSubject("Создан новый заказ на сайте kto-tut.ru");
     $message->setBody(array('products' => $products, 'comment' => $_POST['comment'], 'for_admin' => true), 'text/html');
     $message->addTo(Yii::app()->params['adminEmail']);
     $message->from = Yii::app()->params['adminEmail'];
     Yii::app()->mail->send($message);
     $message = new YiiMailMessage();
     $message->view = 'orderinfo';
     $message->setSubject('Ваш заказ на сайте kto-tut.ru успешно сформирован!');
     $message->setBody(array('products' => $products, 'comment' => $_POST['comment'], 'for_admin' => false), 'text/html');
     $message->addTo(Yii::app()->user->me->email);
     $message->from = Yii::app()->params['adminEmail'];
     Yii::app()->mail->send($message);
     $this->redirect('success');
 }
コード例 #22
0
 public function update_order_product()
 {
     $id = Input::get('id');
     $order_product = OrderProduct::find($id);
     if ($order_product) {
         $order_id = $order_product->order_id;
         $store_id = $order_product->store_id;
         if (Input::has('quantity') && !Input::has('product_name')) {
             $order_product->quantity = Input::get('quantity');
         }
         if (Input::has('price') && !Input::has('product_name')) {
             $order_product->price = Input::get('price');
         }
         if (Input::has('status') && !Input::has('product_name')) {
             $order_product->fulfilment_status = Input::get('status');
         }
         if (Input::has('product_name')) {
             $order_product->fulfilment_status = 'Replacement';
             $order_product->save();
             $order_product = new OrderProduct();
             $order_product->order_id = $order_id;
             $order_product->price = Input::get('price');
             $order_product->quantity = Input::get('quantity');
             $order_product->fulfilment_status = 'Fullfilled';
             $order_product->type = 'Replacement';
             $order_product->parent_id = $id;
             $order_product->product_name = Input::get('product_name');
             $image = Input::file('product_image_url');
             $validator = Validator::make(array('ima' => $image), array('ima' => 'required|mimes:jpeg,bmp,png'));
             if ($validator->fails()) {
                 $error_messages = $validator->messages();
                 $response_array = array('success' => false, 'error' => 'Invalid Input', 'error_code' => 401);
                 $response_code = 200;
                 $message = "Invalid Input File";
                 $type = "failed";
                 return Redirect::to('/admin/order/' . $order_id . '/details')->with('type', $type)->with('message', $message);
             } else {
                 if (Input::hasFile('product_image_url')) {
                     $order_product->product_image_url = upload_image(Input::file('product_image_url'));
                 }
                 $order_product->product_quantity = Input::get('product_quantity');
                 $order_product->product_unit = Input::get('product_unit');
                 $order_product->store_id = $store_id;
             }
             $order_product->save();
         }
         // update order data
         $products = OrderProduct::where('order_id', $order_id)->where('fulfilment_status', 'Fullfilled')->get();
         $total_products = 0;
         $total_amount = 0.0;
         foreach ($products as $product) {
             $total_products++;
             $total_amount = $total_amount + $product->quantity * $product->price;
             echo $total_amount;
         }
         $order = Order::find($order_id);
         $order->total_products = $total_products;
         $order->total_amount = $total_amount;
         $order->save();
         return Redirect::to('/admin/order/' . $order_id . '/details');
     }
 }
コード例 #23
0
ファイル: Order.php プロジェクト: bahdall/karbella_event
 /**
  * @return CActiveDataProvider
  */
 public function getOrderedProducts()
 {
     $products = new OrderProduct();
     $products->order_id = $this->id;
     return $products->search();
 }
コード例 #24
0
ファイル: index.php プロジェクト: mrDumay/demoshop
     $order->client_address = $address;
     $order->save();
     /**
      * Если клиент был приведён на сайт через партнёра, сохраним в заказ партнерскую информацию
      */
     if (\Actionpay\CPA::getLastPartnerName()) {
         // Имя партнёра и идентификатор трафика, хранящиеся в cookie клиента
         $order->partner_name = \Actionpay\CPA::getLastPartnerName();
         $order->partner_traffic_id = \Actionpay\CPA::getLastTrafficIdentifer();
         // Генерируем уникальный ID для отслеживания заказа патрнером.
         // Очень важно, чтобы этот ID генерировался случайным образом!
         $order->partner_order_id = $order->id . '_' . sprintf('%06x', rand(0, pow(2, 24) - 1));
         $order->save();
     }
     foreach ($basket as $productId => $count) {
         $orderProduct = new OrderProduct();
         $orderProduct->order_id = $order->id;
         $orderProduct->product_id = $productId;
         $orderProduct->count = $count;
         $orderProduct->save();
     }
     // редирект на страницу "спасибо"
     $app->redirect('/thankyou?order=' . $order->id);
     // очистка корзины
     $app->session('basket', array());
     $app->session('basketTotalItems', 0);
     $app->session('basketTotalPrice', 0);
     return '';
 }
 $basket = $app->session('basket');
 if (!empty($basket)) {
コード例 #25
0
 public function addProduct()
 {
     $sess = Yii::app()->user->getState('order_product');
     if (isset($_POST['OrderProduct']['id'])) {
         $product = Product::model()->findByPk($_POST['OrderProduct']['id']);
         $orderproduct = new OrderProduct();
         $orderproduct->order_id = 0;
         $orderproduct->product_id = $product->id;
         $orderproduct->name = $product->getName();
         $orderproduct->model = $product->model;
         $orderproduct->quantity = $_POST['OrderProduct']['quantity'];
         $orderproduct->price = $product->price;
         $orderproduct->total = $orderproduct->quantity * $product->price;
         $orderproduct->tax = 0;
         if ($this->addProductOption($product->id)) {
             $orderproduct->order_options = $this->_orderoption;
             $orderoptions = $this->_orderoption;
             if (!empty($sess)) {
                 $addnew = false;
                 foreach ($sess as $i => $cart) {
                     $match = $match2 = false;
                     $diff = $orderproduct->compare($cart);
                     if ($diff) {
                         $sess[$i]->quantity += $_POST['OrderProduct']['quantity'];
                         $addnew = true;
                         break;
                     }
                 }
                 if ($addnew) {
                     $sess[] = $orderproduct;
                 }
             } else {
                 $sess = array($orderproduct);
             }
             Yii::app()->user->setState('order_product', $sess);
             Yii::app()->user->setFlash(TbHtml::ALERT_COLOR_ERROR, Yii::t('info', 'Please fill out all required fields for product options'));
             $this->renderPartial('_form_order', array('orderproduct' => $sess), false, true);
             Yii::app()->end();
         } else {
             Yii::app()->user->setFlash(TbHtml::ALERT_COLOR_ERROR, Yii::t('info', 'Please fill out all required fields for product options'));
         }
     }
     if (empty($sess)) {
         $sess = array();
     }
     $norderopt = array();
     if (isset($_POST['OrderProduct']['id'])) {
         $norderopt = $this->loadProductOption(isset($_POST['OrderProduct']['id']));
     }
     $this->renderPartial('_form_order', array('orderproduct' => $sess, 'orderoption' => $norderopt), false, true);
 }
コード例 #26
0
 public function actionPrintKitchenResultOne()
 {
     $companyId = Yii::app()->request->getParam('companyId');
     $jobid = Yii::app()->request->getParam('jobid');
     $orderProductId = Yii::app()->request->getParam('orderProductId');
     Until::validOperate($companyId, $this);
     $db = Yii::app()->db;
     //$jobstatus=false;
     Gateway::getOnlineStatus();
     $store = Store::instance('wymenu');
     $jobresult = $store->get('job_' . $companyId . "_" . $jobid . '_result');
     //var_dump($jobresult);exit;
     if (empty($jobresult)) {
         $ret = array('status' => false, 'msg' => yii::t('app', '任务未返回'));
     } else {
         if ($jobresult == "success") {
             //var_dump($companyId,$orderProductId);exit;
             $orderProduct = OrderProduct::model()->find(' dpid=:dpid and lid=:lid', array(':dpid' => $companyId, ':lid' => $orderProductId));
             //                        if($orderProduct->is_print=='0')
             //                        {
             //                            $orderProduct->is_print='1';
             //                            $orderProduct->save();
             //                        }
             if ($orderProduct->is_print == '0') {
                 $orderProduct->is_print = '1';
                 $orderProduct->save();
             }
             $ret = array('status' => true, 'msg' => yii::t('app', '打印成功'));
         } else {
             $ret = array('status' => false, 'msg' => yii::t('app', '打印机执行任务失败'));
         }
     }
     Yii::app()->end(json_encode($ret));
     //get status from memcache
     //if error change product kitchen status in db
     //if timenum=0 return finish or all success
 }
コード例 #27
0
 /**
  * Create new order
  * @return Order
  */
 public function createOrder()
 {
     if (Yii::app()->cart->countItems() == 0) {
         return false;
     }
     Yii::import('mod.cart.models.Order');
     Yii::import('mod.cart.models.OrderProduct');
     $order = new Order();
     // Set main data
     $order->user_id = Yii::app()->user->isGuest ? null : Yii::app()->user->id;
     $order->user_name = $this->form->name;
     $order->user_email = $this->form->email;
     $order->user_phone = $this->form->phone;
     $order->user_address = $this->form->address;
     $order->user_comment = $this->form->comment;
     $order->delivery_id = $this->form->delivery_id;
     $order->payment_id = $this->form->payment_id;
     if ($order->validate()) {
         if ($order->save()) {
         }
     } else {
         throw new CHttpException(503, Yii::t('CartModule.default', 'ERROR_CREATE_ORDER'));
     }
     // Process products
     foreach (Yii::app()->cart->getDataWithModels() as $item) {
         $ordered_product = new OrderProduct();
         $ordered_product->order_id = $order->id;
         $ordered_product->product_id = $item['model']->id;
         $ordered_product->configurable_id = $item['configurable_id'];
         $ordered_product->currency_id = $item['model']->currency_id;
         $ordered_product->supplier_id = $item['model']->supplier_id;
         $ordered_product->name = $item['model']->name;
         $ordered_product->quantity = $item['quantity'];
         $ordered_product->sku = $item['model']->sku;
         $ordered_product->date_create = $order->date_create;
         // if($item['currency_id']){
         //     $currency = ShopCurrency::model()->findByPk($item['currency_id']);
         //$ordered_product->price = ShopProduct::calculatePrices($item['model'], $item['variant_models'], $item['configurable_id']) * $currency->rate;
         // }else{
         $ordered_product->price = ShopProduct::calculatePrices($item['model'], $item['variant_models'], $item['configurable_id']);
         // }
         // Process configurable product
         if (isset($item['configurable_model']) && $item['configurable_model'] instanceof ShopProduct) {
             $configurable_data = array();
             $ordered_product->configurable_name = $item['configurable_model']->name;
             // Use configurable product sku
             $ordered_product->sku = $item['configurable_model']->sku;
             // Save configurable data
             $attributeModels = ShopAttribute::model()->cache($this->cacheTime)->findAllByPk($item['model']->configurable_attributes);
             foreach ($attributeModels as $attribute) {
                 $method = 'eav_' . $attribute->name;
                 $configurable_data[$attribute->title] = $item['configurable_model']->{$method};
             }
             $ordered_product->configurable_data = serialize($configurable_data);
         }
         // Save selected variants as key/value array
         if (!empty($item['variant_models'])) {
             $variants = array();
             foreach ($item['variant_models'] as $variant) {
                 $variants[$variant->attribute->title] = $variant->option->value;
             }
             $ordered_product->variants = serialize($variants);
         }
         $ordered_product->save();
     }
     // Reload order data.
     $order->refresh();
     //@todo panix text email tpl
     // All products added. Update delivery price.
     $order->updateDeliveryPrice();
     // Send email to user.
     $this->sendClientEmail($order);
     // Send email to admin.
     $this->sendAdminEmail($order);
     if (Yii::app()->hasModule('sms')) {
         /* $this->widget('mod.sms.widgets.SMSWidget', array(
                'key' => 'ADMIN_ORDER_BEFORE',
                'model' => $order
            ));*/
         $this->widget('mod.sms.widgets.SMSWidget', array('key' => 'CLIENT_ORDER_BEFORE', 'model' => $order));
     }
     return $order;
 }
コード例 #28
0
ファイル: Order.php プロジェクト: conghua1013/yii
 /**
  * 处理取消订单的库存
  * @param $orderId
  */
 public function dealWithCancelOrderProductStock($orderId)
 {
     if (!$orderId) {
         throw new exception('订单的id不能为空!');
     }
     $list = OrderProduct::model()->findAllByAttributes(array('order_id' => $orderId));
     if (empty($list)) {
         throw new exception('订单商品为空!');
     }
     foreach ($list as $row) {
         if ($row['type'] == 1) {
             $pInfo = Tab::model()->findByPk($row['product_id']);
         } elseif ($row['type'] == 2) {
             $pInfo = Zine::model()->findByPk($row['product_id']);
         } else {
             $pInfo = Product::model()->findByPk($row['product_id']);
         }
         if (empty($pInfo)) {
             throw new exception('商品【' . $row['product_name'] . '】不存在!');
         }
         $pInfo->quantity += $row['quantity'];
         $flag = $pInfo->save();
         if (empty($flag)) {
             throw new exception('商品【' . $row['product_name'] . '】库存恢复失败!');
         }
         if (!$row['type']) {
             $stockInfo = ProductStock::model()->findByAttributes(array('product_id' => $row['product_id'], 'attr_id' => $row['size_id']));
             if (empty($stockInfo)) {
                 throw new exception('商品【' . $row['product_name'] . '】库存不存在!');
             }
             $stockInfo->quantity += $row['quantity'];
             $flag = $stockInfo->save();
             if (empty($flag)) {
                 throw new exception('订单【' . $row['product_name'] . '】库存恢复失败!');
             }
         }
     }
     return true;
 }
コード例 #29
0
ファイル: Order.php プロジェクト: syrexby/domovoishop.by
 /**
  * Массив объектов OrderProduct
  * @param $products
  */
 private function updateOrderProducts($products)
 {
     if (!$this->productsChanged) {
         return;
     }
     $validOrderProductIds = [];
     foreach ($products as $var) {
         /* @var $var OrderProduct */
         if ($var->getIsNewRecord()) {
             $var->order_id = $this->id;
         }
         if ($var->save()) {
             $validOrderProductIds[] = $var->id;
         }
     }
     $criteria = new CDbCriteria();
     $criteria->addCondition('order_id = :order_id');
     $criteria->params = [':order_id' => $this->id];
     $criteria->addNotInCondition('id', $validOrderProductIds);
     OrderProduct::model()->deleteAll($criteria);
 }
コード例 #30
0
ファイル: Order.php プロジェクト: hansvn/icepay
 /**
  * Sets the order shipping costs
  * 
  * @since 1.0.0
  * @param string $amount Contains the shipping costs in cents
  * @param int $vat Contains the VAT category in percentages
  * @param string $name Contains the shipping name
  * @return Order
  */
 public function setShippingCosts($amount, $vat = -1, $name = 'Shipping Costs')
 {
     $obj = OrderProduct::create()->setProductID('01')->setProductName($name)->setDescription('')->setQuantity('1')->setUnitPrice($amount)->setVATCategory(OrderVAT::getCategoryForPercentage($vat));
     $this->addProduct($obj);
     return $this;
 }