|
|
|
@ -2,6 +2,7 @@ |
|
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
|
using Shentun.WebPeis.Enums; |
|
|
|
using Shentun.WebPeis.Models; |
|
|
|
using Shentun.WebPeis.Persons; |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Linq; |
|
|
|
@ -18,6 +19,7 @@ namespace Shentun.WebPeis.MedicalPackages |
|
|
|
public class MedicalPackageAppService : ApplicationService |
|
|
|
{ |
|
|
|
private readonly IRepository<MedicalPackage> _repository; |
|
|
|
private readonly IRepository<Person> _personRepository; |
|
|
|
private readonly IRepository<Asbitem> _asbitemRepository; |
|
|
|
private readonly IRepository<ItemType> _itemTypeRepository; |
|
|
|
private readonly IRepository<MedicalPackageDetail> _medicalPackageDetailRepository; |
|
|
|
@ -29,7 +31,8 @@ namespace Shentun.WebPeis.MedicalPackages |
|
|
|
IRepository<Asbitem> asbitemRepository, |
|
|
|
IRepository<MedicalPackageDetail> medicalPackageDetailRepository, |
|
|
|
IRepository<ItemType> itemTypeRepository, |
|
|
|
IRepository<CustomerOrgGroupDetail> customerOrgGroupDetailRepository |
|
|
|
IRepository<CustomerOrgGroupDetail> customerOrgGroupDetailRepository, |
|
|
|
IRepository<Person> personRepository |
|
|
|
|
|
|
|
) |
|
|
|
{ |
|
|
|
@ -39,26 +42,112 @@ namespace Shentun.WebPeis.MedicalPackages |
|
|
|
_medicalPackageDetailRepository = medicalPackageDetailRepository; |
|
|
|
_itemTypeRepository = itemTypeRepository; |
|
|
|
_customerOrgGroupDetailRepository = customerOrgGroupDetailRepository; |
|
|
|
_personRepository = personRepository; |
|
|
|
} |
|
|
|
/// <summary>
|
|
|
|
/// 获取能预约的套餐信息
|
|
|
|
/// </summary>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost("api/app/MedicalPackage/GetCanAppointList")] |
|
|
|
[HttpPost("api/app/MedicalPackage/GetCanAppointListByPersonId")] |
|
|
|
//[AllowAnonymous]
|
|
|
|
public async Task<List<MedicalPackageDto>> GetCanAppointListAsync() |
|
|
|
public async Task<List<MedicalPackageDto>> GetCanAppointListByPersonIdAsync(PersonIdInputDto input) |
|
|
|
{ |
|
|
|
var list = (await _repository.GetListAsync(o => o.IsActive == 'Y' && o.IsWebAppoint == 'Y')) |
|
|
|
.OrderBy(o => o.DisplayOrder).ToList(); |
|
|
|
var returnList = ObjectMapper.Map<List<MedicalPackage>, List<MedicalPackageDto>>(list); ; |
|
|
|
var person = await _personRepository.GetAsync(o => o.PersonId == input.PersonId); |
|
|
|
var age = DateTime.Now.Year - ((DateTime)person.BirthDate).Year; |
|
|
|
var medicalPackages = await _repository.GetListAsync(o => o.IsActive == 'Y' && |
|
|
|
o.IsWebAppoint == 'Y' && |
|
|
|
(o.ForSexId == ForSexFlag.All || o.ForSexId == person.SexId) && |
|
|
|
o.AgeUpperLimit <= age && o.AgeLowerLimit >= age); |
|
|
|
|
|
|
|
if (person.MaritalStatusId == MaritalStatusFlag.UnMarried) |
|
|
|
{ |
|
|
|
//未婚
|
|
|
|
if (medicalPackages.Where(o => o.MaritalStatusId == MaritalStatusFlag.Married).Any()) |
|
|
|
{ |
|
|
|
medicalPackages = medicalPackages.Where(o => |
|
|
|
o.MaritalStatusId == MaritalStatusFlag.UnMarried).ToList(); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
medicalPackages = medicalPackages.Where(o => o.MaritalStatusId == MaritalStatusFlag.All).ToList(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
else if (person.MaritalStatusId != MaritalStatusFlag.UnKnown) |
|
|
|
{ |
|
|
|
//已婚
|
|
|
|
if (medicalPackages.Where(o => o.MaritalStatusId == MaritalStatusFlag.Married).Any()) |
|
|
|
{ |
|
|
|
medicalPackages = medicalPackages.Where(o => o.MaritalStatusId == MaritalStatusFlag.Married).ToList(); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
medicalPackages = medicalPackages.Where(o => o.MaritalStatusId == MaritalStatusFlag.All).ToList(); |
|
|
|
} |
|
|
|
} |
|
|
|
medicalPackages = medicalPackages.OrderBy(o=>o.DisplayOrder).ToList(); |
|
|
|
var returnList = ObjectMapper.Map<List<MedicalPackage>, List<MedicalPackageDto>>(medicalPackages); ; |
|
|
|
foreach (var item in returnList) |
|
|
|
{ |
|
|
|
item.ForSexName = await _cacheService.GetForSexNameAsync(item.ForSexId); |
|
|
|
item.MaritalStatusName = await _cacheService.GetForSexNameAsync(item.MaritalStatusId); |
|
|
|
item.MaritalStatusName = await _cacheService.GetMaritalStatusNameAsync(item.MaritalStatusId); |
|
|
|
} |
|
|
|
return returnList; ; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 获取推荐的套餐
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost("api/app/MedicalPackage/GetRecommendCanAppointByPersonId")] |
|
|
|
public async Task<MedicalPackageDto> GetRecommendCanAppointByPersonIdAsync(PersonIdInputDto input) |
|
|
|
{ |
|
|
|
var person = await _personRepository.GetAsync(o => o.PersonId == input.PersonId); |
|
|
|
var age = DateTime.Now.Year - ((DateTime)person.BirthDate).Year; |
|
|
|
var medicalPackages = await _repository.GetListAsync(o => o.IsActive == 'Y' && |
|
|
|
o.IsWebAppoint == 'Y' && o.IsBasicRecommend == 'Y' && |
|
|
|
(o.ForSexId == ForSexFlag.All || o.ForSexId == person.SexId) && |
|
|
|
o.AgeUpperLimit <= age && o.AgeLowerLimit >= age); |
|
|
|
|
|
|
|
if (person.MaritalStatusId == MaritalStatusFlag.UnMarried) |
|
|
|
{ |
|
|
|
//未婚
|
|
|
|
if (medicalPackages.Where(o => o.MaritalStatusId == MaritalStatusFlag.Married).Any()) |
|
|
|
{ |
|
|
|
medicalPackages = medicalPackages.Where(o => |
|
|
|
o.MaritalStatusId == MaritalStatusFlag.UnMarried).ToList(); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
medicalPackages = medicalPackages.Where(o => o.MaritalStatusId == MaritalStatusFlag.All).ToList(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
else if (person.MaritalStatusId != MaritalStatusFlag.UnKnown) |
|
|
|
{ |
|
|
|
//已婚
|
|
|
|
if (medicalPackages.Where(o => o.MaritalStatusId == MaritalStatusFlag.Married).Any()) |
|
|
|
{ |
|
|
|
medicalPackages = medicalPackages.Where(o => o.MaritalStatusId == MaritalStatusFlag.Married).ToList(); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
medicalPackages = medicalPackages.Where(o => o.MaritalStatusId == MaritalStatusFlag.All).ToList(); |
|
|
|
} |
|
|
|
} |
|
|
|
var medicalPackage = medicalPackages.OrderBy(o => o.DisplayOrder).Single(); |
|
|
|
var result = ObjectMapper.Map<MedicalPackage, MedicalPackageDto>(medicalPackage); ; |
|
|
|
result.ForSexName = await _cacheService.GetForSexNameAsync(result.ForSexId); |
|
|
|
result.MaritalStatusName = await _cacheService.GetForSexNameAsync(result.MaritalStatusId); |
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 获取套餐或单位分组组合项目
|
|
|
|
/// </summary>
|
|
|
|
|