public async Task <OperateResult> UpdateStepAsync(int stepNum, UpdateStepUser userInfo, CancellationToken cancellationToken = default)
        {
            try
            {
                CheckValue.NotNullOrWhiteSpace(userInfo.UserKeyInfo, "userInfo.UserKeyInfo");

                var user = await _userRepo.FindByUserKeyInfoAsync(userInfo.UserKeyInfo, StepFlyProviderType.XiaoMi) ??
                           throw new SoftlyMiCakeException("在修改步数的时候没有找到对应的用户信息");

                // 刷新Token
                await TryRelogin(user, cancellationToken);

                var httpClient = _httpClientFactory.CreateClient();
                var url        = XiaoMiConfig.GetChangeStepUrl();

                var jsonOptions = new JsonSerializerOptions()
                {
                    PropertyNamingPolicy = JsonNamingPolicy.CamelCase
                };
                var content = new StringContent(XiaoMiConfig.GetChangeStepRequestBody(user.UserSystemId, stepNum.ToString()), Encoding.UTF8, "application/x-www-form-urlencoded");
                content.Headers.Add("apptoken", user.TokenInfo);

                using var response = await httpClient.PostAsync(url, content, cancellationToken);

                var responseContent = await response.Content.ReadAsStringAsync();

                _logger.LogInformation(await content.ReadAsStringAsync());
                _logger.LogInformation(responseContent);

                if (response.StatusCode != HttpStatusCode.OK)
                {
                    return(OperateResult.Failed(null, response.StatusCode.ToString(), "修改步数失败", responseContent));
                }

                using var jsonDoc = JsonDocument.Parse(responseContent);
                var successCode = jsonDoc.RootElement.GetProperty("code").GetRawText();
                if (successCode.Equals("1"))
                {
                    return(OperateResult.Success(HttpStatusCode.OK.ToString(), "修改步数成功", responseContent));
                }

                if (successCode.Equals("0"))
                {
                    return(OperateResult.Failed(null, HttpStatusCode.Unauthorized.ToString(), "修改步数失败,登录信息已经过期"));
                }

                return(OperateResult.Success(HttpStatusCode.OK.ToString(), "修改步数失败", responseContent));
            }
            catch (Exception ex)
            {
                return(OperateResult.Failed(ex, "尝试修改步数时产生错误", ex.Message));
            }
        }
        public async Task <OperateResult> UpdateStepAsync(int stepNum, UpdateStepUser userInfo, CancellationToken cancellationToken = default)
        {
            try
            {
                CheckValue.NotNullOrWhiteSpace(userInfo.UserKeyInfo, "userInfo.UserKeyInfo");

                var user = await _userRepo.FindByUserKeyInfoAsync(userInfo.UserKeyInfo) ??
                           throw new SoftlyMiCakeException("在修改步数的时候没有找到对应的用户信息");

                var httpClient = _httpClientFactory.CreateClient();
                var url        = GetUpdateStepUrl();

                var jsonOptions = new JsonSerializerOptions()
                {
                    PropertyNamingPolicy = JsonNamingPolicy.CamelCase
                };
                var content = new StringContent(JsonSerializer.Serialize(GetUpdateStepModel(stepNum, user), jsonOptions), Encoding.UTF8, "application/json");
                content.Headers.Add("Cookie", user.TokenInfo);

                using var response = await httpClient.PostAsync(url, content, cancellationToken);

                response.EnsureSuccessStatusCode();

                var responseContent = await response.Content.ReadAsStringAsync();

                _logger.LogInformation(await content.ReadAsStringAsync());
                _logger.LogInformation(responseContent);

                if (response.StatusCode != HttpStatusCode.OK)
                {
                    return(OperateResult.Failed(null, response.StatusCode.ToString(), "修改步数失败", responseContent));
                }

                var lexinResponse = JsonSerializer.Deserialize <LeXinHttpResponse>(responseContent, new JsonSerializerOptions()
                {
                    PropertyNameCaseInsensitive = true
                });
                if (lexinResponse.Code != 200)
                {
                    return(OperateResult.Failed(null, lexinResponse.Code.ToString(), "修改步数失败", lexinResponse.Msg));
                }

                return(OperateResult.Success(HttpStatusCode.OK.ToString(), "修改步数成功", responseContent));
            }
            catch (Exception ex)
            {
                return(OperateResult.Failed(ex, "尝试修改步数时产生错误", ex.Message));
            }
        }
        public async Task <ChangeXiaoMiStepResultDto> ChangeStepByXiaoMi(ChangeXiaoMiStepDto changeDto)
        {
            var service = _stepFlyServiceFactory.CreateService(StepFlyProviderType.XiaoMi);
            var result  = await service.UpdateStepAsync(changeDto.Step, UpdateStepUser.Create(changeDto.Phone), AbortToken);

            if (!result.Succeeded)
            {
                return(new ChangeXiaoMiStepResultDto()
                {
                    Success = false,
                    Msg = result.Information?.Description + " & " + result.Information?.PlayLoad?.ToString(),
                    Code = result.Information?.Code
                });
            }

            await AddChangeHistory(changeDto.Phone, changeDto.Step, StepFlyProviderType.XiaoMi);

            return(new ChangeXiaoMiStepResultDto()
            {
                Success = true,
                Msg = "修改成功"
            });
        }