/** * 发送注册验证码 */ public function SendVerifyCode() { $this->LogInfo("Send verify code..."); $obj = $this->GetReqObj(); //判断公司是否冻结 $companyCondition['company_id'] = $obj->app_id; $companyDao = MispDaoContext::Company(); $companyStatus = $companyDao->where($companyCondition)->getField('company_status'); if (CompanyEnum::STATUS_FREEZE == $companyStatus) { $this->LogWarn("Send verify code failed. The company is freezed, company id is " . $obj->app_id); $this->errorCode = MispErrorCode::COMPANY_SERVICE_STOP; $this->ReturnJson(); return; } //发送验证码 $phoneNum = $obj->phone_num; $content = ShortMessage::getRandNum(4); $text1 = "验证码:"; $text2 = ",您正在使用快客洗涤手机客户端,请在10分钟内验证。(洁净生活·快客开始,服务电话:0859-3383000)"; $message = $text1 . $content . $text2 . "【快客洗涤】"; $result = ShortMessage::SendMessage($phoneNum, $message); $xmlObj = simplexml_load_string($result); if ($xmlObj->RetCode == "Sucess") { $this->LogInfo("Send verify code success, verify code is " . $content); $data['obj'] = $content; $this->ReturnJson($data); return; } else { $this->LogInfo("Send verify code failed."); $this->errorCode = SEND_MESSAGE_FAILED; $this->ReturnJson(); return; } }
function adminlistAction() { $this->_helper->layout->setLayout("layout_admin"); $request = $this->getRequest(); if (!$request->isPost()) { $plan_id = $request->getParam('plan_id'); } else { //create new plan and execute sql $formData = $request->getPost(); $sql = $formData['sql']; if ($sql == '' || $sql == null) { return; } else { $sql = 'select consumer.* ' . $sql; } $type = $formData['type']; $content = $formData['content']; //1.get all consumers $db = Zend_Registry::get('db'); $result = $db->query($sql); $consumers = $result->fetchAll(); //2. new a communicate plan $telephonePlanModel = new TelephonePlan(); $row = $telephonePlanModel->createRow(); $row->sql = $sql; $row->type = $type; $row->content = $content; //$row->total_consumers = count($consumers); //2011-04-08 ham.bao separate the sessions with admin $row->admin_id = $this->_currentAdmin->id; $row->edit_time = date("Y-m-d H:i:s"); $plan_id = $row->save(); //3. create sms $num = 0; foreach ($consumers as $consumer) { if ($consumer['phone'] == null || $consumer['phone'] == '') { continue; } if (preg_match('/1[35]\\d{9}/', $consumer['phone'], $rs) && count($rs) > 0) { $phone = $rs[0]; } else { continue; } $sms = new ShortMessage(); $row = $sms->createRow(); $row->consumer_id = $consumer['id']; $row->phone = $phone; $row->state = 'New'; $row->plan_id = $plan_id; $row->send_date = date("Y-m-d H:i:s"); $row->save(); $num++; } //4.update plan total number $telephonePlanModel = new TelephonePlan(); $set = array('total_consumers' => $num); $where = "id=" . $plan_id; $telephonePlanModel->update($set, $where); } //5.show consumers $db = Zend_Registry::get('db'); $select = $db->select(); $select->from('short_message', array('phone', 'state', 'send_date', 'plan_id'))->join('consumer', 'consumer.id = short_message.consumer_id', 'name')->where("short_message.plan_id = ?", $plan_id)->order('short_message.state asc')->order('short_message.id'); $this->view->sms = $db->fetchAll($select); $this->view->plan_id = $plan_id; }
function admindeleteAction() { $this->_helper->layout->setLayout("layout_admin"); $this->view->title = "Delete Plan"; if (!$this->_request->isPost()) { $id = (int) $this->_request->getParam('plan_id'); $type = $this->_request->getParam('type'); if ($id > 0) { //first, delete the telephone log or sms if ($type == "TELEPHONE") { $telephoneLogModel = new TelephoneLog(); $telephoneLogModel->deleteByPlan($id); } else { if ($type == "SMS") { $shortMessageModel = new ShortMessage(); $shortMessageModel->deleteByPlan($id); } else { } } //second, delete the plan $telephonePlanModel = new TelephonePlan(); $where = 'id = ' . $id; $telephonePlanModel->delete($where); } } //$this->_helper->json($type); $this->_redirect('conversation/adminindex'); }