Esempio n. 1
0
 public static function CashIt($order)
 {
     global $login_user_id;
     if (!$order['state'] == 'pay') {
         return 0;
     }
     //update order
     Table::UpdateCache('order', $order['id'], array('state' => 'pay', 'service' => 'cash', 'admin_id' => $login_user_id, 'money' => $order['origin'], 'pay_time' => time()));
     /* cash flow */
     $order = Table::FetchForce('order', $order['id']);
     ZFlow::CreateFromStore($order['user_id'], $order['origin']);
     ZTeam::BuyOne($order);
 }
Esempio n. 2
0
 } else {
     if ('userview' == $action) {
         $user = Table::Fetch('user', $id);
         $user['costcount'] = Table::Count('order', array('state' => 'pay', 'user_id' => $id));
         $user['cost'] = Table::Count('flow', array('direction' => 'expense', 'user_id' => $id), 'money');
         $html = render('manage_ajax_dialog_user');
         json($html, 'dialog');
     } else {
         if ('usermoney' == $action) {
             need_auth('admin');
             $user = Table::Fetch('user', $id);
             $money = moneyit($_GET['money']);
             if ($money < 0 && $user['money'] + $money < 0) {
                 json('提现失败 - 用户余额不足', 'alert');
             }
             if (ZFlow::CreateFromStore($id, $money)) {
                 $action = $money > 0 ? '线下充值' : '用户提现';
                 $money = abs($money);
                 json(array(array('data' => "{$action}{$money}元成功", 'type' => 'alert'), array('data' => null, 'type' => 'refresh')), 'mix');
             }
             json('充值失败', 'alert');
         } else {
             if ('orderexpress' == $action) {
                 need_auth('order');
                 $express_id = abs(intval($_GET['eid']));
                 $express_no = strval($_GET['nid']);
                 if (!$express_id) {
                     $express_no = null;
                 }
                 Table::UpdateCache('order', $id, array('express_id' => $express_id, 'express_no' => $express_no));
                 json(array(array('data' => "修改快递信息成功", 'type' => 'alert'), array('data' => null, 'type' => 'refresh')), 'mix');
Esempio n. 3
0
<?php

require_once dirname(dirname(dirname(__FILE__))) . '/app.php';
if ($_POST) {
    need_login(true);
    $gift_card = Table::Fetch('gift_card', $_POST['code'], 'code');
    if (!$gift_card || $gift_card['status'] == 'used') {
        Session::Set('error', 'Gift code is not valid.');
        Utility::Redirect($_SERVER['HTTP_REFERER']);
    }
    $money = $gift_card['amount'];
    if (ZFlow::CreateFromStore($login_user_id, $money)) {
        $table = new Table('gift_card', $gift_card);
        $update_array = array('redeem_time', 'status');
        $table->redeem_time = time();
        $table->status = 'used';
        $flag = $table->update($update_array);
        Session::Set('notice', 'Your account is updated.');
        Utility::Redirect($_SERVER['HTTP_REFERER']);
    }
}
Esempio n. 4
0
                    } else {
                        if ($action == 'withdraw_submit') {
                            need_auth('caiwu_dowithdraw');
                            $apply = Table::Fetch('apply', $id);
                            $user = Table::Fetch('user', $apply['user_id']);
                            $direction = strval($_GET['direction']);
                            $withdrawpay = strval($_GET['withdrawpay']);
                            $withdrawcontent = strval($_GET['c']);
                            $money = moneyit($_GET['withdrawmoney']);
                            if ($money > 0) {
                                log_admin('caiwu', $user['email'] . '充值' . $money . '元失败 - 本次操作仅限提现');
                                json('充值失败 - 本次操作仅限提现', 'alert');
                            } elseif ($money < 0 && $user['money'] + $money < 0) {
                                json('提现失败 - 用户余额不足', 'alert');
                            }
                            Table::UpdateCache('apply', $id, array('direction' => 'yuanlu', 'withdraw_direction' => $direction, 'withdrawpay' => $withdrawpay, 'content' => $withdrawcontent, 'done_time' => time(), 'admin_name' => $login_user['realname'], 'admin_id' => $login_user_id));
                            if (ZFlow::CreateFromStore($apply['user_id'], $money)) {
                                Table::UpdateCache('apply', $id, array('status' => 'be', 'done_time' => time(), 'admin_name' => $login_user['realname'], 'admin_id' => $login_user_id));
                                log_admin('caiwu', '[提现申请]' . $user['username'] . '提现' . $money . '元');
                                if (option_yes('chongtisms')) {
                                    sms_withdraw($id);
                                }
                                json(array(array('data' => "用户提现{$money}元成功", 'type' => 'alert'), array('data' => null, 'type' => 'refresh')), 'mix');
                            }
                        }
                    }
                }
            }
        }
    }
}