租出和租出退租完成

usertest
dengyu 3 months ago
parent 1ceca6013b
commit 8bc1a40fa2

@ -1639,5 +1639,8 @@ public static class MultiLanguageConst
[Description("箱号不能为空")] [Description("箱号不能为空")]
public const string CM_CntrnoNotNull = "Cntrno need value."; public const string CM_CntrnoNotNull = "Cntrno need value.";
[Description("已被退租引用")]
public const string CM_HaveBeenEndLease = "Cntrno CM_Have Been EndLease.";
#endregion #endregion
} }

@ -156,7 +156,7 @@ public class CM_RentOutController : ApiController
/// <returns></returns> /// <returns></returns>
[HttpPost] [HttpPost]
[Route("CM_RentOut_NeedRent_View")] [Route("CM_RentOut_NeedRent_View")]
public Task<DataResult<List<VW_CM_NeedEndLease_DetailRes>>> CM_RentOut_NeedRent_View([FromBody] PageRequest request) public Task<DataResult<List<VW_CM_RentOut_NeedRentRes>>> CM_RentOut_NeedRent_View([FromBody] PageRequest request)
{ {
var res = _invokeService.CM_RentOut_NeedRent_View(request); var res = _invokeService.CM_RentOut_NeedRent_View(request);
return res; return res;
@ -169,14 +169,14 @@ public class CM_RentOutController : ApiController
/// <returns></returns> /// <returns></returns>
[HttpPost] [HttpPost]
[Route("CM_RentOut_NeedEndLease_View")] [Route("CM_RentOut_NeedEndLease_View")]
public Task<DataResult<List<VW_CM_NeedEndLease_DetailRes>>> CM_RentOut_NeedEndLease_View([FromBody] PageRequest request) public Task<DataResult<List<VW_CM_RentOut_NeedEndLeaseRes>>> CM_RentOut_NeedEndLease_View([FromBody] PageRequest request)
{ {
var res = _invokeService.CM_RentOut_NeedEndLease_View(request); var res = _invokeService.CM_RentOut_NeedEndLease_View(request);
return res; return res;
} }
/// <summary> /// <summary>
/// 租箱租出退租_添加 /// 租箱租出_添加
/// </summary> /// </summary>
/// <param name="id"></param> /// <param name="id"></param>
/// <returns></returns> /// <returns></returns>
@ -188,4 +188,17 @@ public class CM_RentOutController : ApiController
//return res; //return res;
} }
/// <summary>
/// 租箱租出退租_添加
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpPost]
[Route("CM_RentOut_EndLease_AddCtn")]
public async Task<DataResult> CM_RentOut_EndLease_AddCtn([FromBody] IdModel model)
{
return await _invokeService.CM_RentOut_EndLease_AddCtn(long.Parse(model.Id), model.Ids);
//return res;
}
} }

