public ServiceResponseData PromFeeCaculate() { try { int costPatTypeid = requestData.GetData <int>(0); int memberAccountID = requestData.GetData <int>(1); decimal totalFee = requestData.GetData <decimal>(2); List <Prescription> prescriptions = requestData.GetData <List <Prescription> >(3); int operatoreID = requestData.GetData <int>(4); int costHeadid = requestData.GetData <int>(5); #region 构造明细表 DataTable dtDetail = new DataTable(); DataColumn col = new DataColumn(); col.ColumnName = "ItemTypeID"; col.DataType = typeof(decimal); dtDetail.Columns.Add(col); col = new DataColumn(); col.ColumnName = "PresDetailId"; col.DataType = typeof(int); dtDetail.Columns.Add(col); col = new DataColumn(); col.ColumnName = "ItemAmount"; col.DataType = typeof(decimal); dtDetail.Columns.Add(col); col = new DataColumn(); col.ColumnName = "PromAmount"; col.DataType = typeof(decimal); dtDetail.Columns.Add(col); foreach (Prescription presc in prescriptions) { DataRow dr = dtDetail.NewRow(); dr["ItemTypeID"] = presc.ItemID; dr["PresDetailId"] = presc.PresDetailID; dr["ItemAmount"] = presc.TotalFee; dr["PromAmount"] = 0; dtDetail.Rows.Add(dr); } #endregion #region 构造分类表 var result = from p in prescriptions.AsEnumerable() group p by p.StatID into g select new { g.Key, SumValue = g.Sum(p => p.TotalFee) }; DataTable dtPromClass = new DataTable(); col = new DataColumn(); col.ColumnName = "ClassTypeID"; col.DataType = typeof(string); dtPromClass.Columns.Add(col); col = new DataColumn(); col.ColumnName = "ClassAmount"; col.DataType = typeof(decimal); dtPromClass.Columns.Add(col); col = new DataColumn(); col.ColumnName = "PromAmount"; col.DataType = typeof(decimal); dtPromClass.Columns.Add(col); foreach (var stat in result) { DataRow dr = dtPromClass.NewRow(); dr["ClassTypeID"] = stat.Key; dr["ClassAmount"] = stat.SumValue; dr["PromAmount"] = 0; dtPromClass.Rows.Add(dr); } #endregion DataTable outdtPromClass = new DataTable(); DataTable outDetail = new DataTable(); PromotionManagement promManager = NewObject <PromotionManagement>(); DiscountInfo discountinfo = new DiscountInfo(); discountinfo.AccountID = memberAccountID; discountinfo.CostType = costPatTypeid; discountinfo.PatientType = 1; discountinfo.Amount = totalFee; discountinfo.OperateID = operatoreID; discountinfo.SettlementNO = costHeadid.ToString(); discountinfo.DtDetail = dtDetail; discountinfo.DtClass = dtPromClass; discountinfo.IsSave = true; discountinfo.AccID = costHeadid;//结算ID DiscountInfo resDiscountInfo = promManager.CalculationPromotion(discountinfo); responseData.AddData(resDiscountInfo.DisAmount); return(responseData); } catch (Exception err) { throw new Exception(err.Message); } }
/// <summary> /// 保存优惠明细 /// </summary> /// <param name="costPatTypeid">病人类型ID</param> /// <param name="memberAccountID">会员账户ID</param> /// <param name="totalFee">总金额</param> /// <param name="prescriptions">处方对象</param> /// <param name="operatoreID">操作员ID</param> /// <param name="costHeadid">结算ID</param> public void SavePromData(int costPatTypeid, int memberAccountID, decimal totalFee, List <Prescription> prescriptions, int operatoreID, int costHeadid) { //#region 构造明细表 //DataTable dtDetail = new DataTable(); //DataColumn col = new DataColumn(); //col.ColumnName = "ItemTypeID"; //col.DataType = typeof(System.Decimal); //dtDetail.Columns.Add(col); //col = new DataColumn(); //col.ColumnName = "PresDetailId"; //col.DataType = typeof(System.Int32); //dtDetail.Columns.Add(col); //col = new DataColumn(); //col.ColumnName = "ItemAmount"; //col.DataType = typeof(System.Decimal); //dtDetail.Columns.Add(col); //col = new DataColumn(); //col.ColumnName = "PromAmount"; //col.DataType = typeof(System.Decimal); //dtDetail.Columns.Add(col); //foreach (Prescription presc in prescriptions) //{ // DataRow dr = dtDetail.NewRow(); // dr["ItemTypeID"] = presc.ItemID; // dr["PresDetailId"] = presc.PresDetailID; // dr["ItemAmount"] = presc.TotalFee; // dr["PromAmount"] = 0; // dtDetail.Rows.Add(dr); //} //#endregion //#region 构造分类表 //var result = from p in prescriptions.AsEnumerable() // group p by p.StatID into g // select new // { // g.Key, // SumValue = g.Sum(p => p.TotalFee) // }; //DataTable dtPromClass = new DataTable(); //col = new DataColumn(); //col.ColumnName = "ClassTypeID"; //col.DataType = typeof(System.String); //dtPromClass.Columns.Add(col); //col = new DataColumn(); //col.ColumnName = "ClassAmount"; //col.DataType = typeof(System.Decimal); //dtPromClass.Columns.Add(col); //col = new DataColumn(); //col.ColumnName = "PromAmount"; //col.DataType = typeof(System.Decimal); //dtPromClass.Columns.Add(col); //foreach (var stat in result) //{ // DataRow dr = dtPromClass.NewRow(); // dr["ClassTypeID"] = stat.Key; // dr["ClassAmount"] = stat.SumValue; // dr["PromAmount"] = 0; // dtPromClass.Rows.Add(dr); //} //#endregion //DataTable outdtPromClass = new DataTable(); //DataTable outDetail = new DataTable(); //PromotionManagement promManager = NewObject<PromotionManagement>(); //DiscountInfo discountinfo = new DiscountInfo(); //discountinfo.AccountID = memberAccountID; //discountinfo.CostType = costPatTypeid; //discountinfo.PatientType = 1; //discountinfo.Amount = totalFee; //discountinfo.OperateID = operatoreID; //discountinfo.SettlementNO = costHeadid.ToString(); //discountinfo.DtDetail = dtDetail; //discountinfo.DtClass = dtPromClass; //discountinfo.IsSave = true; //promManager.CalculationPromotion(discountinfo); PromotionManagement promManager = NewObject <PromotionManagement>(); promManager.UpdateDiscountInfo(costHeadid, costHeadid); }