Example #1
0
 public function buy_order()
 {
     import('ORG.Util.Page');
     $where['type'] = 0;
     $order_model = new UserOrderViewModel();
     $keyword = I('keyword', NULL);
     $ftype = I('ftype', NULL);
     if (!empty($keyword) && !empty($ftype)) {
         if ($ftype == 'user_id') {
             $where[$ftype] = $keyword;
         } else {
             $where[$ftype] = array('like', '%' . $keyword . '%');
         }
     }
     $user_type = I('user_type', '');
     if ($user_type != '') {
         $where['user_type'] = $user_type;
     }
     $starttime = I('starttime', '');
     $endtime = I('endtime', '');
     if ($starttime != '') {
         $_POST['starttime'] = urldecode($starttime);
     }
     if ($endtime != '') {
         $_POST['endtime'] = urldecode($endtime);
     }
     if ($starttime == '') {
         $starttime = '2014-01-01 00:00:00';
     }
     if ($endtime == '') {
         $endtime = '2099-12-30 23:59:59';
     }
     $where['addtime'] = array('between', array($starttime, $endtime));
     if ($_REQUEST['action'] == '删除成功') {
         $mod = new Model('pay_order');
         if (false !== $mod->where($where)->delete()) {
             $this->message('删除成功', __URL__ . '/buy_order');
         } else {
             $this->message('删除失败:' . $mod->getError(), __URL__ . '/buy_order');
         }
     }
     $count = $order_model->where($where)->count();
     $page = new Page($count, 15);
     $show = $page->show();
     $order_list = $order_model->where($where)->order('addtime desc')->limit($page->firstRow . ',' . $page->listRows)->select();
     $type_list = $this->get_user_type();
     $this->assign('type_list', $type_list);
     $this->assign('order_list', $order_list);
     $this->assign('count', $count);
     $this->assign('show', $show);
     $this->display();
 }
Example #2
0
 public function mobansave()
 {
     if (!IS_POST) {
         $this->message2('无效请求!', __APP__ . '/Admin');
     }
     $site_template = I('site_template', 'default');
     $data = array();
     $data['site_template'] = $site_template;
     $config_model = new Model('config');
     if (false !== $config_model->where('id=1')->data($data)->save()) {
         $this->message2('模板设置成功!', 'moban');
     } else {
         $this->message2('模板设置失败:' . $config_model->getError(), 'moban');
     }
 }
Example #3
0
 function add()
 {
     $user = new Model('user');
     //这个数组信息,如查你用上了自动添充等,他的返回值更多啊。不仅仅只有我们看到的这些数据
     //增,删,改,查   CURD  C
     if ($vo = $user->create()) {
         $user->password = md5($user->password);
         if ($user->add()) {
             $this->success('添加成功');
         } else {
             $this->error('添加失败');
         }
         //$this->success('create成功');
         //dump($vo);
         //去考虑为什么会这样?
         //success这个方法是执行成功的一个方法,他会给出对应的跳转页面,跳转时间,还有成功信息提示
         //这个模版不用自己去写。example 就是希望大家能够很好的学习一下别人是怎么写的啊
     } else {
         dump($vo);
         //是thinkphp当中提供的一个执行失败的方法。在这个方法当中,执行失败,代码就不会向后继续执行
         $this->error($user->getError());
     }
 }
Example #4
0
 public function rule_del()
 {
     $id = I('id', NULL);
     if (!empty($id)) {
         if (is_array($id)) {
             $where_e = 'imp_id in (' . implode(',', $id) . ')';
             $where = 'id in  (' . implode(',', $id) . ')';
         } else {
             $where_e = 'imp_id = ' . $id;
             $where = ' id = ' . $id;
         }
         $count = M('xiaohao_type')->where($where_e)->count();
         if (0 < $count) {
             $this->message('该导入规则正在被使用,系统将不能删除!', __URL__ . '/rule_index');
         }
         $model = new Model('imp_rule_xh');
         if (false !== $model->where($where)->delete()) {
             $this->message('删除成功', __URL__ . '/rule_index');
         } else {
             $this->message('删除失败:' . $model->getError(), __URL__ . '/rule_index');
         }
     } else {
         $this->message('请选择删除对象', __URL__ . '/rule_index');
     }
 }
