/** * @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 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; }
/** * @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; }