本文整理汇总了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);
}
示例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;
}
示例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));
}
}