Ejemplo n.º 1
0
 function shipping()
 {
     $sale = $this->system->loadModel('trading/sale');
     $trading = $sale->getCartObject($this->cart, $GLOBALS['runtime']['member_lv'], true);
     $shipping = $this->system->loadModel('trading/delivery');
     $aShippings = $shipping->getDlTypeByArea($_POST['area']);
     foreach ($aShippings as $k => $s) {
         $aShippings[$k]['price'] = cal_fee($s['expressions'], $trading['weight'], $trading['pmt_b']['totalPrice'], $s['price']);
         $s['pad'] == 0 ? $aShippings[$k]['has_cod'] = 0 : ($aShippings[$k]['has_cod'] = 1);
         if ($s['protect'] == 1) {
             $aShippings[$k]['protect'] = true;
         } else {
             $aShippings[$k]['protect'] = false;
         }
     }
     $this->pagedata['shippings'] = $aShippings;
     $this->__tmpl = 'cart/checkout_shipping.html';
     $this->output();
 }
Ejemplo n.º 2
0
 function get_delivery($sid, $areaid = 0)
 {
     set_error_handler(array(&$this, '_ajaxErrorHandler'));
     $objPo = $this->system->loadModel('purchase/order_po');
     $aShipping = $objPo->getDlyTypeByArea($sid, $areaid);
     $aOrder['delivery'] = $aShipping['data_info'];
     $aOrder['total_amount'] = 0;
     $aOrder['total_weight'] = 0;
     $product = $this->system->loadModel('goods/products');
     foreach ($_POST['dealer_bn'] as $k => $v) {
         $aTmp = $product->getFieldByBn($v, array('weight'));
         $aOrder['total_amount'] += $_POST['price'][$k] * $_POST['nums'][$k];
         $aOrder['total_weight'] += $aTmp['weight'] * $_POST['nums'][$k];
     }
     foreach ($aShipping['data_info'] as $k => $s) {
         $aOrder['delivery'][$k]['price'] = cal_fee($s['expressions'], $aOrder['total_weight'], $aOrder['total_amount'], $s['price']);
         if ($s['protect'] == 1) {
             $aOrder['delivery'][$k]['protect_fee'] = max($aOrder['total_amount'] * $s['protect_rate'], $s['minprice']);
         } else {
             $aOrder['delivery'][$k]['protect_fee'] = 0;
         }
     }
     $this->pagedata['order'] = $aOrder;
     $this->__tmpl = 'order/po_delivery.html';
     $this->output();
 }
Ejemplo n.º 3
0
 function checkoutInfo(&$aCart, &$aMember, $aParam = null)
 {
     //$sale = &$this->system->loadModel('trading/sale');
     $sale =& new sale_mdl();
     $trading = $sale->getCartObject($aCart, $aMember['member_lv_id'], true);
     $trading['total_amount'] = $trading['totalPrice'];
     if ($aParam['shipping_id']) {
         $shipping =& $this->system->loadModel('trading/delivery');
         $aShip = $shipping->getDlTypeByArea($aParam['area'], 0, $aParam['shipping_id']);
         if ($trading['exemptFreight'] == 1) {
             $trading['cost_freight'] = 0;
         } else {
             $trading['cost_freight'] = cal_fee($aShip[0]['expressions'], $trading['weight'], $trading['pmt_b']['totalPrice'], $aShip[0]['price']);
         }
         $trading['shipping_id'] = $aParam['shipping_id'];
         if ($aParam['is_protect'] == 'true' && $aShip[0]['protect']) {
             $trading['is_protect'] = 1;
             $trading['cost_protect'] = max($aShip[0]['protect_rate'] * $trading['totalPrice'], $aShip[0]['minprice']);
         }
         $trading['total_amount'] += $trading['cost_freight'] + $trading['cost_protect'];
     }
     if ($this->system->getConf('site.trigger_tax')) {
         $trading['is_tax'] = 1;
         if (isset($aParam['is_tax']) && $aParam['is_tax'] == 'true') {
             $trading['tax_checked'] = 'checked';
             $trading['cost_tax'] = $trading['totalPrice'] * $this->system->getConf('site.tax_ratio');
             $trading['total_amount'] += $trading['cost_tax'];
         }
         $trading['tax_rate'] = $this->system->getConf('site.tax_ratio');
     }
     if ($aParam['payment']) {
         $payment =& $this->system->loadModel('trading/payment');
         $aPay = $payment->getPaymentById($aParam['payment']);
         $config = unserialize($aPay['config']);
         if ($config['method'] != 2) {
             $trading['cost_payment'] = $aPay['fee'] * $trading['total_amount'];
         } else {
             $trading['cost_payment'] = $config['fee'];
         }
         $trading['total_amount'] += $trading['cost_payment'];
     }
     $trading['score_g'] = $trading['pmt_b']['totalGainScore'];
     $trading['pmt_amount'] = $trading['pmt_b']['totalPrice'] - $trading['totalPrice'];
     $trading['member_id'] = $aMember['member_id'];
     $order =& $this->system->loadModel('trading/order');
     $newNum = $order->getOrderDecimal($trading['total_amount']);
     $trading['discount'] = $trading['total_amount'] - $newNum;
     $trading['total_amount'] = $newNum;
     $oCur =& $this->system->loadModel('system/cur');
     $currency = $oCur->getcur($aParam['cur']);
     if ($currency['cur_code']) {
         $trading['cur_rate'] = $currency['cur_rate'];
     } else {
         $trading['cur_rate'] = 1;
     }
     $trading['final_amount'] = $newNum * $trading['cur_rate'];
     $trading['cur_sign'] = $currency['cur_sign'];
     $trading['cur_display'] = $this->system->request['cur'];
     $trading['cur_code'] = $currency['cur_code'];
     return $trading;
 }
