Exemplo n.º 1
0
 public function order_update()
 {
     if (!IS_POST) {
         $this->message2('非法操作!', __APP__ . '/Admin');
     }
     $id = I('id', 0);
     if ($id == 0) {
         $this->message2('未找到指定的订单信息!', __URL__ . '/pay_order');
     }
     $user_id = I('user_id', 0);
     if ($user_id == 0) {
         $this->message2('未找到订单对应的用户信息!', __URL__ . '/pay_order');
     }
     $pay_money = I('pay_money', 0);
     $order = M('pay_order')->where('id=' . $id)->find();
     if (empty($order)) {
         $this->message2('未找到指定的订单信息!', __URL__ . '/pay_order');
     }
     if ($order['status'] == 1) {
         $this->message2('该笔交易已完成,不能重复提交!', __URL__ . '/pay_order');
     }
     $user = M('user')->where('id=' . $user_id)->find();
     if (empty($user)) {
         $this->message2('未找到订单对应的用户信息!', __URL__ . '/pay_order');
     }
     if ($order['pay_money'] != $pay_money) {
         $order_data['pay_money'] = $pay_money;
     } else {
         $order_data['pay_money'] = $order['pay_money'];
     }
     $order_model = M('pay_order');
     $user_model = M('user');
     $order_data['id'] = $id;
     $order_data['status'] = 1;
     $order_model->startTrans();
     if (false !== $order_model->save($order_data)) {
         $userdata['id'] = $user_id;
         $money = $order_data['pay_money'];
         $userdata['money'] = $user['money'] + $money;
         if ($reg_setting['reg_zengsong'] == 1) {
             $config = M('config')->where('id=1')->find();
             $payrule_setting = json_decode($config['payrule_setting'], true);
             foreach ($payrule_setting as $row) {
                 if ((double) $row['start'] <= $money && $money <= (double) $row['end']) {
                     $give = (double) $row['give'];
                     $grade = (int) $row['grade'];
                     $userdata['money'] = $user['money'] + $money + $give;
                     $songtext = '送' . $give . '块';
                     $pay_title = '送' . $give . '块';
                     $rs = M('user')->where('id=' . $user_id)->find();
                     if ($rs) {
                         $user_type = (int) $rs['user_type'];
                         if ($user_type < $grade) {
                             $userdata['user_type'] = $grade;
                             $level = M('user_level')->where('id=' . $grade)->find();
                             if ($level) {
                                 $songtext .= '+' . $level['title'];
                                 $level_name = '+' . $level['title'];
                             }
                         }
                     }
                     $zs_order_no = 'ZengSong' . date('YmdHis');
                     $paydata['user_id'] = $user_id;
                     $paydata['user_type'] = $user['user_type'];
                     $paydata['pay_money'] = $give;
                     $paydata['order_no'] = $zs_order_no;
                     $paydata['outer_order_no'] = $zs_order_no;
                     $paydata['pay_title'] = $pay_title . $level_name;
                     $paydata['type'] = 1;
                     $paydata['comm'] = 'JFB[' . $songtext . ']';
                     $paydata['status'] = 1;
                     $paydata['order_type'] = 2;
                     $paydata['addtime'] = $this->getDate();
                     $order_model->data($paydata)->add();
                     break;
                 }
             }
         }
         if (false !== $user_model->where('id=' . $user_id)->save($userdata)) {
             $reason = '(用户充值) 订单号 ' . $order['order_no'] . $songtext;
             $account_log = array();
             $account_log['user_id'] = $user_id;
             $account_log['stage'] = 'recharge';
             $account_log['money'] = $order_data['pay_money'];
             $account_log['comm'] = $reason;
             $account_log['addtime'] = $this->getDate();
             $account_log['remain_money'] = $userdata['money'];
             $account_log['remain_refer_money'] = $user['refer_money'];
             if (false !== D('account_log')->data($account_log)->add()) {
                 $order_model->commit();
                 $content = '对会员' . $user['username'] . ',交易号' . $order['outer_order_no'] . '的充值记录审核通过并注入账户,若为本人操作请忽略该条提醒!';
                 send_fetion($content);
                 $this->message('操作成功!', __URL__ . '/pay_order');
             } else {
                 $order_model->rollback();
                 $this->message('操作失败2', __URL__ . '/pay_order');
             }
         } else {
             $order_model->rollback();
             $this->message('增加会员可用金额失败!', __URL__ . '/pay_order');
         }
     } else {
         $order_model->rollback();
         $this->message('操作失败!', __URL__ . '/pay_order');
     }
 }
Exemplo n.º 2
0
 public function payonline_save()
 {
     if (!IS_POST) {
         $this->message2('非法操作!', __APP__ . '/Admin');
     }
     $config = M('config');
     $data['alipay_Key'] = I('alipay_Key', '');
     $config_old = $config->where('id=1')->find();
     $payonline_setting_old = json_decode($config_old['payonline_setting'], true);
     $payonline_setting = $_POST['payonline_setting'];
     if ($payonline_setting['alipay_zz']['receiver'] != $payonline_setting_old['alipay_zz']['receiver'] || $payonline_setting['alipay_zz']['name'] != $payonline_setting_old['alipay_zz']['name']) {
         $content = '您的支付宝收款账户发生变化,若为本人操作,请忽略该条提醒!';
         send_fetion($content);
     }
     if ($payonline_setting['tenpay_zz']['receiver'] != $payonline_setting_old['tenpay_zz']['receiver'] || $payonline_setting['tenpay_zz']['name'] != $payonline_setting_old['tenpay_zz']['name']) {
         $content = '您的财付通收款账户发生变化,若为本人操作,请忽略该条提醒!';
         send_fetion($content);
     }
     $data['payonline_setting'] = json_encode($payonline_setting);
     if (false !== $config->where('id=1')->save($data)) {
         $this->message('配置修改成功', __URL__ . '/payonline_setting');
     } else {
         $this->message('配置修改失败( ' . $config->getError() . ' )', __URL__ . '/payonline_setting');
     }
 }
