/// <summary> /// 取消按钮点击方法 /// </summary> protected void CancelButton_Click(object sender, EventArgs e) { OrderInfo order = ButtoStart(); int startOrderStatus = order.OrderStatus; order.OrderStatus = (int)OrderStatus.NoEffect; #region 待付款状态,退还用户下单时抵现的积分 if (startOrderStatus == (int)OrderStatus.WaitPay && order.Point > 0) { var accountRecord = new UserAccountRecordInfo { RecordType = (int)AccountRecordType.Point, Money = 0, Point = order.Point, Date = DateTime.Now, IP = ClientHelper.IP, Note = "取消订单:" + order.OrderNumber + ",退回用户积分", UserId = order.UserId, UserName = order.UserName, }; UserAccountRecordBLL.Add(accountRecord); } #endregion //更新商品库存数量 ProductBLL.ChangeOrderCountByOrder(order.Id, ChangeAction.Minus); ButtonEnd(order, Note.Text, OrderOperate.Cancle, startOrderStatus); }
protected override void PageLoad() { base.PageLoad(); if (CurrentUser.UserType == (int)UserType.Provider) { dt = UserBLL.ShopIndexStatistics(base.UserId); OrderSearchInfo orderSearch = new OrderSearchInfo(); orderSearch.ShopId = base.UserId; orderSearch.IsDelete = (int)BoolType.False; int count = int.MinValue; orderList = OrderBLL.SearchList(1, 10, orderSearch, ref count); } else { OrderSearchInfo orderSearch = new OrderSearchInfo(); orderSearch.UserId = base.UserId; orderSearch.IsDelete = (int)BoolType.False; int count = 0; orderList = OrderBLL.SearchList(1, 10, orderSearch, ref count); dt = UserBLL.UserIndexStatistics(base.UserId); //webservice //get account if (CurrentUser.IsTulouMember) { bool isSuccess; string msg; //var account = WebService.Account.GetAccount(CurrentUser.CardNo, CurrentUser.CardPwd, out isSuccess, out msg); money = 0;// account.Acc; } point = UserAccountRecordBLL.SumPoint(base.UserId); } }
/// <summary> /// 页面加载方法 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { CheckAdminPower("ReadUserAccountRecord", PowerCheckType.Single); userID = RequestHelper.GetQueryString <int>("UserID"); user = UserBLL.ReadUserMore(userID); accountType = RequestHelper.GetQueryString <int>("AccountType"); PageSize = 12; //if (accountType == int.MinValue) //{ // userAccountRecordList = UserAccountRecordBLL.ReadList(CurrentPage, PageSize, AccountRecordType.Money, userID, ref Count); //} //else //{ userAccountRecordList = UserAccountRecordBLL.ReadList(CurrentPage, PageSize, AccountRecordType.Point, userID, ref Count); //} if (userAccountRecordList.Count > 0) { //if (accountType == (int)AccountRecordType.Money) //{ // moneyLeft = UserAccountRecordBLL.ReadMoneyLeftBeforID(userAccountRecordList[0].Id, userID); //} //else //{ pointLeft = UserAccountRecordBLL.ReadPointLeftBeforID(userAccountRecordList[0].Id, userID); //} } //BindControl(MyPager); BindControl(userAccountRecordList, RecordList, MyPager); } }
protected override void PageLoad() { base.PageLoad(); string action = StringHelper.AddSafe(RequestHelper.GetQueryString <string>("Action")); if (action == "Submit") { this.Submit(); } if (action == "CheckPoint") { this.CheckPoint(); } int id = RequestHelper.GetQueryString <int>("Id"); if (base.UserId == 0) { string redirectUrl = string.IsNullOrEmpty(isMobile) ? "/user/login.html?RedirectUrl=/gift/exchange/" + id.ToString() + ".html" : "/mobile/login.html?RedirectUrl=/mobile/gift/exchange/" + id.ToString() + ".html"; ResponseHelper.Redirect(redirectUrl); ResponseHelper.End(); } CurrentUser = UserBLL.Read(base.UserId); Gift = PointProductBLL.Read(id); userPoint = UserAccountRecordBLL.SumPoint(base.UserId); singleUnlimitClass.DataSource = RegionBLL.ReadRegionUnlimitClass(); singleUnlimitClass.ClassID = "|1" + CurrentUser.RegionId; Title = Gift.Name + " - 奖品兑换"; }
protected override void PageLoad() { base.PageLoad(); this.action = RequestHelper.GetQueryString <string>("Action"); int queryString = RequestHelper.GetQueryString <int>("Page"); if (queryString < 1) { queryString = 1; } int pageSize = 15; int count = 0; this.accountType = 2; if (this.action == "Money") { this.accountType = 1; } this.userAccountRecordList = UserAccountRecordBLL.ReadUserAccountRecordList(queryString, pageSize, ref count, base.UserID, this.accountType); if (this.userAccountRecordList.Count > 0) { if (this.accountType == 1) { this.moneyLeft = UserAccountRecordBLL.ReadMoneyLeftBeforID(this.userAccountRecordList[0].ID, base.UserID); } else { this.pointLeft = UserAccountRecordBLL.ReadPointLeftBeforID(this.userAccountRecordList[0].ID, base.UserID); } } this.ajaxPagerClass.CurrentPage = queryString; this.ajaxPagerClass.PageSize = pageSize; this.ajaxPagerClass.Count = count; }
protected void CheckPoint() { if (base.UserId <= 0) { ResponseHelper.Write("error|还未登录"); ResponseHelper.End(); } int pointLeft = UserAccountRecordBLL.SumPoint(base.UserId); int id = RequestHelper.GetQueryString <int>("id"); var gift = PointProductBLL.Read(id); if (gift.IsSale != (int)BoolType.True) { ResponseHelper.Write("error|该商品已下架"); ResponseHelper.End(); } if (gift.Point > pointLeft) { ResponseHelper.Write("error|您当前的积分不足以兑取该商品"); ResponseHelper.End(); } ResponseHelper.Write("ok|"); ResponseHelper.End(); }
/// <summary> /// 提交按钮点击方法 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void SubmitButton_Click(object sender, EventArgs e) { //读取用户信息 userID = Cookies.User.GetUserID(true); string userName = Cookies.User.GetUserName(false); string userEmail = CookiesHelper.ReadCookieValue("UserEmail"); //添加团购记录 int id = RequestHelper.GetQueryString <int>("ID"); groupBuy = GroupBuyBLL.ReadGroupBuy(id); UserGroupBuyInfo userGroupBuy = new UserGroupBuyInfo(); userGroupBuy.GroupBuyID = id; userGroupBuy.Date = RequestHelper.DateNow; userGroupBuy.IP = ClientHelper.IP; userGroupBuy.BuyCount = RequestHelper.GetForm <int>("BuyCount"); userGroupBuy.OrderID = 0; userGroupBuy.UserID = userID; userGroupBuy.UserName = userName; userGroupBuy.Consignee = StringHelper.AddSafe(RequestHelper.GetForm <string>("Consignee")); userGroupBuy.RegionID = RegionID.ClassID; userGroupBuy.Address = StringHelper.AddSafe(RequestHelper.GetForm <string>("Address")); userGroupBuy.ZipCode = StringHelper.AddSafe(RequestHelper.GetForm <string>("ZipCode")); userGroupBuy.Tel = StringHelper.AddSafe(RequestHelper.GetForm <string>("Tel")); userGroupBuy.Email = userEmail; userGroupBuy.Mobile = StringHelper.AddSafe(RequestHelper.GetForm <string>("Mobile")); UserGroupBuyBLL.AddUserGroupBuy(userGroupBuy); UserAccountRecordBLL.AddUserAccountRecord(-groupBuy.Price * userGroupBuy.BuyCount, 0, "参加团购活动:" + groupBuy.Name, userID, userName); ScriptHelper.Alert("购买成功!", "GroupBuyDetail.aspx?ID=" + userGroupBuy.GroupBuyID); }
/// <summary> /// 根据现有积分计算剩余积分 /// </summary> /// <param name="point">现有积分</param> /// <returns></returns> protected object ShowPointLeft(object id, object point) { int tmp = 0; int.TryParse(id.ToString(), out tmp); int tmpPoint = 0; int.TryParse(point.ToString(), out tmpPoint); return(UserAccountRecordBLL.ReadPointLeftBeforID(tmp, userID) + tmpPoint); }
/// <summary> /// 获取我的积分明细 /// </summary> /// <returns></returns> public ActionResult MyPoint(int pageIndex, int pageSize, int inCome) { pageIndex = pageIndex <= 0 ? 1 : pageIndex; pageSize = pageSize <= 0 ? 10 : pageSize; inCome = inCome > 0 ? 1 : 0; int count = 0; List <UserAccountRecordInfo> dataList = UserAccountRecordBLL.ReadList(pageIndex, pageSize, AccountRecordType.Point, user.Id, inCome, ref count); return(Json(new { ok = true, count = dataList.Count, datalist = dataList, user = user, enablePointPay = ShopConfig.ReadConfigInfo().EnablePointPay, pointToMoney = ShopConfig.ReadConfigInfo().PointToMoney }, JsonRequestBehavior.AllowGet)); }
public ActionResult UpdateUserInfo() { if (user.Id <= 0) { return(Json(new { ok = false, msg = "无效的请求" })); } else { string birthdayBeforeUpdate = user.Birthday; string realName = RequestHelper.GetForm <string>("realname"); string birthDay = RequestHelper.GetForm <string>("birthday"); string email = RequestHelper.GetForm <string>("email"); if (string.IsNullOrEmpty(realName)) { return(Json(new { ok = false, msg = "请填写真实姓名" })); } if (string.IsNullOrEmpty(birthDay)) { return(Json(new { ok = false, msg = "请填写生日" })); } if (Convert.ToDateTime(birthDay) >= DateTime.Now) { return(Json(new { ok = false, msg = "请填写真实生日" })); } if (!string.IsNullOrEmpty(email) && !ShopCommon.CheckEmail(email)) { return(Json(new { ok = false, msg = "邮箱格式错误" })); } Dictionary <string, object> dict = new Dictionary <string, object>(); dict.Add("[RealName]", StringHelper.Substring(realName, 18, false)); dict.Add("[Birthday]", StringHelper.Substring(birthDay, 30, false)); dict.Add("[Email]", StringHelper.Substring(email, 30, false)); UserBLL.UpdatePart("[usr]", dict, user.Id); //如果是首次填写生日信息则赠送积分20 if (string.IsNullOrEmpty(birthdayBeforeUpdate)) { UserAccountRecordInfo uar = new UserAccountRecordInfo { RecordType = (int)AccountRecordType.Point, Money = 0, Point = 20, Date = DateTime.Now, IP = ClientHelper.IP, Note = "填写生日赠送积分", UserId = user.Id, UserName = user.UserName }; if (UserAccountRecordBLL.Add(uar) > 0) { user.PointLeft += 20; } } return(Json(new { ok = true })); } }
public ActionResult BindMobile() { bool ok = false; string msg = string.Empty; int pointLeft = user.PointLeft; string mobileBefore = user.Mobile; try { string mobile = RequestHelper.GetForm <string>("mobile"); if (!string.IsNullOrEmpty(mobile)) { Dictionary <string, object> dict = new Dictionary <string, object>(); dict.Add("Mobile", mobile.Trim()); UserBLL.UpdatePart(UserInfo.TABLENAME, dict, user.Id); //首次绑定手机号默认赠送20积分 if (string.IsNullOrEmpty(mobileBefore)) { UserAccountRecordInfo uar = new UserAccountRecordInfo { RecordType = (int)AccountRecordType.Point, Money = 0, Point = 20, Date = DateTime.Now, IP = ClientHelper.IP, Note = "绑定手机号赠送积分", UserId = user.Id, UserName = user.UserName }; if (UserAccountRecordBLL.Add(uar) > 0) { user.PointLeft += 20; } } ok = true; pointLeft = user.PointLeft; } else { msg = "mobile empty"; } } catch (Exception ex) { ok = false; msg = ex.Message; } return(Json(new { ok = ok, msg = msg, pointleft = pointLeft })); }
private void OrderOperate() { string content = string.Empty; int queryString = RequestHelper.GetQueryString <int>("OrderID"); int num2 = RequestHelper.GetQueryString <int>("OrderStatus"); switch (num2) { case 1: case 2: case 5: { OrderInfo order = OrderBLL.ReadOrder(queryString, base.UserID); if (order.ID == 0) { content = "不是属于当前用户的订单"; } else { int orderStatus; if ((num2 == 2) || (num2 == 1)) { orderStatus = order.OrderStatus; order.OrderStatus = 3; ProductBLL.ChangeProductOrderCountByOrder(queryString, ChangeAction.Minus); OrderBLL.UserUpdateOrderAddAction(order, "用户取消订单", 3, orderStatus); } else { int point = OrderBLL.ReadOrderSendPoint(order.ID); if (point > 0) { UserAccountRecordBLL.AddUserAccountRecord(0M, point, ShopLanguage.ReadLanguage("OrderReceived").Replace("$OrderNumber", order.OrderNumber), order.UserID, order.UserName); } orderStatus = order.OrderStatus; order.OrderStatus = 6; OrderBLL.UserUpdateOrderAddAction(order, "用户确认收货", 5, orderStatus); } } break; } default: content = "订单状态错误"; break; } ResponseHelper.Write(content); ResponseHelper.End(); }
/// <summary> /// 取消活动,退还用户余额 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void CancleButton_Click(object sender, EventArgs e) { int groupBuyID = RequestHelper.GetQueryString <int>("GroupBuyID"); groupBuy = GroupBuyBLL.ReadGroupBuy(groupBuyID); List <UserGroupBuyInfo> userGroupBuyList = UserGroupBuyBLL.ReadUserGroupBuyList(groupBuyID); foreach (UserGroupBuyInfo userGroupBuy in userGroupBuyList) { if (userGroupBuy.OrderID == 0) { UserGroupBuyBLL.UpdateUserGroupBuy(userGroupBuy.ID, -1); UserAccountRecordBLL.AddUserAccountRecord(groupBuy.Price * userGroupBuy.BuyCount, 0, "退还团购活动支付余额:" + groupBuy.Name, userGroupBuy.UserID, userGroupBuy.UserName); } } ScriptHelper.Alert("处理成功", RequestHelper.RawUrl); }
/// <summary> /// 提交按钮点击方法 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void SubmitButton_Click(object sender, EventArgs e) { UserAccountRecordInfo uarInfo = new UserAccountRecordInfo(); uarInfo.UserId = RequestHelper.GetQueryString <int>("UserID"); //uarInfo.Money = Convert.ToDecimal(Money.Text); uarInfo.Point = Convert.ToInt32(Point.Text); uarInfo.Note = Note.Text; uarInfo.RecordType = (int)AccountRecordType.Point;//积分类型 uarInfo.IP = ClientHelper.IP; string alertMessage = ShopLanguage.ReadLanguage("AddOK"); CheckAdminPower("AddUserAccountRecord", PowerCheckType.Single); int id = UserAccountRecordBLL.Add(uarInfo); AdminLogBLL.Add(ShopLanguage.ReadLanguage("AddRecord"), ShopLanguage.ReadLanguage("UserAccountRecord"), id); ScriptHelper.Alert(alertMessage, RequestHelper.RawUrl); }
protected override void PageLoad() { base.PageLoad(); string displayType = RequestHelper.GetQueryString <string>("v"); if (displayType != "p" && displayType != "m") { ResponseHelper.End(); } isViewPoint = displayType == "p"; int currentPage = RequestHelper.GetQueryString <int>("Page"); if (currentPage < 1) { currentPage = 1; } int pageSize = 20; int count = 0; var recordType = isViewPoint ? AccountRecordType.Point : AccountRecordType.Money; userAccountRecordList = UserAccountRecordBLL.ReadList(currentPage, pageSize, recordType, base.UserId, ref count); // if (isViewPoint) { left = UserAccountRecordBLL.SumPoint(base.UserId); } else { if (!string.IsNullOrEmpty(CurrentUser.CardNo) && !string.IsNullOrEmpty(CurrentUser.CardPwd)) { bool isSuccess; string msg; //account = WebService.Account.GetAccount(CurrentUser.CardNo, CurrentUser.CardPwd, out isSuccess, out msg); //left = account.Acc; } } pager.Init(currentPage, pageSize, count, !string.IsNullOrEmpty(isMobile)); Title = isViewPoint ? "我的积分" : "我的余额"; }
/// <summary> /// 页面加载 /// </summary> protected override void PageLoad() { base.PageLoad(); action = RequestHelper.GetQueryString <string>("Action"); int currentPage = RequestHelper.GetQueryString <int>("Page"); if (currentPage < 1) { currentPage = 1; } int pageSize = 15; int count = 0; accountType = AccountRecordType.Point; if (action == "Money") { accountType = AccountRecordType.Money; } userAccountRecordList = UserAccountRecordBLL.ReadList(currentPage, pageSize, accountType, base.UserId, ref count); if (userAccountRecordList.Count > 0) { if (accountType == AccountRecordType.Money) { moneyLeft = UserAccountRecordBLL.ReadMoneyLeftBeforID(userAccountRecordList[0].Id, base.UserId); } else { pointLeft = UserAccountRecordBLL.ReadPointLeftBeforID(userAccountRecordList[0].Id, base.UserId); } } ajaxPagerClass.CurrentPage = currentPage; ajaxPagerClass.PageSize = pageSize; ajaxPagerClass.Count = count; ajaxPagerClass.FirstPage = "<<首页"; ajaxPagerClass.PreviewPage = "<<上一页"; ajaxPagerClass.NextPage = "下一页>>"; ajaxPagerClass.LastPage = "末页>>"; ajaxPagerClass.ListType = false; ajaxPagerClass.DisCount = false; ajaxPagerClass.PrenextType = true; }
protected void CheckPoint() { if (base.UserId == 0) { ResponseHelper.Write("还未登录"); ResponseHelper.End(); } int id = RequestHelper.GetQueryString <int>("Id"); var gift = PointProductBLL.Read(id); var memberPoint = UserAccountRecordBLL.SumPoint(base.UserId); if (gift.Point > memberPoint) { ResponseHelper.Write("您当前的积分不足以兑取该礼品"); } else { ResponseHelper.Write("ok"); } ResponseHelper.End(); }
/// <summary> /// 退款按钮点击方法【不支持】 /// </summary> protected void RefundButton_Click(object sender, EventArgs e) { OrderInfo order = ButtoStart(); //余额处理 decimal money = order.Balance; int isCod = PayPlugins.ReadPayPlugins(order.PayKey).IsCod; if (order.OrderStatus == (int)OrderStatus.HasReturn && isCod == (int)BoolType.False) { money += OrderBLL.ReadNoPayMoney(order); } else if (order.OrderStatus == (int)OrderStatus.NoEffect && OrderActionBLL.ReadLast(order.Id, order.OrderStatus).StartOrderStatus == (int)OrderStatus.WaitCheck && isCod == (int)BoolType.False) { money += OrderBLL.ReadNoPayMoney(order); } if (money > 0) { var accountRecord = new UserAccountRecordInfo { RecordType = (int)AccountRecordType.Money, Money = money, Point = 0, Date = DateTime.Now, IP = ClientHelper.IP, Note = "退还订单:" + order.OrderNumber + "的金额", UserId = order.UserId, UserName = order.UserName }; UserAccountRecordBLL.Add(accountRecord); } //更新订单 int startOrderStatus = order.OrderStatus; order.OrderStatus = (int)order.OrderStatus; order.Balance = 0; order.CouponMoney = 0; order.IsRefund = (int)BoolType.True; ButtonEnd(order, Note.Text, OrderOperate.Refund, startOrderStatus); }
protected override void PageLoad() { base.PageLoad(); string action = StringHelper.AddSafe(RequestHelper.GetQueryString <string>("Action")); if (action == "Submit") { this.Submit(); } if (action == "CheckPoint") { this.CheckPoint(); } int id = RequestHelper.GetQueryString <int>("Id"); if (base.UserId <= 0) { ResponseHelper.Redirect("/user/login.html?RedirectUrl=/pointexchange/" + id.ToString() + ".html"); ResponseHelper.End(); } gift = PointProductBLL.Read(id); if (gift.EndDate.Date < DateTime.Now.Date) { ResponseHelper.Redirect("/pointproduct.html"); } var currentUser = UserBLL.Read(base.UserId); userPoint = UserAccountRecordBLL.SumPoint(base.UserId); singleUnlimitClass.DataSource = RegionBLL.ReadRegionUnlimitClass(); singleUnlimitClass.ClassID = base.UserId > 0? currentUser.RegionId:"|1|"; Title = gift.Name + " - 积分商品兑换"; }
/// <summary> /// 提交按钮点击方法 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void SubmitButton_Click(object sender, EventArgs e) { //读取用户信息 userID = Cookies.User.GetUserID(true); int pointLeft = UserBLL.ReadUserMore(userID).PointLeft; string userName = Cookies.User.GetUserName(false); string userEmail = CookiesHelper.ReadCookieValue("UserEmail"); //检测积分 int id = RequestHelper.GetQueryString <int>("ID"); product = ProductBLL.ReadProduct(id); ExchangeAwardInfo exchangeAward = ExchangeAwardBLL.ReadConfigInfo(); int productPoint = 0; if (exchangeAward.PorudctIDList != string.Empty) { string[] productArray = exchangeAward.PorudctIDList.Split(','); string[] pointArray = exchangeAward.PointList.Split(','); for (int i = 0; i < productArray.Length; i++) { if (productArray[i] == id.ToString()) { productPoint = Convert.ToInt32(pointArray[i]); } } } if (productPoint > pointLeft) { ScriptHelper.Alert("您当前的积分不足以兑取该奖品", RequestHelper.RawUrl); } //添加订单 OrderInfo order = new OrderInfo(); order.OrderNumber = ShopCommon.CreateOrderNumber(); order.IsActivity = (int)BoolType.True; order.OrderStatus = (int)OrderStatus.WaitCheck; order.OrderNote = "积分兑换奖品"; order.ProductMoney = 0; order.Balance = 0; order.FavorableMoney = 0; order.OtherMoney = 0; order.CouponMoney = 0; order.Consignee = StringHelper.AddSafe(Consignee.Text); SingleUnlimitClass singleUnlimitClass = new SingleUnlimitClass(); order.RegionID = singleUnlimitClass.ClassID; order.Address = StringHelper.AddSafe(Address.Text); order.ZipCode = StringHelper.AddSafe(ZipCode.Text); order.Tel = StringHelper.AddSafe(Tel.Text); order.Email = userEmail; order.Mobile = StringHelper.AddSafe(Mobile.Text); order.ShippingID = 0; order.ShippingDate = RequestHelper.DateNow; order.ShippingNumber = string.Empty; order.ShippingMoney = 0; order.PayKey = string.Empty; order.PayName = string.Empty; order.PayDate = RequestHelper.DateNow;; order.IsRefund = (int)BoolType.False; order.FavorableActivityID = 0; order.GiftID = 0; order.InvoiceTitle = string.Empty; order.InvoiceContent = string.Empty; order.UserMessage = string.Empty; order.AddDate = RequestHelper.DateNow; order.IP = ClientHelper.IP; order.UserID = userID; order.UserName = userName; int orderID = OrderBLL.AddOrder(order); //添加订单详细 OrderDetailInfo orderDetail = new OrderDetailInfo(); orderDetail.OrderID = orderID; orderDetail.ProductID = product.ID; orderDetail.ProductName = product.Name; orderDetail.ProductWeight = product.Weight; orderDetail.SendPoint = 0; orderDetail.ProductPrice = 0; orderDetail.BuyCount = 1; orderDetail.FatherID = 0; orderDetail.RandNumber = string.Empty; orderDetail.GiftPackID = 0; OrderDetailBLL.AddOrderDetail(orderDetail); //积分操作 UserAccountRecordBLL.AddUserAccountRecord(0, -productPoint, "兑换奖品-" + product.Name, userID, userName); //更改产品库存订单数量 ProductBLL.ChangeProductOrderCountByOrder(orderID, ChangeAction.Plus); //保存记录 string fileName = StringHelper.Encode(ShopConfig.ReadConfigInfo().SecureKey, ShopConfig.ReadConfigInfo().SecureKey) + ".txt"; fileName = Server.MapPath("Admin/" + fileName); File.AppendAllText(fileName, userName + ",订单号:" + order.OrderNumber + ",商品:" + product.Name + "\r\n", System.Text.Encoding.Default); ScriptHelper.Alert("成功兑换", "/User/OrderDetail.aspx?ID=" + orderID.ToString()); }
private void Submit() { /*-----------重新验证选择的商品------------------------------------------*/ checkCart = StringHelper.AddSafe(RequestHelper.GetForm <string>("CheckCart")); int[] cartIds = Array.ConvertAll <string, int>(checkCart.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries), k => Convert.ToInt32(k)); string checkCartCookies = HttpUtility.UrlDecode(CookiesHelper.ReadCookieValue("CheckCart")); if (checkCart != checkCartCookies) { ResponseHelper.Write("error|购买商品发生了变化,请重新提交|" + isMobile + "/cart.html"); ResponseHelper.End(); } if (string.IsNullOrEmpty(checkCart) || cartIds.Length < 1) { ResponseHelper.Write("error|请选择需要购买的商品|" + isMobile + "/cart.html"); ResponseHelper.End(); } /*----------------------------------------------------------------------*/ /*-----------读取购物车清单---------------------------------------------*/ List <CartInfo> cartList = CartBLL.ReadList(base.UserId); cartList = cartList.Where(k => cartIds.Contains(k.Id)).ToList(); if (cartList.Count <= 0) { ResponseHelper.Write("error|请选择需要购买的商品|" + isMobile + "/cart.html"); ResponseHelper.End(); } /*----------------------------------------------------------------------*/ /*-----------必要性检查:收货地址,配送方式,支付方式-------------------*/ var address = new UserAddressInfo { Id = RequestHelper.GetForm <int>("address_id") }; var shipping = new ShippingInfo { Id = RequestHelper.GetForm <int>("ShippingId") }; var pay = new PayPluginsInfo { Key = StringHelper.AddSafe(RequestHelper.GetForm <string>("pay")) }; bool reNecessaryCheck = false; doReNecessaryCheck: if (address.Id < 1) { ResponseHelper.Write("error|请选择收货地址|"); ResponseHelper.End(); } if (shipping.Id < 1) { ResponseHelper.Write("error|请选择配送方式|"); ResponseHelper.End(); } if (string.IsNullOrEmpty(pay.Key)) { ResponseHelper.Write("error|请选择支付方式|"); ResponseHelper.End(); } //读取数据库中的数据,进行重复验证 if (!reNecessaryCheck) { address = UserAddressBLL.Read(address.Id, base.UserId); shipping = ShippingBLL.Read(shipping.Id); pay = PayPlugins.ReadPayPlugins(pay.Key); reNecessaryCheck = true; goto doReNecessaryCheck; } /*----------------------------------------------------------------------*/ /*-----------商品清单、商品总价、邮费价格、库存检查---------------------*/ decimal productMoney = 0; int count = 0; int[] ids = cartList.Select(k => k.ProductId).ToArray(); var products = ProductBLL.SearchList(1, ids.Length, new ProductSearchInfo { InProductId = string.Join(",", ids) }, ref count); foreach (var cart in cartList) { cart.Product = products.FirstOrDefault(k => k.Id == cart.ProductId) ?? new ProductInfo(); if (!string.IsNullOrEmpty(cart.StandardValueList)) { //使用规格的价格和库存 var standardRecord = ProductTypeStandardRecordBLL.Read(cart.ProductId, cart.StandardValueList); cart.Price = standardRecord.SalePrice; cart.LeftStorageCount = standardRecord.Storage - standardRecord.OrderCount; } else { cart.Price = cart.Product.SalePrice; cart.LeftStorageCount = cart.Product.TotalStorageCount - cart.Product.OrderCount; } //不需要检查库存,所有商品均可购买 ////检查库存 //if (cart.BuyCount > cart.LeftStorageCount) //{ // ResponseHelper.Write("error|商品[" + cart.ProductName + "]库存不足,无法购买|"); // ResponseHelper.End(); //} productMoney += cart.BuyCount * cart.Price; } decimal shippingMoney = 0; //首先根据ShopId分组,根据供应商的不同来分别计算运费 //然后将分拆后的供应商商品,按单个商品独立计算运费(相同商品购买多个则叠加计算) ShippingRegionInfo shippingRegion = ShippingRegionBLL.SearchShippingRegion(shipping.Id, address.RegionId); var shopIds = cartList.GroupBy(k => k.Product.ShopId).Select(k => k.Key).ToList(); foreach (var shopId in shopIds) { var shopCartList = cartList.Where(k => k.Product.ShopId == shopId).ToList(); foreach (var shopCartSplit in shopCartList) { shippingMoney += ShippingRegionBLL.ReadShippingMoney(shipping, shippingRegion, shopCartSplit); } } /*----------------------------------------------------------------------*/ int point = 0; decimal pointMoney = 0; /*-----------计算积分金额(不可使用积分)----------------------------------- * decimal totalRate = (decimal)ShopConfig.ReadConfigInfo().BuyPointTotalRate; * decimal pointRate = (decimal)ShopConfig.ReadConfigInfo().BuyPointMoneyRate; * int point = RequestHelper.GetForm<int>("point"); * decimal pointMoney = 0; * if (totalRate > 0 && pointRate > 0 && point > 0) * { * var member = WebService.Member.GetMember(); * decimal leftPoint = member.Point; * if (point > leftPoint) * { * ResponseHelper.Write("error|您的积分不足|"); * ResponseHelper.End(); * } * else * { * pointMoney = Math.Round(point / pointRate, 2); * * if (pointMoney > productMoney * totalRate) * { * ResponseHelper.Write("error|" + "您最多可以使用 " + (productMoney * totalRate * pointRate) + " 积分|"); * ResponseHelper.End(); * } * } * } * ------------------------------------------------------------------------*/ /*-----------应付总价---------------------------------------------------*/ //decimal payMoney = productMoney + shippingMoney - pointMoney; decimal payMoney = productMoney + shippingMoney; /*----------------------------------------------------------------------*/ var user = UserBLL.Read(base.UserId); /*-----------计算图楼卡余额---------------------------------------------*/ decimal balance = RequestHelper.GetForm <decimal>("money"); if (balance > 0) { bool isSuccess; string msg; isSuccess = true; msg = ""; //var account = WebService.Account.GetAccount(user.CardNo, user.CardPwd, out isSuccess, out msg); if (!isSuccess) { ResponseHelper.Write("error|" + msg + "|"); ResponseHelper.End(); } if (balance > 0 /*(account.Zacc + account.Sacc)*/) { ResponseHelper.Write("error|您的图楼卡余额不足|"); ResponseHelper.End(); } else { if (balance > payMoney) { ResponseHelper.Write("error|" + "您只需使用 " + payMoney + " 元即可支付订单|"); ResponseHelper.End(); } } } payMoney -= balance; /*----------------------------------------------------------------------*/ /*-----------检查金额---------------------------------------------------*/ if (payMoney < 0) { ResponseHelper.Write("error|金额有错误,请重新检查|"); ResponseHelper.End(); } /*----------------------------------------------------------------------*/ /*-----------组装基础订单模型,循环生成订单-----------------------------*/ OrderInfo order = new OrderInfo(); order.ProductMoney = productMoney; order.Consignee = address.Consignee; order.RegionId = address.RegionId; order.Address = address.Address; order.ZipCode = address.ZipCode; order.Tel = address.Tel; order.Mobile = address.Mobile; order.Email = CookiesHelper.ReadCookieValue("UserEmail"); order.ShippingId = shipping.Id; order.ShippingDate = RequestHelper.DateNow; order.ShippingMoney = shippingMoney; order.Point = point; order.PointMoney = pointMoney; order.Balance = balance; order.PayKey = pay.Key; order.PayName = pay.Name; order.PayDate = RequestHelper.DateNow; order.IsRefund = (int)BoolType.False; order.UserMessage = StringHelper.AddSafe(RequestHelper.GetForm <string>("msg")); order.AddDate = RequestHelper.DateNow; order.IP = ClientHelper.IP; order.UserId = base.UserId; order.UserName = base.UserName; //循环生成订单 var orderIds = SplitShopProduct(cartList, order); /*----------------------------------------------------------------------*/ var orders = OrderBLL.ReadList(orderIds.ToArray(), base.UserId); /*-----------如果使用了图楼卡支付,需同步到会员管理系统中---------------*/ /*第二步,在订单付款操作(用户端)中,同步图楼卡余额*/ if (balance > 0) { List <string[]> paras = new List <string[]>(); foreach (var oo in orders) { if (oo.Balance > 0 && oo.OrderStatus == (int)OrderStatus.WaitCheck) { string[] para = new string[2]; para[0] = oo.OrderNumber; para[1] = oo.Balance.ToString(); paras.Add(para); } } //如果有全额使用了图楼卡余额支付的订单,需同步到会员管理系统中 if (paras.Count > 0) { bool isSuccess; string msg; isSuccess = true; msg = ""; //WebService.Account.Purchase(user.CardNo, user.CardPwd, paras, out isSuccess, out msg); //同步失败,删除订单及相关信息 if (!isSuccess) { //删除订单、订单详细、订单状态相关数据 OrderBLL.Delete(orderIds.ToArray(), base.UserId); //更改产品库存订单数量 foreach (var orderId in orderIds) { ProductBLL.ChangeOrderCountByOrder(orderId, ChangeAction.Minus); } ResponseHelper.Write("error|" + msg + "|"); ResponseHelper.End(); } else { //记录用户余额消费记录 foreach (var par in paras) { var accountRecord = new UserAccountRecordInfo { RecordType = (int)AccountRecordType.Money, Money = -decimal.Parse(par[1]), Point = 0, Date = DateTime.Now, IP = ClientHelper.IP, Note = "支付订单:" + par[0], UserId = base.UserId, UserName = base.UserName }; UserAccountRecordBLL.Add(accountRecord); } } } } /*----------------------------------------------------------------------*/ /*-----------删除购物车中已下单的商品-----------------------------------*/ CartBLL.Delete(cartIds, base.UserId); CookiesHelper.DeleteCookie("CheckCart"); /*----------------------------------------------------------------------*/ /*如果所有订单均由图楼卡支付完成,则跳转到会员中心,否则跳转到支付提示页面*/ if (orders.Count(k => k.OrderStatus == (int)OrderStatus.WaitPay) > 0) { ResponseHelper.Write("ok||/finish.html?id=" + string.Join(",", orders.Select(k => k.Id).ToArray())); } else { ResponseHelper.Write("ok||/user/index.html"); } ResponseHelper.End(); /*----------------------------------------------------------------------*/ }
/// <summary> /// 完成确认按钮点击方法 /// </summary> protected void ReceivedButton_Click(object sender, EventArgs e) { OrderInfo order = ButtoStart(); #region 确认收货赠送优惠券 int count = 0; var couponlist = CouponBLL.SearchList(1, 1, new CouponSearchInfo { Type = (int)CouponKind.ReceiveShippingGet, CanUse = 1 }, ref count); if (couponlist.Count > 0) { UserCouponInfo userCoupon = UserCouponBLL.ReadLast(couponlist[0].Id); int startNumber = 0; if (userCoupon.Id > 0) { string tempNumber = userCoupon.Number.Substring(3, 5); while (tempNumber.Substring(0, 1) == "0") { tempNumber = tempNumber.Substring(1); } startNumber = Convert.ToInt32(tempNumber); } startNumber++; UserCouponBLL.Add(new UserCouponInfo { UserId = order.UserId, UserName = order.UserName, CouponId = couponlist[0].Id, GetType = (int)CouponType.ReceiveShippingGet, Number = ShopCommon.CreateCouponNo(couponlist[0].Id, startNumber), Password = ShopCommon.CreateCouponPassword(startNumber), IsUse = (int)BoolType.False, OrderId = 0 }); } #endregion #region 赠送积分 //赠送积分--根据商品信息填写的赠送积分额度 //int sendPoint = OrderBLL.ReadOrderSendPoint(order.Id); //根据订单付款金额全额返还积分 int sendPoint = (int)Math.Floor(OrderBLL.ReadNoPayMoney(order)); if (sendPoint > 0 && order.IsActivity == (int)BoolType.False) { var accountRecord = new UserAccountRecordInfo { RecordType = (int)AccountRecordType.Point, Money = 0, Point = sendPoint, Date = DateTime.Now, IP = ClientHelper.IP, Note = ShopLanguage.ReadLanguage("OrderReceived").Replace("$OrderNumber", order.OrderNumber), UserId = order.UserId, UserName = order.UserName }; UserAccountRecordBLL.Add(accountRecord); } #endregion #region 确认收货给分销商返佣 //订单实际支付金额 decimal paid_money = OrderBLL.ReadNoPayMoney(order); //购买人 var user = UserBLL.Read(order.UserId); //购买者有推荐人 且 实际支付金额大于0才进行返佣 if (user.Recommend_UserId > 0 && paid_money > 0) { RebateBLL.RebateToDistributor(user, paid_money, order.Id); } #endregion int startOrderStatus = order.OrderStatus; order.OrderStatus = (int)OrderStatus.ReceiveShipping; ButtonEnd(order, Note.Text, OrderOperate.Received, startOrderStatus); }
protected void Submit() { string userName = base.UserName; string userEmail = CookiesHelper.ReadCookieValue("UserEmail"); SingleUnlimitClass singleUnlimitClass = new SingleUnlimitClass(); //检测积分 int id = RequestHelper.GetForm <int>("updateId"); if (id < 1) { ResponseHelper.Write("error|无效的请求"); ResponseHelper.End(); } if (singleUnlimitClass.ClassID.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries).Length < 3) { ResponseHelper.Write("error|请填写完整的地区信息"); ResponseHelper.End(); ResponseHelper.End(); } var pointLeft = UserAccountRecordBLL.SumPoint(base.UserId); Gift = PointProductBLL.Read(id); if (Gift.Point > pointLeft) { ResponseHelper.Write("error|您当前的积分不足以兑取该礼品"); ResponseHelper.End(); } //库存 int num = RequestHelper.GetForm <int>("num"); if (num > (Gift.TotalStorageCount - Gift.SendCount)) { ResponseHelper.Write("error|该礼品库存不足"); ResponseHelper.End(); } //添加订单 OrderInfo order = new OrderInfo(); order.OrderNumber = ShopCommon.CreateOrderNumber(); order.IsActivity = (int)BoolType.True; order.OrderStatus = (int)OrderStatus.WaitCheck; order.OrderNote = "积分兑换奖品"; order.ProductMoney = 0; order.Balance = 0; order.FavorableMoney = 0; order.OtherMoney = 0; order.CouponMoney = 0; order.Consignee = StringHelper.AddSafe(RequestHelper.GetForm <string>("username")); order.RegionId = singleUnlimitClass.ClassID; order.Address = StringHelper.AddSafe(RequestHelper.GetForm <string>("address")); order.ZipCode = StringHelper.AddSafe(RequestHelper.GetForm <string>("zipcode")); order.Tel = StringHelper.AddSafe(RequestHelper.GetForm <string>("tel")); order.Email = userEmail; order.Mobile = StringHelper.AddSafe(RequestHelper.GetForm <string>("mobile")); order.ShippingId = 0; order.ShippingDate = RequestHelper.DateNow; order.ShippingNumber = string.Empty; order.ShippingMoney = 0; order.PayKey = string.Empty; order.PayName = string.Empty; order.PayDate = RequestHelper.DateNow;; order.IsRefund = (int)BoolType.False; order.FavorableActivityId = 0; order.GiftId = 0; order.InvoiceTitle = string.Empty; order.InvoiceContent = string.Empty; order.UserMessage = string.Empty; order.AddDate = RequestHelper.DateNow; order.IP = ClientHelper.IP; order.UserId = base.UserId; order.UserName = userName; order.ActivityPoint = Gift.Point * num; int orderID = OrderBLL.Add(order); //添加订单详细 OrderDetailInfo orderDetail = new OrderDetailInfo(); orderDetail.OrderId = orderID; orderDetail.ProductId = Gift.Id; orderDetail.ProductName = Gift.Name; orderDetail.ProductWeight = Gift.Weight; orderDetail.SendPoint = 0; orderDetail.ProductPrice = 0; orderDetail.ActivityPoint = Gift.Point; orderDetail.BuyCount = num; orderDetail.ParentId = 0; orderDetail.RandNumber = string.Empty; orderDetail.GiftPackId = 0; OrderDetailBLL.Add(orderDetail); //积分记录 var accountRecord = new UserAccountRecordInfo { Money = 0, Point = -Gift.Point * num, Date = DateTime.Now, IP = ClientHelper.IP, Note = "兑换礼品-" + Gift.Name, UserId = base.UserId, UserName = base.UserName }; UserAccountRecordBLL.Add(accountRecord); //更新商品的已兑换数量 Dictionary <string, object> dict = new Dictionary <string, object>(); dict.Add("SendCount", Gift.SendCount + num); PointProductBLL.UpdatePart(PointProductInfo.TABLENAME, dict, Gift.Id); ResponseHelper.Write("ok|" + orderID); ResponseHelper.End(); }
public override void ProcessNotify() { WxPayData notifyData = GetNotifyData(); //检查支付结果中transaction_id是否存在 if (!notifyData.IsSet("transaction_id")) { //若transaction_id不存在,则立即返回结果给微信支付后台 WxPayData res = new WxPayData(); res.SetValue("return_code", "FAIL"); res.SetValue("return_msg", "支付结果中微信订单号不存在"); Log.Error(this.GetType().ToString(), "The Pay result is error : " + res.ToXml()); //page.Response.Write(res.ToXml()); //page.Response.End(); } else { string transaction_id = notifyData.GetValue("transaction_id").ToString(); //查询订单,判断订单真实性 if (!QueryOrder(transaction_id)) ////沙箱测试只能用out_trade_no //if (notifyData.IsSet("out_trade_no") && !QueryOrderByout_trade_no(notifyData.GetValue("out_trade_no").ToString())) { //若订单查询失败,则立即返回结果给微信支付后台 WxPayData res = new WxPayData(); res.SetValue("return_code", "FAIL"); res.SetValue("return_msg", "订单查询失败"); Log.Error(this.GetType().ToString(), "Order query failure : " + res.ToXml()); //page.Response.Write(res.ToXml()); //page.Response.End(); } //查询订单成功 else { Log.Debug(this.GetType().ToString(), "订单查询成功 "); /************在这里加入商户自己的逻辑***********************************************************/ //attach:以逗号分开的订单Id字符串,与支付时提交的数据一致 if (notifyData.IsSet("attach")) { string attach = notifyData.GetValue("attach").ToString(); string[] orderIds = attach.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (string orderId in orderIds) { var order = OrderBLL.Read(int.Parse(orderId)); if (order.Id > 0) { #region 正常流程 待付款--》待审核 if (order.OrderStatus == (int)OrderStatus.WaitPay) { order.PayKey = "WxPay"; order.PayName = "微信支付"; order.WxPayTradeNo = transaction_id; //沙箱测试用out_trade_no //order.WxPayTradeNo = notifyData.GetValue("out_trade_no").ToString(); order.OrderStatus = (int)OrderStatus.WaitCheck; order.PayDate = RequestHelper.DateNow; OrderBLL.Update(order); #region 拼团订单付款:团长付款--开团+增加参团记录;成员付款--增加参团记录 if (order.IsActivity == (int)OrderKind.GroupBuy) { var orderDetail = OrderDetailBLL.ReadList(order.Id).FirstOrDefault() ?? new OrderDetailInfo(); if (orderDetail.Id > 0) { var product = ProductBLL.Read(orderDetail.ProductId); //团长付款 if (order.FavorableActivityId <= 0) { //开团 int groupId = GroupBuyBLL.Add(new GroupBuyInfo { Leader = order.UserId, ProductId = product.Id, StartTime = DateTime.Now, EndTime = DateTime.Now.AddDays(ShopConfig.ReadConfigInfo().GroupBuyDays), Quantity = product.GroupQuantity, //团购订单支付成功之后计数加1 SignCount = 1 }); //订单绑定团购Id Dictionary <string, object> dict = new Dictionary <string, object>(); dict.Add("[FavorableActivityId]", groupId); OrderBLL.UpdatePart("[Order]", dict, order.Id); //增加参团记录 GroupSignBLL.Add(new GroupSignInfo { GroupId = groupId, UserId = order.UserId, OrderId = order.Id, SignTime = DateTime.Now }); } else//参团者付款--放到参团者checkout { ////增加参团记录 //GroupSignBLL.Add(new GroupSignInfo //{ // GroupId = order.FavorableActivityId, // UserId = order.UserId, // OrderId = order.Id, // SignTime = DateTime.Now //}); ////开团表signcount加1 //GroupBuyBLL.PlusSignCount(order.FavorableActivityId); } } } #endregion #region 自提订单 生成提货码 //避免重复数据,一个订单对应一个提货码,提货码没有有效期,使用过后失效 if (order.SelfPick == 1 && PickUpCodeBLL.ReadByOrderId(order.Id).Id <= 0) { PickUpCodeInfo pkCode = new PickUpCodeInfo(); pkCode.OrderId = order.Id; pkCode.Status = 0; pkCode.PickCode = PickUpCodeBLL.CreatePickUpCode(); int pickCodeId = PickUpCodeBLL.Add(pkCode); } #endregion #region 价订单 if (order.IsActivity == (int)OrderKind.Bargain) { BargainOrderBLL.HandleBargainOrderPay(order.FavorableActivityId); } #endregion //发送订单支付成功通知 SendPayOrderMsg(order); //增加操作记录 OrderActionInfo orderAction = new OrderActionInfo(); orderAction.OrderId = order.Id; orderAction.OrderOperate = (int)OrderOperate.Pay; orderAction.StartOrderStatus = (int)OrderStatus.WaitPay; orderAction.EndOrderStatus = (int)OrderStatus.WaitCheck; orderAction.Note = "客户微信在线支付"; orderAction.IP = ClientHelper.IP; orderAction.Date = RequestHelper.DateNow; orderAction.AdminID = 0; orderAction.AdminName = string.Empty; OrderActionBLL.Add(orderAction); } #endregion #region 非正常流程 待付款超时已失效(未退款)--》待审核 if (order.OrderStatus == (int)OrderStatus.NoEffect && order.IsRefund == 0) { order.PayKey = "WxPay"; order.PayName = "微信支付"; order.WxPayTradeNo = transaction_id; order.OrderStatus = (int)OrderStatus.WaitCheck; order.PayDate = RequestHelper.DateNow; OrderBLL.Update(order); #region 拼团订单付款:团长付款--开团+增加参团记录;成员付款--增加参团记录 if (order.IsActivity == (int)OrderKind.GroupBuy) { var orderDetail = OrderDetailBLL.ReadList(order.Id).FirstOrDefault() ?? new OrderDetailInfo(); if (orderDetail.Id > 0) { var product = ProductBLL.Read(orderDetail.ProductId); //团长付款 if (order.FavorableActivityId <= 0) { //开团 int groupId = GroupBuyBLL.Add(new GroupBuyInfo { Leader = order.UserId, ProductId = product.Id, StartTime = DateTime.Now, EndTime = DateTime.Now.AddDays(ShopConfig.ReadConfigInfo().GroupBuyDays), Quantity = product.GroupQuantity, //团购订单支付成功之后计数加1 SignCount = 1 }); //订单绑定团购Id Dictionary <string, object> dict = new Dictionary <string, object>(); dict.Add("[FavorableActivityId]", groupId); OrderBLL.UpdatePart("[Order]", dict, order.Id); //增加参团记录 GroupSignBLL.Add(new GroupSignInfo { GroupId = groupId, UserId = order.UserId, OrderId = order.Id, SignTime = DateTime.Now }); } else//参团者付款--放到参团者checkout { ////增加参团记录 //GroupSignBLL.Add(new GroupSignInfo //{ // GroupId = order.FavorableActivityId, // UserId = order.UserId, // OrderId = order.Id, // SignTime = DateTime.Now //}); ////开团表signcount加1 //GroupBuyBLL.PlusSignCount(order.FavorableActivityId); } } } #endregion #region 自提订单 生成提货码 //避免重复数据,一个订单对应一个提货码,提货码没有有效期,使用过后失效 if (order.SelfPick == 1 && PickUpCodeBLL.ReadByOrderId(order.Id).Id <= 0) { PickUpCodeInfo pkCode = new PickUpCodeInfo(); pkCode.OrderId = order.Id; pkCode.Status = 0; pkCode.PickCode = PickUpCodeBLL.CreatePickUpCode(); int pickCodeId = PickUpCodeBLL.Add(pkCode); } #endregion #region 价订单 if (order.IsActivity == (int)OrderKind.Bargain) { BargainOrderBLL.HandleBargainOrderPay(order.FavorableActivityId); } #endregion #region 扣除支付积分 if (order.Point > 0) { //减少积分 UserAccountRecordInfo uarInfo = new UserAccountRecordInfo(); uarInfo.RecordType = (int)AccountRecordType.Point; uarInfo.UserId = order.UserId; uarInfo.UserName = order.UserName; uarInfo.Note = "支付订单:" + order.OrderNumber; uarInfo.Point = -order.Point; uarInfo.Money = 0; uarInfo.Date = DateTime.Now; uarInfo.IP = ClientHelper.IP; UserAccountRecordBLL.Add(uarInfo); } #endregion #region 减少商品库存 ProductBLL.ChangeOrderCountByOrder(order.Id, ChangeAction.Plus); #endregion //发送订单支付成功通知 SendPayOrderMsg(order); //增加操作记录 OrderActionInfo orderAction = new OrderActionInfo(); orderAction.OrderId = order.Id; orderAction.OrderOperate = (int)OrderOperate.Pay; orderAction.StartOrderStatus = (int)OrderStatus.WaitPay; orderAction.EndOrderStatus = (int)OrderStatus.WaitCheck; orderAction.Note = "客户微信在线支付"; orderAction.IP = ClientHelper.IP; orderAction.Date = RequestHelper.DateNow; orderAction.AdminID = 0; orderAction.AdminName = string.Empty; OrderActionBLL.Add(orderAction); } #endregion //记录微信支付交易单号 if (order.OrderStatus == (int)OrderStatus.WaitCheck && string.IsNullOrEmpty(order.WxPayTradeNo)) { order.WxPayTradeNo = transaction_id; OrderBLL.Update(order); } notifyResult = true; } } } /************在这里加入商户自己的逻辑***********************************************************/ WxPayData res = new WxPayData(); res.SetValue("return_code", "SUCCESS"); res.SetValue("return_msg", "OK"); Log.Info(this.GetType().ToString(), "order query success : " + res.ToXml()); //page.Response.Write(res.ToXml()); //page.Response.End(); } } }
/// <summary> /// 提交数据 /// </summary> protected override void PostBack() { string url = "/Mobile/CheckOut.html"; //检查地址 string consignee = StringHelper.AddSafe(RequestHelper.GetForm <string>("Consignee")); if (consignee == string.Empty) { ScriptHelper.AlertFront("收货人姓名不能为空", url); } string tel = StringHelper.AddSafe(RequestHelper.GetForm <string>("Tel")); string mobile = StringHelper.AddSafe(RequestHelper.GetForm <string>("Mobile")); if (tel == string.Empty && mobile == string.Empty) { ScriptHelper.AlertFront("固定电话,手机必须得填写一个", url); } string zipCode = StringHelper.AddSafe(RequestHelper.GetForm <string>("ZipCode")); string address = StringHelper.AddSafe(RequestHelper.GetForm <string>("Address")); if (address == string.Empty) { ScriptHelper.AlertFront("地址不能为空", url); } //验证配送方式 int shippingID = RequestHelper.GetForm <int>("ShippingID"); if (shippingID == int.MinValue) { ScriptHelper.AlertFront("请选择配送方式", url); } //检查金额 decimal productMoney = 0; #region 计算订单金额 checkCart = HttpUtility.UrlDecode(CookiesHelper.ReadCookieValue("CheckCart")); int[] cartIds = Array.ConvertAll <string, int>(checkCart.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries), k => Convert.ToInt32(k)); cartList = CartBLL.ReadList(base.UserId); cartList = cartList.Where(k => cartIds.Contains(k.Id)).ToList(); if (cartList.Count < 1) { ResponseHelper.Redirect("/Mobile/cart.html"); ResponseHelper.End(); } //关联的商品 int count = 0; int[] ids = cartList.Select(k => k.ProductId).ToArray(); var products = ProductBLL.SearchList(1, ids.Length, new ProductSearchInfo { InProductId = string.Join(",", ids) }, ref count); //规格与库存判断 foreach (var cart in cartList) { cart.Product = products.FirstOrDefault(k => k.Id == cart.ProductId) ?? new ProductInfo(); if (!string.IsNullOrEmpty(cart.StandardValueList)) { //使用规格的价格和库存 var standardRecord = ProductTypeStandardRecordBLL.Read(cart.ProductId, cart.StandardValueList); int leftStorageCount = standardRecord.Storage - OrderDetailBLL.GetOrderCount(cart.ProductId, cart.StandardValueList); if (leftStorageCount >= cart.BuyCount) { cart.Price = standardRecord.SalePrice; cart.LeftStorageCount = leftStorageCount; //规格集合 cart.Standards = ProductTypeStandardBLL.ReadList(Array.ConvertAll <string, int>(standardRecord.StandardIdList.Split(';'), k => Convert.ToInt32(k))); } else { ScriptHelper.AlertFront("您购物车中 " + cart.Product.Name + " 库存不足,请重新选择", "/Mobile/Cart.html"); } } else { int leftStorageCount = cart.Product.TotalStorageCount - OrderDetailBLL.GetOrderCount(cart.ProductId, cart.StandardValueList); if (leftStorageCount >= cart.BuyCount) { cart.Price = cart.Product.SalePrice; cart.LeftStorageCount = leftStorageCount; } else { ScriptHelper.AlertFront("您购物车中 " + cart.Product.Name + " 库存不足,请重新选择", "/Mobile/Cart.html"); } } } #endregion productMoney = cartList.Sum(k => k.BuyCount * k.Price); decimal favorableMoney = 0; decimal shippingMoney = 0; #region 计算运费与优惠金额 string regionID = RequestHelper.GetForm <string>("RegionID"); //计算配送费用 ShippingInfo shipping = ShippingBLL.Read(shippingID); ShippingRegionInfo shippingRegion = ShippingRegionBLL.SearchShippingRegion(shippingID, regionID); switch (shipping.ShippingType) { case (int)ShippingType.Fixed: shippingMoney = shippingRegion.FixedMoeny; break; case (int)ShippingType.Weight: decimal cartProductWeight = Sessions.ProductTotalWeight; if (cartProductWeight <= shipping.FirstWeight) { shippingMoney = shippingRegion.FirstMoney; } else { shippingMoney = shippingRegion.FirstMoney + Math.Ceiling((cartProductWeight - shipping.FirstWeight) / shipping.AgainWeight) * shippingRegion.AgainMoney; } break; case (int)ShippingType.ProductCount: int cartProductCount = Sessions.ProductBuyCount; shippingMoney = shippingRegion.OneMoeny + (cartProductCount - 1) * shippingRegion.AnotherMoeny; break; default: break; } //计算优惠费用 FavorableActivityInfo favorableActivity = FavorableActivityBLL.Read(DateTime.Now, DateTime.Now, 0); if (favorableActivity.Id > 0) { if (("," + favorableActivity.UserGrade + ",").IndexOf("," + base.GradeID.ToString() + ",") > -1 && Sessions.ProductTotalPrice >= favorableActivity.OrderProductMoney) { switch (favorableActivity.ReduceWay) { case (int)FavorableMoney.Money: favorableMoney += favorableActivity.ReduceMoney; break; case (int)FavorableMoney.Discount: favorableMoney += Sessions.ProductTotalPrice * (10 - favorableActivity.ReduceDiscount) / 10; break; default: break; } if (favorableActivity.ShippingWay == (int)FavorableShipping.Free && ShippingRegionBLL.IsRegionIn(regionID, favorableActivity.RegionId)) { favorableMoney += shippingMoney; } } } #endregion decimal balance = RequestHelper.GetForm <decimal>("Balance"); moneyLeft = UserBLL.ReadUserMore(base.UserId).MoneyLeft; if (balance > moneyLeft) { balance = 0; ScriptHelper.AlertFront("金额有错误,请重新检查", url); } decimal couponMoney = 0; string userCouponStr = RequestHelper.GetForm <string>("UserCoupon"); UserCouponInfo userCoupon = new UserCouponInfo(); if (userCouponStr != string.Empty) { int couponID = 0; if (int.TryParse(userCouponStr.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries)[0], out couponID)) { userCoupon = UserCouponBLL.Read(couponID, base.UserId); if (userCoupon.UserId == base.UserId && userCoupon.IsUse == 0) { couponMoney = CouponBLL.Read(userCoupon.CouponId).Money; } } } if (productMoney - favorableMoney + shippingMoney - balance - couponMoney < 0) { ScriptHelper.AlertFront("金额有错误,请重新检查", url); } //支付方式 string payKey = RequestHelper.GetForm <string>("Pay"); PayPluginsInfo payPlugins = PayPlugins.ReadPayPlugins(payKey); //添加订单 OrderInfo order = new OrderInfo(); order.OrderNumber = ShopCommon.CreateOrderNumber(); order.IsActivity = (int)BoolType.False; if (productMoney - favorableMoney + shippingMoney - balance - couponMoney == 0 || payPlugins.IsCod == (int)BoolType.True) { order.OrderStatus = (int)OrderStatus.WaitCheck; } else { order.OrderStatus = (int)OrderStatus.WaitPay; } order.OrderNote = string.Empty; order.ProductMoney = productMoney; order.Balance = balance; order.FavorableMoney = favorableMoney; order.OtherMoney = 0; order.CouponMoney = couponMoney; order.Consignee = consignee; SingleUnlimitClass singleUnlimitClass = new SingleUnlimitClass(); order.RegionId = singleUnlimitClass.ClassID; order.Address = address; order.ZipCode = zipCode; order.Tel = tel; if (base.UserId == 0) { order.Email = StringHelper.AddSafe(RequestHelper.GetForm <string>("Email")); } else { order.Email = CookiesHelper.ReadCookieValue("UserEmail"); } order.Mobile = mobile; order.ShippingId = shippingID; order.ShippingDate = RequestHelper.DateNow; order.ShippingNumber = string.Empty; order.ShippingMoney = shippingMoney; order.PayKey = payKey; order.PayName = payPlugins.Name; order.PayDate = RequestHelper.DateNow;; order.IsRefund = (int)BoolType.False; order.FavorableActivityId = RequestHelper.GetForm <int>("FavorableActivityID"); order.GiftId = RequestHelper.GetForm <int>("GiftID"); order.InvoiceTitle = StringHelper.AddSafe(RequestHelper.GetForm <string>("InvoiceTitle")); order.InvoiceContent = StringHelper.AddSafe(RequestHelper.GetForm <string>("InvoiceContent")); order.UserMessage = StringHelper.AddSafe(RequestHelper.GetForm <string>("UserMessage")); order.AddDate = RequestHelper.DateNow; order.IP = ClientHelper.IP; order.UserId = base.UserId; order.UserName = base.UserName; int orderID = OrderBLL.Add(order); //使用余额 if (balance > 0) { UserAccountRecordInfo userAccountRecord = new UserAccountRecordInfo(); userAccountRecord.Money = -balance; userAccountRecord.Point = 0; userAccountRecord.Date = RequestHelper.DateNow; userAccountRecord.IP = ClientHelper.IP; userAccountRecord.Note = "支付订单:"; userAccountRecord.UserId = base.UserId; userAccountRecord.UserName = base.UserName; UserAccountRecordBLL.Add(userAccountRecord); } //使用优惠券 string strUserCoupon = RequestHelper.GetForm <string>("UserCoupon"); if (couponMoney > 0 && strUserCoupon != "0|0") { userCoupon.IsUse = (int)BoolType.True; userCoupon.OrderId = orderID; UserCouponBLL.Update(userCoupon); } AddOrderProduct(orderID); //更改产品库存订单数量 ProductBLL.ChangeOrderCountByOrder(orderID, ChangeAction.Plus); ResponseHelper.Redirect("/Mobile/Finish-I" + orderID.ToString() + ".html"); }
/// <summary> /// 撤销按钮点击方法 /// </summary> protected void BackButton_Click(object sender, EventArgs e) { OrderInfo order = ButtoStart(); int startOrderStatus = order.OrderStatus; order.OrderStatus = OrderActionBLL.ReadLast(order.Id, order.OrderStatus).StartOrderStatus; //减去用户积分,积分为负数 int sendPoint = 0; if (startOrderStatus == (int)OrderStatus.ReceiveShipping && order.IsActivity == (int)BoolType.False) { //sendPoint = -OrderBLL.ReadOrderSendPoint(order.Id); //根据订单付款金额全额返还积分 sendPoint = -(int)Math.Floor(OrderBLL.ReadNoPayMoney(order)); } if (startOrderStatus == (int)OrderStatus.HasShipping && order.OrderStatus == (int)OrderStatus.ReceiveShipping && order.IsActivity == (int)BoolType.False)//相当于收货确认 { //sendPoint = OrderBLL.ReadOrderSendPoint(order.Id); //根据订单付款金额全额返还积分 sendPoint = -(int)Math.Floor(OrderBLL.ReadNoPayMoney(order)); } if (sendPoint != 0) { var accountRecord = new UserAccountRecordInfo { RecordType = (int)AccountRecordType.Point, Money = 0, Point = sendPoint, Date = DateTime.Now, IP = ClientHelper.IP, Note = ShopLanguage.ReadLanguage("OrderBack").Replace("$OrderNumber", order.OrderNumber), UserId = order.UserId, UserName = order.UserName }; UserAccountRecordBLL.Add(accountRecord); } //更新商品库存数量 switch (startOrderStatus) { case (int)OrderStatus.WaitPay: case (int)OrderStatus.WaitCheck: if (order.OrderStatus == (int)OrderStatus.NoEffect) //相当于取消操作 { ProductBLL.ChangeOrderCountByOrder(order.Id, ChangeAction.Minus); } break; case (int)OrderStatus.NoEffect: ProductBLL.ChangeOrderCountByOrder(order.Id, ChangeAction.Plus); break; case (int)OrderStatus.HasReturn: ProductBLL.ChangeOrderCountByOrder(order.Id, ChangeAction.Plus); ProductBLL.ChangeSendCountByOrder(order.Id, ChangeAction.Plus); break; case (int)OrderStatus.Shipping: if (order.OrderStatus == (int)OrderStatus.HasShipping) { ProductBLL.ChangeSendCountByOrder(order.Id, ChangeAction.Plus); } break; case (int)OrderStatus.HasShipping: if (order.OrderStatus == (int)OrderStatus.Shipping) { ProductBLL.ChangeSendCountByOrder(order.Id, ChangeAction.Minus); } if (order.OrderStatus == (int)OrderStatus.HasReturn) //相当于退货确认操作 { ProductBLL.ChangeOrderCountByOrder(order.Id, ChangeAction.Minus); ProductBLL.ChangeSendCountByOrder(order.Id, ChangeAction.Minus); } break; default: break; } //更新订单 ButtonEnd(order, Note.Text, OrderOperate.Back, startOrderStatus); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { CheckAdminPower("ManagePointProductOrder", PowerCheckType.Single); string action = RequestHelper.GetQueryString <string>("Action"); if (action == "Shipping") { int shippingId = RequestHelper.GetForm <int>("OrderId"); string shippingName = RequestHelper.GetForm <string>("ShippingName"); string shippingNumber = RequestHelper.GetForm <string>("ShippingNumber"); var pointProductOrder = PointProductOrderBLL.Read(shippingId); if (pointProductOrder.OrderStatus == (int)PointProductOrderStatus.Shipping) { pointProductOrder.OrderStatus = (int)PointProductOrderStatus.HasShipping; pointProductOrder.ShippingName = shippingName; pointProductOrder.ShippingNumber = shippingNumber; pointProductOrder.ShippingDate = DateTime.Now; PointProductOrderBLL.Update(pointProductOrder); } ResponseHelper.End(); } if (action == "Cancel") { int orderId = RequestHelper.GetQueryString <int>("OrderId"); var pointProductOrder = PointProductOrderBLL.Read(orderId); if (pointProductOrder.OrderStatus == (int)PointProductOrderStatus.Shipping) { pointProductOrder.OrderStatus = (int)PointProductOrderStatus.Cancel; PointProductOrderBLL.Update(pointProductOrder); //恢复用户积分 UserAccountRecordBLL.Add(new UserAccountRecordInfo { RecordType = (int)AccountRecordType.Point, Money = 0, Point = pointProductOrder.Point, Date = DateTime.Now, IP = ClientHelper.IP, Note = "取消兑取礼品:" + pointProductOrder.ProductName + " 订单号:" + pointProductOrder.OrderNumber, UserId = pointProductOrder.UserId, UserName = pointProductOrder.UserName }); //恢复兑换数量 PointProductBLL.ChangeSendCount(pointProductOrder.ProductId, ChangeAction.Minus); } ResponseHelper.End(); } orderStatus = RequestHelper.GetQueryString <int>("OrderStatus"); hOrderStatus.Value = orderStatus.ToString(); PointProductOrderSearchInfo searchInfo = new PointProductOrderSearchInfo(); searchInfo.OrderStatus = orderStatus; searchInfo.ProductName = RequestHelper.GetQueryString <string>("ProductName"); searchInfo.OrderNumber = RequestHelper.GetQueryString <string>("OrderNumber"); searchInfo.UserName = RequestHelper.GetQueryString <string>("UserName"); searchInfo.StartAddDate = RequestHelper.GetQueryString <DateTime>("StartAddDate"); searchInfo.EndAddDate = ShopCommon.SearchEndDate(RequestHelper.GetQueryString <DateTime>("EndAddDate")); var data = PointProductOrderBLL.SearchList(CurrentPage, PageSize, searchInfo, ref Count); ProductName.Text = searchInfo.ProductName; OrderNumber.Text = searchInfo.OrderNumber; UserName.Text = searchInfo.UserName; StartAddDate.Text = RequestHelper.GetQueryString <string>("StartAddDate"); EndAddDate.Text = RequestHelper.GetQueryString <string>("EndAddDate"); BindControl(data, RecordList, MyPager); } }
protected void Page_Load(object sender, EventArgs e) { PayConfig payConfig = new PayConfig(); string alipayNotifyURL = "https://www.alipay.com/cooperate/gateway.do?"; string key = payConfig.SecurityKey; //partner 的对应交易安全校验码(必须填写) string _input_charset = "utf-8"; string partner = payConfig.Partner; //partner合作伙伴id(必须填写) alipayNotifyURL = alipayNotifyURL + "service=notify_verify" + "&partner=" + partner + "¬ify_id=" + Request.QueryString["notify_id"]; //获取支付宝ATN返回结果,true是正确的订单信息,false 是无效的 string responseTxt = Get_Http(alipayNotifyURL, 120000); int i; NameValueCollection coll = Request.QueryString; String[] requestarr = coll.AllKeys; //进行排序; string[] Sortedstr = BubbleSort(requestarr); //构造待md5摘要字符串 ; StringBuilder prestr = new StringBuilder(); for (i = 0; i < Sortedstr.Length; i++) { if (Request.Form[Sortedstr[i]] != "" && Sortedstr[i] != "sign" && Sortedstr[i] != "sign_type") { if (i == Sortedstr.Length - 1) { prestr.Append(Sortedstr[i] + "=" + Request.QueryString[Sortedstr[i]]); } else { prestr.Append(Sortedstr[i] + "=" + Request.QueryString[Sortedstr[i]] + "&"); } } } prestr.Append(key); //生成Md5摘要; string mysign = GetMD5(prestr.ToString(), _input_charset); string sign = Request.QueryString["sign"]; if (mysign == sign && responseTxt == "true") //验证支付发过来的消息,签名是否正确 { //更新数据库的订单语句 message = "成功付款"; string orderNumber = RequestHelper.GetQueryString <string>("out_trade_no"); OrderInfo order = OrderBLL.ReadOrderByNumber(orderNumber, 0); if (order.ID > 0) { if (order.OrderStatus == (int)OrderStatus.WaitPay) { order.OrderStatus = (int)OrderStatus.WaitCheck; OrderBLL.UpdateOrder(order); //增加操作记录 OrderActionInfo orderAction = new OrderActionInfo(); orderAction.OrderID = order.ID; orderAction.OrderOperate = (int)OrderOperate.Pay; orderAction.StartOrderStatus = (int)OrderStatus.WaitPay; orderAction.EndOrderStatus = (int)OrderStatus.WaitCheck; orderAction.Note = "客户支付宝在线支付"; orderAction.IP = ClientHelper.IP; orderAction.Date = RequestHelper.DateNow; orderAction.AdminID = 0; orderAction.AdminName = string.Empty; OrderActionBLL.AddOrderAction(orderAction); message = "您已经成功支付订单:" + orderNumber; } } else { UserRechargeInfo userRecharge = UserRechargeBLL.ReadUserRechargeByNumber(orderNumber, 0); if (userRecharge.ID > 0 && userRecharge.IsFinish == (int)BoolType.False) { userRecharge.IsFinish = (int)BoolType.True; UserRechargeBLL.UpdateUserRecharge(userRecharge); //账户记录 string note = "支付宝在线冲值:" + userRecharge.Number; UserAccountRecordBLL.AddUserAccountRecord(userRecharge.Money, 0, note, userRecharge.UserID, userRecharge.UserName); message = "您的冲值已经成功完成"; } } } else { message = "支付订单出现问题"; } }
protected void Page_Load(object sender, EventArgs e) { string suchtml = "<meta content=\"China TENCENT\" name=\"TENCENT_ONLINE_PAYMENT\">\n" + "<script language=\"javascript\">\n" + "window.location.href='http://" + Request.ServerVariables["Http_Host"] + "/Plugins/Pay/TenPay/Show.aspx';\n" + "</script>"; string errmsg = ""; PayConfig payConfig = new PayConfig(); Md5Pay md5pay = new Md5Pay(); md5pay.Key = payConfig.BusinessKey; //卖家商户key md5pay.Bargainor_id = payConfig.BargainorID; //判断签名 if (md5pay.GetPayValueFromUrl(Request.QueryString, out errmsg)) { //认证签名成功 //支付判断 if (md5pay.Pay_Result == Md5Pay.PAYOK) { //支付成功,同定单号md5pay.Transaction_id可能会多次通知,请务必注意判断订单是否重复的逻辑 //跳转到成功页面,财付通收到<meta content=\"China TENCENT\" name=\"TENCENT_ONLINE_PAYMENT\">,认为通知成功 string orderNumber = md5pay.Sp_billno; OrderInfo order = OrderBLL.ReadOrderByNumber(orderNumber, 0); if (order.ID > 0) { if (order.OrderStatus == (int)OrderStatus.WaitPay) { order.OrderStatus = (int)OrderStatus.WaitCheck; OrderBLL.UpdateOrder(order); //增加操作记录 OrderActionInfo orderAction = new OrderActionInfo(); orderAction.OrderID = order.ID; orderAction.OrderOperate = (int)OrderOperate.Pay; orderAction.StartOrderStatus = (int)OrderStatus.WaitPay; orderAction.EndOrderStatus = (int)OrderStatus.WaitCheck; orderAction.Note = "客户财付通在线支付"; orderAction.IP = ClientHelper.IP; orderAction.Date = RequestHelper.DateNow; orderAction.AdminID = 0; orderAction.AdminName = string.Empty; OrderActionBLL.AddOrderAction(orderAction); } } else { UserRechargeInfo userRecharge = UserRechargeBLL.ReadUserRechargeByNumber(orderNumber, 0); if (userRecharge.ID > 0 && userRecharge.IsFinish == (int)BoolType.False) { userRecharge.IsFinish = (int)BoolType.True; UserRechargeBLL.UpdateUserRecharge(userRecharge); //账户记录 string note = "财付通在线冲值:" + userRecharge.Number; UserAccountRecordBLL.AddUserAccountRecord(userRecharge.Money, 0, note, userRecharge.UserID, userRecharge.UserName); } } //StreamWriter sw = File.AppendText(Server.MapPath("log.txt")); //sw.WriteLine(DateTime.Now.ToString() + orderNumber); //sw.Flush(); //sw.Close(); Response.Write(suchtml); } else { //支付失败,请不要按成功处理 Response.Write("支付失败" + errmsg); } } else { //认证签名失败 Response.Write("认证签名失败"); } }
protected void Submit() { if (base.UserId <= 0) { ResponseHelper.Write("error|还未登录"); ResponseHelper.End(); } int pointLeft = UserAccountRecordBLL.SumPoint(base.UserId); string userName = base.UserName; string userEmail = CookiesHelper.ReadCookieValue("UserEmail"); //检测积分 int id = RequestHelper.GetForm <int>("updateId"); if (id < 1) { ResponseHelper.Write("error|无效的请求"); ResponseHelper.End(); } gift = PointProductBLL.Read(id); if (gift.IsSale != (int)BoolType.True) { ResponseHelper.Write("error|该商品已下架"); ResponseHelper.End(); } if (gift.Point > pointLeft) { ResponseHelper.Write("error|您当前的积分不足以兑取该商品"); ResponseHelper.End(); } if (gift.EndDate.Date < DateTime.Now.Date) { ResponseHelper.Write("error|该商品已过有效兑取时间"); ResponseHelper.End(); } //库存 if (gift.TotalStorageCount - gift.SendCount < 1) { ResponseHelper.Write("error|该商品库存不足"); ResponseHelper.End(); } //添加订单 var order = new PointProductOrderInfo(); order.OrderNumber = ShopCommon.CreateOrderNumber(); order.OrderStatus = (int)PointProductOrderStatus.Shipping; order.Point = gift.Point; order.ProductId = gift.Id; order.ProductName = gift.Name; order.BuyCount = 1; order.Consignee = StringHelper.AddSafe(RequestHelper.GetForm <string>("username")); SingleUnlimitClass singleUnlimitClass = new SingleUnlimitClass(); order.RegionId = singleUnlimitClass.ClassID; order.Address = StringHelper.AddSafe(RequestHelper.GetForm <string>("address")); order.Tel = StringHelper.AddSafe(RequestHelper.GetForm <string>("mobile")); order.AddDate = DateTime.Now; order.IP = ClientHelper.IP; order.UserId = base.UserId; order.UserName = base.UserName; order.Id = PointProductOrderBLL.Add(order); if (order.Id > 0) { //扣减积分 UserAccountRecordBLL.Add(new UserAccountRecordInfo { RecordType = (int)AccountRecordType.Point, Money = 0, Point = -order.Point, Date = DateTime.Now, IP = ClientHelper.IP, Note = "兑取商品:" + order.ProductName + " 订单号:" + order.OrderNumber, UserId = order.UserId, UserName = order.UserName }); //扣减库存 PointProductBLL.ChangeSendCount(order.ProductId, ChangeAction.Plus); } ResponseHelper.Write("ok|" + order.Id); ResponseHelper.End(); }