當前位置: 首頁>>代碼示例>>PHP>>正文


PHP unuse_bonus函數代碼示例

本文整理匯總了PHP中unuse_bonus函數的典型用法代碼示例。如果您正苦於以下問題:PHP unuse_bonus函數的具體用法?PHP unuse_bonus怎麽用?PHP unuse_bonus使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了unuse_bonus函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: return_user_surplus_integral_bonus

/**
 * 退回餘額、積分、紅包(取消、無效、退貨時),把訂單使用餘額、積分、紅包設為0
 * @param   array   $order  訂單信息
 */
function return_user_surplus_integral_bonus($order)
{
    /* 處理餘額、積分、紅包 */
    if ($order['user_id'] > 0 && $order['surplus'] > 0) {
        $surplus = $order['money_paid'] < 0 ? $order['surplus'] + $order['money_paid'] : $order['surplus'];
        log_account_change($order['user_id'], $surplus, 0, 0, 0, sprintf($GLOBALS['_LANG']['return_order_surplus'], $order['order_sn']));
        $GLOBALS['db']->query("UPDATE " . $GLOBALS['ecs']->table('order_info') . " SET `order_amount` = '0' WHERE `order_id` =" . $order['order_id']);
    }
    if ($order['user_id'] > 0 && $order['integral'] > 0) {
        log_account_change($order['user_id'], 0, 0, 0, $order['integral'], sprintf($GLOBALS['_LANG']['return_order_integral'], $order['order_sn']));
    }
    if ($order['bonus_id'] > 0) {
        unuse_bonus($order['bonus_id']);
    }
    /* 修改訂單 */
    $arr = array('bonus_id' => 0, 'bonus' => 0, 'integral' => 0, 'integral_money' => 0, 'surplus' => 0);
    update_order($order['order_id'], $arr);
}
開發者ID:norain2050,項目名稱:benhu,代碼行數:22,代碼來源:order.php

示例2: merge_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;
        } else {
            if ($GLOBALS['db']->errno() != 1062) {
                die($GLOBALS['db']->errorMsg());
            }
        }
    } while (true);
    // 防止訂單號重複
    /* 訂單號 */
    $order_id = $GLOBALS['db']->insert_id();
    /* 更新訂單商品 */
    $sql = 'UPDATE ' . $GLOBALS['ecs']->table('order_goods') . " SET order_id = '{$order_id}' " . "WHERE order_id " . db_create_in(array($from_order['order_id'], $to_order['order_id']));
    $GLOBALS['db']->query($sql);
    include_once ROOT_PATH . 'includes/lib_clips.php';
    /* 插入支付日誌 */
    insert_pay_log($order_id, $order['order_amount'], PAY_ORDER);
    /* 刪除原訂單 */
    $sql = 'DELETE FROM ' . $GLOBALS['ecs']->table('order_info') . " WHERE order_id " . db_create_in(array($from_order['order_id'], $to_order['order_id']));
    $GLOBALS['db']->query($sql);
    /* 刪除原訂單支付日誌 */
    $sql = 'DELETE FROM ' . $GLOBALS['ecs']->table('pay_log') . " WHERE order_id " . db_create_in(array($from_order['order_id'], $to_order['order_id']));
    $GLOBALS['db']->query($sql);
    /* 返還 from_order 的紅包,因為隻使用 to_order 的紅包 */
    if ($from_order['bonus_id'] > 0) {
        unuse_bonus($from_order['bonus_id']);
    }
    /* 返回成功 */
    return true;
}
開發者ID:dlpc,項目名稱:ecshop,代碼行數:101,代碼來源:lib_order.php

示例3: del_one_order

 public static function del_one_order($order_id)
 {
     include_once ROOT_PATH . 'includes/lib_transaction.php';
     include_once ROOT_PATH . 'includes/lib_common.php';
     global $db;
     global $ecs;
     $user_id = $_SESSION['user_id'];
     //隻有沒有確認的訂單才可以取消
     //$current_order = $db->getRow("select order_status,pay_status from ecs_order_info where user_id = '$user_id' and order_id = '$order_id'");
     $current_order = $db->getRow("select order_status,pay_status,bonus,surplus,bonus_id,order_sn from ecs_order_info where user_id = '{$user_id}' and order_id = '{$order_id}'");
     if ($current_order['order_status'] == OS_UNCONFIRMED && $current_order['pay_status'] != PS_PAYED) {
         $sql = "update ecs_order_info set order_status =" . OS_CANCELED . " where user_id = '{$user_id}' and order_id = '{$order_id}'";
         $orders = $db->query($sql);
         if ($orders) {
             $change_desc = "訂單號:" . $current_order['order_sn'];
             //取消禮金卡支付的訂單記錄禮金卡賬戶變動
             if ($current_order['surplus'] > 0) {
                 log_mcard_change($user_id, $current_order['surplus'], $change_desc, 0, $order_id, 3);
             } else {
                 if ($current_order['bonus'] > 0) {
                     unuse_bonus(trim($current_order['bonus_id']));
                 } else {
                     log_account_change($user_id, 0, 0, 0, 0, $change_desc);
                 }
             }
         }
         return json_encode(array('code' => RES_SUCCSEE));
     } else {
         return json_encode(array('code' => RES_FAIL));
     }
 }
開發者ID:fromzyy2ann,項目名稱:mescake,代碼行數:31,代碼來源:user.php


注:本文中的unuse_bonus函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。