@ -0,0 +1,186 @@
using DS.Module.Core;
using DS.Module.Core.Enums;
using DS.WMS.Core.Op.Entity;
using FluentValidation;
using Masuit.Tools.Systems;
using SqlSugar;
using System.ComponentModel;
namespace DS.WMS.ContainerManagement.Info.Dtos;
/// <summary>
/// 箱管_租箱租出 待退租明细视图 返回实体
/// </summary>
public class VW_CM_RentOut_NeedEndLeaseRes
{
/// <summary>
/// 租箱业务id
/// </summary>
public long Id { get; set; }
/// <summary>
/// Desc:租箱业务号
/// </summary>
public string Billno { get; set; }
/// <summary>
/// Desc:箱号
/// </summary>
public string Cntrno { get; set; }
/// <summary>
/// 箱型代码
/// </summary>
public string CtnCode { get; set; }
/// <summary>
/// Desc:箱型
/// </summary>
public string Ctnall { get; set; }
/// <summary>
/// Desc:箱来源Id: 自有箱/短租租入/长租租入/买箱
/// </summary>
public CM_CtnSourceEnum? CtnSourceId { get; set; }
/// <summary>
/// Desc:箱业务状态id: 短租租出 长租租出 单程 卖箱
/// </summary>
public CM_CtnBizStateEnum? CtnBizStateId { get; set; }
/// <summary>
/// Desc:是否上线id(是否管理中)
/// </summary>
public CM_IsOnlineEnum? IsOnlineId { get; set; } = 0;
/// <summary>
/// <summary>
/// Desc:箱状态Id
/// </summary>
public CMCtnStateEnum? CtnStateId { get; set; }
/// <summary>
/// Desc:箱流转状态Id
/// </summary>
public CMCtnFlowStateEnum? CtnFlowStateId { get; set; }
/// <summary>
/// Desc:箱主Id
/// </summary>
public long? CtnOwnerId { get; set; }
/// <summary>
/// Desc:原箱主
/// </summary>
public string CtnOwner { get; set; }
/// <summary>
/// Desc:租箱客户Id
/// </summary>
public long RentCustomerId { get; set; }
/// <summary>
/// Desc:租箱客户
/// </summary>
public string RentCustomerName { get; set; }
/// <summary>
/// Desc:租箱业务 租入 租入退租 租出 租出退租 CMRentDirectEnum
/// </summary>
public CMRentDirectEnum? RentDirectId { get; set; }
/// <summary>
/// Desc:租箱类型 1长租 0短租 2单程 CMRentTypeEnum
/// </summary>
public CMRentTypeEnum? RentTypeId { get; set; }
/// <summary>
/// Desc:租入日期
/// </summary>
public DateTime? Bsdate { get; set; }
/// <summary>
/// Desc:开始计费日期
/// </summary>
public DateTime? FeeStartDate { get; set; }
/// <summary>
/// Desc:币别
/// </summary>
public string Currency { get; set; } = "USD";
/// <summary>
/// Desc:日租金
/// </summary>
public decimal? DailyRate { get; set; } = 0M;
/// <summary>
/// Desc:提箱费
/// </summary>
public decimal? PickupFee { get; set; } = 0M;
/// <summary>
/// Desc:提箱日期
/// </summary>
public DateTime? PickupDate { get; set; }
/// <summary>
/// Desc:还箱费
/// </summary>
public decimal? DropoffFee { get; set; } = 0M;
/// <summary>
/// Desc:还箱日期
/// </summary>
public DateTime? DropoffDate { get; set; }
/// <summary>
/// Desc:起租地点代码
/// </summary>
public string RentalPortid { get; set; }
/// <summary>
/// Desc:起租地点五字码
/// </summary>
public string RentalPortCode { get; set; }
/// <summary>
/// Desc:起租地点
/// </summary>
public string RentalPort { get; set; }
/// <summary>
/// Desc:提箱港口代码
/// </summary>
public long? PickupPortid { get; set; }
/// <summary>
/// Desc:提箱港口五字码
/// </summary>
public string PickupPortCode { get; set; }
/// <summary>
/// Desc:提箱港口
/// </summary>
public string PickupPort { get; set; }
/// <summary>
/// Desc:还箱港口代码
/// </summary>
public long? DropoffPortid { get; set; }
/// <summary>
/// Desc:还箱港口五字码
/// </summary>
public string DropoffPortCode { get; set; }
/// <summary>
/// Desc:还箱港口
/// </summary>
public string DropoffPort { get; set; }
/// <summary>
/// Desc:业务编号/提单号
/// </summary>
public string Mblno { get; set; }
/// <summary>
/// Desc:船名航次
/// </summary>
public string VesselVoyno { get; set; }
}

@ -9,7 +9,7 @@ using System.ComponentModel;
namespace DS.WMS.ContainerManagement.Info.Dtos; namespace DS.WMS.ContainerManagement.Info.Dtos;
/// <summary> /// <summary>
/// 箱管_待计算月结费用明细 请求实体 /// 箱管_待计算月结费用明细 返回实体
/// </summary> /// </summary>
public class VW_CM_RentOut_NeedRentRes public class VW_CM_RentOut_NeedRentRes
{ {

@ -71,12 +71,22 @@ public interface ICM_RentOutService
/// </summary> /// </summary>
/// <param name="id"></param> /// <param name="id"></param>
/// <returns></returns> /// <returns></returns>
Task<DataResult<List<VW_CM_NeedEndLease_DetailRes>>> CM_RentOut_NeedEndLease_View(PageRequest request); Task<DataResult<List<VW_CM_RentOut_NeedEndLeaseRes>>> CM_RentOut_NeedEndLease_View(PageRequest request);
/// <summary> /// <summary>
/// 删除租出业务 /// 租出业务 添加租箱明细
/// </summary> /// </summary>
/// <param name="ids">租箱租出业务ID</param> /// <param name="ids">当前状态IDs</param>
/// <returns></returns> /// <returns></returns>
Task<DataResult> CM_RentOut_AddCtn(long id, params long[] ids); Task<DataResult> CM_RentOut_AddCtn(long id, params long[] ids);
/// <summary>
/// 租出业务 添加租箱退租明细
/// </summary>
/// <param name="ids">租箱租出业务明细ID</param>
/// <returns></returns>
Task<DataResult> CM_RentOut_EndLease_AddCtn(long id, params long[] ids);
} }

