Exemplo n.º 1
0
        protected override DelayEventRD ProcessRequest(APIRequest <DelayEventRP> pRequest)
        {
            var                rd   = new DelayEventRD();
            var                para = pRequest.Parameters;
            var                loggingSessionInfo = new SessionManager().CurrentUserLoginInfo;
            T_CTW_LEventBLL    bllCTWEvent        = new T_CTW_LEventBLL(loggingSessionInfo);
            T_CTW_LEventEntity entityCTWEvent     = new T_CTW_LEventEntity();

            entityCTWEvent         = bllCTWEvent.GetByID(para.CTWEventId);
            entityCTWEvent.EndDate = Convert.ToDateTime(para.EndDate);
            bllCTWEvent.Update(entityCTWEvent, null);
            if (para.EventType == "Game")
            {
                T_CTW_LEventInteractionBLL bllEventInteraction = new T_CTW_LEventInteractionBLL(loggingSessionInfo);
                string strEventId = bllEventInteraction.QueryByEntity(new T_CTW_LEventInteractionEntity()
                {
                    CTWEventId = new Guid(para.CTWEventId)
                }, null).FirstOrDefault().LeventId;
                LEventsBLL bllEvent = new LEventsBLL(loggingSessionInfo);
                bllEvent.Update(new LEventsEntity()
                {
                    EndTime = para.EndDate, EventID = strEventId
                }, false);
            }
            if (para.EventType == "Sales")
            {
                PanicbuyingEventBLL bllEvent = new PanicbuyingEventBLL(loggingSessionInfo);

                bllEvent.DelayEvent(para.CTWEventId, para.EndDate);
            }
            rd.EventId = para.CTWEventId;
            return(rd);
        }
Exemplo n.º 2
0
        protected override EmptyResponseData ProcessRequest(DTO.Base.APIRequest <SetBargainRP> pRequest)
        {
            var rd   = new EmptyResponseData();
            var para = pRequest.Parameters;
            var loggingSessionInfo  = new SessionManager().CurrentUserLoginInfo;
            var bllPanicbuyingEvent = new PanicbuyingEventBLL(loggingSessionInfo);

            var UpdateData = bllPanicbuyingEvent.GetByID(para.EventId);

            //if(DateTime.Now>UpdateData.EndTime)
            //    throw new APIException("砍价活动已结束!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS };
            if (UpdateData == null)
            {
                throw new APIException("未找到砍价活动!")
                      {
                          ErrorCode = ERROR_CODES.INVALID_BUSINESS
                      }
            }
            ;

            UpdateData.EventStatus = 10;//提前结束
            //
            bllPanicbuyingEvent.Update(UpdateData);


            return(rd);
        }
    }
Exemplo n.º 3
0
        protected override GetBargainItemRD ProcessRequest(DTO.Base.APIRequest <GetBargainItemRP> pRequest)
        {
            var rd   = new GetBargainItemRD();
            var para = pRequest.Parameters;
            var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo;
            var Bll      = new PanicbuyingKJEventItemMappingBLL(loggingSessionInfo);
            var EventBll = new PanicbuyingEventBLL(loggingSessionInfo);

            var complexCondition = new List <IWhereCondition> {
            };

            complexCondition.Add(new EqualsCondition()
            {
                FieldName = "EventId", Value = para.EventId
            });
            complexCondition.Add(new EqualsCondition()
            {
                FieldName = "customerId", Value = loggingSessionInfo.ClientID
            });
            var lstOrder = new List <OrderBy> {
            };

            lstOrder.Add(new OrderBy()
            {
                FieldName = "LastUpdateTime", Direction = OrderByDirections.Desc
            });
            //活动
            var EventData = EventBll.GetByID(para.EventId);

            if (EventData != null)
            {
                rd.EventName = EventData.EventName;
                rd.BeginTime = EventData.BeginTime.ToString("yyyy-MM-dd HH:mm");
                rd.EndTime   = EventData.EndTime.ToString("yyyy-MM-dd HH:mm");
            }
            var ResultList = Bll.Query(complexCondition.ToArray(), lstOrder.ToArray()).ToList();

            //列表
            rd.ItemMappingInfoList = (from u in ResultList
                                      select new ItemMappingInfo()
            {
                EventItemMappingID = u.EventItemMappingID.ToString(),
                ItemName = u.ItemName,
                SinglePurchaseQty = u.SinglePurchaseQty.Value,
                ItemId = u.ItemID
            }).ToList();

            return(rd);
        }
Exemplo n.º 4
0
        protected override GetEventItemStatusRD ProcessRequest(APIRequest <GetEventItemStatusRP> pRequest)
        {
            GetEventItemStatusRP             rp = pRequest.Parameters;
            GetEventItemStatusRD             rd = new GetEventItemStatusRD();
            PanicbuyingKJEventJoinBLL        panicbuyingKJEventJoinbll        = new PanicbuyingKJEventJoinBLL(CurrentUserInfo);
            PanicbuyingEventBLL              panicbuyingEventbll              = new PanicbuyingEventBLL(CurrentUserInfo);
            PanicbuyingKJEventItemMappingBLL panicbuyingKJEventItemMappingBll = new PanicbuyingKJEventItemMappingBLL(CurrentUserInfo);

            rd.status = 0;

            var panicbuyingKJEventJoinEntity = panicbuyingKJEventJoinbll.GetByID(rp.KJEventJoinId);

            if (panicbuyingKJEventJoinEntity != null)
            {
                var panicbuyingEventEntity = panicbuyingEventbll.QueryByEntity(new PanicbuyingEventEntity()
                {
                    EventId = panicbuyingKJEventJoinEntity.EventId
                }, null).FirstOrDefault();
                if (panicbuyingEventEntity == null || panicbuyingEventEntity.EndTime < DateTime.Now || panicbuyingEventEntity.EventStatus == 10)
                {
                    rd.status = 2;
                }
                else
                {
                    if (panicbuyingKJEventJoinEntity.EventOrderMappingId != null)
                    {//已购买,返回状态4
                        rd.status = 4;
                    }

                    //活动已结束
                    var panicbuyingKJEventItemMappingEntity = panicbuyingKJEventItemMappingBll.QueryByEntity(new PanicbuyingKJEventItemMappingEntity()
                    {
                        EventId = panicbuyingKJEventJoinEntity.EventId, ItemID = panicbuyingKJEventJoinEntity.ItemId
                    }, null).FirstOrDefault();
                    bool isEnd = Convert.ToDateTime(panicbuyingKJEventJoinEntity.CreateTime).AddHours(Convert.ToDouble(panicbuyingKJEventItemMappingEntity.BargaingingInterval)) <= DateTime.Now ? true : false;
                    if (isEnd)
                    {
                        rd.status = 3;
                    }
                }
            }
            else
            {
                rd.status = 1;
            }
            return(rd);
        }
