/// <summary> /// 更新一条数据 /// </summary> public void Update(Lebi_Transport model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update [Lebi_Transport] set "); strSql.Append("Name= @Name,"); strSql.Append("Description= @Description,"); strSql.Append("Code= @Code,"); strSql.Append("IsCanofflinePay= @IsCanofflinePay,"); strSql.Append("Sort= @Sort,"); strSql.Append("Type_id_TransportType= @Type_id_TransportType"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4), new SqlParameter("@Name", SqlDbType.NVarChar, 50), new SqlParameter("@Description", SqlDbType.NVarChar, 2000), new SqlParameter("@Code", SqlDbType.NVarChar, 50), new SqlParameter("@IsCanofflinePay", SqlDbType.Int, 4), new SqlParameter("@Sort", SqlDbType.Int, 4), new SqlParameter("@Type_id_TransportType", SqlDbType.Int, 4) }; parameters[0].Value = model.id; parameters[1].Value = model.Name; parameters[2].Value = model.Description; parameters[3].Value = model.Code; parameters[4].Value = model.IsCanofflinePay; parameters[5].Value = model.Sort; parameters[6].Value = model.Type_id_TransportType; SqlUtils.SqlUtilsInstance.TextExecuteNonQuery(strSql.ToString(), parameters); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Lebi_Transport model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into [Lebi_Transport]("); strSql.Append("Name,Description,Code,IsCanofflinePay,Sort,Type_id_TransportType)"); strSql.Append(" values ("); strSql.Append("@Name,@Description,@Code,@IsCanofflinePay,@Sort,@Type_id_TransportType)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@Name", model.Name), new SqlParameter("@Description", model.Description), new SqlParameter("@Code", model.Code), new SqlParameter("@IsCanofflinePay", model.IsCanofflinePay), new SqlParameter("@Sort", model.Sort), new SqlParameter("@Type_id_TransportType", model.Type_id_TransportType) }; object obj = SqlUtils.SqlUtilsInstance.TextExecuteNonQuery(strSql.ToString(), parameters); if (obj == null) { return(1); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 安全方式绑定对象表单 /// </summary> public Lebi_Transport SafeBindForm(Lebi_Transport model) { if (HttpContext.Current.Request["Name"] != null) { model.Name = Shop.Tools.RequestTool.RequestSafeString("Name"); } if (HttpContext.Current.Request["Description"] != null) { model.Description = Shop.Tools.RequestTool.RequestSafeString("Description"); } if (HttpContext.Current.Request["Code"] != null) { model.Code = Shop.Tools.RequestTool.RequestSafeString("Code"); } if (HttpContext.Current.Request["IsCanofflinePay"] != null) { model.IsCanofflinePay = Shop.Tools.RequestTool.RequestInt("IsCanofflinePay", 0); } if (HttpContext.Current.Request["Sort"] != null) { model.Sort = Shop.Tools.RequestTool.RequestInt("Sort", 0); } if (HttpContext.Current.Request["Type_id_TransportType"] != null) { model.Type_id_TransportType = Shop.Tools.RequestTool.RequestInt("Type_id_TransportType", 0); } return(model); }
/// <summary> /// 对象实体绑定数据 /// </summary> public Lebi_Transport ReaderBind(IDataReader dataReader) { Lebi_Transport model = new Lebi_Transport(); object ojb; ojb = dataReader["id"]; if (ojb != null && ojb != DBNull.Value) { model.id = (int)ojb; } model.Name = dataReader["Name"].ToString(); model.Description = dataReader["Description"].ToString(); model.Code = dataReader["Code"].ToString(); ojb = dataReader["IsCanofflinePay"]; if (ojb != null && ojb != DBNull.Value) { model.IsCanofflinePay = (int)ojb; } ojb = dataReader["Sort"]; if (ojb != null && ojb != DBNull.Value) { model.Sort = (int)ojb; } ojb = dataReader["Type_id_TransportType"]; if (ojb != null && ojb != DBNull.Value) { model.Type_id_TransportType = (int)ojb; } return(model); }
protected void Page_Load(object sender, EventArgs e) { int id = RequestTool.RequestInt("id", 0); if (id == 0) { if (!EX_Admin.Power("transport_add", "添加配送方式")) { WindowNoPower(); } } else { if (!EX_Admin.Power("transport_edit", "编辑配送方式")) { WindowNoPower(); } } model = B_Lebi_Transport.GetModel(id); if (model == null) { model = new Lebi_Transport(); model.Type_id_TransportType = 330; } }
protected void Page_Load(object sender, EventArgs e) { if (!EX_Admin.Power("transport_price_list", "配送区域列表")) { PageReturnMsg = PageNoPowerMsg(); } PageSize = RequestTool.getpageSize(25); OfflinePay = RequestTool.RequestInt("OfflinePay", 2); OnePrice = RequestTool.RequestInt("OnePrice", 2); OfflinePay = OfflinePay > 2 ? 2 : OfflinePay; OnePrice = OnePrice > 2 ? 2 : OnePrice; int tid = RequestTool.RequestInt("tid", 0); tmodel = B_Lebi_Transport.GetModel(tid); string where = "Supplier_id=0 and Transport_id=" + tmodel.id; //if (pid > 0) // where += " and Parentid="+pid; if (OnePrice == 0 || OnePrice == 1) { where += " and IsOnePrice=" + OnePrice; } if (OfflinePay == 0 || OfflinePay == 1) { where += " and IsCanofflinePay=" + OfflinePay; } models = B_Lebi_Transport_Price.GetList(where, "id asc", PageSize, page); int recordCount = B_Lebi_Transport_Price.Counts(where); PageString = Pager.GetPaginationString("?page={0}&tid=" + tid + "&OnePrice=" + OnePrice + "&OfflinePay=" + OfflinePay, page, PageSize, recordCount); }
public Lebi_Transport GetName(int transport_id) { Lebi_Transport transport = B_Lebi_Transport.GetModel(transport_id); if (transport == null) { transport = new Lebi_Transport(); } return(transport); }
protected int sid = 0;//结算供应商ID public void LoadPage() { if (CurrentUser.User_Address_id == 0) { //未设置收货地区的话,不显示内容 Response.Write(""); Response.End(); return; } address = B_Lebi_User_Address.GetModel(CurrentUser.User_Address_id); if (address == null) { //未设置收获地区的话,不显示内容 Response.Write(""); Response.End(); return; } CurrentUser.Transport_Price_id = CurrentUser.Transport_Price_id == "" ? "0" : CurrentUser.Transport_Price_id; if (TPrice == null) { TPrice = new Lebi_Transport_Price(); } if (Transport == null) { Transport = new Lebi_Transport(); } sid = RequestTool.RequestInt("sid", 0); basket = new Basket(sid); Shops = new List <BasketShop>(); if (basket.IsMutiCash) { foreach (Shop.Model.BasketShop shop in basket.Shops) { if (shop.Shop.id == basket.cashsupplierid) { Shops.Add(shop); } } } else { Shops = basket.Shops; } //检查运输方式是否设置正确 foreach (Shop.Model.BasketShop shop in Shops) { Lebi_Transport st = GetTransport(shop.Shop.id); if (st.id == 0) { havedefault = false; } } }
/// <summary> /// 编辑配送区域价格 /// </summary> public void Transport_Price_Edit() { if (!Power("supplier_transport_list", "配送方式")) { AjaxNoPower(); return; } int id = RequestTool.RequestInt("id", 0); int tid = RequestTool.RequestInt("tid", 0); Lebi_Transport tmodel = B_Lebi_Transport.GetModel(tid); Lebi_Transport_Price model = B_Lebi_Transport_Price.GetModel("id = " + id + " and Supplier_id = " + CurrentSupplier.id + ""); if (model != null) { int Area_id = model.Area_id; B_Lebi_Transport_Price.SafeBindForm(model); model.Transport_id = tmodel.id; model.Area_id = Area_id; B_Lebi_Transport_Price.Update(model); Log.Add("编辑配送区域", "Transport_Price", id.ToString(), CurrentSupplier, tmodel.Name); } else { string aids = RequestTool.RequestString("Area_ids"); if (aids == "") { aids = "0"; } List <Lebi_Area> areas = B_Lebi_Area.GetList("id in (lbsql{" + aids + "})", ""); model = new Lebi_Transport_Price(); foreach (Lebi_Area area in areas) { //避免重复添加 int count = B_Lebi_Transport_Price.Counts("Transport_id=" + tmodel.id + " and Area_id=" + area.id + " and Supplier_id = " + CurrentSupplier.id + ""); if (count > 0) { continue; } B_Lebi_Transport_Price.SafeBindForm(model); model.Area_id = area.id; model.Transport_id = tmodel.id; model.Supplier_id = CurrentSupplier.id; B_Lebi_Transport_Price.Add(model); } Log.Add("添加配送区域", "Transport_Price", id.ToString(), CurrentSupplier, tmodel.Name); } Response.Write("{\"msg\":\"OK\"}"); }
/// <summary> /// 获得当前运输方式 /// </summary> /// <param name="shopid"></param> /// <returns></returns> public Lebi_Transport GetTransport(int shopid) { Lebi_Transport_Price price = B_Lebi_Transport_Price.GetModel("id in (" + CurrentUser.Transport_Price_id + ") and Supplier_id=" + shopid + ""); if (price == null) { return(new Lebi_Transport()); } Lebi_Transport model = B_Lebi_Transport.GetModel(price.Transport_id); if (model == null) { model = new Lebi_Transport(); } return(model); }
/// <summary> /// 得到一个对象实体 by id /// </summary> public Lebi_Transport GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 * from [Lebi_Transport] "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; Lebi_Transport model = new Lebi_Transport(); DataSet ds = SqlUtils.SqlUtilsInstance.TextExecuteDataset(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["id"].ToString() != "") { model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString()); } model.Name = ds.Tables[0].Rows[0]["Name"].ToString(); model.Description = ds.Tables[0].Rows[0]["Description"].ToString(); model.Code = ds.Tables[0].Rows[0]["Code"].ToString(); if (ds.Tables[0].Rows[0]["IsCanofflinePay"].ToString() != "") { model.IsCanofflinePay = int.Parse(ds.Tables[0].Rows[0]["IsCanofflinePay"].ToString()); } if (ds.Tables[0].Rows[0]["Sort"].ToString() != "") { model.Sort = int.Parse(ds.Tables[0].Rows[0]["Sort"].ToString()); } if (ds.Tables[0].Rows[0]["Type_id_TransportType"].ToString() != "") { model.Type_id_TransportType = int.Parse(ds.Tables[0].Rows[0]["Type_id_TransportType"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 得到一个对象实体 by where条件 /// </summary> public Lebi_Transport GetModel(string strWhere) { if (strWhere.IndexOf("lbsql{") > 0) { SQLPara para = new SQLPara(strWhere, "", ""); return(GetModel(para)); } StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 * from [Lebi_Transport] "); strSql.Append(" where " + strWhere + ""); Lebi_Transport model = new Lebi_Transport(); DataSet ds = SqlUtils.SqlUtilsInstance.TextExecuteDataset(strSql.ToString()); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["id"].ToString() != "") { model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString()); } model.Name = ds.Tables[0].Rows[0]["Name"].ToString(); model.Description = ds.Tables[0].Rows[0]["Description"].ToString(); model.Code = ds.Tables[0].Rows[0]["Code"].ToString(); if (ds.Tables[0].Rows[0]["IsCanofflinePay"].ToString() != "") { model.IsCanofflinePay = int.Parse(ds.Tables[0].Rows[0]["IsCanofflinePay"].ToString()); } if (ds.Tables[0].Rows[0]["Sort"].ToString() != "") { model.Sort = int.Parse(ds.Tables[0].Rows[0]["Sort"].ToString()); } if (ds.Tables[0].Rows[0]["Type_id_TransportType"].ToString() != "") { model.Type_id_TransportType = int.Parse(ds.Tables[0].Rows[0]["Type_id_TransportType"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Lebi_Transport model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into [Lebi_Transport]("); strSql.Append("[Name],[Description],[Code],[IsCanofflinePay],[Sort],[Type_id_TransportType])"); strSql.Append(" values ("); strSql.Append("@Name,@Description,@Code,@IsCanofflinePay,@Sort,@Type_id_TransportType)"); OleDbParameter[] parameters = { new OleDbParameter("@Name", model.Name), new OleDbParameter("@Description", model.Description), new OleDbParameter("@Code", model.Code), new OleDbParameter("@IsCanofflinePay", model.IsCanofflinePay), new OleDbParameter("@Sort", model.Sort), new OleDbParameter("@Type_id_TransportType", model.Type_id_TransportType) }; AccessUtils.Instance.TextExecuteNonQuery(strSql.ToString(), parameters); return(1); }
/// <summary> /// 根据配送地区取出运输公司并计算相应运费 /// </summary> public static List <Lebi_Transport_Price> TransportPrices_Get(int area_id, int supplierid) { Lebi_Area area = B_Lebi_Area.GetModel(area_id); if (area == null) { return(new List <Lebi_Transport_Price>()); } List <Lebi_Transport_Price> trans = null;//配送地区含当前地区的运输公司以及价格 trans = TransportPrice(area, trans, supplierid); foreach (Lebi_Transport_Price p in trans) { Lebi_Transport t = B_Lebi_Transport.GetModel(p.Transport_id); if (t != null) { p.Sort = t.Sort; } } trans = trans.OrderByDescending(a => a.Sort).ToList(); return(trans); }
/// <summary> /// 批量更新配送区域价格 /// </summary> public void Transport_Price_Update() { if (!Power("supplier_transport_list", "配送方式")) { AjaxNoPower(); return; } int tid = RequestTool.RequestInt("tid", 0); string id = RequestTool.RequestSafeString("Uid"); Lebi_Transport tmodel = B_Lebi_Transport.GetModel(tid); List <Lebi_Transport_Price> models = B_Lebi_Transport_Price.GetList("id in (lbsql{" + id + "}) and Transport_id=" + tid + " and Supplier_id = " + CurrentSupplier.id + "", ""); foreach (Lebi_Transport_Price model in models) { model.Price = RequestTool.GetFormDecimal("Price" + model.id + "", 0); model.Weight_Start = RequestTool.GetFormDecimal("Weight_Start" + model.id + "", 0); model.Weight_Step = RequestTool.GetFormDecimal("Weight_Step" + model.id + "", 0); model.Price_Step = RequestTool.GetFormDecimal("Price_Step" + model.id + "", 0); B_Lebi_Transport_Price.Update(model); } Log.Add("编辑配送区域", "Transport_Price", id.ToString(), CurrentSupplier, tmodel.Name); Response.Write("{\"msg\":\"OK\"}"); }
/// <summary> /// 更新一条数据 /// </summary> public void Update(Lebi_Transport model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update [Lebi_Transport] set "); strSql.Append("[Name]=@Name,"); strSql.Append("[Description]=@Description,"); strSql.Append("[Code]=@Code,"); strSql.Append("[IsCanofflinePay]=@IsCanofflinePay,"); strSql.Append("[Sort]=@Sort,"); strSql.Append("[Type_id_TransportType]=@Type_id_TransportType"); strSql.Append(" where id=" + model.id); OleDbParameter[] parameters = { new OleDbParameter("@Name", model.Name), new OleDbParameter("@Description", model.Description), new OleDbParameter("@Code", model.Code), new OleDbParameter("@IsCanofflinePay", model.IsCanofflinePay), new OleDbParameter("@Sort", model.Sort), new OleDbParameter("@Type_id_TransportType", model.Type_id_TransportType) }; AccessUtils.Instance.TextExecuteNonQuery(strSql.ToString(), parameters); }
/// <summary> /// 生成新订单 /// </summary> public void order_save() { if (CurrentUserLevel.BuyRight != 1) { Response.Write("{\"msg\":\"" + Tag("您所在的分组不允许下单") + "\"}"); return; } int pay_id = RequestTool.RequestInt("pay_id", 0); int sid = RequestTool.RequestInt("sid", 0);//结算供应商ID int onlinepay_id = RequestTool.RequestInt("onlinepay_id", 0); decimal Money_UserCut = RequestTool.RequestDecimal("Money_UserCut", 0); int usermoneytype = RequestTool.RequestInt("usermoneytype", 0); string Pay_Password = RequestTool.RequestSafeString("Pay_Password"); Lebi_PickUp pick = null; DateTime pickdate = System.DateTime.Now; if (usermoneytype == 3) { if (Pay_Password == "") { Response.Write("{\"msg\":\"" + Tag("请输入支付密码") + "\"}"); return; } else { if (EX_User.MD5(Pay_Password) != CurrentUser.Pay_Password) { Response.Write("{\"msg\":\"" + Tag("支付密码不正确") + "\"}"); return; } } if (Money_UserCut > 0 && Money_UserCut > CurrentUser.Money) { Response.Write("{\"msg\":\"" + Tag("余额不足") + "\"}"); return; } } Lebi_Pay pay = B_Lebi_Pay.GetModel(pay_id); if (pay == null) { Response.Write("{\"msg\":\"" + Tag("请设置付款方式") + "\"}"); return; } Basket basket = new Basket(sid); int CustomOfflineMoney = RequestTool.RequestInt("CustomOfflineMoney" + pay.id, 0); decimal OfflineMoney = RequestTool.RequestDecimal("OfflineMoney" + pay.id, 0); if (CustomOfflineMoney == 1) { if (pay.Code != "OfflinePay" && pay.Code != "OnlinePay") { //订单如果选择了线下支付,并且非货到付款 if (OfflineMoney < basket.Money_Product) { Response.Write("{\"msg\":\"" + Tag("打款金额不能少于订单金额") + "\"}"); return; } } } if (pay.Code == "OnlinePay") { Lebi_OnlinePay onpay = B_Lebi_OnlinePay.GetModel(onlinepay_id); if (onpay == null) { Response.Write("{\"msg\":\"" + Tag("请设置付款方式") + "\"}"); return; } } if (basket.Products.Count == 0) { Response.Write("{\"msg\":\"" + Tag("购物车为空") + "\"}"); return; } foreach (Lebi_User_Product up in basket.Products) { if (up.count < 1) { Response.Write("{\"msg\":\"" + Tag("购物车异常") + "\"}"); return; } } if (basket.Point_Buy > 0 && (basket.Point_Buy > CurrentUser.Point)) { Response.Write("{\"msg\":\"" + Tag("积分不足") + "\"}"); return; } int ProductCount = 0; foreach (Lebi_User_Product up in basket.Products) { Lebi_Product pro = B_Lebi_Product.GetModel(up.Product_id); if (pro.Type_id_ProductType != 323) { ProductCount += up.count; } //<-{ 判断是否上架状态 by lebi.kingdge 2015-02-10 if (pro.Type_id_ProductStatus != 101) { Response.Write("{\"msg\":\"" + Lang(pro.Name) + " " + Tag("该商品已经下架") + "\"}"); return; } //}-> if (pro.Type_id_ProductType != 324) { int levelcount = ProductLevelCount(pro); if (up.count < levelcount) { Response.Write("{\"msg\":\"" + Lang(pro.Name) + " " + Tag("起订量") + " " + levelcount + "\"}"); return; } } if (pro.Type_id_ProductType != 320 && pro.Time_Expired > System.DateTime.Now) { if (pro.Count_Limit < up.count && pro.Count_Limit > 0) { Response.Write("{\"msg\":\"" + Tag("购买数量大于限购数量") + "\"}"); return; } } if (SYS.IsNullStockSale != "1") { if (pro.Count_Stock - pro.Count_Freeze < up.count && pro.Type_id_ProductType != 324) { Response.Write("{\"msg\":\"" + Lang(pro.Name) + "" + Tag("库存不足") + "\"}"); return; } } } //验证当前分组允许的最低订单提交金额 if (CurrentUserLevel.OrderSubmit > 0) { if (basket.Money_Product < CurrentUserLevel.OrderSubmit) { Response.Write("{\"msg\":\"" + Tag("单笔订单最低金额为:") + FormatMoney(CurrentUserLevel.OrderSubmit) + "\"}"); return; } } //验证当前分组允许的最低订单提交数量 if (CurrentUserLevel.OrderSubmitCount > 0 && ProductCount > 0) { if (ProductCount < CurrentUserLevel.OrderSubmitCount) { Response.Write("{\"msg\":\"" + Tag("单笔订单最低数量为:") + CurrentUserLevel.OrderSubmitCount + "\"}"); return; } } Lebi_User_Address shouhuo = B_Lebi_User_Address.GetModel(CurrentUser.User_Address_id); if (shouhuo == null) { Response.Write("{\"msg\":\"" + Tag("未设置收获地址") + "\"}"); return; } if (CurrentUser.Transport_Price_id == "") { Response.Write("{\"msg\":\"" + Tag("运费设置错误") + "\"}"); return; } foreach (BasketShop shop in basket.Shops) { Lebi_Transport_Price tprice = B_Lebi_Transport_Price.GetModel("id in (lbsql{" + CurrentUser.Transport_Price_id + "}) and Supplier_id=" + shop.Shop.id + ""); if (tprice == null) { Response.Write("{\"msg\":\"" + Tag("运费设置错误") + "\"}"); return; } Lebi_Transport transport = B_Lebi_Transport.GetModel(tprice.Transport_id); if (tprice == null) { Response.Write("{\"msg\":\"" + Tag("运费设置错误") + "\"}"); return; } //检查运费设置是否正确 if (!EX_Area.CheckAreaPrice(tprice, shouhuo.Area_id)) { Response.Write("{\"msg\":\"" + Tag("运费设置错误") + "\"}"); return; } if (transport.Type_id_TransportType == 332)//自提检查 { int pickup_id = RequestTool.RequestInt("pickup_id" + shop.Shop.id); string pickdate_ = RequestTool.RequestString("pickupdate_" + pickup_id); try { pickdate = Convert.ToDateTime(pickdate_); } catch { Response.Write("{\"msg\":\"" + Tag("配送方式设置错误") + "\"}"); return; } pick = B_Lebi_PickUp.GetModel(pickup_id); if (pick == null) { Response.Write("{\"msg\":\"" + Tag("配送方式设置错误") + "\"}"); return; } if (pick.IsCanWeekend == 0 && (pickdate.DayOfWeek == DayOfWeek.Saturday || pickdate.DayOfWeek == DayOfWeek.Sunday)) { Response.Write("{\"msg\":\"" + Tag("配送方式设置错误") + "\"}"); return; } if (System.DateTime.Now.Date.AddDays(pick.BeginDays) > pickdate) { Response.Write("{\"msg\":\"" + Tag("配送方式设置错误") + "\"}"); return; } string NoServiceDays = pick.NoServiceDays.TrimStart('0').Replace(".0", "."); string nowday = pickdate.ToString("M.d"); if (("," + NoServiceDays + ",").Contains("," + nowday + ",")) { Response.Write("{\"msg\":\"" + Tag("配送方式设置错误") + "\"}"); return; } } } //检查代金券 string pay312 = RequestTool.RequestSafeString("pay312"); if (pay312 != "") { List <Lebi_Card> cs = B_Lebi_Card.GetList("User_id=" + CurrentUser.id + " and id in (lbsql{" + pay312 + "})", "id asc"); int flag = cs.FirstOrDefault().IsCanOtherUse; if (flag == 0 && cs.Count > 1) { Response.Write("{\"msg\":\"" + Tag("代金券异常") + "\"}"); return; } foreach (Lebi_Card c in cs) { if (flag != c.IsCanOtherUse) { Response.Write("{\"msg\":\"" + Tag("代金券异常") + "\"}"); return; } if (!Basket.CheckCard(basket, c)) { Response.Write("{\"msg\":\"" + Tag("代金券异常") + "\"}"); return; } } } //检查代金券结束 //检查发票信息 int billtype_id = RequestTool.RequestInt("billtype_id", 0); Lebi_BillType billtype = B_Lebi_BillType.GetModel(billtype_id); if (ShopCache.GetBaseConfig().BillFlag == "1") { if (billtype == null) { Response.Write("{\"msg\":\"" + Tag("请设置发票内容") + "\"}"); return; } } CurrentUser.Pay_id = pay.id; CurrentUser.OnlinePay_id = onlinepay_id; Lebi_Order ordergroup; List <Lebi_Order> orders = Shop.Bussiness.Order.CreateOrder(CurrentUser, basket, shouhuo, billtype, CurrentCurrency, CurrentSite, CurrentLanguage, out ordergroup); CurrentUser.Count_Order = CurrentUser.Count_Order + orders.Count; B_Lebi_User.Update(CurrentUser); List <Lebi_Order> ordermodel = B_Lebi_Order.GetList("User_id=" + CurrentUser.id + "", "id desc"); ordergroup = ordermodel.FirstOrDefault(); if (OfflineMoney == 0) { OfflineMoney = ordergroup.Money_Order; } string remark = RequestTool.RequestSafeString("remark"); ordergroup.Remark_User = remark; bool needupdate = false; if (remark != "") { Lebi_Comment model = new Lebi_Comment(); model.Content = remark; model.Keyid = ordergroup.id; model.TableName = "Order"; model.User_id = CurrentUser.id; model.User_UserName = CurrentUser.UserName; B_Lebi_Comment.Add(model); needupdate = true; } if (pick != null) { ordergroup.PickUp_Date = pickdate; ordergroup.PickUp_id = pick.id; ordergroup.PickUp_Name = pick.Name; needupdate = true; } if (needupdate) { B_Lebi_Order.Update(ordergroup); } if (pay.Code != "OfflinePay" && pay.Code != "OnlinePay") { //订单如果选择了线下支付,并且非货到付款 //生成一笔充值单 //OfflineMoney Lebi_Currency DefaultCurrency = B_Lebi_Currency.GetModel("IsDefault=1"); if (DefaultCurrency == null) { DefaultCurrency = B_Lebi_Currency.GetList("", "Sort desc").FirstOrDefault(); } Lebi_Order order = new Lebi_Order(); order.Code = "M" + Shop.Bussiness.Order.CreateOrderCode(); order.Money_Order = OfflineMoney; order.Money_Pay = OfflineMoney; order.User_id = CurrentUser.id; order.User_UserName = CurrentUser.UserName; order.IsPaid = 0; order.Currency_Code = ordergroup.Currency_Code; order.Currency_ExchangeRate = ordergroup.Currency_ExchangeRate; order.Currency_id = ordergroup.Currency_id; order.Currency_Msige = ordergroup.Currency_Msige; order.Type_id_OrderType = 214; order.Pay_id = pay.id; order.Pay = pay.Name; order.Site_id = CurrentSite.id; order.Language_id = CurrentLanguage.id; order.Remark_Admin = ""; order.Order_id = ordergroup.id; B_Lebi_Order.Add(order); } //if (orders.Count == 1) // ordergroup = orders.FirstOrDefault(); //Shop.Bussiness.Order.SupplierOrder(order);//根据商品供应商分单 Response.Write("{\"msg\":\"OK\",\"id\":\"" + ordergroup.id + "\"}"); return; }
/// <summary> /// 订单发货通知-不更新库存 /// </summary> public void mSndGoods() { //OrderID 订单编号 //OrderNO 原始订单编号 //CustomerID 客户网名 //SndStyle 发货方式 //BillID 货运单号 //SndDate 发货时间 string OrderID = RequestTool.RequestString("OrderID"); string OrderNO = RequestTool.RequestString("OrderNO"); string CustomerID = RequestTool.RequestString("CustomerID"); string SndStyle = RequestTool.RequestString("SndStyle"); string BillID = RequestTool.RequestString("BillID"); string SndDate = RequestTool.RequestString("SndDate"); Lebi_Order model = B_Lebi_Order.GetModel("Code=lbsql{'" + OrderNO + "'}"); Lebi_Language_Code lang = Language.DefaultLanguage(); string res = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"; if (model == null) { res += "<rsp><result>0</result><cause>无此单号</cause></rsp>"; Response.Write(res); return; } Lebi_Transport tran = B_Lebi_Transport.GetModel("[Name]=lbsql{'" + SndStyle + "'}"); if (tran == null) { tran = new Lebi_Transport(); } Lebi_Transport_Order torder = new Lebi_Transport_Order(); torder.Code = BillID; torder.Order_id = model.id; torder.T_Address = model.T_Address; torder.T_Email = model.T_Email; torder.T_MobilePhone = model.T_MobilePhone; torder.T_Name = model.T_Name; torder.T_Phone = model.T_Phone; torder.Transport_Code = tran == null ? model.Transport_Code : tran.Code; torder.Transport_id = tran == null ? model.Transport_id : tran.id; torder.Transport_Name = tran == null ? model.Transport_Name : tran.Name; torder.User_id = model.User_id; List <TransportProduct> tps = new List <TransportProduct>(); TransportProduct tp; List <Lebi_Order_Product> pros = B_Lebi_Order_Product.GetList("Order_id=" + model.id + "", ""); bool isfahuo_all = true; foreach (Lebi_Order_Product pro in pros) { tp = new TransportProduct(); tp.Count = pro.Count; tp.ImageBig = pro.ImageBig; tp.ImageMedium = pro.ImageMedium; tp.ImageOriginal = pro.ImageOriginal; tp.ImageSmall = pro.ImageSmall; tp.Product_Number = pro.Product_Number; tp.Product_id = pro.Product_id; tp.Product_Name = pro.Product_Name; tps.Add(tp); pro.Count_Shipped = pro.Count; B_Lebi_Order_Product.Update(pro); //更新库存 Lebi_Product product = B_Lebi_Product.GetModel(pro.Product_id); EX_Product.ProductStock_Change(product, (0 - pro.Count), 302, model); } JavaScriptSerializer jss = new JavaScriptSerializer(); torder.Product = jss.Serialize(tps); torder.Type_id_TransportOrderStatus = 220;//默认状态:在途 B_Lebi_Transport_Order.Add(torder); model.IsShipped = 1; model.IsShipped_All = isfahuo_all ? 1 : 0; model.Time_Shipped = System.DateTime.Now;; B_Lebi_Order.Update(model); Log.Add("订单发货-网站管家", "Order", model.id.ToString()); //发送邮件 if (ShopCache.GetBaseConfig().MailSign.ToLower().Contains("dingdanfahuo")) { Lebi_User user = B_Lebi_User.GetModel(model.User_id); Email.SendEmail_ordershipping(user, model, torder); } res += "<rsp><result>1</result></rsp>"; Response.Write(res); Log.Add("订单编号:" + OrderNO + "--" + res, "网店管家同步发货", ""); }
/// <summary> /// 计算运费 /// </summary> /// <param name="weight"></param> /// <param name="volume"></param> /// <param name="price"></param> /// <param name="ordermoney"></param> /// <returns></returns> public static decimal GetYunFei(decimal weight, decimal volume, Lebi_Transport_Price price, decimal ordermoney) { if (price == null) { price = new Lebi_Transport_Price(); } decimal res = 0; if (ordermoney >= price.OrderMoney && price.OrderMoney > 0)//满足订单金额要求 { return(price.Price_OrderMoneyOK); } if (price.IsOnePrice == 1)//定额运费 { return(price.Price); } else { Lebi_Transport transport = B_Lebi_Transport.GetModel(price.Transport_id); if (transport == null) { return(0); } decimal money = price.Price; if (transport.Type_id_TransportType == 331) { //货柜方式计算 JavaScriptSerializer jss = new JavaScriptSerializer(); List <KeyValue> kvs = jss.Deserialize <List <KeyValue> >(price.Container); string ids = ""; foreach (KeyValue kv in kvs) { if (ids == "") { ids = kv.K; } else { ids += "," + kv.K; } } int count = 0; //需要的货柜数量 decimal cprice = 0; //使用的货柜价格 if (ids != "") { List <Lebi_Transport_Container> conts = B_Lebi_Transport_Container.GetList("id in (lbsql{" + ids + "})", "Volume desc"); //判断使用哪个货柜 Lebi_Transport_Container UseCont = new Lebi_Transport_Container(); foreach (Lebi_Transport_Container cont in conts) { if (volume / 100 / 100 / 100 > cont.Volume) { UseCont = cont; break; } } if (UseCont.id == 0) { UseCont = conts.FirstOrDefault(); } UseCont.Weight = UseCont.Weight * 1000 * 1000; //单位转换为克 UseCont.Volume = UseCont.Volume * 100 * 100 * 100; //单位转换为立方厘米 KeyValue kv = (from m in kvs where m.K == UseCont.id.ToString() select m).ToList().FirstOrDefault(); cprice = Convert.ToDecimal(kv.V); if (weight > UseCont.Weight) { //按重量计算 count = (int)(weight / UseCont.Weight); if (weight % UseCont.Weight > 0) { count++; } } else { //按体积计算 count = (int)(volume / UseCont.Volume); if (volume % UseCont.Volume > 0) { count++; } } } count = count == 0 ? 1 : count; money = money + cprice * count; } else { //包裹方式计算 int wei = (int)weight + 1; if (weight > price.Weight_Start) { try { decimal step = (weight - price.Weight_Start) / price.Weight_Step; step = Math.Ceiling(step); money = money + step * price.Price_Step; } catch (DivideByZeroException) { // money = money; } } } res = money; } return(res); }
/// <summary> /// 获得运费备注 /// </summary> /// <param name="weight"></param> /// <param name="volume"></param> /// <param name="price"></param> /// <param name="ordermoney"></param> /// <returns></returns> public static string GerYunFeiMark(decimal weight, decimal volume, Lebi_Transport_Price price, decimal ordermoney = 0) { string res = ""; if (price.IsOnePrice == 1 && ordermoney >= price.OrderMoney)//满足订单金额要求 { return(""); } else { Lebi_Transport transport = B_Lebi_Transport.GetModel(price.Transport_id); decimal money = price.Price; if (transport.Type_id_TransportType == 331) { //货柜方式计算 JavaScriptSerializer jss = new JavaScriptSerializer(); List <KeyValue> kvs = jss.Deserialize <List <KeyValue> >(price.Container); string ids = ""; foreach (KeyValue kv in kvs) { if (ids == "") { ids = kv.K; } else { ids += "," + kv.K; } } int count = 0; //需要的货柜数量 decimal cprice = 0; //使用的货柜价格 if (ids != "") { List <Lebi_Transport_Container> conts = B_Lebi_Transport_Container.GetList("id in (lbsql{" + ids + "})", "Volume desc"); //判断使用哪个货柜 Lebi_Transport_Container UseCont = new Lebi_Transport_Container(); foreach (Lebi_Transport_Container cont in conts) { if (volume / 100 / 100 / 100 > cont.Volume) { UseCont = cont; break; } } if (UseCont.id == 0) { UseCont = conts.FirstOrDefault(); } UseCont.Weight = UseCont.Weight * 1000 * 1000; //单位转换为克 UseCont.Volume = UseCont.Volume * 100 * 100 * 100; //单位转换为立方厘米 KeyValue kv = (from m in kvs where m.K == UseCont.id.ToString() select m).ToList().FirstOrDefault(); cprice = Convert.ToDecimal(kv.V); if (weight > UseCont.Weight) { //按重量计算 count = (int)(weight / UseCont.Weight); if (weight % UseCont.Weight > 0) { count++; } } else { //按体积计算 count = (int)(volume / UseCont.Volume); if (volume % UseCont.Volume > 0) { count++; } } count = count == 0 ? 1 : count; res = UseCont.Name + ":" + count; } } else { } } return(res); }
/// <summary> /// 安全方式绑定表单数据 /// </summary> public static Lebi_Transport SafeBindForm(Lebi_Transport model) { return(D_Lebi_Transport.Instance.SafeBindForm(model)); }
/// <summary> /// 增加一条数据 /// </summary> public static int Add(Lebi_Transport model) { return(D_Lebi_Transport.Instance.Add(model)); }
/// <summary> /// 更新一条数据 /// </summary> public static void Update(Lebi_Transport model) { D_Lebi_Transport.Instance.Update(model); }
protected void Page_Load(object sender, EventArgs e) { int id = RequestTool.RequestInt("id", 0); if (id == 0) { if (!EX_Admin.Power("transport_price_add", "添加配送区域")) { WindowNoPower(); } } else { if (!EX_Admin.Power("transport_price_edit", "编辑配送区域")) { WindowNoPower(); } } int tid = RequestTool.RequestInt("tid", 0); model = B_Lebi_Transport_Price.GetModel(id); if (model == null) { tmodel = B_Lebi_Transport.GetModel(tid); model = new Lebi_Transport_Price(); } else { tmodel = B_Lebi_Transport.GetModel(model.Transport_id); } JavaScriptSerializer jss = new JavaScriptSerializer(); try { kvs = jss.Deserialize <List <KeyValue> >(model.Container); } catch { kvs = new List <KeyValue>(); } //生成货柜价格编辑区 conts = B_Lebi_Transport_Container.GetList("", "Volume desc"); foreach (Shop.Model.Lebi_Transport_Container cont in conts) { KeyValue kv; try { kv = (from m in kvs where m.K == cont.id.ToString() select m).ToList().FirstOrDefault(); } catch (System.ArgumentNullException ex) { kv = null; } bool flag = false; if (kv != null) { flag = true; } else { kv = new KeyValue(); } string price_ = kv.V.ToString(); decimal price = 0; decimal.TryParse(price_, out price); Containestr += "<tr class=\"list\">"; Containestr += "<td><input type=\"checkbox\" name=\"Containerid\" shop=\"true\" value=\"" + cont.id + "\" " + (flag ? "checked" : "") + " /></td>"; Containestr += "<td>" + cont.Name + "</td>"; Containestr += "<td>"; Containestr += " <input type=\"text\" class=\"input\" shop=\"true\" name=\"ContainerPrice" + cont.id + "\" id=\"ContainerPrice" + cont.id + "\" value=\"" + FormatMoney(price, "Number") + "\" style=\"width: 100px;\" onkeyup=\"value=value.replace(/[^\\d]/g,'')\" /> <span></span>"; Containestr += "</td></tr>"; } }
protected int sid = 0;//结算供应商ID public void LoadPage() { sid = RequestTool.RequestInt("sid", 0); basket = new Basket(sid); bool offlinepay = false; if (CurrentUser.Transport_Price_id == "") { CurrentUser.Transport_Price_id = "0"; } List <Lebi_Transport_Price> prices = B_Lebi_Transport_Price.GetList("id in (" + CurrentUser.Transport_Price_id + ")", ""); if (prices.Count == 0) { Response.Write(Tag("请先选择配送方式")); Response.End(); return; } Lebi_Transport_Price currenttranprice = new Lebi_Transport_Price(); Lebi_Transport currenttran = new Lebi_Transport(); foreach (Lebi_Transport_Price price in prices) { currenttran = B_Lebi_Transport.GetModel(price.Transport_id); if (currenttran == null) { Response.Write(Tag("请先选择配送方式")); Response.End(); return; } if (basket.cashsupplierid == price.Supplier_id)//商城收款,供应商发货的情况必须用在线支付,所以下永远匹配不上。 { currenttranprice = price; } } string where = "IsUsed=1"; //if (prices.Count > 1 || currenttranprice.Supplier_id > 0 || basket.cashsupplierid > 0) //{ // where += " and Code='OnlinePay'"; //} //else //{ if (currenttran.IsCanofflinePay == 1 && currenttranprice.IsCanofflinePay == 1) { offlinepay = true; } if (offlinepay == false) { where += " and Code!='OfflinePay'"; } //} string onpaywhere = "IsUsed=1 and parentid=0 and ','+Language_ids+',' like '%," + CurrentLanguage.id + ",%'"; //string useragent=Request.UserAgent.ToString().ToLower(); //if (!useragent.Contains("micromessenger")) //{ // onpaywhere += " and Code!='weixinpay'"; //} if (CurrentSite.IsMobile == 1) { onpaywhere += " and (showtype='' or showtype like '%wap%')"; } else { onpaywhere += " and (showtype='' or showtype like '%web%')"; } SystemLog.Add(onpaywhere); pays = B_Lebi_Pay.GetList(where, "Sort desc"); if ((CurrentUser.Pay_id == 0 || pays.Count == 1) && pays.Count > 0) { CurrentUser.Pay_id = pays.FirstOrDefault().id; } onpays = B_Lebi_OnlinePay.GetList(onpaywhere, "Sort desc"); if (onpays.Count == 0) { CurrentUser.OnlinePay_id = 0; } else { if (CurrentUser.OnlinePay_id == 0 || onpays.Count == 1) { CurrentUser.OnlinePay_id = onpays.FirstOrDefault().id; } else { bool flag = false; foreach (Lebi_OnlinePay p in onpays) { if (p.id == CurrentUser.OnlinePay_id) { flag = true; break; } } if (flag == false) { CurrentUser.OnlinePay_id = onpays.FirstOrDefault().id; } } } }