protected function instantiate($attributes) { $class = get_class($this); if (isset($attributes['type'])) { $class = ServiceHelper::classNameByType($attributes['type']); } $model = new $class(null); return $model; }
public static function FillSessionPm($caller, $sessionPm) { $sessionPm[\Library\Enums\SessionKeys::PmTechnicians] = TechnicianHelper::GetPmTechnicians($caller, $sessionPm); $sessionPm[\Library\Enums\SessionKeys::PmServices] = ServiceHelper::GetPmServices($caller, $sessionPm); /* * Sets * $sessionPm[\Library\Enums\SessionKeys::PmFieldAnalytes] * $sessionPm[\Library\Enums\SessionKeys::PmLabAnalytes] * * And also saves the data filled above. */ AnalyteHelper::StoreListsData($caller, FALSE); self::GetAndStoreCurrentPm($caller->user(), $sessionPm[\Library\Enums\SessionKeys::PmObject]->pm_id()); }
public function edit() { $img_id = $this->_get('id', 'intval'); $uid = session('uid'); $token = session('token'); $ismul = $this->_get('ismul', 'intval'); //判断是否单图文多图文 $db = D('img'); $getkwd['id'] = $img_id; $keyword = $db->where($getkwd)->getField('keyword'); $where['uid'] = $uid; $where['token'] = $token; $where['function'] = 'kefu'; $where['keyword'] = $keyword; $where['status'] = 1; $img_info = $db->where($where)->order('sorts desc')->select(); $itemnum = count($img_info); for ($i = 0; $i < $itemnum; $i++) { if (empty($img_info[$i]['linktype'])) { if (!empty($img_info[$i]['url'])) { $img_info[$i]['linktype'] = 'normal'; } else { $img_info[$i]['linktype'] = 'info'; } } } $this->assign('info', $img_info[0]); $this->assign('itemnum', $itemnum); $this->assign('info2', $img_info); $this->assign('ismul', $ismul); $data = array(); foreach ($img_info as $key => $value) { $data['item_' . $key] = $value; } if ($data) { $this->assign('db_json', json_encode($data)); } else { $this->assign('db_json', null); } $this->assign('services', ServiceHelper::getServices($token)); $this->display(); }
private function tpsEventData($eventType) { //枪神纪最新章节、枪神纪轮播广告 $tpsChooseEventConfKey = "tps_choose_event_conf"; $tpsEventQuestionKey = "tps_event_question"; $tpsEventRuleKey = "tps_event_rule"; $tpsEventAdsKey = "tps_event_advertisements"; $tpsNewEventRuleKey = "tps_new_event_rule"; $tpsNewEventConfKey = "tps_new_event_conf"; $tpsNewEventAdsPicKey = "tps_new_event_ads_pic"; $keyListArr = array($tpsChooseEventConfKey, $tpsEventQuestionKey, $tpsEventRuleKey, $tpsNewEventRuleKey, $tpsEventAdsKey, $tpsNewEventConfKey, $tpsNewEventAdsPicKey); //$tempArr = ServiceHelper::GetValueListByKeyList($keyListArr); $tempArr = ServiceHelper::GetValueListByRedisKeyList($keyListArr); if (empty($eventType)) { $this->tpsEventConf($eventType, $questionNum); } //1.选择题活动 2.拉新活动 if ($eventType == 1) { $tpsChooseEventConfArr = !empty($tempArr) ? $tempArr[$tpsChooseEventConfKey] : array(); $tpsEventQuestionArr = !empty($tempArr) ? $tempArr[$tpsEventQuestionKey] : array(); $tpsEventRuleArr = !empty($tempArr) ? $tempArr[$tpsEventRuleKey] : array(); $this->View->assign("tpsChooseEventConfArr", $tpsChooseEventConfArr); $this->View->assign("tpsEventQuestionArr", $tpsEventQuestionArr); $this->View->assign("tpsEventRuleArr", $tpsEventRuleArr); } else { if ($eventType == 2) { $tpsNewEventRuleArr = !empty($tempArr) ? $tempArr[$tpsNewEventRuleKey] : array(); $tpsNewEventConfArr = !empty($tempArr) ? $tempArr[$tpsNewEventConfKey] : array(); $tpsNewEventAdsPicArr = !empty($tempArr) ? $tempArr[$tpsNewEventAdsPicKey] : array(); $this->View->assign("tpsNewEventRuleArr", $tpsNewEventRuleArr); $this->View->assign("tpsNewEventConfArr", $tpsNewEventConfArr); $this->View->assign("tpsNewEventAdsPicArr", $tpsNewEventAdsPicArr); } } $tpsEventAdsArr = !empty($tempArr) ? $tempArr[$tpsEventAdsKey] : array(); $this->View->assign("eventType", $eventType); $this->View->assign("tpsEventAdsArr", $tpsEventAdsArr); }
public function getUserInfo($uin) { $params = array(); $params['uin'] = $uin; $params['fields'] = "nick"; return ServiceHelper::Call("user.getUserInfo", $params); }
private function is_vip() { $params = array('uin' => is_numeric(Utils::GetValue("uin")) ? Utils::GetValue("uin") : 0); $ret = ServiceHelper::Call("user.checkVipUser", $params); unset($ret['svip_state']); unset($ret['auth_state']); return $ret; // $this->return_format($ret); }
/** * 回答问题 */ private function reply() { $answer = Utils::GetValue("answer"); $answer = trim($answer); if (empty($answer)) { echo '{"status":0, "msg":"请选择答案"}'; exit; } $type = intval(Utils::GetValue("type")); if (!in_array($type, array(1, 2))) { echo '{"status":0,"msg":"提示:参数出现错误!"}'; exit; } //验证活动 $this->checkEvent(); //获取活动配置数据 $tpsEventDataArr = $this->getEventInfofromConf(); $questionArr = $this->getQuestionFromConf(); if (empty($tpsEventDataArr) || empty($questionArr)) { echo json_encode(array("status" => 0, "msg" => '提示:获取活动数据发生错误!请点<a href="http://support.qq.com/write.shtml?fid=744" style="color:#ff0000;width:111px;display:inline;font-family:microsoft yahei;font-size:16px;" target="_blank">【反馈建议】</a>投诉!')); exit; } $questionNum = $tpsEventDataArr[0]["id"]; $eventType = $tpsEventDataArr[0]["eventType"]; //当后台已经更换题型,但是用户未刷新页面,所以需要验证题型是否一致 if ($type != $eventType) { echo '{"status":0,"msg":"提示:活动题型有变化,请刷新页面后再继续!"}'; exit; } $action = $this->packetArr[$eventType]["action"]; $object = $this->packetArr[$eventType]["object"]; //答题规则,每天限1次,无论对错,回答正确不能再回答 //判断是否答对此题记录,action_val:题号; reserve1:答题时间; reserve2:答题结果 $paramsArr = array('event_id' => $this->eventId, 'action' => "question", 'object' => "answer", 'uin' => $this->uin, 'action_val' => $questionNum, 'reserve1' => '', 'reserve2' => 1); $answerArr = ServiceHelper::Call("event.getAction", $paramsArr); if (!empty($answerArr) && $answerArr["reserve2"] == 1) { //正确回答了问题,但是没领取礼包的情况 $paramsArr = array('event_id' => $this->eventId, 'action' => $action, 'object' => $object, 'uin' => $this->uin, 'action_val' => $questionNum); $isGotPacketArr = ServiceHelper::Call("event.getAction", $paramsArr); if (empty($isGotPacketArr)) { echo '{"status":2, "msg":"您已经回答过此题,快去领取礼包吧!"}'; exit; } else { echo '{"status":0, "msg":"您已经回答过此题,期待下次挑战吧!"}'; exit; } } //当天是否有答题记录 $paramsArr = array('event_id' => $this->eventId, 'action' => "question", 'object' => "answer", 'uin' => $this->uin, 'action_val' => $questionNum, 'reserve1' => date("Y-m-d")); $logArr = ServiceHelper::Call("event.getAction", $paramsArr); if (!empty($logArr) && $logArr["reserve2"] == -1) { echo '{"status":0, "msg":"你今天回答机会已经用完了,明天继续哦!"}'; exit; } //答题 $isCorrect = 0; foreach ($questionArr as $value) { if (trim($value["title"]) == $answer && trim($value["answer"]) == 1) { $isCorrect = 1; break; } } $paramsArr['ctime'] = time(); if ($isCorrect) { //记录答案 $paramsArr['reserve2'] = 1; $rs = ServiceHelper::Call("event.addAction", $paramsArr); if ($rs["status"] == 2) { echo '{"status": 1, "msg":"干得漂亮,礼包已激活。速速领取吧!"}'; exit; } } else { $paramsArr['reserve2'] = -1; $rs = ServiceHelper::Call("event.addAction", $paramsArr); if ($rs["status"] == 2) { echo '{"status":0, "msg":"差一点就答对了!再回顾下漫画,明天继续哦!"}'; exit; } } echo '{"status":0, "msg":"写入数据发生错误!"}'; }
<?php $form = $this->beginWidget('bootstrap.widgets.BsActiveForm', array('id' => 'method-of-collection-data-form', 'enableAjaxValidation' => false)); ?> <p class="help-block">Поля, помеченные <span class="required">*</span>, обязательны для заполнения.</p> <?php echo $form->errorSummary($model); ?> <?php echo $form->textFieldControlGroup($model, 'title', array('maxlength' => 255)); ?> <?php echo $form->dropDownListControlGroup($model, 'type', ServiceHelper::getAvailableTypes(), array('class' => 'bs')); ?> <?php echo $form->numberFieldControlGroup($model, 'price', array('maxlength' => 19, 'step' => 0.01)); ?> <?php echo $form->numberFieldControlGroup($model, 'duration'); ?> <?php echo $form->textAreaControlGroup($model, 'comments', array('rows' => 6)); ?> <?php echo $form->numberFieldControlGroup($model, 'defaultCount'); ?> <?php echo $form->numberFieldControlGroup($model, 'sortOrder');
/** * 调用mpboss接口发送游戏道具 * @param type $uin QQ号 * @param type $mpId 活动营销号 * @param type $giftName 道具名 * @param type $zoneId 区域id * @param type $roleId 角色id * @param type $count 赠送道具数量 */ protected function sendPacketByMp($uin, $mpId, $giftName, $zoneId, $roleId, $count = 1) { $params = array('uin' => $uin, 'mpId' => $mpId, 'giftName' => $giftName, 'giftCount' => $count, 'zoneId' => $zoneId, 'roleId' => $roleId); return ServiceHelper::Call("esales.getPropByMp", $params); }
private function getSystemServiceEntry($public_account, $service_tag) { if (empty($public_account) || empty($service_tag)) { return array(); } $button = array(); $tags = explode('-', $service_tag); if ($tags[0] == 'wifi' || $tags[0] == 'canyin' || $tags[0] == 'hotel' || $tags[0] == 'dingdan' || $tags[0] == 'dazhuanpan' || $tags[0] == 'guaguaka' || $tags[0] == 'youhuiquan' || $tags[0] == 'toupiao' || $tags[0] == 'huiyuanka') { $button['type'] = 'click'; $button['key'] = urlencode($this->constructKeyword($this->token, $tags[0], $tags[1], $tags[2])); } else { if ($tags[0] == 'shouye') { if (empty($tags[1])) { //这是首页,首页通过关键词进入 $button['type'] = 'click'; $button['key'] = urlencode($this->constructKeyword($this->token, $tags[0], $tags[1], $tags[2])); } else { //栏目或者文章页 $button['type'] = 'view'; $button['url'] = ServiceHelper::constructHyperLink($this->token, $tags[0], $tags[1], $tags[2]); } } else { if ($tags[0] == 'car') { if ($tags[1] == 'sales') { $button['type'] = 'view'; $button['url'] = ServiceHelper::constructHyperLink($this->token, $tags[0], $tags[1], $tags[2]); } else { if ($tags[1] == 'car' || $tags[1] == 'drive' || $tags[1] == 'maintain' || $tags[1] == 'care') { $button['type'] = 'click'; $button['key'] = urlencode($this->constructKeyword($this->token, $tags[0], $tags[1], $tags[2])); } } } else { if ($public_account['is_authed'] == 1 && $public_account['type'] == 1) { //认证过的服务号,url不带wechat_id $button['type'] = 'view'; $button['url'] = ServiceHelper::constructHyperLink($this->token, $tags[0], $tags[1], $tags[2]); } else { //其他情况下用关键词实现 $button['type'] = 'click'; $button['key'] = urlencode($this->constructKeyword($this->token, $tags[0], $tags[1], $tags[2])); } } } } return $button; }
/** * mpboss平台获得得cdkey方法 * @param type $uin QQ号 * @param type $mpId 活动营销号 * @param type $clientIp 用户的ip * 返回值: * array( * "ret"=>2, * "msg"=>"XXXXXX", * "cdkey"=>"XXXXXXXXX" * ) */ protected function getCdkeyByMp($uin, $mpId, $clientIp) { $params = array('uin' => $uin, 'mpId' => $mpId, 'clientIp' => $clientIp); return ServiceHelper::Call("esales.getCdkeyByMp", $params); }
/** * 获取礼包领取的数量 */ private function getEventPacketTotal($paramsArr) { $valArr = ServiceHelper::Call("event.getActionStatsByRedis", $paramsArr); return !empty($valArr["count"]) ? intval($valArr["count"]) : 0; }
private static function API2Service($classFuncName, $paramsArr) { $v2Client = ServiceHelper::generateV2ServiceClient(); $retjson = $v2Client->call(array($classFuncName => $paramsArr)); $retjson = is_string($retjson) ? json_decode($retjson, true) : $retjson; return isset($retjson[$classFuncName]) ? $retjson[$classFuncName] : false; }
private function getValuefromRedis($eventId, $action, $object, $uin) { $paramsArr = array('event_id' => $eventId, 'action' => $action, 'object' => $object, 'uin' => $uin); $retArr = ServiceHelper::Call("event.getActionUserByRedis", $paramsArr); if (empty($retArr)) { $retArr = ServiceHelper::Call("event.getActionUserByRedis", $paramsArr); } return $retArr; }
private function processNewsResponses($token = '', $ids) { //图文回复 $where = array('token' => $token, 'id' => array('in', implode(',', $ids))); $img_db = M('img'); $img_items = $img_db->field(array('id', 'title', 'text' => 'description', 'pic' => 'picUrl', 'url', 'linktype', 'service'))->where($where)->limit(10)->select(); if ($img_items) { foreach ($img_items as $key => $val) { $img_db->where(array('id' => $img_items[$key]['id']))->setInc('click'); //linktype为info或者normal时应为正常逻辑,不是系统模块 if (!empty($img_items[$key]['linktype']) && !in_array($img_items[$key]['linktype'], array('info', 'normal')) && !empty($img_items[$key]['service'])) { $tags = explode('-', $img_items[$key]['service']); $service_url = ServiceHelper::constructHyperLink($token, $tags[0], $tags[1], $tags[2]); if (!empty($service_url)) { if ($tags[0] != 'xiangce') { //相册url不需要wechat_id, 否则token读取不正确 $service_url = $service_url . '&wecha_id=' . $this->fromWxId; } $img_items[$key]['url'] = $service_url; } } else { if (empty($img_items[$key]['url'])) { $img_items[$key]['url'] = U('Wap/ImageDetail/index@' . C('wx_handler_server'), array('id' => $img_items[$key]['id'], 'template' => 'ktv_content', 'token' => $token)); } else { if (strpos($img_items[$key]['url'], '?') && !strpos($img_items[$key]['url'], 'wecha_id=')) { $img_items[$key]['url'] .= '&wecha_id=' . $this->fromWxId; //为用户的链接加上wxid } } } $img_items[$key]['type'] = 'img'; } } file_put_contents('/tmp/img_item', print_r($img_items, true)); return $img_items; }
public static function getLabServicesForTask($caller, $sessionTask, $filterCategory) { $labServices = $taskServices = array(); if (isset($sessionTask[\Library\Enums\SessionKeys::TaskServices]) && count($sessionTask[\Library\Enums\SessionKeys::TaskServices]) > 0) { $taskServices = \Applications\PMTool\Helpers\ServiceHelper::GetServicesFromTaskServices($caller->user(), $sessionTask); } else { $taskServices = ServiceHelper::GetAndStoreTaskServices($caller, $sessionTask); $sessionTask[\Library\Enums\SessionKeys::TaskServices] = $taskServices; TaskHelper::SetSessionTask($caller->user(), $sessionTask); } foreach ($taskServices as $service) { if ($service['service_type'] === $filterCategory) { array_push($labServices, $service); } } return $labServices; }
protected function addPacketToRedisList($actionId, $uin, $object, $actionVol, $actionVal, $reserve1, $reserve2, $terminal = 1) { $paramsArr = array(); $paramsArr['action_id'] = $actionId; $paramsArr['uin'] = $uin; $paramsArr['object'] = $object; $paramsArr['terminal'] = $terminal; $paramsArr['action_vol'] = $actionVol; $paramsArr['action_val'] = $actionVal; $paramsArr['reserve1'] = $reserve1; $paramsArr['reserve2'] = $reserve2; $paramsArr['ctime'] = time(); $data = array('key' => "ac:event:cf201507:real:list", 'value' => json_encode($paramsArr), 'terminal' => 10); return ServiceHelper::Call("redis.rPush", $data); }
private function getClientIPFromRedis($eventId, $action, $object, $ip) { $ip = md5($ip); $paramsArr = array('event_id' => $eventId, 'action' => $action, 'object' => $object, 'uin' => $ip); $retArr = ServiceHelper::Call("event.getActionUserByRedis", $paramsArr); return !empty($retArr) ? json_decode($retArr, true) : array(); }
<?php /* @var $this ServiceController */ /* @var $model Service */ ?> <?php $this->menu = array(array('icon' => 'glyphicon glyphicon-tasks', 'label' => 'Управление услугами', 'url' => array('admin')), array('icon' => 'glyphicon glyphicon-plus-sign', 'label' => 'Создать услугу', 'url' => array('create')), array('icon' => 'glyphicon glyphicon-edit', 'label' => 'Изменить услугу', 'url' => array('update', 'id' => $model->id)), array('icon' => 'glyphicon glyphicon-minus-sign', 'label' => 'Удалить услугу', 'url' => array('delete', 'id' => $model->id), 'onclick' => "return confirm('Вы уверены, что хотите удалить услугу?');")); ?> <h1><?php echo $model->title; ?> </h1> <?php $this->widget('zii.widgets.CDetailView', array('htmlOptions' => array('class' => 'table table-striped table-condensed table-hover'), 'data' => $model, 'attributes' => array('id', 'title', array("name" => 'type', 'value' => ServiceHelper::getTranslatedTypeName($model->type)), 'price', 'duration', 'comments', 'sortOrder', 'readOnly', 'defaultCount')));