public function register() { $customer = new customer_entity(); $customer->customer_email = $this->customer_email; $customer->customer_active = 1; $customer->customer_default_group_ID = 1; $customer->customer_first_name = $this->customer_firstname; $customer->customer_last_name = $this->customer_lastname; $customer->customer_gender = $this->customer_gender; $customer->customer_password = $this->customer_pwd; if ($customer->save()) { customer_group::addment($customer->customer_ID, null, 1); return true; } return false; }
public function loadModel() { if ($this->_model == null) { if (isset($_GET['id'])) { $condition = ''; $this->_model = customer_entity::model()->findByPk($_GET['id'], $condition); } if ($this->_model == null) { throw new CHttpException(404, "The requested page does not exist!"); } } return $this->_model; }
public function actionCreate() { $this->htmlOption = array('class' => 'icon-head head-products', 'header' => "添加客户地址", 'button' => array(array('class' => 'scalable save', 'id' => 'form-save', 'header' => '保存'))); $model = new address_entity(); if ($_POST['address']) { $model->attributes = $_POST['address']; $model->address_customer_email = $_POST['address']['address_customer_email']; if ($customer = customer_entity::model()->findByAttributes(array('customer_email' => $model->address_customer_email))) { $model->address_customer_ID = $customer->customer_ID; if ($model->save()) { $this->redirect(array('index')); } } } $this->constructScript('create'); $this->render('create', array('model' => $model)); }
public function authenticate() { $customer = customer_entity::model()->findByAttributes(array('customer_email' => $this->email)); if ($customer === null) { $this->errorCode = self::ERROR_EMAIL_INVALID; } else { if (!$customer->validatePassword($this->password)) { $this->errorCode = self::ERROR_PASSWORD_INVALID; } else { $this->_id = $customer->customer_ID; $this->name = $customer->customer_first_name . ' ' . $customer->customer_last_name; $names['cart_ID'] = Yii::app()->user->getState('cart_ID'); $names['guest_ID'] = Yii::app()->user->getState('guest_ID'); $names['currency_ID'] = Yii::app()->user->getState('currency_ID'); $this->setPersistentStates($names); $this->errorCode = self::ERROR_NONE; } } return !$this->errorCode; }
public function actionCustomerEmail() { if (isset($_GET['q']) && ($keyword = trim($_GET['q'])) !== '') { $email = customer_entity::model()->suggestEmail($keyword); if ($email !== array()) { echo implode("\n", $email); } } }
?> <div id="address_general_content" class="content_col"> <div class="box-left"> <!--Order Information--> <div class="entry-edit"> <div class="entry-edit-head"> <h4 class="icon-head head-account">客户地址信息</h4> </div> <div class="fieldset"> <table cellspacing="0" class="form-list"> <tbody> <tr> <td class="label"> <label for="email">客户Email<span class="required">*</span></label></td> <td class="value"> <?php echo customer_entity::model()->findByPk($model->address_customer_ID)->customer_email; ?> </td> <td class="scope-label"> <span class="nobr"></span> </td> <td><small></small></td> </tr> <tr> <td class="label"> <label for="alias">名称<span class="required">*</span></label></td> <td class="value"> <?php echo $form->textField($model, 'address_alias', array('class' => 'required-entry required-entry input-text', 'name' => 'address[address_alias]', 'id' => 'alias')); ?> </td>
public function actionViewOrder() { $customer = customer_entity::model()->findByPk(Yii::app()->user->getId()); if ($order == null) { if (isset($_GET['id'])) { $condition = 'order_customer_ID=' . $customer->customer_ID; $order = sales_order::model()->findByPk($_GET['id'], $condition); } if ($order == null) { throw new CHttpException(404, "The requested page does not exist!"); } } $this->render('viewOrder', array('customer' => $customer, 'model' => $order)); }
public function validateOrder($cart_ID, $order_status, $amountPaid, $paymentMethod = 'Unknown', $message = NULL, $extraVars = array(), $currency_special = NULL, $dont_touch_amount = false) { $cart = cart::model()->findByPk(intval($cart_cart)); if ($cart and !$cart->orderExists()) { $order = new order_entity(); $customer = customer_entity::model()->findByPk($cart->cart_customer_ID); $currency = currency::model()->findByPK($cart->cart_currency_ID); $order->order_carrier_ID = intval($cart->cart_carrier_ID); $order->order_address_ID = intval($cart->cart_address_ID); $order->order_cart_ID = intval($cart->cart_ID); $order->order_currency_ID = intval($cart->cart_currency_ID); $order->order_customer_ID = intval($cart->cart_customer_ID); $order->order_salt = $customer->customer_salt; $order->order_payment_method = $paymentMethod; $amountPaid = !$dont_touch_amount ? round(floatval($amountPaid), 2) : $amountPaid; $order->order_total_paid = $amountPaid; $order->order_total_discount = product_entity::decoratePrice($cart->getOrderTotal(2)); $order->order_total_products = product_entity::decoratePrice($cart->getOrderTotal(1)); $order->order_total_shipping = product_entity::decoratePrice($cart->getOrderShippingCost()); $order->order_grand = product_entity::decoratePrice($cart->getOrderTotal()); $order->order_delivery_ID = 0; $order->order_payment_date = date('Y-m-d H:i:s'); $order->order_delivery_date = '0000-00-00 00:00:00'; if ($order->order_total_paid < $order->order_grand) { $order_status = order_entity::PaymentError; } $order->order_status = $order_status; $res = $order->save(); if ($res and $order->order_ID) { //order detail foreach ($cart->products as $product) { $quantity = $cart->containProduct($row->product_ID); $orderDetail = new order_detail(); $orderDetail->detail_order_ID = $order->order_ID; $orderDetail->detail_product_ID = $product->product_ID; $orderDetail->detail_product_name = $product->product_name; if ($quantity['quantity'] > 1) { $discount_ID = discount_quantity::validateQuantityDiscount($product->product_ID, $quantity['quantity']); if ($discount_ID) { $discountQuantity = discount_quantity::model()->findByPk($discount_ID); $orderDetail->detail_quantity_discount = $currency->convert($product->product_price - $discountQuantity->applyRule($product->product_price)); $orderDetail->detail_quantity_discount_applied = 1; $orderDetail->detail_reducetion_percent = 0; $orderDetail->detail_reducetion_amount = 0; $orderDetail->detail_product_price = $currency->convert($product->product_price - $orderDetail->detail_quantity_discount); } } else { if ($product->isReduction()) { if ($product->product_reducetion_percent) { $orderDetail->detail_reducetion_percent = $currency->convert(floatval($product->product_price) * floatval($product->product_reducetion_percent / 100), 2); $orderDetail->detail_reducetion_amount = 0; $orderDetail->detail_quantity_discount = 0; $orderDetail->detail_quantity_discount_applied = 2; $orderDetail->detail_product_price = $currency->convert($product->product_price - $orderDetail->detail_reducetion_percent); } else { $orderDetail->detail_reducetion_amount = $currency->convert($product->product_reducetion_amount); $orderDetail->detail_reducetion_percent = 0; $orderDetail->detail_quantity_discount = 0; $orderDetail->detail_quantity_discount_applied = 2; $orderDetail->detail_product_price = $currency->convert($product->product_price - $orderDetail->detail_reducetion_amount); } } else { $orderDetail->detail_reducetion_amount = 0; $orderDetail->detail_reducetion_percent = 0; $orderDetail->detail_quantity_discount = 0; $orderDetail->detail_quantity_discount_applied = 2; $orderDetail->detail_product_price = $currency->convert($product->product_price); } } $orderDetail->order_weight = floatval($product->product_weight); $orderDetail->save(); //update product info if ($order->order_status != order_entity::PaymentError and $order->order_status != order_entity::Canceled) { $product->product_quantity -= $quantity['quantity']; $product->save(); } } //order_discount if (sizeof($discounts = cart_discount::items($cart->cart_ID)) >= 1) { foreach ($discounts as $discount) { $orderDiscount = new order_discount(); $orderDiscount->order_ID = $order->order_ID; $orderDiscount->discount_ID = $discount['discount_ID']; $orderDiscount->discount_name = $discount['discount_name']; if ($discount['discount_type'] == 3) { $orderDiscount->discount_value = 0; } else { if ($discount['discount_type'] == 2) { $orderDiscount->discount_value = $currency->convert($discount['discount_value']); } else { if ($discounts['discount_type'] == 1) { $orderDiscount->discount_value = $currency->convert($order->order_total_products * ($discount['discount_value'] / 100)); } } } } } /** * To do list * 1.Email confirm * 2.Product sales * 3.Order message * 4.order History * */ } } }