Exemplo n.º 5
0
        protected override EmptyResponseData ProcessRequest(DTO.Base.APIRequest <SetBargainDetailsRP> pRequest)
        {
            var rd   = new EmptyResponseData();
            var para = pRequest.Parameters;
            var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo;
            var Bll = new PanicbuyingKJEventItemMappingBLL(loggingSessionInfo);
            var PanicbuyingEventBLL = new PanicbuyingEventBLL(loggingSessionInfo);
            var pTran = Bll.GetTran();

            using (pTran.Connection)
            {
                var DeleteItemData = Bll.GetByID(para.EventItemMappingID);
                if (DeleteItemData == null)
                {
                    throw new APIException("未找到相关砍价活动商品,请确认参数")
                          {
                              ErrorCode = ERROR_CODES.INVALID_BUSINESS
                          }
                }
                ;
                //
                Bll.Delete(DeleteItemData, pTran);
                //更新活动商品数量
                var UpdateEventData = PanicbuyingEventBLL.GetByID(para.EventId);
                if (UpdateEventData == null)
                {
                    throw new APIException("未找到相关砍价活动,请确认参数")
                          {
                              ErrorCode = ERROR_CODES.INVALID_BUSINESS
                          }
                }
                ;
                UpdateEventData.ItemQty -= 1;
                PanicbuyingEventBLL.Update(UpdateEventData, pTran);
                //提交
                pTran.Commit();
            }

            return(rd);
        }
    }
}
Exemplo n.º 6
0
        protected override EmptyResponseData ProcessRequest(DTO.Base.APIRequest <GetBargainItemRP> pRequest)
        {
            var rd   = new EmptyResponseData();
            var para = pRequest.Parameters;
            var loggingSessionInfo     = new SessionManager().CurrentUserLoginInfo;
            var bllPanicbuyingEvent    = new PanicbuyingEventBLL(loggingSessionInfo);
            var MHItemAreaBll          = new MHItemAreaBLL(loggingSessionInfo);//商城装修业务对象
            var entityPanicbuyingEvent = bllPanicbuyingEvent.GetByID(para.EventId);

            if (entityPanicbuyingEvent == null)
            {
                throw new APIException("未找到相关砍价活动,请确认参数")
                      {
                          ErrorCode = ERROR_CODES.INVALID_BUSINESS
                      };
            }
            else
            {
                var Result = MHItemAreaBll.QueryByEntity(new MHItemAreaEntity()
                {
                    EventId = new Guid(para.EventId)
                }, null).ToList();
                if (Result.Count > 0)
                {
                    throw new APIException("商城装修已关联当前砍价活动,请先删除商城装修中的砍价活动再删除!")
                          {
                              ErrorCode = ERROR_CODES.INVALID_BUSINESS
                          }
                }
                ;

                bllPanicbuyingEvent.Delete(entityPanicbuyingEvent);
            }


            return(rd);
        }
    }
Exemplo n.º 7
0
        protected override GetItemListRD ProcessRequest(APIRequest <GetItemListRP> pRequest)
        {
            GetItemListRP rp = pRequest.Parameters;
            GetItemListRD rd = new GetItemListRD();

            PanicbuyingEventBLL    panicbuyingEventBll = new PanicbuyingEventBLL(CurrentUserInfo);
            List <KJEventItemInfo> eventItemInfoList   = panicbuyingEventBll.GetKJEventWithItemList(pRequest.CustomerID);

            rd.ItemList = eventItemInfoList.AsEnumerable().Where(n => n.EventId == rp.EventId).Select(n => new EventItem()
            {
                ItemId             = n.ItemId,
                ItemName           = n.ItemName,
                ImageUrl           = n.ImageUrl,
                ImageUrlThumb      = string.IsNullOrEmpty(n.ImageUrl) ? "" : GetImageUrl(n.ImageUrl, "_120"),
                ImageUrlMiddle     = string.IsNullOrEmpty(n.ImageUrl) ? "" : GetImageUrl(n.ImageUrl, "_240"),
                ImageUrlBig        = string.IsNullOrEmpty(n.ImageUrl) ? "" : GetImageUrl(n.ImageUrl, "_480"),
                Price              = n.MinPrice,
                BasePrice          = n.MinBasePrice,
                Qty                = n.Qty - n.SoldQty,
                PromotePersonCount = n.PromotePersonCount
            }).ToList();

            return(rd);
        }
