public function destroyAction($id) { $model = M("Card"); $card = M("Card")->find($id); if (empty($card)) { $this->error("card does not exist!"); } if ($card['status'] != 0 && $card['status'] != 2) { $this->error("非正常状态不能退会!"); } M("Card")->where(array("id" => $id))->setField("status", 4); D("CardOpHistory")->updateStatus($id, 4, 0); // $reason ="退会"; // if(!empty($reason)) // { // $data=array("extension"=>json_encode($card), "reason"=>$reason,"record_id"=>is_user_login(),"club_id"=>get_club_id(),"brand_id"=>get_brand_id(),"type"=>2,"status"=>0); // M("Review")->data($data)->add(); // } $contracts = D("Contract")->getAllContract($id); $paybackmodel = M("PayBack"); foreach ($contracts as $key => $value) { $data = array("contract_id" => $value['id'], "apply_id" => is_user_login(), "club_id" => get_club_id(), "brand_id" => get_brand_id()); $ret = $paybackmodel->where(array("contract_id" => $value['id']))->find(); if (empty($ret)) { M("PayBack")->data($data)->add(); } } $this->success("退会成功,稽核后将有人联系此客户!"); }
public function queryAction() { $uid = is_user_login(); list($page, $sidx, $limit, $sord, $start) = getRequestParams(); $model = D("ClubClassroom"); $condition = array("club_id" => get_club_id()); $filters = I("filters", '', ''); $filters = json_decode($filters); if ($filters->groupOp == 'AND') { $rules = $filters->rules; foreach ($rules as $key => $value) { if ($value->field == "name") { $condition = array_merge($condition, array("name" => array("like", "%{$value->data}%"))); } } } $ret = $model->where($condition)->order("{$sidx} {$sord}")->limit("{$start},{$limit}")->select(); $count = $model->where($condition)->count(); if ($count > 0 && $limit > 0) { $total_pages = ceil($count / $limit); } else { $total_pages = 0; } $response = array("page" => $page, "total" => $total_pages, "records" => $count, "rows" => $ret); $this->ajaxReturn($response); }
public function queryAction() { $model = new \Think\Model(); $brand_id = get_brand_id(); $time = date('Y-m'); $user_id = is_user_login(); $time = I("time"); if (empty($time)) { $start_month = I("start_month"); if (empty($start_month)) { $this->error("请输入月份时间!"); } else { $start_time = $start_month . "-01 00:00:00"; $end_time = $start_month . "-31 23:59:59"; } } else { $start_time = I("start_time"); $end_time = I("end_time"); if (empty($start_time)) { $this->error("请输入开始时间!"); } if (empty($end_time)) { $this->error("请输入终止时间!"); } } $ret = ChannelService::getInstance()->getStatistics($user_id, $start_time, $end_time); $this->ajaxReturn(array("status" => 1, "statistics" => $ret)); }
/** * @function : we used this function for desh_board page * @parametere : * @parametere : */ public function deshboard() { is_user_login(); $this->load->view('admin/includes/header'); $this->load->view('admin/includes/sidebar_list'); $this->load->view('admin/home/deshboard'); $this->load->view('admin/includes/footer'); }
/** * @function : we used this function for add product categories * @parametere : * @parametere : */ public function add_pro_categories() { is_user_login(); $this->load->view('admin/includes/header'); $this->load->view('admin/includes/sidebar_list'); $this->load->view('admin/product_categories/add_product_categories'); $this->load->view('admin/includes/footer'); }
/** * 获得全部文章分类--无限极分类(编辑菜单时选项) * * @descript 递归组合无限极分类,为了编辑页面和增加页面select 展示 * @param $name 表单name名称 * @param $id 当前id * @return array * @author yangyifan <*****@*****.**> */ public static function getAllForSchemaOption($name, $id = 0, $first = true) { //加载函数库 load_func('common'); $data = $id > 0 ? merge_tree_node(obj_to_array(self::where('id', '<>', $id)->where('user_info_id', '=', is_user_login())->where('deleted_at', '=', '0000-00-00 00:00:00')->get())) : merge_tree_node(obj_to_array(self::where('user_info_id', '=', is_user_login())->get())); $first == true && array_unshift($data, ['id' => '0', $name => '顶级分类']); return $data; }
public function doAction($id, $gift_desc) { $record_id = is_user_login(); M("YaaGift")->where("id={$id}")->setField(array("record_id" => $record_id, "gift_status" => 1, "gift_desc" => $gift_desc)); $gift = M("YaaGift")->find($id); M("YaaMember")->where(array("member_id" => $gift['member_id']))->setField(array("gift_status" => 2)); $this->success("领奖成功!"); }
/** * 获得用户全部分类 * * @return \Illuminate\Database\Eloquent\Collection|static[] */ public static function getUserCategory($user_id = null) { //加载函数库 load_func('common'); $user_id = $user_id != null ? $user_id : is_user_login(); $data = obj_to_array(DB::table('user_news_category AS uns')->join('news_cat AS c', 'uns.news_cat_id', '=', 'c.id')->where('uns.user_info_id', '=', $user_id)->where('c.status', '=', 1)->where('c.deleted_at', '=', '0000-00-00 00:00:00')->get()); $data = array_to_obj(merge_tree_child_node($data)); return $data; }
/** * 保存用户头像 * * @param $image * @param null $user_id * @return bool */ public static function saveUserAvatar($image, $user_id = null) { if (!empty($image)) { //加载函数库 load_func('common'); $user_id = $user_id != null ? $user_id : is_user_login(); return self::where('id', '=', $user_id)->update(['face' => $image]); } return false; }
/** * 获得用户组id * * @param $user_id * @return mixed * @author yangyifan <*****@*****.**> */ private static function getFriendGroup($user_id = null) { $user_id = $user_id == null ? is_user_login() : $user_id; $group_info = DB::table('friend_group')->where('user_info_id', '=', $user_id)->where('is_default', '=', '1')->where('deleted_at', '=', '0000-00-00 00:00:00')->first(); if (empty($group_info)) { $id = DB::table('friend_group')->insertGetId(['group_name' => '我的好友', 'created_at' => date('Y-m-d H:i:s'), 'user_info_id' => $user_id, 'is_default' => 1]); return $id; } return $group_info->id; }
/** * 处理添加好友 * * @param AddUsersRequest $request * @author yangyifan <*****@*****.**> */ public function postAddFriend(AddUsersRequest $request) { $user_id = intval($request->get('id')); //搜索内容不能是自己 if ($user_id == is_user_login()) { $this->response(400, trans('response.can_not_add_their_own_friends')); } FriendsModel::addFriend($user_id, trim($request->get('contents'))); $this->response(200, trans('response.send_add_user_message_success')); }
/** * 构造方法 * * @author yangyifan <*****@*****.**> */ public function __construct() { parent::__construct(); $this->disk = Storage::disk('qiniu'); //获得一块硬盘 //加载函数库 load_func('common'); //设置会员头像保存路径 $this->user_avatar_prefix = '/avatar/' . is_user_login() . '/'; }
public function indexAction() { $id = is_user_login(); $mcs = D("McGroup")->getMyGroupMc($id); $this->assign("mcs", $mcs); $this->assign("mcsarr", json_encode($mcs)); $this->assign("is_member", 0); $this->assign("active", "#menu_54"); $this->assign("active_open", "#menu_7"); $this->display(); }
public function dopaybackAction() { $rules = array(array('id', "number", "请输入ID!"), array('price', "require", "请输入正确的价格!"), array('price', '/^\\d*(\\.\\d+)?$/', '请输入正确的价格!')); $model = M("PayBack"); if (!$model->validate($rules)->create()) { $this->error($model->getError()); } $service = \Service\CService::factory("Financial"); $ret = $service->dopayback(I("id"), I("price"), I("desc"), is_user_login()); $this->success("退款成功"); }
public function _initialize() { parent::_initialize(); //echo 'index';exit; //dump($_SESSION);exit; if (is_admin_login()) { redirect('/Home/AdminPage/index?access_token=' . $_GET['access_token']); } elseif (is_user_login()) { redirect('/Home/Index/index?access_token=' . $_GET['access_token']); } }
/** * @function : we used this function for add product * @parametere : * @parametere : */ public function add_product() { is_user_login(); $result = $this->Product_model->read_all(); $data['results'] = $result; // echo "string"; // die; $this->load->view('admin/includes/header'); $this->load->view('admin/includes/sidebar_list'); $this->load->view('admin/product/add_product', $data); $this->load->view('admin/includes/footer'); }
/** * 检测登录 * * @return bool|\Illuminate\Http\RedirectResponse * @author yangyifan <*****@*****.**> */ private function checkIsLogin() { $uid = is_user_login(); if ($uid <= 0 && Request::method() == 'POST') { $this->response(400, trans('response.no_login')); } else { if ($uid <= 0) { header('location:' . action('Home\\UserController@getLogin')); die; } } }
public function testAction() { $auth = new \Think\Auth(); var_dump($auth->check("brand", is_user_login(), 2)); die; if (!$auth->check(MODULE_NAME, is_user_login(), 2)) { $this->error("无此操作权限!"); } else { echo "xx"; die; } }
public function changePasswordAction($original_password, $new_password, $confirm_password) { $id = is_user_login(); $userService = \Service\CService::factory("User"); $ret = $userService->changePassword($id, $original_password, $new_password, $confirm_password); if ($ret) { cookie("sid", null); $this->success("密码修改成功,请重新登陆!", 'Home/Index/index'); } else { $this->error($userService->getError()); } }
public function indexAction() { if (is_user_login()) { if (get_club_id() != 0 || get_brand_id() != 0) { $this->redirect('Home/Main/main'); } else { $this->redirect('Home/Main/main'); } // $this->redirect('Home/Main/teacher'); } $this->display(); }
public function buyAction() { $member_id = I("member_id"); $member = M("MemberBasic")->find(I("member_id")); if (empty($member)) { $this->error("member does not exist"); } $use_recharge = I("use_recharge"); $rules = array(array('pos', 'number', '请输入正确的pos金额!', 1), array('cash', 'number', '请输入正确的现金金额!', 1), array('check', 'number', '请输入正确的支票金额!', 1), array('network', 'number', '请输入正确的支票金额!', 1), array('netbank', 'number', '请输入正确的支票金额!', 1)); $recharge = 0; if ($use_recharge == 1) { $recharge = $member['recharge'] > I("should_pay") ? I("should_pay") : $member['recharge']; } if ($use_recharge == 1 && $recharge != 0) { M("MemberBasic")->where(array("id" => $member_id))->setField("recharge", $member['recharge'] - $recharge); $data = array("member_id" => $member_id, "value" => "-{$recharge}", "record_id" => is_user_login(), "description" => "购定金消费¥{$recharge},余额¥" . ($member['recharge'] - $recharge)); $recharge_id = M("RechargeHistory")->data($data)->add(); } $service = \Service\CService::factory("Financial"); $mc_id = I("type") == 8 ? $member['pt_id'] : $member['mc_id']; $bill_id = $service->addBillProject(I("type"), 0, 0, $member_id, I("should_pay"), 0, get_brand_id(), is_user_login(), get_club_id(), $mc_id, I("description")); if (!$bill_id) { M("MemberBasic")->where(array("id" => $member_id))->setField("recharge", $member['recharge'] + $recharge); if (isset($recharge_id)) { M("RechargeHistory")->delete($recharge_id); } $this->error($service->getError()); } $ret = $service->pay($bill_id, 0, is_user_login(), get_brand_id(), I('description'), I("cash"), I("pos"), I("check"), I("check_num"), get_club_id(), $recharge, I("network"), I("netbank")); if (!$ret) { M("MemberBasic")->where(array("id" => $member_id))->setField("recharge", $member['recharge'] + $recharge); if (isset($recharge_id)) { M("RechargeHistory")->delete($recharge_id); } M("BillProject")->delete($bill_id); $this->error($service->getError()); } if (I("type") == 8) { M("MemberBasic")->where(array("id" => $member_id))->setInc("pt_book_price", I("should_pay")); } if (I("type") == 9) { M("MemberBasic")->where(array("id" => $member_id))->setInc("contract_book_price", I("should_pay")); } // if(!empty($reason)) // { // $contract = M("PtContract")->find($contract_id); // $data=array("extension"=>json_encode($contract),"reason"=>$reason,"record_id"=>is_user_login(),"club_id"=>get_club_id(),"brand_id"=>get_brand_id(),"type"=>1,"status"=>0); // M("Review")->data($data)->add(); // } $this->success("购买成功!", U("Cashier/Book/printreceipts/id/{$ret}")); }
public function indexAction() { if (is_user_brand()) { $clubs = M("Club")->where(array("brand_id" => get_brand_id()))->field('id,club_name')->order("id desc")->select(); } else { $permission = D("FinanceClub")->where(array("user_id" => is_user_login()))->relation(true)->select(); $clubs = array(); foreach ($permission as $key => $value) { $clubs[] = $value['club']; } } $this->assign("clubs", $clubs); $this->display(); }
public function indexAction() { if (is_user_brand()) { parent::indexAction(); return; } $clubs = M("Club")->field('id,club_name')->select(get_club_id()); // $this->assign("clubs",$clubs); $this->assign("clubs", json_encode($clubs)); $this->assign("clubarray", $clubs); $roles = M("AuthGroup")->select(); $this->assign("roles", $roles); $this->selfid = is_user_login(); $this->display(); }
public function _initialize() { parent::_initialize(); if (is_admin_login()) { $data['status'] = 0; $data['info'] = '管理员暂时不能报修'; $this->ajaxReturn($data, 'JSON'); exit; } elseif (is_user_login()) { $data['status'] = 0; $data['info'] = '你没有权限访问'; $this->ajaxReturn($data, 'JSON'); exit; } }
public function getMyGroupMc($id = null) { if (empty($id)) { $id = is_user_login(); } $group_ids = M("McGroup")->where("team_leader_id={$id}")->field("id")->select(); $group_id = array(); foreach ($group_ids as $key => $value) { $group_id[] = $value['id']; } $group_id[] = is_user_login(); $condition = array("group_id" => array("in", $group_id)); $mcs = D("UserExtension")->where($condition)->select(); return $mcs; }
public function consumeAction($code, $name, $phone) { $rules = array(array('code', 'require', '蜘蛛码必须!', 1), array('name', 'require', '姓名必须!', 1), array('phone', 'require', '电话必须!', 1)); $model = D("SpiderCode"); if (!$model->validate($rules)->create()) { $this->error($model->getError()); } $c = M("SpiderCode")->where(array("code" => $code))->find(); if (empty($c)) { $this->error("号码不存在"); } if ($c['valid'] != 0) { $this->error("蜘蛛码被其他人消费!请重新提供!"); } $model->where(array("code" => $code))->setField(array("use_time" => getDbTime(), "record_id" => is_user_login(), "valid" => 1, "name" => $name, "phone" => $phone)); $this->ajaxReturn(array("status" => 1)); }
/** * 获得在线好友 * * @param $params array 用户登录名和密码参数 * @return int * @author yangyifan <*****@*****.**> */ public static function onlineUser() { load_func('instanceof,image,common'); $online_user = get_redis()->hGetAll(config('config.user_list_hash_table')); $item = []; //获得全部我的好友 $my_friends = FriendsModel::getMyFriends(); foreach ($online_user as $user) { $user = unserialize($user); //如果是自己,则跳过 || 如果不是自己好友,则跳过 if ($user->id == is_user_login() || !in_array($user->id, $my_friends)) { continue; } $item[] = ['id' => $user->id, 'name' => $user->user_name, 'face' => get_user_info_face($user->face), 'url' => action("User\\UserController@getIndex", ['id' => $user->id])]; } $data = [['name' => '在线好友', 'nums' => count($item), 'id' => 1, 'item' => $item]]; return $data; }
public function checkTaskAction() { $id = is_user_login(); if (D("User")->isReception($id)) { //check choose pt $ret = M("TaskChoosept")->where("status=0")->order("id asc")->limit(1)->find(); if (!empty($ret)) { $class = M("PtConsumeHistory")->find($ret['history_id']); $member = M("MemberBasic")->find($class['member_id']); $cmd = "choosept"; // M("TaskChoosept")->where("id=".$ret['id'])-> setField(array("status"=>2)); $this->ajaxReturn(array("cmd" => $cmd, "class" => $class, "member" => $member)); } //check print $ret = M("TaskPtprint")->where("status=0")->order("id asc")->limit(1)->find(); if (!empty($ret)) { $class = M("PtConsumeHistory")->find($ret['history_id']); $member = M("MemberBasic")->find($class['member_id']); $cmd = "printpt"; // M("TaskChoosept")->where("id=".$ret['id'])-> setField(array("status"=>2)); $this->ajaxReturn(array("cmd" => $cmd, "class" => $class, "member" => $member, "task" => $ret)); } } }
public function indexAction() { $this->setIndexActiveClass(); $id = I("id"); $this->assign("edit", DIRECTORY_SEPARATOR . MODULE_NAME . DIRECTORY_SEPARATOR . CONTROLLER_NAME . DIRECTORY_SEPARATOR . "index"); $this->assign("exist", DIRECTORY_SEPARATOR . MODULE_NAME . DIRECTORY_SEPARATOR . CONTROLLER_NAME . DIRECTORY_SEPARATOR . "exist"); $this->assign("queryRecommend", DIRECTORY_SEPARATOR . MODULE_NAME . DIRECTORY_SEPARATOR . CONTROLLER_NAME . DIRECTORY_SEPARATOR . "queryRecommend"); $this->assign("action", DIRECTORY_SEPARATOR . MODULE_NAME . DIRECTORY_SEPARATOR . CONTROLLER_NAME . DIRECTORY_SEPARATOR . "add"); if (!empty($id)) { $this->assign("action", DIRECTORY_SEPARATOR . MODULE_NAME . DIRECTORY_SEPARATOR . CONTROLLER_NAME . DIRECTORY_SEPARATOR . "edit"); $model = D("MemberBasic"); $member = $model->find($id); if (!is_user_brand()) { $is_reception = D("User")->isReception(is_user_login()); if (!$is_reception && $member["mc_id"] != is_user_login() && $member['record_id'] != is_user_login() && $member["pt_id"] != is_user_login()) { $this->error("无权查看此用户信息"); } } else { if ($member['brand_id'] != get_brand_id()) { $this->error("无权查看此用户信息"); } } // $mc $this->assign("member", $member); } $model = M("Channel"); $channles = $this->getchannels(); $this->assign("channels", $channles); if ((D("User")->isMc(is_user_login()) || D("User")->isPt(is_user_login())) && empty($id) && MODULE_NAME != 'Reception') { // $mcs=array( D("UserExtension")->find(is_user_login())); $mcs = D("User")->getMc(); } else { $mcs = D("User")->getMc(); } $this->assign("mcs", $mcs); // $brand_id=get_brand_id(); // $users= $model->where("a.id=b.id and a.id=c.uid and b.brand_id=$brand_id and c.group_id=18")->table(array("yoga_user_extension"=>"a","yoga_user"=>"b","yoga_auth_group_access"=>"c"))->field("a.id,a.name_cn")->select(); // $this->assign("users",$users); $model = M("Club"); $clubs = $model->where(array("brand_id" => get_brand_id()))->field("id,club_name")->select(); $model = D("CardSaleclub"); $types = $model->getCanSaleCards(); $this->assign("types", $types); $this->assign("clubs", $clubs); // $mcs= $model->where("a.id=b.id and a.id=c.uid and b.brand_id=$brand_id and c.group_id=6")->table(array("yoga_user_extension"=>"a","yoga_user"=>"b","yoga_auth_group_access"=>"c"))->field("a.id,a.name_cn")->select(); // $this->assign("mcs",$mcs); $this->display("Mc@Visit:index"); }
public function doPayAction() { $goodsModel = M("Goods"); $goodsModel->startTrans(); $service = \Service\CService::factory("Financial"); $bill_project = M("BillProject")->find(I("id")); if (empty($bill_project)) { $goodsModel->rollback(); $this->error("Bill is not exist!"); } $recharge = 0; $member_id = I("member_id"); $member = M("MemberBasic")->find(I("member_id")); $price = $bill_project['price'] - $bill_project['paid']; if (I('use_recharge') == 1) { $recharge = $member['recharge']; $recharge = $recharge > $price ? $price : $recharge; } $ret = $service->pay(I("id"), 1, is_user_login(), get_brand_id(), I("description"), I("cash"), I("pos"), I("check"), I('check_num'), get_club_id(), $recharge, I("network"), I("netbank")); if (!$ret) { $goodsModel->rollback(); $this->error($service->getError()); } if (I('use_recharge') == 1 && $recharge > 0) { M("MemberBasic")->where(array("id" => $member_id))->setField("recharge", $member['recharge'] - $recharge); $data = array("member_id" => $member_id, "value" => "-{$recharge}", "record_id" => is_user_login(), "description" => "支付购物欠款,余额" . ($member['recharge'] - $recharge)); M("RechargeHistory")->data($data)->add(); } $goodsModel->commit(); $this->success("支付成功", U("printreceipts", array("id" => $ret))); }