Пример #1
0
        public string GetTCTWPanicbuyingEventKV(string pRequest)
        {
            TCTWPanicbuyingEventKVRD rd = new TCTWPanicbuyingEventKVRD();

            try
            {
                var rp = pRequest.DeserializeJSONTo <APIRequest <GetTCTWPanicbuyingEventKVRP> >();

                //var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo;
                var     loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, rp.UserID);
                var     bll = new PanicbuyingEventSkuMappingBLL(loggingSessionInfo);
                DataSet ds  = bll.GetTCTWPanicbuyingEventKV(rp.Parameters.CTWEventId);
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0] != null && ds.Tables[0].Rows.Count != 0)
                {
                    rd.TCTWPanicbuyingEventKVInfo = DataTableToObject.ConvertToObject <T_CTW_PanicbuyingEventKVEntity>(ds.Tables[0].Rows[0]);
                }
                var rsp = new SuccessResponse <IAPIResponseData>(rd);
                return(rsp.ToJSON());
            }
            catch (Exception ex)
            {
                throw new APIException(ex.Message);
            }
            //return "{\"ResultCode\":0,\"Message\":\"OK\",\"Data\":{\"ItemList\":[{\"ItemID\":\"22\",\"ItemName\":\"美的\",\"ImageUrl\":\"http://www.o2omarketing.cn: 8400/Framework/Javascript/Other/kindeditor/attached/image/lzlj/album1.jpg\",\"SkuList\":[{\"kuID\":\"1111\",\"SkuName\":\"138L(银灰色)\",\"Qty\":\"250\",\"KeepQty\":\"200\",\"SoldQty\":\"30\",\"InverTory\":\"20\"}]}]}}";
        }
Пример #2
0
        public string GetEventMerchandise(string pRequest)
        {
            EventMerchandiseRD rd = new EventMerchandiseRD();

            try
            {
                var rp = pRequest.DeserializeJSONTo <APIRequest <EventMerchandiseRP> >();

                //var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo;
                var     loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, rp.UserID);
                var     bll = new PanicbuyingEventSkuMappingBLL(loggingSessionInfo);
                DataSet ds  = bll.GetEventMerchandise(rp.Parameters.EventId);
                if (ds.Tables.Count > 0 && ds.Tables[0] != null)
                {
                    rd.ItemList = DataTableToObject.ConvertToList <Item>(ds.Tables[0]);

                    foreach (var item in rd.ItemList)
                    {
                        DataSet skuds = bll.GetGetEventMerchandiseSku(item.EventItemMappingId.ToString());
                        if (skuds.Tables.Count > 0 && skuds.Tables[0] != null)
                        {
                            item.SkuList = DataTableToObject.ConvertToList <Sku>(skuds.Tables[0]);
                        }
                    }
                }

                //查询
                var eventBll  = new PanicbuyingEventBLL(loggingSessionInfo);
                var tempEvent = eventBll.GetPanicbuyingEventDetails(rp.Parameters.EventId);
                PanicbuyingEvent eventEntity = new PanicbuyingEvent();
                eventEntity.EventId     = tempEvent.EventId;
                eventEntity.EventName   = tempEvent.EventName;
                eventEntity.EventTypeId = tempEvent.EventTypeId;
                eventEntity.BeginTime   = tempEvent.BeginTime.ToString("yyyy-MM-dd HH:mm");
                eventEntity.EndTime     = tempEvent.EndTime.ToString("yyyy-MM-dd HH:mm");
                eventEntity.CustomerID  = tempEvent.CustomerID;
                eventEntity.Qty         = tempEvent.Qty;
                eventEntity.RemainQty   = tempEvent.RemainQty;
                eventEntity.EventStatus = tempEvent.EventStatus.ToString();
                //倒计时
                //   TimeSpan nowSpan = tempEvent.EndTime - DateTime.Now;//应该是结束时间减去当前时间
                //  eventEntity.DeadlineSecond =  nowSpan.TotalSeconds<=0?0:  Convert.ToInt32( nowSpan.TotalSeconds);


                rd.TimeFlag = "begin";
                if (tempEvent.BeginTime > DateTime.Now)
                {
                    TimeSpan nowSpan = tempEvent.BeginTime - DateTime.Now;//应该是结束时间减去当前时间
                    eventEntity.DeadlineSecond = nowSpan.TotalSeconds <= 0 ? 0 : Convert.ToInt32(nowSpan.TotalSeconds);
                    if (eventEntity.DeadlineSecond > 0)
                    {
                        eventEntity.DeadlineTime = nowSpan.Days + "天" + nowSpan.Hours + "时" + nowSpan.Minutes + "分" + nowSpan.Seconds;
                    }
                    else
                    {
                        eventEntity.DeadlineTime = 0 + "天" + 0 + "时" + 0 + "分" + 0;
                    }
                }
                else
                {
                    rd.TimeFlag = "end";
                    TimeSpan nowSpan = tempEvent.EndTime - DateTime.Now;//应该是结束时间减去当前时间
                    eventEntity.DeadlineSecond = nowSpan.TotalSeconds <= 0 ? 0 : Convert.ToInt32(nowSpan.TotalSeconds);

                    if (eventEntity.DeadlineSecond > 0)
                    {
                        eventEntity.DeadlineTime = nowSpan.Days + "天" + nowSpan.Hours + "时" + nowSpan.Minutes + "分" + nowSpan.Seconds;
                    }
                    else
                    {
                        eventEntity.DeadlineTime = 0 + "天" + 0 + "时" + 0 + "分" + 0;
                    }
                }
                rd.BeginTime = tempEvent.BeginTime.ToString("MM月dd日");



                rd.PanicbuyingEvent = eventEntity;


                var rsp = new SuccessResponse <IAPIResponseData>(rd);
                return(rsp.ToJSON());
            }
            catch (Exception ex)
            {
                throw new APIException(ex.Message);
            }
            //return "{\"ResultCode\":0,\"Message\":\"OK\",\"Data\":{\"ItemList\":[{\"ItemID\":\"22\",\"ItemName\":\"美的\",\"ImageUrl\":\"http://www.o2omarketing.cn: 8400/Framework/Javascript/Other/kindeditor/attached/image/lzlj/album1.jpg\",\"SkuList\":[{\"kuID\":\"1111\",\"SkuName\":\"138L(银灰色)\",\"Qty\":\"250\",\"KeepQty\":\"200\",\"SoldQty\":\"30\",\"InverTory\":\"20\"}]}]}}";
        }
