public function _initialize() { import("ORG.Error.Error"); $code = $this->checkToken(); if ($code != Error::SUCCESS_OK) { $this->ajaxReturn($code, Error::getErrMsg($code), $code); } }
public function token() { if ($this->checkUser()) { $time = time(); //返回当前时间 $token = sha1($this->ecid . $this->appid . $this->appsecret . $time); //计算字符串的 SHA-1 散列 $req = array('access_token' => $token, 'expires_in' => 7200); S('api_token_' . $this->ecid, $token, 7200); //缓存 return $req; } else { $req = array('errcode' => Error::ERROR_API_DISTRUST_USER, 'errmsg' => Error::getErrMsg(Error::ERROR_API_DISTRUST_USER)); return $req; } }
public function _initialize() { //获取用户信息config $this->_userCfg = C('LOGIN_USER'); //检查是否登录 $code = $this->isLogin(); if ($code != Error::SUCCESS_OK) { $this->error(Error::getErrMsg($code), '/'); } //检查权限 /*$code = $this->checkAuth(); if ( $code != Error::SUCCESS_OK ) { $this->error( Error::getErrMsg( $code ) ); }*/ $this->assign("ecid", session($this->_userCfg['ECID'])); $this->assign("city", session($this->_userCfg['CITY'])); }
public function token() { switch ($this->_method) { case 'get': // get请求处理代码 $data['ecid'] = I('get.ecid'); $data['grant_type'] = I('get.grant_type'); $data['appid'] = I('get.appid'); $data['appsecret'] = I('get.appsecret'); $auth = new \Api\Auth\Auth($data); $req = $auth->token(); $this->response($req, 'json'); break; case 'put': // put请求处理代码 // put请求处理代码 case 'post': // post请求处理代码 $req = array('errcode' => Error::ERROR_API_DISTRUST_REQUEST, 'errmsg' => Error::getErrMsg(Error::ERROR_API_DISTRUST_REQUEST)); $this->response($data, 'json'); break; } }
public function msgDelete() { if (!IS_POST) { _404('页面不存在', U('index')); } //审核表设置数据不通过 $opt = I('post.'); if ($row = M("Company_fw_reply_review")->where("modifyId = " . $opt['id'])->find()) { $newOpt['pass'] = -1; $newOpt['id'] = $row['id']; $newOpt['reviewUserId'] = session($this->_userCfg['UID']); $newOpt['reviewTime'] = date("Y-m-d H:i:s"); M("Company_fw_reply_review")->save($newOpt); } //删除回复表信息 if (M("Company_fw_reply")->where("id = '" . $_POST["id"] . "' AND ecid = '" . $_POST['ecid'] . "'")->delete()) { $data["status"] = Error::SUCCESS_OK; } else { $data["status"] = Error::ERROR_DELETE_HANDLE_ERR; $data["info"] = Error::getErrMsg(Error::ERROR_DELETE_HANDLE_ERR); } $this->ajaxReturn($data, "JSON"); }
public function getCodenum() { switch ($this->_method) { case 'get': // get请求处理代码 break; case 'put': // put请求处理代码 break; case 'post': // post请求处理代码 $ecid = I('get.ecid'); $token = I('get.token'); $date = I('get.time'); if (Auth::checkToken($token, $ecid)) { $fwnum = new \Api\Fw\ExData($ecid, ''); $res = $fwnum->getNum($date); if ($res) { $result['code'] = 0; $result['msg'] = $res; } else { $result['code'] = -1; $result['msg'] = '失败!'; } $this->response($result, 'json'); } else { $req = array('errcode' => Error::ERROR_API_DISTRUST_USER, 'errmsg' => Error::getErrMsg(Error::ERROR_API_DISTRUST_USER)); $this->response($req, 'json'); } break; } }
public function updateService() { if (!IS_POST) { _404('页面不存在', U('index')); } $data = M("Company_services")->where("serviceId = '" . $_POST['id'] . "' AND ecid = '" . $_POST['ecid'] . "'")->find(); $opt['id'] = $data['id']; $opt['endTime'] = date('Y-m-d', strtotime($data['endTime'] . "+" . $_POST['year'] . " year")); if (M("Company_services")->save($opt)) { $result["status"] = Error::SUCCESS_OK; //清除企业缓存 $ecid_cache = 'company_info' . session($this->_userCfg['ECID']); if (S($ecid_cache)) { S($ecid_cache, NULL); } } else { $result["status"] = Error::ERROR_EDIT_HANDLE_ERR; $result["info"] = Error::getErrMsg(Error::ERROR_EDIT_HANDLE_ERR); } $this->ajaxReturn($result, "JSON"); }
public function tagsHandle() { if (!IS_POST) { _404('页面不存在', U('index')); } $m = M("Company_tags"); if ($m->where("ecid = '" . session($this->_userCfg["ECID"]) . "' AND name = '" . I('post.name') . "'")->find()) { $result["status"] = Error::ERROR_BRAND_TAGS_NAME_EXIST; $result["info"] = Error::getErrMsg(Error::ERROR_BRAND_TAGS_NAME_EXIST); } else { $opt['name'] = strip_tags(I('post.name')); $opt['ecid'] = session($this->_userCfg["ECID"]); if (I('post.handleType') == "add") { if ($m->add($opt)) { $result["status"] = Error::SUCCESS_OK; } else { $result["status"] = Error::ERROR_EDIT_HANDLE_ERR; $result["info"] = Error::getErrMsg(Error::ERROR_EDIT_HANDLE_ERR); } } else { if (I('post.handleType') == "edit") { if ($m->where('id = ' . I('post.id'))->save($opt)) { $result["status"] = Error::SUCCESS_OK; } else { $result["status"] = Error::ERROR_EDIT_HANDLE_ERR; $result["info"] = Error::getErrMsg(Error::ERROR_EDIT_HANDLE_ERR); } } } } $this->ajaxReturn($result, "JSON"); }
public function index() { $weObj = new Wechat($this->getOption()); //验证合法性 $weObj->valid(); //获取微信参数 $this->wechatMsg = $weObj->getRev()->getRevData(); //回复内容 $response = ''; // //检查是否具有调用权限 $code = $this->checkCompany($weObj->getRevTo(), $weObj->getRevContent()); if ($code != Error::SUCCESS_OK) { echo Error::getErrMsg($code); return; } $this->log($this->companyInfo['ecid']); $this->log($this->wechatMsg['FromUserName']); //添加用户 $this->saveUserInfo($this->companyInfo['ecid'], $this->wechatMsg['FromUserName']); //处理收到的信息 switch ($this->wechatMsg['MsgType']) { case Wechat::MSGTYPE_TEXT: //收到文本信息 $keywordResponse = new \Weixin\Keyword\KeywordResponse($this->companyInfo, $this->wechatMsg); $response = $keywordResponse->getResponse(); break; case Wechat::MSGTYPE_EVENT: //收到事件信息 $eventResponse = new \Weixin\Event\EventResponse($this->companyInfo, $this->wechatMsg); $response = $eventResponse->getResponse(); break; case Wechat::MSGTYPE_LOCATION: //收到地理信息 $locationResponse = new \Weixin\Location\LocationResponse($this->companyInfo, $this->wechatMsg); $response = $locationResponse->getResponse(); break; case Wechat::MSGTYPE_IMAGE: //回复图片信息 break; case Wechat::MSGTYPE_VOICE: //处理语音信息 if (assert($this->wechatMsg['Recognition'])) { $keywordResponse = new \Weixin\Keyword\KeywordResponse($this->companyInfo, $this->wechatMsg); $response = $keywordResponse->getResponse(); } break; default: break; } //$this->log(json_encode($response)); // 响应回复 switch ($response['type']) { case Wechat::MSGTYPE_TEXT: $weObj->text($response["content"])->reply(); break; case Wechat::MSGTYPE_NEWS: $weObj->news($response['content'])->reply(); default: $weObj->transfer_customer_service()->reply(); break; } if ($response['ext'] != null) { $this->sendCustomMessage($response['ext'], $this->wechatMsg['FromUserName']); } // 记录日志 $wechatMsg['Content'] = htmlspecialchars_decode($wechatMsg['Content']); //过滤html和实体 $wechatMsg['Content'] = strip_tags($wechatMsg['Content']); \Weixin\Log\ResponseLog::wxReceiveLog($this->companyInfo['ecid'], $this->wechatMsg); }
/** * getQrHandle 获取经销商二维码 */ public function getQrHandle() { if (!IS_POST) { _404('页面不存在', U('index')); } $m = M("Company_qr_type"); $opt['dealerId'] = $_POST['id']; if ($result = $m->where($opt)->find()) { $data['status'] = Error::SUCCESS_OK; $data['info'] = $this->getQrPicUrl($result['ecid'], $result['scene_id']); } else { $data['status'] = ERROR_PRODUCT_SCENEID_EMPTY; $data['info'] = Error::getErrMsg(Error::ERROR_PRODUCT_SCENEID_EMPTY); } $this->ajaxReturn($data, "JSON"); }
public function DepartHandle() { if (!IS_POST) { _404('页面不存在', U('index')); } $opt['id'] = I('post.id'); $opt['department'] = I('post.department'); $opt['info'] = I('post.info'); $m = M('Company_department'); $Data = M('Company_employees'); switch (I("post.handleType")) { case 'add': if ($this->inputNameHandle(I('post.department'))) { $opt['ecid'] = session($this->_userCfg['ECID']); $result = $m->add($opt); if ($result) { $data["status"] = Error::SUCCESS_OK; } else { $data["status"] = Error::ERROR_ADD_HANDLE_ERR; $data["info"] = Error::getErrMsg(Error::ERROR_ADD_HANDLE_ERR); } } else { $data['status'] = ERROR::ERROR_USER_DEPARTNAME_EXIST; $data['info'] = Error::getErrMsg(Error::ERROR_USER_DEPARTNAME_EXIST); } break; case 'edit': if ($m->save($opt)) { $data["status"] = Error::SUCCESS_OK; } else { $data["status"] = Error::ERROR_EDIT_HANDLE_ERR; $data["info"] = Error::getErrMsg(Error::ERROR_EDIT_HANDLE_ERR); } break; case 'delete': if ($m->where("id = '" . I('post.id') . "'")->delete()) { $departmentId['departmentId'] = ''; $Data->where("departmentId = '" . I('post.id') . "'")->save($departmentId); $data["status"] = Error::SUCCESS_OK; } else { $data["status"] = Error::ERROR_EDIT_HANDLE_ERR; $data["info"] = Error::getErrMsg(Error::ERROR_EDIT_HANDLE_ERR); } break; default: $data["status"] = Error::ERROR_EDIT_HANDLE_ERR; $data["info"] = Error::getErrMsg(Error::ERROR_EDIT_HANDLE_ERR); break; } $this->ajaxReturn($data, "JSON"); }
public function sendCustomMessage() { $token = $this->getAppToken(session($this->_userCfg['ECID'])); //如果接口信息不完整,直接返回 if ($token['weixin_AppId'] == '' || $token['weixin_AppSecret'] == '') { $this->ajaxReturn(Error::ERROR_MENU_TOKEN_EMPTY, Error::getErrMsg(Error::ERROR_MENU_TOKEN_EMPTY), 0); } $data['touser'] = I('post.touser'); $data['msgtype'] = I('post.msgtype'); $data['text'] = I('post.text', '', ''); $weObj = new \Org\Weixin\Wechat(); if ($weObj->checkAuth($token['weixin_AppId'], $token['weixin_AppSecret'])) { $result = $weObj->sendCustomMessage($data); if ($result['errcode'] == 0) { $opt['ecid'] = session($this->_userCfg['ECID']); $opt['openId'] = $data['touser']; $opt['responseType'] = 'text'; $opt['content'] = $data['text']['content']; $opt['time'] = date("Y-m-d H:i:s"); M('Company_response')->add($opt); } $this->ajaxReturn($result); } }
public function releaseMenuHandle() { $token = $this->getAppToken(session('ecid')); //如果接口信息不完整,直接返回 if ($token['weixin_AppId'] == '' || $token['weixin_AppSecret'] == '') { $this->ajaxReturn(Error::ERROR_MENU_TOKEN_EMPTY, Error::getErrMsg(Error::ERROR_MENU_TOKEN_EMPTY), 0); } $menu = $this->getMenuSet(session('ecid')); $menu_weixin = array('button' => ''); for ($i = 0; $i < count($menu); $i++) { $menu_weixin['button'][$i] = $this->changeWeixinArray($menu[$i], $token); if ($menu[$i]['hasSub'] == 1) { for ($j = 0; $j < count($menu[$i]['subitem']); $j++) { if (($menu[$i]['subitem'][$j]['responseType'] == null || $menu[$i]['subitem'][$j]['responseType'] == "text") && $menu[$i]['subitem'][$j]['responseText'] == "") { $data['data'] = ERROR::ERROR_MENU_REPLY_EMPTY; $data['info'] = $menu[$i]['subitem'][$j]['name'] . ":" . Error::getErrMsg(Error::ERROR_MENU_REPLY_EMPTY); $this->ajaxReturn($data, "JSON"); } } } else { if (($menu[$i]['responseType'] == "text" || $menu[$i]['responseType'] == null) && $menu[$i]['responseText'] == "") { $data['data'] = ERROR::ERROR_MENU_REPLY_EMPTY; $data['info'] = $menu[$i]['name'] . ":" . Error::getErrMsg(Error::ERROR_MENU_REPLY_EMPTY); $this->ajaxReturn($data, "JSON"); } } } $weObj = new \Org\Weixin\Wechat(); if ($weObj->checkAuth($token['weixin_AppId'], $token['weixin_AppSecret'])) { if ($tmp = $weObj->createMenu($menu_weixin)) { $data['data'] = Error::SUCCESS_OK; $data['info'] = Error::getErrMsg(Error::SUCCESS_OK); $this->ajaxReturn($data, 'JSON'); } } }
public function delHandle() { //获取所有post参数 $opt = I('post.'); if (!assert($opt['id']) || !assert($opt['ecid'])) { $result["data"] = Error::ERROR_GENERAL; $result["info"] = Error::getErrMsg(Error::ERROR_GENERAL); } $m = M('Company_keyword_response'); if ($m->where($opt)->delete()) { $result["data"] = Error::SUCCESS_OK; } else { $result["data"] = Error::ERROR_EDIT_HANDLE_ERR; $result["info"] = Error::getErrMsg(Error::ERROR_EDIT_HANDLE_ERR); } $this->ajaxReturn($result, "JSON"); }
public function adHandle() { if (!IS_POST) { _404('页面不存在', U('index')); } $opt['name'] = I('post.name'); $opt['value'] = I('post.value'); $opt['type'] = I('post.type'); $opt['ecid'] = I('post.ecid'); $opt['description'] = I('post.description'); $opt['width'] = I('post.width'); $opt['height'] = I('post.height'); $opt['maxNum'] = I('post.maxNum'); $opt['modifyUserId'] = session($this->_userCfg['UID']); $opt['modifyTime'] = date("Y-m-d H:i:s"); $m = M('Company_ad'); switch (I("post.handleType")) { case 'add': if ($this->inputNameHandle(I('post.name'), I('post.value'))) { $result = $m->add($opt); if ($result) { $data["status"] = Error::SUCCESS_OK; } else { $data["status"] = Error::ERROR_ADD_HANDLE_ERR; $data["info"] = Error::getErrMsg(Error::ERROR_ADD_HANDLE_ERR); } } else { $data["status"] = Error::ERROR_CONTENT_FALSE; $data["info"] = Error::getErrMsg(Error::ERROR_CONTENT_FALSE); } break; case 'edit': $option['name'] = I('post.name'); $option['id'] = array('neq', I('post.id')); $condition['value'] = I('post.value'); $condition['id'] = array('neq', I('post.id')); if ($m->where($option)->find()) { $data["status"] = Error::ERROR_ADNAME_EXIST; $data["info"] = Error::getErrMsg(Error::ERROR_ADNAME_EXIST); } else { if ($m->where($condition)->find()) { $data["status"] = Error::ERROR_ADVALUE_EXIST; $data["info"] = Error::getErrMsg(Error::ERROR_ADVALUE_EXIST); } else { $opt['id'] = I('post.id'); if ($m->save($opt)) { $data["status"] = Error::SUCCESS_OK; } else { $data["status"] = Error::ERROR_EDIT_HANDLE_ERR; $data["info"] = Error::getErrMsg(Error::ERROR_EDIT_HANDLE_ERR); } } } break; case 'delete': if ($m->where("id = '" . I('post.id') . "'")->delete()) { $data["status"] = Error::SUCCESS_OK; } else { $data["status"] = Error::ERROR_EDIT_HANDLE_ERR; $data["info"] = Error::getErrMsg(Error::ERROR_EDIT_HANDLE_ERR); } break; default: $data["status"] = Error::ERROR_EDIT_HANDLE_ERR; $data["info"] = Error::getErrMsg(Error::ERROR_EDIT_HANDLE_ERR); break; } $this->ajaxReturn($data, "JSON"); }
/** * 问答活动中问题编辑处理 * @author 黄浩 * 1、修改历史 2014-08-10创建 */ public function editHandle() { if (!IS_POST) { _404('页面不存在', U('index')); } $opt['question'] = I('post.arr', "", false); //取消数据过滤。 $opt['modifyUserId'] = session($this->_userCfg['UID']); $opt['modifyTime'] = date("Y-m-d H:i:s"); $m = M('Company_activity_question'); if ($m->where('id =' . I('post.id'))->save($opt)) { $result["status"] = Error::SUCCESS_OK; } else { $result["status"] = Error::ERROR_ADD_HANDLE_ERR; $result["info"] = Error::getErrMsg(Error::ERROR_ADD_HANDLE_ERR); } $this->ajaxReturn($result, "JSON"); }
public function advertHandle() { if (!IS_POST) { _404('页面不存在', U('index')); } //判断是否是post方式传值 $m = M("Company_ad_set"); //将以post方式传值赋值给opt数组 $opt['adId'] = I('post.adId'); $opt['ecid'] = I('post.ecid'); $opt['brandId'] = I('post.brandId'); $opt['productId'] = I('post.productId'); $opt['dealerId'] = I('post.dealerId'); $opt['linkUrl'] = I('post.linkUrl'); // $opt['tagId'] = I('post.tagId'); $opt['imgPath'] = I('post.imgPath'); $opt['modifyUserId'] = session($this->_userCfg["UID"]); $opt['modifyTime'] = date("Y-m-d H:i:s"); /** * 判断操作方式是否为添加,如果是判断是否添加成功,添加成功,提示操作成功信息 * 不成功,提示不成功信息,调用不成功信息获取提示语。 * */ if (I('post.handleType') == "add") { if ($m->add($opt)) { $result["status"] = Error::SUCCESS_OK; } else { $result["status"] = Error::ERROR_EDIT_HANDLE_ERR; $result["info"] = Error::getErrMsg(Error::ERROR_EDIT_HANDLE_ERR); } } /** * 判断操作方式是否为删除,如果是判断是否添加成功,添加成功,提示操作成功信息 * 不成功,提示不成功信息,调用不成功信息获取提示语。 * */ if (I('post.handleType') == "delete") { if ($m->where("id =" . I('post.id'))->delete()) { $result["status"] = Error::SUCCESS_OK; } else { $result["status"] = Error::ERROR_EDIT_HANDLE_ERR; $result["info"] = Error::getErrMsg(Error::ERROR_EDIT_HANDLE_ERR); } } if (I('post.handleType') == "edit") { if ($m->where("id = '" . I('post.id') . "'")->save($opt)) { $result["status"] = Error::SUCCESS_OK; } else { $result["status"] = Error::ERROR_EDIT_HANDLE_ERR; $result["info"] = Error::getErrMsg(Error::ERROR_EDIT_HANDLE_ERR); } } $this->ajaxReturn($result, "JSON"); //以JSON格式返回数据。 }
public function doLogin() { //验证验证码是否正确 if (!$this->checkVerify($_POST['verify'])) { $this->error(\Org\Error\Error::getErrMsg(\Org\Error\Error::ERROR_WRONG_VERIFY)); } //检查数据库是否存在用户 $code = $this->checkUser(); if ($code != \Org\Error\Error::SUCCESS_OK) { $this->error(\Org\Error\Error::getErrMsg($code)); } redirect(U('Admin/Index/index')); }
public function deleteGroup() { if (!IS_POST) { _404('页面不存在', U('index')); } if ($row = M("Company_event_response")->where("responseType = 'news' AND ecid = '" . session($this->_userCfg['ECID']) . "'")->find()) { if ($row['responseMaterialId'] == I('post.id')) { $arr['responseType'] = 'text'; M("Company_event_response")->where("id = " . $row['id'])->save($arr); } } $newsid = M("Company_material_group")->where("id=" . $_POST["id"] . " AND ecid = '" . session($this->_userCfg['ECID']) . "'")->select(); $newsidArr = explode(",", $newsid[0]["materialId"]); for ($i = 0; $i < count($newsidArr); $i++) { M("Company_news")->where("id=" . $newsidArr[$i] . " AND ecid = '" . session($this->_userCfg['ECID']) . "'")->delete(); } if (M("Company_material_group")->where("id=" . $_POST["id"] . " AND ecid = '" . session($this->_userCfg['ECID']) . "'")->delete()) { S("Material_" . $_POST["id"], null); $result["status"] = Error::SUCCESS_OK; } else { $result["status"] = Error::ERROR_DELETE_HANDLE_ERR; $result["info"] = Error::getErrMsg(Error::ERROR_DELETE_HANDLE_ERR); } $this->ajaxReturn($result, "JSON"); }