public async Task <IActionResult> UpdateMerchantAsync([FromBody] UpdateMerchantRequestDto request)
        {
            var merchantBiz   = new MerchantBiz();
            var merchantModel = await merchantBiz.GetAsync(request.MerchantGuid);

            if (merchantModel == null)
            {
                return(Failed(ErrorCode.UserData, "商户不存在!"));
            }

            if (request.Account != merchantModel.Account && await merchantBiz.AnyAccountAsync(request.Account))
            {
                return(Failed(ErrorCode.UserData, "已经存在相同的账号!"));
            }
            //商户信息
            merchantModel.MerchantPicture = request.MerchantPicture;
            merchantModel.MerchantName    = request.MerchantName;
            merchantModel.Telephone       = request.Telephone;
            merchantModel.LastUpdatedBy   = merchantModel.MerchantGuid;
            merchantModel.LastUpdatedDate = DateTime.Now;
            merchantModel.Latitude        = request.Latitude;
            merchantModel.Longitude       = request.Longitude;
            merchantModel.Account         = request.Account;
            if (null != request.Password)
            {
                merchantModel.Password = CryptoHelper.AddSalt(merchantModel.MerchantGuid, request.Password);
            }
            merchantModel.MerchantAddress = $"{request.Province}{request.City}{request.Area}{request.Street}";
            merchantModel.Area            = request.Area;
            merchantModel.City            = request.City;
            merchantModel.Province        = request.Province;
            merchantModel.Street          = request.Street;
            merchantModel.HospitalGuid    = request.HospitalGuid ?? string.Empty;
            //商户经营范围信息
            var scopes = request.Scopes.Select(scope => new ScopeModel
            {
                ScopeGuid     = Guid.NewGuid().ToString("N"),
                ScopeDicGuid  = scope.ScopeDicGuid,
                MerchantGuid  = merchantModel.MerchantGuid,
                PictureGuid   = scope.AccessoryGuid,
                CreatedBy     = merchantModel.MerchantGuid,
                OrgGuid       = string.Empty,
                LastUpdatedBy = merchantModel.MerchantGuid
            });
            //商户配置项证书信息 & 配置项证书附件信息
            var lstCertificate = request.Certificates.Select(item => new CertificateModel
            {
                CertificateGuid = Guid.NewGuid().ToString("N"),
                PictureGuid     = item.AccessoryGuid,
                OwnerGuid       = merchantModel.MerchantGuid,
                DicGuid         = item.DicGuid,
                CreatedBy       = UserID,
                OrgGuid         = string.Empty,
                LastUpdatedBy   = UserID
            });
            var result = await merchantBiz.UpdateMerchantAsync(merchantModel, scopes, lstCertificate);

            if (!result)
            {
                Failed(ErrorCode.DataBaseError, "商户修改失败!");
            }
            return(Success());
        }
        public async Task <IActionResult> RegisterMerchantAsync([FromBody] RegisterMerchantRequestDto request)
        {
            if (!request.Scopes.Any())
            {
                return(Failed(ErrorCode.UserData, "经营范围数据为空!"));
            }
            var merchantBiz = new MerchantBiz();

            if (await merchantBiz.AnyAccountAsync(request.Account))
            {
                return(Failed(ErrorCode.UserData, "已经存在相同的账号!"));
            }
            //商户信息
            string merchantGuid  = Guid.NewGuid().ToString("N");
            var    merchantModel = new MerchantModel
            {
                Status          = MerchantModel.StatusEnum.Approved.ToString(),
                MerchantGuid    = merchantGuid,
                MerchantPicture = request.MerchantPicture,
                MerchantName    = request.MerchantName,
                CreatedBy       = merchantGuid,
                SignatureGuid   = request.SignatureGuid,
                Telephone       = request.Telephone,
                OrgGuid         = string.Empty,
                MerchantAddress = $"{request.Province}{request.City}{request.Area}{request.Street}",
                Latitude        = request.Latitude,
                Longitude       = request.Longitude,
                LastUpdatedBy   = merchantGuid,
                Password        = CryptoHelper.AddSalt(merchantGuid, request.Password),
                Account         = request.Account,
                Enable          = true,
                Area            = request.Area,
                City            = request.City,
                Province        = request.Province,
                Street          = request.Street,
                HospitalGuid    = request.HospitalGuid ?? string.Empty
            };
            //商户经营范围信息
            var lstScope = request.Scopes.Select(scope => new ScopeModel
            {
                ScopeGuid     = Guid.NewGuid().ToString("N"),
                ScopeDicGuid  = scope.ScopeDicGuid,
                MerchantGuid  = merchantModel.MerchantGuid,
                PictureGuid   = scope.AccessoryGuid,
                CreatedBy     = merchantGuid,
                OrgGuid       = string.Empty,
                LastUpdatedBy = merchantGuid
            }).ToList();
            //商户配置项证书信息 & 配置项证书附件信息
            var lstCertificate = request.Certificates.Select(item => new CertificateModel
            {
                CertificateGuid = Guid.NewGuid().ToString("N"),
                PictureGuid     = item.AccessoryGuid,
                OwnerGuid       = merchantModel.MerchantGuid,
                DicGuid         = item.DicGuid,
                CreatedBy       = UserID,
                OrgGuid         = string.Empty,
                LastUpdatedBy   = UserID
            });
            var lstAccessory = (await new AccessoryBiz().GetListAsync(request.Certificates.Select(a => a.AccessoryGuid).ToArray())).ToList();

            lstAccessory.ForEach(a =>
            {
                a.OwnerGuid       = lstCertificate.FirstOrDefault(b => b.PictureGuid == a.AccessoryGuid)?.CertificateGuid;
                a.LastUpdatedDate = DateTime.Now;
                a.CreatedBy       = UserID;
            });
            var result = await merchantBiz.RegisterMerchantAsync(merchantModel, lstScope, lstCertificate, lstAccessory);

            if (!result)
            {
                Failed(ErrorCode.DataBaseError, "商户注册数据插入不成功!");
            }
            return(Success());
        }