@ -102,8 +102,6 @@ public class CM_RentIn_DetailService : CMServiceBase, ICM_RentIn_DetailService
return DataResult<CM_RentIn_DetailRes>.Success(data, MultiLanguageConst.DataQuerySuccess); return DataResult<CM_RentIn_DetailRes>.Success(data, MultiLanguageConst.DataQuerySuccess);
} }
#region 删除
/// <summary> /// <summary>
/// 删除 /// 删除
/// </summary> /// </summary>
@ -111,7 +109,7 @@ public class CM_RentIn_DetailService : CMServiceBase, ICM_RentIn_DetailService
/// <returns></returns> /// <returns></returns>
public async Task<DataResult> DeleteCM_RentIn_DetailAsync(params long[] ids) public async Task<DataResult> DeleteCM_RentIn_DetailAsync(params long[] ids)
{ {
var feeCount = await TenantDb.Queryable<FeeRecord>().Where(x => ids.Contains(x.BusinessId)).CountAsync(); //var feeCount = await TenantDb.Queryable<FeeRecord>().Where(x => ids.Contains(x.BusinessId)).CountAsync();
//foreach (var _id in ids) { //foreach (var _id in ids) {
//if (await IsLockedAsync(_id, BusinessType.CM_RentIn)) //if (await IsLockedAsync(_id, BusinessType.CM_RentIn))
@ -120,6 +118,13 @@ public class CM_RentIn_DetailService : CMServiceBase, ICM_RentIn_DetailService
//if (await TenantDb.Queryable<FeeRecord>().AnyAsync(x => ids.Contains(x.Id) && (x.FeeStatus != FeeStatus.Entering && x.FeeStatus != FeeStatus.RejectSubmission))) //if (await TenantDb.Queryable<FeeRecord>().AnyAsync(x => ids.Contains(x.Id) && (x.FeeStatus != FeeStatus.Entering && x.FeeStatus != FeeStatus.RejectSubmission)))
// return DataResult.FailedWithDesc(nameof(MultiLanguageConst.FeeRecordDelete)); // return DataResult.FailedWithDesc(nameof(MultiLanguageConst.FeeRecordDelete));
var 退detail = await TenantDb.Queryable<CM_RentIn_Detail>().Where(x => ids.Contains(x.RentDetailId)).ToListAsync();
if (退detail != null && 退detail.Count > 0) {
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.CM_HaveBeenEndLease));
}
int result = await TenantDb.Deleteable<CM_RentIn_Detail>(x => ids.Contains(x.Id)).ExecuteCommandAsync(); int result = await TenantDb.Deleteable<CM_RentIn_Detail>(x => ids.Contains(x.Id)).ExecuteCommandAsync();
//await WriteBackStatusAsync(model.BusinessId, model.BusinessType); //await WriteBackStatusAsync(model.BusinessId, model.BusinessType);
@ -127,5 +132,4 @@ public class CM_RentIn_DetailService : CMServiceBase, ICM_RentIn_DetailService
return result > 0 ? DataResult.Success : DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed)); return result > 0 ? DataResult.Success : DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed));
} }
#endregion
} }

