public string Save(FEERULEEntity DefineSave) { var v = GetVerify(DefineSave); if (DefineSave.ID.IsEmpty()) { DefineSave.ID = service.CommonService.NewINC("FEERULE"); } v.Require(a => a.ID); v.IsUnique(a => a.ID); v.Require(a => a.NAME); v.IsUnique(a => a.NAME); v.Require(a => a.PAY_CYCLE); //缴费周期 v.Require(a => a.ADVANCE_CYCLE); //提前周期 v.Require(a => a.FEE_DAY); //出单日期 v.Verify(); if ((Convert.ToInt32(DefineSave.FEE_DAY) <= 0 && Convert.ToInt32(DefineSave.FEE_DAY) != -1) || Convert.ToInt32(DefineSave.FEE_DAY) > 28) { throw new Exception("出单日期不能小于0或者大于28"); } if ((Convert.ToInt32(DefineSave.UP_DATE) <= 0 && Convert.ToInt32(DefineSave.UP_DATE) != -1) || Convert.ToInt32(DefineSave.UP_DATE) > 28) { throw new Exception("缴费截至日不能小于0或者大于28"); } return(CommonSave(DefineSave)); }
public void Delete(FEERULEEntity DefineDelete) { var v = GetVerify(DefineDelete); v.Require(a => a.ID); v.Verify(); CommenDelete(DefineDelete); }
public List <CONTRACT_RENTITEMEntity> zlYdFj(List <CONTRACT_RENTEntity> Data, CONTRACTEntity ContractData) { List <CONTRACT_RENTITEMEntity> zjfjList = new List <CONTRACT_RENTITEMEntity>(); //当月度分解没定义的时候抛出异常提示待完善 FEERULEEntity feeRule = new FEERULEEntity(); feeRule = DbHelper.Select(new FEERULEEntity() { ID = ContractData.FEERULE_RENT }); CONFIGEntity configBzybj = new CONFIGEntity(); configBzybj = DbHelper.Select(new CONFIGEntity() { ID = "1004" }); if (!"012".Contains(configBzybj.CUR_VAL)) { throw new LogicException("参数1004(不足月时月金额算法)设置有误"); } CONFIGEntity configBzyts = new CONFIGEntity(); configBzyts = DbHelper.Select(new CONFIGEntity() { ID = "1003" }); if (configBzyts.CUR_VAL.ToInt() <= 0) { throw new LogicException("参数1003(不足月天数设定)设置有误"); } CONFIGEntity configBlxsw = new CONFIGEntity(); configBlxsw = DbHelper.Select(new CONFIGEntity() { ID = "1002" }); //季度分解日期生成 CONFIGEntity configJDFJGZ = new CONFIGEntity(); configJDFJGZ = DbHelper.Select(new CONFIGEntity() { ID = "1005" }); //PAY_CYCLE缴费周期 //ADVANCE_CYCLE 提前周期 //FEE_DAY 出单日 //先计算出来每个年月对应的生成日期 DateTime dt = ContractData.CONT_START.ToDateTime(); var ym = dt.Year * 100 + dt.Month; if (configJDFJGZ.CUR_VAL.ToInt() == 0) //添加月份生成参数 0,按自然季度 ,1 顺延季度 BY:DZK 20190717 { switch (feeRule.PAY_CYCLE.ToInt()) { case 3: switch (dt.Month) { case 1: case 2: case 3: ym = dt.Year * 100 + 1; break; case 4: case 5: case 6: ym = dt.Year * 100 + 4; break; case 7: case 8: case 9: ym = dt.Year * 100 + 7; break; case 10: case 11: case 12: ym = dt.Year * 100 + 10; break; } break; case 6: switch (dt.Month) { case 1: case 2: case 3: case 4: case 5: case 6: ym = dt.Year * 100 + 1; break; case 7: case 8: case 9: case 10: case 11: case 12: ym = dt.Year * 100 + 7; break; } break; case 12: switch (dt.Month) { case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10: case 11: case 12: ym = dt.Year * 100 + 1; break; } break; default: ym = dt.Year * 100 + dt.Month; break; } } else { ym = dt.Year * 100 + dt.Month; } List <PERIODEntity> Perio = new List <PERIODEntity>(); Perio = DbHelper.SelectList(new PERIODEntity()). Where(a => (a.DATE_START.ToDateTime() <= ContractData.CONT_END.ToDateTime()) && (a.DATE_END.ToDateTime() >= ContractData.CONT_START.ToDateTime())).OrderBy(b => b.YEARMONTH).ToList(); List <CONTRACT_RENTITEMEntity> zjfjListGd = new List <CONTRACT_RENTITEMEntity>(); foreach (var per in Perio) { CONTRACT_RENTITEMEntity zjfj = new CONTRACT_RENTITEMEntity(); var scny = 0; //可以通过日期上加月份处理 if ((ym.ToString().Substring(4, 2).ToInt() - feeRule.ADVANCE_CYCLE.ToInt()) <= 0) { scny = (ym.ToString().Substring(0, 4).ToInt() - 1) * 100 + ((ym.ToString().Substring(4, 2).ToInt() + 12 - feeRule.ADVANCE_CYCLE.ToInt())); } else { scny = ym - feeRule.ADVANCE_CYCLE.ToInt(); } var ymLast = 0; if ((ym.ToString().Substring(4, 2).ToInt() + feeRule.PAY_CYCLE.ToInt()) > 12) { ymLast = (ym.ToString().Substring(0, 4).ToInt() + 1) * 100 + ((ym.ToString().Substring(4, 2).ToInt() + feeRule.PAY_CYCLE.ToInt()) - 12); } else { ymLast = ym + feeRule.PAY_CYCLE.ToInt(); } var scn = scny.ToString().Substring(0, 4).ToInt(); var scy = scny.ToString().Substring(4, 2).ToInt(); zjfj.YEARMONTH = per.YEARMONTH; if (feeRule.FEE_DAY.ToInt() == -1) { PERIODEntity PerioYm = new PERIODEntity(); PerioYm = DbHelper.Select(new PERIODEntity() { YEARMONTH = (scn * 100 + scy).ToString() }); zjfj.CREATEDATE = PerioYm.DATE_END; } else { zjfj.CREATEDATE = (new DateTime(scn, scy, feeRule.FEE_DAY.ToInt())).ToString().ToDateTime().ToString(); } zjfjListGd.Add(zjfj); if ((per.YEARMONTH.ToString().Substring(4, 2).ToInt() + 1) > 12) { per.YEARMONTH = ((per.YEARMONTH.ToString().Substring(0, 4).ToInt() + 1) * 100 + ((per.YEARMONTH.ToString().Substring(4, 2).ToInt() + 1) - 12)).ToString(); } else { per.YEARMONTH = (per.YEARMONTH.ToInt() + 1).ToString(); } if (per.YEARMONTH.ToInt() == ymLast) { ym = ymLast; } ; } foreach (var ydfj in Data) { List <PERIODEntity> Period = new List <PERIODEntity>(); Period = DbHelper.SelectList(new PERIODEntity()). Where(a => (a.DATE_START.ToDateTime() <= ydfj.ENDDATE.ToDateTime()) && (a.DATE_END.ToDateTime() >= ydfj.STARTDATE.ToDateTime())).OrderBy(b => b.YEARMONTH).ToList(); foreach (var per in Period) { double zts = Math.Abs((per.DATE_END.ToDateTime() - per.DATE_START.ToDateTime()).Days) + 1; CONTRACT_RENTITEMEntity zjfj = new CONTRACT_RENTITEMEntity(); if ((per.DATE_START.ToDateTime() < ContractData.CONT_START.ToDateTime()) || (per.DATE_START.ToDateTime() < ydfj.STARTDATE.ToDateTime())) { per.DATE_START = ydfj.STARTDATE; } ; if ((per.DATE_END.ToDateTime() > ContractData.CONT_END.ToDateTime()) || (per.DATE_END.ToDateTime() > ydfj.ENDDATE.ToDateTime())) { per.DATE_END = ydfj.ENDDATE; } ; zjfj.STARTDATE = per.DATE_START; zjfj.ENDDATE = per.DATE_END; double zjfjTs = Math.Abs((zjfj.ENDDATE.ToDateTime() - zjfj.STARTDATE.ToDateTime()).Days) + 1; zjfj.INX = ydfj.INX; var je = Convert.ToDouble(ydfj.RENTS); switch (ydfj.DJLX.ToInt()) { case 1: //日租金 zjfj.RENTS = Math.Round(je * zjfjTs, configBlxsw.CUR_VAL.ToInt(), MidpointRounding.AwayFromZero).ToString(); break; case 2: //月租金 if (zjfjTs != zts) //不足月时金额算法 { if (configBzybj.CUR_VAL.ToInt() == 0) //0(月金额/当月总天数)*实际天数; { zjfj.RENTS = (Math.Round(je / zts * zjfjTs, configBlxsw.CUR_VAL.ToInt(), MidpointRounding.AwayFromZero)).ToString(); } else if (configBzybj.CUR_VAL.ToInt() == 1) //1:(月金额/1003参数设置的天数)*实际天数; { zjfj.RENTS = (Math.Round(je / (configBzyts.CUR_VAL).ToDouble() * zjfjTs, configBlxsw.CUR_VAL.ToInt(), MidpointRounding.AwayFromZero)).ToString(); } else //2:(月金额*12/365)*实际天数 { zjfj.RENTS = (Math.Round((je * 12 / 365) * zjfjTs, configBlxsw.CUR_VAL.ToInt(), MidpointRounding.AwayFromZero)).ToString(); } } else { zjfj.RENTS = je.ToString(); } break; } ; foreach (var scrq in zjfjListGd) { if (per.YEARMONTH.ToInt() == scrq.YEARMONTH.ToInt()) { zjfj.CREATEDATE = scrq.CREATEDATE; } } zjfj.YEARMONTH = per.YEARMONTH; zjfjList.Add(zjfj); } } return(zjfjList); }