public function execute()
 {
     $sku_id = $this->get('id', true);
     $skus_model = new shopProductSkusModel();
     $sku = $skus_model->getSku($sku_id);
     if ($sku) {
         $this->response = $sku;
     } else {
         throw new waAPIException('invalid_param', 'SKU not found', 404);
     }
 }
 public function orderCalculateDiscount($params)
 {
     if ($this->getSettings('status')) {
         if ($discountcard_number = wa()->getStorage()->get('shop/discountcard')) {
             $model = new shopDiscountcardsPluginModel();
             if ($this->getSettings('binding_customer')) {
                 if (wa()->getStorage()->get('shop/discountcard/customer_id')) {
                     $contact_id = wa()->getStorage()->get('shop/discountcard/customer_id');
                 } else {
                     $contact_id = wa()->getUser()->getId();
                 }
                 if ($contact_id) {
                     $discountcard = $model->getByField(array('contact_id' => $contact_id, 'discountcard' => $discountcard_number));
                     if (empty($discountcard)) {
                         $discountcard = $model->getByField(array('contact_id' => 0, 'discountcard' => $discountcard_number));
                     }
                 } else {
                     $discountcard = $model->getByField(array('contact_id' => 0, 'discountcard' => $discountcard_number));
                 }
             } else {
                 $discountcard = $model->getByField('discountcard', $discountcard_number);
             }
             if ($discountcard) {
                 if ($discountcard['discount']) {
                     $discount = array();
                     $def_currency = wa('shop')->getConfig()->getCurrency(true);
                     foreach ($params['order']['items'] as $item_id => $item) {
                         if ($item['type'] == 'product') {
                             $skus_model = new shopProductSkusModel();
                             $sku = $skus_model->getSku($item['sku_id']);
                             if (!($this->getSettings('ignore_compare_price') && $sku['compare_price'] > 0)) {
                                 $discount['items'][$item_id] = array('discount' => shop_currency($item['price'] * $discountcard['discount'] / 100.0, $item['currency'], $params['order']['currency'], false) * $item['quantity'], 'description' => "Скидка по дисконтной карте {$discountcard['discount']}%");
                             }
                         }
                     }
                     return $discount;
                 }
             } else {
                 wa()->getStorage()->set('shop/discountcard', '');
                 wa()->getStorage()->set('shop/discountcard/customer_id', '');
             }
         }
     }
 }