Example #5
0
 public function type_del()
 {
     $id = I('id', NULL);
     if (!empty($id)) {
         $model = new Model('kefu_type');
         if (is_array($id)) {
             $where = 'id in (' . implode(',', $id) . ')';
             $where_a = 'kf_type in (' . implode(',', $id) . ')';
         } else {
             $where = 'id = ' . $id;
             $where_a = 'kf_type =' . $id;
         }
         $count = M('kefu')->where($where_a)->count();
         if (0 < $count) {
             $this->message('该客服组下已经存在客服,不能删除!', __URL__ . '/type_index');
         }
         if (false !== $model->where($where)->delete()) {
             $this->message('删除成功', __URL__ . '/type_index');
         } else {
             $this->message('删除失败:' . $model->getError(), __URL__ . '/type_index');
         }
     } else {
         $this->message('请选择删除对象', __URL__ . '/index');
     }
 }
Example #6
0
 public function dhsave()
 {
     if (!IS_POST) {
         $this->message2('无效请求!', __APP__ . '/Index');
     }
     $userid = session('userid');
     $order_money = I('total_price', 0);
     if ($order_money <= 0) {
         $this->message2('订单金额不能小于0', 'dh');
     }
     $order_nums = I('qty_item_1', 0);
     if ($order_nums <= 0) {
         $this->message2('请填写订单数目!', 'dh');
     }
     $type_id = I('type_id', '');
     if (empty($type_id) || $type_id == '') {
         $this->message2('请选择单号类型!', 'dh');
     }
     $curr_type = M('danhao_type')->where('id=' . $type_id)->find();
     if ($curr_type['state'] == 1) {
         $this->message2('该单号类型目前暂停出售,暂不能下单!', 'dh');
     }
     $where_k['type_id'] = $type_id;
     $where_k['isused'] = 0;
     $count = M('danhao')->where($where_k)->count();
     if ($count < $order_nums) {
         $this->message2('系统内单号数量不足,请联系网站客服!', 'dh');
     }
     $danhao_list_temp = M('danhao')->where($where_k)->limit($order_nums)->select();
     $danhao = array();
     foreach ($danhao_list_temp as $dh) {
         $temp = array();
         $temp['id'] = $dh['id'];
         $temp['note_no'] = $dh['note_no'];
         $danhao[] = $temp;
     }
     $user_model = new Model('user');
     $user = $user_model->where('id=' . $userid)->find();
     $money = $user['money'];
     if ($money < $order_money) {
         $this->message2('你的账户可用金额不足,请先充值!', U('Cash/recharge'));
     }
     $user_model->startTrans();
     $userdata['id'] = $userid;
     $userdata['money'] = $user['money'] - $order_money;
     $userdata['used_money'] = $user['used_money'] + $order_money;
     if (false !== $user_model->data($userdata)->save()) {
         $order_no = $this->create_orderno('DHBuy');
         $reason = '(购买单号) 订单号 ' . $order_no;
         $account_log = array();
         $account_log['user_id'] = $userid;
         $account_log['stage'] = 'buy';
         $account_log['money'] = 0 - $order_money;
         $account_log['comm'] = $reason;
         $account_log['addtime'] = $this->getDate();
         $account_log['remain_money'] = $userdata['money'];
         $account_log['remain_refer_money'] = $user['refer_money'];
         $account_log['order_no'] = $order_no;
         $account_log_model = new Model('account_log');
         $return_1 = D('account_log')->data($account_log)->add();
         $paydata = array();
         $paydata['user_id'] = $userid;
         $paydata['user_type'] = $user['user_type'];
         $paydata['pay_money'] = $order_money;
         $paydata['order_no'] = $order_no;
         $paydata['type'] = 0;
         $paydata['comm'] = '购买单号订单';
         $paydata['status'] = 1;
         $paydata['addtime'] = $this->getDate();
         $return_2 = M('pay_order')->data($paydata)->add();
         if ($return_1 && $return_2) {
             $i = 0;
             $order_time = $this->getDate();
             $result = true;
             $order_no_string = '';
             foreach ($danhao as $dh) {
                 $order_no_string .= $dh['note_no'] . ',';
                 $danhao_data = array();
                 $danhao_data['id'] = $dh['id'];
                 $danhao_data['isused'] = 1;
                 $danhao_data['order_type'] = 0;
                 $danhao_data['order_no'] = $order_no;
                 $return_3 = D('danhao')->data($danhao_data)->save();
                 if (!$return_3) {
                     $result = false;
                 }
             }
             if (!$result) {
                 $user_model->rollback();
                 $this->message2('下单失败1:' . $user_model->getError(), U('dh'));
             }
             $danhao_order_data = array();
             $danhao_order_data['user_id'] = $userid;
             $danhao_order_data['type_id'] = $type_id;
             $danhao_order_data['order_no'] = $order_no;
             $danhao_order_data['order_time'] = $order_time;
             $danhao_order_data['order_status'] = 1;
             $danhao_order_data['note_no'] = rtrim($order_no_string, ',');
             $result_4 = D('danhao_order')->data($danhao_order_data)->add();
             if (!$result_4) {
                 $user_model->rollback();
                 $this->message2('下单失败2:' . $user_model->getError(), U('dh'));
             }
             $refer_users = calc_commission($userid, 1, 2, $type_id);
             $add_result = true;
             if (!empty($refer_users)) {
                 $add_result = addrefer_money($refer_users, 1, $order_nums, 2, $order_no);
             }
             if (!$add_result) {
                 $user_model->rollback();
                 $this->message2('下单失败3:' . $user_model->getError(), U('dh'));
             }
             $user_model->commit();
             $this->message2('订单提交成功!', U('Log/dh_log', array('ftype' => 'order_no', 'keyword' => $order_no)));
         } else {
             $user_model->rollback();
             $this->message2('下单失败4:' . $user_model->getError(), U('dh'));
         }
     } else {
         $user_model->rollback();
         $this->message2('下单失败5:' . $user_model->getError(), U('dh'));
     }
 }
