From b4c1be039112ff538c37bbcb4f4bcfaa39383001 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 9 Jan 2017 15:20:26 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=9F=E6=88=90order=E9=83=A8=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Checkout/block/onepage/Placeorder.php | 10 +++- services/Order.php | 49 ++++++++++++++++++- 2 files changed, 57 insertions(+), 2 deletions(-) diff --git a/app/appfront/modules/Checkout/block/onepage/Placeorder.php b/app/appfront/modules/Checkout/block/onepage/Placeorder.php index 1a76ca0b..c5207ee5 100644 --- a/app/appfront/modules/Checkout/block/onepage/Placeorder.php +++ b/app/appfront/modules/Checkout/block/onepage/Placeorder.php @@ -20,6 +20,10 @@ class Placeorder{ if(empty($this->_check_error)){ # 如果是游客,则更新信息到cart中存储。 $this->updateGuestCart($post); + # 设置checkout type + $serviceOrder = Yii::$service->order; + $checkout_type = $serviceOrder::CHECKOUT_TYPE_STANDARD; + $serviceOrder->setCheckoutType($checkout_type); # 将购物车数据,生成订单。 Yii::$service->order->generateOrderByCart($this->_billing,$this->_shipping_method,$this->_payment_method); } @@ -151,7 +155,11 @@ class Placeorder{ $this->_check_error[] = Yii::$service->helper->errors->get(); return false; } - $this->_billing = $address_one; + $arr['customer_id'] = $customer_id; + foreach($address_one as $k=>$v){ + $arr[$k] = $v; + } + $this->_billing = $arr; } } } diff --git a/services/Order.php b/services/Order.php index eaa5debc..27992f7f 100644 --- a/services/Order.php +++ b/services/Order.php @@ -22,7 +22,21 @@ class Order extends Service { public $requiredAddressAttr; # 必填的订单字段。 public $paymentStatus; # 订单支付状态。 + protected $checkout_type; + const CHECKOUT_TYPE_STANDARD = 'standard'; + const CHECKOUT_TYPE_EXPRESS = 'express'; + protected function actionSetCheckoutType($checkout_type){ + $arr = [self::CHECKOUT_TYPE_STANDARD,self::CHECKOUT_TYPE_EXPRESS]; + if(in_array($checkout_type,$arr)){ + $this->checkout_type = $checkout_type; + return true; + } + return false; + } + protected function actionGetCheckoutType(){ + return $this->checkout_type; + } /** * @property $billing | Array * @return boolean @@ -194,7 +208,40 @@ class Order extends Service $myOrder['total_weight'] = $cartInfo['product_weight']; $myOrder['order_currency_code'] = $currency_code; $myOrder['order_to_base_rate'] = $currency_rate; - $myOrder['grand_total'] = $cartInfo['grand_total']; + + $myOrder['grand_total'] = $cartInfo['grand_total']; + $myOrder['base_grand_total'] = $cartInfo['base_grand_total']; + $myOrder['subtotal'] = $cartInfo['product_total']; + $myOrder['base_subtotal'] = $cartInfo['base_product_total']; + $myOrder['subtotal_with_discount'] = $cartInfo['coupon_cost']; + $myOrder['base_subtotal_with_discount'] = $cartInfo['base_coupon_cost']; + $myOrder['shipping_total'] = $cartInfo['shipping_cost']; + $myOrder['base_shipping_total'] = $cartInfo['base_shipping_cost']; + + $myOrder['checkout_method'] = $this->getCheckoutType(); + if($address['customer_id']){ + $is_guest = 2; + }else{ + $is_guest = 1; + } + $myOrder['customer_id'] = $address['customer_id']; + $myOrder['customer_email'] = $address['email']; + $myOrder['customer_firstname'] = $address['first_name']; + $myOrder['customer_lastname'] = $address['last_name']; + $myOrder['customer_is_guest'] = $is_guest; + $myOrder['customer_telephone'] = $address['telephone']; + $myOrder['customer_address_country']= $address['country']; + $myOrder['customer_address_state'] = $address['state']; + $myOrder['customer_address_city'] = $address['city']; + $myOrder['customer_address_zip'] = $address['zip']; + $myOrder['customer_address_street1']= $address['street1']; + $myOrder['customer_address_street2']= $address['street2']; + + $myOrder['coupon_code'] = $cartInfo['coupon_code']; + $myOrder['payment_method'] = $shipping_method; + $myOrder['shipping_method'] = $payment_method; + $myOrder->save(); + } -- GitLab