public function recordOne($state = false) { if (!$this->schemeId) { $scheme = new Scheme(); $scheme->level = Scheme::LEVEL_ONE; } else { $scheme = Scheme::findOne($this->schemeId); } $scheme->usageModeId = $this->usageModeId; $scheme->name = $this->name; $scheme->payMoney = $this->payMoney; $scheme->rebate = $this->rebate; $scheme->rebateSelf = $this->rebateSelf; $scheme->startDate = $this->startDate; $scheme->endDate = $this->endDate; if ($state) { $checkResult = Scheme::checkScheme($scheme->usageModeId, $this->startDate, $this->endDate); //检查方案冲突 if ($checkResult) { CommonFunctions::createAlertMessage("方案设置失败,启用的方案中存在与想要设置的方案时间存在冲突,冲突方案名称是:" . $checkResult, "error"); return true; } $scheme->state = Scheme::STATE_ABLE; } else { $scheme->state = Scheme::STATE_DISABLE; } if (!$scheme->save()) { throw new Exception("practice-form scheme save error"); } return false; }
public function update() { if ($this->provinceId == "" || $this->majorJobId == "") { CommonFunctions::createAlertMessage("省份或者专业类型不能为空", "error"); return false; } $user = Yii::$app->session->get('user'); $majorJob = MajorJob::findOne($this->majorJobId); if ($this->provinceId != $majorJob['provinceId']) { CommonFunctions::createAlertMessage("专业类型与所处省份不一致,请重新选择", "error"); return false; } //修改省份或专业岗位,需要清除用户的在线练习相关信息 if ($this->provinceId != $user['provinceId'] || $this->majorJobId != $user['majorJobId']) { CurrentTestLibrary::deleteAll(['userId' => $user['userId']]); //删除当前记录 ErrorQuestion::deleteAll(['userId' => $user['userId']]); //删除错题记录 Collection::deleteAll(['userId' => $user['userId']]); //删除收藏 } /** @var $user \common\models\Users */ $user = Users::findOne($user['userId']); $user->nickname = $this->nickname; $user->realname = $this->realname; $user->provinceId = $this->provinceId; $user->majorJobId = $this->majorJobId; $user->company = $this->company; $user->address = $this->address; if (!$user->save()) { throw new Exception("UpdateInfoForm update Save Error"); } Yii::$app->session->set('user', $user); return true; }
public function modifyPassword() { $user = Yii::$app->session->get('user'); /** @var $user \common\models\Users */ $user = Users::findOne($user['userId']); $user->password = CommonFunctions::encrypt($this->newPassword); $user->save(); }
public function register() { if ($this->provinceId == "" || $this->majorJobId == "") { CommonFunctions::createAlertMessage("省份或者专业类型不能为空", "error"); return false; } $majorJob = MajorJob::findOne($this->majorJobId); if ($this->provinceId != $majorJob['provinceId']) { CommonFunctions::createAlertMessage("专业类型与所处省份不一致,请重新选择", "error"); return false; } $openId = Yii::$app->session->get('openId'); $user = Users::findByWeiXin($openId); if (!$user) { //如果用户不存在,即关注的时候没有把微信的相关信息存入 $user = new Users(); $user->weixin = $openId; } if (!$user->registerDate || $user->registerDate == 0) { //如果用户注册日期不存在或为0,表明用户第一次实名认证 $user->bitcoin = 0; $user->registerDate = DateFunctions::getCurrentDate(); $user->role = Users::ROLE_A; $user->state = Users::STATE_NORMAL; do { //保证生成的推荐码的唯一 $recommendCode = CommonFunctions::createCommonRecommendCode(); } while (Users::findUserByRecommendCode($recommendCode)); $user->recommendCode = $recommendCode; if ($this->tjm) { //推荐码绑定推荐人 $this->recommendUser = Users::findUserByRecommendCode($this->tjm); if ($this->recommendUser) { if ($this->recommendUser['userId'] != $user['userId']) { //推荐人不是自己 $user->recommendUserID = $this->recommendUser['userId']; } } } } $user->nickname = $this->nickname; $user->realname = $this->realname; $user->provinceId = $this->provinceId; $user->majorJobId = $this->majorJobId; $user->cellphone = $this->cellphone; $user->company = $this->company; $user->address = $this->address; if (!$user->save()) { throw new Exception("RegisterForm register Save Error"); } Yii::$app->cache->delete($user->cellphone); //注册成功后将验证码缓存清除 Yii::$app->session->set('user', $user); return true; }
/** 修改用户银行卡信息 */ public function actionUpdateBank() { $user = Yii::$app->session->get('user'); $updateUserForm = UpdateUserForm::initUser($user['userId']); if ($updateUserForm->load(Yii::$app->request->post()) && $updateUserForm->validate()) { $updateUserForm->updateBank($user['userId']); CommonFunctions::createAlertMessage("修改成功", 'success'); return $this->redirect(['default/index']); } return $this->render('update-bank', ['user' => $user, 'updateUserForm' => $updateUserForm]); }
/** 咨询与建议 */ public function actionConsult() { $user = Yii::$app->session->get('user'); $consultForm = new ConsultForm(); if ($consultForm->load(Yii::$app->request->post()) && $consultForm->validate()) { $consultForm->record(); CommonFunctions::createAlertMessage("已经记录您的咨询或建议,我们将尽快给您答复", "success"); } else { CommonFunctions::createAlertMessage("请填写相关咨询的内容或者对我们的建议,我们会在第一时间回复您!", "info"); } $ownerServices = Service::findByUser($user['userId'], 5); $publishServices = Service::findPublished(5); return $this->render('consult', ['consultForm' => $consultForm, 'ownerServices' => $ownerServices, 'publishServices' => $publishServices]); }
public function actionOver() { $user = Yii::$app->session->get('user'); $info = Info::findByUserId($user['userId']); if ($info->state == Info::STATE_RECORD) { CommonFunctions::createAlertMessage("您的报名信息已经记录,请耐心等待工作人员帮您填报信息,填报完成可以在线进行查看", "info"); } elseif ($info->state == Info::STATE_PASS) { CommonFunctions::createAlertMessage("您好!您提交的在线报名申请,云豆已经为您办理完成了,您可以登录网站进行在线查看。\n <br>您的登录账号为: 身份证号,初始密码为:" . $info->password, "success"); } elseif ($info->state == Info::STATE_REFUSE) { CommonFunctions::createAlertMessage("工作人员帮您填写报名信息失败,原因是:" . $info->replyContent, "error"); } else { CommonFunctions::createAlertMessage("您的报名信息状态异常,请联系管理员", "warning"); } return $this->render('over', ['info' => $info]); }
public function actionIndex() { $user = Yii::$app->session->get('user'); $request = Yii::$app->request; $applyInvoiceForm = new ApplyInvoiceForm(); if ($request->isPost) { if ($applyInvoiceForm->load($request->post()) && $applyInvoiceForm->validate()) { if ($applyInvoiceForm->record()) { CommonFunctions::createAlertMessage("申请提交成功", 'success'); } else { CommonFunctions::createAlertMessage("申请提交失败,原因是已经存在正在申请中的记录", "error"); } } else { CommonFunctions::createAlertMessage("申请提交失败,填写信息有误", 'error'); } } return $this->render('index', ['user' => $user, 'applyInvoiceForm' => $applyInvoiceForm]); }
public function actionIndex() { $applyMoneyForm = new ApplyMoneyForm(); $request = Yii::$app->request; if ($request->isPost) { if ($applyMoneyForm->load($request->post()) && $applyMoneyForm->validate()) { if ($applyMoneyForm->record()) { CommonFunctions::createAlertMessage("申请提交成功", "success"); } else { CommonFunctions::createAlertMessage("申请提交失败,原因是已经存在正在申请中的记录", "error"); } } else { CommonFunctions::createAlertMessage("填写的信息有错误", "error"); } } else { CommonFunctions::createAlertMessage("提现申请提交后请及时提交对应金额的发票<b>(开票单位:南京云宝网络有限公司,开票项目:服务费)</b>,\n 系统会提交相关人员审核,审核后将会打款至您提交的银行账户。提现金额最低100元。", "info"); } return $this->render('index', ['applyMoneyForm' => $applyMoneyForm]); }
public function login() { $user = Users::find()->where(['username' => $this->username])->one(); if ($user) { if ($user['state'] == Users::STATE_STOP) { //用户状态被终止 $this->addError('username', "该用户已被终止登录"); return false; } if ($user['password'] != CommonFunctions::encrypt($this->password)) { $this->addError('password', "密码错误"); return false; } Yii::$app->session->set('user', $user); return true; } else { $this->addError('username', "用户不存在"); return false; } }
/** 分配云豆 */ public function actionDistribute() { $request = Yii::$app->request; if ($request->isPost) { $user = Yii::$app->session->get('user'); $bitcoin = intval($request->post('distribute_bitcoin_number')); $userId = $request->post('distribute_bitcoin_userId'); if ($bitcoin <= 0) { CommonFunctions::createAlertMessage("分配云豆失败,因为您未填写云豆数量或云豆数量未大于0", "error"); } elseif ($bitcoin > Users::findBitcoin($user['userId'])) { CommonFunctions::createAlertMessage("分配云豆失败,因为您的云豆余额不足", "error"); } else { Users::distributeBitcoin($user['userId'], $userId, $bitcoin); CommonFunctions::createAlertMessage("成功分配给用户号为" . $userId . "的用户" . $bitcoin . "云豆。", "success"); } } else { CommonFunctions::createAlertMessage("非法提交", "error"); } return $this->redirect(['user/previous']); }
public function record() { $user = Yii::$app->session->get('user'); $invoice = Invoice::findApplyingByUser($user['userId']); if ($invoice) { CommonFunctions::createAlertMessage("发票申请失败,您已经有正在申请中的发票了,一次只能申请一张", "error"); return false; } else { $invoice = new Invoice(); $invoice->userId = $user['userId']; $invoice->address = $this->address; $invoice->money = $this->money; $invoice->description = $this->description; $invoice->createDate = DateFunctions::getCurrentDate(); $invoice->state = Invoice::STATE_ING; if (!$invoice->save()) { throw new Exception("Apply Invoice save error"); } return true; } }
public function actionGenerate() { $updateWithdrawForm = new UpdateWithdrawForm(); $request = Yii::$app->request; if ($updateWithdrawForm->load($request->post()) && $updateWithdrawForm->validate()) { $type = $request->post("type"); if ($type == 'refuse') { $state = Withdraw::STATE_REFUSE; } elseif ($type == 'agree') { $state = Withdraw::STATE_PASS; } else { CommonFunctions::createAlertMessage("提交的状态类型未知", 'error'); return $this->redirect(['withdraw/index']); } $updateWithdrawForm->updateWithdraw($state); CommonFunctions::createAlertMessage("处理成功", "success"); return $this->redirect(['withdraw/index']); } else { CommonFunctions::createAlertMessage("处理失败", "error"); return $this->redirect(['withdraw/index']); } }
public function actionMajor() { $request = Yii::$app->request; if ($request->isPost) { $id = $request->post('id'); $name = $request->post('name'); if ($id) { $major = MajorJob::findOne($id); CommonFunctions::createAlertMessage("修改成功", "success"); } else { $major = new Province(); CommonFunctions::createAlertMessage("添加成功", "success"); } $major->name = $name; if (!$major->save()) { throw new Exception("Basic Date area save error"); } return $this->redirect(['basic-data/major']); } $models = MajorJob::findAllForObject(); return $this->render('major', ['models' => $models]); }
public function actionPublish() { $request = Yii::$app->request; if ($request->isPost) { $serviceId = $request->post('serviceId'); return Service::changePublish($serviceId); } else { CommonFunctions::createAlertMessage("非正常请求,错误!", 'error'); } return $this->redirect(['service/index']); }
/** 充值完成页面 */ public function actionOver() { CommonFunctions::createAlertMessage("充值成功,云豆将在2小时内充值到您的账户,如未到达可联系客服", "success"); return $this->render('over'); }
<?php /** @var $schemes \common\models\Scheme[] */ /** @var $orders */ use common\functions\CommonFunctions; use common\models\Users; $this->title = "云豆充值"; $user = Yii::$app->session->get('user'); $userIcon = isset($user['userIcon']) ? $user['userIcon'] : null; $userIcon = CommonFunctions::createHttpImagePath($userIcon); $tools = new JsApiPay(); /** @var $jsApiParameters Array //JSON */ $jsApiParameters = []; foreach ($orders as $order) { array_push($jsApiParameters, $tools->GetJsApiParameters($order)); } ?> <div class="account-header"> <div class="avatar"> <img src="<?php echo $userIcon; ?> " alt="head"> <p><?php echo $user['nickname']; ?> </p> <p>云豆余额:<strong><?php echo Users::findBitcoin($user['userId']); ?> </strong></p>
/** 更新手机号 */ public function actionUpdateCellphone() { $updateCellphoneForm = new UpdateCellphoneForm(); CommonFunctions::createAlertMessage("您可以在此修改您的手机号!", "info"); if ($updateCellphoneForm->load(Yii::$app->request->post()) && $updateCellphoneForm->validate()) { $updateCellphoneForm->update(); CommonFunctions::createAlertMessage("恭喜您,修改成功", "success"); } return $this->render('update-cellphone', ['updateCellphoneForm' => $updateCellphoneForm]); }
/** 处理申请改变状态 */ public function actionGenerate() { $updateInvoiceForm = new UpdateInvoiceForm(); $request = Yii::$app->request; if ($updateInvoiceForm->load($request->post()) && $updateInvoiceForm->validate()) { $type = $request->post('type'); if ($type == 'refuse') { $state = Invoice::STATE_REFUSE; } elseif ($type == 'agree') { $state = Invoice::STATE_PASS; } else { CommonFunctions::createAlertMessage("提交的状态类型未知", 'error'); return $this->redirect(['invoice/apply']); } $updateInvoiceForm->updateInvoice($state); CommonFunctions::createAlertMessage("处理成功", 'success'); return $this->redirect(['invoice/apply']); } else { CommonFunctions::createAlertMessage("处理失败", 'error'); return $this->redirect(['invoice/apply']); } }
/** * 测试用页面 */ use yii\helpers\Url; use yii\helpers\Html; //echo \frontend\functions\WeiXinFunctions::createMenu(); //::remember([Url::current([],true)],"openFilter"); //echo Url::current([],true); //echo Url::to(['practice/normal','type'=>'continue','openId'=>"123"],true); //$a = new \frontend\functions\WeChatCallBack(); //$a->ZIXUN_VIEW_Response("ow-bOvjH7CpKQtxsvjJuRmg6-g-k",35); //echo \frontend\functions\CommonFunctions::createRecommendCode(); //echo \frontend\functions\DateFunctions::getCurrentDate(); //echo \common\models\PracticeRecord::findByUser(5); //echo urldecode(Url::current([],true)); echo \common\functions\CommonFunctions::createBigRecommendCode(); //echo Url::base(true); //\common\models\Users::addBitcoin(5,10000); //echo \common\models\ExamScore::findTotalRank(); //echo \common\models\ExamScore::findRank(15,150); //print_r( \common\models\Users::findRecommendUser(null)); //\common\functions\CommonFunctions::logger_wx("真好"); //echo Url::to(['/we-chat/notify'],true); /*$xml= '<xml><appid><![CDATA[wxcf0cd66d7cdf0708]]></appid> <attach><![CDATA[云豆充值]]></attach> <bank_type><![CDATA[CFT]]></bank_type> <cash_fee><![CDATA[1]]></cash_fee> <fee_type><![CDATA[CNY]]></fee_type> <is_subscribe><![CDATA[Y]]></is_subscribe> <mch_id><![CDATA[1253356301]]></mch_id> <nonce_str><![CDATA[tp66p05hmcgvctyl1p3kj0oe4o36tg48]]></nonce_str>
public function actionCreateDetail($id) { $request = Yii::$app->request; /** @var $examTemplate \common\models\ExamTemplate*/ $examTemplate = ExamTemplate::findOne($id); if ($request->isPost) { //保存数据之前 删除所有原来的数据 且必须是模板未启用的状态下才能删除 if ($examTemplate->state == ExamTemplate::STATE_DISABLE) { ExamTemplateDetail::deleteAllByExamTemplateId($examTemplate->examTemplateId); } else { CommonFunctions::createAlertMessage("模板启用状态下删除题目出错", 'error'); return $this->redirect(['exam-template/index']); } //保存题目数量和分数 $examTemplate->pa1 = $request->post("number_pa1") . "|" . $request->post("score_pa1"); $examTemplate->pa2 = $request->post("number_pa2") . "|" . $request->post("score_pa2"); $examTemplate->pa3 = $request->post("number_pa3") . "|" . $request->post("score_pa3"); $examTemplate->pa4 = $request->post("number_pa4") . "|" . $request->post("score_pa4"); $examTemplate->pb1 = $request->post("number_pb1") . "|" . $request->post("score_pb1"); $examTemplate->pb2 = $request->post("number_pb2") . "|" . $request->post("score_pb2"); $examTemplate->pb3 = $request->post("number_pb3") . "|" . $request->post("score_pb3"); $examTemplate->pb4 = $request->post("number_pb4") . "|" . $request->post("score_pb4"); if (!$examTemplate->save()) { CommonFunctions::createAlertMessage("题目保存出错", 'error'); return $this->redirect(['exam-template/index']); } $testChapters = TestChapter::find()->where(['majorJobId' => $examTemplate->majorJobId])->all(); foreach ($testChapters as $testChapter) { $testNumber_1 = $request->post("danxuan_" . $testChapter->testChapterId); $testNumber_2 = $request->post("duoxuan_" . $testChapter->testChapterId); $testNumber_3 = $request->post("panduan_" . $testChapter->testChapterId); $testNumber_4 = $request->post("anli_" . $testChapter->testChapterId); if ($testNumber_1 && $testNumber_1 != 0) { ExamTemplateDetail::saveOne($id, $testChapter->preTypeId, $testChapter->testChapterId, 1, $testNumber_1); } if ($testNumber_2 && $testNumber_2 != 0) { ExamTemplateDetail::saveOne($id, $testChapter->preTypeId, $testChapter->testChapterId, 2, $testNumber_2); } if ($testNumber_3 && $testNumber_3 != 0) { ExamTemplateDetail::saveOne($id, $testChapter->preTypeId, $testChapter->testChapterId, 3, $testNumber_3); } if ($testNumber_4 && $testNumber_4 != 0) { ExamTemplateDetail::saveOne($id, $testChapter->preTypeId, $testChapter->testChapterId, 4, $testNumber_4); } } CommonFunctions::createAlertMessage("模板组题完成", 'success'); return $this->redirect(['exam-template/index']); } $testChapters_1 = TestChapter::find()->where(['majorJobId' => $examTemplate->majorJobId, 'preTypeId' => 1])->all(); $testChapters_2 = TestChapter::find()->where(['majorJobId' => $examTemplate->majorJobId, 'preTypeId' => 2])->all(); $examTemplateDetails = ExamTemplateDetail::findByExamTemplate($examTemplate->examTemplateId); $examTemplateDetails = ExamTemplateDetail::remakeArray($examTemplateDetails); return $this->render('create-detail', ['examTemplate' => $examTemplate, 'testChapters_1' => $testChapters_1, 'testChapters_2' => $testChapters_2, 'examTemplateDetails' => $examTemplateDetails]); }
public function recordOne() { if (!$this->userId) { //新添加 $user = new Users(); $user->bitcoin = 0; $user->password = CommonFunctions::encrypt("123456"); //初始密码设置为123456 $user->state = Users::STATE_NORMAL; do { if ($this->role == Users::ROLE_AA) { $recommendCode = CommonFunctions::create2ARecommendCode(); } elseif ($this->role == Users::ROLE_AAA) { $recommendCode = CommonFunctions::create3ARecommendCode(); } elseif ($this->role == Users::ROLE_BIG) { $recommendCode = CommonFunctions::createBigRecommendCode(); } else { throw new Exception("未知的角色类型"); } } while (Users::findUserByRecommendCode($recommendCode)); $user->recommendCode = $recommendCode; $recommendUser = Users::findUserByRecommendCode($this->recommendCode); $user->recommendUserID = $recommendUser['userId']; $user->registerDate = DateFunctions::getCurrentDate(); } else { //已存在 $user = Users::findOne($this->userId); } $user->role = $this->role; $user->departmentId = $this->departmentId; $user->username = $this->username; $user->nickname = $this->nickname; $user->address = $this->address; $user->realname = $this->realname; $user->cellphone = $this->cellphone; $user->email = $this->email; $user->qq = $this->qq; $user->weixin = $this->weixin; if (!$user->save()) { throw new Exception("add-user-form user save error"); } else { /** @var $bankCard \common\models\BankCard */ $bankCard = BankCard::findOne(['userId' => $user->userId]); if (!$bankCard) { //如果没有 $bankCard = new BankCard(); $bankCard->userId = $user->userId; $bankCard->state = BankCard::STATE_DEFAULT; } $bankCard->bankName = $this->bankName; $bankCard->cardNumber = $this->cardNumber; $bankCard->cardName = $this->cardName; $bankCard->save(); } }
/** 删除 */ public function actionDelete($id) { /** @var $scheme \common\models\Scheme */ $scheme = Scheme::findOne($id); if ($scheme && $scheme->state == Scheme::STATE_DISABLE) { //非启用状态才能删除 $scheme->delete(); CommonFunctions::createAlertMessage("删除方案成功", 'success'); return $this->redirect(['rebate/index']); } else { CommonFunctions::createAlertMessage("方案启用状态下,删除出错", 'error'); return $this->redirect(['rebate/index']); } }
/** 关联用户 */ public function actionLinkUser() { $request = Yii::$app->request; $userId = $request->get('id'); if (!$userId) { CommonFunctions::createAlertMessage("缺少对应的用户序号", "error"); return $this->redirect(['user-big/previous']); } $recommendUser = Users::findOne($userId); Yii::$app->session->setFlash('recommendUser', $recommendUser); //记录推荐用户,便于查询页面使用 $query = Users::find()->where(['recommendUserID' => $recommendUser['userId']]); $pagination = new Pagination(['defaultPageSize' => Yii::$app->params['pageSize'], 'totalCount' => $query->count()]); $users = $query->offset($pagination->offset)->limit($pagination->limit)->orderBy(['registerDate' => SORT_DESC])->all(); return $this->render('link-user', ['users' => $users, 'pages' => $pagination]); }
$question = CommonFunctions::replaceSmallImage($questions[$i], $smallPictures, $smallPictureIndex); $question = CommonFunctions::replaceBigImage($question, $bigPictures, $bigPictureIndex); ?> <?php echo $i + 1; ?> ) <?php echo $question; ?> </h5> <?php foreach ($options as $option) { ?> <?php $value = substr(trim($option), 0, 1); $option = CommonFunctions::replaceSmallImage($option, $smallPictures, $smallPictureIndex); ?> <div class="checkbox"> <label> <input name="input_question_<?php echo $id; ?> " type="checkbox" value="<?php echo $value; ?> " data-id="<?php echo $id; ?> " data-testtype="<?php echo $testTypeId;
public function record() { $user = Yii::$app->session->get('user'); $info = Info::findRefusedByUserId($user['userId']); if (!$info) { $info = new Info(); $info->password = CommonFunctions::createRandPassword(); } $info->userId = $this->userId; $info->IDCard = $this->IDCard; $info->realName = $this->realName; $info->cellphone = $this->cellphone; $info->education = $this->education; $info->major = $this->major; $info->workTime = $this->workTime; $info->technical = $this->technical; $info->signUpMajor = $this->signUpMajor; $info->company = $this->company; $info->findPasswordQuestion = $this->findPasswordQuestion; $info->findPasswordAnswer = $this->findPasswordAnswer; $info->headImg = $this->headImg; $info->educationImg = $this->educationImg; $info->createDate = DateFunctions::getCurrentDate(); $info->state = Info::STATE_RECORD; if (!$info->save()) { throw new Exception("Sign Up Info save error"); } }