Ejemplo n.º 4
0
 function create(&$aCart, &$aMember, &$aDelivery, &$aPayment, &$minfo, &$postInfo)
 {
     //$oSale = &$this->system->loadModel('trading/sale');
     $oSale =& new sale_mdl();
     $trading = $oSale->getCartObject($aCart, $aMember['member_lv_id'], true, true);
     //保存收货人地址
     $this->_saveAddr($aMember['member_id'], $aDelivery);
     $iProduct = 0;
     if (is_array($trading['products']) && count($trading['products'])) {
         $objGoods =& $this->system->loadModel('trading/goods');
         //生成订单前检查库存
         $objCart =& $this->system->loadModel('trading/cart');
         $arr = array();
         $aLinkId = array();
         foreach ($trading['products'] as $k => $p) {
             $aStore = $objGoods->getFieldById($p['goods_id'], array('marketable', 'disabled'));
             if ($aStore['marketable'] == 'false' || $aStore['disabled'] == 'true') {
                 /**
                  * trigger Smarty error
                  *
                  * @param string $error_msg
                  * @param integer $error_type
                  */
                 trigger_error($p['name'] . __('商品未发布不能下单。'), E_USER_ERROR);
                 return false;
                 exit;
             }
             if ($this->freez_time() == 'order') {
                 if (!$objCart->_checkStore($p['product_id'], $p['nums'])) {
                     trigger_error("商品“" . $p['name'] . "”库存不足", E_USER_ERROR);
                     return false;
                     exit;
                 }
             }
             //判断配件库存to检查变量
             if (count($p['adjList'])) {
                 foreach ($p['adjList'] as $pid => $num) {
                     if (!$objCart->_checkStore($pid, $num * $p['nums'])) {
                         trigger_error("商品配件库存不足", E_USER_ERROR);
                         return false;
                         exit;
                     }
                 }
             }
             $arr[] = $p['name'] . '(' . $p['nums'] . ')';
             $this->itemnum += $p['nums'];
             $aLinkId[] = $p['goods_id'];
             $trading['products'][$k]['addon']['minfo'] = $minfo[$p['product_id']];
             //将商品用户信息存入addon
             $trading['products'][$k]['minfo'] = $minfo[$p['product_id']];
             //将商品用户信息存入addon
             if ($p['goods_id']) {
                 $aP[] = $p['goods_id'];
             }
             $iProduct++;
         }
     }
     if ($trading['package'] || $trading['gift_e']) {
         $otherPhysical = true;
     } else {
         $otherPhysical = false;
     }
     if (count($aP) || $otherPhysical) {
         $return = $this->checkOrderDelivery($aP, $aDelivery, $otherPhysical, $aMember['member_id']);
         //检测实体商品配送信息的合法性
         if ($return) {
             $aDelivery['is_delivery'] = $return;
             if ($return == 'Y' && empty($aDelivery['shipping_id'])) {
                 trigger_error(__("提交不成功,请选择配送方式"), E_USER_ERROR);
                 return false;
                 exit;
             }
         } else {
             trigger_error(__("对不起,请完整填写配送信息"), E_USER_ERROR);
             return false;
             exit;
         }
     }
     $iPackage = 0;
     if (is_array($trading['package']) && count($trading['package'])) {
         $objCart =& $this->system->loadModel('trading/cart');
         foreach ($trading['package'] as $v) {
             if (!$objCart->_checkStore($v['goods_id'], $v['nums'])) {
                 trigger_error(__("捆绑商品库存不足"), E_USER_ERROR);
                 return false;
                 exit;
             }
             $iPackage++;
             $arr[] = $v['name'] . '(' . $v['nums'] . ')';
         }
     }
     if (is_array($trading['gift_e']) && count($trading['gift_e'])) {
         foreach ($trading['gift_e'] as $v) {
             $arr[] = $v['name'] . '(' . $v['nums'] . ')';
         }
     }
     if ($iProduct + $iPackage + count($trading['gift_p']) + count($trading['gift_e']) == 0) {
         trigger_error(__("购物车中无有效商品!"), E_USER_ERROR);
         return false;
     }
     //        $objProduct->updateRate($aLinkId);    //更新商品推荐度
     $oCur =& $this->system->loadModel('system/cur');
     $tdelivery = explode(':', $aDelivery['ship_area']);
     $area_id = $tdelivery[count($tdelivery) - 1];
     $oDelivery =& $this->system->loadModel('trading/delivery');
     $rows = $oDelivery->getDlTypeByArea($area_id, $trading['weight'], $aDelivery['shipping_id']);
     if ($trading['exemptFreight'] == 1) {
         //[exemptFreight] => 1免运费
         $aDelivery['cost_freight'] = 0;
     } else {
         $trading['cost_freight'] = $oCur->formatNumber(cal_fee($rows[0]['expressions'], $trading['weight'], $trading['pmt_b']['totalPrice'], $rows[0]['price']), false);
     }
     $trading['cost_freight'] = is_null($trading['cost_freight']) ? 0 : $trading['cost_freight'];
     if ($aDelivery['is_protect'][$aDelivery['shipping_id']] && $rows[0]['protect'] == 1) {
         $aDelivery['cost_protect'] = $oCur->formatNumber(max($trading['totalPrice'] * $rows[0]['protect_rate'], $rows[0]['minprice']), false);
         $aDelivery['is_protect'] = 'true';
     } else {
         $aDelivery['cost_protect'] = 0;
         $aDelivery['is_protect'] = 'false';
     }
     if ($aPayment['payment'] > 0 || $aPayment['payment'] == -1) {
         $oPayment =& $this->system->loadModel('trading/payment');
         $aPay = $oPayment->getPaymentById($aPayment['payment']);
         if ($aPay['pay_type'] == 'DEPOSIT' && $aMember['member_id'] == "") {
             trigger_error(__("未登录客户不能选择预存款支付!"), E_USER_ERROR);
             return false;
         }
         $config = unserialize($aPay['config']);
         $aPayment['fee'] = $aPay['fee'];
         if ($config['method'] == 2) {
             $aPayment['fee'] = $config['fee'];
             $aPayment['method'] = $config['method'];
         }
     } else {
         trigger_error(__("提交不成功,未选择支付方式!"), E_USER_ERROR);
         return false;
     }
     $currency = $oCur->getcur($aPayment['currency'], true);
     $aPayment['currency'] = $currency['cur_code'];
     if (!$this->checkPoint($aMember['member_id'], $trading)) {
         return false;
     }
     if (!$this->checkGift($trading['gift_p'])) {
         unset($trading['gift_p']);
         //直接不给
     }
     $orderInfo = $trading;
     $orderInfo['order_id'] = $this->gen_id();
     $orderInfo['cur_rate'] = $currency['cur_rate'] > 0 ? $currency['cur_rate'] : 1;
     $orderInfo['tostr'] = implode(',', $arr);
     $orderInfo['itemnum'] = $this->itemnum;
     getRefer($orderInfo);
     //推荐下单
     $aDelivery['ship_time'] = ($aDelivery['day'] == 'specal' ? $aDelivery['specal_day'] : $aDelivery['day']) . ' ' . $aDelivery['time'];
     $orderInfo = array_merge($orderInfo, $aDelivery, $aPayment);
     if ($aMember) {
         $orderInfo = array_merge($orderInfo, $aMember);
     }
     //限时抢购 减少库存
     $scareModel = new mdl_scare();
     foreach ($orderInfo['products'] as $k => $p) {
         $scareInfo = $scareModel->getFieldByGoodsId($p['goods_id']);
         if ($scareInfo && $scareInfo['iflimit'] == 1 && $scareInfo['e_time'] > strtotime('now') && $scareInfo['s_time'] < strtotime('now') && $scareInfo['scare_count'] > 0) {
             //限时抢购于系统关联预展库存 2011-7-7 by zhangxuehui
             $store_time_type = $this->system->getConf('system.store.time');
             $p['nums'] = $store_time_type == '1' || $store_time_type == '0' ? $p['nums'] : '0';
             //限时抢购于系统关联预展库存 2011-7-7 by zhangxuehui
             $scareModel->reduceCount($p['goods_id'], $p['nums']);
         }
     }
     //end
     return $this->save($orderInfo, true, $postInfo);
 }
