public ActionResult SaveAddrInfo(SendAddressItem addrInfo) { SolemartUser user = User as SolemartUser; addrInfo.DeliverWay = DeliverWay.ByManual; addrInfo.UserID = user.UserID; user.SendAddressInfo = addrInfo; return(Content(WebResult <string> .SuccessResult.ResponseString)); }
/// <summary>保存用户的送货地址信息 /// </summary> /// <param name="addressItem">保存的送货地址信息</param> /// <returns>保存成功返回true,否则返回false</returns> public static bool SaveSendAddressInfoForUser(SendAddressItem addressItem) { using (SolemartDBContext context = new SolemartDBContext()) { SendAddressItem address = context.SendAddressItems.Find(addressItem.UserID); if (address != null) { address.Phone = addressItem.Phone; address.PostCode = addressItem.PostCode; address.Receiver = addressItem.Receiver; address.PaymentType = addressItem.PaymentType; address.Address = addressItem.Address; address.DeliverWay = addressItem.DeliverWay; } else { context.SendAddressItems.Add(addressItem); } return(context.SaveChanges() > 0); } }
public ActionResult CheckoutOrder(SendAddressItem addrInfo, string remark) { SolemartUser user = User as SolemartUser; if (string.IsNullOrWhiteSpace(addrInfo.Address) || string.IsNullOrWhiteSpace(addrInfo.Phone)) { return(Content(WebResult <string> .IncompleteInputResult.ResponseString)); } addrInfo.DeliverWay = DeliverWay.ByManual; addrInfo.UserID = user.UserID; user.SendAddressInfo = addrInfo; if (user.Cart.CartItems.Count == 0) { return(Content(WebResult <string> .ParameterErrorResult.ResponseString)); } OrderItem oi = new OrderItem(); if (user.IsAnonymous) { oi.UserID = SolemartUser.DefaultAnonymousUserID; } else { oi.UserID = user.UserID; } oi.Receiver = addrInfo.Receiver; oi.Phone = addrInfo.Phone; oi.PaymentType = addrInfo.PaymentType; oi.PostCode = addrInfo.PostCode; oi.Address = addrInfo.Address; oi.DeliverWay = addrInfo.DeliverWay; oi.TotalPrice = user.Cart.TotalPrice; oi.Remark = remark; foreach (CartItem item in user.Cart.CartItems) { oi.OrderDetails.Add(new OrderDetailItem { ProductID = item.ProductID, Amount = item.Amount, UnitPrice = item.UnitPrice }); } if (!OrderManager.NewOrder(oi)) { return(Content("error")); } //Clear the user's cart. //user.ClearCart(); //新订单产生后,刷新最受欢迎的产品列表 //ProductManager.RefleshMostPopularProducts(); if (oi.OrderID > 0) { // 已进入订单后,临时购物车上物品需要清除 user.Cart.ClearAndSave(user.UserID); //先保存用户的积分(目前的积分按购物的价格计算)。 if (!user.IsAnonymous) { user.AddPoint((int)oi.TotalPrice); } #if false //支付宝暂时不支持 if (oi.PaymentType == PaymentType.OnLine) { #region 填写支付宝参数 //支付类型 string payment_type = "1"; //必填,不能修改 //服务器异步通知页面路径 //string notify_url = "http://www.solemart.com/Cart/CheckOutComplete/"+orderid; //需http://格式的完整路径,不能加?id=123这类自定义参数 //页面跳转同步通知页面路径 string return_url = ConfigurationManager.AppSettings["website"] + "Cart/CheckOutComplete/" + oi.OrderID; //需http://格式的完整路径,不能加?id=123这类自定义参数,不能写成http://localhost/ //卖家支付宝帐户 string seller_email = "18065911899"; //必填 //商户订单号 string out_trade_no = oi.OrderID.ToString("000000"); //商户网站订单系统中唯一订单号,必填 //订单名称 string subject = "叟玛特订单"; //必填 //付款金额 string price = oi.TotalPrice.ToString("#0.00"); //必填 //商品数量 string quantity = "1"; //必填,建议默认为1,不改变值,把一次交易看成是一次下订单而非购买一件商品 //物流费用 string logistics_fee = "0.00"; //必填,即运费 //物流类型 string logistics_type = "EXPRESS"; //必填,三个值可选:EXPRESS(快递)、POST(平邮)、EMS(EMS) //物流支付方式 string logistics_payment = "SELLER_PAY"; //必填,两个值可选:SELLER_PAY(卖家承担运费)、BUYER_PAY(买家承担运费) //订单描述 //string body = ""; //商品展示地址 //string show_url = ""; //需以http://开头的完整路径,如:http://www.Solemart.com/myorder.html //收货人姓名 string receive_name = oi.Receiver; //如:张三 //收货人地址 string receive_address = oi.Address; //如:XX省XXX市XXX区XXX路XXX小区XXX栋XXX单元XXX号 //收货人邮编 string receive_zip = oi.PostCode == null ? "350600" : oi.PostCode; //如:123456 //收货人电话号码 string receive_phone = oi.Phone; //如:0571-88158090 //收货人手机号码 string receive_mobile = oi.Phone; //如:13312341234 //////////////////////////////////////////////////////////////////////////////////////////////// //把请求参数打包成数组 SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>(); sParaTemp.Add("partner", Config.Partner); sParaTemp.Add("_input_charset", Config.Input_charset.ToLower()); sParaTemp.Add("service", "trade_create_by_buyer"); sParaTemp.Add("payment_type", payment_type); //sParaTemp.Add("notify_url", notify_url); sParaTemp.Add("return_url", return_url); sParaTemp.Add("seller_email", seller_email); sParaTemp.Add("out_trade_no", out_trade_no); sParaTemp.Add("subject", subject); sParaTemp.Add("price", price); sParaTemp.Add("quantity", quantity); sParaTemp.Add("logistics_fee", logistics_fee); sParaTemp.Add("logistics_type", logistics_type); sParaTemp.Add("logistics_payment", logistics_payment); //sParaTemp.Add("body", body); sParaTemp.Add("receive_name", receive_name); sParaTemp.Add("receive_address", receive_address); sParaTemp.Add("receive_zip", receive_zip); sParaTemp.Add("receive_phone", receive_phone); sParaTemp.Add("receive_mobile", receive_mobile); #endregion //建立请求 string sHtmlText = Submit.BuildRequest(sParaTemp, "get", "确认"); return(Content("ok-alipay-" + sHtmlText)); } else { return(Content("ok-" + oi.OrderID)); } } else { #endif return(Content(new WebResult <string> { ResultCode = WebResultCode.Success, ResultData = oi.OrderID.ToString() }.ResponseString)); }