|
|
using Microsoft.AspNetCore.Authorization;using Microsoft.AspNetCore.Mvc;using Microsoft.EntityFrameworkCore;using Shentun.Peis.Enums;using Shentun.Peis.Models;using System;using System.Collections.Generic;using System.ComponentModel.DataAnnotations;using System.Linq;using System.Threading.Tasks;using System.Transactions;using Volo.Abp.Application.Services;using Volo.Abp.Domain.Repositories;using Volo.Abp.Identity;
namespace Shentun.Peis.ChargeAsbitems{ /// <summary>
/// 收费项目
/// </summary>
[ApiExplorerSettings(GroupName = "Work")] [Authorize] public class ChargeAsbitemAppService : ApplicationService { private readonly IRepository<ChargeAsbitem, Guid> _chargeAsbitemRepository; private readonly IRepository<IdentityUser, Guid> _userRepository; private readonly IRepository<RegisterCheckAsbitem, Guid> _registerAsbitemRepository; private readonly IRepository<RegisterCheck, Guid> _registerCheckRepository;
public ChargeAsbitemAppService( IRepository<ChargeAsbitem, Guid> chargeAsbitemRepository, IRepository<IdentityUser, Guid> userRepository, IRepository<RegisterCheckAsbitem, Guid> registerAsbitemRepository, IRepository<RegisterCheck, Guid> registerCheckRepository ) { this._chargeAsbitemRepository = chargeAsbitemRepository; this._userRepository = userRepository; this._registerAsbitemRepository = registerAsbitemRepository; this._registerCheckRepository = registerCheckRepository; }
/// <summary>
/// 获取收费项目 跟据收费主表ID
/// </summary>
/// <param name="ChargeId"></param>
/// <returns></returns>
[HttpGet("api/app/chargeasbitem/getchargeasbiteminchargeid")] public async Task<List<ChargeAsbitemDto>> GetChargeAsbitemInChargeIdAsync(Guid ChargeId) { var chargeAsbitemList = (await _chargeAsbitemRepository.GetDbSetAsync()) .Include(x => x.Asbitem) .Where(m => m.ChargeId == ChargeId);
var userQueryable = await _userRepository.GetQueryableAsync(); var registerAsbitemQueryable = await _registerAsbitemRepository.GetQueryableAsync(); var registerCheckQueryable = await _registerCheckRepository.GetQueryableAsync();
DateTime? dtnull = null; char? charnull = null;
var entlist = from a in chargeAsbitemList join b in userQueryable on a.CreatorId equals b.Id into bb from ab in bb.DefaultIfEmpty() join c in userQueryable on a.LastModifierId equals c.Id into cc from ac in cc.DefaultIfEmpty() join d in registerAsbitemQueryable on a.RegisterAsbitemId equals d.Id into dd from ad in dd.DefaultIfEmpty() join f in userQueryable on ad.CreatorId equals f.Id into ff from af in ff.DefaultIfEmpty() join e in registerCheckQueryable on ad.RegisterCheckId equals e.Id into ee from ae in ee.DefaultIfEmpty() select new { a, CreatorName = ab.Surname, LastModifierName = ac.Surname, AsbitemPrice = ad != null ? ad.StandardPrice : 0, RegisterAsbitemChargePrice = ad != null ? ad.ChargePrice : 0, RegisterAsbitemCreationTime = ad != null ? ad.CreationTime : dtnull, RegisterAsbitemCreatorName = af != null ? af.Surname : "", RegisterAsbitemPayTypeFlag = ad != null ? ad.PayTypeFlag : PayTypeFlag.PersonPay, RegisterCheckCompleteFlag = ae != null ? ae.CompleteFlag : charnull, };
var ss = entlist.ToQueryString(); var entlistdto = entlist.Select(s => new ChargeAsbitemDto { Amount = s.a.Amount, ChargePrice = s.a.ChargePrice, ChargeId = s.a.ChargeId, AsbitemId = s.a.AsbitemId, AsbitemName = s.a.Asbitem.DisplayName, AsbitemPrice = s.AsbitemPrice, CreationTime = s.a.CreationTime, CreatorId = s.a.CreatorId, CreatorName = s.CreatorName, Id = s.a.Id, LastModificationTime = s.a.LastModificationTime, LastModifierId = s.a.LastModifierId, LastModifierName = s.LastModifierName, RegisterAsbitemId = s.a.RegisterAsbitemId, RegisterAsbitemChargePrice = s.RegisterAsbitemChargePrice, RegisterAsbitemCreationTime =DataHelper.ConversionDateToString( s.RegisterAsbitemCreationTime), RegisterAsbitemCreatorName = s.RegisterAsbitemCreatorName, RegisterAsbitemPayTypeFlag = s.RegisterAsbitemPayTypeFlag, RegisterCheckCompleteFlag = s.RegisterCheckCompleteFlag != null ? s.RegisterCheckCompleteFlag.Value : null
}).ToList();
return entlistdto;
}
}}
|