protected override PrizeWinnerListRD ProcessRequest(DTO.Base.APIRequest <GetPrizeLocationListRP> pRequest) { var rd = new PrizeWinnerListRD();//返回值 LPrizeWinnerBLL bllWinner = new LPrizeWinnerBLL(this.CurrentUserInfo); DataTable dtWinner = bllWinner.GetTop10PizewWinnerListByEventId(pRequest.Parameters.EventID).Tables[0]; rd.WinnerList = DataTableToObject.ConvertToList <WinnerInfo>(dtWinner); rd.TotalCount = dtWinner.Rows.Count; return(rd); }
/// <summary> /// 获取活动奖项信息 /// </summary> public string getEventPrizes() { string content = string.Empty; var respData = new getEventPrizesRespData(); try { string reqContent = Request["ReqContent"]; var reqObj = reqContent.DeserializeJSONTo <getEventPrizesReqData>(); string openId = reqObj.common.openId; string weixinId = reqObj.common.weiXinId ?? reqObj.common.openId; string eventId = reqObj.special.eventId; //活动ID string vipId = reqObj.common.userId; string vipName = string.Empty; string longitude = reqObj.special.longitude; //经度 string latitude = reqObj.special.latitude; //纬度 if (string.IsNullOrEmpty(eventId)) { eventId = "E5A304D716D14CD2B96560EBD2B6A29C"; } Loggers.Debug(new DebugLogInfo() { Message = string.Format("getEventPrizes: {0}", reqContent) }); //判断客户ID是否传递 if (!string.IsNullOrEmpty(reqObj.common.customerId)) { customerId = reqObj.common.customerId; } var loggingSessionInfo = Default.GetBSLoggingSession(customerId, "1"); respData.content = new getEventPrizesRespContentData(); respData.content.prizeList = new List <PrizesEntity>(); var eventList = new LEventsBLL(loggingSessionInfo).QueryByEntity(new LEventsEntity { EventID = eventId }, null); if (eventList != null && eventList.Length > 0) { var eventEntity = eventList.FirstOrDefault(); if (Convert.ToDateTime(eventEntity.EndTime).AddDays(1) > DateTime.Now) //当天还是有效的 updated by Willie Yan on 2014-04-28 { #region 获取VIPID VipBLL vipService = new VipBLL(loggingSessionInfo); var vipList = vipService.QueryByEntity(new VipEntity() { WeiXinUserId = openId }, null); if (vipList == null || vipList.Length == 0) { respData.code = "103"; respData.description = "未查找到匹配的VIP信息"; return(respData.ToJSON()); } else { vipId = vipList.FirstOrDefault().VIPID; vipName = vipList.FirstOrDefault().VipName; } #endregion //查询抽奖日志 LLotteryLogBLL lotteryService = new LLotteryLogBLL(loggingSessionInfo); var lotteryList = lotteryService.QueryByEntity(new LLotteryLogEntity() { EventId = eventId, VipId = vipId }, null); #region 奖品信息 LPrizesBLL prizesService = new LPrizesBLL(loggingSessionInfo); var prizesList = prizesService.QueryByEntity(new LPrizesEntity() { EventId = eventId }, new OrderBy[] { new OrderBy { FieldName = " DisplayIndex ", Direction = OrderByDirections.Asc } }); if (prizesList != null && prizesList.Length > 0) { foreach (var item in prizesList) { var entity = new PrizesEntity() { prizesID = item.PrizesID, prizeName = item.PrizeName, prizeDesc = item.PrizeDesc, displayIndex = item.DisplayIndex.ToString(), countTotal = item.CountTotal.ToString(), imageUrl = item.ImageUrl }; respData.content.prizeList.Add(entity); } } #endregion #region 抽奖信息 //respData.content.lotteryCount = eventEntity.PrizesCount.ToString(); respData.content.lotteryNumber = "0"; respData.content.validTime = ConfigurationManager.AppSettings["ValidTime"]; int totalLotteryCount = 0; //获取剩余抽奖次数 VwVipCenterInfoBLL vwVipCenterInfoBLL = new VwVipCenterInfoBLL(loggingSessionInfo); var vwVipCenterInfo = vwVipCenterInfoBLL.GetByID(vipId); totalLotteryCount = vwVipCenterInfo.LotteryCount ?? 0; //获取已抽奖次数 if (lotteryList != null && lotteryList.Length > 0) { respData.content.lotteryNumber = lotteryList.FirstOrDefault().LotteryCount.ToString(); } else { totalLotteryCount++; //如果未抽奖,活动默认有一次抽奖机会 } //判断抽奖次数是否有效 if (Convert.ToInt32(respData.content.lotteryNumber) >= totalLotteryCount) { respData.content.isLottery = "0"; respData.content.lotteryDesc = "您已经没有抽奖机会了,想得到更多抽奖机会,请在对话栏内发送中文“分享”给我们,获得图文消息后多多转发。详情关注“推荐有礼”菜单。"; } else { //判断之前是否已经中奖 LPrizeWinnerBLL winnerService = new LPrizeWinnerBLL(loggingSessionInfo); var prize = winnerService.GetWinnerInfo(vipId, eventId); if (!prize.Read()) { //抽奖 LPrizePoolsBLL poolsServer = new LPrizePoolsBLL(loggingSessionInfo); var returnDataObj = poolsServer.SetShakeOffLottery(vipName, vipId, eventId, ToFloat(longitude), ToFloat(latitude)); if (returnDataObj.Params.result_code.Equals("1")) //中奖 { //获取奖品信息 prize = winnerService.GetWinnerInfo(vipId, eventId); if (prize.Read()) { var prizeValue = GetPrizeValue(prize["PrizeShortDesc"].ToString()); respData.content.isLottery = "1"; respData.content.lotteryDesc = returnDataObj.Params.result_message;// "恭喜您中奖了"; respData.content.isWinning = "1"; respData.content.winningValue = prizeValue; } //added by zhangwei 中奖后绑定推荐关系,设置奖项 BindRecommender(); setEventPrizes(); } else //没有中奖,一直能抽奖 { respData.content.isLottery = "1"; respData.content.isWinning = "0"; respData.content.winningValue = "0"; respData.content.lotteryDesc = "恭喜您中奖了";//张伟,为泸州老窖新人有礼前台判断使用 } } else { var prizeValue = GetPrizeValue(prize["PrizeShortDesc"].ToString()); respData.content.isLottery = "1"; respData.content.lotteryDesc = "恭喜您中奖了"; respData.content.isWinning = "1"; respData.content.winningValue = prizeValue; } prize.Close(); respData.content.lotteryCount = totalLotteryCount.ToString(); } #endregion } else { respData.content.isLottery = "0"; respData.content.lotteryDesc = "活动已经结束"; } } else { respData.content.isLottery = "0"; respData.content.lotteryDesc = "指定的活动不存在"; } } catch (Exception ex) { respData.code = "103"; respData.description = "数据库操作错误"; //respData.exception = ex.ToString(); } content = respData.ToJSON(); return(content); }
protected override CTWEventShareLogRD ProcessRequest(DTO.Base.APIRequest <CTWEventShareLogRP> pRequest) { var rd = new CTWEventShareLogRD();//返回值 var para = pRequest.Parameters; if (!string.IsNullOrEmpty(para.CTWEventId) && !string.IsNullOrEmpty(para.Sender) && !string.IsNullOrEmpty(para.OpenId)) { var bllLeventShareLog = new T_LEventsSharePersonLogBLL(this.CurrentUserInfo); var entityLeventShareLog = new T_LEventsSharePersonLogEntity(); entityLeventShareLog.ShareVipID = para.Sender; entityLeventShareLog.ShareOpenID = para.OpenId; entityLeventShareLog.BeShareOpenID = para.BeSharedOpenId; entityLeventShareLog.BeShareVipID = para.BEsharedUserId; entityLeventShareLog.BusTypeCode = "CTW"; entityLeventShareLog.ObjectId = para.CTWEventId; entityLeventShareLog.ShareURL = para.ShareURL; entityLeventShareLog.ShareVipType = 3; bllLeventShareLog.Create(entityLeventShareLog); //是否分享给自己 if (para.Sender == para.BEsharedUserId) { return(rd); } //触点奖励 ContactEventBLL bllContactEvent = new ContactEventBLL(this.CurrentUserInfo); var entityContact = bllContactEvent.QueryByEntity(new ContactEventEntity() { EventId = para.CTWEventId, IsDelete = 0, IsCTW = 1, ContactTypeCode = "Share" }, null).SingleOrDefault(); if (entityContact != null) { LPrizesBLL bllPrize = new LPrizesBLL(this.CurrentUserInfo); LPrizeWinnerBLL bllPrizeWinner = new LPrizeWinnerBLL(this.CurrentUserInfo); LLotteryLogBLL bllLottery = new LLotteryLogBLL(this.CurrentUserInfo); ///判断是否已经获得奖励 int intLogCount = bllLottery.GetEventLotteryLogByEventId(entityContact.ContactEventId.ToString(), para.Sender); if (intLogCount > 0) { return(rd); } var prize = DataTableToObject.ConvertToList <LPrizesEntity>(bllPrize.GetCouponTypeIDByEventId(entityContact.ContactEventId.ToString()).Tables[0]).FirstOrDefault(); if (prize != null) { CouponBLL bllCoupon = new CouponBLL(this.CurrentUserInfo); if (prize.PrizeTypeId == "Coupon") { bllCoupon.CouponBindVip(para.Sender, prize.CouponTypeID, entityContact.ContactEventId.ToString(), "Share"); DataSet ds = bllPrize.GetAllCouponTypeByPrize(prize.PrizesID); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { var redisVipMappingCouponBLL = new JIT.CPOS.BS.BLL.RedisOperationBLL.Coupon.RedisVipMappingCouponBLL(); foreach (DataRow dr in ds.Tables[0].Rows) { redisVipMappingCouponBLL.SetVipMappingCoupon(new CC_Coupon() { CustomerId = this.CurrentUserInfo.ClientID, CouponTypeId = dr["CouponTypeID"].ToString() }, entityContact.ContactEventId.ToString(), para.Sender, "Share"); } } } if (prize.PrizeTypeId == "Point") { #region 调用积分统一接口 var salesReturnBLL = new T_SalesReturnBLL(this.CurrentUserInfo); VipIntegralBLL bllVipIntegral = new VipIntegralBLL(this.CurrentUserInfo); var vipBLL = new VipBLL(this.CurrentUserInfo); var vipInfo = vipBLL.GetByID(para.Sender); var IntegralDetail = new VipIntegralDetailEntity() { Integral = prize.Point, IntegralSourceID = "28", ObjectId = entityContact.ContactEventId.ToString() }; //变动前积分 string OldIntegral = (vipInfo.Integration ?? 0).ToString(); //变动积分 string ChangeIntegral = (IntegralDetail.Integral ?? 0).ToString(); var vipIntegralDetailId = bllVipIntegral.AddIntegral(ref vipInfo, null, IntegralDetail, null, this.CurrentUserInfo); //发送微信积分变动通知模板消息 if (!string.IsNullOrWhiteSpace(vipIntegralDetailId)) { var CommonBLL = new CommonBLL(); CommonBLL.PointsChangeMessage(OldIntegral, vipInfo, ChangeIntegral, vipInfo.WeiXinUserId, this.CurrentUserInfo); } #endregion } #region 奖励日志 LPrizeWinnerEntity entityPrizeWinner = new LPrizeWinnerEntity() { PrizeWinnerID = Guid.NewGuid().ToString(), VipID = para.Sender, PrizeID = prize.PrizesID, PrizeName = prize.PrizeName, PrizePoolID = "", CreateBy = this.CurrentUserInfo.UserID, CreateTime = DateTime.Now, IsDelete = 0 }; bllPrizeWinner.Create(entityPrizeWinner); LLotteryLogEntity lotteryEntity = new LLotteryLogEntity() { LogId = Guid.NewGuid().ToString(), VipId = para.Sender, EventId = entityContact.ContactEventId.ToString(), LotteryCount = 1, IsDelete = 0 }; bllLottery.Create(lotteryEntity); #endregion } } } return(rd); }
private string ExportWinner() { try { var para = HttpContext.Current.Request.Params; string EventId = FormatParamValue(para["eventId"]); var service = new LPrizeWinnerBLL(this.CurrentUserInfo); var dataExport = service.GetPrizeWinnerListByEventId(EventId, 0, 0); //var service = new LEventSignUpBLL(loggingSessionInfo); //GetResponseParams<LEventSignUpEntity> dataList = service.GetEventApplies(para["eventId"] ?? "", 0, 10000); //IList<LEventSignUpEntity> data2 = new List<LEventSignUpEntity>(); int dataTotalCount = 0; var data2 = dataExport.PrizeWinnerList; dataTotalCount = dataExport.ICount; //IList<List<string>> source = new List<List<string>>(); //for (var i = 0; i < dataExport.Count; i++) //{ // var tmpHt = new List<string>(); // var dr = dataExport.PrizeWinnerList[i]; // for (var c = 1; c < dataExport.Columns.Count; c++) // { // tmpHt.Add(dr[c] == null ? "" : dr[c].ToString()); // } // source.Add(tmpHt); //} if (data2 == null || data2.Count == 0) { return(string.Empty); } var fileName = DateTime.Now.ToString("yyyyMMddHHmmssfff") + _random.Next(1, 100).ToString() + ".xls"; var full_path = ExportDir + fileName; var sw = new FileStream(full_path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite); var Writer = new StreamWriter(sw, System.Text.Encoding.UTF8); System.Collections.Generic.List <string> headers = new List <string>(); string[] header_nex = new string[] { }; headers.Add("人员名称"); headers.Add("奖品名称"); headers.Add("时间"); var data = data2; ExportHtmlExcel <LPrizeWinnerEntity>(Writer, headers.ToArray(), data, obj => { var cells = new object[] { obj.VipName ?? "", obj.PrizeName ?? "", (obj.CreateTime == null ? "" : obj.CreateTime.ToString()) }; return(cells); }, null); Writer.Close(); sw.Close(); return(fileName); } catch (Exception ex) { PageLog.Current.Write(ex); return(null); } }