Exemplo n.º 8
0
        protected override EventListRD ProcessRequest(APIRequest <EventListRP> pRequest)


        {
            EventListRP rp = pRequest.Parameters;
            EventListRD rd = new EventListRD();

            PanicbuyingEventBLL panicbuyingEventBll = new PanicbuyingEventBLL(CurrentUserInfo);

            List <PanicbuyingEventEntity> panicbuyingEventEntityList = panicbuyingEventBll.QueryByEntity(new PanicbuyingEventEntity()
            {
                EventTypeId = rp.EventTypeId, CustomerID = pRequest.CustomerID
            }, null).ToList();

            if (panicbuyingEventEntityList.Count > 0)
            {
                var ResultList = panicbuyingEventEntityList.Where(t => t.EndTime >= DateTime.Now && t.EventStatus == 20).ToList();

                if (ResultList.Count > 0)
                {
                    List <KJEventItemInfo> eventItemInfoList = panicbuyingEventBll.GetKJEventWithItemList(pRequest.CustomerID);

                    rd.EventList = ResultList.Select(t => new EventInfo()
                    {
                        EventId       = t.EventId.ToString(),
                        BeginTime     = t.BeginTime == null ? "" : t.BeginTime.ToString("yyyy-MM-dd HH:mm:ss"),
                        EndTime       = t.EndTime == null ? "" : t.EndTime.ToString("yyyy-MM-dd HH:mm:ss"),
                        Seconds       = 0,//Convert.ToInt64(t.EndTime.Subtract(DateTime.Now).TotalSeconds) >= 0 ? Convert.ToInt64(t.EndTime.Subtract(DateTime.Now).TotalSeconds) : 0,
                        Status        = t.BeginTime > DateTime.Now ? 1 : t.EndTime < DateTime.Now ? 2 : 0,
                        EventItemList = eventItemInfoList.AsEnumerable().Where(n => n.EventId == t.EventId.ToString()).Select(n => new EventItem()
                        {
                            ItemId             = n.ItemId,
                            ItemName           = n.ItemName,
                            ImageUrl           = n.ImageUrl,
                            ImageUrlThumb      = string.IsNullOrEmpty(n.ImageUrl) ? "" : GetImageUrl(n.ImageUrl, "_120"),
                            ImageUrlMiddle     = string.IsNullOrEmpty(n.ImageUrl) ? "" : GetImageUrl(n.ImageUrl, "_240"),
                            ImageUrlBig        = string.IsNullOrEmpty(n.ImageUrl) ? "" : GetImageUrl(n.ImageUrl, "_480"),
                            Price              = n.MinPrice,
                            BasePrice          = n.MinBasePrice,
                            Qty                = n.Qty - n.SoldQty,
                            PromotePersonCount = n.PromotePersonCount
                        }).ToList(),
                    }).ToList();

                    foreach (var item in rd.EventList)
                    {
                        var BeginTime = Convert.ToDateTime(item.BeginTime);
                        var EndTime   = Convert.ToDateTime(item.EndTime);
                        if (BeginTime > DateTime.Now)
                        {
                            item.Seconds = Convert.ToInt64(BeginTime.Subtract(DateTime.Now).TotalSeconds) >= 0 ? Convert.ToInt64(BeginTime.Subtract(DateTime.Now).TotalSeconds) : 0;
                        }
                        else
                        {
                            item.Seconds = Convert.ToInt64(EndTime.Subtract(DateTime.Now).TotalSeconds) >= 0 ? Convert.ToInt64(EndTime.Subtract(DateTime.Now).TotalSeconds) : 0;
                        }
                    }
                    rd.EventList = rd.EventList.OrderBy(t => t.Status).ThenBy(t => t.Seconds).ToList();
                }
                else
                {
                    rd.IsAllEnd = 1;
                }
            }
            return(rd);
        }
        protected override AddKJEventJoinDetailRD ProcessRequest(APIRequest <AddKJEventJoinDetailRP> pRequest)
        {
            var rp  = pRequest.Parameters;
            var rd  = new AddKJEventJoinDetailRD();
            var Bll = new PanicbuyingKJEventJoinDetailBLL(CurrentUserInfo);

            var PanicbuyingEventBll   = new PanicbuyingEventBLL(CurrentUserInfo);
            var EventSkuMappingBll    = new PanicbuyingKJEventSkuMappingBLL(CurrentUserInfo);
            var KJEventJoinBll        = new PanicbuyingKJEventJoinBLL(CurrentUserInfo);
            var KJEventItemMappingBll = new PanicbuyingKJEventItemMappingBLL(CurrentUserInfo);
            var pTran = Bll.GetTran();
            //
            var EventData = PanicbuyingEventBll.GetByID(rp.EventId);

            if (EventData == null)
            {
                throw new APIException("找不到砍价活动对象!")
                      {
                          ErrorCode = ERROR_CODES.INVALID_BUSINESS
                      }
            }
            ;
            //
            var EventItemData = KJEventItemMappingBll.QueryByEntity(new PanicbuyingKJEventItemMappingEntity()
            {
                EventId = new System.Guid(rp.EventId), ItemID = rp.ItemId
            }, null).FirstOrDefault();

            if (EventData == null)
            {
                throw new APIException("找不到砍价活动商品对象!")
                      {
                          ErrorCode = ERROR_CODES.INVALID_BUSINESS
                      }
            }
            ;
            //
            var EventSkuMappingData = EventSkuMappingBll.QueryByEntity(new PanicbuyingKJEventSkuMappingEntity()
            {
                EventItemMappingID = EventItemData.EventItemMappingID.ToString(), SkuID = rp.SkuId
            }, null).FirstOrDefault();

            if (EventSkuMappingData == null)
            {
                throw new APIException("找不到砍价活动商品Sku关系对象!")
                      {
                          ErrorCode = ERROR_CODES.INVALID_BUSINESS
                      }
            }
            ;
            //
            var KJEventJoinData = KJEventJoinBll.GetByID(rp.KJEventJoinId);

            if (KJEventJoinData == null)
            {
                throw new APIException("找不到砍价参与主表对象!")
                      {
                          ErrorCode = ERROR_CODES.INVALID_BUSINESS
                      }
            }
            ;
            //判断重复帮砍
            var Collection = Bll.QueryByEntity(new PanicbuyingKJEventJoinDetailEntity()
            {
                KJEventJoinId = KJEventJoinData.KJEventJoinId, VipId = pRequest.UserID
            }, null).ToList();

            if (Collection.Count > 0)
            {
                throw new APIException("您已经帮砍过了,不能重复帮砍!")
                      {
                          ErrorCode = ERROR_CODES.INVALID_BUSINESS
                      }
            }
            ;
            #region  价业务处理
            //当前成交价
            decimal NowMoney = KJEventJoinData.SalesPrice.Value;
            if (NowMoney == EventSkuMappingData.BasePrice)
            {
                throw new APIException("已经砍到底价,不能继续砍价!")
                      {
                          ErrorCode = ERROR_CODES.INVALID_BUSINESS
                      }
            }
            ;
            if (EventSkuMappingData.BargainStartPrice == null || EventSkuMappingData.BargainEndPrice == null)
            {
                throw new APIException("砍价起始、结束区间值不能为Null,错误数据!")
                      {
                          ErrorCode = ERROR_CODES.INVALID_BUSINESS
                      }
            }
            ;
            //
            Random ran   = new Random();
            int    start = Convert.ToInt32(EventSkuMappingData.BargainStartPrice);
            int    End   = Convert.ToInt32(EventSkuMappingData.BargainEndPrice);
            int    math  = ran.Next(start, End);
            //砍价后的价格
            decimal Result = NowMoney - Convert.ToDecimal(math);
            if (Result < EventSkuMappingData.BasePrice)
            {//如果Result小于底价,那Result赋值为底价金额值
                Result = EventSkuMappingData.BasePrice.Value;
            }
            //砍了多少
            decimal BargainPrice = NowMoney - Result;
            //赋值
            rd.BargainPrice = BargainPrice;
            #endregion

            using (pTran.Connection)
            {
                try
                {
                    //添加砍价参与者信息
                    var AddData = new PanicbuyingKJEventJoinDetailEntity();
                    AddData.KJEventJoinDetailId = System.Guid.NewGuid();
                    AddData.KJEventJoinId       = KJEventJoinData.KJEventJoinId;
                    AddData.EventId             = new System.Guid(rp.EventId);
                    AddData.ItemId           = rp.ItemId;
                    AddData.SkuId            = rp.SkuId;
                    AddData.VipId            = pRequest.UserID;
                    AddData.BargainPrice     = BargainPrice;
                    AddData.MomentSalesPrice = Result;
                    AddData.CustomerId       = CurrentUserInfo.ClientID;
                    //
                    Bll.Create(AddData, pTran);
                    //更新参与主表帮砍统计、成交价
                    KJEventJoinData.BargainPersonCount  = KJEventJoinData.BargainPersonCount ?? 0;
                    KJEventJoinData.BargainPersonCount += 1;
                    KJEventJoinData.SalesPrice          = KJEventJoinData.SalesPrice ?? 0;
                    KJEventJoinData.SalesPrice          = Result;
                    KJEventJoinBll.Update(KJEventJoinData, pTran);
                    //更新砍价活动表帮砍人数统记
                    EventData.BargainPersonCount += 1;
                    PanicbuyingEventBll.Update(EventData, pTran);
                    //更新活动商品帮砍人数统计
                    EventItemData.BargainPersonCount  = EventItemData.BargainPersonCount ?? 0;
                    EventItemData.BargainPersonCount += 1;
                    KJEventItemMappingBll.Update(EventItemData, pTran);
                    //提交
                    pTran.Commit();
                }
                catch (APIException ex)
                {
                    pTran.Rollback();
                    throw ex;
                }
            }
            return(rd);
        }
    }
}
Exemplo n.º 10
0
        protected override SetBargainRD ProcessRequest(DTO.Base.APIRequest <SetBargainRP> pRequest)
        {
            var    rd   = new SetBargainRD();
            var    para = pRequest.Parameters;
            var    loggingSessionInfo  = new SessionManager().CurrentUserLoginInfo;
            var    bllPanicbuyingEvent = new PanicbuyingEventBLL(loggingSessionInfo);
            string REventId            = string.Empty;


            if (string.IsNullOrEmpty(para.EventId))
            {
                var entityPanicbuyingEvent = new PanicbuyingEventEntity();
                entityPanicbuyingEvent.EventId   = System.Guid.NewGuid();
                entityPanicbuyingEvent.EventName = para.EventName;

                #region  称重复处理
                var Result = bllPanicbuyingEvent.QueryByEntity(new PanicbuyingEventEntity()
                {
                    EventName = para.EventName, EventTypeId = 4, CustomerID = CurrentUserInfo.ClientID
                }, null).ToList();
                if (Result.Count() > 0)
                {
                    throw new APIException("已有相同的砍价活动名称,请重新命名!");
                }
                #endregion

                entityPanicbuyingEvent.BeginTime = para.BeginTime;
                entityPanicbuyingEvent.EndTime   = para.EndTime;
                //
                entityPanicbuyingEvent.EventTypeId        = 4;
                entityPanicbuyingEvent.EventStatus        = 20;
                entityPanicbuyingEvent.PromotePersonCount = 0;
                entityPanicbuyingEvent.BargainPersonCount = 0;
                entityPanicbuyingEvent.ItemQty            = 0;
                entityPanicbuyingEvent.IsCTW      = 0;
                entityPanicbuyingEvent.CustomerID = loggingSessionInfo.ClientID;
                bllPanicbuyingEvent.Create(entityPanicbuyingEvent);
                //
                REventId = entityPanicbuyingEvent.EventId.ToString();
            }
            else
            {
                var UpdateData = bllPanicbuyingEvent.GetByID(para.EventId);
                if (UpdateData == null)
                {
                    throw new APIException("未找到砍价活动!")
                          {
                              ErrorCode = ERROR_CODES.INVALID_BUSINESS
                          }
                }
                ;

                #region  称重复处理
                if (!UpdateData.EventName.Trim().Equals(para.EventName.Trim()))
                {
                    var Result = bllPanicbuyingEvent.QueryByEntity(new PanicbuyingEventEntity()
                    {
                        EventName = para.EventName, EventTypeId = 4, CustomerID = CurrentUserInfo.ClientID
                    }, null).ToList();
                    if (Result.Count() > 0)
                    {
                        throw new APIException("已有相同的砍价活动名称,请重新命名!")
                              {
                                  ErrorCode = ERROR_CODES.INVALID_BUSINESS
                              }
                    }
                    ;
                }
                #endregion

                if (UpdateData.EndTime < DateTime.Now)
                {
                    throw new APIException("砍价活动已经结束了!")
                          {
                              ErrorCode = ERROR_CODES.INVALID_BUSINESS
                          }
                }
                ;

                UpdateData.EventName = para.EventName;
                UpdateData.BeginTime = para.BeginTime;
                UpdateData.EndTime   = para.EndTime;
                bllPanicbuyingEvent.Update(UpdateData);
                //
                REventId = para.EventId;
            }
            rd.EventId = REventId;

            return(rd);
        }
    }
}
Exemplo n.º 11
0
        /// <summary>
        /// 活动列表
        /// </summary>
        /// <param name="pRequest"></param>
        /// <returns></returns>
        public string GetPanicbuyingEvent(string pRequest)
        {
            var rp = pRequest.DeserializeJSONTo <APIRequest <GetPanicbuyingEventRP> >();
            var loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, rp.UserID);
            //var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo;
            var rd       = new PanicbuyingEventRD();
            var eventBll = new PanicbuyingEventBLL(loggingSessionInfo);
            //查询参数
            List <IWhereCondition> complexCondition = new List <IWhereCondition> {
            };

            if (rp.Parameters.EventTypeId != 0)
            {
                complexCondition.Add(new EqualsCondition()
                {
                    FieldName = "EventTypeId", Value = rp.Parameters.EventTypeId
                });
                complexCondition.Add(new EqualsCondition()
                {
                    FieldName = "CustomerID", Value = loggingSessionInfo.ClientID
                });
            }

            //IsCTW是1时是创意活动,为0或者null时为非创意活动****
            if (rp.Parameters.IsCTW == 1)
            {
                complexCondition.Add(new EqualsCondition()
                {
                    FieldName = "IsCTW", Value = rp.Parameters.IsCTW
                });
            }
            else
            {
                complexCondition.Add(new DirectCondition(" (IsCTW is null or  IsCTW=0) "));
            }
            if (!string.IsNullOrEmpty(rp.Parameters.CTWEventId))
            {
                complexCondition.Add(new DirectCondition(" (Eventid in  (select leventid from T_CTW_LEventInteraction where  convert(varchar(50), ctwEventid)='" + rp.Parameters.CTWEventId + "' )) "));
            }


            //排序参数
            List <OrderBy> lstOrder = new List <OrderBy> {
            };

            //  lstOrder.Add(new OrderBy() { FieldName = "StatusValue", Direction = OrderByDirections.Desc });
            lstOrder.Add(new OrderBy()
            {
                FieldName = "BeginTime", Direction = OrderByDirections.Asc
            });
            //查询

            var tempEvent = eventBll.GetPanicbuyingEvent(complexCondition.ToArray(), lstOrder.ToArray(), rp.Parameters.PageSize, rp.Parameters.PageIndex + 1);
            List <PanicbuyingEvent> eventList = new List <PanicbuyingEvent> {
            };

            eventList.AddRange(tempEvent.Entities.Select(t => new PanicbuyingEvent()
            {
                EventId       = t.EventId,
                EventName     = t.EventName,
                EventTypeId   = t.EventTypeId,
                BeginTime     = t.BeginTime.ToString("yyyy-MM-dd HH:mm"),
                EndTime       = t.EndTime.ToString("yyyy-MM-dd HH:mm"),
                BeginTimeName = t.BeginTime.Month + "月" + t.BeginTime.Day + "日",  //t.BeginTime.ToString("MM-dd HH:mm"),
                CustomerID    = t.CustomerID,
                Qty           = t.Qty,
                RemainQty     = t.RemainQty,
                EventStatus   = t.EventStatusStr
            }));
            rd.PanicbuyingEventList = eventList.ToArray();
            rd.TotalPage            = tempEvent.PageCount;
            //创意仓库分享信息
            Share share = new Share();
            T_CTW_SpreadSettingBLL bllSpreadSetting = new T_CTW_SpreadSettingBLL(loggingSessionInfo);
            DataSet dsShare = bllSpreadSetting.GetSpreadSettingQRImageByCTWEventId(rp.Parameters.CTWEventId, "Share");

            if (dsShare != null && dsShare.Tables.Count > 0 && dsShare.Tables[0].Rows.Count > 0)
            {
                share.Title             = dsShare.Tables[0].Rows[0]["Title"].ToString();
                share.Summary           = dsShare.Tables[0].Rows[0]["Summary"].ToString();
                share.ImageUrl          = dsShare.Tables[0].Rows[0]["BGImageUrl"].ToString();
                share.OnLineRedirectUrl = dsShare.Tables[0].Rows[0]["OnLineRedirectUrl"].ToString();
            }
            rd.ShareInfo = share;
            var rsp = new SuccessResponse <IAPIResponseData>(rd);

            return(rsp.ToJSON());
            //return "{\"ResultCode\":0,\"Message\":\"OK\",\"IsSuccess\":true,\"Data\":{\"TotalPage\":1,\"PanicbuyingEventList\":[{\"CustomerID\":\"1E8CFF7F-214A-4DC2-BA1D-F61576A39824\",\"EventTypeId\":1,\"EventId\":\"1E8CFF7F-214A-4DC2-BA1D-F61576A39824\",\"EventName\":\"\u9524\u5B50\u624B\u673A\u56E2\u8D2D\",\"BeginTime\":\"2014-07-25 10:00\",\"EndTime\":\"2014-07-29 20:00\",\"Qty\":100,\"RemainQty\":10,\"EventStatus\":\"\u5DF2\u4E0A\u67B6\"},{\"CustomerID\":\"1E8CFF7F-214A-4DC2-BA1D-F61576A39824\",\"EventTypeId\":1,\"EventId\":\"1E8CFF7F-214A-4DC2-BA1D-F61576A39824\",\"EventName\":\"\u82F9\u679C\u624B\u673A\u56E2\u8D2D\",\"BeginTime\":\"2014-07-25 10:00\",\"EndTime\":\"2014-07-29 20:00\",\"Qty\":100,\"RemainQty\":10,\"EventStatus\":\"\u5DF2\u4E0A\u67B6\"}]}}";
        }
