Beispiel #1
0
        /// <summary>
        /// 保存额度信息表
        /// </summary>
        /// <param name="monthLimit">年月额度信息数据</param>
        public int SaveMonthlyPayLimit(MonthlyPayLimit monthLimit)
        {
            Mapper.CreateMap <LTC_MONTHLYPAYLIMIT, MonthlyPayLimit>();
            Mapper.CreateMap <MonthlyPayLimit, LTC_MONTHLYPAYLIMIT>();
            var model = Mapper.Map <LTC_MONTHLYPAYLIMIT>(monthLimit);

            unitOfWork.GetRepository <LTC_MONTHLYPAYLIMIT>().Insert(model);
            return(model.PAYLIMITID);

            unitOfWork.Save();
        }
Beispiel #2
0
        /// <summary>
        /// 无额度信息生成账单
        /// </summary>
        /// <param name="billV2">使用记录信息</param>
        /// <param name="item">时间集合</param>
        /// <param name="isHaveNCI">是否拥有护理险资格</param>
        /// <param name="billInfo">账单数据</param>
        public void NotHasQuotaInfo(BillV2Info billV2, KeyValueForDate item, bool isHaveNCI, BillV2 billInfo, string idNo)
        {
            var feeRecordYearMonth = billV2.feeRecordList.Where(m => m.TakeTime >= item.startDate && m.TakeTime <= item.endtDate.AddDays(1).AddSeconds(-1)).ToList();

            if (feeRecordYearMonth != null && feeRecordYearMonth.Count > 0)
            {
                decimal payedAmount = 0;                                                                     //累计额度

                var selfPay          = feeRecordYearMonth.Where(m => m.IsNCIItem == false).Sum(m => m.Cost); //自费项目总费用
                var nciItemTotalCost = feeRecordYearMonth.Where(m => m.IsNCIItem == true).Sum(m => m.Cost);  // 护理险项目总费用

                int hospDay     = GetDiffDateDays(item.startDate, item.endtDate);
                var nciPayLevel = billInfo.NCIPAYLEVEL;
                var nciPaysCale = billInfo.NCIPAYSCALE;

                // 是否拥有护理资格
                if (isHaveNCI)
                {
                    #region  护理险资格
                    #region 账单数据更新
                    billInfo.SELFPAY          += Convert.ToDecimal(selfPay);
                    billInfo.NCIITEMTOTALCOST += Convert.ToDecimal(nciItemTotalCost);
                    billInfo.HOSPDAY          += hospDay;

                    var nciPayCost = Convert.ToDecimal(hospDay * Convert.ToDecimal(nciPayLevel) * Convert.ToDecimal(nciPaysCale)); // 护理险最多可报销的费用

                    if (Convert.ToDecimal(nciItemTotalCost) <= nciPayCost)
                    {
                        billInfo.NCIPAY         += Convert.ToDecimal(nciItemTotalCost);
                        payedAmount              = Convert.ToDecimal(nciItemTotalCost);
                        billInfo.NCIITEMSELFPAY += Convert.ToDecimal(selfPay);
                    }
                    else
                    {
                        billInfo.NCIPAY         += Convert.ToDecimal(nciPayCost);
                        payedAmount              = Convert.ToDecimal(nciPayCost);
                        billInfo.NCIITEMSELFPAY += Convert.ToDecimal(selfPay + Convert.ToDecimal(nciItemTotalCost) - nciPayCost);
                    }
                    #endregion

                    #region 保存额度信息表 和 额度历史记录表  和 住民账户表
                    #region 保存额度信息表
                    MonthlyPayLimit monthLimit = new MonthlyPayLimit();
                    monthLimit.YEARMONTH    = string.Format("{0}{1}", item.startDate.Year, item.startDate.Month);
                    monthLimit.FEENO        = billInfo.FEENO;
                    monthLimit.RESIDENTSSID = idNo;
                    monthLimit.PAYEDAMOUNT  = payedAmount;
                    monthLimit.NCIPAYLEVEL  = nciPayLevel;
                    monthLimit.NCIPAYSCALE  = nciPaysCale;
                    monthLimit.ORGID        = SecurityHelper.CurrentPrincipal.OrgId;
                    monthLimit.CREATEBY     = SecurityHelper.CurrentPrincipal.UserId.ToString();
                    monthLimit.CREATETIME   = DateTime.Now;
                    int payLimitId = SaveMonthlyPayLimit(monthLimit);
                    #endregion
                    #region 保存额度历史记录表
                    MonthlyPayBillRecord monthBillRecord = new MonthlyPayBillRecord();
                    monthBillRecord.BILLID        = billInfo.BILLID;
                    monthBillRecord.YEARMONTH     = string.Format("{0}{1}", item.startDate.Year, item.startDate.Month);
                    monthBillRecord.FEENO         = billInfo.FEENO;
                    monthBillRecord.PAYEDAMOUNT   = payedAmount;
                    monthBillRecord.COMPSTARTDATE = item.startDate;
                    monthBillRecord.COMPENDDATE   = item.endtDate;
                    monthBillRecord.STATUS        = 0;
                    monthBillRecord.CREATEBY      = SecurityHelper.CurrentPrincipal.UserId.ToString();
                    monthBillRecord.CREATETIME    = DateTime.Now;
                    monthBillRecord.ISDELETE      = false;
                    SaveMonthlyPayBillRecord(monthBillRecord);
                    #endregion
                    #region 更新住民账户信息
                    var banmodel = unitOfWork.GetRepository <LTC_RESIDENTBALANCE>().dbSet.Where(x => x.FEENO == billInfo.FEENO).FirstOrDefault();
                    if (banmodel != null)
                    {
                        banmodel.TOTALCOST   = banmodel.TOTALCOST == null ? 0 : banmodel.TOTALCOST + selfPay + nciItemTotalCost;
                        banmodel.TOTALNCIPAY = banmodel.TOTALNCIPAY == null ? 0 : banmodel.TOTALNCIPAY + payedAmount;
                        unitOfWork.GetRepository <LTC_RESIDENTBALANCE>().Update(banmodel);
                        unitOfWork.Save();
                    }
                    #endregion
                    #endregion
                    #endregion
                }
                else
                {
                    #region 无护理险资格
                    billInfo.SELFPAY          += Convert.ToDecimal(selfPay);
                    billInfo.NCIITEMTOTALCOST += Convert.ToDecimal(nciItemTotalCost);
                    billInfo.NCIPAY           += 0;
                    billInfo.HOSPDAY          += hospDay;
                    billInfo.NCIITEMSELFPAY   += Convert.ToDecimal(selfPay + nciItemTotalCost);
                    var banmodel = unitOfWork.GetRepository <LTC_RESIDENTBALANCE>().dbSet.Where(x => x.FEENO == billInfo.FEENO).FirstOrDefault();
                    if (banmodel != null)
                    {
                        banmodel.TOTALCOST = banmodel.TOTALCOST == null ? 0 : banmodel.TOTALCOST + selfPay + nciItemTotalCost;
                        unitOfWork.GetRepository <LTC_RESIDENTBALANCE>().Update(banmodel);
                        unitOfWork.Save();
                    }
                    #endregion
                }
            }
        }