From d671b708930c78ff15d66675e68769c6430842a0 Mon Sep 17 00:00:00 2001
From: wxd <123@qq.com>
Date: Mon, 18 Nov 2024 15:31:21 +0800
Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0ChargeAsbitemId?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
 .../AppointRegisterAsbitemDto.cs              |   6 +
 .../AppointPatientRegisterAppService.cs       | 507 ++++++++++--------
 .../Wechats/WeChatOrderAppService.cs          |   1 +
 3 files changed, 278 insertions(+), 236 deletions(-)
diff --git a/src/Shentun.WebPeis.Application.Contracts/AppointRegisterAsbitems/AppointRegisterAsbitemDto.cs b/src/Shentun.WebPeis.Application.Contracts/AppointRegisterAsbitems/AppointRegisterAsbitemDto.cs
index f4cdd62..d68d766 100644
--- a/src/Shentun.WebPeis.Application.Contracts/AppointRegisterAsbitems/AppointRegisterAsbitemDto.cs
+++ b/src/Shentun.WebPeis.Application.Contracts/AppointRegisterAsbitems/AppointRegisterAsbitemDto.cs
@@ -46,6 +46,12 @@ namespace Shentun.WebPeis.AppointRegisterAsbitems
         /// 是否收费
         /// 
         public char IsCharge { get; set; }
+
+        /// 
+        /// 收费项明细ID
+        /// 
+        public Guid? ChargeAsbitemId { get; set; }
+
         /// 
         /// 数量
         /// 
diff --git a/src/Shentun.WebPeis.Application/AppointPatientRegisters/AppointPatientRegisterAppService.cs b/src/Shentun.WebPeis.Application/AppointPatientRegisters/AppointPatientRegisterAppService.cs
index 9fdddd9..2413450 100644
--- a/src/Shentun.WebPeis.Application/AppointPatientRegisters/AppointPatientRegisterAppService.cs
+++ b/src/Shentun.WebPeis.Application/AppointPatientRegisters/AppointPatientRegisterAppService.cs
@@ -75,6 +75,7 @@ namespace Shentun.WebPeis.AppointPatientRegisters
         private readonly WeChatOrderAppService _weChatOrderAppService;
         private readonly IRepository _chargeRepository;
         private readonly IRepository _chargePayRepository;
+        private readonly IRepository _chargeAsbitemRepository;
         public AppointPatientRegisterAppService(IRepository repository,
              CacheService cacheService,
              IRepository itemTypeRepository,
@@ -111,7 +112,8 @@ namespace Shentun.WebPeis.AppointPatientRegisters
             IRepository appointScheduleTimeRepository,
             WeChatOrderAppService weChatOrderAppService,
             IRepository chargeRepository,
-            IRepository chargePayRepository)
+            IRepository chargePayRepository,
+            IRepository chargeAsbitemRepository)
         {
             _repository = repository;
             _cacheService = cacheService;
@@ -151,9 +153,10 @@ namespace Shentun.WebPeis.AppointPatientRegisters
             _weChatOrderAppService = weChatOrderAppService;
             _chargeRepository = chargeRepository;
             _chargePayRepository = chargePayRepository;
+            _chargeAsbitemRepository = chargeAsbitemRepository;
         }
         /// 
-        /// 创建预约,小程序使用
+        /// 创建预约,小程序使用  部分单位跟个人
         /// 
         /// 
         /// 
@@ -191,151 +194,7 @@ namespace Shentun.WebPeis.AppointPatientRegisters
             return result;
         }
 