Exemplo n.º 12
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\"}]}]}}";
        }
        protected override GetPanicbuyingKJItemDetailRD ProcessRequest(APIRequest <GetPanicBuyingKJItemDetailRP> pRequest)
        {
            GetPanicBuyingKJItemDetailRP rp = pRequest.Parameters;
            GetPanicbuyingKJItemDetailRD rd = new GetPanicbuyingKJItemDetailRD();

            OnlineShoppingItemBLL itemService    = new OnlineShoppingItemBLL(CurrentUserInfo);
            ItemService           itemServiceBll = new ItemService(CurrentUserInfo);
            var customerBasicSettingBll          = new CustomerBasicSettingBLL(CurrentUserInfo);
            var panicbuyingEventBll = new PanicbuyingEventBLL(CurrentUserInfo);
            var panicbuyingKJEventItemMappingBll = new PanicbuyingKJEventItemMappingBLL(CurrentUserInfo);
            var panicbuyingKJEventSkuMappingBll  = new PanicbuyingKJEventSkuMappingBLL(CurrentUserInfo);
            var panicbuyingKJEventJoinBll        = new PanicbuyingKJEventJoinBLL(CurrentUserInfo);
            var panicbuyingKJEventJoinDetailBll  = new PanicbuyingKJEventJoinDetailBLL(CurrentUserInfo);
            var vipBll = new VipBLL(CurrentUserInfo);

            var vipEntity = vipBll.GetByID(pRequest.UserID);

            if (vipEntity != null)
            {
                rd.HeadImageUrl = vipEntity.HeadImgUrl;
            }

            #region 判断是否已经参与
            rd.isPromoted = 0;
            if (!string.IsNullOrEmpty(rp.KJEventJoinId))
            {
                var panicbuyingKJEventJoinEntity = panicbuyingKJEventJoinBll.GetByID(rp.KJEventJoinId);
                if (panicbuyingKJEventJoinEntity == null)
                {
                    rd.isPromoted = 0;
                }
                else
                {
                    rd.isPromoted = 1;

                    var VipData = vipBll.GetByID(panicbuyingKJEventJoinEntity.VipId);
                    rd.HeadImageUrl = VipData.HeadImgUrl;
                }
            }
            #endregion

            //为复用原来接口所设置参数
            DateTime dtBeginTime = Convert.ToDateTime("9999/01/01");
            DateTime dtEndTime   = Convert.ToDateTime("9999/01/01");


            #region  价活动商品基本信息
            KJEventItemDetailInfo eventItemInfo = panicbuyingEventBll.GetKJEventWithItemDetail(rp.EventId, rp.ItemId);
            if (eventItemInfo != null)
            {
                rd.ItemId             = eventItemInfo.ItemId;
                rd.ItemName           = eventItemInfo.ItemName;
                rd.MinPrice           = eventItemInfo.MinPrice;
                rd.MinBasePrice       = eventItemInfo.MinBasePrice;
                rd.SinglePurchaseQty  = eventItemInfo.SinglePurchaseQty;
                rd.PromotePersonCount = eventItemInfo.PromotePersonCount;
                rd.CurrentQty         = eventItemInfo.CurrentQty;
                rd.SoldQty            = eventItemInfo.SoldQty;
                rd.EventEndTime       = eventItemInfo.EventEndTime.ToString("yyyy-MM-dd HH:mm:ss");
                rd.Seconds            = Convert.ToInt64(eventItemInfo.EventEndTime.Subtract(DateTime.Now).TotalSeconds < 0 ? 0 : eventItemInfo.EventEndTime.Subtract(DateTime.Now).TotalSeconds);
                rd.PropName1          = eventItemInfo.Prop1Name;
                rd.PropName2          = eventItemInfo.Prop2Name;
                rd.ItemIntroduce      = eventItemInfo.ItemIntroduce;

                #endregion

                #region
                if (eventItemInfo.EventEndTime < DateTime.Now)
                {
                    rd.isEventEnd = 0;
                }
                else if (eventItemInfo.EventBeginTime > DateTime.Now)
                {//活动未开始
                    rd.isEventEnd = 2;
                    rd.Seconds    = Convert.ToInt64(eventItemInfo.EventBeginTime.Subtract(DateTime.Now).TotalSeconds < 0 ? 0 : eventItemInfo.EventBeginTime.Subtract(DateTime.Now).TotalSeconds);
                }
                else
                {
                    rd.isEventEnd = 1;
                }
                #endregion

                #region 商品图片
                var dsImages = itemService.GetItemImageList(rp.ItemId);
                if (dsImages != null && dsImages.Tables.Count > 0 && dsImages.Tables[0].Rows.Count > 0)
                {
                    rd.ImageList = DataTableToObject.ConvertToList <ImageInfo>(dsImages.Tables[0]);
                }
                #endregion

                #region 商品详情页
                if (rp.type == 1)
                {
                    #region 关于商品所有Sku信息
                    var dsSkus = itemServiceBll.GetItemSkuList(rp.ItemId, pRequest.UserID, pRequest.CustomerID, dtBeginTime, dtEndTime);
                    var panicbuyingKJEventSkuMappingList = panicbuyingKJEventSkuMappingBll.QueryByEntity(new PanicbuyingKJEventSkuMappingEntity()
                    {
                        EventItemMappingID = eventItemInfo.EventItemMappingID
                    }, null).ToList();
                    if (dsSkus != null && dsSkus.Tables.Count > 0 && dsSkus.Tables[0].Rows.Count > 0)
                    {
                        rd.SkuInfoList = DataTableToObject.ConvertToList <ItemSkuInfo>(dsSkus.Tables[0]);
                    }
                    rd.SkuInfoList = rd.SkuInfoList.Join(panicbuyingKJEventSkuMappingList, n => n.skuId, m => m.SkuID, (n, m) => new ItemSkuInfo()
                    {
                        skuId      = n.skuId,
                        skuProp1   = n.skuProp1,
                        skuProp2   = n.skuProp2,
                        BasePrice  = m.BasePrice.ToString(),
                        price      = m.Price.ToString(),
                        SalesCount = m.SoldQty.ToString(),
                        Stock      = (m.Qty - m.SoldQty).ToString(),
                    }).Distinct().ToList();
                    #endregion

                    #region 商品属性
                    var dsProp1 = panicbuyingKJEventItemMappingBll.GetKJItemProp1List(rp.ItemId, rp.EventId);
                    if (dsProp1 != null && dsProp1.Tables.Count > 0 && dsProp1.Tables[0].Rows.Count > 0)
                    {
                        rd.Prop1List = DataTableToObject.ConvertToList <SkuProp1>(dsProp1.Tables[0]);
                    }
                    #endregion
                    rd.status = 1;
                }
                #endregion

                #region 帮砍页面
                if (rp.type == 2 && rd.isPromoted == 1)
                {
                    if (!string.IsNullOrEmpty(rp.SkuId))
                    {
                        KJItemSkuInfo kJItemSkuInfo = panicbuyingKJEventSkuMappingBll.GetKJItemSkuInfo(rp.EventId, rp.SkuId, rp.KJEventJoinId);
                        rd.SkuInfoList = new List <ItemSkuInfo>();

                        ItemSkuInfo itemSkuInfo = new ItemSkuInfo();
                        itemSkuInfo.skuId    = kJItemSkuInfo.skuId;
                        itemSkuInfo.skuProp1 = kJItemSkuInfo.skuProp1;
                        itemSkuInfo.skuProp2 = kJItemSkuInfo.skuProp2;
                        itemSkuInfo.price    = kJItemSkuInfo.price.ToString();
                        itemSkuInfo.Stock    = kJItemSkuInfo.Stock;
                        rd.SkuInfoList.Add(itemSkuInfo);

                        rd.BargainedPrice    = kJItemSkuInfo.price - kJItemSkuInfo.SalesPrice;
                        rd.MinPrice          = kJItemSkuInfo.price;
                        rd.MinBasePrice      = kJItemSkuInfo.BasePrice;
                        rd.EventSKUMappingId = kJItemSkuInfo.EventSKUMappingId;

                        double EventTime = Convert.ToInt64(eventItemInfo.EventEndTime.Subtract(DateTime.Now).TotalSeconds < 0 ? 0 : eventItemInfo.EventEndTime.Subtract(DateTime.Now).TotalSeconds);
                        double tempTime  = (kJItemSkuInfo.CreateTime.AddHours(Convert.ToDouble(eventItemInfo.BargaingingInterval)) - DateTime.Now).TotalSeconds;
                        if (EventTime > tempTime)
                        {
                            rd.Seconds = Convert.ToInt64(tempTime < 0 ? 0 : tempTime);
                        }
                        else
                        {
                            rd.Seconds = Convert.ToInt64(EventTime < 0 ? 0 : EventTime);
                        }


                        decimal tempPrice = rd.MinPrice - rd.MinBasePrice;
                        if (tempPrice != 0)
                        {
                            rd.BargainedRate = Math.Round(rd.BargainedPrice / (tempPrice), 2);
                        }
                        else
                        {
                            rd.BargainedRate = 0;
                        }

                        if (!string.IsNullOrEmpty(rp.KJEventJoinId))
                        {
                            var panicbuyingKJEventJoinDetailEntity = panicbuyingKJEventJoinDetailBll.QueryByEntity(new PanicbuyingKJEventJoinDetailEntity()
                            {
                                KJEventJoinId = new Guid(rp.KJEventJoinId), VipId = pRequest.UserID
                            }, null).FirstOrDefault();
                            if (panicbuyingKJEventJoinDetailEntity == null)
                            {
                                rd.status = 2;
                            }
                            else
                            {
                                rd.status = 3;
                            }
                        }
                        else
                        {
                            rd.status = 2;
                        }
                    }
                }
                #endregion

                rd.DeliveryDesc      = customerBasicSettingBll.GetSettingValueByCode("DeliveryStrategy");
                rd.CustomerShortName = customerBasicSettingBll.GetSettingValueByCode("CustomerShortName");
                rd.WebLogo           = customerBasicSettingBll.GetSettingValueByCode("WebLogo");
                rd.QRCodeURL         = customerBasicSettingBll.GetSettingValueByCode("GuideQRCode");
            }
            else
            {
                throw new APIException("此活动已不存在")
                      {
                          ErrorCode = 100
                      };
            }
            return(rd);
        }
