/**
  * 用户注册
  */
 public function register()
 {
     $password = isset($_POST['password']) ? htmlspecialchars($_POST['password']) : '';
     $mobile = isset($_POST['mobile']) ? htmlspecialchars($_POST['mobile']) : '';
     $code_verify = isset($_POST['code_verify']) ? htmlspecialchars($_POST['code_verify']) : '';
     if (empty($mobile)) {
         $this->jsonUtils->echo_json_msg(4, '手机号码为空!');
         exit;
     }
     $mobile_exits = $this->dao->where("mobile='{$mobile}'")->select();
     if ($mobile_exits) {
         $this->jsonUtils->echo_json_msg(1, '此手机已经注册过...');
         exit;
     }
     $sms = new \Org\Util\Sms();
     if (empty($_POST['session_id'])) {
         $msg = $sms->send_sms($mobile, 1, 0);
         if ($msg['code'] == 2) {
             $this->jsonUtils->echo_json_data(0, '成功发送短信,请查收..', $msg['session_id']);
             exit;
         } else {
             $this->jsonUtils->echo_json_msg(1, $msg['msg']);
             exit;
         }
     } else {
         if (empty($_POST['session_id'])) {
             $this->jsonUtils->echo_json_msg(4, 'session_id为空...');
             exit;
         }
         $code = $sms->getVerifyCode($_POST['session_id'], $mobile);
         if (empty($password)) {
             $this->jsonUtils->echo_json_msg(4, '密码为空...');
             exit;
         }
         if ($code == $code_verify) {
             $data["pwd"] = md5($password);
             $data["mobile"] = $mobile;
             $data["nick_name"] = substr_replace($mobile, '****', 3, 4);
             $data['add_time'] = time();
             $result = $this->dao->add($data);
             if ($result) {
                 CommonController::BeforeRegisterUser($result, $mobile, '', $mobile);
                 $this->jsonUtils->echo_json_msg(0, '注册成功');
                 exit;
             } else {
                 $this->jsonUtils->echo_json_msg(1, '注册失败!');
                 exit;
             }
         } else {
             $this->jsonUtils->echo_json_msg(1, '验证码错误或者验证码过期...');
             exit;
         }
     }
 }
 /**
  * 商家注册
  * 
  * @return [type] [description]
  */
 public function register()
 {
     $username = isset($_POST['username']) ? htmlspecialchars(trim($_POST['username'])) : '';
     $password = isset($_POST['password']) ? htmlspecialchars(trim($_POST['password'])) : '';
     if (empty($username)) {
         $this->jsonUtils->echo_json_msg(1, '请输入账号!');
         exit;
     } else {
         if (!preg_match('|^\\d{11}$|', $username)) {
             $this->jsonUtils->echo_json_msg(2, '手机号码不符合格式!');
             exit;
         }
     }
     $isexist = $this->dao->where(array('mobile' => $username))->getField('id');
     if ($isexist) {
         $this->jsonUtils->echo_json_msg(5, "{$username},已经注册过!");
         exit;
     }
     $sms = new \Org\Util\Sms();
     if (empty($_POST['session_id'])) {
         $msg = $sms->send_sms($username, 1, 2);
         if ($msg['code'] == 2) {
             $this->jsonUtils->echo_json_data(0, '成功发送短信,请查收..', $msg['session_id']);
             exit;
         } else {
             $this->jsonUtils->echo_json_msg(1, $msg['msg']);
             exit;
         }
     } else {
         $code_verify = isset($_POST['code_verify']) ? htmlspecialchars(trim($_POST['code_verify'])) : '';
         if (empty($code_verify)) {
             $this->jsonUtils->echo_json_msg(43, '验证码为空...');
             exit;
         }
         if (empty($password)) {
             $this->jsonUtils->echo_json_msg(44, '密码为空!');
             exit;
         }
         if (!preg_match('|^[0-9a-zA-z]{6,16}$|', $password)) {
             $this->jsonUtils->echo_json_msg(5, '请输入6-16位数字和字母密码!');
             exit;
         }
         $code = $sms->getVerifyCode($_POST['session_id'], $username);
         if ($code == $code_verify) {
             $data['mobile'] = $username;
             $data['merchant_name'] = substr_replace($username, '****', 3, 4);
             $data['pwd'] = md5($password);
             $data['addtime'] = time();
             $data['modtime'] = time();
             $data['status'] = 0;
             $result = $this->dao->add($data);
             if ($result) {
                 CommonController::BeforeRegisterUser($result, $username, '', $username, 2);
                 $this->jsonUtils->echo_json_data(0, '注册成功!', $result);
                 exit;
             } else {
                 $this->jsonUtils->echo_json_msg(1, '注册失败!');
                 exit;
             }
         } else {
             $this->jsonUtils->echo_json_msg(8, '验证码错误或者已过期...');
             exit;
         }
     }
 }