-        /// 
-        /// 通过手机号等获取预约列表信息,体检程序前台登记使用
-        /// 
-        /// 
-        /// 
-        /// 
-        [AllowAnonymous]
-        [HttpPost("api/app/AppointPatientRegister/GetListByFilter")]
-        public async Task> GetListByFilterAsync(AppointPatientRegisterInputDto input)
-        {
-            if (input == null) throw new UserFriendlyException("参数不能为空");
-
-            Guid medicalCenterId;
-            if (input.MedicalCenterId == null || input.MedicalCenterId == Guid.Empty)
-            {
-                var webPeisOrganizationUnit = await _webPeisOrganizationUnitManager.GetMedicalCenterListAsync();
-                if (webPeisOrganizationUnit.Count > 1 || webPeisOrganizationUnit.Count == 0)
-                {
-                    throw new UserFriendlyException("体检中心参数不能为空");
-                }
-                medicalCenterId = webPeisOrganizationUnit.First().Id;
-            }
-            else
-            {
-                medicalCenterId = (Guid)input.MedicalCenterId;
-            }
-            if (input.AppointStartDate == null)
-            {
-                input.AppointStartDate = DateTime.Now.Date;
-            }
-            else
-            {
-                input.AppointStartDate = ((DateTime)input.AppointStartDate).Date;
-            }
-
-            if (input.AppointStopDate == null)
-            {
-                input.AppointStopDate = DateTime.Now.Date.AddDays(3650);
-            }
-            else
-            {
-                input.AppointStopDate = ((DateTime)input.AppointStopDate).Date.AddDays(1);
-            }
-
-            if (string.IsNullOrWhiteSpace(input.MobilePhone) && string.IsNullOrWhiteSpace(input.IdNo))
-            {
-                throw new UserFriendlyException("手机号和身份证必须至少填一个");
-            }
-            var query = (from user in await _identityUserRepository.GetQueryableAsync()
-                         join person in await _personRepository.GetQueryableAsync()
-                         on user.Id equals person.PersonId
-                         join appointPatientRegister in await _repository.GetQueryableAsync()
-                         on person.PersonId equals appointPatientRegister.PersonId
-                         join medicalPackage in await _medicalPackageRepository.GetQueryableAsync()
-                         on appointPatientRegister.MedicalPackageId equals medicalPackage.MedicalPackageId into canEmptyMedicalPackage
-                         from haveMedicalPackage in canEmptyMedicalPackage.DefaultIfEmpty()
-                         join customerOrgGroup in await _customerOrgGroupRepository.GetQueryableAsync()
-                         on appointPatientRegister.CustomerOrgGroupId equals customerOrgGroup.CustomerOrgGroupId into canEmptyCustomerOrgGroup
-                         from haveCustomerOrgGroup in canEmptyCustomerOrgGroup.DefaultIfEmpty()
-                         join appointRegisterAsbitem in await _appointRegisterAsbitemRepository.GetQueryableAsync()
-                         on appointPatientRegister.AppointPatientRegisterId equals appointRegisterAsbitem.AppointPatientRegisterId
-                         join asbitem in await _asbitemRepository.GetQueryableAsync()
-                         on appointRegisterAsbitem.AsbitemId equals asbitem.AsbitemId
-                         join customerOrg in await _customerOrgRepository.GetQueryableAsync()
-                         on appointPatientRegister.CustomerOrgId equals customerOrg.CustomerOrgId
-                         where appointPatientRegister.MedicalCenterId == medicalCenterId &&
-                            appointPatientRegister.AppointDate >= input.AppointStartDate &&
-                            appointPatientRegister.AppointDate < input.AppointStopDate &&
-                            appointPatientRegister.CustomerOrgId == GuidFlag.PersonCustomerOrgId
-                         orderby appointPatientRegister.AppointDate
-                         select new
-                         {
-                             user,
-                             person,
-                             appointPatientRegister,
-                             appointRegisterAsbitem,
-                             asbitem,
-                             haveMedicalPackage,
-                             haveCustomerOrgGroup,
-                             customerOrg
-                         }
-                         );
-
-
-            if (!string.IsNullOrWhiteSpace(input.IdNo))
-            {
-                if (input.IdNo.Length != 18)
-                {
-                    throw new UserFriendlyException("身份证长度必须是18位");
-                }
-                query = query.Where(o => o.person.IdNo == input.IdNo);
-
-            }
-            else
-            {
-                if (input.MobilePhone.Length != 11)
-                {
-                    throw new UserFriendlyException("手机号长度必须是11位");
-                }
-                query = query.Where(o => o.user.PhoneNumber == input.MobilePhone);
-            }
-
-            if (input.CompleteFlag != null)
-            {
-                query = query.Where(o => o.appointPatientRegister.CompleteFlag == input.CompleteFlag);
-            }
-            var appointPatientRegisterDtos = query.ToList();
-
-            var list = appointPatientRegisterDtos.GroupBy(o => o.appointPatientRegister)
-                  .Select(o => new AppointPatientRegisterDto()
-                  {
-                      AppointPatientRegisterId = o.FirstOrDefault().appointPatientRegister.AppointPatientRegisterId,
-                      PersonId = o.FirstOrDefault().appointPatientRegister.PersonId,
-                      PersonName = o.FirstOrDefault().user.Name,
-                      IdNo = o.FirstOrDefault().person.IdNo,
-                      MobileTelephone = o.FirstOrDefault().user.PhoneNumber,
-                      SexId = o.FirstOrDefault().person.SexId,
-                      MaritalStatusId = o.FirstOrDefault().person.MaritalStatusId,
-                      CustomerOrgId = o.FirstOrDefault().appointPatientRegister.CustomerOrgId,
-                      ChildCustomerOrgName = o.FirstOrDefault().customerOrg.PathCode.Length == 5 ? "" : o.FirstOrDefault().customerOrg.CustomerOrgName,
-                      CustomerOrgGroupId = o.FirstOrDefault().appointPatientRegister.CustomerOrgGroupId,
-                      CustomerOrgGroupName = o.FirstOrDefault().haveCustomerOrgGroup == null ? "" : o.FirstOrDefault().haveCustomerOrgGroup.CustomerOrgGroupName,
-                      CustomerOrgRegisterId = o.FirstOrDefault().appointPatientRegister.CustomerOrgRegisterId,
-                      MedicalPackageId = o.FirstOrDefault().appointPatientRegister.MedicalPackageId,
-                      MedicalPackageName = o.FirstOrDefault().haveMedicalPackage == null ? "" : o.FirstOrDefault().haveMedicalPackage.MedicalPackageName,
-                      MedicalCenterId = o.FirstOrDefault().appointPatientRegister.MedicalCenterId,
-                      CompleteFlag = o.FirstOrDefault().appointPatientRegister.CompleteFlag,
-                      ChargeFlag = o.FirstOrDefault().appointPatientRegister.ChargeFlag,
-                      AppointDate = o.FirstOrDefault().appointPatientRegister.AppointDate,
-                      Remark = o.FirstOrDefault().appointPatientRegister.Remark,
-                      PregnantFlag = o.FirstOrDefault().appointPatientRegister.PregnantFlag,
-                      Height = o.FirstOrDefault().appointPatientRegister.Height,
-                      Weight = o.FirstOrDefault().appointPatientRegister.Weight,
-                      SexName = _cacheService.GetSexNameAsync(o.FirstOrDefault().person.SexId).Result,
-                      MaritalStatusName = _cacheService.GetMaritalStatusNameAsync(o.FirstOrDefault().person.MaritalStatusId).Result,
-                      CustomerOrgName = _customerOrgManager.GetTopCustomerOrgAsync(o.FirstOrDefault().appointPatientRegister.CustomerOrgId).Result.CustomerOrgName
 
-                  }).ToList();
-
-
-            return list;
-
-
-
-        }
         /// 
         /// 获取某人的个人预约列表,小程序使用
         /// 