Exemplo n.º 14
0
        protected override GetBargainListRD ProcessRequest(DTO.Base.APIRequest <GetBargainListRP> pRequest)
        {
            var rd = new GetBargainListRD();

            var para = pRequest.Parameters;
            var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo;
            var bll = new PanicbuyingEventBLL(loggingSessionInfo);

            var complexCondition = new List <IWhereCondition> {
            };

            if (!string.IsNullOrWhiteSpace(para.EventName))
            {
                complexCondition.Add(new LikeCondition()
                {
                    FieldName = "EventName ", Value = "%" + para.EventName + "%"
                });
            }
            if (para.EventStatus > 0)
            {
                #region MyRegion
                DateTime m_Date = DateTime.Now;
                //正常状态
                //complexCondition.Add(new DirectCondition("Status=0 "));
                switch (para.EventStatus)
                {
                case 1:
                    //未开始
                    complexCondition.Add(new DirectCondition("BeginTime>'" + m_Date + "' "));
                    break;

                case 2:
                    //运行中
                    complexCondition.Add(new DirectCondition("(BeginTime<='" + m_Date + "' and EndTime>='" + m_Date + "') "));
                    break;

                case 3:
                    //结束
                    complexCondition.Add(new DirectCondition("EndTime<'" + m_Date + "' "));
                    break;

                case 4:
                    //提前结束
                    complexCondition.Add(new EqualsCondition()
                    {
                        FieldName = "EventStatus ", Value = 10
                    });
                    break;

                default:
                    break;
                }
                #endregion
            }
            if (!string.IsNullOrWhiteSpace(para.BeginTime))
            {
                complexCondition.Add(new DirectCondition("BeginTime>='" + para.BeginTime + "' "));
            }
            if (!string.IsNullOrWhiteSpace(para.EndTime))
            {
                complexCondition.Add(new DirectCondition("EndTime<='" + para.EndTime + "' "));
            }
            //商户ID
            complexCondition.Add(new EqualsCondition()
            {
                FieldName = "CustomerID ", Value = loggingSessionInfo.ClientID
            });
            complexCondition.Add(new EqualsCondition()
            {
                FieldName = "EventTypeId ", Value = 4
            });

            //排序参数
            var lstOrder = new List <OrderBy> {
            };
            lstOrder.Add(new OrderBy()
            {
                FieldName = "LastUpdateTime", Direction = OrderByDirections.Desc
            });
            //
            var tempList = bll.PagedQuery(complexCondition.ToArray(), lstOrder.ToArray(), para.PageSize, para.PageIndex);
            rd.TotalPageCount = tempList.PageCount;
            rd.TotalCount     = tempList.RowCount;
            rd.BargainList    = tempList.Entities.Select(t => new BargainInfo()
            {
                EventId            = t.EventId.ToString(),
                EventName          = t.EventName,
                ItemCount          = t.ItemQty == null?0:t.ItemQty.Value,
                PromotePersonCount = t.PromotePersonCount == null ? 0 : t.PromotePersonCount.Value,
                BargainPersonCount = t.BargainPersonCount == null ? 0 : t.BargainPersonCount.Value,
                BeginTime          = t.BeginTime.ToString("yyyy-MM-dd HH:mm"),
                EndTime            = t.EndTime.ToString("yyyy-MM-dd HH:mm"),
                Status             = t.EventStatus.Value
            }).ToList();

            var Time = DateTime.Now;
            //处理状态
            foreach (var item in rd.BargainList)
            {
                if (item.Status == 10)
                {
                    item.Status = 3;
                }
                if (item.Status == 20)
                {
                    if (Convert.ToDateTime(item.BeginTime) > Time)
                    {
                        item.Status = 1;//未开始
                        continue;
                    }
                    if (Convert.ToDateTime(item.BeginTime) <= Time && Convert.ToDateTime(item.EndTime) >= Time)
                    {
                        item.Status = 2;//进行中
                        continue;
                    }
                    if (Convert.ToDateTime(item.EndTime) < Time)
                    {
                        item.Status = 3;//未开始
                        continue;
                    }
                }
            }
            return(rd);
        }
