Esempio n. 1
0
 public function saveOrder()
 {
     $ShoppingCart = Kiwi::getShoppingCart();
     $this->user_id = Yii::$app->user->id;
     $this->total_price = $ShoppingCart->getTotal();
     /**@TODO attributes  * */
     $this->shipping_fee = $ShoppingCart->getShippingFee();
     $this->payment_fee = 0;
     $this->status = 1;
     $cartItems = $ShoppingCart->cartItems;
     $orderItems = [];
     foreach ($cartItems as $cartItem) {
         $key = $cartItem->data['key'];
         /** @var \extensions\sales\models\CustomerSales $customer_sale */
         $customerSaleClass = Kiwi::getCustomerSalesClass();
         $customer_sale = $customerSaleClass::find()->where(['key' => $key])->one();
         $orderItem = Kiwi::getOrderItem();
         $orderItem->item_id = $cartItem->item->item_id;
         $orderItem->price = $customer_sale->sale_price;
         $orderItem->qty = $cartItem->qty;
         $orderItem->name = $cartItem->item->name;
         $orderItem->data = $cartItem->data;
         /**@TODO picture can not null * */
         $orderItem->picture = is_null($cartItem->item->pictures) ? $cartItem->item->pictures : 'default';
         $orderItems[] = $orderItem;
     }
     $this->orderItems = $orderItems;
     if ($this->save()) {
         $ShoppingCart->clearAll();
         return true;
     }
     return false;
 }
Esempio n. 2
0
                        <li style="padding: 10px 30px; border-bottom: dashed 1px #8c8b8b; line-height: 24px">销售: <?php 
    echo $topSeller->user->username;
    ?>
; 销量: <?php 
    echo $topSeller->getSelesCount();
    ?>
</li>
                    <?php 
}
?>
                </ul>
            </div>
            <div class="tab-pane fade" id="category">
                <ul class="list-unstyled contact-details">
                    <?php 
$categories = Kiwi::getOrderItem()->getCategoryOrderBy();
foreach ($categories as $value) {
    ?>
                        <li style="padding: 10px 30px; border-bottom: dashed 1px #8c8b8b; line-height: 24px"><?php 
    echo $value['name'];
    ?>
; 销量: <?php 
    echo $value['total'];
    ?>
</li>
                    <?php 
}
?>
                </ul>
            </div>
        </div>