/// <inheritdoc /> /// <summary> /// 获取相关信息 /// </summary> /// <param name="dto"></param> /// <returns></returns> public async Task <Ranking> GetRanking(DriverLicenseOfferDto dto) { //你的分数为xx分,在驾照取得地,可值xx元,超越了xx%本地用户,超越xx全国用户,在居住地,可值xx元,超越了xx%本地用户,超越xx全国用户 var result = new Ranking(); if (dto == null) { return(result); } if (!string.IsNullOrEmpty(dto.SourceAreaId))// { //取得报价 result.SourceTotalPrice = await _areaService.GetOfferByAreaId(dto.SourceAreaId, dto.DriverLicenseType) * dto.ScoreLeft; var totalSource = await GetSourceCount(dto.SourceAreaId, 0); if (totalSource == 0) { totalSource = 1; } result.SourceBeyond = (float) await GetSourceCountSub(dto.SourceAreaId, result.SourceTotalPrice) / totalSource; var totalAllSource = await GetTotalSourceCount(0); if (totalAllSource == 0) { totalAllSource = 1; } result.SourceBeyondAll = (float) await GetTotalSourceCountSub(result.SourceTotalPrice) / totalAllSource; } if (string.IsNullOrEmpty(dto.GoalAreaId)) { return(result); } //取得报价 //居住地 result.GoalTotalPrice = await _areaService.GetOfferByAreaId(dto.GoalAreaId, dto.DriverLicenseType) * dto.ScoreLeft; var totalGoal = await GetGoalCount(dto.GoalAreaId, 0); if (totalGoal == 0) { totalGoal = 1; } result.GoalBeyond = (float) await GetGoalCountSub(dto.GoalAreaId, result.GoalTotalPrice) / totalGoal; var totalAllGoal = await GetTotalGoalCount(0); if (totalAllGoal == 0) { totalAllGoal = 1; } result.GoalBeyondAll = (float) await GetTotalGoalCountSub(result.GoalTotalPrice) / totalAllGoal; result.DriverLicenseOfferId = await Add(dto); return(result); }
//see https://www.cnblogs.com/CreateMyself/p/6246977.html public async Task <NormalResult <Ranking> > GetOffer([FromBody] DriverLicenseOfferDto dto) { var result = new NormalResult <Ranking> { Data = await _driverLicenseOfferService.GetRanking(dto) }; return(result); }
public async Task <string> Add(DriverLicenseOfferDto dto) { var entity = _mapper.Map <DriverLicenseOfferDto, DriverLicenseOfferEntity>(dto); entity.Init(); _context.DriverLicenseOffers.Add(entity); await _context.SaveChangesAsync(); return(entity.Id); }
//see https://www.cnblogs.com/CreateMyself/p/6246977.html public async Task <NormalResult> ReportServiceUser([FromBody] DriverLicenseOfferDto dto) { var success = await _driverLicenseOfferService.Update (dto); var result = new NormalResult { Message = success ? "成功":"失败", Successful = success }; return(result); }
public async Task <bool> Update(DriverLicenseOfferDto dto) { var entity = await _context.DriverLicenseOffers.FindAsync(dto.Id); if (entity == null) { return(false); } entity.SourceTotalPrice = dto.SourceTotalPrice; //entity.DriverLicenseType = dto.DriverLicenseType; entity.GoalAddress = dto.GoalAddress; entity.GoalTotalPrice = dto.GoalTotalPrice; //entity.ScoreLeft = dto.ScoreLeft; entity.Sex = (byte)dto.Sex; entity.AcquisitionTime = dto.AcquisitionTime; //entity.GoalAreaId = dto.GoalAreaId; entity.PhoneNumber = dto.PhoneNumber; entity.WeiXinId = dto.WeiXinId; //entity.SourceAreaId = dto.SourceAreaId; return(await _context.SaveChangesAsync() == 1); }