/// <summary> /// 获取地址列表 /// </summary> /// <param name="openId"></param> /// <returns></returns> public AddressListsModel GetAddressList(int accountId) { var model = new AddressListsModel(); var GetUserInfo = IAccountService.GetById(accountId);//获取userId if (GetUserInfo != null) { // accountId = GetUserInfo.accountId; if (GetUserInfo.defaultAddressId != 0) { model.defaultAddressId = GetUserInfo.defaultAddressId; var DefGetAddressInfo = UserAddressService.GetById(model.defaultAddressId); if (DefGetAddressInfo != null) { model.defaultDetailedAddress = DefGetAddressInfo.detailedAddress; model.defaultMoblie = DefGetAddressInfo.moblie; model.defaultProvinceName = DefGetAddressInfo.provinceName == null ? " " : DefGetAddressInfo.provinceName; model.defaultRecipients = DefGetAddressInfo.recipients; } else { model.defaultAddressId = 0; } } else { model.defaultAddressId = 0; } } var GetAddressInfo = UserAddressService.GetByAccountId(accountId); if (GetAddressInfo != null && GetAddressInfo.ModelList != null && GetAddressInfo.ModelList.Count > 0) { //地址列表赋值 model.AddressList = GetAddressInfo.ModelList.ToList().Select(x => new AddressListModel() { userAddressId = x.userAddressId, moblie = x.moblie, recipients = x.recipients, detailedAddress = x.detailedAddress, city = CityService.GetById(x.cityId) == null ? "" : CityService.GetById(x.cityId).Name, province = ProvinceService.GetById(x.provinceId) == null ? "" : ProvinceService.GetById(x.provinceId).Name, ProvinceName = x.provinceName, zipCode = x.zipCode }).ToList(); return(model); } return(null); }
/// <summary> /// 订单详情 /// </summary> /// <param name="quantity"></param> /// <param name="openId"></param> /// <returns></returns> public ListOrderDetail GetOrders(string orderNo) { var model = new ListOrderDetail(); decimal totalAmt = 0; var orderInfo = OrderService.GetOrderNo(orderNo); if (orderInfo == null) { return(null); } else { model.payState = orderInfo.orderState; model.recipients = orderInfo.recipients == null ? " " : orderInfo.recipients; model.detailedAddress = orderInfo.detailedAddress == null ? " " : orderInfo.detailedAddress; model.moblie = orderInfo.moblie == null ? " " : orderInfo.moblie; model.Remark = orderInfo.remark == null ? " " : orderInfo.remark; model.orderState = orderInfo.orderState; model.Freight = orderInfo.freight; model.ExpressCompany = orderInfo.ExpressCompany == null ? " " : orderInfo.ExpressCompany; model.ExpressNumber = orderInfo.ExpressNumber == null ? " " : orderInfo.ExpressNumber; model.UserAddressId = orderInfo.UserAddressId; model.orderNo = orderInfo.orderNo; } var orderDtlInfo = OrderDetailService.GetAllByOrderNo(orderNo).ToList(); if (orderDtlInfo != null) { foreach (var item in orderDtlInfo) { var dtlModel = new OrderDetailsModel(); var commodity = JuMeiMallService.GetById(item.commodityId); if (commodity == null) { return(null); } if (commodity.commodityState == CommodityStates.soldOut) { return(null); } //数量 dtlModel.Image = GetFirstImage(commodity.images); dtlModel.Id = item.commodityId; dtlModel.Price = item.price; dtlModel.quantity = item.quantity; dtlModel.Title = commodity.commodityName; dtlModel.specification = item.specification; // totalAmt += commodity.commodityPrice * item.quantity; //freight = commodity.commodityFreight; model.OrderDetailsList.Add(dtlModel); } } model.TotalAmt = orderInfo.amount; model.Freight = orderInfo.freight; var GetAddressInfo = UserAddressService.GetByAccountId(orderInfo.userId); if (GetAddressInfo != null && GetAddressInfo.ModelList != null && GetAddressInfo.ModelList.Count > 0) { //地址列表赋值 model.ListUserAddress = GetAddressInfo.ModelList.ToList().Select(x => new UserAddress() { userAddressId = x.userAddressId, moblie = x.moblie, recipients = x.recipients, detailedAddress = x.detailedAddress, //city = CityService.GetById(x.cityId) == null ? "" : CityService.GetById(x.cityId).Name, //province = ProvinceService.GetById(x.provinceId) == null ? "" : ProvinceService.GetById(x.provinceId).Name, //ProvinceName = x.provinceName, //zipCode = x.zipCode }).ToList(); return(model); } return(model); }