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;
 }
示例#2
0
 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;
 }
示例#3
0
 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]);
 }
示例#6
0
 public function validateRecommendCode($attribute)
 {
     if (!$this->userId) {
         //新用户检查
         if ($this->recommendCode) {
             //如果推荐码存在
             $first = substr($this->recommendCode, 0, 1);
             if ("d" != $first && "g" != $first) {
                 CommonFunctions::createAlertMessage("填写的推荐码必须是金牌伙伴或者钻石伙伴的", "error");
                 $this->addError($attribute, '填写的推荐码必须是金牌伙伴或者钻石伙伴的');
             }
         }
     }
 }
 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]);
 }
示例#10
0
 /** 分配云豆 */
 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');
 }
 /** 处理申请改变状态 */
 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']);
     }
 }
 /** 更新手机号 */
 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 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 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]);
 }
 /** 删除 */
 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']);
     }
 }