123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176 |
- <?php
- /*
- Created by PhpStorm.
- User: xiaofeng
- Date: 2018/6/10
- Time: 下午3:15
- */
- namespace frontend\controllers;
- use frontend\base\CommonController;
- use Yii;
- use frontend\base\Help;
- use common\api\EnrollServer;
- use common\enums\EmailEnum;
- use linslin\yii2\curl\Curl;
- class EnrollController extends CommonController
- {
- public $enableCsrfValidation = false;
- /*
- * name 姓名
- * source_model 来源模块
- * mobile 手机号
- * intention_house 意向楼盘
- * hid 楼盘ID 不存在:0
- * equipment 设备 2=>pc 1=>移动
- * city 区域
- *
- * */
- public function actionSignup()
- {
- $en = new EnrollServer();
- $cacheResult = $en->Restrict(Yii::$app->request->post());
- if (!$cacheResult['is_test'] && $cacheResult['sign']) {
- return Help::JsonCode(Help::ERROR, '您今天的报名次数已超过限制');
- }
- $form = new \common\forms\VisitorRegistrationForm();
- $form->load(Yii::$app->request->post(), '');
- if (!$form->validate()) return Help::JsonCode(Help::ERROR, '提交失败', $form->errors);
- /*
- * 2020.7.27 lyy 报名号码限制
- * */
- $astrict_is = $en->ChacPhone(Yii::$app->request->post('mobile'));
- if ($astrict_is['code']) return Help::JsonCode(Help::ERROR, $astrict_is['msg']);//号码限制
- $model = new \common\models\Enroll();
- $model->scenario = 'pcadd';
- $model->load(array_merge($form->attributes, Yii::$app->request->post()), '');
- if ($model->save()) {
- if ($cacheResult['is_test']) {
- //如果是测试号码,则不走以下发送邮箱的步骤
- return Help::JsonCode(Help::SUCCESS, '测试号码提交成功');
- }
- $array = array_merge($form->attributes, Yii::$app->request->post());
- (new Curl())->setPostParams([
- 'name' => empty($array['housename']) ? '' : $array['housename'],
- 'city' => empty($array['city_name']) ? '' : $array['city_name'],
- 'tel' => empty($array['mobile']) ? '' : $array['mobile'],
- 'time' => $_SERVER['REQUEST_TIME'],
- ])->post('http://abc.pinfangw.com/index.php?m=Admin&c=ReceiveSign');
- $Email = $form->attributes;
- $Email['id'] = $model->attributes['id'];
- (new \common\service\common\MailerService())->send($form->send_email, $Email, EmailEnum::SITEFORM);
- return Help::JsonCode(Help::SUCCESS, '提交成功');
- }
- // $en = new EnrollServer();
- // $cacheResult = $en->Restrict();
- // if($cacheResult === false) return Help::JsonCode(Help::ERROR,'您今天的报名次数已超过限制');
- // // aid: 0
- // //source: 2
- // //equipment: 2
- // //intention_city: 区域
- // //intention_housetype: 户型
- // //budget: 预算
- // //mobile: 13816450442
- // //根据报名判断是否有相应的区域邮箱
- // $input = Yii::$app->request->post();
- // $en->mobile = $input['mobile'];
- // if(!empty($input['intention_house']))
- // {
- // $en->housename = $input['intention_house'];
- // }
- // if(!empty($input['intention_housetype']))
- // {
- // $en->houseType = $input['intention_housetype'];
- // }
- // if(!empty($input['budget']))
- // {
- // $en->budget = $input['budget'];//预算
- // }
- // if(!empty($input['hid'])){
- // $houst = new \common\models\House();
- // $houseModel = $houst->FindById($input['hid']); //楼盘相关信息
- // $en->housename = $houseModel['name'];
- // $city = $houseModel['city'];
- // // $email = $cityEmail->FindByEmail($houseModel['city']);
- // // $en->city = $email['city_name'];
- // }else if(!empty($input['city'])){
- // $city = $input['city'];
- // // $email = $cityEmail->FindByEmail($input['city']);
- // // $en->city = $email['city_name'];
- // }
- // if(!empty($input['intention_city']))
- // {
- // $city_rows = \common\models\CategoryCity::findOne(['city_name'=> $input['intention_city']]);
- // if($city_rows)
- // {
- // $city = $city_rows['id'];
- // }
- // $en->city = $input['intention_city'];
- // }
- // //根据区域发送指定邮箱
- // if(!empty($city))
- // {
- // $cityEmail = new \common\models\Email();
- // $email = $cityEmail->FindByEmail($city);
- // $catCity = ( new \common\models\CategoryCity())->FindById($city);
- // $en->city = $catCity['city_name'];
- // }
- // if(!empty($email))
- // {
- // $e = $email['email'];
- // $en->city = $email['city_name'];
- // }
- // else
- // {
- // $e = Yii::$app->params['default_email'];
- // }
- // // ( new \common\api\EmailServer())->SendOut($e,Yii::t('app','enter_email'),$msgemail);
- // $model = new \common\models\Enroll();
- // $model->scenario = 'pcadd';
- // $auth = $model->Authenticator($input);
- // if(is_object($auth))
- // {
- // $auth->ip = Yii::$app->request->userIP;
- // $auth->send_email = $e;
- // if($auth->save(false)){
- // $auth->attributes['id'];
- // $en->username = $auth->name;
- // //发送邮件
- // $event = new \common\event\Event();
- // $arr = [];
- // $arr['email'] = $e;
- // $arr['title'] = Yii::t('app','enter_email');
- // $arr['content'] = $en->TemplateOne();
- // $arr['id'] = $auth->attributes['id'];
- // $event->SendEmail($arr);
- // return Help::JsonCode(Help::SUCCESS,'提交成功');
- // }
- // }
- // return Help::JsonCode(Help::ERROR,'提交失败',$auth);
- }
- }
|