//public static CheckOutResult GetPayAndShipTypeList(CheckOutContext context, int customerSysNo) //{ // CheckOutResult result = new CheckOutResult(); // CheckOutContext newCheckoutContenxt = new CheckOutContext(); // if (context != null) // { // newCheckoutContenxt = context.Clone(); // } // MemberInfo memberInfo = CustomerDA.GetCustomerInfo(customerSysNo); // //取得用户选择的收货地址信息 // var custShippingAddrResult = GetCustomerShippingAddressList(newCheckoutContenxt, customerSysNo); // result.SelShippingAddress = custShippingAddrResult.SelShippingAddress; // #region 支付类别选择 // result.PaymentCategoryList = GetAllPaymentCategoryList(); // //优先取context指定的支付类型 // //其次取配送地址指定的支付类型 // if (!result.PaymentCategoryList.Exists(x => // { // if (x.Key.ToString() == newCheckoutContenxt.PaymentCategoryID // || x.Key == result.SelShippingAddress.PaymentCategoryID) // { // result.SelPaymentCategoryID = x.Key; // return true; // } // return false; // })) // { // //都没有就取第一条支付类型 // result.SelPaymentCategoryID = result.PaymentCategoryList.First().Key; // } // #endregion // #region 配送方式选择 // //step1 取得配送地址支持的所有配送方式 // var shipTypeList = ShipTypeFacade.GetSupportedShipTypeList(result.SelShippingAddress.ReceiveAreaSysNo, null); // //step2 如果不存在支持货到付款的配送方式, 则移除掉货到付款支付类别 // if (shipTypeList.Count(x => x.IsPayWhenRecv) <= 0) // { // result.PaymentCategoryList = result.PaymentCategoryList.FindAll(x => x.Key == (int)PaymentCategory.OnlinePay); // result.SelPaymentCategoryID = (int)PaymentCategory.OnlinePay; // } // //step3 如果选择的是货到付款,则移除掉不支持货到付款的配送方式 // if (result.SelPaymentCategoryID == (int)PaymentCategory.PayWhenRecv) // { // result.ShipTypeList = shipTypeList.Where(x => x.IsPayWhenRecv).ToList(); // //step4 移除掉不支持货到付款的配送方式后没有可用的配送方式时,系统自动选择在线支付 // if (result.ShipTypeList.Count <= 0) // { // result.ShipTypeList = shipTypeList; // result.PaymentCategoryList= result.PaymentCategoryList.FindAll(x =>x.Key==(int)PaymentCategory.OnlinePay); // result.SelPaymentCategoryID=(int)PaymentCategory.OnlinePay; // } // } // else // { // result.ShipTypeList = shipTypeList; // } // //优先取context指定的配送方式 // result.SelShipType = result.ShipTypeList.Find(x => x.ShipTypeSysNo.ToString() == newCheckoutContenxt.ShipTypeID); // //其次取配送地址指定的配送方式 // if (result.SelShipType == null && result.SelShippingAddress != null) // { // result.SelShipType = result.ShipTypeList.Find(x => x.ShipTypeSysNo == result.SelShippingAddress.ShipTypeSysNo); // } // //都没有就取第一条配送方式 // if (result.SelShipType == null && result.ShipTypeList.Count > 0) // { // result.SelShipType = result.ShipTypeList.First(); // } // result.ShipTypeList = EnsureNotNullObject(result.ShipTypeList); // result.SelShipType = EnsureNotNullObject(result.SelShipType); // #endregion // #region 支付方式选择 // result.PayTypeList = GetAllPayTypeList(); // if (result.SelPaymentCategoryID == (int)PaymentCategory.PayWhenRecv) // { // result.PayTypeList = result.PayTypeList.FindAll(x => x.IsPayWhenRecv == 1); // } // //优先取用户上次下单使用的支付方式 // result.SelPayType = result.PayTypeList.Find(x => x.PayTypeID == memberInfo.ExtendInfo.LastPayTypeSysNo); // if (result.SelPayType == null && result.PayTypeList.Count > 0) // { // result.SelPayType = result.PayTypeList.First(); // } // if (result.SelPayType != null && result.PayTypeList.Count > 0) // { // var cateId = result.SelPayType.IsPayWhenRecv == 1 ? (int)PaymentCategory.PayWhenRecv : (int)PaymentCategory.OnlinePay; // var isPayWhenRecvValue = result.SelPaymentCategoryID == (int)PaymentCategory.PayWhenRecv ? 1 : 0; // //如果上次下单用户使用的支付方式类型跟本次下单选择的支付类型不一致 // //则选择符合当前选择的支付类型的第一个支付方式 // if (cateId != result.SelPaymentCategoryID) // { // result.SelPayType = result.PayTypeList.Where(x => x.IsPayWhenRecv == isPayWhenRecvValue).First(); // } // } // result.PayTypeList = EnsureNotNullObject(result.PayTypeList); // result.SelPayType = EnsureNotNullObject(result.SelPayType); // #endregion // return result; //} public static CheckOutResult GetCustomerShippingAddressList(CheckOutContext context, int customerSysNo) { CheckOutResult result = new CheckOutResult(); ShippingContactInfo curShippingAddress = null; List <ShippingContactInfo> customerShippingAddressList = CustomerShippingAddresssFacade.GetCustomerShippingAddressList(customerSysNo); if (customerShippingAddressList != null && customerShippingAddressList.Count > 0) { if (context == null) { curShippingAddress = customerShippingAddressList.Find(x => x.IsDefault); } else { curShippingAddress = customerShippingAddressList.Find(x => x.SysNo == context.ShippingAddressID); } if (curShippingAddress == null) { curShippingAddress = customerShippingAddressList.First(); } } result.ShippingAddressList = EnsureNotNullObject(customerShippingAddressList); result.SelShippingAddress = EnsureNotNullObject(curShippingAddress); return(result); }
public ActionResult EditShippingAddress() { if (Request["cmd"] == null) { throw new BusinessException("无效的请求"); } int contactAddressSysNo; string command = Request["cmd"].Trim().ToUpper(); switch (command) { case "GET": if (Request["id"] == null || !int.TryParse(Request["id"], out contactAddressSysNo)) { throw new BusinessException("无效的请求"); } else { ShippingContactInfo customerShippingAddressInfo = CustomerShippingAddresssFacade.GetCustomerShippingAddress(contactAddressSysNo, CurrUser.UserSysNo); if (customerShippingAddressInfo == null) { throw new BusinessException("无效的收货地址"); } return(PartialView("_RMAShippingAddressEditPanel", customerShippingAddressInfo)); } case "DEL": if (Request["id"] == null || !int.TryParse(Request["id"], out contactAddressSysNo)) { throw new BusinessException("无效的请求"); } else { CustomerShippingAddresssFacade.DeleteCustomerContactInfo(contactAddressSysNo, CurrUser.UserSysNo); return(Json(new { sysno = contactAddressSysNo })); } case "DEFAULT": if (Request["id"] == null || !int.TryParse(Request["id"], out contactAddressSysNo)) { throw new BusinessException("无效的请求"); } else { CustomerShippingAddresssFacade.SetCustomerContactAsDefault(contactAddressSysNo, CurrUser.UserSysNo); return(Content("y")); } default: break; } return(Json("")); }
/// <summary> /// 编辑用户的收货地址,包括新建和更新 /// </summary> /// <param name="customerShippingAddress">收货地址信息</param> /// <param name="customerSysNo">用户系统编号</param> public static ShippingContactInfo EditCustomerContactInfo(ShippingContactInfo customerShippingAddress, int customerSysNo) { if (customerShippingAddress.SysNo > 0) { customerShippingAddress = CustomerShippingAddressDA.Update(customerShippingAddress, customerSysNo); } else { customerShippingAddress.CustomerSysNo = customerSysNo; customerShippingAddress = CustomerShippingAddressDA.Create(customerShippingAddress); } return(customerShippingAddress); }
public JsonResult EditShippingAddress(ShippingContactInfo shippingAddress) { int sysNo; bool success = true; CustomerManager.EditCustomerShippingAddress(UserMgr.ReadUserInfo(), shippingAddress, out sysNo); JsonResult result = new JsonResult(); result.Data = new AjaxResult() { Success = success, Data = sysNo, }; return(result); }
public ActionResult AjaxGetShippingAddress() { int contactAddressSysNo; if (Request["id"] == null || !int.TryParse(Request["id"], out contactAddressSysNo)) { throw new BusinessException("无效的请求"); } else { ShippingContactInfo customerShippingAddressInfo = CustomerShippingAddresssFacade.GetCustomerShippingAddress(contactAddressSysNo, CurrUser.UserSysNo); if (customerShippingAddressInfo == null) { throw new BusinessException("无效的收货地址"); } return(PartialView("_ReceiveAddressEdit", customerShippingAddressInfo)); } }
public static ShippingContactInfo Update(ShippingContactInfo customerShippingAddress, int customerSysNo) { DataCommand dataCommand = DataCommandManager.GetDataCommand("Shipping_UpdateShippingAddress"); dataCommand.SetParameterValue("@SysNo", customerShippingAddress.SysNo); dataCommand.SetParameterValue("@CustomerSysNo", customerSysNo); dataCommand.SetParameterValue("@AddressTitle", customerShippingAddress.AddressTitle); dataCommand.SetParameterValue("@IsDefault", customerShippingAddress.IsDefault); dataCommand.SetParameterValue("@ReceiveName", customerShippingAddress.ReceiveName); dataCommand.SetParameterValue("@ReceiveContact", customerShippingAddress.ReceiveContact); dataCommand.SetParameterValue("@ReceivePhone", customerShippingAddress.ReceivePhone); dataCommand.SetParameterValue("@ReceiveCellPhone", customerShippingAddress.ReceiveCellPhone); dataCommand.SetParameterValue("@ReceiveFax", customerShippingAddress.ReceiveFax); dataCommand.SetParameterValue("@ReceiveAreaSysNo", customerShippingAddress.ReceiveAreaSysNo); dataCommand.SetParameterValue("@ReceiveAddress", customerShippingAddress.ReceiveAddress); dataCommand.SetParameterValue("@ReceiveZip", customerShippingAddress.ReceiveZip); return(dataCommand.ExecuteEntity <ShippingContactInfo>()); }
public ActionResult AjaxSubmitShippingAddress(FormCollection form) { ShippingContactInfo shippingAddressInfo = new ShippingContactInfo(); if (TryUpdateModel(shippingAddressInfo)) { int receiveAreaIdD; if (int.TryParse(Request["District"], out receiveAreaIdD) && receiveAreaIdD > 0) { shippingAddressInfo.ReceiveAreaSysNo = receiveAreaIdD; //checkout页面“收货人”和“联系人”写成同一个值 shippingAddressInfo.ReceiveContact = shippingAddressInfo.ReceiveName; CustomerShippingAddresssFacade.EditCustomerContactInfo(shippingAddressInfo, CurrUser.UserSysNo); return(Json(shippingAddressInfo)); } return(Json(BuildAjaxErrorObject("收货区域不能为空"))); } return(Json(BuildAjaxErrorObject("无效的请求"))); }
public static ShippingContactInfo Create(ShippingContactInfo customerShippingAddress) { DataCommand dataCommand = DataCommandManager.GetDataCommand("Shipping_CreateShippingAddress"); dataCommand.SetParameterValue("@CustomerSysNo", customerShippingAddress.CustomerSysNo); dataCommand.SetParameterValue("@AddressTitle", customerShippingAddress.AddressTitle); dataCommand.SetParameterValue("@IsDefault", customerShippingAddress.IsDefault); dataCommand.SetParameterValue("@ReceiveName", customerShippingAddress.ReceiveName); dataCommand.SetParameterValue("@ReceiveContact", customerShippingAddress.ReceiveContact); dataCommand.SetParameterValue("@ReceivePhone", customerShippingAddress.ReceivePhone); dataCommand.SetParameterValue("@ReceiveCellPhone", customerShippingAddress.ReceiveCellPhone); dataCommand.SetParameterValue("@ReceiveFax", customerShippingAddress.ReceiveFax); dataCommand.SetParameterValue("@ReceiveAreaSysNo", customerShippingAddress.ReceiveAreaSysNo); dataCommand.SetParameterValue("@ReceiveAddress", customerShippingAddress.ReceiveAddress); dataCommand.SetParameterValue("@ReceiveZip", customerShippingAddress.ReceiveZip); customerShippingAddress.SysNo = Convert.ToInt32(dataCommand.ExecuteScalar()); customerShippingAddress = Load(customerShippingAddress.SysNo, customerShippingAddress.CustomerSysNo); return(customerShippingAddress); }
public ActionResult CreateCustomerShippingInfo(FormCollection form) { string Action = Request["Action"].ToString(); string Data = Request["Data"].ToString(); Data = System.Web.HttpUtility.UrlDecode(Data); JavaScriptSerializer jss = new JavaScriptSerializer(); ShippingContactInfo shippingAddress = jss.Deserialize <ShippingContactInfo>(Data); // JsonHelper.JsonToObject<ShippingContactInfo>(Data); shippingAddress.ReceiveName = shippingAddress.ReceiveContact; if (Action == "2") { CustomerShippingAddresssFacade.DeleteCustomerContactInfo(shippingAddress.SysNo, CurrUser.UserSysNo); } else { CustomerShippingAddresssFacade.EditCustomerContactInfo(shippingAddress, CurrUser.UserSysNo); } return(Json("s", JsonRequestBehavior.AllowGet)); }
public ActionResult SubmitShippingAddress() { ShippingContactInfo shippingAddressInfo = new ShippingContactInfo() { IsDefault = true }; if (TryUpdateModel(shippingAddressInfo)) { int receiveAreaIdD; if (int.TryParse(Request["District"], out receiveAreaIdD) && receiveAreaIdD > 0) { shippingAddressInfo.ReceiveAreaSysNo = receiveAreaIdD; //checkout页面“收货人”和“联系人”写成同一个值 shippingAddressInfo.ReceiveContact = shippingAddressInfo.ReceiveName; shippingAddressInfo = CustomerShippingAddresssFacade.EditCustomerContactInfo(shippingAddressInfo, CurrUser.UserSysNo); return(Json(shippingAddressInfo)); } throw new BusinessException("收货区域不能为空"); } throw new BusinessException("无效的请求"); }