• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP value_of_integral函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中value_of_integral函数的典型用法代码示例。如果您正苦于以下问题:PHP value_of_integral函数的具体用法?PHP value_of_integral怎么用?PHP value_of_integral使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了value_of_integral函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
//.........这里部分代码省略.........
开发者ID:dlpc,项目名称:ecshop,代码行数:101,代码来源:lib_order.php


示例2: order_fee


//.........这里部分代码省略.........
             $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;
         // 积分最多还能支付的金额
     }
     /* 余额 */
     $order['surplus'] = $order['surplus'] > 0 ? $order['surplus'] : 0;
     if ($total['amount'] > 0) {
         if (isset($order['surplus']) && $order['surplus'] > $total['amount']) {
             $order['surplus'] = $total['amount'];
             $total['amount'] = 0;
         } else {
             $total['amount'] -= floatval($order['surplus']);
         }
     } else {
         $order['surplus'] = 0;
         $total['amount'] = 0;
     }
     $total['surplus'] = $order['surplus'];
     $total['surplus_formated'] = price_format($order['surplus'], false);
     /* 积分 */
     $order['integral'] = $order['integral'] > 0 ? $order['integral'] : 0;
     if ($total['amount'] > 0 && $max_amount > 0 && $order['integral'] > 0) {
         $integral_money = value_of_integral($order['integral']);
         // 使用积分支付
         $use_integral = min($total['amount'], $max_amount, $integral_money);
         // 实际使用积分支付的金额
         $total['amount'] -= $use_integral;
         $total['integral_money'] = $use_integral;
         $order['integral'] = integral_of_value($use_integral);
     } else {
         $total['integral_money'] = 0;
         $order['integral'] = 0;
     }
     $total['integral'] = $order['integral'];
     $total['integral_formated'] = price_format($total['integral_money'], false);
     /* 保存订单信息 */
     $_SESSION['flow_order'] = $order;
     $se_flow_type = isset($_SESSION['flow_type']) ? $_SESSION['flow_type'] : '';
     /* 支付费用 */
     if (!empty($order['pay_id']) && ($total['real_goods_count'] > 0 || $se_flow_type != CART_EXCHANGE_GOODS)) {
         $total['pay_fee'] = pay_fee($order['pay_id'], $total['amount'], $shipping_cod_fee);
     }
     $total['pay_fee_formated'] = price_format($total['pay_fee'], false);
     $total['amount'] += $total['pay_fee'];
     // 订单总额累加上支付费用
     $total['amount_formated'] = price_format($total['amount'], false);
     /* 取得可以得到的积分和红包 */
     if ($order['extension_code'] == 'group_buy') {
         $total['will_get_integral'] = $group_buy['gift_integral'];
     } elseif ($order['extension_code'] == 'exchange_goods') {
         $total['will_get_integral'] = 0;
     } else {
         $total['will_get_integral'] = model('Order')->get_give_integral($goods);
     }
     $total['will_get_bonus'] = $order['extension_code'] == 'exchange_goods' ? 0 : price_format(model('Order')->get_total_bonus(), false);
     $total['formated_goods_price'] = price_format($total['goods_price'], false);
     $total['formated_market_price'] = price_format($total['market_price'], false);
     $total['formated_saving'] = price_format($total['saving'], false);
     if ($order['extension_code'] == 'exchange_goods') {
         $sql = 'SELECT SUM(eg.exchange_integral) ' . 'as sum FROM ' . $this->pre . 'cart AS c,' . $this->pre . 'exchange_goods AS eg ' . "WHERE c.goods_id = eg.goods_id AND c.session_id= '" . SESS_ID . "' " . "  AND c.rec_type = '" . CART_EXCHANGE_GOODS . "' " . '  AND c.is_gift = 0 AND c.goods_id > 0 ' . 'GROUP BY eg.goods_id';
         $res = $this->row($sql);
         $exchange_integral = $res['sum'];
         $total['exchange_integral'] = $exchange_integral;
     }
     return $total;
 }
开发者ID:m7720647,项目名称:demo,代码行数:101,代码来源:UsersModel.class.php


示例3: bonus_info

 /* 如果选择了红包,先使用红包支付 */
 if ($_POST['bonus_id'] > 0) {
     /* todo 检查红包是否可用 */
     $order['bonus_id'] = $_POST['bonus_id'];
     $bonus = bonus_info($_POST['bonus_id']);
     $order['bonus'] = $bonus['type_money'];
     $order['order_amount'] -= $order['bonus'];
 }
 /* 使用红包之后待付款金额仍大于0 */
 if ($order['order_amount'] > 0) {
     if ($old_order['extension_code'] != 'exchange_goods') {
         /* 如果设置了积分,再使用积分支付 */
         if (isset($_POST['integral']) && intval($_POST['integral']) > 0) {
             /* 检查积分是否足够 */
             $order['integral'] = intval($_POST['integral']);
             $order['integral_money'] = value_of_integral(intval($_POST['integral']));
             if ($old_order['integral'] + $user['pay_points'] < $order['integral']) {
                 sys_msg($_LANG['pay_points_not_enough']);
             }
             $order['order_amount'] -= $order['integral_money'];
         }
     } else {
         if (intval($_POST['integral']) > $user['pay_points'] + $old_order['integral']) {
             sys_msg($_LANG['pay_points_not_enough']);
         }
     }
     if ($order['order_amount'] > 0) {
         /* 如果设置了余额,再使用余额支付 */
         if (isset($_POST['surplus']) && floatval($_POST['surplus']) >= 0) {
             /* 检查余额是否足够 */
             $order['surplus'] = round(floatval($_POST['surplus']), 2);
开发者ID:norain2050,项目名称:benhu,代码行数:31,代码来源:order.php


示例4: array

        }
        // print_r($result);exit;
        $out = array('bonus' => $result['total']['bonus'], 'bonus_formated' => $result['total']['bonus_formated']);
        GZ_Api::outPut($out);
        break;
    case 'integral':
        $integral = _POST('integral', 0);
        if (!$integral) {
            GZ_Api::outPut(101);
        }
        // $user_id = $_SESSION['user_id'];
        // 	        $user_info = user_info($user_id);
        // 	        // 查询用户有多少积分
        // 	        $flow_points = flow_available_points();  // 该订单允许使用的积分
        // $user_points = $user_info['pay_points']; // 用户的积分总数
        $integral_to_p = value_of_integral($integral);
        // print_r($user_info);
        // print_r($flow_points);exit;
        GZ_Api::outPut(array("bonus" => $integral_to_p, "bonus_formated" => price_format($integral_to_p)));
        break;
}
GZ_Api::outPut(101);
/**
 * 获得用户的可用积分
 *
 * @access  private
 * @return  integral
 */
function flow_available_points()
{
    $sql = "SELECT SUM(g.integral * c.goods_number) " . "FROM " . $GLOBALS['ecs']->table('cart') . " AS c, " . $GLOBALS['ecs']->table('goods') . " AS g " . "WHERE c.session_id = '" . SESS_ID . "' AND c.goods_id = g.goods_id AND c.is_gift = 0 AND g.integral > 0 " . "AND c.rec_type = '" . CART_GENERAL_GOODS . "'";
开发者ID:blowfishJ,项目名称:galaxyCode,代码行数:31,代码来源:validate.php



注:本文中的value_of_integral函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP value_or_default函数代码示例发布时间:2022-05-23
下一篇:
PHP value函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap