public ActionResult EditStoreShipFee(int recordId = -1) { StoreShipFeeInfo storeShipFeeInfo = AdminStores.GetStoreShipFeeById(recordId); if (storeShipFeeInfo == null) { return(PromptView("店铺配送费用不存在")); } StoreShipTemplateInfo storeShipTemplateInfo = AdminStores.GetStoreShipTemplateById(storeShipFeeInfo.StoreSTid); if (storeShipTemplateInfo == null) { return(PromptView("店铺配送模板不存在")); } if (storeShipTemplateInfo.StoreId != WorkContext.StoreId) { return(PromptView("不能操作其它店铺的配送模板")); } StoreShipFeeModel model = new StoreShipFeeModel(); model.RegionId = storeShipFeeInfo.RegionId; model.StartValue = storeShipFeeInfo.StartValue; model.StartFee = storeShipFeeInfo.StartFee; model.AddValue = storeShipFeeInfo.AddValue; model.AddFee = storeShipFeeInfo.AddFee; LoadStoreShipFee(model.RegionId); return(View(model)); }
public ActionResult EditStoreShipFee(StoreShipFeeModel model, int recordId = -1) { StoreShipFeeInfo storeShipFeeInfo = AdminStores.GetStoreShipFeeById(recordId); if (storeShipFeeInfo == null) { return(PromptView("店铺配送费用不存在")); } StoreShipTemplateInfo storeShipTemplateInfo = AdminStores.GetStoreShipTemplateById(storeShipFeeInfo.StoreSTid); if (storeShipTemplateInfo == null) { return(PromptView("店铺配送模板不存在")); } if (storeShipTemplateInfo.StoreId != WorkContext.StoreId) { return(PromptView("不能操作其它店铺的配送模板")); } if (ModelState.IsValid) { storeShipFeeInfo.RegionId = model.RegionId; storeShipFeeInfo.StartValue = model.StartValue; storeShipFeeInfo.StartFee = model.StartFee; storeShipFeeInfo.AddValue = model.AddValue; storeShipFeeInfo.AddFee = model.AddFee; AdminStores.UpdateStoreShipFee(storeShipFeeInfo); AddStoreAdminLog("修改店铺配送费用", "修改店铺配送费用,店铺配送费用ID为:" + recordId); return(PromptView("店铺配送费用修改成功")); } LoadStoreShipFee(model.RegionId); return(View(model)); }
public ActionResult AddStoreShipFee(StoreShipFeeModel model, int storeSTid = -1) { StoreShipTemplateInfo storeShipTemplateInfo = AdminStores.GetStoreShipTemplateById(storeSTid); if (storeShipTemplateInfo == null) { return(PromptView("店铺配送模板不存在")); } if (storeShipTemplateInfo.StoreId != WorkContext.StoreId) { return(PromptView("不能操作其它店铺的配送模板")); } if (ModelState.IsValid) { StoreShipFeeInfo storeShipFeeInfo = new StoreShipFeeInfo() { StoreSTid = storeSTid, RegionId = model.RegionId, StartValue = model.StartValue, StartFee = model.StartFee, AddValue = model.AddValue, AddFee = model.AddFee }; AdminStores.CreateStoreShipFee(storeShipFeeInfo); AddStoreAdminLog("添加店铺配送费用", "添加店铺配送费用"); return(PromptView("店铺配送费用添加成功")); } LoadStoreShipFee(model.RegionId); return(View(model)); }
/// <summary> /// 删除店铺配送费用 /// </summary> public ActionResult DelStoreShipFee(int recordId = -1) { StoreShipFeeInfo storeShipFeeInfo = AdminStores.GetStoreShipFeeById(recordId); if (storeShipFeeInfo == null) { return(PromptView("店铺配送费用不存在")); } StoreShipTemplateInfo storeShipTemplateInfo = AdminStores.GetStoreShipTemplateById(storeShipFeeInfo.StoreSTid); if (storeShipTemplateInfo == null) { return(PromptView("店铺配送模板不存在")); } if (storeShipTemplateInfo.StoreId != WorkContext.StoreId) { return(PromptView("不能操作其它店铺的配送模板")); } if (storeShipFeeInfo.RegionId == -1) { return(PromptView("默认店铺配送费用不能删除")); } AdminStores.DeleteStoreShipFeeById(recordId); AddStoreAdminLog("删除店铺配送费用", "删除店铺配送费用,店铺配送费用ID为:" + recordId); return(PromptView("店铺配送费用删除成功")); }
/// <summary> /// 获得配送费用 /// </summary> /// <param name="provinceId">省id</param> /// <param name="cityId">市id</param> /// <param name="orderProductList">订单商品列表</param> /// <returns></returns> public static int GetShipFee(int provinceId, int cityId, List<OrderProductInfo> orderProductList) { List<int> storeSTidList = new List<int>(orderProductList.Count); foreach (OrderProductInfo orderProductInfo in orderProductList) { storeSTidList.Add(orderProductInfo.StoreSTid); } storeSTidList = storeSTidList.Distinct<int>().ToList<int>(); int shipFee = 0; foreach (int storeSTId in storeSTidList) { StoreShipTemplateInfo storeShipTemplateInfo = Stores.GetStoreShipTemplateById(storeSTId); if (storeShipTemplateInfo.Free == 0)//不免运费 { StoreShipFeeInfo storeShipFeeInfo = Stores.GetStoreShipFeeByStoreSTidAndRegion(storeSTId, provinceId, cityId); List<OrderProductInfo> list = Carts.GetSameShipOrderProductList(storeSTId, orderProductList); if (storeShipTemplateInfo.Type == 0)//按件数计算运费 { int totalCount = Carts.SumOrderProductCount(orderProductList); if (totalCount <= storeShipFeeInfo.StartValue)//没有超过起步价时 { shipFee += storeShipFeeInfo.StartFee; } else//超过起步价时 { int temp = 0; if ((totalCount - storeShipFeeInfo.StartValue) % storeShipFeeInfo.AddValue == 0) temp = (totalCount - storeShipFeeInfo.StartValue) / storeShipFeeInfo.AddValue; else temp = (totalCount - storeShipFeeInfo.StartValue) / storeShipFeeInfo.AddValue + 1; shipFee += storeShipFeeInfo.StartFee + temp * storeShipFeeInfo.AddFee; } } else//按重量计算运费 { int totalWeight = Carts.SumOrderProductWeight(orderProductList); if (totalWeight <= storeShipFeeInfo.StartValue * 1000)//没有超过起步价时 { shipFee += storeShipFeeInfo.StartFee; } else//超过起步价时 { int temp = 0; if ((totalWeight - storeShipFeeInfo.StartValue * 1000) % (storeShipFeeInfo.AddValue * 1000) == 0) temp = (totalWeight - storeShipFeeInfo.StartValue * 1000) / (storeShipFeeInfo.AddValue * 1000); else temp = (totalWeight - storeShipFeeInfo.StartValue * 1000) / (storeShipFeeInfo.AddValue * 1000) + 1; shipFee += storeShipFeeInfo.StartFee + temp * storeShipFeeInfo.AddFee; } } } } return shipFee; }
/// <summary> /// 获得店铺配送费用 /// </summary> /// <param name="recordId">记录id</param> /// <returns></returns> public static StoreShipFeeInfo GetStoreShipFeeById(int recordId) { StoreShipFeeInfo storeShipFeeInfo = null; IDataReader reader = BrnMall.Core.BMAData.RDBS.GetStoreShipFeeById(recordId); if (reader.Read()) { storeShipFeeInfo = BuildStoreShipFeeFromReader(reader); } reader.Close(); return(storeShipFeeInfo); }
/// <summary> /// 获得店铺配送费用 /// </summary> /// <param name="storeSTid">店铺模板id</param> /// <param name="provinceId">省id</param> /// <param name="cityId">市id</param> /// <returns></returns> public static StoreShipFeeInfo GetStoreShipFeeByStoreSTidAndRegion(int storeSTid, int provinceId, int cityId) { StoreShipFeeInfo storeShipFeeInfo = null; IDataReader reader = BrnMall.Core.BMAData.RDBS.GetStoreShipFeeByStoreSTidAndRegion(storeSTid, provinceId, cityId); if (reader.Read()) { storeShipFeeInfo = BuildStoreShipFeeFromReader(reader); } reader.Close(); return(storeShipFeeInfo); }
/// <summary> /// 从IDataReader创建StoreShipFeeInfo /// </summary> public static StoreShipFeeInfo BuildStoreShipFeeFromReader(IDataReader reader) { StoreShipFeeInfo storeShipFeeInfo = new StoreShipFeeInfo(); storeShipFeeInfo.RecordId = TypeHelper.ObjectToInt(reader["recordid"]); storeShipFeeInfo.StoreSTid = TypeHelper.ObjectToInt(reader["storestid"]); storeShipFeeInfo.RegionId = TypeHelper.ObjectToInt(reader["regionid"]); storeShipFeeInfo.StartValue = TypeHelper.ObjectToInt(reader["startvalue"]); storeShipFeeInfo.StartFee = TypeHelper.ObjectToInt(reader["startfee"]); storeShipFeeInfo.AddValue = TypeHelper.ObjectToInt(reader["addvalue"]); storeShipFeeInfo.AddFee = TypeHelper.ObjectToInt(reader["addfee"]); return(storeShipFeeInfo); }
/// <summary> /// 创建店铺配送费用 /// </summary> /// <param name="storeShipFeeInfo">店铺配送费用信息</param> public void CreateStoreShipFee(StoreShipFeeInfo storeShipFeeInfo) { DbParameter[] parms = { GenerateInParam("@storestid", SqlDbType.Int, 4, storeShipFeeInfo.StoreSTid), GenerateInParam("@regionid", SqlDbType.Int, 4, storeShipFeeInfo.RegionId), GenerateInParam("@startvalue", SqlDbType.Int, 4, storeShipFeeInfo.StartValue), GenerateInParam("@startfee", SqlDbType.Int, 4, storeShipFeeInfo.StartFee), GenerateInParam("@addvalue", SqlDbType.Int, 4, storeShipFeeInfo.AddValue), GenerateInParam("@addfee", SqlDbType.Int, 4, storeShipFeeInfo.AddFee) }; string commandText = string.Format("INSERT INTO [{0}storeshipfees]([storestid],[regionid],[startvalue],[startfee],[addvalue],[addfee]) VALUES(@storestid,@regionid,@startvalue,@startfee,@addvalue,@addfee)", RDBSHelper.RDBSTablePre); RDBSHelper.ExecuteNonQuery(CommandType.Text, commandText, parms); }
/// <summary> /// 更新店铺配送费用 /// </summary> /// <param name="storeShipFeeInfo">店铺配送费用信息</param> public void UpdateStoreShipFee(StoreShipFeeInfo storeShipFeeInfo) { DbParameter[] parms = { GenerateInParam("@storestid", SqlDbType.Int, 4, storeShipFeeInfo.StoreSTid), GenerateInParam("@regionid", SqlDbType.Int, 4, storeShipFeeInfo.RegionId), GenerateInParam("@startvalue", SqlDbType.Int, 4, storeShipFeeInfo.StartValue), GenerateInParam("@startfee", SqlDbType.Int, 4, storeShipFeeInfo.StartFee), GenerateInParam("@addvalue", SqlDbType.Int, 4, storeShipFeeInfo.AddValue), GenerateInParam("@addfee", SqlDbType.Int, 4, storeShipFeeInfo.AddFee), GenerateInParam("@recordid", SqlDbType.Int, 4, storeShipFeeInfo.RecordId) }; string commandText = string.Format("UPDATE [{0}storeshipfees] SET [storestid]=@storestid,[regionid]=@regionid,[startvalue]=@startvalue,[startfee]=@startfee,[addvalue]=@addvalue,[addfee]=@addfee WHERE [recordid]=@recordid", RDBSHelper.RDBSTablePre); RDBSHelper.ExecuteNonQuery(CommandType.Text, commandText, parms); }
/// <summary> /// 删除店铺配送费用 /// </summary> public ActionResult DelStoreShipFee(int recordId = -1) { StoreShipFeeInfo storeShipFeeInfo = AdminStores.GetStoreShipFeeById(recordId); if (storeShipFeeInfo == null) { return(PromptView("店铺配送费用不存在")); } if (storeShipFeeInfo.RegionId == -1) { return(PromptView("默认店铺配送费用不能删除")); } AdminStores.DeleteStoreShipFeeById(recordId); AddMallAdminLog("删除店铺配送费用", "删除店铺配送费用,店铺配送费用ID为:" + recordId); return(PromptView("店铺配送费用删除成功")); }
public ActionResult AddStoreShipTemplate(AddStoreShipTemplateModel model, int storeId = -1) { StoreInfo storeInfo = AdminStores.GetStoreById(storeId); if (storeInfo == null) { return(PromptView("店铺不存在")); } if (ModelState.IsValid) { StoreShipTemplateInfo storeShipTemplateInfo = new StoreShipTemplateInfo() { StoreId = storeId, Title = model.TemplateTitle, Free = model.Free, Type = model.Type }; int storeSTid = AdminStores.CreateStoreShipTemplate(storeShipTemplateInfo); if (storeSTid > 0) { StoreShipFeeInfo storeShipFeeInfo = new StoreShipFeeInfo() { StoreSTid = storeSTid, RegionId = -1, StartValue = model.StartValue, StartFee = model.StartFee, AddValue = model.AddValue, AddFee = model.AddFee }; AdminStores.CreateStoreShipFee(storeShipFeeInfo); AddMallAdminLog("添加店铺配送模板", "添加店铺配送模板,店铺配送模板为:" + model.TemplateTitle); return(PromptView("店铺配送模板添加成功")); } else { return(PromptView("店铺配送模板添加失败")); } } ViewData["referer"] = MallUtils.GetMallAdminRefererCookie(); return(View(model)); }
public ActionResult EditStoreShipFee(int recordId = -1) { StoreShipFeeInfo storeShipFeeInfo = AdminStores.GetStoreShipFeeById(recordId); if (storeShipFeeInfo == null) { return(PromptView("店铺配送费用不存在")); } StoreShipFeeModel model = new StoreShipFeeModel(); model.RegionId = storeShipFeeInfo.RegionId; model.StartValue = storeShipFeeInfo.StartValue; model.StartFee = storeShipFeeInfo.StartFee; model.AddValue = storeShipFeeInfo.AddValue; model.AddFee = storeShipFeeInfo.AddFee; LoadStoreShipFee(model.RegionId); return(View(model)); }
/// <summary> /// 更新店铺配送费用 /// </summary> /// <param name="storeShipFeeInfo">店铺配送费用信息</param> public static void UpdateStoreShipFee(StoreShipFeeInfo storeShipFeeInfo) { NStore.Data.Stores.UpdateStoreShipFee(storeShipFeeInfo); }
/// <summary> /// 创建店铺配送费用 /// </summary> /// <param name="storeShipFeeInfo">店铺配送费用信息</param> public static void CreateStoreShipFee(StoreShipFeeInfo storeShipFeeInfo) { BrnMall.Data.Stores.CreateStoreShipFee(storeShipFeeInfo); }
/// <summary> /// 创建店铺配送费用 /// </summary> /// <param name="storeShipFeeInfo">店铺配送费用信息</param> public static void CreateStoreShipFee(StoreShipFeeInfo storeShipFeeInfo) { NStore.Core.BMAData.RDBS.CreateStoreShipFee(storeShipFeeInfo); }
/// <summary> /// 更新店铺配送费用 /// </summary> /// <param name="storeShipFeeInfo">店铺配送费用信息</param> public static void UpdateStoreShipFee(StoreShipFeeInfo storeShipFeeInfo) { BrnMall.Core.BMAData.RDBS.UpdateStoreShipFee(storeShipFeeInfo); }