From 479c6cec21a80bd9e9ed236ae21dbe2b55a0d8fb Mon Sep 17 00:00:00 2001 From: wxd <123@qq.com> Date: Thu, 31 Aug 2023 10:33:25 +0800 Subject: [PATCH] charge --- .../CardRegisters/GetCardRegisterListDto.cs | 4 +++ .../ChargeBackPays/ChargeBackPayDto.cs | 7 +++++- .../ChargePays/ChargePayDto.cs | 7 +++++- .../CardRegisters/CardRegisterAppService.cs | 5 ++++ .../ChargeBackPays/ChargeBackPayAppService.cs | 25 ++++++++++++++++--- .../ChargePays/ChargePayAppService.cs | 20 +++++++++++++-- 6 files changed, 61 insertions(+), 7 deletions(-) diff --git a/src/Shentun.Peis.Application.Contracts/CardRegisters/GetCardRegisterListDto.cs b/src/Shentun.Peis.Application.Contracts/CardRegisters/GetCardRegisterListDto.cs index 1f28338..4926fb7 100644 --- a/src/Shentun.Peis.Application.Contracts/CardRegisters/GetCardRegisterListDto.cs +++ b/src/Shentun.Peis.Application.Contracts/CardRegisters/GetCardRegisterListDto.cs @@ -8,6 +8,10 @@ namespace Shentun.Peis.CardRegisters { public class GetCardRegisterListDto { + /// + /// 卡模式 (0:充值卡,1:积分卡) + /// + public char? CardModeId { get; set; } /// /// 卡类型 /// diff --git a/src/Shentun.Peis.Application.Contracts/ChargeBackPays/ChargeBackPayDto.cs b/src/Shentun.Peis.Application.Contracts/ChargeBackPays/ChargeBackPayDto.cs index 33665d8..799b5e6 100644 --- a/src/Shentun.Peis.Application.Contracts/ChargeBackPays/ChargeBackPayDto.cs +++ b/src/Shentun.Peis.Application.Contracts/ChargeBackPays/ChargeBackPayDto.cs @@ -24,8 +24,13 @@ namespace Shentun.Peis.ChargeBackPays public decimal BackMoeny { get; set; } /// - /// 卡记录ID + /// 卡消费记录ID /// public Guid? CardBillId { get; set; } + + /// + /// 会员卡ID + /// + public Guid? CardRegisterId { get; set; } } } diff --git a/src/Shentun.Peis.Application.Contracts/ChargePays/ChargePayDto.cs b/src/Shentun.Peis.Application.Contracts/ChargePays/ChargePayDto.cs index cf7559d..4798c9b 100644 --- a/src/Shentun.Peis.Application.Contracts/ChargePays/ChargePayDto.cs +++ b/src/Shentun.Peis.Application.Contracts/ChargePays/ChargePayDto.cs @@ -22,8 +22,13 @@ namespace Shentun.Peis.ChargePays public decimal ChargeMoney { get; set; } /// - /// 记账记录ID + /// 卡消费记录ID /// public Guid? CardBillId { get; set; } + + /// + /// 会员卡ID + /// + public Guid? CardRegisterId { get; set; } } } diff --git a/src/Shentun.Peis.Application/CardRegisters/CardRegisterAppService.cs b/src/Shentun.Peis.Application/CardRegisters/CardRegisterAppService.cs index 1582458..65e145f 100644 --- a/src/Shentun.Peis.Application/CardRegisters/CardRegisterAppService.cs +++ b/src/Shentun.Peis.Application/CardRegisters/CardRegisterAppService.cs @@ -46,6 +46,11 @@ namespace Shentun.Peis.CardRegisters var cardRegisterList = (await _cardRegisterRepository.GetDbSetAsync()) .Include(x => x.CardType).AsEnumerable(); + if (input.CardModeId != null) + { + cardRegisterList = cardRegisterList.Where(m => m.CardType.CardModeId == input.CardModeId); + } + if (input.CardTypeId != null && input.CardTypeId != Guid.Empty) { cardRegisterList = cardRegisterList.Where(m => m.CardTypeId == input.CardTypeId); diff --git a/src/Shentun.Peis.Application/ChargeBackPays/ChargeBackPayAppService.cs b/src/Shentun.Peis.Application/ChargeBackPays/ChargeBackPayAppService.cs index 14c676e..3193cca 100644 --- a/src/Shentun.Peis.Application/ChargeBackPays/ChargeBackPayAppService.cs +++ b/src/Shentun.Peis.Application/ChargeBackPays/ChargeBackPayAppService.cs @@ -1,6 +1,7 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Shentun.Peis.ChargeAsbitems; +using Shentun.Peis.ChargePays; using Shentun.Peis.Models; using System; using System.Collections.Generic; @@ -22,12 +23,15 @@ namespace Shentun.Peis.ChargeBackPays public class ChargeBackPayAppService : ApplicationService { private readonly IRepository _chargeBackPayRepository; + private readonly IRepository _cardBillRepository; public ChargeBackPayAppService( - IRepository chargeBackPayRepository + IRepository chargeBackPayRepository, + IRepository cardBillRepository ) { this._chargeBackPayRepository = chargeBackPayRepository; + this._cardBillRepository = cardBillRepository; } /// @@ -38,18 +42,33 @@ namespace Shentun.Peis.ChargeBackPays [HttpGet("api/app/chargebackpay/getchargebackpayinchargebackid")] public async Task> GetChargeBackPayInChargeBackIdAsync(Guid ChargeBackId) { - var chargeBackPayList = await _chargeBackPayRepository.GetListAsync(m => m.ChargeBackId == ChargeBackId); + Guid? guidNull = null; + + var chargeBackPayList = from a in (await _chargeBackPayRepository.GetQueryableAsync()) + join b in (await _cardBillRepository.GetQueryableAsync()) on a.CardBillId equals b.Id into bb + from ab in bb.DefaultIfEmpty() + where a.ChargeBackId == ChargeBackId + select new + { + ChargeBackId = a.ChargeBackId, + CardBillId = a.CardBillId, + BackMoeny = a.BackMoeny, + PayModeId = a.PayModeId, + CardRegisterId = ab != null ? ab.CardRegisterId : guidNull, + }; var entlistdto = chargeBackPayList.Select(s => new ChargeBackPayDto { BackMoeny = s.BackMoeny, ChargeBackId = s.ChargeBackId, CardBillId = s.CardBillId, - PayModeId = s.PayModeId + PayModeId = s.PayModeId, + CardRegisterId = s.CardRegisterId }).ToList(); return entlistdto; + } } } diff --git a/src/Shentun.Peis.Application/ChargePays/ChargePayAppService.cs b/src/Shentun.Peis.Application/ChargePays/ChargePayAppService.cs index 9f6581b..f6a888d 100644 --- a/src/Shentun.Peis.Application/ChargePays/ChargePayAppService.cs +++ b/src/Shentun.Peis.Application/ChargePays/ChargePayAppService.cs @@ -21,14 +21,17 @@ namespace Shentun.Peis.ChargePays public class ChargePayAppService : ApplicationService { private readonly IRepository _chargePayRepository; + private readonly IRepository _cardBillRepository; private readonly IRepository _userRepository; public ChargePayAppService( IRepository chargePayRepository, + IRepository cardBillRepository, IRepository userRepository ) { this._chargePayRepository = chargePayRepository; + this._cardBillRepository = cardBillRepository; this._userRepository = userRepository; } @@ -40,15 +43,28 @@ namespace Shentun.Peis.ChargePays [HttpGet("api/app/chargepay/getchargepayinchargeid")] public async Task> GetChargePayInChargeIdAsync(Guid ChargeId) { + Guid? guidNull = null; - var chargePayList = await _chargePayRepository.GetListAsync(m => m.ChargeId == ChargeId); + var chargePayList = from a in (await _chargePayRepository.GetQueryableAsync()) + join b in (await _cardBillRepository.GetQueryableAsync()) on a.CardBillId equals b.Id into bb + from ab in bb.DefaultIfEmpty() + where a.ChargeId == ChargeId + select new + { + ChargeId = a.ChargeId, + CardBillId = a.CardBillId, + ChargeMoney = a.ChargeMoney, + PayModeId = a.PayModeId, + CardRegisterId = ab != null ? ab.CardRegisterId : guidNull, + }; var entlistdto = chargePayList.Select(s => new ChargePayDto { ChargeId = s.ChargeId, CardBillId = s.CardBillId, ChargeMoney = s.ChargeMoney, - PayModeId = s.PayModeId + PayModeId = s.PayModeId, + CardRegisterId = s.CardRegisterId }).ToList(); return entlistdto;