public async Task <JsonResult> CreateCompany(CreateOrUpdateCompanyInput model)
        {
            if (PermissionChecker.IsGranted("Pages.Company.CreateCompany"))
            {
                try
                {
                    var oldCompany = await _companyService.GetCompanyByUserId(model.CompanyEditDto.UserId);

                    if (oldCompany != null)
                    {
                        return(Json(new { success = false, msg = "存在该用户已关联的企业" }));
                    }

                    CheckModelState();

                    using (var unitWork = UnitOfWorkManager.Begin())
                    {
                        var newModel = await _companyService.CreateCompanyAsync(model.CompanyEditDto);

                        if (newModel.Id > 0)
                        {
                            List <string> industryIds = newModel.Industry.Split(',').ToList();
                            foreach (string industryId in industryIds)
                            {
                                CreateOrUpdateCompanyIndustryInput industryInput = new CreateOrUpdateCompanyIndustryInput();
                                CompanyIndustryEditDto             dto           = new CompanyIndustryEditDto()
                                {
                                    CompanyId = newModel.Id.Value, IndustryId = int.Parse(industryId)
                                };
                                industryInput.CompanyIndustryEditDto = dto;
                                await _companyIndustryAppService.CreateOrUpdateCompanyIndustryAsync(industryInput);
                            }

                            var relativeUser = _userAppService.Get(new EntityDto <long> {
                                Id = model.CompanyEditDto.UserId
                            }).Result;
                            relativeUser.UserType = UserType.Company;

                            if (model.CompanyAuthEditDto != null)
                            {
                                relativeUser.UserType = UserType.VipCompany;
                                model.CompanyAuthEditDto.CompanyId = newModel.Id.Value;
                                var newAuthModel =
                                    await _companyAuthAppService.CreateCompanyAuthAsync(model.CompanyAuthEditDto);
                            }

                            var user = _userAppService.UpdateUser(relativeUser);


                            if (model.ContactEdit != null)
                            {
                                var contactEditDto = model.ContactEdit;
                                contactEditDto.CompanyId = newModel.Id.Value;
                                var newContactModel = await _contactAppService.CreateContactAsync(contactEditDto);

                                if (contactEditDto.IsDefault)
                                {
                                    await _contactAppService.SetContactDefault(newContactModel.CompanyId,
                                                                               newContactModel.Id.Value);
                                }
                            }
                        }
                        unitWork.Complete();
                    }
                    return(Json(new { success = true, msg = "" }));
                }
                catch (Exception e)
                {
                    return(Json(new { success = false, msg = "保存失败" }));
                }
            }
            return(Json(new { success = false, msg = "无操作权限" }));
        }