Bladeren bron

初始化公司信息开发中

吴学文 7 jaren geleden
bovenliggende
commit
c0a8fcc11b

+ 39 - 0
WebService/src/main/java/com/java110/web/smo/impl/RegisterServiceSMOImpl.java

@@ -1,9 +1,11 @@
 package com.java110.web.smo.impl;
 
+import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.java110.common.cache.CommonCache;
 import com.java110.common.constant.ServiceConstant;
 import com.java110.common.util.Assert;
+import com.java110.common.util.StringUtil;
 import com.java110.core.context.IPageData;
 import com.java110.core.factory.AliSendMessageFactory;
 import com.java110.core.factory.AuthenticationFactory;
@@ -55,6 +57,17 @@ public class RegisterServiceSMOImpl extends BaseComponentSMO implements IRegiste
             return responseEntity;
         }
 
+        responseEntity = this.checkNameAndTelExists(pd,registerInfo.getString("username"),"");
+        if(responseEntity.getStatusCode()!=HttpStatus.OK){
+            return responseEntity;
+        }
+
+        responseEntity = this.checkNameAndTelExists(pd,"",registerInfo.getString("tel"));
+        if(responseEntity.getStatusCode()!=HttpStatus.OK){
+            return responseEntity;
+        }
+
+
         registerInfo.put("passwd", AuthenticationFactory.passwdMd5(registerInfo.getString("passwd")));
 
         registerInfo.put("name",registerInfo.getString("username"));
@@ -63,6 +76,32 @@ public class RegisterServiceSMOImpl extends BaseComponentSMO implements IRegiste
         return responseEntity;
     }
 