@@ -420,7 +279,7 @@ namespace Shentun.WebPeis.AppointPatientRegisters
         }
 
         /// 
-        /// 取消预约
+        /// 取消预约  收费的会退款
         /// 
         /// 
         /// 
@@ -467,96 +326,7 @@ namespace Shentun.WebPeis.AppointPatientRegisters
             }
 
         }
-        /// 
-        /// 获取预约的组合项目通过预约ID
-        /// 
-        /// 
-        /// 
-        [AllowAnonymous]
-        [HttpPost("api/app/AppointPatientRegister/GetAppointRegisterAsbitemListById")]
-        public async Task> GetAppointRegisterAsbitemListByIdAsync(AppointPatientRegisterIdInputDto input)
-        {
-            var appointPatientRegister = await _repository.GetAsync(o => o.AppointPatientRegisterId == input.AppointPatientRegisterId);
-            var appointRegisterAsbitemDtos = (
-
-              from appointRegisterAsbitem in await _appointRegisterAsbitemRepository.GetQueryableAsync()
-              join asbitem in await _asbitemRepository.GetQueryableAsync()
-              on appointRegisterAsbitem.AsbitemId equals asbitem.AsbitemId
-              join itemType in await _itemTypeRepository.GetQueryableAsync()
-              on asbitem.ItemTypeId equals itemType.ItemTypeId
-              orderby appointPatientRegister.AppointDate
-              where appointRegisterAsbitem.AppointPatientRegisterId == input.AppointPatientRegisterId
-              select new AppointRegisterAsbitemDto()
-              {
-                  AppointPatientRegisterId = input.AppointPatientRegisterId,
-                  AsbitemId = appointRegisterAsbitem.AsbitemId,
-                  AsbitemName = asbitem.AsbitemName,
-                  StandardPrice = appointRegisterAsbitem.StandardPrice,
-                  ChargePrice = appointRegisterAsbitem.ChargePrice,
-                  Amount = appointRegisterAsbitem.Amount,
-                  IsCharge = appointRegisterAsbitem.IsCharge,
-                  DisplayOrder = asbitem.DisplayOrder,
-                  ItemTypeId = itemType.ItemTypeId,
-                  ItemTypeName = itemType.ItemTypeName,
-                  ItemTypeDisplayOrder = itemType.DisplayOrder,
-                  PayTypeFlag = appointRegisterAsbitem.PayTypeFlag
-              }
-
-             ).ToList();
-
-            List asbitems = new List();
-            if (appointPatientRegister.MedicalPackageId != null)
-            {
-                asbitems = (await _medicalPackageDetailRepository.GetQueryableAsync())
-                    .Where(o => o.MedicalPackageId == appointPatientRegister.MedicalPackageId)
-                    .Select(x => x.AsbitemId).ToList();
-                ;
-            }
-            else if (appointPatientRegister.CustomerOrgGroupId != null)
-            {
-                asbitems = (await _customerOrgGroupDetailRepository.GetQueryableAsync())
-                   .Where(o => o.CustomerOrgGroupId == appointPatientRegister.CustomerOrgGroupId)
-                   .Select(x => x.AsbitemId).ToList();
-            }
-            var itemTypes = await _itemTypeRepository.GetListAsync();
-            appointRegisterAsbitemDtos.ForEach(o =>
-            {
-                if (asbitems.Where(x => x == o.AsbitemId).ToList().Any())
-                {
-                    o.IsBelongGroupPackage = 'Y';
-                }
-                var itemType = itemTypes.Where(o => o.ItemTypeId == o.ItemTypeId).First();
-                itemType = itemTypes.Where(o => o.PathCode == itemType.PathCode.Substring(0, 5)).First();
-                o.ItemTypeId = itemType.ItemTypeId;
-                o.ItemTypeDisplayOrder = itemType.DisplayOrder;
-            });
-            appointRegisterAsbitemDtos = appointRegisterAsbitemDtos.OrderBy(o => o.ItemTypeDisplayOrder)
-                .OrderBy(o => o.DisplayOrder).ToList();
-            return appointRegisterAsbitemDtos;
-        }
-
 
