Exemple #1
0
        /// <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);
        }
Exemple #2
0
        /// <summary>
        /// 付款后更新订单
        /// </summary>
        /// <param name="orderNo"></param>
        /// <param name="userAddressId"></param>
        /// <returns></returns>
        public ResultMessage UpdOrderPaid(string orderNo, int userAddressId, string remark, decimal totalAmt)
        {
            var tran = TransactionHelper.BeginTransaction();

            try
            {
                var userAddress = UserAddressService.GetById(userAddressId);
                if (userAddress == null)
                {
                    return new ResultMessage()
                           {
                               Code = -1, Msg = "订单数据地址录入有误,请截图并联系管理员,订单号:" + orderNo
                           }
                }
                ;

                var orderInfo = OrderService.GetOrderNo(orderNo);
                if (orderInfo == null)
                {
                    return new ResultMessage()
                           {
                               Code = -1, Msg = "订单数据丢失,请截图并联系管理员,订单号:" + orderNo
                           }
                }
                ;
                //if (totalAmt != orderInfo.amount + orderInfo.freight)
                //{
                //    return new ResultMessage() { Code = -1, Msg = "订单金额与订单不一致,请截图并联系管理员,订单号:" + orderNo };
                //}
                orderInfo.detailedAddress = userAddress.provinceName + " " + userAddress.detailedAddress;
                orderInfo.provinceId      = userAddress.provinceId;
                orderInfo.cityId          = userAddress.cityId;
                //orderInfo.orderState = OrderStates.paid;
                //orderInfo.payState = PayStates.paid;
                //orderInfo.submitTime = DateTime.Now;
                orderInfo.recipients        = userAddress.recipients;
                orderInfo.moblie            = userAddress.moblie;
                orderInfo.remark            = remark;
                orderInfo.zipCode           = userAddress.zipCode;
                orderInfo.distributionstate = DistributionStates.unfilled;
                //orderInfo.payType = PayTypes.weChatPayment;
                orderInfo.payAmount     = orderInfo.amount + orderInfo.freight;
                orderInfo.UserAddressId = userAddress.userAddressId;
                OrderService.Update(orderInfo);

                tran.Commit();
                //TransactionHelper.Commit();
                return(new ResultMessage()
                {
                    Code = 0, Msg = orderNo
                });
            }
            catch (Exception ex)
            {
                logService.Insert(ex);
                return(new ResultMessage()
                {
                    Code = -1, Msg = "订单数据录入有误,请截图并联系管理员,订单号:" + orderNo
                });
            }
            finally { tran.Dispose(); }
        }