From 45749a84711447d1853bda994a7c459fb6769802 Mon Sep 17 00:00:00 2001 From: ddlucky Date: Sat, 24 Dec 2022 12:51:03 +0800 Subject: [PATCH] 20221224 --- .../MsRptSaleBalProfitShareController.cs | 7 ++ .../MsRptSaleBalProfitShareDAL.cs | 115 +++++++++++++++++- 2 files changed, 121 insertions(+), 1 deletion(-) diff --git a/DSWeb/Areas/MvcShipping/Controllers/MsRptSaleBalProfitShareController.cs b/DSWeb/Areas/MvcShipping/Controllers/MsRptSaleBalProfitShareController.cs index 50a96991..20378cab 100644 --- a/DSWeb/Areas/MvcShipping/Controllers/MsRptSaleBalProfitShareController.cs +++ b/DSWeb/Areas/MvcShipping/Controllers/MsRptSaleBalProfitShareController.cs @@ -265,6 +265,13 @@ namespace DSWeb.MvcShipping.Controllers } + public ContentResult GetTBDataListStr(int start, int limit, string condition, string TEU, string PROFITBOUNDS, string sort, string printstr, string sortstr) + { + var data = MsRptSaleBalProfitShareDAL.GetTBDataListStr(condition, TEU, PROFITBOUNDS, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), sort); + + var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = data.ToString() }); + return new ContentResult() { Content = json }; + } public ContentResult SaveFee(string data) { diff --git a/DSWeb/Areas/MvcShipping/DAL/MsRptSaleBalProfitShare/MsRptSaleBalProfitShareDAL.cs b/DSWeb/Areas/MvcShipping/DAL/MsRptSaleBalProfitShare/MsRptSaleBalProfitShareDAL.cs index 3f1ec7b5..3b0666d2 100644 --- a/DSWeb/Areas/MvcShipping/DAL/MsRptSaleBalProfitShare/MsRptSaleBalProfitShareDAL.cs +++ b/DSWeb/Areas/MvcShipping/DAL/MsRptSaleBalProfitShare/MsRptSaleBalProfitShareDAL.cs @@ -2252,9 +2252,120 @@ namespace DSWeb.MvcShipping.DAL.MsRptSaleBalProfitShareDAL #region 泰邦 提成计算 + static public List GetTBDataList(string strCondition, string TEU, string PROFITBOUNDS, string userid, string usercode, string companyid, string sort = null) { + //var rangstr = GetRangDAStr("index", userid, usercode, companyid); + //var strConditionAll = strCondition; + //if (!string.IsNullOrEmpty(rangstr)) + //{ + // if (!string.IsNullOrEmpty(strCondition)) + // { + // strConditionAll = strCondition + " and " + rangstr; + // } + // else + // { + // strConditionAll = rangstr; + // } + //} + + + //var strSql = new StringBuilder(); + //strSql.Append(" if object_id('tempdb..##SALEPROFITSHARE') is not null Begin DROP TABLE ##SALEPROFITSHARE End "); + + //strSql.Append("SELECT * into ##SALEPROFITSHARE FROM (SELECT B.BSNO, B.OPLB,B.OPTYPE,B.OPLBNAME, B.BSTYPE,B.CUSTOMERNAME, B.CUSTNO, B.MBLNO, B.HBLNO,B.VESSEL, B.VOYNO, B.INPUTBY, B.CREATETIME, B.BSSTATUS, B.SALE, B.OP, B.DOC,"); + //strSql.Append("B.ETD,B.OPDATE,B.CUSTOMDATE,B.FEESTATUSREF,B.BLFRT,B.BSSOURCEDETAIL,B.STLNAME"); + //strSql.Append(",B.STLDATE "); + + //strSql.Append(",B.CUSTSERVICE, B.PORTLOAD, B.PORTDISCHARGE, B.CUSTOMNO, B.ACCDATE,B.CARRIER, B.BSSOURCE, B.LANE, B.FORWARDER,B.NETWEIGHT,B.KGS,B.TEU,B.CNTRTOTAL,B.CORPID"); + //strSql.Append(",B.CNTR1,B.CNTR2,B.CNTR3,B.CNTR4,B.CNTR5,B.CNTR6,B.CNTR7,B.CNTR8,B.CNTR9,B.CNTR10,B.OTCNTR,B.TRADETYPE,B.GOODSNAME,B.FEESTATUS"); + //strSql.Append(",B.RMBDR,B.RMBCR,B.STLRMBDR,B.STLRMBCR,B.USDDR,B.USDCR,B.STLUSDDR,B.STLUSDCR,B.OTDR,B.OTCR,B.STLOTDR,B.STLOTCR,B.TTLDR,B.TTLCR,B.STLTTLDR,B.STLTTLCR"); + //strSql.Append(",B.USDPROFIT,B.RMBPROFIT,B.OTPROFIT,B.TTLPROFIT,B.PROFITRATE,B.TAXPROFIT,B.RMBNODR,B.USDNODR,B.OTNODR,B.TTLNODR,B.RMBNOCR,B.USDNOCR,B.OTNOCR,B.TTLNOCR "); + //strSql.Append(",T.SETTLETIME,f.ISFEE,T.STLTTLDR MONTHSTLTTLDR"); + + ////该客户的 Info_Client_ACCDATE.BGNDATE (生效日期) 减 每票货的开船日期得出是否超过一年以内 + ////一年以内则提成30% 一年之外为15% + ////此处ACTUALDAY为ETD-帐期生效日期。大于1年则ACTUALDAY小于-365 + //strSql.Append(",DATEDIFF([day],b.ETD,(select min(bgndate) from Info_Client_ACCDATE where LINKGID=(select gid from Info_Client where SHORTNAME=b.CUSTOMERNAME)))+1 ACTUALDAY"); + + //strSql.Append(",DATEDIFF([day],ISNULL(T.SETTLETIME,GETDATE()),(select min(bgndate) from Info_Client_ACCDATE where LINKGID=(select gid from Info_Client where SHORTNAME=b.CUSTOMERNAME))) NODAY"); + + //strSql.Append(",B.ACCDATE ETDMONTH,(CASE f.ISFEE WHEN 1 THEN '已发放' else '未发放' end) as ISFEEREF,CASE WHEN (B.TTLDR-B.STLTTLDR)<0 THEN 0 ELSE (dbo.GetZHZYTTL(B.STLDATE,B.BSNO)+TTLNODR*ZYRATE*DATEDIFF([day],B.STLDATE,GETDATE())) END ZYTTL "); + + //strSql.Append(" FROM v_op_bill_gain_zh B "); + //strSql.Append("LEFT JOIN V_MAX_SETTLEMENTTIME_BSDR T ON (T.BSNO=B.BSNO) "); + //strSql.Append("LEFT JOIN op_sale_proftfee f ON (f.BSNO=B.BSNO) where B.TTLDR<>0 "); + //strSql.Append(" AND B.TTLDR=B.STLTTLDR "); + + + //if (!string.IsNullOrEmpty(strConditionAll)) + //{ + // strSql.Append(" and " + strConditionAll); + //} + + ////if (isalldr == "1") + ////{ + // strSql.Append(" union SELECT B.BSNO, B.OPLB,B.OPTYPE,B.OPLBNAME, B.BSTYPE,B.CUSTOMERNAME, B.CUSTNO, B.MBLNO, B.HBLNO,B.VESSEL, B.VOYNO, B.INPUTBY, B.CREATETIME, B.BSSTATUS, B.SALE, B.OP, B.DOC,"); + // strSql.Append("B.ETD,B.OPDATE,B.CUSTOMDATE,B.FEESTATUSREF,B.BLFRT,B.BSSOURCEDETAIL,B.STLNAME"); + // strSql.Append(",B.STLDATE "); + // strSql.Append(",B.CUSTSERVICE, B.PORTLOAD, B.PORTDISCHARGE, B.CUSTOMNO, B.ACCDATE,B.CARRIER, B.BSSOURCE, B.LANE, B.FORWARDER,B.NETWEIGHT,B.KGS,B.TEU,B.CNTRTOTAL,B.CORPID"); + // strSql.Append(",B.CNTR1,B.CNTR2,B.CNTR3,B.CNTR4,B.CNTR5,B.CNTR6,B.CNTR7,B.CNTR8,B.CNTR9,B.CNTR10,B.OTCNTR,B.TRADETYPE,B.GOODSNAME,B.FEESTATUS"); + // strSql.Append(",B.RMBDR,B.RMBCR,B.STLRMBDR,B.STLRMBCR,B.USDDR,B.USDCR,B.STLUSDDR,B.STLUSDCR,B.OTDR,B.OTCR,B.STLOTDR,B.STLOTCR,B.TTLDR,B.TTLCR,B.STLTTLDR,B.STLTTLCR"); + // strSql.Append(",B.USDPROFIT,B.RMBPROFIT,B.OTPROFIT,B.TTLPROFIT,B.PROFITRATE,B.TAXPROFIT,B.RMBNODR,B.USDNODR,B.OTNODR,B.TTLNODR,B.RMBNOCR,B.USDNOCR,B.OTNOCR,B.TTLNOCR "); + // strSql.Append(",T.SETTLETIME,f.ISFEE,0 MONTHSTLTTLDR"); + + // //该客户的 Info_Client_ACCDATE.BGNDATE (生效日期) 减 每票货的开船日期得出是否超过一年以内 + // //一年以内则提成30% 一年之外为15% + // //此处NODAY为ETD-帐期生效日期。大于1年则noday小于-365 + // strSql.Append(",DATEDIFF([day],b.ETD,(select min(bgndate) from Info_Client_ACCDATE where LINKGID=(select gid from Info_Client where SHORTNAME=b.CUSTOMERNAME)))+1 ACTUALDAY"); + + // strSql.Append(",DATEDIFF([day],ISNULL(T.SETTLETIME,GETDATE()),(select min(bgndate) from Info_Client_ACCDATE where LINKGID=(select gid from Info_Client where SHORTNAME=b.CUSTOMERNAME))) NODAY"); + + // strSql.Append(",B.ACCDATE ETDMONTH,(CASE f.ISFEE WHEN 1 THEN '已发放' else '未发放' end) as ISFEEREF,0 ZYTTL "); + + // strSql.Append(" FROM v_op_bill_gain_zh B "); + // strSql.Append("LEFT JOIN V_MAX_SETTLEMENTTIME_CR T ON (T.BSNO=B.BSNO) "); + // strSql.Append("LEFT JOIN op_sale_proftfee f ON (f.BSNO=B.BSNO) where B.TTLDR=0 "); + + // //strSql.Append("AND (T.SETTLETIME>='" + CurDateBegin.ToString("yyyy-MM-dd") + "' AND T.SETTLETIME<='" + CurDateEnd.ToString("yyyy-MM-dd 23:59:59") + "' "); + // //strSql.Append(" AND B.ACCDATE<='" + CurDateBegin.ToString("yyyy-MM") + "') "); + + // if (!string.IsNullOrEmpty(strConditionAll)) + // { + // strSql.Append(" and " + strConditionAll); + // } + + + + ////} + //strSql.Append(" ) AS V "); + //// + //var sortstring = DatasetSort.Getsortstring(sort); + //if (!string.IsNullOrEmpty(sortstring)) + //{ + // strSql.Append(" order by " + sortstring); + //} + //else + //{ + // strSql.Append(" order by SALE,(CASE WHEN TTLPROFIT<0 THEN convert(datetime,convert(varchar(7),ACCDATE)+'-01') ELSE convert(datetime,convert(varchar(7),ACCDATE)+'-02') END),SETTLETIME,CREATETIME DESC"); + // // strSql.Append(" order by SALE,SETTLETIME,ETD,CREATETIME DESC"); + //} + + //strSql.Append(" SELECT * FROM ##SALEPROFITSHARE "); + + var strSql = GetTBDataListStr(strCondition, TEU, PROFITBOUNDS, userid, usercode, companyid, sort); + + return SetTBData(strCondition, strSql, TEU, PROFITBOUNDS); + } + + + + + static public StringBuilder GetTBDataListStr(string strCondition, string TEU, string PROFITBOUNDS, string userid, string usercode, string companyid, string sort = null) + { + + var rangstr = GetRangDAStr("index", userid, usercode, companyid); var strConditionAll = strCondition; if (!string.IsNullOrEmpty(rangstr)) @@ -2353,7 +2464,9 @@ namespace DSWeb.MvcShipping.DAL.MsRptSaleBalProfitShareDAL strSql.Append(" SELECT * FROM ##SALEPROFITSHARE "); - return SetTBData(strCondition, strSql, TEU, PROFITBOUNDS); + //return SetTBData(strCondition, strSql, TEU, PROFITBOUNDS); + + return strSql; }