Exemplo n.º 15
0
        protected override EmptyResponseData ProcessRequest(DTO.Base.APIRequest <SetBargainDetailsRP> pRequest)
        {
            var    rd   = new EmptyResponseData();
            var    para = pRequest.Parameters;
            var    loggingSessionInfo  = new SessionManager().CurrentUserLoginInfo;
            var    ItemMappingBll      = new PanicbuyingKJEventItemMappingBLL(loggingSessionInfo);
            var    SkuMappingBll       = new PanicbuyingKJEventSkuMappingBLL(loggingSessionInfo);
            var    PanicbuyingEventBLL = new PanicbuyingEventBLL(loggingSessionInfo);
            var    pTran = ItemMappingBll.GetTran();
            string m_EventItemMappingID = string.Empty;
            int    SumQty = 0;

            using (pTran.Connection)
            {
                try
                {
                    #region 商品
                    if (!string.IsNullOrWhiteSpace(para.EventItemMappingID))
                    {
                        //编辑
                        var UpdateItemData = ItemMappingBll.GetByID(para.EventItemMappingID);
                        if (UpdateItemData == null)
                        {
                            throw new APIException("未找到相关砍价活动商品,请确认参数")
                                  {
                                      ErrorCode = ERROR_CODES.INVALID_BUSINESS
                                  }
                        }
                        ;

                        UpdateItemData.SinglePurchaseQty   = para.SinglePurchaseQty;
                        UpdateItemData.BargaingingInterval = para.BargaingingInterval;
                        //
                        ItemMappingBll.Update(UpdateItemData, pTran);
                        //
                        m_EventItemMappingID = para.EventItemMappingID;
                    }
                    else
                    {
                        #region 创建砍价商品

                        var ItemResult = ItemMappingBll.QueryByEntity(new PanicbuyingKJEventItemMappingEntity()
                        {
                            EventId = new Guid(para.EventId), ItemID = para.ItemId
                        }, null).ToList();
                        if (ItemResult.Count() > 0)
                        {
                            throw new APIException("当前砍价活动已添加过相同的商品,请换一个商品添加!")
                                  {
                                      ErrorCode = ERROR_CODES.INVALID_BUSINESS
                                  }
                        }
                        ;


                        var AddItemData = new PanicbuyingKJEventItemMappingEntity();
                        AddItemData.EventItemMappingID = System.Guid.NewGuid();
                        AddItemData.EventId            = new Guid(para.EventId);
                        AddItemData.ItemID             = para.ItemId;
                        AddItemData.MinPrice           = 0;
                        AddItemData.MinBasePrice       = 0;
                        AddItemData.SoldQty            = 0;
                        AddItemData.Qty                 = 0;
                        AddItemData.KeepQty             = 0;
                        AddItemData.SinglePurchaseQty   = para.SinglePurchaseQty;
                        AddItemData.DiscountRate        = 0;
                        AddItemData.PromotePersonCount  = 0;
                        AddItemData.BargainPersonCount  = 0;
                        AddItemData.PurchasePersonCount = 0;
                        AddItemData.Status              = 1;
                        AddItemData.StatusReason        = "";
                        AddItemData.DisplayIndex        = 0;
                        AddItemData.BargaingingInterval = para.BargaingingInterval;
                        AddItemData.customerId          = loggingSessionInfo.ClientID;
                        //
                        ItemMappingBll.Create(AddItemData, pTran);
                        //更新活动商品数量
                        var UpdateEventData = PanicbuyingEventBLL.GetByID(para.EventId);
                        if (UpdateEventData == null)
                        {
                            throw new APIException("未找到相关砍价活动,请确认参数")
                                  {
                                      ErrorCode = ERROR_CODES.INVALID_BUSINESS
                                  }
                        }
                        ;
                        UpdateEventData.ItemQty += 1;
                        PanicbuyingEventBLL.Update(UpdateEventData, pTran);
                        //
                        m_EventItemMappingID = AddItemData.EventItemMappingID.ToString();
                        #endregion
                    }
                    #endregion
                    #region sku
                    if (para.EventSkuInfoList.Count > 0)
                    {
                        foreach (var item in para.EventSkuInfoList)
                        {
                            if (!string.IsNullOrWhiteSpace(item.EventSKUMappingId))
                            {
                                var UpdateSkuData = SkuMappingBll.GetByID(item.EventSKUMappingId);
                                if (UpdateSkuData == null)
                                {
                                    throw new APIException("未找到相关砍价活动商品规格信息,请确认参数")
                                          {
                                              ErrorCode = ERROR_CODES.INVALID_BUSINESS
                                          }
                                }
                                ;

                                if (item.IsDelete == 1)
                                {
                                    //删除
                                    SkuMappingBll.Delete(UpdateSkuData, pTran);
                                    //
                                    //
                                    SumQty += -UpdateSkuData.Qty.Value;
                                }
                                else
                                {
                                    //
                                    SumQty += item.Qty - UpdateSkuData.Qty.Value;
                                    #region 编辑
                                    UpdateSkuData.BasePrice         = item.BasePrice;
                                    UpdateSkuData.Qty               = item.Qty;
                                    UpdateSkuData.BargainStartPrice = item.BargainStartPrice;
                                    UpdateSkuData.BargainEndPrice   = item.BargainEndPrice;
                                    //
                                    SkuMappingBll.Update(UpdateSkuData, pTran);
                                    #endregion
                                }
                            }
                            else
                            {
                                #region 创建

                                var SkuResult = SkuMappingBll.QueryByEntity(new PanicbuyingKJEventSkuMappingEntity()
                                {
                                    EventItemMappingID = m_EventItemMappingID, SkuID = item.SkuID
                                }, null).ToList();
                                if (SkuResult.Count() > 0)
                                {
                                    throw new APIException("当前砍价活动商品已添加过相同的Sku,请换一个!")
                                          {
                                              ErrorCode = ERROR_CODES.INVALID_BUSINESS
                                          }
                                }
                                ;

                                var AddSkuData = new PanicbuyingKJEventSkuMappingEntity();
                                AddSkuData.EventSKUMappingId  = System.Guid.NewGuid();
                                AddSkuData.EventItemMappingID = m_EventItemMappingID;
                                AddSkuData.SkuID             = item.SkuID;
                                AddSkuData.AddedTime         = DateTime.Now;
                                AddSkuData.Qty               = item.Qty;
                                AddSkuData.KeepQty           = 0;
                                AddSkuData.SoldQty           = 0;
                                AddSkuData.SinglePurchaseQty = 0;
                                AddSkuData.Price             = item.Price;
                                AddSkuData.BasePrice         = item.BasePrice;
                                AddSkuData.BargainStartPrice = item.BargainStartPrice;
                                AddSkuData.BargainEndPrice   = item.BargainEndPrice;
                                AddSkuData.DisplayIndex      = 0;
                                AddSkuData.IsFirst           = 1;
                                AddSkuData.Status            = 1;
                                AddSkuData.CustomerId        = loggingSessionInfo.ClientID;
                                //
                                SkuMappingBll.Create(AddSkuData, pTran);
                                //
                                SumQty += AddSkuData.Qty.Value;
                                #endregion
                            }
                        }
                    }
                    #endregion
                    //提交
                    pTran.Commit();
                }
                catch (APIException ex)
                {
                    pTran.Rollback();
                    throw ex;
                }
            }
            //更新砍价商品总库存、最小底价、原价
            if (SumQty > 0)
            {
                var UpdateData = ItemMappingBll.GetByID(m_EventItemMappingID);
                UpdateData.Qty         += SumQty;
                UpdateData.MinPrice     = SkuMappingBll.GetConfigPrice(UpdateData.EventItemMappingID.ToString(), "MinPrice");
                UpdateData.MinBasePrice = SkuMappingBll.GetConfigPrice(UpdateData.EventItemMappingID.ToString(), "MinBasePrice");
                ItemMappingBll.Update(UpdateData);
            }

            return(rd);
        }
