LifePayment/LifePayment.Application.Contracts/LifePay/ILifePayRateService.cs
New file @@ -0,0 +1,50 @@ using Alipay.EasySDK.Payment.Common.Models; using LifePayment.Application.Contracts.LifePay; using LifePayment.Domain.Shared; using System; using System.Collections.Generic; using System.Threading.Tasks; using Volo.Abp; using Volo.Abp.Application.Services; using ZeroD.Util; namespace LifePayment.Application.Contracts; public interface ILifePayRateService : IApplicationService { /// <summary> /// 获取折扣通道配置分页 /// </summary> /// <param name="input"></param> /// <returns></returns> Task<PageOutput<CreateEditRateChannelOutput>> GetLifePayRateChannelPage(PageInput input); /// <summary> /// 获取折扣通道配置列表 /// </summary> /// <param name="input"></param> /// <returns></returns> Task<List<CreateEditRateChannelOutput>> GetLifePayRateChannelAllList(QueryRateChannelInput input); /// <summary> /// 新增编辑折扣通道配置 /// </summary> /// <param name="input"></param> /// <returns></returns> Task<int> CreateOrEditLifePayRateChannel(CreateEditRateChannelInput input); /// <summary> /// 设置折扣通道状态 /// </summary> /// <param name="id"></param> /// <param name="status"></param> /// <returns></returns> Task<int> SetRateChannelStatus(Guid id, LifePayRateChannelStatus status); /// <summary> /// 删除折扣通道 /// </summary> /// <param name="id"></param> /// <returns></returns> Task<int> DeleteRateChannel(Guid id); } LifePayment/LifePayment.Application.Contracts/LifePay/LifePayRateInput.cs
New file @@ -0,0 +1,64 @@ using LifePayment.Domain.Shared; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; namespace LifePayment.Application.Contracts.LifePay; public class CreateEditRateChannelInput { public Guid? Id { get; set; } /// <summary> /// 充值类型 /// </summary> [Required(ErrorMessage = "充值类型是必填项。")] public LifePayOrderTypeEnum LifePayOrderType { get; set; } /// <summary> /// 通道 /// </summary> [Required(ErrorMessage = "通道是必填项。")] public string RateChannelName { get; set; } /// <summary> /// ID /// </summary> [Required(ErrorMessage = "ID是必填项。")] public int Code { get; set; } /// <summary> /// 供应商折扣 /// </summary> [Required(ErrorMessage = "供应商折扣是必填项。")] public decimal SupplierRate { get; set; } /// <summary> /// 平台折扣 /// </summary> [Required(ErrorMessage = "平台折扣是必填项。")] public decimal PlatformRate { get; set; } /// <summary> /// 通道状态 /// </summary> [Required(ErrorMessage = "通道状态是必填项。")] public LifePayRateChannelStatus Status { get; set; } /// <summary> /// 通知内容 /// </summary> [Required(ErrorMessage = "通知内容是必填项。")] public string Remark { get; set; } } public class CreateEditRateChannelOutput: CreateEditRateChannelInput { public DateTime CreationTime { get; set; } } public class QueryRateChannelInput { public LifePayRateChannelStatus? Status { get; set; } } LifePayment/LifePayment.Application/LifePay/LifePayRateService.cs
New file @@ -0,0 +1,132 @@ using LifePayment.Application.Contracts; using LifePayment.Application.Contracts.LifePay; using LifePayment.Domain; using LifePayment.Domain.LifePay; using LifePayment.Domain.Models; using LifePayment.Domain.Shared; using Microsoft.EntityFrameworkCore; using Nest; using System; using System.Collections.Generic; using System.Linq; using System.Linq.Dynamic.Core; using System.Text; using System.Threading.Tasks; using Volo.Abp.Application.Services; using Volo.Abp.Domain.Repositories; using Volo.Abp.ObjectMapping; using Z.EntityFramework.Plus; using ZeroD.Util; using static Microsoft.EntityFrameworkCore.DbLoggerCategory; namespace LifePayment.Application.LifePay; public class LifePayRateService : ApplicationService, ILifePayRateService { private readonly IRepository<LifePayRateChannel, Guid> _lifePayRateChannelRepository; public LifePayRateService(IRepository<LifePayRateChannel, Guid> lifePayRateChannelRepository) { _lifePayRateChannelRepository = lifePayRateChannelRepository; } /// <summary> /// 获取折扣通道配置分页 /// </summary> /// <param name="input"></param> /// <returns></returns> public async Task<PageOutput<CreateEditRateChannelOutput>> GetLifePayRateChannelPage(PageInput input) { return await GetLifePayRateChannelListFilter().GetPageResult(input.PageModel); } /// <summary> /// 获取折扣通道配置列表 /// </summary> /// <param name="input"></param> /// <returns></returns> public async Task<List<CreateEditRateChannelOutput>> GetLifePayRateChannelAllList(QueryRateChannelInput input) { return await GetLifePayRateChannelListFilter().WhereIf(input.Status.HasValue, x => x.Status == input.Status).OrderByDescending(r => r.CreationTime).ToListAsync(); } /// <summary> /// 新增编辑折扣通道配置 /// </summary> /// <param name="input"></param> /// <returns></returns> public async Task<int> CreateOrEditLifePayRateChannel(CreateEditRateChannelInput input) { CheckExtensions.IfTrueThrowUserFriendlyException(input.SupplierRate < 0.01m, "供应商折扣设置错误"); CheckExtensions.IfTrueThrowUserFriendlyException(input.PlatformRate < 0.01m, "平台折扣设置错误"); CheckExtensions.IfTrueThrowUserFriendlyException(input.PlatformRate < input.SupplierRate, "平台折扣无法低于供应商折扣"); bool isExist = await _lifePayRateChannelRepository.AnyAsync(r => r.Code == input.Code); CheckExtensions.IfTrueThrowUserFriendlyException(isExist, "ID已存在"); if (input.Id.HasValue) { var dto = await _lifePayRateChannelRepository.FirstOrDefaultAsync(r => r.Id == input.Id.Value); CheckExtensions.IfTrueThrowUserFriendlyException(dto == null, "未获取到折扣通道数据"); dto.LifePayOrderType = input.LifePayOrderType; dto.RateChannelName = input.RateChannelName; dto.Code = input.Code; dto.SupplierRate = input.SupplierRate; dto.PlatformRate = input.PlatformRate; dto.Status = input.Status; dto.Remark = input.Remark; } else { input.Id = Guid.NewGuid(); var entity = ObjectMapper.Map<CreateEditRateChannelInput, LifePayRateChannel>(input); await _lifePayRateChannelRepository.InsertAsync(entity); } return Constant.SUCCESS; } /// <summary> /// 设置折扣通道状态 /// </summary> /// <param name="id"></param> /// <param name="status"></param> /// <returns></returns> public async Task<int> SetRateChannelStatus(Guid id, LifePayRateChannelStatus status) { await _lifePayRateChannelRepository.Where(r => r.Id == id).UpdateAsync(r => new LifePayRateChannel { Status = status, }); return Constant.SUCCESS; } /// <summary> /// 删除折扣通道 /// </summary> /// <param name="id"></param> /// <returns></returns> public async Task<int> DeleteRateChannel(Guid id) { await _lifePayRateChannelRepository.DeleteAsync(s => s.Id == id); return Constant.SUCCESS; } private IQueryable<CreateEditRateChannelOutput> GetLifePayRateChannelListFilter() { var query = from x in _lifePayRateChannelRepository select new CreateEditRateChannelOutput { Id = x.Id, LifePayOrderType = x.LifePayOrderType, RateChannelName = x.RateChannelName, Code = x.Code, SupplierRate = x.SupplierRate, PlatformRate = x.PlatformRate, Status = x.Status, Remark = x.Remark, CreationTime = x.CreationTime, }; return query; } } LifePayment/LifePayment.Application/LifePay/LifePayService.cs
@@ -512,7 +512,7 @@ public async Task<LifePayRefundOrderOutput> GetLifePayRefundOrderDetail(string orderNo) { var order = await _lifePayOrderRepository.Where(x => x.OrderNo == orderNo).FirstOrDefaultAsync(); var platformRate = await _lifePayRateRepository.FirstOrDefaultAsync(r => r.RateType == LifePayRateTypeEnum.供应商折扣价); //var platformRate = await _lifePayRateRepository.FirstOrDefaultAsync(r => r.RateType == LifePayRateTypeEnum.供应商折扣价); var channle = await _lifePayChannlesRep.FirstOrDefaultAsync(r => r.ChannlesNum == order.ChannelId); var premium = await _lifePayPremiumRepository.Where(x => x.PremiumType == order.LifePayType).FirstOrDefaultAsync(); CheckExtensions.IfTrueThrowUserFriendlyException(order == null, "订单不存在"); LifePayment/LifePayment.Application/LifePaymentServicesApplicationModuleAutoMapperProfile.cs
@@ -1,5 +1,6 @@ using AutoMapper; using LifePayment.Application.Contracts; using LifePayment.Application.Contracts.LifePay; using LifePayment.Application.Contracts.Sync; using LifePayment.Domain; using LifePayment.Domain.LifePay; @@ -40,6 +41,8 @@ CreateMap<CreateChannelConsultationFollowupInput, LifePayChannelConsultationFollowup>(MemberList.None); CreateMap<LogFrontInput, LogFrontRecord>(MemberList.None); CreateMap<CreateEditRateChannelInput, LifePayRateChannel>(MemberList.None); } } } LifePayment/LifePayment.Domain.Shared/Enum/LifePay/LifePayRateChannel.cs
New file @@ -0,0 +1,52 @@ using System.ComponentModel; namespace LifePayment.Domain.Shared; public enum LifePayRateChannelStatus { /// <summary> /// 启用 /// </summary> [Description("启用")] Disabled = -10, /// <summary> /// 禁用 /// </summary> [Description("禁用")] Enabled = 10, } public enum LifePayRateChannelCodeEnum { /// <summary> /// 中国移动 /// </summary> [Description("中国移动")] 中国移动 = 10, /// <summary> /// 中国联通 /// </summary> [Description("中国联通")] 中国联通 = 20, /// <summary> /// 中国电信 /// </summary> [Description("中国电信")] 中国电信 = 30, /// <summary> /// 国家电网 /// </summary> [Description("国家电网")] 国家电网 = 40, /// <summary> /// 南方电网 /// </summary> [Description("南方电网")] 南方电网 = 50, } LifePayment/LifePayment.Domain/LifePay/LifePayRateChannel.cs
New file @@ -0,0 +1,48 @@ using LifePayment.Domain.Shared; using System; using Volo.Abp; using Volo.Abp.Domain.Entities.Auditing; namespace LifePayment.Domain; public partial class LifePayRateChannel : FullAuditedEntity<Guid>, IDataUserFilter { public LifePayRateChannel() { } /// <summary> /// 充值类型 /// </summary> public LifePayOrderTypeEnum LifePayOrderType { get; set; } /// <summary> /// 通道 /// </summary> public string RateChannelName { get; set; } /// <summary> /// ID /// </summary> public int Code { get; set; } /// <summary> /// 供应商折扣 /// </summary> public decimal SupplierRate { get; set; } /// <summary> /// 平台折扣 /// </summary> public decimal PlatformRate { get; set; } /// <summary> /// 通道状态 /// </summary> public LifePayRateChannelStatus Status { get; set; } /// <summary> /// 通知内容 /// </summary> public string Remark { get; set; } } LifePayment/LifePayment.EntityFrameworkCore/LifePaymentServicesDbContext.cs
@@ -63,6 +63,8 @@ public virtual DbSet<DallyStatistics> DallyStatistics { get; set; } public virtual DbSet<LifePayRateChannel> LifePayRateChannel { get; set; } [UnitOfWork] protected override void OnModelCreating(ModelBuilder builder) { LifePayment/LifePayment.Host/LifePaymentService.HttpApi.xml
@@ -513,6 +513,42 @@ <param name="input"></param> <returns></returns> </member> <member name="M:LifePayment.HttpApi.LifePayRateController.GetLifePayRateChannelPage(ZeroD.Util.PageInput)"> <summary> 获取折扣通道配置分页 </summary> <param name="input"></param> <returns></returns> </member> <member name="M:LifePayment.HttpApi.LifePayRateController.GetLifePayRateChannelAllList(LifePayment.Application.Contracts.LifePay.QueryRateChannelInput)"> <summary> 获取折扣通道配置列表 </summary> <param name="input"></param> <returns></returns> </member> <member name="M:LifePayment.HttpApi.LifePayRateController.CreateOrEditLifePayRateChannel(LifePayment.Application.Contracts.LifePay.CreateEditRateChannelInput)"> <summary> 新增编辑折扣通道配置 </summary> <param name="input"></param> <returns></returns> </member> <member name="M:LifePayment.HttpApi.LifePayRateController.SetRateChannelStatus(System.Guid,LifePayment.Domain.Shared.LifePayRateChannelStatus)"> <summary> 设置折扣通道状态 </summary> <param name="id"></param> <param name="status"></param> <returns></returns> </member> <member name="M:LifePayment.HttpApi.LifePayRateController.DeleteRateChannel(System.Guid)"> <summary> 删除折扣通道 </summary> <param name="id"></param> <returns></returns> </member> <member name="M:LifePayment.HttpApi.LogController.LogFront(LifePayment.Domain.Shared.LogFrontInput)"> <summary> 记录前端日志 LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml
@@ -4,6 +4,42 @@ <name>LifePayment.Application.Contracts</name> </assembly> <members> <member name="M:LifePayment.Application.Contracts.ILifePayRateService.GetLifePayRateChannelPage(ZeroD.Util.PageInput)"> <summary> 获取折扣通道配置分页 </summary> <param name="input"></param> <returns></returns> </member> <member name="M:LifePayment.Application.Contracts.ILifePayRateService.GetLifePayRateChannelAllList(LifePayment.Application.Contracts.LifePay.QueryRateChannelInput)"> <summary> 获取折扣通道配置列表 </summary> <param name="input"></param> <returns></returns> </member> <member name="M:LifePayment.Application.Contracts.ILifePayRateService.CreateOrEditLifePayRateChannel(LifePayment.Application.Contracts.LifePay.CreateEditRateChannelInput)"> <summary> 新增编辑折扣通道配置 </summary> <param name="input"></param> <returns></returns> </member> <member name="M:LifePayment.Application.Contracts.ILifePayRateService.SetRateChannelStatus(System.Guid,LifePayment.Domain.Shared.LifePayRateChannelStatus)"> <summary> 设置折扣通道状态 </summary> <param name="id"></param> <param name="status"></param> <returns></returns> </member> <member name="M:LifePayment.Application.Contracts.ILifePayRateService.DeleteRateChannel(System.Guid)"> <summary> 删除折扣通道 </summary> <param name="id"></param> <returns></returns> </member> <member name="M:LifePayment.Application.Contracts.ILifePayService.GetElectricParValue"> <summary> 获取电费面值 @@ -2239,6 +2275,41 @@ 结算时间 </summary> </member> <member name="P:LifePayment.Application.Contracts.LifePay.CreateEditRateChannelInput.LifePayOrderType"> <summary> 充值类型 </summary> </member> <member name="P:LifePayment.Application.Contracts.LifePay.CreateEditRateChannelInput.RateChannelName"> <summary> 通道 </summary> </member> <member name="P:LifePayment.Application.Contracts.LifePay.CreateEditRateChannelInput.Code"> <summary> ID </summary> </member> <member name="P:LifePayment.Application.Contracts.LifePay.CreateEditRateChannelInput.SupplierRate"> <summary> 供应商折扣 </summary> </member> <member name="P:LifePayment.Application.Contracts.LifePay.CreateEditRateChannelInput.PlatformRate"> <summary> 平台折扣 </summary> </member> <member name="P:LifePayment.Application.Contracts.LifePay.CreateEditRateChannelInput.Status"> <summary> 通道状态 </summary> </member> <member name="P:LifePayment.Application.Contracts.LifePay.CreateEditRateChannelInput.Remark"> <summary> 通知内容 </summary> </member> <member name="M:LifePayment.Application.Contracts.ILogService.LogFront(LifePayment.Domain.Shared.LogFrontInput)"> <summary> 记录前端日志 LifePayment/LifePayment.HttpApi/LifePay/LifePayRateController.cs
New file @@ -0,0 +1,94 @@ using Alipay.AopSdk.F2FPay.Model; using LifePayment.Application; using LifePayment.Application.Contracts; using LifePayment.Application.Contracts.LifePay; using LifePayment.Application.LifePay; using LifePayment.Domain; using LifePayment.Domain.Common; using LifePayment.Domain.Shared; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Volo.Abp; using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.AspNetCore.WebClientInfo; using ZeroD.Util; using ZeroD.Util.Fadd; namespace LifePayment.HttpApi { [Route("api/[controller]/[action]")] [ApiController] [Authorize] public class LifePayRateController : AbpController { private readonly ILifePayRateService _lifePayRateService; public LifePayRateController( ILifePayRateService lifePayRateService ) { _lifePayRateService = lifePayRateService; } /// <summary> /// 获取折扣通道配置分页 /// </summary> /// <param name="input"></param> /// <returns></returns> [HttpPost] public async Task<PageOutput<CreateEditRateChannelOutput>> GetLifePayRateChannelPage(PageInput input) { return await _lifePayRateService.GetLifePayRateChannelPage(input); } /// <summary> /// 获取折扣通道配置列表 /// </summary> /// <param name="input"></param> /// <returns></returns> [HttpPost] public async Task<List<CreateEditRateChannelOutput>> GetLifePayRateChannelAllList(QueryRateChannelInput input) { return await _lifePayRateService.GetLifePayRateChannelAllList(input); } /// <summary> /// 新增编辑折扣通道配置 /// </summary> /// <param name="input"></param> /// <returns></returns> [HttpPost] public async Task<int> CreateOrEditLifePayRateChannel(CreateEditRateChannelInput input) { return await _lifePayRateService.CreateOrEditLifePayRateChannel(input); } /// <summary> /// 设置折扣通道状态 /// </summary> /// <param name="id"></param> /// <param name="status"></param> /// <returns></returns> [HttpGet] public async Task<int> SetRateChannelStatus(Guid id, LifePayRateChannelStatus status) { return await _lifePayRateService.SetRateChannelStatus(id, status); } /// <summary> /// 删除折扣通道 /// </summary> /// <param name="id"></param> /// <returns></returns> [HttpPost] public async Task<int> DeleteRateChannel(Guid id) { return await _lifePayRateService.DeleteRateChannel(id); } } }