Example #7
0
 public function deal_change()
 {
     if (!IS_POST) {
         $this->message2('无效请求!', __APP__ . '/Index');
     }
     $money = I('money', 0);
     if ($money <= 0) {
         $this->message2('转换金额必须大于0', __APP__ . '/User/Home');
     }
     if ($money % 1 != 0) {
         $this->message2('转换金额必须为整数!', __APP__ . '/User/Home');
     }
     $userid = session('userid');
     $user_model = new Model('user');
     $user = $user_model->where('id=' . $userid)->find();
     if (empty($user)) {
         $this->message2('获取用户信息出错!', __APP__ . '/User/Home');
     }
     $refer_money = $user['refer_money'];
     if ($refer_money < $money) {
         $this->message2('转换金额不能高于当前可用佣金!', __APP__ . '/User/Home');
     }
     $userdata['id'] = $userid;
     $userdata['refer_money'] = $user['refer_money'] - $money;
     $userdata['money'] = $user['money'] + $money;
     $user_model->startTrans();
     $result = $user_model->data($userdata)->save();
     if ($result) {
         $account_log_model = new Model('account_log');
         $reason = '佣金转换成账户余额-佣金减少';
         $account_log = array();
         $account_log['user_id'] = $userid;
         $account_log['stage'] = 'change';
         $account_log['money'] = 0 - $money;
         $account_log['comm'] = $reason;
         $account_log['addtime'] = $this->getDate();
         $account_log['remain_money'] = $userdata['money'];
         $account_log['remain_refer_money'] = $userdata['refer_money'];
         $result_1 = D('account_log')->data($account_log)->add();
         $reason = '佣金转换成账户余额-账户余额增加';
         $account_log['money'] = $money;
         $account_log['comm'] = $reason;
         $result_2 = D('account_log')->data($account_log)->add();
         if ($result_1 && $result_2) {
             $user_model->commit();
             $this->message2('转换成功!', __APP__ . '/User/Home');
         } else {
             $user_model->rollback();
             $this->message2('佣金转换失败:' . $user_model->getError(), __APP__ . '/User/Home');
         }
     } else {
         $user_model->rollback();
         $this->message2('佣金转换失败:' . $user_model->getError(), __APP__ . '/User/Home');
     }
 }
