private void OkBuy() { int meid = new BCW.User.Users().GetUsId(); if (meid == 0) { Utils.Login(); } int id = int.Parse(Utils.GetRequest("id", "post", 2, @"^[0-9]\d*$", "ID错误")); string LaNotes = Utils.GetRequest("LaNotes", "post", 2, @"^[\s\S]{1,300}$", "评价限1-300字"); int stats = int.Parse(Utils.GetRequest("stats", "post", 2, @"^[3-4]$", "选择状态错误")); //是否存在未确认/评价订单记录 if (!new BCW.BLL.Buylist().Exists(id, meid, 2)) { Utils.Error("不存在的记录", ""); } BCW.Model.Buylist model = new BCW.Model.Buylist(); model.ID = id; model.LaNotes = LaNotes; //model.AcStats = stats; model.AcStats = 3; new BCW.BLL.Buylist().UpdateStats(model); //更新评价数 new BCW.BLL.Goods().UpdateEvcount(id, 1); Utils.Success("确定交易", "确定交易/评价成功..", Utils.getUrl("myshop.aspx?act=view&id=" + id + "&backurl=" + Utils.getPage(0) + ""), "1"); }
private void SaveBuy() { int id = int.Parse(Utils.GetRequest("id", "post", 1, @"^[0-9]\d*$", "0")); string RealName = Utils.GetRequest("RealName", "post", 2, @"^[\u4e00-\u9fa5]{2,8}$", "姓名填写错误"); string Mobile = Utils.GetRequest("Mobile", "post", 2, @"^(?:13|15|18)\d{9}$|^(\d{3}-|\d{4}-)?(\d{8}|\d{7})?(-\d+)?$", "联系电话不正确,必填固话或者手机号"); string Address = Utils.GetRequest("Address", "post", 2, @"^[\s\S]{8,}$", "收货地址请尽量详细到门牌号"); string Notes = Utils.GetRequest("Notes", "post", 3, @"^[\s\S]{1,200}$", "备注限200字,可以留空"); string LaNotes = Utils.GetRequest("LaNotes", "post", 3, @"^[\s\S]{1,200}$", "评价限200字,可以留空"); int AcPrice = int.Parse(Utils.GetRequest("AcPrice", "post", 2, @"^[0-9]\d*$", "金额填写出错")); int Ispn = int.Parse(Utils.GetRequest("Ispn", "post", 1, @"^[0-1]\d*$", "0")); if (!new BCW.BLL.Buylist().Exists(id)) { Utils.Error("不存在的记录", ""); } BCW.Model.Buylist model = new BCW.Model.Buylist(); model.ID = id; model.RealName = RealName; model.Mobile = Mobile; model.Address = Address; model.Notes = Notes; model.LaNotes = LaNotes; model.AcPrice = AcPrice; new BCW.BLL.Buylist().UpdateBuy(model); //更新评价数 if (Ispn == 1) { new BCW.BLL.Goods().UpdateEvcount(id, 1); } Utils.Success("修改成功", "修改订单成功..", Utils.getUrl("shopbuy.aspx?act=view&id=" + id + "&backurl=" + Utils.getPage(0) + ""), "1"); }
private void SaveBuylist() { //用户资料 int meid = new BCW.User.Users().GetUsId(); string mename = new BCW.BLL.User().GetUsName(meid); if (meid == 0) { Utils.Login(); } int id = int.Parse(Utils.GetRequest("id", "all", 2, @"^[0-9]\d*$", "ID错误")); if (!new BCW.BLL.Goods().Exists(id)) { Utils.Error("不存在的记录", ""); } //是否刷屏 string appName = "BUYLIST"; int Expir = Convert.ToInt32(ub.GetSub("BuylistExpir", xmlPath)); BCW.User.Users.IsFresh(appName, Expir); int Paycount = int.Parse(Utils.GetRequest("Paycount", "post", 2, @"^[0-9]\d*$", "购买数量错误")); string RealName = Utils.GetRequest("RealName", "post", 2, @"^[\u4e00-\u9fa5]{2,8}$", "姓名填写错误"); string Mobile = Utils.GetRequest("Mobile", "post", 2, @"^(?:13|15|18)\d{9}$|^(\d{3}-|\d{4}-)?(\d{8}|\d{7})?(-\d+)?$", "联系电话不正确,必填固话或者手机号"); string Address = Utils.GetRequest("Address", "post", 2, @"^[\s\S]{8,}$", "收货地址请尽量详细到门牌号"); int pType = int.Parse(Utils.GetRequest("pType", "post", 2, @"^[0-9]\d*$", "邮寄方式选择错误")); string Notes = Utils.GetRequest("Notes", "post", 3, @"^[\s\S]{1,200}$", "备注限200字,可以留空"); BCW.Model.Goods modelGoods = new BCW.BLL.Goods().GetGoods(id); Master.Title = "购买宝贝"; builder.Append(Out.Tab("<div class=\"title\">购买宝贝</div>", "")); builder.Append(Out.Tab("<div class=\"text\">", "")); if ((modelGoods.StockCount - modelGoods.SellCount) < Paycount) { Utils.Error("对不起,目前最多可以购买" + (modelGoods.StockCount - modelGoods.SellCount) + "件", ""); } int pMoney = 0; if (!string.IsNullOrEmpty(modelGoods.PostMoney)) { string[] sTemp = modelGoods.PostMoney.Split("|".ToCharArray()); int k = 1; pMoney = -1; for (int j = 0; j < sTemp.Length; j++) { if (j % 2 == 0) { if (k == pType) { pMoney = Convert.ToInt32(sTemp[j].ToString()); break; } } k++; } if (pMoney == -1) { Utils.Error("邮寄方式选择错误", ""); } } //扣币与内线 if (modelGoods.PostType > 0) { if (modelGoods.PostType == 1) { if (new BCW.BLL.User().GetGold(meid) < Convert.ToInt64(modelGoods.VipMoney)) { Utils.Error("您的" + ub.Get("SiteBz") + "不足", ""); } else if (modelGoods.PostType == 2) { if (new BCW.BLL.User().GetMoney(meid) < Convert.ToInt64(modelGoods.VipMoney)) { Utils.Error("您的" + ub.Get("SiteBz2") + "不足", ""); } } if (modelGoods.PostType == 1) { new BCW.BLL.User().UpdateiGold(meid, mename, -Convert.ToInt64(modelGoods.VipMoney), "购买商品《" + modelGoods.Title + "》"); //发信给下订单的会员 new BCW.BLL.Guest().Add(meid, mename, "您已成功购买[url=/shopdetail.aspx?id=" + id + "]" + modelGoods.Title + "[/url],扣除您的" + Convert.ToInt64(modelGoods.VipMoney) + "" + ub.Get("SiteBz") + ",多谢惠顾![br][url=/myshop.aspx]>我的订单[/url]"); } else if (modelGoods.PostType == 2) { new BCW.BLL.User().UpdateiMoney(meid, mename, -Convert.ToInt64(modelGoods.VipMoney), "购买商品《" + modelGoods.Title + "》"); //发信给下订单的会员 new BCW.BLL.Guest().Add(meid, mename, "您已成功购买[url=/shopdetail.aspx?id=" + id + "]" + modelGoods.Title + "[/url],扣除您的" + Convert.ToInt64(modelGoods.VipMoney) + "" + ub.Get("SiteBz2") + ",多谢惠顾![br][url=/myshop.aspx]>我的订单[/url]"); } } } else { //发信给下订单的会员 new BCW.BLL.Guest().Add(meid, mename, "您已成功购买[url=/shopdetail.aspx?id=" + id + "]" + modelGoods.Title + "[/url],如果商品要求先付款再发货,请尽快付款,多谢惠顾![br][url=/myshop.aspx]>我的订单[/url]"); } //生成订单号 string Ding = DT.getDateTimeNum(); //写入订单 BCW.Model.Buylist model = new BCW.Model.Buylist(); model.TingNo = Ding; model.NodeId = new BCW.BLL.Goods().GetNodeId(id); model.GoodsId = id; model.Title = modelGoods.Title; model.Price = modelGoods.VipMoney; model.Paycount = Paycount; if (modelGoods.PayType == 1) { model.PostMoney = -1; } else { model.PostMoney = pMoney; } model.SellId = 0;//系统默认ID,说明是系统发布的商品 model.UserId = meid; model.UserName = mename; model.RealName = RealName; model.Mobile = Mobile; model.Address = Address; model.Notes = Notes; model.AcPrice = Convert.ToInt32(Paycount * modelGoods.VipMoney); model.AcStats = 0; model.AcText = ""; model.AddUsIP = Utils.GetUsIP(); model.AddTime = DateTime.Now; new BCW.BLL.Buylist().Add(model); //更新购买人数 new BCW.BLL.Goods().UpdatePaycount(id, 1); //更新出售数量 new BCW.BLL.Goods().UpdateSellCount(id, Paycount); builder.Append("购买宝贝成功"); builder.Append("<br />订单号:" + Ding + ""); builder.Append("<br />进入:<a href=\"" + Utils.getUrl("myshop.aspx?id=" + id + "&backurl=" + Utils.getPage(0) + "") + "\">我的订单</a>"); builder.Append(Out.Tab("</div>", "")); builder.Append(Out.Tab("<div class=\"title\">", Out.Hr())); builder.Append("<a href=\"" + Utils.getUrl("default.aspx") + "\">首页</a>-"); builder.Append("<a href=\"" + Utils.getUrl("shopdetail.aspx?id=" + id + "&backurl=" + Utils.getPage(0) + "") + "\">上级</a>"); builder.Append(Out.Tab("</div>", "")); }
/// <summary> /// 更新后台订单状态 /// </summary> public void UpdateMStats(BCW.Model.Buylist model) { dal.UpdateMStats(model); }
/// <summary> /// 更新用户订单 /// </summary> public void UpdateBuy(BCW.Model.Buylist model) { dal.UpdateBuy(model); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(BCW.Model.Buylist model) { return(dal.Add(model)); }
private void OkBuy() { int id = int.Parse(Utils.GetRequest("id", "post", 1, @"^[0-9]\d*$", "0")); string AcEms = Utils.GetRequest("AcEms", "post", 3, @"^[A-Za-z0-9]+$", "运单号填写错误"); string AcText = Utils.GetRequest("AcText", "post", 3, @"^[\s\S]{1,300}$", "附言最多300字"); int stats = int.Parse(Utils.GetRequest("stats", "post", 2, @"^[0-4]$", "选择状态错误")); string info = Utils.GetRequest("info", "all", 1, "", ""); if (info != "ok" && (stats == 3 || stats == 4)) { Master.Title = "确定订单"; builder.Append(Out.Tab("<div class=\"title\">", "")); if (stats == 3) { builder.Append("确定把订单记录确认为交易成功吗,确认后不可修改"); } else { builder.Append("确定把订单记录确认为交易失败吗,确认后不可修改"); } builder.Append(Out.Tab("</div>", "<br />")); string strName = "AcEms,AcText,stats,id,act,backurl,info"; string strValu = "" + AcEms + "'" + AcText + "'" + stats + "'" + id + "'ok'" + Utils.getPage(2) + "'ok"; string strOthe = "确认交易,shopbuy.aspx,post,0,red"; builder.Append(Out.wapform(strName, strValu, strOthe)); builder.Append(Out.Tab("<div>", "<br />")); builder.Append(" <a href=\"" + Utils.getUrl("shopbuy.aspx?act=view&id=" + id + "&backurl=" + Utils.getPage(0) + "") + "\">等待确认</a>"); builder.Append(Out.Tab("</div>", "")); builder.Append(Out.Tab("<div class=\"hr\"></div>", Out.Hr())); builder.Append(Out.Tab("<div>", "")); builder.Append("<a href=\"" + Utils.getUrl("shopbuy.aspx?act=view&id=" + id + "") + "\">返回上一级</a><br />"); builder.Append(Out.Tab("</div><div class=\"title\"><a href=\"" + Utils.getUrl("default.aspx") + "\">返回管理中心</a>", "<a href=\"" + Utils.getUrl("default.aspx") + "\">返回管理中心</a>")); builder.Append(Out.Tab("</div>", "<br />")); } else { if (!new BCW.BLL.Buylist().Exists(id)) { Utils.Error("不存在的记录", ""); } BCW.Model.Buylist modelBuy = new BCW.BLL.Buylist().GetBuylist(id); if (modelBuy.AcStats == 3 || modelBuy.AcStats == 4) { Utils.Error("此订单已经确认,无法进行更改", ""); } BCW.Model.Buylist model = new BCW.Model.Buylist(); model.ID = id; model.AcText = AcText; model.AcEms = AcEms; model.AcStats = stats; new BCW.BLL.Buylist().UpdateMStats(model); if (stats == 4) { //如果失败,更新出售数量 new BCW.BLL.Goods().UpdateSellCount(modelBuy.GoodsId, -modelBuy.Paycount); } if (stats == 3) { //如果交易成功并有推荐ID,则执行 long ReTar = Utils.ParseInt64(ub.GetSub("BuylistReTar", xmlPath)); if (ReTar > 0) { int InviteNum = new BCW.BLL.User().GetInviteNum(modelBuy.UserId); if (InviteNum > 0) { //计算分成 long gold = Convert.ToInt64(modelBuy.Paycount * modelBuy.Price); long ReFcGold = Convert.ToInt64(gold * ReTar * 0.01); //更新InviteNum分成金额 new BCW.BLL.User().UpdateiFcGold(InviteNum, ReFcGold); BCW.Model.Shoptg tg = new BCW.Model.Shoptg(); tg.ZrID = InviteNum; tg.UsID = modelBuy.UserId; tg.UsName = modelBuy.UserName; tg.Notes = "购买" + modelBuy.Title + "(" + modelBuy.Paycount + "件),分成收入" + ReFcGold + "元"; tg.DetailId = modelBuy.GoodsId; tg.AddTime = DateTime.Now; new BCW.BLL.Shoptg().Add(tg); //发信给推荐ID,提醒分成收入 new BCW.BLL.Guest().Add(InviteNum, new BCW.BLL.User().GetUsName(InviteNum), "恭喜!您推荐的会员[url=/bbs/uinfo.aspx?uid=" + modelBuy.UserId + "]" + modelBuy.UserName + "[/url]成功购买了商品[url=/shopdetail.aspx?id=" + modelBuy.GoodsId + "]《" + modelBuy.Title + "》[/url],你的分成收入增加" + ReFcGold + "元"); } } } //发信给下订单的会员 new BCW.BLL.Guest().Add(modelBuy.UserId, modelBuy.UserName, "您的订单[url=/myshop.aspx?act=view&id=" + id + "]" + modelBuy.Title + "[/url]已变更为" + BCW.User.AppCase.CaseBuyStats(stats) + ""); Utils.Success("确定交易", "确定成功,订单变更为" + BCW.User.AppCase.CaseBuyStats(stats) + "," + modelBuy.UserName + "将收到订单结果的内线..", Utils.getUrl("shopbuy.aspx?act=view&id=" + id + "&backurl=" + Utils.getPage(0) + ""), "1"); } }