diff --git a/Src/Asp.Net/MySqlTest/MySqlTest.csproj b/Src/Asp.Net/MySqlTest/MySqlTest.csproj index cebdef4b6..1d8fedd11 100644 --- a/Src/Asp.Net/MySqlTest/MySqlTest.csproj +++ b/Src/Asp.Net/MySqlTest/MySqlTest.csproj @@ -86,6 +86,8 @@ + + diff --git a/Src/Asp.Net/MySqlTest/UnitTest/Models/BilPayment.cs b/Src/Asp.Net/MySqlTest/UnitTest/Models/BilPayment.cs new file mode 100644 index 000000000..415bbcb4f --- /dev/null +++ b/Src/Asp.Net/MySqlTest/UnitTest/Models/BilPayment.cs @@ -0,0 +1,177 @@ +using SqlSugar; +using System; + +namespace OrmTest +{ + + /// + /// 应付费用表,记录与服务商之间的应收/应付费用。 + /// + [SugarTable("bil_payment", "应付费用表,记录与服务商之间的应收/应付费用。")] + public partial class BilPayment + { + /// + /// 应付费用id + /// + [SugarColumn(ColumnName = "pm_id", IsPrimaryKey = true, IsIdentity = true, ColumnDescription = "应付费用id")] + public long Id { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "tms_id", ColumnDescription = "")] + public int? TmsId { get; set; } + + /// + /// 业务id + /// + [SugarColumn(ColumnName = "bs_id", ColumnDescription = "业务id")] + public long BsId { get; set; } + + /// + /// 服务商id + /// + [SugarColumn(ColumnName = "server_id", ColumnDescription = "服务商id")] + public long ServerId { get; set; } + + /// + /// 费用类型 + /// + [SugarColumn(ColumnName = "fk_code", ColumnDescription = "费用类型")] + public string FkCode { get; set; } + + /// + /// 计费单位 + /// + [SugarColumn(ColumnName = "unit_code", ColumnDescription = "计费单位")] + public string UnitCode { get; set; } + + /// + /// 金额,负数表示服务商退回费用 + /// + [SugarColumn(ColumnName = "pm_amount", ColumnDescription = "金额,负数表示服务商退回费用")] + public decimal PmAmount { get; set; } + + /// + /// 原币种 + /// + [SugarColumn(ColumnName = "currency_code", ColumnDescription = "原币种")] + public string CurrencyCode { get; set; } + + /// + /// 汇率 + /// + [SugarColumn(ColumnName = "pm_currencyrate", ColumnDescription = "汇率")] + public decimal PmCurrencyrate { get; set; } + + /// + /// 本位币金额 + /// + [SugarColumn(ColumnName = "pm_currencyamount", ColumnDescription = "本位币金额")] + public decimal? PmCurrencyamount { get; set; } + + + /// + /// 核销完成标志,y表示本费用被核销 + /// + [SugarColumn(ColumnName = "pm_writeoffsign", ColumnDescription = "核销完成标志,y表示本费用被核销 ")] + public string PmWriteoffsign { get; set; } + + /// + /// 应付费用付清时间 + /// + [SugarColumn(ColumnName = "pm_writeoffdate", ColumnDescription = "应付费用付清时间")] + public DateTime? PmWriteoffdate { get; set; } + + /// + /// 费用发生日期。快件指出货日期,其它指入机日期 + /// + [SugarColumn(ColumnName = "pd_occurdate", ColumnDescription = "费用发生日期。快件指出货日期,其它指入机日期")] + public DateTime PdOccurdate { get; set; } + + /// + /// 计费价格表id + /// + [SugarColumn(ColumnName = "pd_pricesheetid", ColumnDescription = "计费价格表id")] + public long? PdPricesheetid { get; set; } + + /// + /// 计费价格值id + /// + [SugarColumn(ColumnName = "pv_pricevalueid", ColumnDescription = "计费价格值id")] + public long? PvPricevalueid { get; set; } + + /// + /// 计费分区 + /// + [SugarColumn(ColumnName = "pd_zoneid", ColumnDescription = "计费分区")] + public long? PdZoneid { get; set; } + + /// + /// 备注 + /// + [SugarColumn(ColumnName = "pd_note", ColumnDescription = "备注")] + public string PdNote { get; set; } + + /// + /// 服务商余额顺序ID + /// + [SugarColumn(ColumnName = "pm_server_surplusorderid", ColumnDescription = "服务商余额顺序ID")] + public long? PmServerSurplusorderid { get; set; } + + /// + /// 对账标志,Y为已完成服务商金额对账,N为未完成对账 + /// + [SugarColumn(ColumnName = "servebill_checksign", ColumnDescription = "对账标志,Y为已完成服务商金额对账,N为未完成对账")] + public string ServebillChecksign { get; set; } + + /// + /// 服务商对账时间 + /// + [SugarColumn(ColumnName = "servebill_checkdate", ColumnDescription = "服务商对账时间")] + public DateTime? ServebillCheckdate { get; set; } + + /// + /// 服务商账单ID + /// + [SugarColumn(ColumnName = "servebill_id", ColumnDescription = "服务商账单ID")] + public long? ServebillId { get; set; } + + /// + /// 导入时的服务商账单ID + /// + [SugarColumn(ColumnName = "import_servebill_id", ColumnDescription = "导入时的服务商账单ID")] + public long? ImportServebillId { get; set; } + + /// + /// 费用冲抵id + /// + [SugarColumn(ColumnName = "offset_pm_id", ColumnDescription = "费用冲抵id")] + public long? OffsetPmId { get; set; } + + /// + /// 成本费用分摊id + /// + [SugarColumn(ColumnName = "share_id", ColumnDescription = "成本费用分摊id")] + public long? ShareId { get; set; } + + /// + /// 应付账单id + /// + [SugarColumn(ColumnName = "paymentbill_id", ColumnDescription = "应付账单id")] + public long? PaymentbillId { get; set; } + + /// + /// 供应商账单ID + /// + [SugarColumn(ColumnName = "supplierbill_id", ColumnDescription = "供应商账单ID")] + public long? SupplierbillId { get; set; } + + /// + /// 差异原因,基础表:bsd_servebilldifference_reason(人工导入的费用,标记与系统自动算出的费用的差异原因) + /// + [SugarColumn(ColumnName = "difference_reason", ColumnDescription = "差异原因,基础表:bsd_servebilldifference_reason(人工导入的费用,标记与系统自动算出的费用的差异原因)")] + public string DifferenceReason { get; set; } + + } +} \ No newline at end of file diff --git a/Src/Asp.Net/MySqlTest/UnitTest/Models/BilSupplierbalancerecord.cs b/Src/Asp.Net/MySqlTest/UnitTest/Models/BilSupplierbalancerecord.cs new file mode 100644 index 000000000..90e1a0b79 --- /dev/null +++ b/Src/Asp.Net/MySqlTest/UnitTest/Models/BilSupplierbalancerecord.cs @@ -0,0 +1,68 @@ +using SqlSugar; +using System; + +namespace OrmTest +{ + + /// + /// 供应商付款核销记录表 + /// + [SugarTable("bil_supplierbalancerecord", "供应商付款核销记录表")] + public partial class BilSupplierbalancerecord + { + /// + /// 自增ID + /// + [SugarColumn(ColumnName = "sbr_id", IsPrimaryKey = true, IsIdentity = true, ColumnDescription = "自增ID")] + public long Id { get; set; } + + /// + /// 应付费用ID,对应bil_payment表的pm_id + /// + [SugarColumn(ColumnName = "pm_id", ColumnDescription = "应付费用ID,对应bil_payment表的pm_id")] + public long? PmId { get; set; } + + /// + /// 种类代码(Q信用额度,S金额),目前只有S + /// + [SugarColumn(ColumnName = "ipf_code", ColumnDescription = "种类代码(Q信用额度,S金额),目前只有S")] + public string IpfCode { get; set; } + + /// + /// 供应商付款ID,对应stm_suppliercurrent表的sc_id + /// + [SugarColumn(ColumnName = "sbr_payablefundid", ColumnDescription = "供应商付款ID,对应stm_suppliercurrent表的sc_id")] + public long? SbrPayablefundid { get; set; } + + /// + /// 核销金额 + /// + [SugarColumn(ColumnName = "sbr_amount", ColumnDescription = "核销金额 ")] + public decimal? SbrAmount { get; set; } + + /// + /// 核销日期 + /// + [SugarColumn(ColumnName = "sbr_createdate", ColumnDescription = "核销日期")] + public DateTime CreateTime{get;set;} + + /// + /// 核销人 + /// + [SugarColumn(ColumnName = "st_id_create", ColumnDescription = "核销人")] + public long CreateBy { get; set; } + + /// + /// 记录相互冲抵的sbr_id,相互冲抵的应付费用不新建付款来核销了,直接核销 + /// + [SugarColumn(ColumnName = "sbr_offsetid", ColumnDescription = "记录相互冲抵的sbr_id,相互冲抵的应付费用不新建付款来核销了,直接核销")] + public long? SbrOffsetid { get; set; } + + /// + /// 核销金额(原币) + /// + [SugarColumn(ColumnName = "sbr_amount_ocur", ColumnDescription = "核销金额(原币)")] + public decimal? SbrAmountOcur { get; set; } + + } +} \ No newline at end of file diff --git a/Src/Asp.Net/MySqlTest/UnitTest/UCustom20.cs b/Src/Asp.Net/MySqlTest/UnitTest/UCustom20.cs index 10ccbca21..52f3990f7 100644 --- a/Src/Asp.Net/MySqlTest/UnitTest/UCustom20.cs +++ b/Src/Asp.Net/MySqlTest/UnitTest/UCustom20.cs @@ -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().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() + .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