Example #8
0
 public function log_save()
 {
     if (!IS_POST) {
         $this->message2('无效请求', __APP__);
     }
     $is_update = I('is_update', 0);
     $is_update1 = I('is_update1', 0);
     $id = I('id', '');
     if ($id == '') {
         $this->message2('未指定更新项!', 'kb_log');
     }
     $url = U('log_update', array('id' => $id));
     $log = M('kongbao_order')->where('id=' . $id)->find();
     if ($log['exp_status'] == 1) {
         $this->message2('该订单已完成,不能再修改!', 'kb_log');
     }
     if ($is_update == 1) {
         $address_province = $_POST['send_province'];
         if ($address_province == '省份') {
             $this->message2('请正确填写发货省份信息!', $url);
         }
         $address_province = $_POST['send_city'];
         if ($address_province == '地级市') {
             $this->message2('请正确填写发货地级市信息!', $url);
         }
         $address_province = $_POST['send_district'];
         if ($address_province == '市、县级市') {
             $this->message2('请正确填写发货区县信息!', $url);
         }
     } else {
         $_POST['send_province'] = $log['send_province'];
         $_POST['send_city'] = $log['send_city'];
         $_POST['send_district'] = $log['send_district'];
         $_POST['send_address'] = $log['send_address'];
     }
     unset($_POST['is_update']);
     if ($is_update1 == 1) {
         $address_province = $_POST['rec_province'];
         if ($address_province == '省份') {
             $this->message2('请正确填写收货省份信息!', $url);
         }
         $address_province = $_POST['rec_city'];
         if ($address_province == '地级市') {
             $this->message2('请正确填写收货地级市信息!', $url);
         }
         $address_province = $_POST['rec_district'];
         if ($address_province == '市、县级市') {
             $this->message2('请正确填写收货区县信息!', $url);
         }
         $_POST['rec_address'] = $_POST['rec_province'] . ' ' . $_POST['rec_city'] . ' ' . $_POST['rec_district'] . ' ' . $_POST['rec_address'];
     } else {
         $_POST['rec_province'] = $log['rec_province'];
         $_POST['rec_city'] = $log['rec_city'];
         $_POST['rec_district'] = $log['rec_district'];
         $_POST['rec_address'] = $log['rec_address'];
     }
     unset($_POST['is_update1']);
     $send_name = I('send_name', '');
     $send_shouji = I('send_shouji', '');
     $send_phone = I('send_phone', '');
     $send_zipcode = I('send_zipcode', '');
     if (empty($send_name) || $send_name == '') {
         $this->message2('发货人姓名不能为空!', $url);
     }
     if ($send_shouji == '' && $send_phone == '') {
         $this->message2('发货人手机号或者联系电话可任选其一填写!', $url);
     }
     $rec_name = I('rec_name', '');
     $rec_shouji = I('rec_shouji', '');
     $rec_phone = I('rec_phone', '');
     $rec_zipcode = I('rec_zipcode', '');
     if (empty($rec_name) || $rec_name == '') {
         $this->message2('收货人姓名不能为空!', $url);
     }
     if ($rec_shouji == '' && $rec_phone == '') {
         $this->message2('收货人手机号或者联系电话可任选其一填写!', $url);
     }
     $model = new Model('kongbao_order');
     $data = $model->create();
     if (false !== $model->where('id=' . $id)->save($data)) {
         $this->message2('编辑成功', 'kb_log');
     } else {
         $this->message2('编辑失败:' . $model->getError(), 'kb_log');
     }
 }
