/** * @params array sdf * @params array * @params string * @params string message */ private function _chgdata(&$sdf, &$order_data, $member_indent = '') { $now = time(); $objCurrency = app::get('ectools')->model("currency")->getcur($sdf['payment']['currency']); // 得到shipping name $objDlytype = $this->app->model("dlytype"); $shipping_name = $objDlytype->dump($sdf['delivery']['shipping_id'], 'dt_name'); $order_data = array('order_id' => $order_data['order_id'], 'member_id' => $order_data['member_id'], 'confirm' => 'N', 'status' => 'active', 'pay_status' => '0', 'ship_status' => '0', 'is_delivery' => 'Y', 'createtime' => $now, 'last_modified' => $now, 'memo' => $sdf['memo'], 'ip' => $_SERVER['REMOTE_ADDR'], 'title' => '订单明细介绍', 'shipping' => array('shipping_id' => $sdf['delivery']['shipping_id'], 'is_protect' => $sdf['delivery']['is_protect'][$sdf['delivery']['shipping_id']] ? 'true' : 'false', 'shipping_name' => $shipping_name['dt_name'], 'cost_shipping' => 10, 'cost_protect' => 0), 'payinfo' => array('pay_app_id' => $sdf['payment']['pay_app_id'] != '-1' ? $sdf['payment']['pay_app_id'] : '货到付款'), 'currency' => $sdf['payment']['currency'], 'cur_rate' => $objCurrency['cur_rate'], 'is_tax' => $sdf['payment']['is_tax'] ? 'true' : 'false', 'tax_title' => $sdf['payment']['tax_company']); $obj_mCart = $this->app->model('cart'); if ($member_indent) { $data = $obj_mCart->get_cookie_cart_arr($member_indent); $objCarts = $obj_mCart->get_cart_object($data); } else { $objCarts = $this->app->model('cart')->get_objects(true); } // 购物车是否为空 $is_empty = $this->app->model('cart')->is_empty($objCarts); if ($is_empty) { $msg = '购物车为空!'; return false; } $order_data['weight'] = $objCarts['subtotal_weight']; $order_data['itemnum'] = $objCarts['items_quantity']; // 计算cart的总费用 $obj_total = new b2c_order_total(); $sdf_order = array('payment' => $sdf['payment']['pay_app_id'], 'shipping_id' => $sdf['delivery']['shipping_id'], 'is_protect' => $sdf['delivery']['is_protect'][$sdf['delivery']['shipping_id']] ? $sdf['delivery']['is_protect'][$sdf['delivery']['shipping_id']] : 0, 'currency' => $sdf['payment']['currency'], 'is_tax' => $sdf['payment']['is_tax'] ? $sdf['payment']['is_tax'] : 'false', 'tax_company' => $sdf['payment']['tax_company'] ? $sdf['payment']['tax_company'] : '', 'area' => $sdf['delivery']['ship_area']); $order_detail = $obj_total->payment_detail($this->app->controller('site_order'), $objCarts, $sdf_order); // 订单显示方式 $system_money_decimals = $this->app->getConf('system.money.decimals'); $system_money_operation_carryset = $this->app->getConf('system.money.operation.carryset'); $order_data['cost_item'] = $this->objMath->formatNumber($order_detail['cost_item'], $system_money_decimals, $system_money_operation_carryset); $order_data['cost_tax'] = $this->objMath->formatNumber($this->objMath->number_multiple(array($this->app->getConf('site.tax_ratio'), $order_detail['cost_item'])), $system_money_decimals, $system_money_operation_carryset); //$order_data['tax_company'] = $sdf['payment']['tax_company']; $order_data['shipping']['cost_shipping'] = $this->objMath->formatNumber($order_detail['cost_freight'], $system_money_decimals, $system_money_operation_carryset); $order_data['shipping']['cost_protect'] = $this->objMath->formatNumber($order_detail['cost_protect'], $system_money_decimals, $system_money_operation_carryset); $order_data['payinfo']['cost_payment'] = $this->objMath->formatNumber($order_detail['cost_payment'], $system_money_decimals, $system_money_operation_carryset); $order_data['total_amount'] = $this->objMath->formatNumber($order_detail['total_amount'], $system_money_decimals, $system_money_operation_carryset); $order_data['cur_amount'] = app::get('ectools')->model("currency")->changer_odr($order_data['total_amount'], $this->app->getConf("site.currency.defalt_currency"), true, false, $system_money_decimals, $system_money_operation_carryset); $order_data['pmt_goods'] = $this->objMath->formatNumber($objCarts['discount_amount_prefilter'], $system_money_decimals, $system_money_operation_carryset); $order_data['pmt_order'] = $this->objMath->formatNumber($objCarts['discount_amount_order'], $system_money_decimals, $system_money_operation_carryset); $order_data['discount'] = $order_detail['discount']; $order_data['payed'] = "0.00"; $order_data['score_u'] = $objCarts['subtotal_consume_score']; $order_data['score_g'] = $objCarts['subtotal_gain_score']; $site_get_policy_method = $this->app->getConf('site.get_policy.method'); if ($site_get_policy_method == '2') { $site_get_rate_method = $this->app->getConf('site.get_rate.method'); $other_fee = $this->objMath->number_plus(array($order_detail['cost_freight'], $order_detail['cost_payment'])); $other_fee = $this->objMath->number_multiple(array($other_fee, $site_get_rate_method)); $order_data['score_g'] = round($this->objMath->number_plus(array($order_data['score_g'], $other_fee))); } $order_data['consignee'] = array('name' => $sdf['delivery']['ship_name'], 'addr' => $sdf['delivery']['ship_addr_area'] . $sdf['delivery']['ship_addr'], 'zip' => $sdf['delivery']['ship_zip'], 'telephone' => $sdf['delivery']['ship_tel'], 'mobile' => $sdf['delivery']['ship_mobile'], 'email' => $sdf['delivery']['ship_email'], 'area' => $sdf['delivery']['ship_area'], 'r_time' => ($sdf['delivery']['specal_day'] ? $sdf['delivery']['specal_day'] : $sdf['delivery']['day']) . $sdf['delivery']['time'], 'meta' => array()); $this->_order_items($sdf, $order_data, $objCarts['object']); if (isset($objCarts['promotion']) && $objCarts['promotion']) { $this->_order_pmts($order_data, $objCarts['promotion']); } }
/** * 订单标准数据生成. */ public function generate(&$order_sdf, $cart_result = array(), &$msg = '') { $new_order_id = $order_sdf['order_id'] ? $order_sdf['order_id'] : app::get('b2c')->model('orders')->apply_id(); $obj_total = new b2c_order_total(); $total = $obj_total->detail($order_sdf, $cart_result); $sdf = array('order_id' => $new_order_id, 'weight' => $cart_result['weight'], 'quantity' => $cart_result['goods_count'], 'ip' => base_request::get_remote_addr(), 'memberlv_discount' => $cart_result['member_discount_amount'], 'pmt_goods' => $cart_result['goods_promotion_discount_amount'], 'pmt_order' => $cart_result['order_promotion_discount_amount'], 'finally_cart_amount' => $cart_result['finally_cart_amount'], 'score_g' => $total['gain_score'], 'order_total' => $total['order_total'], 'cost_tax' => $total['cost_tax'], 'cost_protect' => $total['cost_protect'], 'cost_payment' => $total['cost_payment'], 'cost_freight' => $total['cost_freight']); $order_sdf = array_merge($order_sdf, $sdf); //发票参数处理 if ($order_sdf['need_invoice'] != 'true') { $order_sdf['need_invoice'] = 'false'; unset($order_sdf['invoice_title']); } else { if (!isset($order_sdf['invoice_addon']) || !is_array($order_sdf['invoice_addon'])) { $order_sdf['invoice_addon'] = array(); } //发票未开出 $order_sdf['invoice_addon'] = array_merge($order_sdf['invoice_addon'], array('invoice_out' => 'false')); } //组织订单明细-[商品] foreach ($cart_result['objects']['goods'] as $key => $object) { if ($object['disabled'] == 'true') { continue; } $product = $object['item']['product']; //has_many order_items $order_sdf['items'][] = array('order_id' => $new_order_id, 'product_id' => $product['product_id'], 'goods_id' => $product['goods_id'], 'bn' => $product['bn'], 'name' => $product['name'], 'spec_info' => $product['spec_info'], 'price' => $product['price'], 'member_lv_price' => $product['member_lv_price'], 'buy_price' => $product['buy_price'], 'amount' => $this->obj_math->number_multiple(array($product['buy_price'], $object['quantity'])), 'nums' => $object['quantity'], 'weight' => $this->obj_math->number_multiple(array($product['weight'], $object['quantity'])), 'image_id' => $product['image_id']); $cart_objects[$object['obj_ident']] = $object; } //组织订单明细-[商品促销规则] foreach ($cart_result['promotions']['goods'] as $key => $pmts) { foreach ($pmts as $value) { $order_sdf['promotions'][] = array('rule_id' => $value['rule_id'], 'order_id' => $new_order_id, 'product_id' => $cart_objects[$key]['item']['product']['product_id'], 'pmt_type' => 'goods', 'pmt_tag' => $value['tag'], 'pmt_description' => $value['desc'], 'pmt_solution' => $value['solution'], 'pmt_save' => $value['save']); } } //组织订单明细-[订单促销规则] foreach ($cart_result['promotions']['order'] as $key => $value) { $order_sdf['promotions'][] = array('rule_id' => $value['rule_id'], 'order_id' => $new_order_id, 'pmt_type' => 'order', 'pmt_tag' => $value['tag'], 'pmt_description' => $value['desc'], 'pmt_solution' => $value['solution'], 'pmt_save' => $value['save']); } //TODO 优惠券数据 // 订单创建前之行的方法 $services = vmc::servicelist('b2c.order.create.before'); if ($services) { foreach ($services as $service) { $flag = $service->exec($order_sdf, $cart_result, $msg); if (!$flag) { return false; } } } return true; }
public function total() { $this->_common(false, $_POST['isfastbuy']); $obj_total = new b2c_order_total(); $sdf_order = $_POST; if ($_POST) { $payment = json_decode($_POST['payment']['pay_app_id'], true); $shipping = json_decode($_POST['shipping'], true); $address = json_decode($_POST['address'], true); $address_area = explode(':', $address['area']); } $sdf_order['cur'] = $_POST['payment']['currency']; $sdf_order['shipping_id'] = $shipping['id']; $sdf_order['is_protect'] = $_POST['is_protect']; $sdf_order['is_tax'] = $_POST['payment']['is_tax']; $sdf_order['tax_type'] = $_POST['payment']['tax_type']; $sdf_order['payment'] = $payment['pay_app_id']; $arrMember = $this->get_current_member(); $sdf_order['member_id'] = $arrMember['member_id']; $sdf_order['area_id'] = $address_area[2] ? $address_area[2] : $address['area']; $sdf_order['dis_point'] = floor($_POST['point']['score']); $arr_cart_object = $this->pagedata['aCart']; $this->set_header(); echo $obj_total->order_total_method($this, $arr_cart_object, $sdf_order, "false", "wap/cart/checkout/checkout_total.html"); exit; }
public function total() { switch ($_REQUEST['isfastbuy']) { case 'true': $isfastbuy = true; break; case 'group': $isfastbuy = 'group'; break; default: $isfastbuy = false; break; } $this->_common(false, $isfastbuy); $obj_total = new b2c_order_total(); $sdf_order = $_POST; if ($_POST) { $payment = json_decode($_POST['payment']['pay_app_id'], true); $shipping = json_decode($_POST['shipping'], true); $address = json_decode($_POST['address'], true); $address_area = explode(':', $address['area']); } $sdf_order['cur'] = $_POST['payment']['currency']; $sdf_order['shipping_id'] = $shipping['id']; $sdf_order['is_protect'] = $_POST['is_protect']; $sdf_order['is_tax'] = $_POST['payment']['is_tax']; $sdf_order['tax_type'] = $_POST['payment']['tax_type']; $sdf_order['payment'] = $payment['pay_app_id']; $member_id = kernel::single('b2c_user_object')->get_member_id(); $sdf_order['member_id'] = $member_id; $sdf_order['area_id'] = $address_area[2] ? $address_area[2] : $address['area']; $sdf_order['dis_point'] = floor($_POST['point']['score']); $arr_cart_object = $this->pagedata['aCart']; //$this->set_header(); $payment_detail = $obj_total->payment_detail($this, $arr_cart_object, $sdf_order); return $payment_detail; }
public function total() { $this->_common(); $obj_total = new b2c_order_total(); $sdf_order = $_POST; $arrMember = $this->get_current_member(); $sdf_order['member_id'] = $arrMember['member_id']; $arr_cart_object = $this->mCart->get_objects(true); //$sdf_order = array('payment'=>$_POST['payment'],'shipping_id'=>$_POST['shipping_id'],'is_protect'=>$_POST['is_protect'],'currency'=>$_POST['cur'], 'cart'=>$this->pagedata['aCart'], 'is_tax'=>$_POST['is_tax'],'tax_company'=>$_POST['tax_company'],'area'=>$_POST['area']); echo $obj_total->order_total_method($this, $arr_cart_object, $sdf_order); exit; }
/** * @params array sdf * @params array * @params string * @params string message * @return boolean true or false */ private function _chgdata(&$sdf, &$order_data, $member_indent = '', &$msg = '', $aCart = array()) { $now = time(); $objCurrency = app::get('ectools')->model("currency")->getcur($sdf['payment']['currency']); // 得到shipping name $objDlytype = $this->app->model("dlytype"); $shipping_name = $objDlytype->dump($sdf['delivery']['shipping_id'], 'dt_name'); $order_data = array('order_id' => $order_data['order_id'], 'member_id' => $order_data['member_id'], 'confirm' => 'N', 'status' => 'active', 'pay_status' => '0', 'ship_status' => '0', 'is_delivery' => 'Y', 'createtime' => $now, 'last_modified' => $now, 'memo' => $sdf['memo'], 'ip' => $_SERVER['REMOTE_ADDR'], 'title' => app::get('b2c')->_('订单明细介绍'), 'shipping' => array('shipping_id' => $sdf['delivery']['shipping_id'], 'is_protect' => $sdf['delivery']['is_protect'][$sdf['delivery']['shipping_id']] ? 'true' : 'false', 'shipping_name' => $shipping_name['dt_name'], 'cost_shipping' => 10, 'cost_protect' => 0), 'payinfo' => array('pay_app_id' => $sdf['payment']['pay_app_id']), 'currency' => $sdf['payment']['currency'], 'cur_rate' => $objCurrency['cur_rate'], 'is_tax' => $sdf['payment']['is_tax'] ? $sdf['payment']['is_tax'] : 'false', 'tax_title' => $sdf['payment']['tax_company'], 'tax_content' => $sdf['payment']['tax_content'], 'tax_type' => $sdf['payment']['tax_type']); $objCarts = $aCart; // 购物车是否为空 $is_empty = $this->app->model('cart')->is_empty($objCarts); if ($is_empty) { $msg = app::get('b2c')->_('购物车为空!'); return false; } $order_data['weight'] = $objCarts['subtotal_weight']; $order_data['itemnum'] = $objCarts['items_quantity']; // 计算cart的总费用 $obj_total = new b2c_order_total(); $sdf_order = array('payment' => $sdf['payment']['pay_app_id'], 'shipping_id' => $sdf['delivery']['shipping_id'], 'is_protect' => $sdf['delivery']['is_protect'][$sdf['delivery']['shipping_id']] ? $sdf['delivery']['is_protect'][$sdf['delivery']['shipping_id']] : 0, 'currency' => $sdf['payment']['currency'], 'is_tax' => $sdf['payment']['is_tax'] ? $sdf['payment']['is_tax'] : 'false', 'tax_type' => $sdf['payment']['tax_type'] ? $sdf['payment']['tax_type'] : 'false', 'tax_company' => $sdf['payment']['tax_company'] ? $sdf['payment']['tax_company'] : '', 'tax_content' => $sdf['payment']['tax_content'] ? $sdf['payment']['tax_content'] : '', 'area' => $sdf['delivery']['ship_area']); /** 积分抵扣值的转换 **/ $sdf_order['dis_point'] = $sdf['payment']['dis_point']; $sdf_order['member_id'] = $sdf['member_id']; // 订单创建过程添加项埋点 foreach (kernel::servicelist('b2c.order_add_sdf') as $services) { if (is_object($services)) { if (method_exists($services, 'addElement')) { $services->addElement($sdf_order, $sdf['payment']['tax_type']); } } } $ctl_site_order = $this->app->controller('site_order'); $order_detail = $obj_total->payment_detail($ctl_site_order, $objCarts, $sdf_order); // 订单显示方式 $system_money_decimals = $this->app->getConf('system.money.decimals'); $system_money_operation_carryset = $this->app->getConf('system.money.operation.carryset'); $order_data['cost_item'] = $this->objMath->formatNumber($order_detail['cost_item'], $system_money_decimals, $system_money_operation_carryset); if ($sdf['payment']['is_tax']) { $order_data['cost_tax'] = $this->objMath->formatNumber($order_detail['cost_tax'], $system_money_decimals, $system_money_operation_carryset); } else { $order_data['cost_tax'] = 0; } //$order_data['tax_company'] = $sdf['payment']['tax_company']; $order_data['shipping']['cost_shipping'] = $this->objMath->formatNumber($order_detail['cost_freight'], $system_money_decimals, $system_money_operation_carryset); $order_data['shipping']['cost_protect'] = $this->objMath->formatNumber($order_detail['cost_protect'], $system_money_decimals, $system_money_operation_carryset); $order_data['payinfo']['cost_payment'] = $this->objMath->formatNumber($order_detail['cost_payment'], $system_money_decimals, $system_money_operation_carryset); $order_data['total_amount'] = $this->objMath->formatNumber($order_detail['total_amount'], $system_money_decimals, $system_money_operation_carryset); $order_data['cur_amount'] = app::get('ectools')->model("currency")->changer_odr($order_data['total_amount'], $sdf['payment']['currency'], true, false, $system_money_decimals, $system_money_operation_carryset); $order_data['pmt_goods'] = $this->objMath->formatNumber($objCarts['discount_amount_prefilter'], $system_money_decimals, $system_money_operation_carryset); $order_data['pmt_order'] = $this->objMath->formatNumber($order_detail['pmt_order'], $system_money_decimals, $system_money_operation_carryset); $order_data['discount'] = $this->objMath->number_minus(array(0, $order_detail['discount'])); $order_data['payed'] = "0.00"; $order_data['score_u'] = round($order_detail['totalConsumeScore']); $order_data['score_g'] = round($order_detail['totalGainScore']); $obj_service_change_point = kernel::servicelist('b2c.order_total_change'); if ($obj_service_change_point) { foreach ($obj_service_change_point as $obj_point) { $obj_point->order_summary_change($sdf, $order_data, $system_money_decimals, $system_money_operation_carryset); } } $order_data['consignee'] = array('name' => $sdf['delivery']['ship_name'], 'addr' => $sdf['delivery']['ship_addr'], 'zip' => $sdf['delivery']['ship_zip'], 'telephone' => $sdf['delivery']['ship_tel'], 'mobile' => $sdf['delivery']['ship_mobile'], 'email' => $sdf['delivery']['ship_email'], 'area' => $sdf['delivery']['ship_area'], 'r_time' => ($sdf['delivery']['specal_day'] ? $sdf['delivery']['specal_day'] : $sdf['delivery']['day']) . ',' . $sdf['delivery']['time'], 'meta' => array()); $is_generate = true; $is_generate = $this->_order_items($sdf, $order_data, $objCarts['object'], $msg); if (!$is_generate) { return false; } if (isset($objCarts['promotion']) && $objCarts['promotion']) { if ($objCarts['is_free_shipping'] == true) { if (isset($objCarts['promotion'][$objCarts['free_shipping_rule_type']][$objCarts['free_shipping_rule_id']])) { $objCarts['promotion'][$objCarts['free_shipping_rule_type']][$objCarts['free_shipping_rule_id']]['discount_amount'] = $order_detail['cost_freight']; } } $is_generate = $this->_order_pmts($order_data, $objCarts['promotion'], $msg); if (!$is_generate) { return false; } } return true; }
public function total() { $this->_common(); $obj_total = new b2c_order_total(); $sdf_order = $_POST; $arrMember = $this->get_current_member(); $sdf_order['member_id'] = $arrMember['member_id']; $arr_cart_object = $this->pagedata['aCart']; header("Cache-Control:no-store, no-cache, must-revalidate"); // HTTP/1.1 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // 强制查询etag header('Progma: no-cache'); echo $obj_total->order_total_method($this, $arr_cart_object, $sdf_order); exit; }
/** * 计算订单总计信息 * @param null * @return null */ public function total() { if ($_POST['member_id']) { $member_indent = md5($_POST['member_id'] . kernel::single('base_session')->sess_id()); } else { $member_indent = md5(kernel::single('base_session')->sess_id()); } $obj_mCart = $this->app->model('cart'); $data = $obj_mCart->get_cookie_cart_arr($member_indent); $arr_cart_objects = $obj_mCart->get_cart_object($data); $obj_total = new b2c_order_total(); $sdf_order = $_POST; echo $obj_total->order_total_method($this, $arr_cart_objects, $sdf_order); exit; }