You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

185 lines
6.2 KiB

3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. using AutoMapper.Internal.Mappers;
  2. using Microsoft.AspNetCore.Authorization;
  3. using Microsoft.AspNetCore.Mvc;
  4. using Shentun.Peis.HelperDto;
  5. using Shentun.Peis.Models;
  6. using Shentun.Peis.Patients;
  7. using Shentun.Peis.PayModes;
  8. using Shentun.Utilities;
  9. using System;
  10. using System.Collections.Generic;
  11. using System.Linq;
  12. using System.Text;
  13. using System.Threading.Tasks;
  14. using Volo.Abp;
  15. using Volo.Abp.Application.Services;
  16. using Volo.Abp.Domain.Repositories;
  17. using Volo.Abp.ObjectMapping;
  18. namespace Shentun.Peis.PayModes
  19. {
  20. /// <summary>
  21. /// 支付方式
  22. /// </summary>
  23. [ApiExplorerSettings(GroupName = "Work")]
  24. [Authorize]
  25. public class PayModeAppService : ApplicationService
  26. {
  27. private readonly IRepository<PayMode> _repository;
  28. private readonly PayModeManager _manager;
  29. public PayModeAppService(
  30. IRepository<PayMode> repository,
  31. PayModeManager manager)
  32. {
  33. this._repository = repository;
  34. this._manager = manager;
  35. }
  36. /// <summary>
  37. /// 获取支付方式数据列表
  38. /// </summary>
  39. /// <returns></returns>
  40. public async Task<List<PayModeDto>> GetListAsync()
  41. {
  42. var entlist = await _repository.GetListAsync();
  43. entlist = entlist.OrderBy(o => o.DisplayOrder).ToList();
  44. return ObjectMapper.Map<List<PayMode>, List<PayModeDto>>(entlist);
  45. }
  46. /// <summary>
  47. /// 获取支付方式数据列表 筛选是否启用状态
  48. /// </summary>
  49. /// <returns></returns>
  50. [HttpGet("api/app/paymode/getlistinisactive")]
  51. public async Task<List<PayModeDto>> GetListInIsActiveAsync()
  52. {
  53. var entlist = await _repository.GetListAsync(m => m.IsActive == 'Y');
  54. entlist = entlist.OrderBy(o => o.DisplayOrder).ToList();
  55. return ObjectMapper.Map<List<PayMode>, List<PayModeDto>>(entlist);
  56. }
  57. /// <summary>
  58. /// 修改
  59. /// </summary>
  60. /// <param name="Id">主键ID</param>
  61. /// <param name="input">修改参数</param>
  62. /// <returns></returns>
  63. public async Task<PayModeDto> UpdateAsync(string Id, UpdatePayModeDto input)
  64. {
  65. var entity = await _repository.GetAsync(m => m.Id == Id);
  66. var sourceEntity = ObjectMapper.Map<UpdatePayModeDto, PayMode>(input);
  67. _manager.UpdateAsync(sourceEntity, entity);
  68. entity = await _repository.UpdateAsync(entity);
  69. return ObjectMapper.Map<PayMode, PayModeDto>(entity);
  70. }
  71. /// <summary>
  72. /// 修改排序 相邻之间
  73. /// </summary>
  74. /// <param name="id">需要修改的ID</param>
  75. /// <param name="targetid">目标ID</param>
  76. [HttpPut("api/app/paymode/updatesort")]
  77. [RemoteService(false)]
  78. public async Task UpdateSortAsync(string id, string targetid)
  79. {
  80. var entity = await _repository.GetAsync(m => m.Id == id);
  81. var targetentity = await _repository.GetAsync(m => m.Id == targetid);
  82. int olddisplaynum = entity.DisplayOrder;
  83. entity.DisplayOrder = targetentity.DisplayOrder;
  84. targetentity.DisplayOrder = olddisplaynum;
  85. List<PayMode> entlist = new List<PayMode>();
  86. entlist.Add(entity);
  87. entlist.Add(targetentity);
  88. await _repository.UpdateManyAsync(entlist);
  89. }
  90. /// <summary>
  91. /// 修改排序 置顶,置底
  92. /// </summary>
  93. /// <param name="id">需要修改的ID</param>
  94. /// <param name="SortType">修改方式:1 置顶 2 置底</param>
  95. /// <returns></returns>
  96. [HttpPut("api/app/paymode/updatemanysort")]
  97. public async Task UpdateManySortAsync(string id, int SortType)
  98. {
  99. var entity = await _repository.GetAsync(m => m.Id == id);
  100. List<PayMode> UptList = new List<PayMode>();
  101. if (SortType == 2)
  102. {
  103. UptList = (await _repository.GetListAsync(o => o.DisplayOrder > entity.DisplayOrder)).OrderBy(o => o.DisplayOrder).ToList();
  104. if (UptList.Count > 0)
  105. {
  106. int indexnum = entity.DisplayOrder; //原有值
  107. entity.DisplayOrder = UptList[UptList.Count - 1].DisplayOrder; //修改当前排序值为最大
  108. //置顶操作,往上一行开始,逐渐替换
  109. foreach (var item in UptList)
  110. {
  111. int dqnum = item.DisplayOrder;
  112. item.DisplayOrder = indexnum;
  113. indexnum = dqnum;
  114. }
  115. }
  116. }
  117. else
  118. {
  119. UptList = (await _repository.GetListAsync(o => o.DisplayOrder < entity.DisplayOrder)).OrderByDescending(o => o.DisplayOrder).ToList(); ;
  120. int indexnum = entity.DisplayOrder; //原有值
  121. entity.DisplayOrder = UptList[UptList.Count - 1].DisplayOrder; //修改当前排序值为最小
  122. //置底操作,往下一行开始,逐渐替换
  123. foreach (var item in UptList)
  124. {
  125. int dqnum = item.DisplayOrder;
  126. item.DisplayOrder = indexnum;
  127. indexnum = dqnum;
  128. }
  129. }
  130. UptList.Add(entity);
  131. await _repository.UpdateManyAsync(UptList);
  132. }
  133. /// <summary>
  134. /// 修改排序 拖拽
  135. /// </summary>
  136. /// <param name="input"></param>
  137. /// <returns></returns>
  138. [HttpPut("api/app/paymode/updatesortmany")]
  139. public async Task UpdateSortManyAsync(UpdateSortManyNokeyDto input)
  140. {
  141. var entitylist = await _repository.GetListAsync(o => input.ItemList.Select(s => s.Id).Contains(o.Id));
  142. foreach (var entity in entitylist)
  143. {
  144. foreach (var item in input.ItemList)
  145. {
  146. if (item.Id == entity.Id)
  147. entity.DisplayOrder = item.DisplayOrder;
  148. }
  149. }
  150. await _repository.UpdateManyAsync(entitylist);
  151. }
  152. }
  153. }