-        /// 
-        /// 获取预约的人员信息通过备单登记ID
-        /// 
-        /// 
-        /// 
-        [AllowAnonymous]
-        [HttpPost("api/app/AppointPatientRegister/GetByPatientRegisterId")]
-        public async Task GetByPatientRegisterIdAsync(PatientRegisterIdInputDto input)
-        {
-            if (input == null) throw new UserFriendlyException("参数不能为空");
-            var appointRegister = await _repository.FindAsync(o => o.PatientRegisterId == input.PatientRegisterId && o.CompleteFlag == AppointPatientRegisterCompleteFlag.Appoint);
-            if (appointRegister == null)
-            {
-                throw new UserFriendlyException("没有预约的人员信息");
-            }
-            var AppointPatientRegisterDto = new AppointPatientRegisterDto()
-            {
-                AppointPatientRegisterId = appointRegister.AppointPatientRegisterId
-            };
-            return AppointPatientRegisterDto;
-        }
         /// 
         /// 获取单位预约病人
         /// 
@@ -1360,5 +1130,270 @@ namespace Shentun.WebPeis.AppointPatientRegisters
                 }
             }
         }
+
+
+        #region 提供给体检系统调用
+
+        /// 
+        /// 获取预约的组合项目通过预约ID
+        /// 
+        /// 
+        /// 
+        [AllowAnonymous]
+        [HttpPost("api/app/AppointPatientRegister/GetAppointRegisterAsbitemListById")]
+        public async Task> GetAppointRegisterAsbitemListByIdAsync(AppointPatientRegisterIdInputDto input)
+        {
+            var appointPatientRegister = await _repository.GetAsync(o => o.AppointPatientRegisterId == input.AppointPatientRegisterId);
+            var appointRegisterAsbitemDtos = (
+
+              from appointRegisterAsbitem in await _appointRegisterAsbitemRepository.GetQueryableAsync()
+              join asbitem in await _asbitemRepository.GetQueryableAsync()
+              on appointRegisterAsbitem.AsbitemId equals asbitem.AsbitemId
+              join itemType in await _itemTypeRepository.GetQueryableAsync()
+              on asbitem.ItemTypeId equals itemType.ItemTypeId
+              orderby appointPatientRegister.AppointDate
+              where appointRegisterAsbitem.AppointPatientRegisterId == input.AppointPatientRegisterId
+              select new AppointRegisterAsbitemDto()
+              {
+                  AppointPatientRegisterId = input.AppointPatientRegisterId,
+                  AsbitemId = appointRegisterAsbitem.AsbitemId,
+                  AsbitemName = asbitem.AsbitemName,
+                  StandardPrice = appointRegisterAsbitem.StandardPrice,
+                  ChargePrice = appointRegisterAsbitem.ChargePrice,
+                  Amount = appointRegisterAsbitem.Amount,
+                  IsCharge = appointRegisterAsbitem.IsCharge,
+                  DisplayOrder = asbitem.DisplayOrder,
+                  ItemTypeId = itemType.ItemTypeId,
+                  ItemTypeName = itemType.ItemTypeName,
+                  ItemTypeDisplayOrder = itemType.DisplayOrder,
+                  PayTypeFlag = appointRegisterAsbitem.PayTypeFlag
+              }
+
+             ).ToList();
+
+            List asbitems = new List();
+            if (appointPatientRegister.MedicalPackageId != null)
+            {
+                asbitems = (await _medicalPackageDetailRepository.GetQueryableAsync())
+                    .Where(o => o.MedicalPackageId == appointPatientRegister.MedicalPackageId)
+                    .Select(x => x.AsbitemId).ToList();
+                ;
+            }
+            else if (appointPatientRegister.CustomerOrgGroupId != null)
+            {
+                asbitems = (await _customerOrgGroupDetailRepository.GetQueryableAsync())
+                   .Where(o => o.CustomerOrgGroupId == appointPatientRegister.CustomerOrgGroupId)
+                   .Select(x => x.AsbitemId).ToList();
+            }
+            var itemTypes = await _itemTypeRepository.GetListAsync();
+            appointRegisterAsbitemDtos.ForEach(o =>
+            {
+                if (asbitems.Where(x => x == o.AsbitemId).ToList().Any())
+                {
+                    o.IsBelongGroupPackage = 'Y';
+                }
+                var itemType = itemTypes.Where(o => o.ItemTypeId == o.ItemTypeId).First();
+                itemType = itemTypes.Where(o => o.PathCode == itemType.PathCode.Substring(0, 5)).First();
+                o.ItemTypeId = itemType.ItemTypeId;
+                o.ItemTypeDisplayOrder = itemType.DisplayOrder;
+            });
+
+
+            #region 获取收费明细数据,有就赋值
+
+            var chargeAsbitemDetail = (from charge in await _chargeRepository.GetQueryableAsync()
+                                       join chargeAsbitem in await _chargeAsbitemRepository.GetQueryableAsync() on charge.AppointPatientRegisterId equals input.AppointPatientRegisterId
+                                       where charge.ChargeFlag == '0'
+                                       select new
+                                       {
+                                           asbitemId = chargeAsbitem.AsbitemId,
+                                           chargeAsbitemId = chargeAsbitem.ChargeAsbitemId
+                                       }).ToList();
+
+            appointRegisterAsbitemDtos.ForEach(o =>
+            {
+                var chargeAsbitemEnt = chargeAsbitemDetail.FirstOrDefault(x => x.asbitemId == o.AsbitemId);
+                if (chargeAsbitemEnt != null)
+                {
+                    o.ChargeAsbitemId = chargeAsbitemEnt.chargeAsbitemId;
+                }
+            });
+
+            #endregion
+
+            appointRegisterAsbitemDtos = appointRegisterAsbitemDtos.OrderBy(o => o.ItemTypeDisplayOrder)
+                .OrderBy(o => o.DisplayOrder).ToList();
+            return appointRegisterAsbitemDtos;
+        }
+
+
+        /// 
+        /// 获取预约的人员信息通过备单登记ID
+        /// 
+        /// 
+        /// 
+        [AllowAnonymous]
+        [HttpPost("api/app/AppointPatientRegister/GetByPatientRegisterId")]
+        public async Task GetByPatientRegisterIdAsync(PatientRegisterIdInputDto input)
+        {
+            if (input == null) throw new UserFriendlyException("参数不能为空");
+            var appointRegister = await _repository.FindAsync(o => o.PatientRegisterId == input.PatientRegisterId && o.CompleteFlag == AppointPatientRegisterCompleteFlag.Appoint);
+            if (appointRegister == null)
+            {
+                throw new UserFriendlyException("没有预约的人员信息");
+            }
+            var AppointPatientRegisterDto = new AppointPatientRegisterDto()
+            {
+                AppointPatientRegisterId = appointRegister.AppointPatientRegisterId
+            };
+            return AppointPatientRegisterDto;
+        }
+
+        /// 
+        /// 通过手机号等获取预约列表信息,体检程序前台登记使用
+        /// 
+        /// 
+        /// 
+        /// 
+        [AllowAnonymous]
+        [HttpPost("api/app/AppointPatientRegister/GetListByFilter")]
+        public async Task> GetListByFilterAsync(AppointPatientRegisterInputDto input)
+        {
+            if (input == null) throw new UserFriendlyException("参数不能为空");
+
+            Guid medicalCenterId;
+            if (input.MedicalCenterId == null || input.MedicalCenterId == Guid.Empty)
+            {
+                var webPeisOrganizationUnit = await _webPeisOrganizationUnitManager.GetMedicalCenterListAsync();
+                if (webPeisOrganizationUnit.Count > 1 || webPeisOrganizationUnit.Count == 0)
+                {
+                    throw new UserFriendlyException("体检中心参数不能为空");
+                }
+                medicalCenterId = webPeisOrganizationUnit.First().Id;
+            }
+            else
+            {
+                medicalCenterId = (Guid)input.MedicalCenterId;
+            }
+            if (input.AppointStartDate == null)
+            {
+                input.AppointStartDate = DateTime.Now.Date;
+            }
+            else
+            {
+                input.AppointStartDate = ((DateTime)input.AppointStartDate).Date;
+            }
+
+            if (input.AppointStopDate == null)
+            {
+                input.AppointStopDate = DateTime.Now.Date.AddDays(3650);
+            }
+            else
+            {
+                input.AppointStopDate = ((DateTime)input.AppointStopDate).Date.AddDays(1);
+            }
+
+            if (string.IsNullOrWhiteSpace(input.MobilePhone) && string.IsNullOrWhiteSpace(input.IdNo))
+            {
+                throw new UserFriendlyException("手机号和身份证必须至少填一个");
+            }
+            var query = (from user in await _identityUserRepository.GetQueryableAsync()
+                         join person in await _personRepository.GetQueryableAsync()
+                         on user.Id equals person.PersonId
+                         join appointPatientRegister in await _repository.GetQueryableAsync()
+                         on person.PersonId equals appointPatientRegister.PersonId
+                         join medicalPackage in await _medicalPackageRepository.GetQueryableAsync()
+                         on appointPatientRegister.MedicalPackageId equals medicalPackage.MedicalPackageId into canEmptyMedicalPackage
+                         from haveMedicalPackage in canEmptyMedicalPackage.DefaultIfEmpty()
+                         join customerOrgGroup in await _customerOrgGroupRepository.GetQueryableAsync()
+                         on appointPatientRegister.CustomerOrgGroupId equals customerOrgGroup.CustomerOrgGroupId into canEmptyCustomerOrgGroup
+                         from haveCustomerOrgGroup in canEmptyCustomerOrgGroup.DefaultIfEmpty()
+                         join appointRegisterAsbitem in await _appointRegisterAsbitemRepository.GetQueryableAsync()
+                         on appointPatientRegister.AppointPatientRegisterId equals appointRegisterAsbitem.AppointPatientRegisterId
+                         join asbitem in await _asbitemRepository.GetQueryableAsync()
+                         on appointRegisterAsbitem.AsbitemId equals asbitem.AsbitemId
+                         join customerOrg in await _customerOrgRepository.GetQueryableAsync()
+                         on appointPatientRegister.CustomerOrgId equals customerOrg.CustomerOrgId
+                         where appointPatientRegister.MedicalCenterId == medicalCenterId &&
+                            appointPatientRegister.AppointDate >= input.AppointStartDate &&
+                            appointPatientRegister.AppointDate < input.AppointStopDate &&
+                            appointPatientRegister.CustomerOrgId == GuidFlag.PersonCustomerOrgId
+                         orderby appointPatientRegister.AppointDate
+                         select new
+                         {
+                             user,
+                             person,
+                             appointPatientRegister,
+                             appointRegisterAsbitem,
+                             asbitem,
+                             haveMedicalPackage,
+                             haveCustomerOrgGroup,
+                             customerOrg
+                         }
+                         );
+
+
+            if (!string.IsNullOrWhiteSpace(input.IdNo))
+            {
+                if (input.IdNo.Length != 18)
+                {
+                    throw new UserFriendlyException("身份证长度必须是18位");
+                }
+                query = query.Where(o => o.person.IdNo == input.IdNo);
+
+            }
+            else
+            {
+                if (input.MobilePhone.Length != 11)
+                {
+                    throw new UserFriendlyException("手机号长度必须是11位");
+                }
+                query = query.Where(o => o.user.PhoneNumber == input.MobilePhone);
+            }
+
+            if (input.CompleteFlag != null)
+            {
+                query = query.Where(o => o.appointPatientRegister.CompleteFlag == input.CompleteFlag);
+            }
+            var appointPatientRegisterDtos = query.ToList();
+
+            var list = appointPatientRegisterDtos.GroupBy(o => o.appointPatientRegister)
+                  .Select(o => new AppointPatientRegisterDto()
+                  {
+                      AppointPatientRegisterId = o.FirstOrDefault().appointPatientRegister.AppointPatientRegisterId,
+                      PersonId = o.FirstOrDefault().appointPatientRegister.PersonId,
+                      PersonName = o.FirstOrDefault().user.Name,
+                      IdNo = o.FirstOrDefault().person.IdNo,
+                      MobileTelephone = o.FirstOrDefault().user.PhoneNumber,
+                      SexId = o.FirstOrDefault().person.SexId,
+                      MaritalStatusId = o.FirstOrDefault().person.MaritalStatusId,
+                      CustomerOrgId = o.FirstOrDefault().appointPatientRegister.CustomerOrgId,
+                      ChildCustomerOrgName = o.FirstOrDefault().customerOrg.PathCode.Length == 5 ? "" : o.FirstOrDefault().customerOrg.CustomerOrgName,
+                      CustomerOrgGroupId = o.FirstOrDefault().appointPatientRegister.CustomerOrgGroupId,
+                      CustomerOrgGroupName = o.FirstOrDefault().haveCustomerOrgGroup == null ? "" : o.FirstOrDefault().haveCustomerOrgGroup.CustomerOrgGroupName,
+                      CustomerOrgRegisterId = o.FirstOrDefault().appointPatientRegister.CustomerOrgRegisterId,
+                      MedicalPackageId = o.FirstOrDefault().appointPatientRegister.MedicalPackageId,
+                      MedicalPackageName = o.FirstOrDefault().haveMedicalPackage == null ? "" : o.FirstOrDefault().haveMedicalPackage.MedicalPackageName,
+                      MedicalCenterId = o.FirstOrDefault().appointPatientRegister.MedicalCenterId,
+                      CompleteFlag = o.FirstOrDefault().appointPatientRegister.CompleteFlag,
+                      ChargeFlag = o.FirstOrDefault().appointPatientRegister.ChargeFlag,
+                      AppointDate = o.FirstOrDefault().appointPatientRegister.AppointDate,
+                      Remark = o.FirstOrDefault().appointPatientRegister.Remark,
+                      PregnantFlag = o.FirstOrDefault().appointPatientRegister.PregnantFlag,
+                      Height = o.FirstOrDefault().appointPatientRegister.Height,
+                      Weight = o.FirstOrDefault().appointPatientRegister.Weight,
+                      SexName = _cacheService.GetSexNameAsync(o.FirstOrDefault().person.SexId).Result,
+                      MaritalStatusName = _cacheService.GetMaritalStatusNameAsync(o.FirstOrDefault().person.MaritalStatusId).Result,
+                      CustomerOrgName = _customerOrgManager.GetTopCustomerOrgAsync(o.FirstOrDefault().appointPatientRegister.CustomerOrgId).Result.CustomerOrgName
+
+                  }).ToList();
+
+
+            return list;
+
+
+
+        }
+        #endregion
     }
 }
diff --git a/src/Shentun.WebPeis.Application/Wechats/WeChatOrderAppService.cs b/src/Shentun.WebPeis.Application/Wechats/WeChatOrderAppService.cs
index 4b3ee02..9297b62 100644
--- a/src/Shentun.WebPeis.Application/Wechats/WeChatOrderAppService.cs
+++ b/src/Shentun.WebPeis.Application/Wechats/WeChatOrderAppService.cs
@@ -176,6 +176,7 @@ namespace Shentun.WebPeis.Wechats
         /// 
         /// 
         [HttpPost("api/app/WeChatOrder/CreateWeChatOrderRefund")]
+        [RemoteService(false)]
         public async Task CreateWeChatOrderRefundAsync(CreateWeChatOrderRefundInputDto input)
         {