/// <summary> /// 获得数据列表 /// </summary> public List <SalesInfoModel> GetModelList(string strWhere) { DataSet ds = dal.GetList(strWhere); List <SalesInfoModel> modelList = new List <SalesInfoModel>(); int rowsCount = ds.Tables[0].Rows.Count; if (rowsCount > 0) { SalesInfoModel model; for (int n = 0; n < rowsCount; n++) { model = new SalesInfoModel(); if (ds.Tables[0].Rows[n]["SalesType"].ToString() != "") { model.SalesType = int.Parse(ds.Tables[0].Rows[n]["SalesType"].ToString()); } if (ds.Tables[0].Rows[n]["ProductId"].ToString() != "") { model.ProductId = int.Parse(ds.Tables[0].Rows[n]["ProductId"].ToString()); } if (ds.Tables[0].Rows[n]["RuleType"].ToString() != "") { model.RuleType = int.Parse(ds.Tables[0].Rows[n]["RuleType"].ToString()); } if (ds.Tables[0].Rows[n]["SortValue"].ToString() != "") { model.SortValue = int.Parse(ds.Tables[0].Rows[n]["SortValue"].ToString()); } modelList.Add(model); } } return(modelList); }
/// <summary> /// 对象实体绑定数据 /// </summary> public SalesInfoModel ReaderBind(IDataReader dataReader) { SalesInfoModel model = new SalesInfoModel(); object ojb; ojb = dataReader["SalesType"]; if (ojb != null && ojb != DBNull.Value) { model.SalesType = (int)ojb; } ojb = dataReader["ProductId"]; if (ojb != null && ojb != DBNull.Value) { model.ProductId = (int)ojb; } ojb = dataReader["RuleType"]; if (ojb != null && ojb != DBNull.Value) { model.RuleType = (int)ojb; } ojb = dataReader["SortValue"]; if (ojb != null && ojb != DBNull.Value) { model.SortValue = (int)ojb; } return(model); }
public List <RecommendItemModel> GetHomeRecommendItemList(int postionID, int count) { var recommendItemEntityList = RecommendFacade.QueryRecommendProduct(0, 0, postionID, count, ConstValue.LanguageCode, ConstValue.CompanyCode); List <RecommendItemModel> result = new List <RecommendItemModel>(); ImageSize imageSize = ImageUrlHelper.GetImageSize(ImageType.Middle); foreach (var itemEntity in recommendItemEntityList) { RecommendItemModel itemModel = new RecommendItemModel(); itemModel.ID = itemEntity.SysNo; itemModel.ProductTitle = itemEntity.BriefName; itemModel.PromotionTitle = itemEntity.PromotionTitle; itemModel.Code = itemEntity.ProductID; itemModel.ImageUrl = ProductFacade.BuildProductImage(imageSize, itemEntity.DefaultImage); var priceModel = new SalesInfoModel(); itemModel.Price = priceModel; priceModel.BasicPrice = itemEntity.BasicPrice; priceModel.CurrentPrice = itemEntity.RealPrice; priceModel.CashRebate = itemEntity.CashRebate; priceModel.TariffPrice = itemEntity.TariffPrice; priceModel.FreeEntryTax = itemEntity.TariffPrice <= ConstValue.TariffFreeLimit; decimal realTariffPrice = priceModel.TariffPrice; if (priceModel.FreeEntryTax) { realTariffPrice = 0; } priceModel.TotalPrice = itemEntity.CurrentPrice + itemEntity.CashRebate + realTariffPrice; result.Add(itemModel); } return(result); }
/// <summary> /// ����һ������ /// </summary> public void Add(SalesInfoModel model) { DbCommand dbCommand = dbw.GetStoredProcCommand("UP_pdSalesInfo_ADD"); dbw.AddInParameter(dbCommand, "SalesType", DbType.Byte, model.SalesType); dbw.AddInParameter(dbCommand, "ProductId", DbType.Int32, model.ProductId); dbw.AddInParameter(dbCommand, "RuleType", DbType.Byte, model.RuleType); dbw.AddInParameter(dbCommand, "SortValue", DbType.Int32, model.SortValue); dbw.ExecuteNonQuery(dbCommand); }
/// <summary> /// 更新一条数据 /// </summary> public void Update(SalesInfoModel model) { DbCommand dbCommand = dbw.GetStoredProcCommand("UP_pdSalesInfo_Update"); dbw.AddInParameter(dbCommand, "SalesType", DbType.Byte, model.SalesType); dbw.AddInParameter(dbCommand, "ProductId", DbType.Int32, model.ProductId); dbw.AddInParameter(dbCommand, "RuleType", DbType.Byte, model.RuleType); dbw.AddInParameter(dbCommand, "SortValue", DbType.Int32, model.SortValue); dbw.ExecuteNonQuery(dbCommand); }
/// <summary> /// 得到一个对象实体 /// </summary> public SalesInfoModel GetModel(int SalesType, int ProductId, int RuleType) { DbCommand dbCommand = dbr.GetStoredProcCommand("UP_pdSalesInfo_GetModel"); dbr.AddInParameter(dbCommand, "SalesType", DbType.Byte, SalesType); dbr.AddInParameter(dbCommand, "ProductId", DbType.Int32, ProductId); dbr.AddInParameter(dbCommand, "RuleType", DbType.Byte, RuleType); SalesInfoModel model = null; using (IDataReader dataReader = dbr.ExecuteReader(dbCommand)) { if (dataReader.Read()) { model = ReaderBind(dataReader); } } return(model); }
private RecommendItemModel MapFloorItem(FloorItemProduct itemEntity, ImageSize imageSize) { RecommendItemModel itemModel = new RecommendItemModel(); itemModel.ID = itemEntity.ProductSysNo; itemModel.ProductTitle = itemEntity.ProductTitle; //itemModel.PromotionTitle = itemEntity.PromotionTitle; itemModel.Code = ""; itemModel.ImageUrl = ProductFacade.BuildProductImage(imageSize, itemEntity.DefaultImage); var priceModel = new SalesInfoModel(); itemModel.Price = priceModel; priceModel.BasicPrice = itemEntity.BasicPrice ?? 0m; priceModel.CurrentPrice = itemEntity.ProductPrice ?? 0m; priceModel.CashRebate = itemEntity.CashRebate ?? 0m;; priceModel.TariffPrice = 0; priceModel.TotalPrice = itemEntity.RealPrice ?? 0m; return(itemModel); }
private List <ProductItemModel> TransformResultItemList(PagedResult <ProductSearchResultItem> solrItemList) { List <ProductItemModel> result = new List <ProductItemModel>(); ImageSize imageSizeItemList = Nesoft.ECWeb.MobileService.Models.Product.ImageUrlHelper.GetImageSize(ImageType.Middle); foreach (var item in solrItemList) { ProductItemModel model = new ProductItemModel(); //基本信息 model.ID = item.ProductSysNo; model.Code = item.ProductID; model.ProductTitle = item.ProductDisplayName; model.PromotionTitle = item.PromotionTitle; model.ImageUrl = ProductFacade.BuildProductImage(imageSizeItemList, item.ProductDefaultImage); //价格相关信息 SalesInfoModel salesInfo = new SalesInfoModel(); salesInfo.BasicPrice = item.MarketPrice; salesInfo.CurrentPrice = item.SalesPrice; salesInfo.CashRebate = item.CashRebate; salesInfo.TariffPrice = item.ProductTariffAmt; salesInfo.FreeEntryTax = item.ProductTariffAmt <= ConstValue.TariffFreeLimit; salesInfo.TotalPrice = item.TotalPrice; //赠送积分数量 salesInfo.PresentPoint = item.Point; salesInfo.OnlineQty = item.OnlineQty; salesInfo.IsHaveValidGift = item.IsHaveValidGift; salesInfo.IsCountDown = item.IsCountDown; salesInfo.IsNewProduct = item.IsNewproduct; salesInfo.IsGroupBuyProduct = item.IsGroupBuyProduct; model.SalesInfo = salesInfo; //其它信息 model.ReviewCount = item.ReviewCount; model.ReviewScore = item.ReviewScore; result.Add(model); } return(result); }
public List <RecommendItemModel> MapAdvItem(List <SaleAdvertisementItem> advItemList) { List <RecommendItemModel> result = new List <RecommendItemModel>(); if (advItemList == null) { return(result); } ImageSize imageSize = ImageUrlHelper.GetImageSize(ImageType.Big); foreach (var itemEntity in advItemList) { RecommendItemModel itemModel = new RecommendItemModel(); itemModel.ID = itemEntity.ProductSysNo; itemModel.ProductTitle = itemEntity.ProductTitle; itemModel.Code = itemEntity.ProductCode; itemModel.ImageUrl = ProductFacade.BuildProductImage(imageSize, itemEntity.DefaultImage); var priceModel = new SalesInfoModel(); itemModel.Price = priceModel; priceModel.BasicPrice = itemEntity.MarketPrice; priceModel.CurrentPrice = itemEntity.CurrentPrice; priceModel.CashRebate = itemEntity.CashRebate; priceModel.FreeEntryTax = itemEntity.ProductTariffAmt <= ConstValue.TariffFreeLimit; priceModel.TariffPrice = itemEntity.ProductTariffAmt; decimal realTariffPrice = priceModel.TariffPrice; if (priceModel.FreeEntryTax) { realTariffPrice = 0; } priceModel.TotalPrice = itemEntity.CurrentPrice + itemEntity.CashRebate + realTariffPrice; result.Add(itemModel); } return(result); }
/// <summary> /// 限时抢购列表 /// </summary> /// <param name="pageIndex"></param> /// <param name="pageSize"></param> /// <returns></returns> public QueryResult <CountDownItemModel> GetCountDownList(int pageIndex, int pageSize) { var countDownList = CountDownFacade.GetCountDownList(pageIndex, pageSize); //列表信息 QueryResult <CountDownItemModel> result = new QueryResult <CountDownItemModel>(); result.ResultList = new List <CountDownItemModel>(); ImageSize imageSize = ImageUrlHelper.GetImageSize(ImageType.Middle); var countDownItemList = countDownList.ResultList ?? new List <CountDownInfo>(); foreach (var item in countDownItemList) { CountDownItemModel itemModel = new CountDownItemModel(); itemModel.Code = item.ProductID; itemModel.ID = item.ProductSysNo; itemModel.ImageUrl = ProductFacade.BuildProductImage(imageSize, item.DefaultImage); itemModel.ProductTitle = item.ProductTitle; itemModel.PromotionTitle = item.PromotionTitle; //Asura 添加开始时间 开始 itemModel.StartTime = string.Format("{0:G}", item.StartTime); //Asura 添加开始时间 结束 if (item.StartTime > DateTime.Now) { itemModel.LeftSeconds = (int)(DateTime.Now - item.StartTime).TotalSeconds; } else { if (item.EndTime < DateTime.Now) { itemModel.LeftSeconds = 0; } else { itemModel.LeftSeconds = (int)(item.EndTime - DateTime.Now).TotalSeconds; } } //销售相关信息 var priceModel = new SalesInfoModel(); itemModel.Price = priceModel; decimal realSnapShotTariffPrice = item.SnapShotTariffPrice; if (realSnapShotTariffPrice <= ConstValue.TariffFreeLimit) { realSnapShotTariffPrice = 0; } priceModel.BasicPrice = item.SnapShotCurrentPrice + item.SnapShotCashRebate + realSnapShotTariffPrice; priceModel.CurrentPrice = item.CountDownPrice; priceModel.CashRebate = item.CountDownCashRebate; priceModel.TariffPrice = item.TariffPrice; decimal realTariffPrice = item.TariffPrice; if (item.TariffPrice <= ConstValue.TariffFreeLimit) { realTariffPrice = 0; } priceModel.TotalPrice = item.CountDownPrice + item.CountDownCashRebate + realTariffPrice; priceModel.OnlineQty = item.OnlineQty; result.ResultList.Add(itemModel); } result.ResultList.Sort((x, y) => x.LeftSeconds.CompareTo(y.LeftSeconds)); //result.ResultList.Reverse(); //分页信息 if (countDownList.PageInfo != null) { var pageInfo = new PageInfo(); pageInfo.PageIndex = pageIndex; pageInfo.PageSize = pageSize; pageInfo.TotalCount = countDownList.PageInfo.TotalCount; result.PageInfo = pageInfo; } return(result); }
/// <summary> /// 更新一条数据 /// </summary> public void Update(SalesInfoModel model) { dal.Update(model); }
/// <summary> /// 增加一条数据 /// </summary> public void Add(SalesInfoModel model) { dal.Add(model); }
// GET: /sales/period1/period2 public ActionResult Index(int period1 = 1, int period2 = 12) { DataSet invoiceTable = new DataSet(); DataSet companyTable = new DataSet(); DataSet customerTable = new DataSet(); SalesModel SalesDashboardModel = new SalesModel(); string connectionString = FirstREST.SqlConnection.GetConnectionString(); using (System.Data.SqlClient.SqlConnection connection = new System.Data.SqlClient.SqlConnection(connectionString)) { var query = " "; if (period1 < period2) { query = "Select * From dbo.Invoice where period >= " + period1 + "and period <=" + period2; } else if (period1 == period2) { query = "Select * From dbo.Invoice where period = " + period1; } else { query = "Select * From dbo.Invoice where period <= 12 and period >=" + period1 + "or period >= 1 and period <=" + period2; } using (SqlCommand command = new SqlCommand(query, connection)) { using (SqlDataAdapter adapter = new SqlDataAdapter(command)) { adapter.Fill(invoiceTable, "Invoices"); foreach (DataRow row in invoiceTable.Tables["Invoices"].Rows) { InvoiceModel temp_invoice = new InvoiceModel(); temp_invoice.invoiceNo = row.Field <string>("invoiceNo"); temp_invoice.invoiceStatus = row.Field <string>("invoiceStatus"); temp_invoice.period = row.Field <int>("period"); temp_invoice.invoiceDate = row.Field <DateTime>("invoiceDate"); temp_invoice.invoiceType = row.Field <string>("invoiceType"); temp_invoice.customerID = row.Field <string>("customerID"); temp_invoice.grossTotal = row.Field <double>("grossTotal"); temp_invoice.netTotal = row.Field <double>("netTotal"); temp_invoice.taxTotal = row.Field <double>("taxTotal"); SalesDashboardModel.CompanyInvoices.Add(temp_invoice); } } } using (SqlCommand command = new SqlCommand("Select * from dbo.Customer", connection)) { using (SqlDataAdapter adapter = new SqlDataAdapter(command)) { adapter.Fill(customerTable, "Customers"); foreach (DataRow row in customerTable.Tables["Customers"].Rows) { CustomerModel tempCostumer = new CustomerModel(); tempCostumer.customerAccountId = row.Field <string>("AccountID"); tempCostumer.customerAddr = row.Field <string>("Country"); tempCostumer.customerId = row.Field <string>("CustomerID"); tempCostumer.customerName = row.Field <string>("CustomerName"); tempCostumer.customerTaxId = row.Field <string>("CustomerTaxID"); SalesDashboardModel.CompanyCustomers.Add(tempCostumer); } } } } using (System.Data.SqlClient.SqlConnection connection = new System.Data.SqlClient.SqlConnection(connectionString)) { using (SqlCommand command = new SqlCommand("Select * From dbo.Sales", connection)) { using (SqlDataAdapter adapter = new SqlDataAdapter(command)) { adapter.Fill(invoiceTable, "sales"); SalesInfoModel temp = new SalesInfoModel(); temp.totalInvoiceCredit = invoiceTable.Tables["sales"].Rows[0].Field <double>("InvoicesTotalCredit"); temp.totalInvoiceDebit = invoiceTable.Tables["sales"].Rows[0].Field <double>("InvoicesTotalDebit"); SalesDashboardModel.SalesInfo = temp; } } } using (System.Data.SqlClient.SqlConnection connection = new System.Data.SqlClient.SqlConnection(connectionString)) { using (SqlCommand command = new SqlCommand("Select AVG(GrossTotal) as average From dbo.Invoice", connection)) { using (SqlDataAdapter adapter = new SqlDataAdapter(command)) { adapter.Fill(invoiceTable, "Average"); SalesDashboardModel.averageTransactionPrice = invoiceTable.Tables["Average"].Rows[0].Field <double>("average"); } } } using (System.Data.SqlClient.SqlConnection connection = new System.Data.SqlClient.SqlConnection(connectionString)) { using (SqlCommand command = new SqlCommand("Select SUM(taxTotal) as sum From dbo.Invoice", connection)) { using (SqlDataAdapter adapter = new SqlDataAdapter(command)) { adapter.Fill(invoiceTable, "Sum"); SalesDashboardModel.sumTotalTaxes = invoiceTable.Tables["Sum"].Rows[0].Field <double>("sum"); } } } using (System.Data.SqlClient.SqlConnection connection = new System.Data.SqlClient.SqlConnection(connectionString)) { using (SqlCommand command = new SqlCommand("Select * From dbo.Company", connection)) { using (SqlDataAdapter adapter = new SqlDataAdapter(command)) { adapter.Fill(companyTable, "company"); SaftFileDateModel temp = new SaftFileDateModel(); temp.startDate = companyTable.Tables["company"].Rows[0].Field <DateTime>("StartDate"); temp.endDate = companyTable.Tables["company"].Rows[0].Field <DateTime>("EndDate"); SalesDashboardModel.SaftInfo = temp; } } } return(View(SalesDashboardModel)); }
private QueryResult <GroupBuyBaseModel> MapItemList(QueryResult <GroupBuyingInfo> queryResult) { QueryResult <GroupBuyBaseModel> result = new QueryResult <GroupBuyBaseModel>(); result.ResultList = new List <GroupBuyBaseModel>(); var resultList = queryResult.ResultList ?? new List <GroupBuyingInfo>(); foreach (var item in resultList) { GroupBuyBaseModel itemModel = new GroupBuyBaseModel(); itemModel.GroupBuyingPicUrl = item.GroupBuyingSmallPicUrl; itemModel.GroupBuyingSysNo = item.SysNo; itemModel.GroupBuyingTitle = item.GroupBuyingTitle; itemModel.CurrentSellCount = item.CurrentSellCount; //计算剩余时间 if (item.EndDate <= DateTime.Now) { itemModel.LeftSeconds = 0; } else { itemModel.LeftSeconds = (long)(item.EndDate - DateTime.Now).TotalSeconds; } //计算销售状态 if (itemModel.LeftSeconds == 0) { itemModel.SellStatusStr = "团购结束"; } else if (item.OnlineQty <= 0) { itemModel.SellStatusStr = "已售罄"; } else { itemModel.SellStatusStr = "团购进行中"; } var priceModel = new SalesInfoModel(); itemModel.Price = priceModel; priceModel.CurrentPrice = item.CurrentPrice; priceModel.CashRebate = 0; //海外商品,算税 if (item.GroupBuyingTypeSysNo == 0) { priceModel.TariffPrice = item.TaxRate * item.CurrentPrice; decimal snapShotTariffPrice = item.SnapShotCurrentPrice * item.TaxRate; if (snapShotTariffPrice <= ConstValue.TariffFreeLimit) { snapShotTariffPrice = 0; } priceModel.BasicPrice = item.SnapShotCurrentPrice + item.SnapShotCashRebate + snapShotTariffPrice; } else { priceModel.TariffPrice = 0; priceModel.BasicPrice = item.SnapShotCurrentPrice + item.SnapShotCashRebate; } decimal realTariffPrice = priceModel.TariffPrice; bool isTaxFree = priceModel.TariffPrice <= ConstValue.TariffFreeLimit; if (isTaxFree) { realTariffPrice = 0; } priceModel.TotalPrice = item.CurrentPrice + realTariffPrice; priceModel.FreeEntryTax = isTaxFree; priceModel.OnlineQty = item.OnlineQty; //计算折扣 decimal finalPrice = priceModel.TotalPrice; if (item.MarketPrice == 0) { itemModel.DiscountStr = ""; } else { itemModel.DiscountStr = (finalPrice / item.MarketPrice * 10).ToString("F2") + "折"; } //计算省好多 itemModel.SaveMoney = item.MarketPrice - finalPrice; result.ResultList.Add(itemModel); } //分页信息 if (queryResult.PageInfo != null) { var pageInfo = new PageInfo(); pageInfo.PageIndex = queryResult.PageInfo.PageIndex; pageInfo.PageSize = queryResult.PageInfo.PageSize; pageInfo.TotalCount = queryResult.PageInfo.TotalCount; result.PageInfo = pageInfo; } return(result); }
/// <summary> /// ����ʵ������� /// </summary> public SalesInfoModel ReaderBind(IDataReader dataReader) { SalesInfoModel model=new SalesInfoModel(); object ojb; ojb = dataReader["SalesType"]; if(ojb != null && ojb != DBNull.Value) { model.SalesType=(int)ojb; } ojb = dataReader["ProductId"]; if(ojb != null && ojb != DBNull.Value) { model.ProductId=(int)ojb; } ojb = dataReader["RuleType"]; if(ojb != null && ojb != DBNull.Value) { model.RuleType=(int)ojb; } ojb = dataReader["SortValue"]; if(ojb != null && ojb != DBNull.Value) { model.SortValue=(int)ojb; } return model; }