Пример #3
0
        protected override GetBargainDetailsRD ProcessRequest(DTO.Base.APIRequest <GetBargainDetailsRP> pRequest)
        {
            var rd   = new GetBargainDetailsRD();
            var para = pRequest.Parameters;
            var loggingSessionInfo  = new SessionManager().CurrentUserLoginInfo;
            var ItemBll             = new T_ItemBLL(loggingSessionInfo);
            var EventItemMappingBll = new PanicbuyingKJEventItemMappingBLL(loggingSessionInfo);
            //砍价活动sku业务对象
            var PanicbuyingKJEventSkuMappingBll = new PanicbuyingKJEventSkuMappingBLL(loggingSessionInfo);
            var SkuBll = new T_SkuBLL(loggingSessionInfo);
            //活动
            var SkuMappingBLL = new PanicbuyingEventSkuMappingBLL(loggingSessionInfo);
            //
            string ItemID         = string.Empty;
            var    SkuMappingList = new List <PanicbuyingKJEventSkuMappingEntity>();

            if (!string.IsNullOrWhiteSpace(para.EventItemMappingID))
            {
                var EventItemData = EventItemMappingBll.GetByID(para.EventItemMappingID);
                if (EventItemData != null)
                {
                    ItemID = EventItemData.ItemID;
                    //商品信息赋值
                    rd.SinglePurchaseQty   = EventItemData.SinglePurchaseQty.Value;
                    rd.ItemID              = EventItemData.ItemID;
                    rd.BargaingingInterval = EventItemData.BargaingingInterval.Value;
                }
                //砍价Sku集合
                SkuMappingList = PanicbuyingKJEventSkuMappingBll.QueryByEntity(new PanicbuyingKJEventSkuMappingEntity()
                {
                    EventItemMappingID = para.EventItemMappingID
                }, null).ToList();
            }
            else
            {
                ItemID = para.ItemId;
            }

            var ItemData = ItemBll.GetByID(ItemID);

            if (ItemData == null)
            {
                throw new APIException("未找到相关商品,请确认参数")
                      {
                          ErrorCode = ERROR_CODES.INVALID_BUSINESS
                      }
            }
            ;
            //商品ID、名称赋值
            rd.ItemID   = ItemID;
            rd.ItemName = ItemData.item_name;

            #region sku
            rd.SkuInfoList = new List <SkuInfos>();
            //var SkuList = SkuBll.QueryByEntity(new T_SkuEntity() { item_id = ItemID }, null).ToList();
            DataSet ds      = SkuMappingBLL.GetItemSku("", ItemID, "");
            var     SkuList = new List <Sku>();
            if (ds.Tables.Count > 0 && ds.Tables[0] != null)
            {
                SkuList = DataTableToObject.ConvertToList <Sku>(ds.Tables[0]);
            }
            foreach (var item in SkuList)
            {
                var SkuInfos = new SkuInfos();
                SkuInfos.SkuID   = item.SkuID;
                SkuInfos.SkuName = item.SkuName;
                SkuInfos.Price   = item.price;
                if (!string.IsNullOrWhiteSpace(para.EventItemMappingID))
                {
                    var Result = SkuMappingList.FirstOrDefault(m => m.SkuID.Equals(item.SkuID));
                    if (Result != null)
                    {
                        SkuInfos.EventSkuInfo = new EventSkuInfo();
                        SkuInfos.EventSkuInfo.EventSKUMappingId  = Result.EventSKUMappingId.ToString();
                        SkuInfos.EventSkuInfo.EventItemMappingID = Result.EventItemMappingID.ToString();
                        SkuInfos.EventSkuInfo.SkuID             = Result.SkuID;
                        SkuInfos.EventSkuInfo.Qty               = Result.Qty.Value;
                        SkuInfos.EventSkuInfo.Price             = Result.Price.Value;
                        SkuInfos.EventSkuInfo.BasePrice         = Result.BasePrice.Value;
                        SkuInfos.EventSkuInfo.BargainStartPrice = Result.BargainStartPrice.Value;
                        SkuInfos.EventSkuInfo.BargainEndPrice   = Result.BargainEndPrice.Value;
                    }
                }
                //
                rd.SkuInfoList.Add(SkuInfos);
            }
            #endregion

            return(rd);
        }
    }