Exemplo n.º 16
0
        protected override JoinInKJEventRD ProcessRequest(APIRequest <JoinInKJEventRP> pRequest)
        {
            JoinInKJEventRP rp = pRequest.Parameters;
            JoinInKJEventRD rd = new JoinInKJEventRD();

            PanicbuyingKJEventJoinBLL        panicbuyingKJEventJoinBll        = new PanicbuyingKJEventJoinBLL(CurrentUserInfo);
            PanicbuyingEventBLL              panicbuyingEventBll              = new PanicbuyingEventBLL(CurrentUserInfo);
            PanicbuyingKJEventItemMappingBLL panicbuyingKJEventItemMappingBll = new PanicbuyingKJEventItemMappingBLL(CurrentUserInfo);

            if (string.IsNullOrEmpty(rp.EventId))
            {
                throw new APIException("EventId不能为空");
            }
            if (string.IsNullOrEmpty(rp.SkuId))
            {
                throw new APIException("SkuId不能为空");
            }

            #region  价参与
            PanicbuyingKJEventJoinEntity panicbuyingKJEventJoinEntity = new PanicbuyingKJEventJoinEntity()
            {
                KJEventJoinId = Guid.NewGuid(),
                EventId       = new Guid(rp.EventId),
                ItemId        = rp.ItemId,
                SkuId         = rp.SkuId,
                VipId         = pRequest.UserID,
                CustomerId    = pRequest.CustomerID,
                SalesPrice    = rp.Price,
            };
            panicbuyingKJEventJoinBll.Create(panicbuyingKJEventJoinEntity);
            #endregion

            #region 更新参与砍价活动人数统计
            var panicbuyingEventEnetity = panicbuyingEventBll.QueryByEntity(new PanicbuyingEventEntity()
            {
                EventId = new Guid(rp.EventId)
            }, null).FirstOrDefault();
            if (panicbuyingEventEnetity != null)
            {
                panicbuyingEventEnetity.PromotePersonCount += 1;
                //panicbuyingEventEnetity.BargainPersonCount += 1;
                panicbuyingEventBll.Update(panicbuyingEventEnetity);
            }
            #endregion

            #region 更新发起砍价商品活动人数统计
            var panicbuyingKJEventItemMappingEntity = panicbuyingKJEventItemMappingBll.QueryByEntity(new PanicbuyingKJEventItemMappingEntity()
            {
                EventId = new Guid(rp.EventId), ItemID = rp.ItemId
            }, null).FirstOrDefault();
            if (panicbuyingKJEventItemMappingEntity != null)
            {
                panicbuyingKJEventItemMappingEntity.PromotePersonCount += 1;
                panicbuyingKJEventItemMappingBll.Update(panicbuyingKJEventItemMappingEntity);
            }
            #endregion


            rd.KJEventJoinId = panicbuyingKJEventJoinEntity.KJEventJoinId.ToString();
            return(rd);
        }