// 查看订单详情
        public OrderDetailView getOrderByStatus(string orderid)
        {
            Order              order           = _context.Orders.Where(x => x.OrdersId == orderid).FirstOrDefault();
            OrdersCommodity    ordersCommodity = _context.OrdersCommodities.Where(x => x.OrdersId == orderid).FirstOrDefault();
            Commodity          commodity       = _context.Commodities.Where(x => x.CommodityId == ordersCommodity.CommodityId).FirstOrDefault();
            Shop               shop            = _context.Shops.Where(x => x.ShopId == order.ShopId).FirstOrDefault();
            ReceiveInformation receive         = _context.ReceiveInformations.Where(x => x.ReceivedId == order.ReceivedId).FirstOrDefault();

            OrderDetailView orderDetail = new OrderDetailView
            {
                OrdersId   = order.OrdersId,         // 订单ID
                BuyerId    = order.BuyerId,          // 买家ID
                ReceivedId = order.ReceivedId,       // 收货详情ID
                ShopId     = order.ShopId,           // 店铺ID
                Status     = order.Status,           // 订单的状态
                OrdersDate = order.OrdersDate,       // 下单时间

                // Orderamount // 订单包含物品数量
                Price         = commodity.Price,      // 商品价格
                Category      = commodity.Category,   // 商品类别
                CommodityName = commodity.Name,       // 商品名称
                CommodityUrl  = commodity.Url,        // 商品图片
                ShopName      = shop.Name,            // 店铺名称
                ReceiverPhone = receive.Phone,        // 收货人电话号码
                ReceiverName  = receive.ReceiverName, // 收货人姓名
                Country       = receive.Country,      // 国家
                Province      = receive.Province,     // 省份
                City          = receive.City,         // 城市
                District      = receive.District,     // 街区
                DetailAddr    = receive.DetailAddr    // 地址详情
            };

            return(orderDetail);
        }
        // 更新收货地址
        public bool updateReceiveInformation(string receiveId, string newName, string newPhone, string newAddress, string newTag)
        {
            ReceiveInformation receiveInformation = _context.ReceiveInformations.Where(x => x.ReceivedId == receiveId).FirstOrDefault();

            if (receiveInformation != null)
            {
                receiveInformation.ReceiverName = newName;
                receiveInformation.Phone        = newPhone;
                receiveInformation.DetailAddr   = newAddress;
                receiveInformation.Tag          = newTag;
                _context.ReceiveInformations.Update(receiveInformation);
                if (_context.SaveChanges() > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
        // 创建收货信息
        // public string createReceiveInformation(string buyerid, string receiverName, string phone, string country, string province, string city, string receivedId, string district, string detailAddr)
        public string createReceiveInformation(string buyerid, string receiverName, string phone, string detailAddr, string tag)
        {
            // 收货信息Id生成
            CreateIdCount receivedCount = new CreateIdCount(_context);
            string        receivedid    = receivedCount.GetOrderCount();

            ReceiveInformation receiveInformation = new ReceiveInformation
            {
                ReceivedId   = receivedid,
                Phone        = phone,
                ReceiverName = receiverName,
                BuyerId      = buyerid,
                Country      = "1",
                Province     = "2",
                City         = "3",
                District     = "4",
                DetailAddr   = detailAddr,
                Tag          = tag
            };

            _context.ReceiveInformations.Add(receiveInformation);

            if (_context.SaveChanges() > 0)
            {
                return(receivedid);
            }
            else
            {
                return(null);
            }
        }
Example #4
0
        private void ReceiveCallback(IAsyncResult ar)
        {
            lock (locker)
            {
                ReceiveInformation recvinf = (ReceiveInformation)ar.AsyncState;
                int  len        = 0;
                bool needMore   = false;
                int  lastoffset = 0;
                try
                {
                    len = socket.EndReceive(ar);

                    if (len <= 0)
                    {
                        DisconnectedReceived(false);
                    }
                    else
                    {
                        var messages = new SocketMessageEventArgs(recvinf.buffer, recvinf.lastoffset + len);
                        messages.Messages = SocketMessage.Resolve(recvinf.buffer, recvinf.lastindex, recvinf.lastoffset + len - 1, out needMore, out lastoffset);

                        if (messages.Messages.Count > 0)
                        {
                            if (MessageReceived != null)
                            {
                                MessageReceived(this, messages);
                            }
                        }

                        if (needMore == false)
                        {
                            recvinf.lastoffset = 0;
                            recvinf.lastindex  = 0;
                            recvinf.socket.BeginReceive(recvinf.buffer, 0, recvinf.buffer.Length, SocketFlags.None, ReceiveCallback, recvinf);
                        }
                        else
                        {
                            recvinf.lastoffset = recvinf.lastindex + len;
                            recvinf.lastindex  = lastoffset;
                            recvinf.socket.BeginReceive(recvinf.buffer, recvinf.lastoffset, recvinf.buffer.Length - recvinf.lastoffset, SocketFlags.None, ReceiveCallback, recvinf);
                        }
                    }
                }
                catch (SocketException sex)
                {
                    switch ((SocketExceptionErrorCode)sex.ErrorCode)
                    {
                    case SocketExceptionErrorCode.ConnectionForciblyClosed:
                        DisconnectedReceived(true);
                        break;
                    }
                }
            }
        }
        // 删除收货信息
        public bool deleteReceiveInformation(string receiveid)
        {
            ReceiveInformation receiveInformation = _context.ReceiveInformations.Where(x => x.ReceivedId == receiveid).FirstOrDefault();

            _context.ReceiveInformations.Remove(receiveInformation);

            if (_context.SaveChanges() > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }