public ActionResult GiftSubmit(int giftType) { bool result = false; string msg = string.Empty; if (giftType != 1 && giftType != 2 && giftType != 3 && giftType != 4) { return Json(new { result = result, msg = "请求参数错误!" }); } string orderCode = string.Empty; //1.获取默认收货地址 int userId = this.LoginUser.UserID; List<AddressModel> list = new List<AddressModel>(); list = addressBll.GetAddressList(userId, 1, this.language).ToList(); if (list == null || list.Count <= 0) { return Json(new { result = result, msg = "您还未填写收货地址,请前往个人中心添加!" }); } var address = list.Where(o => o.IsDefault == 1).FirstOrDefault(); //2.构建需要传入的model的信息 OrderProductInfoModel model = new OrderProductInfoModel(); model.UserId = this.LoginUser.UserID; model.Language = this.language; model.DeliveryRegion = this.DeliveryRegion; model.OrderLimitValue = this.OrderLimitValue; model.ExchangeRate = this.ExchangeRate; model.AddressId = address.Id; //3.根据礼包类型创建商品集合 List<ProductItem> productList = new List<ProductItem>(); productList = GetProductListByType(giftType); //4.构建订单 result = buyOrderManager.SaveGift(model, productList, ref orderCode, giftType, null, BuyOrderManager.GatewayCode(productList)); if (result) { return Json(new{result=result,msg=orderCode}); } return Json(new { result=result,msg="创建订单失败!"}); }