Beispiel #1
0
        public void Handle(PayedOrderRequest message)
        {
            var response = new CancelOrderResponse();
            var service  = new HotelOrderService();

            try
            {
                var order = service.GetModel(message.OrderId);
                if (CheckStatus(order))
                {
                    response.Success = service.Update(message.OrderId,
                                                      HotelStatusManager.OrderStatus.Payed.StatusId.ToString());
                }
                else
                {
                    response.Success = false;
                }
            }
            catch
            {
                response.Success = false;
            }

            _bus.Reply(response);
        }
Beispiel #2
0
        public void Handle(CreateOrderRequest message)
        {
            var service = new HotelOrderService();

            var entity = message.Order.MapTo <HotelOrderInfo>();

            entity.hotelid     = message.HotelId;
            entity.openid      = message.OpenId;
            entity.roomid      = message.RoomId;
            entity.roomType    = message.RoomType;
            entity.createDate  = DateTime.Now;
            entity.orderTime   = DateTime.Now;
            entity.orderStatus = HotelStatusManager.OrderStatus.Pending.StatusId;
            entity.orderNumber = "H" + DateTime.Now.ToString("yyyyMMddHHmmssffff") + Utils.Number(5);

            //获取房间的加个
            var room = new RoomService().GetModel(entity.roomid);

            entity.yuanjia = (double)room.roomPrice.Value;
            entity.price   = (double)room.salePrice;

            using (var scope = new TransactionScope())
            {
                if (entity.id == 0)
                {
                    entity.id = service.Add(entity);
                    //创建验证码
                    CreateIdentifyingCode(message.Wid, entity);
                }
                else
                {
                    service.Update(entity);
                }

                scope.Complete();
            }

            _bus.Reply(new CreateOrderResponse()
            {
                OrderId = entity.id
            });
        }