本文整理匯總了PHP中shipping_insure_fee函數的典型用法代碼示例。如果您正苦於以下問題:PHP shipping_insure_fee函數的具體用法?PHP shipping_insure_fee怎麽用?PHP shipping_insure_fee使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了shipping_insure_fee函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: merge_order
/**
* 合並訂單
* @param string $from_order_sn 從訂單號
* @param string $to_order_sn 主訂單號
* @return 成功返回true,失敗返回錯誤信息
*/
function merge_order($from_order_sn, $to_order_sn)
{
/* 訂單號不能為空 */
if (trim($from_order_sn) == '' || trim($to_order_sn) == '') {
return $GLOBALS['_LANG']['order_sn_not_null'];
}
/* 訂單號不能相同 */
if ($from_order_sn == $to_order_sn) {
return $GLOBALS['_LANG']['two_order_sn_same'];
}
/* 取得訂單信息 */
$from_order = order_info(0, $from_order_sn);
$to_order = order_info(0, $to_order_sn);
/* 檢查訂單是否存在 */
if (!$from_order) {
return sprintf($GLOBALS['_LANG']['order_not_exist'], $from_order_sn);
} elseif (!$to_order) {
return sprintf($GLOBALS['_LANG']['order_not_exist'], $to_order_sn);
}
/* 檢查合並的訂單是否為普通訂單,非普通訂單不允許合並 */
if ($from_order['extension_code'] != '' || $to_order['extension_code'] != 0) {
return $GLOBALS['_LANG']['merge_invalid_order'];
}
/* 檢查訂單狀態是否是已確認或未確認、未付款、未發貨 */
if ($from_order['order_status'] != OS_UNCONFIRMED && $from_order['order_status'] != OS_CONFIRMED) {
return sprintf($GLOBALS['_LANG']['os_not_unconfirmed_or_confirmed'], $from_order_sn);
} elseif ($from_order['pay_status'] != PS_UNPAYED) {
return sprintf($GLOBALS['_LANG']['ps_not_unpayed'], $from_order_sn);
} elseif ($from_order['shipping_status'] != SS_UNSHIPPED) {
return sprintf($GLOBALS['_LANG']['ss_not_unshipped'], $from_order_sn);
}
if ($to_order['order_status'] != OS_UNCONFIRMED && $to_order['order_status'] != OS_CONFIRMED) {
return sprintf($GLOBALS['_LANG']['os_not_unconfirmed_or_confirmed'], $to_order_sn);
} elseif ($to_order['pay_status'] != PS_UNPAYED) {
return sprintf($GLOBALS['_LANG']['ps_not_unpayed'], $to_order_sn);
} elseif ($to_order['shipping_status'] != SS_UNSHIPPED) {
return sprintf($GLOBALS['_LANG']['ss_not_unshipped'], $to_order_sn);
}
/* 檢查訂單用戶是否相同 */
if ($from_order['user_id'] != $to_order['user_id']) {
return $GLOBALS['_LANG']['order_user_not_same'];
}
/* 合並訂單 */
$order = $to_order;
$order['order_id'] = '';
$order['add_time'] = gmtime();
// 合並商品總額
$order['goods_amount'] += $from_order['goods_amount'];
// 合並折扣
$order['discount'] += $from_order['discount'];
if ($order['shipping_id'] > 0) {
// 重新計算配送費用
$weight_price = order_weight_price($to_order['order_id']);
$from_weight_price = order_weight_price($from_order['order_id']);
$weight_price['weight'] += $from_weight_price['weight'];
$weight_price['amount'] += $from_weight_price['amount'];
$weight_price['number'] += $from_weight_price['number'];
$region_id_list = array($order['country'], $order['province'], $order['city'], $order['district']);
$shipping_area = shipping_area_info($order['shipping_id'], $region_id_list);
$order['shipping_fee'] = shipping_fee($shipping_area['shipping_code'], unserialize($shipping_area['configure']), $weight_price['weight'], $weight_price['amount'], $weight_price['number']);
// 如果保價了,重新計算保價費
if ($order['insure_fee'] > 0) {
$order['insure_fee'] = shipping_insure_fee($shipping_area['shipping_code'], $order['goods_amount'], $shipping_area['insure']);
}
}
// 重新計算包裝費、賀卡費
if ($order['pack_id'] > 0) {
$pack = pack_info($order['pack_id']);
$order['pack_fee'] = $pack['free_money'] > $order['goods_amount'] ? $pack['pack_fee'] : 0;
}
if ($order['card_id'] > 0) {
$card = card_info($order['card_id']);
$order['card_fee'] = $card['free_money'] > $order['goods_amount'] ? $card['card_fee'] : 0;
}
// 紅包不變,合並積分、餘額、已付款金額
$order['integral'] += $from_order['integral'];
$order['integral_money'] = value_of_integral($order['integral']);
$order['surplus'] += $from_order['surplus'];
$order['money_paid'] += $from_order['money_paid'];
// 計算應付款金額(不包括支付費用)
$order['order_amount'] = $order['goods_amount'] - $order['discount'] + $order['shipping_fee'] + $order['insure_fee'] + $order['pack_fee'] + $order['card_fee'] - $order['bonus'] - $order['integral_money'] - $order['surplus'] - $order['money_paid'];
// 重新計算支付費
if ($order['pay_id'] > 0) {
// 貨到付款手續費
$cod_fee = $shipping_area ? $shipping_area['pay_fee'] : 0;
$order['pay_fee'] = pay_fee($order['pay_id'], $order['order_amount'], $cod_fee);
// 應付款金額加上支付費
$order['order_amount'] += $order['pay_fee'];
}
/* 插入訂單表 */
do {
$order['order_sn'] = get_order_sn();
if ($GLOBALS['db']->autoExecute($GLOBALS['ecs']->table('order_info'), addslashes_deep($order), 'INSERT')) {
break;
//.........這裏部分代碼省略.........
示例2: die
/* 如果不存在實體商品,退出 */
if (!exist_real_goods($order_id)) {
die('Hacking Attemp');
}
/* 取得訂單信息 */
$order_info = order_info($order_id);
$region_id_list = array($order_info['country'], $order_info['province'], $order_info['city'], $order_info['district']);
/* 保存訂單 */
$shipping_id = $_POST['shipping'];
$shipping = shipping_area_info($shipping_id, $region_id_list);
$weight_amount = order_weight_price($order_id);
$shipping_fee = shipping_fee($shipping['shipping_code'], $shipping['configure'], $weight_amount['weight'], $weight_amount['amount'], $weight_amount['number']);
$order = array('shipping_id' => $shipping_id, 'shipping_name' => addslashes($shipping['shipping_name']), 'shipping_fee' => $shipping_fee);
if (isset($_POST['insure'])) {
/* 計算保價費 */
$order['insure_fee'] = shipping_insure_fee($shipping['shipping_code'], order_amount($order_id), $shipping['insure']);
} else {
$order['insure_fee'] = 0;
}
update_order($order_id, $order);
update_order_amount($order_id);
/* 更新 pay_log */
update_pay_log($order_id);
/* 清除首頁緩存:發貨單查詢 */
clear_cache_files('index.dwt');
/* todo 記錄日誌 */
$sn = $old_order['order_sn'];
$new_order = order_info($order_id);
if ($old_order['total_fee'] != $new_order['total_fee']) {
$sn .= ',' . sprintf($_LANG['order_amount_change'], $old_order['total_fee'], $new_order['total_fee']);
}
示例3: SUM
$sql = "SELECT order_id, SUM(goods_number * goods_price) AS goods_amount " . "FROM " . $ecs->table('order_goods') . " WHERE order_id " . db_create_in($order_id_list) . " GROUP BY order_id";
$res = $db->query($sql);
while ($row = $db->fetchRow($res)) {
$order_id = $row['order_id'];
$goods_amount = floatval($row['goods_amount']);
/* 取得訂單信息 */
$order = order_info($order_id);
/* 判斷訂單是否有效:餘額支付金額 + 已付款金額 >= 保證金 */
if ($order['surplus'] + $order['money_paid'] >= $group_buy['deposit']) {
/* 有效,設為已確認,更新訂單 */
// 更新商品總額
$order['goods_amount'] = $goods_amount;
// 如果保價,重新計算保價費用
if ($order['insure_fee'] > 0) {
$shipping = shipping_info($order['shipping_id']);
$order['insure_fee'] = shipping_insure_fee($shipping['shipping_code'], $goods_amount, $shipping['insure']);
}
// 重算支付費用
$order['order_amount'] = $order['goods_amount'] + $order['shipping_fee'] + $order['insure_fee'] + $order['pack_fee'] + $order['card_fee'] - $order['money_paid'] - $order['surplus'];
if ($order['order_amount'] > 0) {
$order['pay_fee'] = pay_fee($order['pay_id'], $order['order_amount']);
} else {
$order['pay_fee'] = 0;
}
// 計算應付款金額
$order['order_amount'] += $order['pay_fee'];
// 計算付款狀態
if ($order['order_amount'] > 0) {
$order['pay_status'] = PS_UNPAYED;
$order['pay_time'] = 0;
} else {
示例4: order_fee
//.........這裏部分代碼省略.........
$total['card_fee_formated'] = price_format($total['card_fee'], false);
/* 紅包 */
if (!empty($order['bonus_id'])) {
$bonus = model('Order')->bonus_info($order['bonus_id']);
$total['bonus'] = $bonus['type_money'];
}
$total['bonus_formated'] = price_format($total['bonus'], false);
/* 線下紅包 */
if (!empty($order['bonus_kill'])) {
$bonus = model('Order')->bonus_info(0, $order['bonus_kill']);
$total['bonus_kill'] = $order['bonus_kill'];
$total['bonus_kill_formated'] = price_format($total['bonus_kill'], false);
}
/* 配送費用 */
$shipping_cod_fee = NULL;
if ($order['shipping_id'] > 0 && $total['real_goods_count'] > 0) {
$region['country'] = $consignee['country'];
$region['province'] = $consignee['province'];
$region['city'] = $consignee['city'];
$region['district'] = $consignee['district'];
$shipping_info = model('Shipping')->shipping_area_info($order['shipping_id'], $region);
if (!empty($shipping_info)) {
if ($order['extension_code'] == 'group_buy') {
$weight_price = model('Order')->cart_weight_price(CART_GROUP_BUY_GOODS);
} else {
$weight_price = model('Order')->cart_weight_price();
}
// 查看購物車中是否全為免運費商品,若是則把運費賦為零
$sql = 'SELECT count(*) as count FROM ' . $this->pre . "cart WHERE `session_id` = '" . SESS_ID . "' AND `extension_code` != 'package_buy' AND `is_shipping` = 0";
$res = $this->row($sql);
$shipping_count = $res['count'];
$total['shipping_fee'] = ($shipping_count == 0 and $weight_price['free_shipping'] == 1) ? 0 : shipping_fee($shipping_info['shipping_code'], $shipping_info['configure'], $weight_price['weight'], $total['goods_price'], $weight_price['number']);
if (!empty($order['need_insure']) && $shipping_info['insure'] > 0) {
$total['shipping_insure'] = shipping_insure_fee($shipping_info['shipping_code'], $total['goods_price'], $shipping_info['insure']);
} else {
$total['shipping_insure'] = 0;
}
if ($shipping_info['support_cod']) {
$shipping_cod_fee = $shipping_info['pay_fee'];
}
}
}
$total['shipping_fee_formated'] = price_format($total['shipping_fee'], false);
$total['shipping_insure_formated'] = price_format($total['shipping_insure'], false);
// 購物車中的商品能享受紅包支付的總額
$bonus_amount = model('Order')->compute_discount_amount();
// 紅包和積分最多能支付的金額為商品總額
$max_amount = $total['goods_price'] == 0 ? $total['goods_price'] : $total['goods_price'] - $bonus_amount;
/* 計算訂單總額 */
if ($order['extension_code'] == 'group_buy' && $group_buy['deposit'] > 0) {
$total['amount'] = $total['goods_price'];
} else {
$total['amount'] = $total['goods_price'] - $total['discount'] + $total['tax'] + $total['pack_fee'] + $total['card_fee'] + $total['shipping_fee'] + $total['shipping_insure'] + $total['cod_fee'];
// 減去紅包金額
$use_bonus = min($total['bonus'], $max_amount);
// 實際減去的紅包金額
if (isset($total['bonus_kill'])) {
$use_bonus_kill = min($total['bonus_kill'], $max_amount);
$total['amount'] -= $price = number_format($total['bonus_kill'], 2, '.', '');
// 還需要支付的訂單金額
}
$total['bonus'] = $use_bonus;
$total['bonus_formated'] = price_format($total['bonus'], false);
$total['amount'] -= $use_bonus;
// 還需要支付的訂單金額
$max_amount -= $use_bonus;
示例5: action_insert_update
/**
* 添加/編輯預售活動的提交
*/
function action_insert_update()
{
$user = $GLOBALS['user'];
$_CFG = $GLOBALS['_CFG'];
$_LANG = $GLOBALS['_LANG'];
$smarty = $GLOBALS['smarty'];
$db = $GLOBALS['db'];
$ecs = $GLOBALS['ecs'];
$user_id = $_SESSION['user_id'];
/* 取得預售活動id */
$pre_sale_id = intval($_POST['act_id']);
if (isset($_POST['finish']) || isset($_POST['succeed']) || isset($_POST['fail']) || isset($_POST['mail'])) {
if ($pre_sale_id <= 0) {
sys_msg($_LANG['error_pre_sale'], 1);
}
$pre_sale = pre_sale_info($pre_sale_id);
if (empty($pre_sale)) {
sys_msg($_LANG['error_pre_sale'], 1);
}
}
if (isset($_POST['finish'])) {
/* 設置活動結束 */
/* 判斷活動狀態 */
if ($pre_sale['status'] != PSS_UNDER_WAY) {
sys_msg($_LANG['error_status'], 1);
// 此處懷疑是如果活動進行中突然要結束掉,應該拋出禁止的頁麵,貌似去掉了,所以程序繼續執行
}
/* 結束預售活動,修改結束時間為當前時間 */
$sql = "UPDATE " . $ecs->table('goods_activity') . " SET end_time = '" . gmtime() . "' " . "WHERE act_id = '{$pre_sale_id}' LIMIT 1";
$db->query($sql);
/* 清除緩存 */
clear_cache_files();
/* 提示信息 */
$links = array(array('href' => 'pre_sale.php?act=list', 'text' => $_LANG['back_list']));
sys_msg($_LANG['edit_success'], 0, $links);
} elseif (isset($_POST['succeed'])) {
/* 設置活動成功 */
/* 判斷訂單狀態 */
if ($pre_sale['status'] != PSS_FINISHED) {
sys_msg($_LANG['error_status'], 1);
}
/* 如果有訂單,更新訂單信息 */
if ($pre_sale['total_order'] > 0) {
/* 查找該預售活動的已確認或未確認訂單(已取消的就不管了) */
$sql = "SELECT order_id " . "FROM " . $ecs->table('order_info') . " WHERE extension_code = '" . PRE_SALE_CODE . "' " . "AND extension_id = '{$pre_sale_id}' " . "AND (order_status = '" . OS_CONFIRMED . "' or order_status = '" . OS_UNCONFIRMED . "')";
$order_id_list = $db->getCol($sql);
/* 更新訂單商品價 */
$final_price = $pre_sale['trans_price'];
$sql = "UPDATE " . $ecs->table('order_goods') . " SET goods_price = '{$final_price}' " . "WHERE order_id " . db_create_in($order_id_list);
$db->query($sql);
/* 查詢訂單商品總額 */
$sql = "SELECT order_id, SUM(goods_number * goods_price) AS goods_amount " . "FROM " . $ecs->table('order_goods') . " WHERE order_id " . db_create_in($order_id_list) . " GROUP BY order_id";
$res = $db->query($sql);
while ($row = $db->fetchRow($res)) {
$order_id = $row['order_id'];
$goods_amount = floatval($row['goods_amount']);
/* 取得訂單信息 */
$order = order_info($order_id);
/* 判斷訂單是否有效:餘額支付金額 + 已付款金額 >= 保證金 */
if ($order['surplus'] + $order['money_paid'] >= $pre_sale['deposit']) {
/* 有效,設為已確認,更新訂單 */
// 更新商品總額
$order['goods_amount'] = $goods_amount;
// 如果保價,重新計算保價費用
if ($order['insure_fee'] > 0) {
$shipping = shipping_info($order['shipping_id']);
$order['insure_fee'] = shipping_insure_fee($shipping['shipping_code'], $goods_amount, $shipping['insure']);
}
// 重算支付費用
$order['order_amount'] = $order['goods_amount'] + $order['shipping_fee'] + $order['insure_fee'] + $order['pack_fee'] + $order['card_fee'] - $order['money_paid'] - $order['surplus'];
if ($order['order_amount'] > 0) {
$order['pay_fee'] = pay_fee($order['pay_id'], $order['order_amount']);
} else {
$order['pay_fee'] = 0;
}
// 計算應付款金額
$order['order_amount'] += $order['pay_fee'];
// 計算付款狀態
if ($order['order_amount'] > 0) {
$order['pay_status'] = PS_UNPAYED;
$order['pay_time'] = 0;
} else {
$order['pay_status'] = PS_PAYED;
$order['pay_time'] = gmtime();
}
// 如果需要退款,退到帳戶餘額
if ($order['order_amount'] < 0) {
// todo (現在手工退款)
}
// 訂單狀態
$order['order_status'] = OS_CONFIRMED;
$order['confirm_time'] = gmtime();
// 更新訂單
$order = addslashes_deep($order);
update_order($order_id, $order);
} else {
/* 無效,取消訂單,退回已付款 */
//.........這裏部分代碼省略.........