+    private ResponseEntity<String> checkNameAndTelExists(IPageData pd,String name,String tel){
+        ResponseEntity<String> responseEntity = null;
+        //校验用户名或手机是否存在
+        responseEntity = this.callCenterService(restTemplate,pd,"",
+                ServiceConstant.SERVICE_API_URL+"/api/check.hasUser.byNameOrTel?name="+name+"&tel="+tel,
+                HttpMethod.GET);
+
+        if(responseEntity.getStatusCode()!=HttpStatus.OK){
+            logger.error("调用后端服务异常:{}",responseEntity);
+            return new ResponseEntity<String>("调用中心服务异常",HttpStatus.INTERNAL_SERVER_ERROR);
+        }
+
+        Assert.jsonObjectHaveKey(responseEntity.getBody(),"userCount","调用中心服务异常,报文中未包含userCount节点");
+
+        JSONObject userInfo = JSONObject.parseObject(responseEntity.getBody());
+
+        if(userInfo.getIntValue("userCount") > 0){
+            return new ResponseEntity<String>(StringUtil.isNullOrNone(name)?"手机号已占用":"用户名已占用",HttpStatus.INTERNAL_SERVER_ERROR);
+        }
+
+        responseEntity = new ResponseEntity<>("成功",HttpStatus.OK);
+
+        return responseEntity;
+
+    }
+
     /**
      * 发送验证码
      * @param pd

+ 22 - 28
WebService/src/main/resources/components/company/company.html

@@ -3,50 +3,44 @@
         <div class="col-lg-12">
             <div class="ibox">
                 <div class="ibox-title">
-                    <h5>Wizard with Validation</h5>
+                    <h5>公司信息</h5>
                     <div class="ibox-tools">
-                        <a class="collapse-link">
-                            <i class="fa fa-chevron-up"></i>
-                        </a>
-                        <a class="dropdown-toggle" data-toggle="dropdown" href="#">
-                            <i class="fa fa-wrench"></i>
-                        </a>
-                        <ul class="dropdown-menu dropdown-user">
-                            <li><a href="#" class="dropdown-item">Config option 1</a>
-                            </li>
-                            <li><a href="#" class="dropdown-item">Config option 2</a>
-                            </li>
-                        </ul>
-                        <a class="close-link">
-                            <i class="fa fa-times"></i>
-                        </a>
+
                     </div>
                 </div>
                 <div class="ibox-content">
                     <h2>
-                        Validation Wizard Form
+                        完善公司信息
                     </h2>
                     <p>
-                        This example show how to use Steps with jQuery Validation plugin.
+                        请仔细填写公司相关信息,有利于快速审核
                     </p>
 
                     <form id="form" action="#" class="wizard-big">
-                        <h1>Account</h1>
+                        <h1>基本信息</h1>
                         <fieldset>
-                            <h2>Account Information</h2>
+                            <h2>公司基本信息</h2>
                             <div class="row">
                                 <div class="col-lg-8">
                                     <div class="form-group">
-                                        <label>Username *</label>
-                                        <input id="userName" name="userName" type="text" class="form-control required">
+                                        <label>公司名称 *</label>
+                                        <input id="name" name="name" type="text" class="form-control required">
+                                    </div>
+                                    <div class="form-group">
+                                        <label>公司地址 *</label>
+                                        <input id="address" name="address" type="text" class="form-control required">
+                                    </div>
+                                    <div class="form-group">
+                                        <label>联系电话 *</label>
+                                        <input id="tel" name="tel" type="text" class="form-control required">
                                     </div>
                                     <div class="form-group">
-                                        <label>Password *</label>
-                                        <input id="password" name="password" type="text" class="form-control required">
+                                        <label>公司业务 *</label>
+                                        <input id="storeTypeCd" name="storeTypeCd" type="text" class="form-control required">
                                     </div>
                                     <div class="form-group">
-                                        <label>Confirm Password *</label>
-                                        <input id="confirm" name="confirm" type="text" class="form-control required">
+                                        <label>附近建筑 *</label>
+                                        <input id="nearbyLandmarks" name="nearbyLandmarks" type="text" class="form-control required">
                                     </div>
                                 </div>
                                 <div class="col-lg-4">
@@ -59,9 +53,9 @@
                             </div>
 
                         </fieldset>
-                        <h1>Profile</h1>
+                        <h1>证件信息</h1>
                         <fieldset>
-                            <h2>Profile Information</h2>
+                            <h2>公司证件信息</h2>
                             <div class="row">
                                 <div class="col-lg-6">
                                     <div class="form-group">

+ 82 - 1
WebService/src/main/resources/components/company/company.js

@@ -6,4 +6,85 @@
 (function(vc){
 
 
-})(window.vc);
+})(window.vc);
+
+(function(){
+    $(document).ready(function(){
+                $("#wizard").steps();
+                $("#form").steps({
+                    bodyTag: "fieldset",
+                    onStepChanging: function (event, currentIndex, newIndex)
+                    {
+                        // Always allow going backward even if the current step contains invalid fields!
+                        if (currentIndex > newIndex)
+                        {
+                            return true;
+                        }
+
+                        // Forbid suppressing "Warning" step if the user is to young
+                        if (newIndex === 3 && Number($("#age").val()) < 18)
+                        {
+                            return false;
+                        }
+
+                        var form = $(this);
+
+                        // Clean up if user went backward before
+                        if (currentIndex < newIndex)
+                        {
+                            // To remove error styles
+                            $(".body:eq(" + newIndex + ") label.error", form).remove();
+                            $(".body:eq(" + newIndex + ") .error", form).removeClass("error");
+                        }
+
+                        // Disable validation on fields that are disabled or hidden.
+                        form.validate().settings.ignore = ":disabled,:hidden";
+
+                        // Start validation; Prevent going forward if false
+                        return form.valid();
+                    },
+                    onStepChanged: function (event, currentIndex, priorIndex)
+                    {
+                        // Suppress (skip) "Warning" step if the user is old enough.
+                        if (currentIndex === 2 && Number($("#age").val()) >= 18)
+                        {
+                            $(this).steps("next");
+                        }
+
+                        // Suppress (skip) "Warning" step if the user is old enough and wants to the previous step.
+                        if (currentIndex === 2 && priorIndex === 3)
+                        {
+                            $(this).steps("previous");
+                        }
+                    },
+                    onFinishing: function (event, currentIndex)
+                    {
+                        var form = $(this);
+
+                        // Disable validation on fields that are disabled.
+                        // At this point it's recommended to do an overall check (mean ignoring only disabled fields)
+                        form.validate().settings.ignore = ":disabled";
+
+                        // Start validation; Prevent form submission if false
+                        return form.valid();
+                    },
+                    onFinished: function (event, currentIndex)
+                    {
+                        var form = $(this);
+
+                        // Submit form input
+                        form.submit();
+                    }
+                }).validate({
+                            errorPlacement: function (error, element)
+                            {
+                                element.before(error);
+                            },
+                            rules: {
+                                confirm: {
+                                    equalTo: "#password"
+                                }
+                            }
+                        });
+           });
+})();

+ 3 - 3
WebService/src/main/resources/components/validate-tel/validate-tel.js

@@ -60,12 +60,12 @@
                 },
                 //验证码定时
                 messageCodeTimer(){
-                      var num = 0;
+                      var num = 60;
 
                     var _timer = vc.createTimer(function(){
-                        num ++;
+                        num --;
                         vc.component.buttonInfo = num +" 秒后重试";
-                        if(num === 60){
+                        if(num === 1){
                             vc.clearTimer(_timer);
                             vc.component.buttonInfo = "验证码";
                         }

+ 1 - 1
WebService/src/main/resources/static/css/plugins/steps/jquery.steps.css

@@ -148,7 +148,7 @@
 }
 
 .wizard-big.wizard > .content {
-    min-height: 320px;
+    min-height: 520px;
 }
 .wizard.vertical > .content
 {

+ 4 - 1
WebService/src/main/resources/views/init_company.html

@@ -12,17 +12,20 @@
     <title>完善公司信息 | java110</title>
 
     <vc:create name="commonTop"></vc:create>
+    <link href="/css/plugins/steps/jquery.steps.css" rel="stylesheet"/>
+    <script src="/js/plugins/validate/jquery.validate.min.js"></script>
 
 </head>
 
 <body class="gray-bg">
-<div id="component" class="middle-box text-center loginscreen animated fadeInDown">
+<div id="component" >
     <vc:create name="company"></vc:create>
 
 </div>
 
 
 <vc:create name="commonBottom"></vc:create>
+<script src="/js/plugins/steps/jquery.steps.min.js"></script>
 </body>
 
 </html>