| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- <?php
- namespace openend\controllers;
- use common\services\xhSetMealService;
- use common\services\xhInviteService;
- use common\services\xhMerchantAccountService;
- use common\services\xhMerchantService;
- use common\components\weixinUtil;
- use common\components\configDict;
- use common\components\stringUtil;
- use common\components\util;
- use common\services\xhAdminService;
- use common\services\xhCommonService;
- use common\services\xhApplyOrderService;
- use Yii;
- use yii\web\Controller;
- class MainController extends OpenendController
- {
- public $withoutLogin = ['index','product','service','about-us','login','check-merchant-name'];
- public function actionIndex()
- {
- return $this->render('index');
- }
- public function actionProduct()
- {
- return $this->render('product');
- }
- public function actionService()
- {
- return $this->render('service');
- }
- public function actionAboutUs()
- {
- return $this->render('aboutUs');
- }
- public function actionApply()
- {
- return $this->renderPartial('apply');
- }
- public function actionApplySubmit()
- {
- $post = Yii::$app->request->post();
- unset($post['_csrf']);
- $createTime = date("Y-m-d H:i:s");
- $account = xhMerchantAccountService::getByBusinessLicense($post['businessLicense']);
- if(empty($account)){
- $accountData = ['userId'=>$this->userId,'businessLicense'=>$post['businessLicense'],'idCard'=>$post['idCard'],
- 'idCardBack'=>$post['idCardBack'],'bankCardInfo'=>$post['bankCardInfo'],'bankCardNo'=>$post['bankCardNo'],
- 'mobile'=>$post['mobile'],'email'=>$post['email'],'createTime'=>$createTime,'bankCard'=>$post['bankCard'],
- 'applyName'=>$post['applyName'],'telephone'=>$post['telephone'],
- ];
- $account = xhMerchantAccountService::add($accountData);//保存商事主体信息
- }
- util::successInfo('请稍候');
- }
- public function actionApplySuccess()
- {
- return $this->renderPartial('applySuccess');
- }
- public function actionLogin()
- {
- echo '请使用微信访问';
- }
- /**
- * 下载微信里的图片到服务器
- */
- public function actionDownloadWxImg()
- {
- $get = Yii::$app->request->get();
- $mediaId = isset($get['mediaId']) ? $get['mediaId'] : '';
- $imgList = weixinUtil::downloadmediaIdImg($this->merchant, $mediaId);
- if(!empty($imgList)){
- util::successInfo('操作成功','A0001',$imgList);
- }
- util::failInfo();
- }
- public function actionCheckMerchantName()
- {
- $get = Yii::$app->request->get();
- $merchantName = isset($get['merchantName']) ? $get['merchantName'] : '';
- $m = xhMerchantService::getByMerchantName($merchantName);
- if(!empty($m)){
- util::failInfo('公众号名称已经使用');
- }
- util::successInfo();
- }
- public function actionCheckInviteCode()
- {
- $get = Yii::$app->request->get();
- $code = isset($get['code']) ? $get['code'] : '';
- $invite = xhInviteService::getByCode($code);
- if(empty($invite)){
- util::failInfo('邀请码错误');
- }
- $now = time();
- if($now > $invite['deadline']){
- util::failInfo('邀请码已经失效');
- }
- if(!empty($invite['takeStatus'])){
- util::failInfo('邀请码已经使用');
- }
- util::successInfo('操作成功','A0001',$invite);
- }
- public function actionGenerateCode()
- {
- $get = Yii::$app->request->get();
- $mobile = isset($get['mobile']) ? $get['mobile'] : '';
- if(preg_match("/^1[0-9]\d{9}$/",$mobile) == false){
- util::failInfo('手机号填写有误');
- }
- $session = Yii::$app->session;
- $now = time();
- if(isset($session['authCode']) == false || ($now - $session['authCodeTime']) > 120){
- $num = stringUtil::getRandNum(5);
- $session['authCode'] = $num;
- $session['authCodeTime'] = time();
- $msg = "您的验证码:".$num;
- xhCommonService::sendMobileMsg($mobile, $msg);
- util::successInfo();
- }
- util::failInfo('请稍等会…');
- }
- /**
- * 检测验证码
- */
- public function actionCheckCode()
- {
- $get = Yii::$app->request->get();
- $authCode = isset($get['authCode']) ? $get['authCode'] : '';
- $session = Yii::$app->session;
- if(isset($session['authCode']) && $authCode == $session['authCode']){
- util::successInfo('');
- }
- util::failInfo('验证号不正确');
- }
- public function actionCheckEmail()
- {
- $get = Yii::$app->request->get();
- $email = isset($get['email']) ? $get['email'] : '';
- $status = xhApplyOrderService::emailIsUse($email);
- if($status){
- util::failInfo('邮箱已经使用');
- }
- util::successInfo();
- }
- }
|