Example #9
0
 public function restore_use()
 {
     $id = I('id', NULL);
     if (!empty($id)) {
         if (is_array($id)) {
             $where = 'id  in (' . implode(',', $id) . ')';
         } else {
             $where = 'id = ' . $id;
         }
         $model = new Model('kongbao');
         $kongbao_data = array();
         $kongbao_data['isused'] = 0;
         $kongbao_data['order_type'] = 0;
         $kongbao_data['order_no'] = '';
         if (false !== $model->where($where)->data($kongbao_data)->save()) {
             $this->message('空包单号恢复使用成功', __URL__ . '/invalid_index');
         } else {
             $this->message('空包单号恢复使用失败:' . $model->getError(), __URL__ . '/invalid_index');
         }
     } else {
         $this->message('请选择要恢复使用的空包单号!', __URL__ . '/invalid_index');
     }
 }
Example #10
0
 public function admin_log_del()
 {
     $model = new Model('admin_log');
     if (IS_POST) {
         $ids = I('del_id', '');
         if ($ids == '') {
             $this->message2('请选择要删除的信息!', __URL__ . '/admin_log');
         }
         $where = 'id in (' . implode(',', $ids) . ')';
     } else {
         $id = I('id', '');
         if ($id == '') {
             $this->message2('请选择要删除的信息!', __URL__ . '/admin_log');
         } else {
             $where = 'id =' . $id;
         }
     }
     if (false !== $model->where($where)->delete()) {
         $this->message('日志删除成功!', __URL__ . '/admin_log');
     } else {
         $this->message('日志删除失败:' . $model->getError(), __URL__ . '/admin_log');
     }
 }
Example #11
0
 public function update()
 {
     if (!IS_POST) {
         $this->message2('无效请求!', __APP__ . '/Admin');
     }
     $id = I('id', NULL);
     if (empty($id)) {
         $this->message2('无效参数!', __APP__ . '/Admin');
     }
     $userdata = array();
     $userdata['id'] = $id;
     $userdata['isvalid'] = I('isvalid', 1);
     $userdata['user_qq'] = I('user_qq', '');
     $userdata['user_type'] = I('user_type', 1);
     $refer_id = I('refer_id', 0);
     $refer_user = M('user')->where('id=' . $refer_id)->find();
     if (empty($refer_user)) {
         $refer_id = 0;
     }
     $userdata['refer_id'] = $refer_id;
     $user_model = new Model('user');
     $result = $user_model->data($userdata)->save();
     if (false !== $result) {
         $this->message('操作成功', 'index');
     } else {
         $this->message('操作失败:' . $user_model->getError(), 'index');
     }
 }
 /**
 +----------------------------------------------------------
 * 更新一个数据对象
 +----------------------------------------------------------
 * @access protected 
 +----------------------------------------------------------
 * @param Model $model 数据对象 
 +----------------------------------------------------------
 * @return void
 +----------------------------------------------------------
 * @throws ThinkExecption
 +----------------------------------------------------------
 */
 protected function _update($model)
 {
     $vo = $model->create('', 'edit');
     if (!$vo) {
         $this->error($model->getError());
     }
     $id = is_array($vo) ? $vo[$model->getPk()] : $vo->{$model->getPk()};
     $guid = $model->getModelName() . '_' . $id;
     if (S($guid) == $vo) {
         $this->error(L('无需更新!'));
     }
     $result = $model->save($vo);
     if ($result) {
         $vo = $model->getById($id);
         // 保存成功,更新缓存Vo对象
         S($guid, $vo);
         //数据保存触发器
         if (method_exists($this, '_trigger')) {
             $this->_trigger($vo);
         }
         if (!empty($_FILES)) {
             //如果有文件上传
             //执行默认上传操作
             //保存附件信息到数据库
             $this->_upload(MODULE_NAME, $id);
         }
         //成功提示
         $this->success(L('_UPDATE_SUCCESS_'));
     } else {
         //错误提示
         $this->error($model->getError());
     }
 }
