Пример #1
0
        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);
            }
        }