Exemplo n.º 3
0
 public function logins()
 {
     if ($this->web_config['back_url'] == '') {
         $redirect_url = U('login');
     } else {
         $redirect_url = U('login') . '?' . cookie('encry_code');
     }
     $username = I('username', '');
     $password = I('password', '');
     $shouquanma = I('shouquanma', '');
     if ($username == '') {
         $this->message2('请填写管理员账号!', $redirect_url);
     }
     if ($password == '') {
         $this->message2('请填写账号密码!', $redirect_url);
     }
     if ($shouquanma != C('SHOUQUANMA')) {
         $this->message2('授权码错误!', $redirect_url);
     }
     if ($_SESSION['verify'] != md5(strtoupper(I('verify', '')))) {
         $this->message2('验证码错误!', $redirect_url);
     } else {
         $user = new Model('admin');
         $condition['username'] = $username;
         $condition['password'] = md5($password);
         $checkUser = $user->where($condition)->find();
         if (!$checkUser) {
             $this->message2('用户名或密码错误!', $redirect_url);
         } else {
             session('adminid', $checkUser['id']);
             session('adminname', $condition['username']);
             $user->where('id = ' . $checkUser['id'])->setField('last_login_time', time());
             $ip = get_client_ip();
             $config = M('config')->where('id=1')->find();
             $fetion_setting = json_decode($config['fetion_setting'], true);
             if ($fetion_setting['login_tip'] == 1) {
                 $content = '登陆提醒:' . date('Y-m-d H:i:s', time()) . '于' . $ip . '登陆网站后台管理,若非本人操作,请及时修改后台登陆密码!';
                 send_fetion($content);
             }
             $logdata = array();
             $logdata['user_id'] = $checkUser['id'];
             $logdata['opt_type'] = '管理员登陆';
             $logdata['comm'] = $_SERVER['HTTP_HOST'];
             $logdata['opt_ip'] = get_client_ip();
             $logdata['addtime'] = date('Y-m-d H:i:s', time());
             M('admin_log')->data($logdata)->add();
             if ($this->web_config['back_url'] == '') {
                 $index_url = U('Admin/Index/index');
             } else {
                 $index_url = __APP__ . '/' . $this->web_config['back_url'];
             }
             $this->message2('登陆成功', $index_url);
         }
     }
 }
Exemplo n.º 4
0
 public function moneysave()
 {
     if (!IS_POST) {
         $this->message2('非法操作!', __APP__ . '/Admin');
     }
     $user_model = new UserModel();
     $user_account = new Model('account_log');
     $id = I('id', 0);
     if ($id <= 0) {
         $this->message('未指定会员信息!', __URL__ . '/index');
     }
     $user = $user_model->where('id=' . $id)->find();
     if (empty($user)) {
         $this->message('未找到指定会员信息!', __URL__ . '/index');
     }
     $account_type = I('account_type', 1);
     $bg_type = I('bg_type', 1);
     $addmoney = I('addmoney', 0);
     $reason = I('reason', '');
     if ($addmoney <= 0) {
         $this->message('请填写变动金额!', __URL__ . '/addmoney/id/' . $id);
     }
     if ($reason == '') {
         $this->message('请填写变更原因!', __URL__ . '/addmoney/id/' . $id);
     }
     if ($account_type == 1) {
         if ($bg_type == 1) {
             $money = $user['money'] + $addmoney;
             $content = '增加账户余额' . $addmoney;
         } else {
             $money = $user['money'] - $addmoney;
             $content = '减少账户余额' . $addmoney;
             $addmoney = 0 - $addmoney;
         }
         if ($money < 0) {
             $this->message('该人账户可用余额已不足以冲减!', __URL__ . '/addmoney/id/' . $id);
         }
         $data['money'] = $money;
     } else {
         if ($account_type == 2) {
             if ($bg_type == 1) {
                 $money = $user['refer_money'] + $addmoney;
                 $content = '增加可用佣金' . $addmoney;
             } else {
                 $money = $user['refer_money'] - $addmoney;
                 $content = '减少可用佣金' . $addmoney;
                 $addmoney = 0 - $addmoney;
             }
             $data['refer_money'] = $money;
             if ($money < 0) {
                 $this->message('该人账户可用佣金已不足以冲减!', __URL__ . '/addmoney/id/' . $id);
             }
         }
     }
     $user_model->startTrans();
     if (false !== $user_model->where('id=\'' . $id . '\'')->data($data)->save()) {
         $account_log['user_id'] = $id;
         $account_log['stage'] = 'admin';
         $account_log['money'] = $addmoney;
         $account_log['comm'] = $reason;
         $account_log['addtime'] = $this->getDate();
         if ($account_type == 1) {
             $account_log['remain_money'] = $money;
             $account_log['remain_refer_money'] = $user['refer_money'];
         } else {
             if ($account_type == 2) {
                 $account_log['remain_money'] = $user['money'];
                 $account_log['remain_refer_money'] = $money;
             }
         }
         if (false !== $user_account->data($account_log)->add()) {
             $user_model->commit();
             $content = '对会员' . $user['username'] . $content . ',若为本人操作,请忽略该条提醒!';
             send_fetion($content);
             $this->message('操作成功', __URL__ . '/index');
         } else {
             $user_model->rollback();
             $this->message('操作失败1:' . $user_account->getError(), __URL__ . '/addmoney/id/' . $id);
         }
     } else {
         $user_model->rollback();
         $this->message('操作失败2:' . $user_account->getDbError());
     }
 }