Example #13
0
 public function binds()
 {
     $openid = isset($_SESSION['qqopenid']) ? $_SESSION['qqopenid'] : '';
     if ($openid == '') {
         $this->message2('缺少QQ登陆授权码,注册失败!', __APP__ . '/Index');
     }
     $user_model = new Model('user');
     $data = array();
     $is_valid = 1;
     if ($this->reg_setting['shenhe'] == 1) {
         $data['isvalid'] = 0;
         $is_valid = 0;
     }
     if ($this->reg_setting['verycode'] == 1) {
         if (session('verify') != md5(strtoupper(I('captcha', '')))) {
             $this->message2('验证码不正确!', U('bind'));
         }
     }
     $zs_money = 0;
     if ($this->reg_setting['zs_valid'] == 1 && 0 < $this->reg_setting['zs_money']) {
         $zs_money = $this->reg_setting['zs_money'];
     }
     $zs_user_type = 1;
     if ($reg_setting['zs_levl'] == 1 && 0 < $reg_setting['zs_user_type']) {
         $zs_user_type = $reg_setting['zs_user_type'];
     }
     $create_ip = get_client_ip();
     if ($this->reg_setting['reg_ip'] == 1) {
         $ip_counts = $this->reg_setting['ip_counts'];
         $reg_counts = M('user')->where('create_ip="' . $create_ip . '"')->count();
         if ($ip_counts <= $reg_counts) {
             $this->message2('注册失败:您的IP已被限制注册!', __APP__ . '/Index');
         }
     }
     $username = I('user_name', NULL);
     $data['username'] = $username;
     $data['password'] = MD5(I('pwd', NULL));
     $data['email'] = I('email', NULL);
     $data['user_qq'] = I('user_qq', NULL);
     $data['qqopenid'] = $openid;
     if (0 < $zs_money) {
         $data['money'] = $zs_money;
     }
     if (0 < $zs_user_type) {
         $data['user_type'] = $zs_user_type;
     }
     $data['create_time'] = $this->getDate();
     $data['last_login_time'] = $this->getDate();
     $data['last_login_ip'] = get_client_ip();
     $data['login_counts'] = 1;
     $data['create_ip'] = $create_ip;
     if ($reg_setting['reg_mibao'] == 1) {
         $mibao_name = I('mibao_name', '');
         $mibao_daan = I('mibao_daan', '');
         $data['mibao_setting'] = '{name:"' . $mibao_name . '",daan:"' . $mibao_daan . '"}';
         if ($mibao_name == '') {
             $this->message2('请选择保密问题,便于日后找回密码!', __URL__ . '/reg');
         }
         if ($mibao_daan == '') {
             $this->message2('请输入保密答案!', __URL__ . '/reg');
         }
     }
     $userid = $user_model->data($data)->add();
     if (false !== $userid) {
         if (0 < $zs_money) {
             if (0 < $zs_user_type) {
                 $log_array = array();
                 $log_array['user_id'] = $userid;
                 $log_array['stage'] = 'admin';
                 $log_array['money'] = $zs_money;
                 $log_array['remain_money'] = $zs_money;
                 $log_array['user_type'] = $zs_user_type;
                 $log_array['comm'] = '会员注册赠送体验金';
                 $log_array['addtime'] = $this->getDate();
                 M('account_log')->data($log_array)->add();
             }
         }
         session('userid', $userid);
         session('username', $username);
         session('IS_LOGIN', 1);
         session('isvalid', $is_valid);
         $this->message2('注册并成功绑定QQ!', __APP__ . '/Index');
     } else {
         $this->message2('注册失败:' . $user_model->getError(), __APP__ . '/Index');
     }
 }