mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-24 07:22:57 +08:00
Add unit test
This commit is contained in:
parent
40ad748f6a
commit
3059e93665
@ -86,6 +86,8 @@
|
||||
<Compile Include="Models\Unit\Custom1\PurchaseDetailModel.cs" />
|
||||
<Compile Include="Models\ViewOrder.cs" />
|
||||
<Compile Include="Demo\DemoJ_Report.cs" />
|
||||
<Compile Include="UnitTest\Models\BilPayment.cs" />
|
||||
<Compile Include="UnitTest\Models\BilSupplierbalancerecord.cs" />
|
||||
<Compile Include="UnitTest\UCustom20.cs" />
|
||||
<Compile Include="UnitTest\UBulkCopy2.cs" />
|
||||
<Compile Include="UnitTest\UCustom07.cs" />
|
||||
|
177
Src/Asp.Net/MySqlTest/UnitTest/Models/BilPayment.cs
Normal file
177
Src/Asp.Net/MySqlTest/UnitTest/Models/BilPayment.cs
Normal file
@ -0,0 +1,177 @@
|
||||
using SqlSugar;
|
||||
using System;
|
||||
|
||||
namespace OrmTest
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 应付费用表,记录与服务商之间的应收/应付费用。
|
||||
///</summary>
|
||||
[SugarTable("bil_payment", "应付费用表,记录与服务商之间的应收/应付费用。")]
|
||||
public partial class BilPayment
|
||||
{
|
||||
/// <summary>
|
||||
/// 应付费用id
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "pm_id", IsPrimaryKey = true, IsIdentity = true, ColumnDescription = "应付费用id")]
|
||||
public long Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "tms_id", ColumnDescription = "")]
|
||||
public int? TmsId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 业务id
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "bs_id", ColumnDescription = "业务id")]
|
||||
public long BsId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 服务商id
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "server_id", ColumnDescription = "服务商id")]
|
||||
public long ServerId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 费用类型
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "fk_code", ColumnDescription = "费用类型")]
|
||||
public string FkCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 计费单位
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "unit_code", ColumnDescription = "计费单位")]
|
||||
public string UnitCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 金额,负数表示服务商退回费用
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "pm_amount", ColumnDescription = "金额,负数表示服务商退回费用")]
|
||||
public decimal PmAmount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 原币种
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "currency_code", ColumnDescription = "原币种")]
|
||||
public string CurrencyCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 汇率
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "pm_currencyrate", ColumnDescription = "汇率")]
|
||||
public decimal PmCurrencyrate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 本位币金额
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "pm_currencyamount", ColumnDescription = "本位币金额")]
|
||||
public decimal? PmCurrencyamount { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 核销完成标志,y表示本费用被核销
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "pm_writeoffsign", ColumnDescription = "核销完成标志,y表示本费用被核销 ")]
|
||||
public string PmWriteoffsign { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 应付费用付清时间
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "pm_writeoffdate", ColumnDescription = "应付费用付清时间")]
|
||||
public DateTime? PmWriteoffdate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 费用发生日期。快件指出货日期,其它指入机日期
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "pd_occurdate", ColumnDescription = "费用发生日期。快件指出货日期,其它指入机日期")]
|
||||
public DateTime PdOccurdate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 计费价格表id
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "pd_pricesheetid", ColumnDescription = "计费价格表id")]
|
||||
public long? PdPricesheetid { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 计费价格值id
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "pv_pricevalueid", ColumnDescription = "计费价格值id")]
|
||||
public long? PvPricevalueid { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 计费分区
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "pd_zoneid", ColumnDescription = "计费分区")]
|
||||
public long? PdZoneid { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 备注
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "pd_note", ColumnDescription = "备注")]
|
||||
public string PdNote { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 服务商余额顺序ID
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "pm_server_surplusorderid", ColumnDescription = "服务商余额顺序ID")]
|
||||
public long? PmServerSurplusorderid { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 对账标志,Y为已完成服务商金额对账,N为未完成对账
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "servebill_checksign", ColumnDescription = "对账标志,Y为已完成服务商金额对账,N为未完成对账")]
|
||||
public string ServebillChecksign { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 服务商对账时间
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "servebill_checkdate", ColumnDescription = "服务商对账时间")]
|
||||
public DateTime? ServebillCheckdate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 服务商账单ID
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "servebill_id", ColumnDescription = "服务商账单ID")]
|
||||
public long? ServebillId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 导入时的服务商账单ID
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "import_servebill_id", ColumnDescription = "导入时的服务商账单ID")]
|
||||
public long? ImportServebillId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 费用冲抵id
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "offset_pm_id", ColumnDescription = "费用冲抵id")]
|
||||
public long? OffsetPmId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 成本费用分摊id
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "share_id", ColumnDescription = "成本费用分摊id")]
|
||||
public long? ShareId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 应付账单id
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "paymentbill_id", ColumnDescription = "应付账单id")]
|
||||
public long? PaymentbillId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 供应商账单ID
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "supplierbill_id", ColumnDescription = "供应商账单ID")]
|
||||
public long? SupplierbillId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 差异原因,基础表:bsd_servebilldifference_reason(人工导入的费用,标记与系统自动算出的费用的差异原因)
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "difference_reason", ColumnDescription = "差异原因,基础表:bsd_servebilldifference_reason(人工导入的费用,标记与系统自动算出的费用的差异原因)")]
|
||||
public string DifferenceReason { get; set; }
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
using SqlSugar;
|
||||
using System;
|
||||
|
||||
namespace OrmTest
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 供应商付款核销记录表
|
||||
///</summary>
|
||||
[SugarTable("bil_supplierbalancerecord", "供应商付款核销记录表")]
|
||||
public partial class BilSupplierbalancerecord
|
||||
{
|
||||
/// <summary>
|
||||
/// 自增ID
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "sbr_id", IsPrimaryKey = true, IsIdentity = true, ColumnDescription = "自增ID")]
|
||||
public long Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 应付费用ID,对应bil_payment表的pm_id
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "pm_id", ColumnDescription = "应付费用ID,对应bil_payment表的pm_id")]
|
||||
public long? PmId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 种类代码(Q信用额度,S金额),目前只有S
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "ipf_code", ColumnDescription = "种类代码(Q信用额度,S金额),目前只有S")]
|
||||
public string IpfCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 供应商付款ID,对应stm_suppliercurrent表的sc_id
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "sbr_payablefundid", ColumnDescription = "供应商付款ID,对应stm_suppliercurrent表的sc_id")]
|
||||
public long? SbrPayablefundid { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 核销金额
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "sbr_amount", ColumnDescription = "核销金额 ")]
|
||||
public decimal? SbrAmount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 核销日期
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "sbr_createdate", ColumnDescription = "核销日期")]
|
||||
public DateTime CreateTime{get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// 核销人
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "st_id_create", ColumnDescription = "核销人")]
|
||||
public long CreateBy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 记录相互冲抵的sbr_id,相互冲抵的应付费用不新建付款来核销了,直接核销
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "sbr_offsetid", ColumnDescription = "记录相互冲抵的sbr_id,相互冲抵的应付费用不新建付款来核销了,直接核销")]
|
||||
public long? SbrOffsetid { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 核销金额(原币)
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "sbr_amount_ocur", ColumnDescription = "核销金额(原币)")]
|
||||
public decimal? SbrAmountOcur { get; set; }
|
||||
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@ -27,6 +28,22 @@ namespace OrmTest
|
||||
{
|
||||
throw new Exception("unit error");
|
||||
}
|
||||
var servebillIdList = new string[] { };
|
||||
var sql= db.Queryable<BilPayment>().Where(pm1 => SqlFunc.ContainsArray(servebillIdList, pm1.ServebillId))
|
||||
.GroupBy(pm1 => pm1.ServebillId)
|
||||
.Select(pm1 => (object)new
|
||||
{
|
||||
pm1.ServebillId,
|
||||
PmCurrencyamount = SqlFunc.AggregateSum(pm1.PmCurrencyamount),
|
||||
PmAmount = SqlFunc.AggregateSum(pm1.PmAmount),
|
||||
SbrAmount = SqlFunc.AggregateSum(SqlFunc.Subqueryable<BilSupplierbalancerecord>()
|
||||
.Where(x => x.IpfCode == "" && x.PmId == pm1.Id)
|
||||
.Select(x => SqlFunc.AggregateSum(SqlFunc.ToDecimal(x.SbrAmount))))
|
||||
}).ToSqlString();
|
||||
if (!sql.Contains("`bil_payment` pm1"))
|
||||
{
|
||||
throw new Exception("unit error");
|
||||
}
|
||||
}
|
||||
|
||||
public class TestDTO
|
||||
|
Loading…
Reference in New Issue
Block a user