@ -680,25 +680,55 @@ public class CM_RentOutService : CMServiceBase, ICM_RentOutService
} }
/// <summary> /// <summary>
/// 租箱租出明细视图_列表 /// 租箱租出 待租出 明细_视图
/// </summary> /// </summary>
/// <param name="request"></param> /// <param name="id"></param>
/// <returns></returns> /// <returns></returns>
//public async Task<DataResult<List<VW_CM_NeedEndLease_DetailRes>>> CM_RentOut_Detail_View(PageRequest request) public async Task<DataResult<List<VW_CM_RentOut_NeedRentRes>>> CM_RentOut_NeedRent_View(PageRequest request)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
//if (request.PageCondition.SortConditions == null || request.PageCondition.SortConditions.Count() == 0)
//{ //{
// var tenantDb = saasService.GetBizDbScopeById(user.TenantId); // request.PageCondition.SortConditions = new SortCondition[]{new SortCondition
// //序列化查询条件 // {
// var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition); // SortField = nameof(VW_CM_RentOut_NeedRentRes.StateTime),
// var data = tenantDb.Queryable<VW_CM_NeedEndLease_Detail>() // ListSortDirection = System.ComponentModel.ListSortDirection.Descending
// .Where(whereList) // } };
// .Select<VW_CM_NeedEndLease_DetailRes>().ToQueryPage(request.PageCondition);
// return data;
//} //}
request.SetDefaultOrderField("StateTime");
//序列化查询条件
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
var data = tenantDb.Queryable<VW_CM_RentOut_NeedRent>()
.Where(whereList)
.Select<VW_CM_RentOut_NeedRentRes>()
.ToQueryPage(request.PageCondition);
return data;
}
/// <summary> /// <summary>
/// 租箱租出退租_添加箱 /// 租箱租出 待退租 明细_视图
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public async Task<DataResult<List<VW_CM_RentOut_NeedEndLeaseRes>>> CM_RentOut_NeedEndLease_View(PageRequest request)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
//序列化查询条件
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
var data = tenantDb.Queryable<VW_CM_RentOut_NeedEndLease>()
.Where(whereList)
.Select<VW_CM_RentOut_NeedEndLeaseRes>().ToQueryPage(request.PageCondition);
return data;
}
/// <summary>
/// 租箱租出_添加箱
/// </summary> /// </summary>
/// <param name="ids">租出明细ID</param> /// <param name="ids">租出明细ID</param>
/// <returns></returns> /// <returns></returns>
@ -717,14 +747,14 @@ public class CM_RentOutService : CMServiceBase, ICM_RentOutService
var CurrentDetailList = TenantDb.Queryable<CM_RentOut_Detail>() var CurrentDetailList = TenantDb.Queryable<CM_RentOut_Detail>()
.Where(a => a.Pid == id).ToList(); .Where(a => a.Pid == id).ToList();
var OnAddDetail = TenantDb.Queryable<CM_RentOut_Detail>() var AddCurrentStateList = TenantDb.Queryable<CM_CurrentState>()
.Where(a => ids.Contains(a.Id)).ToList(); .Where(a => ids.Contains(a.Id)).ToList();
var addList = new List<CM_RentOut_Detail>(); var addList = new List<CM_RentOut_Detail>();
if (OnAddDetail != null && OnAddDetail.Count > 0) if (AddCurrentStateList != null && AddCurrentStateList.Count > 0)
{ {
foreach (var addrec in OnAddDetail) foreach (var addrec in AddCurrentStateList)
{ {
if (CurrentDetailList.Exists(x => x.Cntrno == addrec.Cntrno)) if (CurrentDetailList.Exists(x => x.Cntrno == addrec.Cntrno))
{ {
@ -736,9 +766,12 @@ public class CM_RentOutService : CMServiceBase, ICM_RentOutService
newrec = addrec.Adapt<CM_RentOut_Detail>(); newrec = addrec.Adapt<CM_RentOut_Detail>();
newrec.Id = 0; newrec.Id = 0;
newrec.Pid = id; newrec.Pid = id;
newrec.RentDirectId = CMRentDirectEnum.退; newrec.RentDirectId = CMRentDirectEnum.;
newrec.DropoffDate = head.Bsdate; newrec.DropoffDate = head.Bsdate;
newrec.RentDetailId = addrec.Id;// newrec.RentDetailId = addrec.Id;//
newrec.RentCustomerId = head.RentCustomerId;
newrec.RentCustomerName = head.RentCustomerName;
newrec.RentTypeId = head.RentTypeId;
addList.Add(newrec); addList.Add(newrec);
} }
@ -766,46 +799,74 @@ public class CM_RentOutService : CMServiceBase, ICM_RentOutService
//return result > 0 ? DataResult.Success : DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed)); //return result > 0 ? DataResult.Success : DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed));
} }
/// <summary> /// <summary>
/// 租箱租出 待租出 明细_视图 /// 租箱租出退租_添加箱
/// </summary> /// </summary>
/// <param name="id"></param> /// <param name="ids">租出明细ID</param>
/// <returns></returns> /// <returns></returns>
public async Task<DataResult<List<VW_CM_RentOut_NeedRentRes>>> CM_RentOut_NeedRent_View(PageRequest request) { public async Task<DataResult> CM_RentOut_EndLease_AddCtn(long id, params long[] ids)
var tenantDb = saasService.GetBizDbScopeById(user.TenantId); {
//if (request.PageCondition.SortConditions == null || request.PageCondition.SortConditions.Count() == 0) //foreach (var _id in ids)
//{
// request.PageCondition.SortConditions = new SortCondition[]{new SortCondition
//{ //{
// SortField = nameof(VW_CM_RentOut_NeedRentRes.StateTime), if (await IsLockedAsync(id, BusinessType.CM_RentOut))
// ListSortDirection = System.ComponentModel.ListSortDirection.Descending return DataResult.FailedWithDesc(nameof(MultiLanguageConst.FeeLocked));
// } };
//} //}
//
request.SetDefaultOrderField("StateTime"); var head = TenantDb.Queryable<CM_RentOut>().Where(a => a.Id == id).First();
//序列化查询条件 var CurrentDetailList = TenantDb.Queryable<CM_RentOut_Detail>()
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition); .Where(a => a.Pid == id).ToList();
var data = tenantDb.Queryable<VW_CM_RentOut_NeedRent>()
.Where(whereList) var OnAddDetail = TenantDb.Queryable<CM_RentOut_Detail>()
.Select<VW_CM_RentOut_NeedRentRes > () .Where(a => ids.Contains(a.Id)).ToList();
.ToQueryPage(request.PageCondition);
return data; var addList = new List<CM_RentOut_Detail>();
if (OnAddDetail != null && OnAddDetail.Count > 0)
{
foreach (var addrec in OnAddDetail)
{
if (CurrentDetailList.Exists(x => x.Cntrno == addrec.Cntrno))
{
//箱号已存在 就不添加
} }
else
{
var newrec = new CM_RentOut_Detail();
newrec = addrec.Adapt<CM_RentOut_Detail>();
newrec.Id = 0;
newrec.Pid = id;
newrec.RentDirectId = CMRentDirectEnum.退;
newrec.DropoffDate = head.Bsdate;
newrec.RentDetailId = addrec.Id;//
/// <summary> addList.Add(newrec);
/// 租箱租出 待退租 明细_视图 }
/// </summary>
/// <param name="id"></param> }
/// <returns></returns>
public async Task<DataResult<List<VW_CM_NeedEndLease_DetailRes>>> CM_RentOut_NeedEndLease_View(PageRequest request) { if (addList != null && addList.Count > 0)
var tenantDb = saasService.GetBizDbScopeById(user.TenantId); {
//序列化查询条件 await TenantDb.Insertable(addList).ExecuteCommandAsync();
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
var data = tenantDb.Queryable<VW_CM_NeedEndLease_Detail>() return DataResult.Successed("添加成功!", id, MultiLanguageConst.DataCreateSuccess);
.Where(whereList)
.Select<VW_CM_NeedEndLease_DetailRes>().ToQueryPage(request.PageCondition);
return data;
} }
else
{
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed));
}
}
else
{
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed));
}
//await WriteBackStatusAsync(model.BusinessId, model.BusinessType);
//return result > 0 ? DataResult.Success : DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed));
}
} }