Ejemplo n.º 5
0
 function shipping()
 {
     if ($_POST['isgroupbuy'] == 2) {
         require_once PLUGIN_DIR . '/app/group_activity/group_activity_shop_ctl_cart.php';
         $group_activity_ctl_product = new group_activity_shop_ctl_cart();
         $group_activity_ctl_product->shipping();
     } else {
         //$sale = &$this->system->loadModel('trading/sale');
         $sale =& new sale_mdl();
         $trading = $sale->getCartObject($this->cart, $GLOBALS['runtime']['member_lv'], true);
         $shipping =& $this->system->loadModel('trading/delivery');
         $aShippings = $shipping->getDlTypeByArea($_POST['area']);
         foreach ($aShippings as $k => $s) {
             $aShippings[$k]['price'] = cal_fee($s['expressions'], $trading['weight'], $trading['pmt_b']['totalPrice'], $s['price']);
             $s['pad'] == 0 ? $aShippings[$k]['has_cod'] = 0 : ($aShippings[$k]['has_cod'] = 1);
             if ($s['protect'] == 1) {
                 $aShippings[$k]['protect'] = true;
             } else {
                 $aShippings[$k]['protect'] = false;
             }
         }
         $this->pagedata['shippings'] = $aShippings;
         $this->display('cart/checkout_shipping.html');
     }
 }
Ejemplo n.º 6
0
 function shipping()
 {
     $aCart = $_POST['aCart'];
     $aMember = $_SESSION['order_user'];
     $sale = $this->system->loadModel('trading/sale');
     $trading = $sale->getCartObject($aCart, $aMember['member_lv_id'], true);
     $shipping = $this->system->loadModel('trading/delivery');
     $aShippings = $shipping->getDlTypeByArea($_POST['area']);
     foreach ($aShippings as $k => $s) {
         $aShippings[$k]['price'] = cal_fee($s['expressions'], $trading['weight'], $trading['pmt_b']['totalPrice'], $s['price']);
         if ($s['pad'] == 0 || $s['has_cod'] == 0) {
             $aShippings[$k]['has_cod'] = 0;
         }
         if ($s['protect'] == 1) {
             $aShippings[$k]['protect'] = max($trading['totalPrice'] * $s['protect_rate'], $s['minprice']);
         } else {
             $aShippings[$k]['protect'] = false;
         }
     }
     $this->pagedata['shippings'] = $aShippings;
     $this->setView('shop:cart/checkout_shipping.html');
     $this->output();
 }