示例#1
0
文件: member.php 项目: ss098/Fire
     } else {
         // 满足折扣码最低消费金额
         if ($discount["min_price"] < $discounted_price) {
             // 进行折扣
             $use_discount_code = true;
             $discounted_price = $commodity['price'] * $count - $discount["discount_price"];
         } else {
             $message[] = "折扣码需要满 {$discount['min_price']} Fire Card 使用";
         }
     }
 } else {
     // 没有使用折扣码
 }
 // 可用流量
 $transfer_enable = 1024 * 1024 * 1024 * $commodity['transfer'] * $count;
 $formated_transfer = format_transfer($transfer_enable);
 // 套餐过期时间
 $expired_time = time() + $commodity['time'];
 if (!count($message)) {
     // 没有套餐错误,检查余额
     $member = $db->get('member', array('id', 'name', 'email', 'money', 'phone', 'password', 'salt'), array('name' => $token['username']));
     if (!$member) {
         $message[] = '请重新登录后选择套餐';
     } else {
         if ($member['money'] >= $discounted_price) {
             // 插入尝试扣款日志
             $active = $db->insert('active', array('content' => "[未扣款]尝试购买 {$count} 个 {$region['name']} 区域的 {$commodity['name']} 套餐共 {$formated_transfer},支付 {$discounted_price} Fire Card,余额 {$member['money']} Fire Card", 'username' => $token['username'], 'time' => date('Y-m-d H:i:s', time())));
             // 标记已使用
             $db->update('discount', array('used_member' => $token['username']), array('card' => $discount_code));
             if ($discount_price == 0 || $db->update('member', array('money[-]' => $discounted_price), array('id' => $member['id']))) {
                 // 扣款成功
示例#2
0
文件: panel.php 项目: hzqim/MakeDieSS
function echo_transfer_info($type, $u, $d, $transfer_enable)
{
    $transfer_leave = $transfer_enable - $u - $d;
    $transfer_leave = $transfer_leave < 0 ? 0 : $transfer_leave;
    $transfer_enable_ = $transfer_enable < $u + $d ? $u + $d : $transfer_enable;
    $per_u = $u / $transfer_enable_ * 100.0;
    $per_u = $per_u > 100.0 ? 100.0 : $per_u;
    $per_d = $d / $transfer_enable_ * 100.0;
    $per_d = $per_d > 100.0 ? 100.0 : $per_d;
    ?>
    <div class="col-md-10">
        <h3 id="labels" class="page-header">
            流量统计
        </h3>

        <div class="row">
            <div class="col-md-10">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h3 class="panel-title">
                            <?php 
    switch ($type) {
        case 1:
            echo '免费用户(每天可用2048MB流量)';
            break;
        case 3:
            echo '作死用户(每天可用8888MB流量)';
            break;
        case 7:
            echo '做大死用户(每天可用88888MB流量)';
            break;
    }
    ?>

                        </h3>
                    </div>
                    <div class="panel-body">
                        <div class="progress">
                            <div class="progress-bar progress-bar-striped active" role="progressbar"
                                 aria-valuenow="<?php 
    echo $per_d;
    ?>
" aria-valuemin="0" aria-valuemax="100"
                                 style="width: <?php 
    echo $per_d;
    ?>
                                     %">
                            </div>
                            <div
                                class="progress-bar progress-bar-success progress-bar-striped active"
                                role="progressbar" aria-valuenow="<?php 
    echo $per_u;
    ?>
" aria-valuemin="0" aria-valuemax="100"
                                style="width: <?php 
    echo $per_u;
    ?>
                                    %">
                            </div>
                        </div>
                        <div class="input-group">
                                                <span class="input-group-addon">
                                                    套餐流量
                                                </span>
                            <input type="text" value="<?php 
    echo format_transfer($transfer_enable);
    ?>
" disabled="disabled" class="form-control">
                        </div>
                        <div class="input-group">
                                                <span class="input-group-addon">
                                                    下行流量
                                                </span>
                            <input type="text" value="<?php 
    echo format_transfer($d);
    ?>
" disabled="disabled" class="form-control">
                        </div>
                        <div class="input-group">
                                                <span class="input-group-addon">
                                                    上行流量
                                                </span>
                            <input type="text" value="<?php 
    echo format_transfer($u);
    ?>
" disabled="disabled" class="form-control">
                        </div>
                        <div class="input-group">
                                                <span class="input-group-addon">
                                                    剩余流量
                                                </span>
                            <input type="text" value="<?php 
    echo format_transfer($transfer_leave);
    ?>
" disabled="disabled" class="form-control">
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
<?php 
}