@ -111,14 +111,15 @@ public class CM_RentOut_DetailService : CMServiceBase, ICM_RentOut_DetailService
/// <returns></returns> /// <returns></returns>
public async Task<DataResult> DeleteCM_RentOut_DetailAsync(params long[] ids) public async Task<DataResult> DeleteCM_RentOut_DetailAsync(params long[] ids)
{ {
var feeCount = await TenantDb.Queryable<FeeRecord>().Where(x => ids.Contains(x.BusinessId)).CountAsync(); //var feeCount = await TenantDb.Queryable<FeeRecord>().Where(x => ids.Contains(x.BusinessId)).CountAsync();
//foreach (var _id in ids) { var 退detail = await TenantDb.Queryable<CM_RentIn_Detail>().Where(x => ids.Contains(x.RentDetailId)).ToListAsync();
//if (await IsLockedAsync(_id, BusinessType.CM_RentIn))
// return DataResult.FailedWithDesc(nameof(MultiLanguageConst.FeeLocked)); if (退detail != null && 退detail.Count > 0)
//} {
//if (await TenantDb.Queryable<FeeRecord>().AnyAsync(x => ids.Contains(x.Id) && (x.FeeStatus != FeeStatus.Entering && x.FeeStatus != FeeStatus.RejectSubmission))) return DataResult.FailedWithDesc(nameof(MultiLanguageConst.CM_HaveBeenEndLease));
// return DataResult.FailedWithDesc(nameof(MultiLanguageConst.FeeRecordDelete));
}
int result = await TenantDb.Deleteable<CM_RentOut_Detail>(x => ids.Contains(x.Id)).ExecuteCommandAsync(); int result = await TenantDb.Deleteable<CM_RentOut_Detail>(x => ids.Contains(x.Id)).ExecuteCommandAsync();

Loading…
Cancel
Save