public void SentShipMessage(InoutInfo Inout, string OpenID, string VipID, LoggingSessionInfo loggingSessionInfo) { //这里保持了源代码 if (string.IsNullOrWhiteSpace(OpenID)) { var VipInfo = new VipBLL(loggingSessionInfo).GetByID(Inout.vipId); OpenID = VipInfo == null ? "" : VipInfo.WeiXinUserId; } var CommonBLL = new JIT.CPOS.BS.BLL.WX.CommonBLL(); //根据模板信息的简称和商户的标识获取模板消息的模板内容 var WXTMConfigData = new WXTMConfigBLL(loggingSessionInfo).QueryByEntity(new WXTMConfigEntity() { TemplateIdShort = "OPENTM200565259", CustomerId = loggingSessionInfo.ClientID, IsDelete = 0 }, null).FirstOrDefault(); if (WXTMConfigData == null) { return; } CommonData CommonData = new CommonData(); CommonData.first = new DataInfo() { value = WXTMConfigData.FirstText, color = WXTMConfigData.FirstColour }; CommonData.keyword1 = new DataInfo() { value = Inout.order_no, color = WXTMConfigData.Colour1 }; CommonData.keyword2 = new DataInfo() { value = Inout.carrier_name, color = WXTMConfigData.Colour2 }; CommonData.keyword3 = new DataInfo() { value = Inout.Field2, color = WXTMConfigData.Colour3 }; CommonData.remark = new DataInfo() { value = WXTMConfigData.RemarkText, color = WXTMConfigData.RemarkColour }; //下面往redis里存入数据 var response = RedisOpenAPI.Instance.CCOrderSend().SetOrderSend(new CC_OrderSend { CustomerID = loggingSessionInfo.ClientID, ConfigData = new CC_ConfigData { LogSession = loggingSessionInfo.JsonSerialize(), OpenID = OpenID, TemplateID = WXTMConfigData.TemplateID, VipID = VipID }, OrderSendData = new CC_OrderSendData { first = new CC_DataInfo { value = CommonData.first.value, color = CommonData.first.color }, keyword1 = new CC_DataInfo { value = CommonData.keyword1.value, color = CommonData.keyword1.color }, keyword2 = new CC_DataInfo { value = CommonData.keyword2.value, color = CommonData.keyword2.color }, keyword3 = new CC_DataInfo { value = CommonData.keyword3.value, color = CommonData.keyword3.color }, remark = new CC_DataInfo { value = CommonData.remark.value, color = CommonData.remark.color } } }); //如果往缓存redis里写入不成功,还是按照原来的老方法直接发送 if (response.Code != ResponseCode.Success) { CommonBLL.SendMatchWXTemplateMessage(WXTMConfigData.TemplateID, CommonData, null, null, null, null, null, null, null, "8", OpenID, VipID, loggingSessionInfo); new RedisXML().RedisReadDBCount("OrderSend", "确认收货/完成订单 - 处理奖励", 2); } else { new RedisXML().RedisReadDBCount("OrderSend", "确认收货/完成订单 - 处理奖励", 1); } //return CommonBLL.SendMatchWXTemplateMessage(WXTMConfigData.TemplateID, CommonData, null, null, null, null, "8", OpenID, VipID, loggingSessionInfo); }
/// <summary> /// 主动给用户推送订单消息 /// </summary> /// <returns></returns> public string SetOrderPush() { var respData = new RespData(); if (string.IsNullOrEmpty(Request["WeiXinId"]) || string.IsNullOrEmpty(Request["OpenId"]) || string.IsNullOrEmpty(Request["OrdeNo"])) { respData.Code = "103"; respData.Description = "数据库操作错误"; respData.Exception = "请求的数据不能为空"; return(respData.ToJSON()); } string content = string.Empty; try { string vipID = string.Empty; string vipName = string.Empty; var loggingSessionInfo = Default.GetLjLoggingSession(); //根据客户标识获取连接字符串 qianzhi 2013-07-30 if (!string.IsNullOrEmpty(Request["customerId"])) { loggingSessionInfo = Default.GetBSLoggingSession(Request["customerId"].Trim(), ""); } #region 获取VIP信息 VipBLL vipService = new VipBLL(loggingSessionInfo); var vipList = vipService.QueryByEntity(new VipEntity() { WeiXinUserId = Request["OpenId"], WeiXin = Request["WeiXinId"] }, 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 // 推送消息 string msgUrl = ConfigurationManager.AppSettings["push_weixin_msg_url"].Trim(); string msgText = string.Format("亲爱的会员{1},您单号为{0}的购买请求我们已经收到,请您到指定渠道下交纳钱款。谢谢再次惠顾!", Request["OrdeNo"], vipName); string msgData = "<xml><OpenID><![CDATA[" + Request["OpenId"] + "]]></OpenID><Content><![CDATA[" + msgText + "]]></Content></xml>"; var msgResult = Common.Utils.GetRemoteData(msgUrl, "POST", msgData); #region 发送日志 MarketSendLogBLL logServer = new MarketSendLogBLL(loggingSessionInfo); MarketSendLogEntity logInfo = new MarketSendLogEntity(); logInfo.LogId = BaseService.NewGuidPub(); logInfo.IsSuccess = 1; logInfo.MarketEventId = Request["OrdeNo"]; logInfo.SendTypeId = "2"; logInfo.TemplateContent = msgData; logInfo.VipId = vipID; logInfo.WeiXinUserId = Request["OpenId"]; logInfo.CreateTime = System.DateTime.Now; logServer.Create(logInfo); #endregion Loggers.Debug(new DebugLogInfo() { Message = string.Format("PushMsgResult:{0}", msgResult) }); } catch (Exception ex) { respData.Code = "201"; 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); }
protected override GetEventPrizesRD ProcessRequest(DTO.Base.APIRequest <GetEventPrizesRP> pRequest) { GetEventPrizesRD rd = new GetEventPrizesRD(); string vipID = pRequest.UserID; //string vipID = "f3d925e364e34bf69dfda34fcedc58f8"; string vipName = string.Empty; string reCommandId = pRequest.Parameters.RecommandId; string eventId = pRequest.Parameters.EventId; float longitude = pRequest.Parameters.Longitude; float latitude = pRequest.Parameters.Latitude; string customerId = this.CurrentUserInfo.ClientID; int pointsLotteryFlag = pRequest.Parameters.PointsLotteryFlag; if (string.IsNullOrEmpty(customerId)) { customerId = "f6a7da3d28f74f2abedfc3ea0cf65c01"; } var loggingSessionInfo = Default.GetBSLoggingSession(customerId, "1"); #region 是否在活动现场 //respData.content.isSite = "1"; rd.content = new EventPrizesInfo { IsSite = 1 }; #endregion #region 判断活动是否需要注册 var leventsBll = new LEventsBLL(this.CurrentUserInfo); var enableFlag = leventsBll.GetEnableFlagByEventId(eventId); var vipService = new VipBLL(loggingSessionInfo); rd.SignFlag = 1; //如果需要注册,则判断该会员有没有注册,没有返回 if (enableFlag.Substring(0, 1) == "1") { var vipEntity = vipService.GetByID(vipID); if (vipEntity == null) { rd.SignFlag = 0; return(rd); } else { rd.SignFlag = 1; vipID = vipEntity.VIPID; vipName = vipEntity.VipName; } } #endregion #region 获取VIPID #endregion #region Loggers.Debug(new DebugLogInfo() { Message = "vipName = " + vipName + ",vipID =" + vipID + ",eventId=" + eventId + ",longitude" + longitude + ",latitude" + latitude + ",customerId" + customerId + ",reCommandId" + reCommandId }); LPrizePoolsBLL poolsServer = new LPrizePoolsBLL(loggingSessionInfo); var ds = poolsServer.GetEventWinningInfo(vipName, vipID, eventId, longitude, latitude, customerId, reCommandId, pointsLotteryFlag); int isLottery = Convert.ToInt32(ds.Tables[0].Rows[0]["IsLottery"]); int winnerFlag = Convert.ToInt32(ds.Tables[0].Rows[0]["WinnerFlag"]);//是否中奖 string prizeName = ds.Tables[0].Rows[0]["prizeName"].ToString(); string prizesId = ds.Tables[0].Rows[0]["prizesId"].ToString(); rd.content.IsLottery = isLottery; rd.content.IsWinning = winnerFlag; rd.content.WinningDesc = prizeName; rd.content.Remark = ds.Tables[0].Rows[0]["Remark"].ToString(); rd.content.WinningExplan = ds.Tables[0].Rows[0]["PrizeDesc"].ToString(); rd.content.EventRound = ds.Tables[0].Rows[0]["EventRoundId"].ToString(); rd.content.Status = Convert.ToInt32(ds.Tables[0].Rows[0]["step"].ToString()); rd.content.PrizesTypeName = ds.Tables[0].Rows[0]["prizeTypeName"].ToString(); rd.content.PrizesName = ds.Tables[0].Rows[0]["prizesName"].ToString(); rd.content.EventPoints = Convert.ToInt32(ds.Tables[0].Rows[0]["EventPoints"].ToString()); #region update by wzq 2014/07/01 积分兑换标识(活动,个人) rd.content.PersonPointsLotteryFlag = Convert.ToInt32(ds.Tables[0].Rows[0]["PersonPointsLotteryFlag"].ToString()); rd.content.EventPointsLotteryFlag = Convert.ToInt32(ds.Tables[0].Rows[0]["EventPointsLotteryFlag"].ToString()); #endregion #endregion #region 推荐人 //活动是否分享 var isShare = leventsBll.GetIsShareByEventId(eventId); rd.IsShare = isShare; Loggers.Debug(new DebugLogInfo() { Message = "isShare = " + isShare }); CouponBLL couponService = new CouponBLL(loggingSessionInfo); //Updated by Willie Yan on 2014-05-30 必须是新推荐的会员 if (isShare == 1 && !couponService.IfRecordedRecommendTrace(vipID, reCommandId)) { Loggers.Debug(new DebugLogInfo() { Message = "reCommandId = " + reCommandId + ", VipID = " + vipID }); if (reCommandId != "" && !string.IsNullOrEmpty(reCommandId)) { if (reCommandId != vipID) { var vipEntity = vipService.GetByID(vipID); vipEntity.HigherVipID = reCommandId; vipService.Update(vipEntity); Loggers.Debug(new DebugLogInfo() { Message = "Update HigherVipID = " + reCommandId + "for vipid=" + vipID }); //查看推荐人成功推荐人数,满足条件给奖励 //TODO:added by zhangwei20141009,保存上下线记录 couponService.UpdateVipRecommandTrace(vipID, reCommandId); Loggers.Debug(new DebugLogInfo() { Message = "UpdateVipRecommandTrace vipid=" + vipID + ",reCommandId= " + reCommandId }); couponService.RecommenderPrize(reCommandId, eventId); Loggers.Debug(new DebugLogInfo() { Message = "RecommenderPrize reCommandId= " + reCommandId }); } } } //推荐人是否为空 //推荐人跟vipId是否相同 #endregion #region 奖品集合 LPrizesBLL prizesService = new LPrizesBLL(loggingSessionInfo); var orderby = new List <OrderBy> { new OrderBy() { FieldName = "DisplayIndex", Direction = OrderByDirections.Asc } }; var prizesList = prizesService.QueryByEntity(new LPrizesEntity() { EventId = eventId }, orderby.ToArray()); rd.content.PrizesList = new List <PrizesEntity>(); 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, Sponsor = item.ContentText }; if (prizesId == item.PrizesID) { rd.content.PrizeIndex = item.DisplayIndex; } rd.content.PrizesList.Add(entity); } } #endregion #region 中奖集合 var winDs = poolsServer.GetPersonWinnerList(vipID, eventId); rd.content.WinnerList = new List <WinnerList>(); if (winDs != null && winDs.Tables.Count > 0 && winDs.Tables[0].Rows.Count > 0) { rd.content.WinnerList = DataTableToObject.ConvertToList <WinnerList>(winDs.Tables[0]); } #endregion #region 新增字段 var leventsInfoDs = leventsBll.GetLeventsInfoDataSet(eventId); if (leventsInfoDs.Tables[0].Rows.Count > 0) { rd.BootUrl = leventsInfoDs.Tables[0].Rows[0]["BootUrl"].ToString(); rd.OverRemark = leventsInfoDs.Tables[0].Rows[0]["OverRemark"].ToString(); rd.PosterImageUrl = leventsInfoDs.Tables[0].Rows[0]["PosterImageUrl"].ToString(); rd.ShareRemark = leventsInfoDs.Tables[0].Rows[0]["ShareRemark"].ToString(); rd.ShareLogoUrl = leventsInfoDs.Tables[0].Rows[0]["ShareLogoUrl"].ToString(); } #endregion #region 添加引导页URL //var bootDs = leventsBll.GetBootUrlByEventId(eventId); //if (bootDs.Tables[0].Rows.Count > 0) //{ // rd.ShareRemark = bootDs.Tables[0].Rows[0]["ShareRemark"].ToString(); // rd.OverRemark = bootDs.Tables[0].Rows[0]["OverRemark"].ToString(); // rd.PosterImageUrl = bootDs.Tables[0].Rows[0]["PosterImageUrl"].ToString(); // rd.BootUrl = bootDs.Tables[0].Rows[0]["BootUrl"].ToString(); //} #endregion return(rd); }
protected override GetMemberInfoRD ProcessRequest(DTO.Base.APIRequest <GetMemberInfoRP> pRequest) { GetMemberInfoRD rd = new GetMemberInfoRD(); rd.MemberInfo = new MemberInfo(); var vipLoginBLL = new VipBLL(base.CurrentUserInfo); //如果有一个查询标识非空,就用查询标识查,发现没有会员就报错 if (!string.IsNullOrEmpty(pRequest.Parameters.SearchFlag)) { List <IWhereCondition> complexCondition = new List <IWhereCondition> { }; complexCondition.Add(new EqualsCondition() { FieldName = "ClientID", Value = CurrentUserInfo.ClientID }); var cond1 = new LikeCondition() { FieldName = "VipName", Value = "%" + pRequest.Parameters.SearchFlag + "%" }; var cond2 = new LikeCondition() { FieldName = "VipRealName", Value = "%" + pRequest.Parameters.SearchFlag + "%" }; var com1 = new ComplexCondition() { Left = cond1, Right = cond2, Operator = LogicalOperators.Or }; var cond3 = new EqualsCondition() { FieldName = "Phone", Value = pRequest.Parameters.SearchFlag }; var com2 = new ComplexCondition() { Left = com1, Right = cond3, Operator = LogicalOperators.Or }; complexCondition.Add(com2); complexCondition.Add(new DirectCondition("(WeiXinUserId!='' Or WeiXinUserId IS NOT NULL)")); var tempVipList = vipLoginBLL.Query(complexCondition.ToArray(), null); if (tempVipList != null && tempVipList.Length != 0) { pRequest.UserID = pRequest.Parameters.MemberID = tempVipList[0].VIPID; } } string m_MemberID = ""; if (!string.IsNullOrWhiteSpace(pRequest.Parameters.OwnerVipID)) { m_MemberID = string.IsNullOrWhiteSpace(pRequest.Parameters.OwnerVipID) ? pRequest.UserID : pRequest.Parameters.OwnerVipID; } else { m_MemberID = string.IsNullOrWhiteSpace(pRequest.Parameters.MemberID) ? pRequest.UserID : pRequest.Parameters.MemberID; } string UserID = m_MemberID; var VipLoginInfo = vipLoginBLL.GetByID(UserID); if (VipLoginInfo == null) { throw new APIException("用户不存在") { ErrorCode = 330 } } ; #region 20140909 kun.zou 发现状态为0,改为1 if (VipLoginInfo.Status.HasValue && VipLoginInfo.Status == 0) { VipLoginInfo.Status = 1; vipLoginBLL.Update(VipLoginInfo, false); var log = new VipLogEntity() { Action = "更新", ActionRemark = "vip状态为0的改为1.", CreateBy = UserID, CreateTime = DateTime.Now, VipID = VipLoginInfo.VIPID, LogID = Guid.NewGuid().ToString("N") }; var logBll = new VipLogBLL(base.CurrentUserInfo); logBll.Create(log); } #endregion int couponCount = vipLoginBLL.GetVipCoupon(UserID); rd.MemberInfo.Mobile = VipLoginInfo.Phone; //手机号码 rd.MemberInfo.Name = VipLoginInfo.UserName; //姓名 rd.MemberInfo.VipID = VipLoginInfo.VIPID; //组标识 rd.MemberInfo.VipName = VipLoginInfo.VipName; //会员名 rd.MemberInfo.ImageUrl = VipLoginInfo.HeadImgUrl; //会员头像 add by Henry 2014-12-5 rd.MemberInfo.VipRealName = VipLoginInfo.VipRealName; rd.MemberInfo.VipNo = VipLoginInfo.VipCode; rd.MemberInfo.IsDealer = VipLoginInfo.Col48 != null?int.Parse(VipLoginInfo.Col48) : 0; //超级分销体系配置表 为判断是否存在分销体系使用 var T_SuperRetailTraderConfigbll = new T_SuperRetailTraderConfigBLL(CurrentUserInfo); //获取分销体系信息 var T_SuperRetailTraderConfigInfo = T_SuperRetailTraderConfigbll.QueryByEntity(new T_SuperRetailTraderConfigEntity() { IsDelete = 0, CustomerId = CurrentUserInfo.CurrentUser.customer_id }, null).FirstOrDefault(); if (T_SuperRetailTraderConfigInfo != null) { rd.MemberInfo.CanBeSuperRetailTrader = 1; } else { rd.MemberInfo.CanBeSuperRetailTrader = 0; } rd.MemberInfo.SuperRetailTraderID = VipLoginInfo.Col26; //rd.MemberInfo.Integration = VipLoginInfo.Integration ?? 0;//会员积分 #region 会员有效积分 var vipIntegralBLL = new VipIntegralBLL(CurrentUserInfo); var vipIntegralInfo = vipIntegralBLL.QueryByEntity(new VipIntegralEntity() { VipID = UserID, VipCardCode = VipLoginInfo.VipCode }, null).FirstOrDefault(); if (vipIntegralInfo != null) { rd.MemberInfo.Integration = vipIntegralInfo.ValidIntegral != null ? vipIntegralInfo.ValidIntegral.Value : 0; } #endregion //会员等级 //rd.MemberInfo.VipLevelName = string.IsNullOrEmpty(vipLoginBLL.GetVipLeave(UserID)) ? null : vipLoginBLL.GetVipLeave(UserID); #region 会员卡名称 var vipCardVipMappingBLL = new VipCardVipMappingBLL(CurrentUserInfo); var vipCardBLL = new VipCardBLL(CurrentUserInfo); var vipCardTypeBLL = new SysVipCardTypeBLL(CurrentUserInfo); var vipCardRuleBLL = new VipCardRuleBLL(CurrentUserInfo); var vipT_InoutBLL = new T_InoutBLL(CurrentUserInfo); VipAmountBLL vipAmountBLL = new VipAmountBLL(CurrentUserInfo); ShoppingCartBLL service = new ShoppingCartBLL(CurrentUserInfo); ShoppingCartEntity queryEntity = new ShoppingCartEntity(); queryEntity.VipId = UserID; int totalQty = service.GetListQty(queryEntity); rd.MemberInfo.ShopCartCount = totalQty; //定义当前自定义等级 int?CurVipLevel = 0; var vipCardMappingInfo = vipCardVipMappingBLL.QueryByEntity(new VipCardVipMappingEntity() { VIPID = UserID, CustomerID = CurrentUserInfo.ClientID }, new OrderBy[] { new OrderBy() { FieldName = "CreateTime", Direction = OrderByDirections.Desc } }).FirstOrDefault(); if (vipCardMappingInfo != null) { var vipCardInfo = vipCardBLL.QueryByEntity(new VipCardEntity() { VipCardID = vipCardMappingInfo.VipCardID, VipCardStatusId = 1 }, null).FirstOrDefault(); if (vipCardInfo != null) { var vipCardTypeInfo = vipCardTypeBLL.QueryByEntity(new SysVipCardTypeEntity() { VipCardTypeID = vipCardInfo.VipCardTypeID }, null).FirstOrDefault(); if (vipCardTypeInfo != null) { rd.MemberInfo.VipLevelName = vipCardTypeInfo.VipCardTypeName != null ? vipCardTypeInfo.VipCardTypeName : ""; rd.MemberInfo.CardTypeImageUrl = vipCardTypeInfo.PicUrl != null ? vipCardTypeInfo.PicUrl : ""; rd.MemberInfo.CardTypePrice = vipCardTypeInfo.Prices != null ? vipCardTypeInfo.Prices.Value : 0; rd.MemberInfo.IsExtraMoney = vipCardTypeInfo.IsExtraMoney != null ? vipCardTypeInfo.IsExtraMoney : 0; CurVipLevel = vipCardTypeInfo.VipCardLevel; rd.MemberInfo.IsPrepaid = vipCardTypeInfo.Isprepaid; if (CurVipLevel > 1) { var VipCardTypeSysInfo = vipCardTypeBLL.GetBindVipCardTypeInfo(CurrentUserInfo.ClientID, VipLoginInfo.Phone, pRequest.UserID, CurVipLevel); if (VipCardTypeSysInfo == null || VipCardTypeSysInfo.Tables[0].Rows.Count == 0) { rd.MemberInfo.IsNeedCard = 2; } } else { rd.MemberInfo.IsNeedCard = 1; } //因为卡等级不能重复,知道当前等级后查找相应的下一级是否是自动升级(消费升级) var NextVipCardTypeInfo = vipCardTypeBLL.QueryByEntity(new SysVipCardTypeEntity() { VipCardLevel = CurVipLevel + 1, CustomerID = CurrentUserInfo.ClientID }, null).FirstOrDefault(); if (NextVipCardTypeInfo != null) { //获取当前会员的消费金额信息 decimal CurVipConsumptionAmount = 0; decimal VipConsumptionInfo = vipT_InoutBLL.GetVipSumAmount(UserID); if (VipConsumptionInfo > 0) { CurVipConsumptionAmount = Convert.ToDecimal(Convert.ToDecimal(VipConsumptionInfo).ToString("0.00")); } //知道下一等级后要判断,升级条件是否是消费升级 //定义累积消费金额 decimal AccumulatedAmount = 0; var vipCardTypeUpGradeInfo = vipCardTypeBLL.GetVipCardTypeUpGradeInfo(CurrentUserInfo.ClientID, CurVipLevel); if (vipCardTypeUpGradeInfo != null && vipCardTypeUpGradeInfo.Tables[0].Rows.Count > 0) { //判断拉取的所有卡等级里的最近的一级满足条件即可返回提示所需的值 int flag = 0; foreach (DataRow dr in vipCardTypeUpGradeInfo.Tables[0].Rows) { AccumulatedAmount = Convert.ToDecimal(Convert.ToDecimal(dr["BuyAmount"].ToString()).ToString("0.00")); //获取消费升级还需多少钱 if (AccumulatedAmount > CurVipConsumptionAmount && flag == 0) { flag = 1; rd.MemberInfo.UpGradeNeedMoney = AccumulatedAmount - CurVipConsumptionAmount; if (rd.MemberInfo.UpGradeNeedMoney > 0) { rd.MemberInfo.UpgradePrompt = "还需要消费" + rd.MemberInfo.UpGradeNeedMoney + "元可以升级啦,快点通知会员!"; } } } } } var VipCardRuleInfo = vipCardRuleBLL.QueryByEntity(new VipCardRuleEntity() { CustomerID = CurrentUserInfo.ClientID, VipCardTypeID = vipCardTypeInfo.VipCardTypeID }, null).FirstOrDefault(); if (VipCardRuleInfo != null) { rd.MemberInfo.CardDiscount = Convert.ToDecimal(Convert.ToDecimal((VipCardRuleInfo.CardDiscount / 10)).ToString("0.00")); } } } } else { //表示需要领卡,并展示等级为1的默认卡 rd.MemberInfo.IsNeedCard = 0; var VipCardTypeData = vipCardTypeBLL.QueryByEntity(new SysVipCardTypeEntity() { VipCardLevel = 1, CustomerID = CurrentUserInfo.ClientID }, null).FirstOrDefault(); if (VipCardTypeData != null) { rd.MemberInfo.CardTypeImageUrl = VipCardTypeData.PicUrl != null ? VipCardTypeData.PicUrl : ""; } } //获取红利/// decimal[0]=总收入(红利) decimal[2]=支出余额 decimal[1]=总提现金额 decimal[] array = vipAmountBLL.GetVipSumAmountByCondition(UserID, CurrentUserInfo.ClientID, true); if (array[0] != null) { rd.MemberInfo.ProfitAmount = array[0]; } //是否有付费的会员卡 List <IWhereCondition> freeCardCon = new List <IWhereCondition> { }; freeCardCon.Add(new EqualsCondition() { FieldName = "CustomerID", Value = CurrentUserInfo.ClientID }); freeCardCon.Add(new DirectCondition("Prices>0")); var freeCardTypeInfo = vipCardTypeBLL.Query(freeCardCon.ToArray(), null).FirstOrDefault(); if (freeCardTypeInfo != null) { rd.MemberInfo.IsCostCardType = 1; } else { rd.MemberInfo.IsCostCardType = 0; } #endregion rd.MemberInfo.Status = VipLoginInfo.Status.HasValue ? VipLoginInfo.Status.Value : 1; rd.MemberInfo.CouponsCount = couponCount; rd.MemberInfo.IsActivate = (VipLoginInfo.IsActivate.HasValue && VipLoginInfo.IsActivate.Value == 1 ? true : false); var customerBasicSettingBll = new CustomerBasicSettingBLL(CurrentUserInfo); rd.MemberInfo.MemberBenefits = customerBasicSettingBll.GetMemberBenefits(pRequest.CustomerID); //获取标签信息 TagsBLL TagsBLL = new TagsBLL(base.CurrentUserInfo); var dsIdentity = TagsBLL.GetVipTagsList("", UserID);//“车主标签” 传7 if (dsIdentity != null && dsIdentity.Tables.Count > 0 && dsIdentity.Tables[0].Rows.Count > 0) { rd.IdentityTagsList = DataTableToObject.ConvertToList <TagsInfo>(dsIdentity.Tables[0]).ToArray(); //“年龄段” 传8 } #region 获取注册表单的列明和值 var vipEntity = vipLoginBLL.QueryByEntity(new VipEntity() { VIPID = UserID }, null); if (vipEntity == null || vipEntity.Length == 0) { return(rd); } else { var ds = vipLoginBLL.GetVipColumnInfo(CurrentUserInfo.ClientID, "online005"); var vipDs = vipLoginBLL.GetVipInfo(UserID); if (ds.Tables[0].Rows.Count > 0) { var temp = ds.Tables[0].AsEnumerable().Select(t => new MemberControlInfo() { ColumnName = t["ColumnName"].ToString(), ControlType = Convert.ToInt32(t["ControlType"]), ColumnValue = vipDs.Tables[0].Rows[0][t["ColumnName"].ToString()].ToString(), ColumnDesc = t["columnDesc"].ToString() }); rd.MemberControlList = temp.ToArray(); } } //var vipamountBll = new VipAmountBLL(this.CurrentUserInfo); //var vipAmountEntity = vipamountBll.GetByID(UserID); var unitBll = new UnitBLL(this.CurrentUserInfo); //Hashtable htPara = new Hashtable(); //htPara["MemberID"] = UserID; //htPara["CustomerID"] = CurrentUserInfo.ClientID; //htPara["PageIndex"] = 1; //htPara["PageSize"] = 10; //DataSet dsMyAccount = unitBll.GetMyAccount(htPara); //if (dsMyAccount.Tables[0].Rows.Count > 0) //{ // //rd.AccountList = DataTableToObject.ConvertToList<AccountInfo>(dsMyAccount.Tables[0]); // //rd.MemberInfo.Balance = Convert.ToDecimal(dsMyAccount.Tables[0].Rows[0]["Total"].ToString()); // //rd.TotalPageCount = int.Parse(dsMyAccount.Tables[0].Rows[0]["PageCount"].ToString()); //} //else // rd.MemberInfo.Balance = 0; //返现 add by Henry 2015-4-15 var vipAmountBll = new VipAmountBLL(CurrentUserInfo); //var vipAmountInfo = vipAmountBll.GetByID(UserID); var vipAmountInfo = vipAmountBll.QueryByEntity(new VipAmountEntity() { VipId = UserID, VipCardCode = VipLoginInfo.VipCode }, null).FirstOrDefault(); decimal returnAmount = 0; decimal amount = 0; if (vipAmountInfo != null) { returnAmount = vipAmountInfo.ValidReturnAmount == null ? 0 : vipAmountInfo.ValidReturnAmount.Value; amount = vipAmountInfo.EndAmount == null ? 0 : vipAmountInfo.EndAmount.Value; } rd.MemberInfo.ReturnAmount = returnAmount; //返现 rd.MemberInfo.Balance = amount; //余额 #endregion //获取订单的日期和订单的里的商品名称、商品单价、商品数量 //先获取订单列表,再获取订单详细信息 int? pageSize = 3; //rp.Parameters.PageSize;,只取三条记录 int? pageIndex = 1; //rp.Parameters.PageIndex; string OrderBy = ""; string OrderType = ""; T_InoutBLL T_InoutBLL = new T_InoutBLL(CurrentUserInfo); InoutService InoutService = new InoutService(CurrentUserInfo); //只取状态为700的 //根据订单列表取订单详情 DataSet dsOrder = T_InoutBLL.GetOrdersByVipID(rd.MemberInfo.VipID, pageIndex ?? 1, pageSize ?? 15, OrderBy, OrderType);//获取会员信息 if (dsOrder != null && dsOrder.Tables.Count != 0 && dsOrder.Tables[0].Rows.Count != 0) { List <JIT.CPOS.DTO.Module.VIP.Login.Response.OrderInfo> orderList = DataTableToObject.ConvertToList <JIT.CPOS.DTO.Module.VIP.Login.Response.OrderInfo>(dsOrder.Tables[1]); foreach (JIT.CPOS.DTO.Module.VIP.Login.Response.OrderInfo oi in orderList) { IList <InoutDetailInfo> detailList = InoutService.GetInoutDetailInfoByOrderId(oi.order_id); oi.DetailList = detailList; } rd.OrderList = orderList; } MessageInfo message = new MessageInfo(); InnerGroupNewsBLL InnerGroupNewsService = new InnerGroupNewsBLL(CurrentUserInfo); SetoffToolsBLL setofftoolsService = new SetoffToolsBLL(CurrentUserInfo); //1=微信用户 2=APP员工 int UnReadInnerMessageCount = InnerGroupNewsService.GetVipInnerGroupNewsUnReadCount(CurrentUserInfo.UserID, pRequest.CustomerID, 1, null, Convert.ToDateTime(VipLoginInfo.CreateTime)); var setofftoolsMessageCount = setofftoolsService.GetUnReadSetoffToolsCount(CurrentUserInfo.UserID, pRequest.CustomerID, 1, 1); message.InnerGroupNewsCount = UnReadInnerMessageCount; message.SetoffToolsCount = setofftoolsMessageCount; var VipUpNewsInfo = InnerGroupNewsService.GetVipInnerNewsInfo(CurrentUserInfo.ClientID, 2, 1, 3, 0); if (VipUpNewsInfo != null && VipUpNewsInfo.Tables[0].Rows.Count > 0) { message.UpGradeSucess = VipUpNewsInfo.Tables[0].Rows[0]["Text"] != null ? VipUpNewsInfo.Tables[0].Rows[0]["Text"].ToString() : ""; //获取通知信息 并更新已读状态 数据如果不是一条进行更新所有数据 var newsUserMappingBLL = new NewsUserMappingBLL(CurrentUserInfo); if (VipUpNewsInfo.Tables[0].Rows.Count > 1)//数据如果不是一条进行更新所有数据 { foreach (DataRow VipNewsdr in VipUpNewsInfo.Tables[0].Rows) { var vipNewsInfo = newsUserMappingBLL.QueryByEntity(new NewsUserMappingEntity() { CustomerId = CurrentUserInfo.ClientID, MappingID = VipNewsdr["MappingID"].ToString() }, null).FirstOrDefault(); if (vipNewsInfo != null) { vipNewsInfo.HasRead = 1; newsUserMappingBLL.Update(vipNewsInfo); } } } else { var vipNewsInfo = newsUserMappingBLL.QueryByEntity(new NewsUserMappingEntity() { CustomerId = CurrentUserInfo.ClientID, MappingID = VipUpNewsInfo.Tables[0].Rows[0]["MappingID"].ToString() }, null).FirstOrDefault(); if (vipNewsInfo != null) { vipNewsInfo.HasRead = 1; newsUserMappingBLL.Update(vipNewsInfo); } } } else { message.UpGradeSucess = ""; } rd.MessageInfo = message; return(rd); } }
/// <summary> /// 校园专家 重置密码 /// </summary> /// <returns></returns> public string ForgetPassword() { string content = string.Empty; var respData = new ambassadorLoginInRespData(); try { //接收参数 string reqContent = HttpContext.Current.Request["ReqContent"]; var reqObj = reqContent.DeserializeJSONTo <ambassadorLoginInReqData>(); reqObj = reqObj == null ? new ambassadorLoginInReqData() : reqObj; //获取客户ID if (!string.IsNullOrEmpty(reqObj.common.customerId)) { customerId = reqObj.common.customerId; } //初始化返回对象 respData.content = new ambassadorLoginInRespContentData(); respData.content.vipList = new List <ambassadorLoginInRespContentDataItem>(); //用户登录信息 var loggingSessionInfo = Default.GetBSLoggingSession(customerId, "1"); OnlineShoppingItemBLL itemService = new OnlineShoppingItemBLL(loggingSessionInfo); var vipInfo = itemService.ForgetPassword(reqObj.special.email); if (vipInfo != null && vipInfo.Count > 0) { //生成随机数 6位 Random rd = new Random(); string code = rd.Next(100000, 999999).ToString(); VipBLL vipBLL = new VipBLL(loggingSessionInfo); VipEntity entity = new VipEntity(); entity = vipBLL.GetByID(vipInfo[0].VIPID); entity.VipPasswrod = MD5Helper.Encryption(MD5Helper.Encryption(code) + entity.Col4); entity.LastUpdateTime = DateTime.Now; vipBLL.Update(entity); #region 邮件发送 try { XmlManager xml = new XmlManager(ConfigurationManager.AppSettings["xmlFile"]); FromSetting fs = new FromSetting(); fs.SMTPServer = xml.SelectNodeText("//Root/AsusMail//SMTPServer", 0); fs.SendFrom = xml.SelectNodeText("//Root/AsusMail//MailSendFrom", 0); fs.UserName = xml.SelectNodeText("//Root/AsusMail//MailUserName", 0); fs.Password = xml.SelectNodeText("//Root/AsusMail//MailUserPassword", 0); Mail.SendMail(fs, entity.Col7 + "," + xml.SelectNodeText("//Root/AsusMail//MailTo", 0), xml.SelectNodeText("//Root/AsusMail//MailTitle", 0), entity.VipRealName + ":你好,你的新密码为:" + code, null); } catch { respData.code = "111"; respData.description = "邮箱发送失败,请稍后重试"; content = respData.ToJSON(); return(content); } #endregion List <ambassadorLoginInRespContentDataItem> list = new List <ambassadorLoginInRespContentDataItem>(); foreach (var item in vipInfo) { ambassadorLoginInRespContentDataItem info = new ambassadorLoginInRespContentDataItem(); info.VipID = item.VIPID; info.VipPassword = code; info.Email = item.Email; list.Add(info); } respData.content.vipList = list; } else { respData.code = "111"; respData.description = "邮箱不存在"; } } catch (Exception ex) { respData.code = "103"; respData.description = "数据库操作错误"; respData.exception = ex.ToString(); } content = respData.ToJSON(); return(content); }
/// <summary> /// 添加会员 /// </summary> /// <returns></returns> public string GenerateQR() { string content = string.Empty; var respData = new ambassadorLoginInRespData(); try { //接收参数 string reqContent = HttpContext.Current.Request["ReqContent"]; var reqObj = reqContent.DeserializeJSONTo <ambassadorLoginInReqData>(); reqObj = reqObj == null ? new ambassadorLoginInReqData() : reqObj; //获取客户ID if (!string.IsNullOrEmpty(reqObj.common.customerId)) { customerId = reqObj.common.customerId; } //初始化返回对象 respData.content = new ambassadorLoginInRespContentData(); respData.content.vipList = new List <ambassadorLoginInRespContentDataItem>(); //用户登录信息 var loggingSessionInfo = Default.GetBSLoggingSession(customerId, "1"); VipBLL vipBLL = new VipBLL(loggingSessionInfo); VipEntity entity = new VipEntity(); //是否有此人 var vip = vipBLL.Query(new IWhereCondition[] { new EqualsCondition() { FieldName = "VipID", Value = reqObj.common.userId }, new EqualsCondition() { FieldName = "ClientID", Value = customerId } }, null).FirstOrDefault(); if (vip != null) { string QRCode = null; if (!string.IsNullOrEmpty(vip.Col6)) { QRCode = vip.Col6; } if (reqObj.special.generater) { QRCode = GeneratedQR(reqObj.special.url, vip.VIPID); entity = vipBLL.GetByID(vip.VIPID); entity.Col6 = QRCode; entity.LastUpdateTime = DateTime.Now; vipBLL.Update(entity); } else { QRCode = GeneratedQR(reqObj.special.url, vip.VIPID); entity = vipBLL.GetByID(vip.VIPID); entity.Col6 = QRCode; entity.LastUpdateTime = DateTime.Now; vipBLL.Update(entity); } List <ambassadorLoginInRespContentDataItem> list = new List <ambassadorLoginInRespContentDataItem>(); ambassadorLoginInRespContentDataItem info = new ambassadorLoginInRespContentDataItem(); info.VipID = vip.VIPID; info.VipName = vip.VipName; info.Phone = vip.Phone; info.DeliveryAddress = vip.DeliveryAddress; info.VipRealName = vip.VipRealName; info.QRCode = QRCode; info.Code = vip.Col4; list.Add(info); respData.content.vipList = list; } } catch (Exception ex) { respData.code = "103"; respData.description = "数据库操作错误"; respData.exception = ex.ToString(); } content = respData.ToJSON(); return(content); }
public HttpResponseMessage MemberBenefits(string vipId, decimal?TotalPayAmount) { string guid = Guid.NewGuid().ToString(); Loggers.Debug(new DebugLogInfo() { Message = $"调用[api/Vip/MemberBenefits],参数:\"vipId:{vipId}\"", UserID = vipId, ClientID = guid }); try { if (string.IsNullOrEmpty(vipId)) { throw new Exception("会员数据不能为空!"); } var orderResponse = new MemberBenefitsResponeModel(); #region MyRegion string customerid = ConfigurationManager.AppSettings["CustomerId"].Trim(); var loggingSessionInfo = Default.GetLoggingSession(customerid, vipId); loggingSessionInfo.Conn = ConfigurationManager.AppSettings["Conn"].Trim(); var bll = new VipBLL(loggingSessionInfo); var vipInfo = bll.GetByID(vipId); //会员信息 if (vipInfo == null) { throw new APIException("没有该会员信息") { ErrorCode = 302 }; } #endregion //获取社会化销售配置和积分返现配置 var basicSettingBll = new CustomerBasicSettingBLL(loggingSessionInfo); Hashtable htSetting = basicSettingBll.GetSocialSetting(); orderResponse.EnableIntegral = int.Parse(htSetting["enableIntegral"].ToString()); orderResponse.EnableRewardCash = int.Parse(htSetting["enableRewardCash"].ToString()); //应付金额 decimal?totalPayAmount = 0; if (TotalPayAmount != null) { totalPayAmount = TotalPayAmount; } #region 启用积分 if (orderResponse.EnableIntegral == 1) { //2.获取会员的积分和账户余额 var vipIntegralbll = new VipIntegralBLL(loggingSessionInfo); //var vipIntegralEntity = vipIntegralbll.GetByID(rp.UserID); //根据会员和会员卡号获取积分 var vipIntegralEntity = vipIntegralbll.QueryByEntity( new VipIntegralEntity() { VipID = vipInfo.UserId, VipCardCode = vipInfo.VipCode }, null) .FirstOrDefault(); if (vipIntegralEntity == null) { orderResponse.Integral = 0; orderResponse.IntegralAmount = 0; } else { decimal validIntegral = vipIntegralEntity.ValidIntegral ?? 0; //会员积分 int totalIntegral = 0; //可使用积分(取整) //if (int.Parse(htSetting["rewardsType"].ToString()) == 1)//按商品奖励 // totalIntegral = (int)Math.Round(bll.GetIntegralBySkuId(skuIdList), 1); //积分使用上限比例 decimal pointsRedeemUpLimit = decimal.Parse(htSetting["pointsRedeemUpLimit"].ToString()) / 100; //3.获取积分与金额的兑换比例 var integralAmountPre = bll.GetIntegralAmountPre(customerid); if (integralAmountPre == 0) { integralAmountPre = (decimal)0.01; } totalIntegral = (int)Math.Round(totalPayAmount.Value * pointsRedeemUpLimit * integralAmountPre, 1); //可使用的积分 orderResponse.Integral = validIntegral > totalIntegral ? totalIntegral : validIntegral; if (totalPayAmount == 0) { orderResponse.Integral = Convert.ToDecimal(vipIntegralEntity.ValidIntegral); } //rd.IntegralAmount = rd.Integral * integralAmountPre; orderResponse.IntegralAmount = bll.GetAmountByIntegralPer(loggingSessionInfo.ClientID, orderResponse.Integral); orderResponse.IntegralDesc = "使用积分" + orderResponse.Integral.ToString("0") + ",可兑换" + orderResponse.IntegralAmount.ToString("0.00") + "元"; orderResponse.PointsRedeemLowestLimit = int.Parse(htSetting["pointsRedeemLowestLimit"].ToString()); } } #endregion //根据会员和会员卡号获取余额和返现 var vipAmountBll = new VipAmountBLL(loggingSessionInfo); var vipAmountInfo = vipAmountBll.QueryByEntity( new VipAmountEntity() { VipId = vipInfo.VIPID, VipCardCode = vipInfo.VipCode }, null) .FirstOrDefault(); #region 启用返现 if (orderResponse.EnableRewardCash == 1) { if (vipAmountInfo != null) { //累计返现金额 decimal returnAmount = vipAmountInfo.ValidReturnAmount == null ? 0 : vipAmountInfo.ValidReturnAmount.Value; //订单可使用最大返现金额 decimal returnAmountOrder = totalPayAmount.Value * (decimal.Parse(htSetting["cashRedeemUpLimit"].ToString()) / 100); orderResponse.ReturnAmount = returnAmount > returnAmountOrder ? returnAmountOrder : returnAmount; orderResponse.CashRedeemLowestLimit = decimal.Parse(htSetting["cashRedeemLowestLimit"].ToString()); } } #endregion //账户余额 //var vipEndAmount = bll.GetVipEndAmount(rp.UserID); //rd.VipEndAmount = totalPayAmount > vipEndAmount ? vipEndAmount : totalPayAmount; if (vipAmountInfo != null) { orderResponse.VipEndAmount = vipAmountInfo.EndAmount.Value; } //获取会员折扣 var sysVipCardGradeBLL = new SysVipCardGradeBLL(loggingSessionInfo); decimal vipDiscount = 10; //会员折扣 //如果订单业务类型为null var orderReason = GetOrderReason(EnumOrderReason.Pos); //超级分销、团购、抢购、砍价商品没有会员折扣 if (orderReason != "CB43DD7DD1C94853BE98C4396738E00C" && orderReason != "671E724C85B847BDA1E96E0E5A62055A" && orderReason != "096419BFDF394F7FABFE0DFCA909537F") { //if (rp.Parameters.DiscountType == 0) vipDiscount = sysVipCardGradeBLL.GetVipDiscount(); } orderResponse.VipDiscount = vipDiscount; var tempAmount = totalPayAmount.Value; if (totalPayAmount.Value > 0 && vipDiscount > 0) { tempAmount = totalPayAmount.Value * (vipDiscount / 10); } var ds = bll.GetVipCouponDataSet(vipInfo.VIPID, tempAmount, 2, string.Empty, 1, customerid); if (ds.Tables[0].Rows.Count > 0) { var temp = ds.Tables[0].AsEnumerable().Select(t => new CouponModel() { CouponId = t["CouponID"].ToString(), CouponCode = t["CouponCode"].ToString(), CouponAmount = Convert.ToDecimal(t["parValue"]), CouponName = t["CoupnName"].ToString(), CouponDesc = t["CouponDesc"].ToString(), DisplayIndex = Convert.ToInt32(t["displayIndex"]), EnableFlag = Convert.ToInt32(t["EnableFlag"]), //ValidDateDesc = t["ValidDateDesc"].ToString(), StartDate = t["BeginDate"].ToString(), EndDate = t["EndDate"].ToString() }); orderResponse.CouponInfoList = temp.ToList(); } orderResponse.IsSucess = true; var json = new JavaScriptSerializer().Serialize(orderResponse); Loggers.Debug(new DebugLogInfo() { Message = $"调用[api/Vip/MemberBenefits],返回参数:\"{json}\"", UserID = vipId, ClientID = guid }); return(Request.CreateResponse(HttpStatusCode.OK, orderResponse)); } catch (Exception ex) { var orderResponse = new MemberBenefitsResponeModel() { IsSucess = false, ErrorMessage = ex.Message }; Loggers.Debug(new DebugLogInfo() { Message = $"[api/Vip/MemberBenefits]错误,参数:\"ErrorMsg:{ex.Message}\"", UserID = vipId, ClientID = guid }); return(Request.CreateResponse(HttpStatusCode.InternalServerError, orderResponse)); } }
public HttpResponseMessage Password(string vipId, string password) { Loggers.Debug(new DebugLogInfo() { Message = $"[api/Vip/Password]接口,参数:\"vipId:{vipId}&&password:{password}\"" }); try { if (string.IsNullOrEmpty(password)) { throw new APIException("请求参数中缺少Password或值为空.") { ErrorCode = 121 }; } if (string.IsNullOrEmpty(password)) { throw new APIException("请求参数中缺少Password或值为空.") { ErrorCode = 121 }; } var rd = new EmptyResponseData(); string customerid = ConfigurationManager.AppSettings["CustomerId"].Trim(); var loggingSessionInfo = Default.GetLoggingSession(customerid, "1"); var vipbll = new VipBLL(loggingSessionInfo); var vipEntity = vipbll.GetByID(vipId); if (vipEntity == null) { throw new APIException("无效的会员ID【VipId】") { ErrorCode = 121 }; } var bll = new VipAmountBLL(loggingSessionInfo); var vipAmountEntity = bll.GetByID(vipId); if (vipAmountEntity == null) { throw new APIException("该会员暂无绑定账户") { ErrorCode = 121 }; } else { if (vipAmountEntity.PayPassword != password) { throw new APIException("密码不正确") { ErrorCode = 122 }; } } var responseModel = new BaseResponeModel { IsSucess = true }; return(Request.CreateResponse(HttpStatusCode.OK, responseModel)); } catch (Exception ex) { var responseModel = new BaseResponeModel { IsSucess = false, ErrorMessage = ex.Message }; return(Request.CreateResponse(HttpStatusCode.InternalServerError, responseModel)); } }
public string SetSignUp() { string content = string.Empty; var respData = new SetSignUpRespData(); try { Loggers.Debug(new DebugLogInfo() { Message = string.Format("SetSignUp: {0}", reqContent) }); #region //解析请求字符串 chech var reqObj = reqContent.DeserializeJSONTo <SetSignUpReqData>(); if (reqObj.special == null) { respData.code = "101"; respData.description = "没有特殊参数"; return(respData.ToJSON().ToString()); } if (reqObj.special.phone == null || reqObj.special.phone.Equals("")) { respData.code = "102"; respData.description = "电话不能为空"; return(respData.ToJSON().ToString()); } #endregion #region //判断客户ID是否传递 if (!string.IsNullOrEmpty(reqObj.common.customerId)) { customerId = reqObj.common.customerId; } var loggingSessionInfo = Default.GetBSLoggingSession(customerId, "1"); #endregion //#region 判断客户是否扫过活动二维码 QRCodeScanLogBLL qRCodeScanLogBLL = new QRCodeScanLogBLL(loggingSessionInfo); if (!qRCodeScanLogBLL.CheckVipEventQRCode(reqObj.common.userId, reqObj.special.eventId)) { respData.code = "2206"; respData.description = "请先扫描本次活动的二维码"; return(respData.ToJSON().ToString()); } //#endregion VipBLL vipBLL = new VipBLL(loggingSessionInfo); EventVipBLL eventVipBLL = new EventVipBLL(loggingSessionInfo); var tmpPhoneVip = vipBLL.GetVipByPhone(reqObj.special.phone, reqObj.common.userId, "2"); Loggers.Debug(new DebugLogInfo() { Message = "tmpPhoneVip: " + tmpPhoneVip.ToJSON() }); if (tmpPhoneVip != null && tmpPhoneVip.VIPID != reqObj.common.userId) { respData.code = "2201"; respData.description = "您填写的手机号码已经被其他参会人员认证。如需帮助,请联系现场工作人员。"; return(respData.ToJSON().ToString()); } var tmpEventVipList = eventVipBLL.QueryByEntity(new EventVipEntity() { Phone = reqObj.special.phone, EventId = reqObj.special.eventId }, null); var tmpVipList = vipBLL.QueryByEntity(new VipEntity() { VIPID = reqObj.common.userId , ClientID = customerId }, null); #region 与会嘉宾中存在该手机号 if (tmpEventVipList != null && tmpEventVipList.Length > 0) { #region 会员表中存在该会员 if (tmpVipList != null && tmpVipList.Length > 0) { //签到 vipBLL.Update(new VipEntity() { VIPID = reqObj.common.userId, VipRealName = tmpEventVipList[0].VipName, Phone = reqObj.special.phone, Status = 2 }, false); respData.code = "200"; respData.description = "恭喜您签到成功!"; } #endregion } #endregion else { respData.code = "2202"; respData.description = "在参会嘉宾中未查询到您输入的手机号码,请确认您输入是否有误。如需帮助,请联系现场工作人员。"; return(respData.ToJSON().ToString()); } if (!string.IsNullOrEmpty(tmpEventVipList[0].Seat)) { respData.content = new SetSignUpRespContentData(); respData.description += "您的座位是:" + tmpEventVipList[0].Seat + ",请就坐。"; } string error = ""; var sendFlag = eventVipBLL.SetEventVipSeatPush(tmpVipList[0].VIPID, reqObj.special.eventId, out error); if (!sendFlag) { Loggers.Debug(new DebugLogInfo() { Message = string.Format("SetStaffSeatsPush: {0}", error) }); } } catch (Exception ex) { respData.code = "103"; respData.description = "数据库操作错误"; respData.exception = ex.ToString(); Loggers.Exception(new ExceptionLogInfo() { ErrorMessage = ex.ToJSON() }); } content = respData.ToJSON(); return(content); }
public void ExportExcel(HttpContext pContext, string CustomerID) { MarketNamedApplyBLL marketNamedApplyBll = new MarketNamedApplyBLL(CurrentUserInfo); VipBLL vip = new VipBLL(CurrentUserInfo); DataSet dsVip = marketNamedApplyBll.GetVipByMarketNamedApply(CustomerID); if (dsVip.Tables.Count > 0) { string MapUrl = pContext.Server.MapPath(@"~/Framework/Upload/" + DateTime.Now.ToString("yyyy.MM.dd.HH.mm.ss.ms") + ".xls"); Aspose.Cells.License lic = new Aspose.Cells.License(); lic.SetLicense("Aspose.Total.lic"); Workbook workbook = new Workbook(); Worksheet sheet = workbook.Worksheets[0]; Cells cells = sheet.Cells; //单元格 Style style1 = workbook.Styles[workbook.Styles.Add()]; //新增样式 style1.HorizontalAlignment = TextAlignmentType.Center; //文字居中 style1.Font.Name = "宋体"; //文字字体 style1.Font.Size = 14; //文字大小 style1.Font.IsBold = true; //粗体 style1.IsTextWrapped = true; //单元格内容自动换行 style1.Borders[BorderType.LeftBorder].LineStyle = CellBorderType.Thin; style1.Borders[BorderType.RightBorder].LineStyle = CellBorderType.Thin; style1.Borders[BorderType.TopBorder].LineStyle = CellBorderType.Thin; style1.Borders[BorderType.BottomBorder].LineStyle = CellBorderType.Thin; Style style2 = workbook.Styles[workbook.Styles.Add()]; //新增样式 style2.HorizontalAlignment = TextAlignmentType.Center; //文字居中 style2.Font.Name = "宋体"; //文字字体 style2.Font.Size = 12; //文字大小 style2.Borders[BorderType.LeftBorder].LineStyle = CellBorderType.Thin; style2.Borders[BorderType.RightBorder].LineStyle = CellBorderType.Thin; style2.Borders[BorderType.TopBorder].LineStyle = CellBorderType.Thin; style2.Borders[BorderType.BottomBorder].LineStyle = CellBorderType.Thin; //设置宽度 cells.SetColumnWidth(1, 30); cells.SetColumnWidth(2, 30); cells.SetColumnWidth(3, 90); cells[0, 0].PutValue("会员姓名"); cells[0, 0].SetStyle(style1); cells[0, 1].PutValue("会员电话"); cells[0, 1].SetStyle(style1); cells[0, 2].PutValue("二维码路径"); cells[0, 2].SetStyle(style1); cells.SetRowHeight(0, 30); cells.SetColumnWidth(0, 30); cells.SetRowHeight(1, 20); cells.SetColumnWidth(2, 90); #region 生成数据行 for (int i = 0; i < dsVip.Tables[0].Rows.Count; i++) { cells[i + 1, 0].PutValue(dsVip.Tables[0].Rows[i]["VipName"].ToString()); cells[i + 1, 0].SetStyle(style2); cells[i + 1, 1].PutValue(dsVip.Tables[0].Rows[i]["Phone"].ToString()); cells[i + 1, 1].SetStyle(style2); cells[i + 1, 2].PutValue(dsVip.Tables[0].Rows[i]["QRCodeUrl"].ToString()); cells[i + 1, 3].SetStyle(style2); } #endregion workbook.Save(MapUrl); Utils.OutputExcel(pContext, MapUrl);//输出Excel文件 } else { throw new APIException("没有人报名"); } }
protected override MergeVipInfoRD ProcessRequest(DTO.Base.APIRequest <MergeVipInfoRP> pRequest) { //参数验证 if (string.IsNullOrWhiteSpace(pRequest.Parameters.AuthCode)) { throw new APIException("请求参数中缺少AuthCode或值为空.") { ErrorCode = ERROR_LACK_AUTHCODE }; } if (string.IsNullOrWhiteSpace(pRequest.Parameters.Mobile)) { throw new APIException("请求参数中缺少Mobile或值为空.") { ErrorCode = ERROR_LACK_MOBILE }; } // MergeVipInfoRD rd = new MergeVipInfoRD(); var bll = new VipBLL(this.CurrentUserInfo); var codebll = new RegisterValidationCodeBLL(base.CurrentUserInfo); #region 验证验证码 var entity = codebll.GetByMobile(pRequest.Parameters.Mobile); if (entity == null) { throw new APIException("未找到此手机的验证信息") { ErrorCode = ERROR_AUTHCODE_NOTEXISTS } } ; if (entity.IsValidated.Value == 1) { throw new APIException("此验证码已被使用") { ErrorCode = ERROR_AUTHCODE_WAS_USED } } ; if (entity.Expires.Value < DateTime.Now) { throw new APIException("此验证码已失效") { ErrorCode = ERROR_AUTHCODE_INVALID } } ; if (entity.Code != pRequest.Parameters.AuthCode) { throw new APIException("验证码不正确.") { ErrorCode = ERROR_AUTHCODE_NOT_EQUALS } } ; #endregion JIT.Utility.Log.Loggers.Debug(new Utility.Log.DebugLogInfo() { Message = string.Format("action={0},request={1}", "MergeVipInfo", pRequest.ToJSON()) }); //if (!bll.MergeVipInfo(pRequest.CustomerID, pRequest.UserID, pRequest.Parameters.Mobile))//目前有 //{ // throw new APIException("合并会员信息失败") { ErrorCode = ERROR_AUTO_MERGE_MEMBER_FAILED }; //} return(rd); } } }
public void AutoSetOrderNotPayCache() { foreach (var customer in _CustomerIDList) { _T_loggingSessionInfo.ClientID = customer.Key; _T_loggingSessionInfo.CurrentLoggingManager.Connection_String = customer.Value; // _T_InoutBLL = new T_InoutBLL(_T_loggingSessionInfo); _Inout3Service = new InoutService(_T_loggingSessionInfo); var inoutStatus = new TInoutStatusBLL(_T_loggingSessionInfo); _VipBLL = new VipBLL(_T_loggingSessionInfo); // // var t_InoutList = new List<string>(); try { List <IWhereCondition> complexCondition = new List <IWhereCondition>(); string[] statusArr = { "620", "610", "600" }; complexCondition.Add(new InCondition <string>() { FieldName = "Field7", Values = statusArr }); complexCondition.Add( new DirectCondition( " CONVERT(NVARCHAR(10),complete_date,120) = CONVERT(NVARCHAR(10),DATEADD(day, -1, GETDATE()),120)")); var t_InoutEntitys = _T_InoutBLL.Query(complexCondition.ToArray(), null); if (t_InoutEntitys == null || t_InoutEntitys.Count() <= 0) { } // // roleList = roleEntities.Select(it => it.role_id).ToList(); foreach (var t_InoutInfo in t_InoutEntitys) { TInoutStatusEntity info = new TInoutStatusEntity(); info.InoutStatusID = Guid.Parse(Utils.NewGuid()); info.OrderID = t_InoutInfo.order_id; info.CustomerID = _T_loggingSessionInfo.ClientID; info.Remark = string.Empty; info.OrderStatus = 700; string statusDesc = GetStatusDesc("700");//变更后的状态名称 try { info.StatusRemark = "订单状态从" + t_InoutInfo.status_desc + "变为" + statusDesc + "[操作人:自动]"; _Inout3Service.UpdateOrderDeliveryStatus(t_InoutInfo.order_id, "700", Utils.GetNow()); } catch { continue; } inoutStatus.Create(info); #region 支付成功,调用RabbitMQ发送给ERP try { var msg = new EventContract { Operation = OptEnum.Update, EntityType = EntityTypeEnum.Order, Id = t_InoutInfo.order_id }; var eventService = new EventService(); eventService.PublishMsg(msg); } catch (Exception ex) { throw new Exception(ex.Message); } #endregion } } catch { // ignored } } }
protected override GrantCouponRD ProcessRequest(DTO.Base.APIRequest <GrantCouponRP> pRequest) { var rd = new GrantCouponRD();//返回值 var param = pRequest.Parameters; VipCouponMappingBLL bllVipCoupon = new VipCouponMappingBLL(this.CurrentUserInfo); try { var customerBasicSettingBLL = new CustomerBasicSettingBLL(this.CurrentUserInfo); var ResultList = customerBasicSettingBLL.GetBusinessBasisConfigInfo(CurrentUserInfo.ClientID); rd.CustomerName = ResultList.FirstOrDefault(m => m.SettingCode.Equals("CustomerShortName")) == null ? "" : ResultList.FirstOrDefault(m => m.SettingCode.Equals("CustomerShortName")).SettingValue; //引导二维码 rd.FollowUrl = ResultList.FirstOrDefault(m => m.SettingCode.Equals("GuideLinkUrl")) == null ? "" : ResultList.FirstOrDefault(m => m.SettingCode.Equals("GuideLinkUrl")).SettingValue; //引导链接 rd.GuideQRCode = ResultList.FirstOrDefault(m => m.SettingCode.Equals("GuideQRCode")) == null ? "" : ResultList.FirstOrDefault(m => m.SettingCode.Equals("GuideQRCode")).SettingValue; //引导二维码 if (bllVipCoupon.HadBeGranted(param.CouponId, param.Giver) == 0) { rd.IsAccept = 1; rd.IsSuccess = false; rd.Message = "手慢一步,优惠券已被高人领走!"; return(rd); } CouponBLL bll = new CouponBLL(this.CurrentUserInfo); DataSet ds = bll.GetCouponDetail(pRequest.Parameters.CouponId, ""); if (ds.Tables != null && ds.Tables.Count > 0 && ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0 && ds.Tables[0].Rows[0]["Status"].ToString() == "2") { if (bllVipCoupon.GrantCoupon(param.Giver, pRequest.UserID, param.CouponId) > 0) { CouponGrantLogBLL bllCouponGrantLog = new CouponGrantLogBLL(this.CurrentUserInfo); bllCouponGrantLog.Create(new CouponGrantLogEntity() { CouponId = param.CouponId, FromVipId = param.Giver, ToVipId = pRequest.UserID, CouponGrantLogId = Guid.NewGuid() }); VipBLL bllVip = new VipBLL(this.CurrentUserInfo); var vipInfo = bllVip.GetVipDetailByVipID(param.Giver); rd.IsSuccess = true; rd.Message = vipInfo.VipName + "赠送你一张" + ds.Tables[0].Rows[0]["CouponName"] + "的优惠券"; rd.IsAccept = 0; } else { rd.IsAccept = 1; rd.IsSuccess = false; rd.Message = "领取失败"; } } else { rd.IsAccept = 1; rd.IsSuccess = false; rd.Message = "优惠券已被使用"; } } catch (Exception ex) { rd.IsAccept = 0; rd.IsSuccess = false; rd.Message = ex.Message.ToString(); throw; } return(rd); }
const int MEMBER_HAVECARDNOTIPS = 320; //领取成功 不提示 但跳到实体卡 #endregion protected override AuthCodeLoginRD ProcessRequest(DTO.Base.APIRequest <AuthCodeLoginRP> pRequest) { var vipCardVipMappingBLL = new VipCardVipMappingBLL(CurrentUserInfo); //参数验证 if (string.IsNullOrEmpty(pRequest.Parameters.Mobile)) { throw new APIException("请求参数中缺少Mobile或值为空.") { ErrorCode = ERROR_LACK_MOBILE }; } if (pRequest.Parameters.VipSource.HasValue == false) { pRequest.Parameters.VipSource = 1; //throw new APIException("请求参数中缺少VipSource或值为空.") { ErrorCode = ERROR_LACK_VIP_SOURCE }; } // AuthCodeLoginRD rd = new AuthCodeLoginRD(); var bll = new VipBLL(this.CurrentUserInfo); var codebll = new RegisterValidationCodeBLL(base.CurrentUserInfo); VipEntity vipByID = null; //根据VIP ID查找出来的VIP记录 VipEntity vipByPhone = null; //根据手机号查找出来的VIP记录 //var list = codebll.QueryByEntity(new RegisterValidationCodeEntity() //{ // Mobile = pRequest.Parameters.Mobile //}, null); //bool b = false; //if (list != null) //{ // foreach (var entity in list) // { // if (entity == null) // throw new APIException("未找到此手机的验证信息") {ErrorCode = ERROR_AUTHCODE_NOTEXISTS}; // //if (entity.IsValidated.Value == 1) // // throw new APIException("此验证码已被使用") {ErrorCode = ERROR_AUTHCODE_WAS_USED}; // //if (entity.Expires.Value < DateTime.Now) // // throw new APIException("此验证码已失效") {ErrorCode = ERROR_AUTHCODE_INVALID}; // if (entity.Code == pRequest.Parameters.AuthCode) // b = true; // } //} //if (!b) //{ // throw new APIException("验证码不正确.") { ErrorCode = ERROR_AUTHCODE_NOT_EQUALS }; //} #region 验证验证码 var entity = codebll.GetByMobile(pRequest.Parameters.Mobile); if (entity == null) { throw new APIException("未找到此手机的验证信息") { ErrorCode = ERROR_AUTHCODE_NOTEXISTS } } ; if (entity.IsValidated.Value == 1) { throw new APIException("此验证码已被使用") { ErrorCode = ERROR_AUTHCODE_WAS_USED } } ; if (entity.Expires.Value < DateTime.Now) { throw new APIException("此验证码已失效") { ErrorCode = ERROR_AUTHCODE_INVALID } } ; if (entity.Code != pRequest.Parameters.AuthCode) { throw new APIException("验证码不正确.") { ErrorCode = ERROR_AUTHCODE_NOT_EQUALS } } ; #endregion #region 获取会员权益 var customerBasicSettingBll = new CustomerBasicSettingBLL(CurrentUserInfo); var memberBenefit = customerBasicSettingBll.GetMemberBenefits(pRequest.CustomerID); var bllPrize = new LPrizesBLL(CurrentUserInfo); #endregion //自定义没有实体卡,有实体卡时变为1 int HaveVipcard = 0; //要发送给rabbitmq的信息 var eventService = new EventService(); EventContract vipMsg = null; switch (pRequest.Parameters.VipSource.Value) { case 3: //来源是微信时,做自动合并 { #region 根据手机号查找下,看下是否存在同样手机号的VIP记录 { List <IWhereCondition> wheres = new List <IWhereCondition>(); wheres.Add(new MoreThanCondition() { FieldName = "status", Value = 0, IncludeEquals = false }); //潜在或者正式会员 wheres.Add(new EqualsCondition() { FieldName = "phone", Value = pRequest.Parameters.Mobile }); wheres.Add(new EqualsCondition() { FieldName = "clientid", Value = pRequest.CustomerID }); var result = bll.Query(wheres.ToArray(), null); if (result != null && result.Length > 0) { vipByPhone = result[0]; } if (vipByPhone != null && vipByPhone.VipSourceId == "3" && vipByPhone.Status.Value >= 2) { throw new APIException("会员已经注册") { ErrorCode = ERROR_MEMBER_REGISTERED }; } } #endregion #region 根据VIP ID查找下,看下是否存在该VIP的记录 if (!string.IsNullOrEmpty(pRequest.UserID)) { List <IWhereCondition> wheres = new List <IWhereCondition>(); //wheres.Add(new MoreThanCondition() { FieldName = "status", Value = 0, IncludeEquals = false }); wheres.Add(new MoreThanCondition() { FieldName = "status", Value = 0, IncludeEquals = true }); wheres.Add(new EqualsCondition() { FieldName = "vipid", Value = pRequest.UserID }); wheres.Add(new EqualsCondition() { FieldName = "clientid", Value = pRequest.CustomerID }); var result = bll.Query(wheres.ToArray(), null); if (result != null && result.Length > 0) { vipByID = result[0]; } } else { //如果前端未指定VIP ID则后台指定 pRequest.UserID = Guid.NewGuid().ToString("N"); } //判断用户是从点击领取过来的 还是从点击绑定实体卡过来的 int?RegisterType = 0; if (pRequest.Parameters.registerType != null) { RegisterType = pRequest.Parameters.registerType; } //当手机号不为空时需要查询是否存在实体卡 if (!string.IsNullOrEmpty(pRequest.Parameters.Mobile) && (!string.IsNullOrEmpty(pRequest.UserID) || !string.IsNullOrEmpty(vipByPhone.VIPID))) { List <IWhereCondition> wheres = new List <IWhereCondition>(); wheres.Add(new EqualsCondition() { FieldName = "phone", Value = pRequest.Parameters.Mobile }); wheres.Add(new EqualsCondition() { FieldName = "clientid", Value = pRequest.CustomerID }); wheres.Add(new DirectCondition("VipID!='" + pRequest.UserID + "'")); var vipInfo = bll.Query(wheres.ToArray(), null); //若是从绑定实体卡进入,进行实体卡的判断,并不注册成功 if (RegisterType == 2) { if (vipInfo == null || vipInfo.Length == 0) { throw new APIException("未检测到实体卡") { ErrorCode = MEMBER_HAVENOCARD }; } else { vipCardVipMappingBLL.BindVipCard(vipByID.VIPID, vipByID.VipCode, vipByID.CouponInfo); HaveVipcard = 1; //需要给绑定实体卡的提示 } } else { vipCardVipMappingBLL.BindVipCard(vipByID.VIPID, vipByID.VipCode, vipByID.CouponInfo); //若是从"点击领取"进入则进行判断有没有实体卡 有没有实体卡都进行领卡成功的提示 if (vipInfo != null && vipInfo.Length > 0) { HaveVipcard = 1; //需要给绑定实体卡的提示 } else { HaveVipcard = 2; //注册成功但没有实体卡 } } } if (vipByID == null && vipByPhone == null) //根据vipid查不出记录,并且根据手机号也查不出记录 新增一条vip { //如果不存在则首先创建一条VIP记录,补充记录 vipByID = new VipEntity() { Phone = pRequest.Parameters.Mobile, VipName = pRequest.Parameters.Mobile, UserName = pRequest.Parameters.Mobile, VipRealName = pRequest.Parameters.VipRealName, VIPID = pRequest.UserID, Status = 2, ClientID = pRequest.CustomerID, VipCode = "Vip" + bll.GetNewVipCode(pRequest.CustomerID), VipSourceId = pRequest.Parameters.VipSource.ToString(), WeiXinUserId = string.IsNullOrWhiteSpace(pRequest.UserID) ? Guid.NewGuid().ToString("N") : pRequest.UserID, RegistrationTime = DateTime.Now }; bll.Create(vipByID); #region 注册会员触点活动奖励 //bllPrize.CheckIsWinnerForShare(CurrentUserInfo.UserID, "", "Reg"); RedisContactBLL redisContactBll = new RedisContactBLL(); redisContactBll.SetRedisContact(new RedisOpenAPIClient.Models.CC.CC_Contact() { CustomerId = CurrentUserInfo.ClientID, ContactType = "Reg", VipId = CurrentUserInfo.UserID }); #endregion } else if (vipByID != null) { VipEntity vipUpdateInfo = new VipEntity(); List <IWhereCondition> wheres = new List <IWhereCondition>(); //wheres.Add(new MoreThanCondition() { FieldName = "status", Value = 0, IncludeEquals = false }); wheres.Add(new MoreThanCondition() { FieldName = "status", Value = 0, IncludeEquals = true }); wheres.Add(new EqualsCondition() { FieldName = "vipid", Value = pRequest.UserID }); wheres.Add(new EqualsCondition() { FieldName = "clientid", Value = pRequest.CustomerID }); var result = bll.Query(wheres.ToArray(), null); if (result != null && result.Length > 0) { vipUpdateInfo = result[0]; } vipUpdateInfo.Phone = pRequest.Parameters.Mobile; if (!string.IsNullOrEmpty(pRequest.Parameters.VipRealName)) { vipUpdateInfo.VipRealName = pRequest.Parameters.VipRealName; } vipUpdateInfo.Status = 2; vipUpdateInfo.RegistrationTime = DateTime.Now; bll.Update(vipUpdateInfo); #region 注册会员触点活动奖励 //bllPrize.CheckIsWinnerForShare(CurrentUserInfo.UserID, "", "Reg"); RedisContactBLL redisContactBll = new RedisContactBLL(); redisContactBll.SetRedisContact(new RedisOpenAPIClient.Models.CC.CC_Contact() { CustomerId = CurrentUserInfo.ClientID, ContactType = "Reg", VipId = CurrentUserInfo.UserID }); #endregion #region 会员金矿、注册集客奖励 bll.SetOffActionReg(vipByID); #endregion } #endregion #region 根据VIP ID及手机号查询出的结果,尝试自动合并会员 (因目前会员注册不自动绑卡,实现用户自行选择绑卡业务故将绑卡业务注释掉) //if (vipByPhone == null) //{//如果未有相同手机号的用户,则无须绑定,直接使用VIP ID对应的VIP记录作为当前注册用户的记录 // rd.MemberInfo = new MemberInfo() // { // Mobile = vipByID.Phone // , // VipID = vipByID.VIPID // , // Name = vipByID.UserName // , // VipName = vipByID.VipName // , // VipNo = vipByID.VipCode // , // MemberBenefits = memberBenefit // , // IsActivate = vipByID.IsActivate.HasValue && vipByID.IsActivate.Value == 1 ? true : false // }; // //处理绑卡业务 add by Henry 2015/10/28 // vipCardVipMappingBLL.BindVipCard(vipByID.VIPID, vipByID.VipCode, vipByID.CouponInfo); //} //else //{//否则调用存储过程,做自动会员合并 // //如果会员已经注册过,并且来源是微信的则表示该帐号已经被注册过不能再次绑定 // if (vipByPhone.VipSourceId == "3" && vipByPhone.Status.Value >= 2) // { // throw new APIException("会员已经注册") { ErrorCode = ERROR_MEMBER_REGISTERED }; // } // //否则做会员合并 // if (!bll.MergeVipInfo(pRequest.CustomerID, pRequest.UserID, pRequest.Parameters.Mobile)) // { // throw new APIException("自动绑定会员信息失败") { ErrorCode = ERROR_AUTO_MERGE_MEMBER_FAILED }; // } // //合并成功后重新读取信息 // List<IWhereCondition> wheres = new List<IWhereCondition>(); // wheres.Add(new MoreThanCondition() { FieldName = "status", Value = 0, IncludeEquals = false }); // wheres.Add(new EqualsCondition() { FieldName = "vipid", Value = pRequest.UserID }); // wheres.Add(new EqualsCondition() { FieldName = "clientid", Value = pRequest.CustomerID }); // var result = bll.Query(wheres.ToArray(), null); // vipByID = result[0]; // rd.MemberInfo = new MemberInfo() // { // Mobile = vipByID.Phone // , // VipID = vipByID.VIPID // , // Name = vipByID.UserName // , // VipName = vipByID.VipName // , // VipNo = vipByID.VipCode // , // MemberBenefits = memberBenefit // , // IsActivate = vipByID.IsActivate.HasValue && vipByID.IsActivate.Value == 1 ? true : false // }; // //处理绑卡业务 add by Henry 2015/10/28 // vipCardVipMappingBLL.BindVipCard(vipByID.VIPID, vipByID.VipCode, vipByID.CouponInfo); //} #endregion } //注册会员信息发布到rabbitmq vipMsg = new EventContract { Operation = OptEnum.Create, EntityType = EntityTypeEnum.Vip, Id = pRequest.UserID }; eventService.PublishMsg(vipMsg); break; default: //其他来源则为自动注册 { #region 根据手机号查找下,看下是否存在同样手机号的VIP记录 { List <IWhereCondition> wheres = new List <IWhereCondition>(); wheres.Add(new MoreThanCondition() { FieldName = "status", Value = 0, IncludeEquals = false }); wheres.Add(new EqualsCondition() { FieldName = "phone", Value = pRequest.Parameters.Mobile }); wheres.Add(new EqualsCondition() { FieldName = "clientid", Value = pRequest.CustomerID }); var result = bll.Query(wheres.ToArray(), null); if (result != null && result.Length > 0) { vipByPhone = result[0]; } if (vipByPhone != null && vipByPhone.Status.Value >= 2) { throw new APIException("会员已经注册") { ErrorCode = ERROR_MEMBER_REGISTERED }; } } #endregion #region 没有找到相同电话的会员则自动注册 if (vipByPhone == null) { //没有找到相同电话的会员则自动注册 vipByPhone = new VipEntity() { Phone = pRequest.Parameters.Mobile, VipName = pRequest.Parameters.Mobile, UserName = pRequest.Parameters.Mobile, VipRealName = pRequest.Parameters.VipRealName, VIPID = string.IsNullOrWhiteSpace(pRequest.UserID) ? Guid.NewGuid().ToString("N") : pRequest.UserID, Status = 2, //状态为注册 VipCode = "Vip" + bll.GetNewVipCode(pRequest.CustomerID), ClientID = pRequest.CustomerID, VipSourceId = pRequest.Parameters.VipSource.ToString(), WeiXinUserId = string.IsNullOrWhiteSpace(pRequest.UserID) ? Guid.NewGuid().ToString("N") : pRequest.UserID, RegistrationTime = DateTime.Now }; bll.Create(vipByPhone); #region 注册会员触点活动奖励 //bllPrize.CheckIsWinnerForShare(CurrentUserInfo.UserID, "", "Reg"); RedisContactBLL redisContactBll = new RedisContactBLL(); redisContactBll.SetRedisContact(new RedisOpenAPIClient.Models.CC.CC_Contact() { CustomerId = CurrentUserInfo.ClientID, ContactType = "Reg", VipId = CurrentUserInfo.UserID }); #endregion } #endregion #region decimal EndAmount = 0; VipAmountBLL AmountBLL = new VipAmountBLL(this.CurrentUserInfo); VipAmountEntity amountEntity = AmountBLL.GetByID(vipByPhone.VIPID); if (amountEntity != null) { EndAmount = amountEntity.EndAmount.HasValue ? amountEntity.EndAmount ?? 0 : 0; } #endregion #region 返回用户信息 rd.MemberInfo = new MemberInfo() { Mobile = vipByPhone.Phone , VipID = vipByPhone.VIPID , Name = vipByPhone.UserName , VipName = vipByPhone.VipName , VipRealName = vipByPhone.VipRealName , VipNo = vipByPhone.VipCode , MemberBenefits = memberBenefit , IsActivate = false , Integration = vipByPhone.Integration ?? 0 , Balance = EndAmount }; #endregion } //注册会员信息发布到rabbitmq vipMsg = new EventContract { Operation = OptEnum.Create, EntityType = EntityTypeEnum.Vip, Id = rd.MemberInfo.VipID }; eventService.PublishMsg(vipMsg); break; } T_LEventsRegVipLogBLL lEventRegVipLogBll = new T_LEventsRegVipLogBLL(CurrentUserInfo); if (!string.IsNullOrEmpty(pRequest.Parameters.CTWEventId)) { lEventRegVipLogBll.CTWRegOrFocusLog(pRequest.Parameters.CTWEventId, pRequest.UserID, "", CurrentUserInfo, "Reg"); } //如果是通过优惠券进来的就有couponId 新注册的需要加记录 if (!string.IsNullOrEmpty(pRequest.Parameters.couponId)) { lEventRegVipLogBll.CouponRegOrFocusLog(pRequest.Parameters.couponId, pRequest.UserID, "", CurrentUserInfo, "Reg"); } //当手机号不为空时需要查询是否存在实体卡 //if (!string.IsNullOrEmpty(pRequest.Parameters.Mobile) && (!string.IsNullOrEmpty(pRequest.UserID) || !string.IsNullOrEmpty(vipByPhone.VIPID))) //{ // List<IWhereCondition> wheres = new List<IWhereCondition>(); // wheres.Add(new EqualsCondition() { FieldName = "phone", Value = pRequest.Parameters.Mobile }); // wheres.Add(new EqualsCondition() { FieldName = "clientid", Value = pRequest.CustomerID }); // wheres.Add(new DirectCondition("VipID!='" + pRequest.UserID + "'")); // var vipInfo = bll.Query(wheres.ToArray(), null); // if (vipInfo != null && vipInfo.Length > 0) // { // throw new APIException("检测到会员相关实体卡") { ErrorCode = MEMBER_HAVECARD }; // } // else // { // //如果会员当前没有实体卡,则默认绑定等级为1的卡 // vipCardVipMappingBLL.BindVipCard(vipByID.VIPID, vipByID.VipCode, vipByID.CouponInfo); // throw new APIException("未检测到实体卡") { ErrorCode = MEMBER_HAVENOCARD }; // } //} //判定是否有可绑卡的定义 1=有可绑卡 if (HaveVipcard == 1 || HaveVipcard == 2) { //有积分的话给相应领取成功的积分提示 var contactEventBLL = new ContactEventBLL(CurrentUserInfo); int sendIntegral = 0; if (!string.IsNullOrEmpty(pRequest.Parameters.CTWEventId)) { sendIntegral = contactEventBLL.GetContactEventIntegral(CurrentUserInfo.ClientID, "Reg", "Point", 1); } else { sendIntegral = contactEventBLL.GetContactEventIntegral(CurrentUserInfo.ClientID, "Reg", "Point", 0); } if (sendIntegral > 0) { if (pRequest.Parameters.registerType != 2 && HaveVipcard == 2) { throw new APIException("恭喜您领取成功并获得" + sendIntegral + "注册积分") { ErrorCode = MEMBER_GETSUCCESS }; //领取成功不跳转跳转到实体卡 } else if (pRequest.Parameters.registerType == 2 && HaveVipcard == 1) { throw new APIException("恭喜您领取成功并获得" + sendIntegral + "注册积分") { ErrorCode = MEMBER_HAVECARD_Integral }; //检测到有相关实体卡前端不提示领取成功 并跳到实体卡列表 } else { throw new APIException("恭喜您领取成功并获得" + sendIntegral + "注册积分") { ErrorCode = MEMBER_HAVECARD }; //领取成功,提示领取成功,并跳到相关实体卡 } } else { if (pRequest.Parameters.registerType != 2 && HaveVipcard == 2) { throw new APIException("领取成功") { ErrorCode = MEMBER_GETSUCCESS }; //领取成功不跳转跳转到实体卡 } else if (pRequest.Parameters.registerType == 2 && HaveVipcard == 1) { throw new APIException("检测到有相关实体卡") { ErrorCode = MEMBER_HAVECARD }; //检测到有相关实体卡前端不提示领取成功 并跳到实体卡列表 } else if (pRequest.Parameters.registerType != 2 && HaveVipcard == 1) { throw new APIException("领取成功") { ErrorCode = MEMBER_HAVECARD }; //领取成功有实体卡,并跳转 } else { throw new APIException("检测到有相关实体卡") { ErrorCode = MEMBER_HAVECARD }; //领取成功,提示领取成功,并跳到相关实体卡 } } } #region 将验证码设置为已验证 //entity.IsValidated = 1; //codebll.Update(entity); #endregion return(rd); //AuthCodeLoginRD rd = new AuthCodeLoginRD(); //rd.MemberInfo = new MemberInfo(); //var codebll = new RegisterValidationCodeBLL(base.CurrentUserInfo); //var entity = codebll.GetByMobile(pRequest.Parameters.Mobile); //if (entity == null) // throw new APIException("未找到此手机的验证信息") { ErrorCode = ERROR_AUTHCODE_NOTEXISTS }; //if (entity.IsValidated.Value == 1) // throw new APIException("此验证码已失效") { ErrorCode = ERROR_AUTHCODE_FAILURE }; //if (entity.Expires.Value < DateTime.Now) // throw new APIException("此验证码已失效") { ErrorCode = ERROR_AUTHCODE_FAILURE }; //var vipbll = new VipBLL(base.CurrentUserInfo); //var vipinfo = vipbll.GetByMobile(pRequest.Parameters.Mobile, pRequest.CustomerID); //#region VIP来源更新 //switch (pRequest.Parameters.VipSource.Value) //{ // case 4: // case 9: // vipinfo.VipSourceId = pRequest.Parameters.VipSource.ToString(); // vipbll.Update(vipinfo); // break; //} //#endregion //if (string.IsNullOrEmpty(vipinfo.ClientID)) //{ // vipinfo.ClientID = pRequest.CustomerID; // vipbll.Update(vipinfo); //} //rd.MemberInfo.Mobile = vipinfo.Phone; //rd.MemberInfo.Name = vipinfo.UserName; //rd.MemberInfo.VipID = vipinfo.VIPID; //rd.MemberInfo.VipName = vipinfo.VipName; //var customerBasicSettingBll = new CustomerBasicSettingBLL(CurrentUserInfo); //rd.MemberInfo.MemberBenefits = customerBasicSettingBll.GetMemberBenefits(pRequest.CustomerID); //entity.IsValidated = 1; //codebll.Update(entity); //return rd; } } }
public HttpResponseMessage ScanQRCode([FromBody] ScanQRCodeRequestModel requestParameter) { var json = new JavaScriptSerializer().Serialize(requestParameter); Loggers.Debug(new DebugLogInfo() { Message = $"[api/Order/ScanQRCode]接口,参数:\"{json}\"" }); try { #region MyRegion string customerId = ConfigurationManager.AppSettings["CustomerId"].Trim(); string content = string.Empty; #endregion #region var loggingSessionInfo = Default.GetLoggingSession(customerId, "1"); if (string.IsNullOrWhiteSpace(requestParameter.ParaTmp)) { throw new APIException("paraTmp不能为空") { ErrorCode = 302 }; } #endregion #region 创建临时匹配表 VipDCodeBLL vipDCodeServer = new VipDCodeBLL(loggingSessionInfo); VipDCodeEntity info = new VipDCodeEntity(); //由于CodeId有重复的概率,因此只取出最新的一条记录 info = vipDCodeServer.QueryByEntity( new VipDCodeEntity() { DCodeId = ToStr(requestParameter.ParaTmp.Replace(" ", "")) } //又去掉了中间的空格 , new OrderBy[] { new OrderBy() { FieldName = "CreateTime", Direction = OrderByDirections.Desc } } )[0]; string status = string.Empty; string vipId = string.Empty; string openId = string.Empty; if (info == null || info.DCodeId == null) { throw new APIException("不存在对应的记录") { ErrorCode = 303 }; } else { status = info.Status; openId = info.OpenId; vipId = info.VipId; } string mode = "Inbound"; //if ((RP.Parameters.special.Mode == null || (!string.IsNullOrEmpty(RP.Parameters.special.Mode) && RP.Parameters.special.Mode.Equals("Inbound"))) && !string.IsNullOrEmpty(info.VipId) && info.VipId != RP.UserID) if ((mode == null || (!string.IsNullOrEmpty(mode) && mode.Equals("Inbound"))) && !string.IsNullOrEmpty(info.VipId) && info.VipId != requestParameter.UserId) { VipBLL vipBll = new VipBLL(loggingSessionInfo); var unitBll = new t_unitBLL(loggingSessionInfo); var UserBll = new T_UserBLL(loggingSessionInfo); var vipInfo = vipBll.GetByID(info.VipId); var tt = vipBll.GetUnitByUserId(requestParameter.UserId); //获取员工的会集店**** var UserEntity = UserBll.GetByID(vipInfo.SetoffUserId); //当前会员集客员工 // string UserStatus = ""; if (UserEntity != null) { UserStatus = UserEntity.user_status; } #region 会员会籍店、集客员工变动处理 //string.IsNullOrWhiteSpace(vipInfo.CouponInfo) || string.IsNullOrWhiteSpace(vipInfo.SetoffUserId) 目前未用到 if (string.IsNullOrWhiteSpace(vipInfo.HigherVipID) && string.IsNullOrWhiteSpace(vipInfo.SetoffUserId)) { //当会员会籍店、集客员工为空时 if (!string.IsNullOrEmpty(tt)) { vipInfo.CouponInfo = tt; //设为门店 vipInfo.SetoffUserId = requestParameter.UserId; //设为门店员工 vipInfo.Col21 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); //集客时间***** vipInfo.Col23 = "1"; } if (vipInfo != null && vipInfo.SetoffUserId == requestParameter.UserId) { //rsp.Message = "恭喜你集客成功。会员需要用心经营才会有订单哦!"; } } else { if (vipInfo != null && !string.IsNullOrEmpty(vipInfo.CouponInfo) && vipInfo.SetoffUserId != requestParameter.UserId) { //rsp.Message = "此客户已是会员,无需再集客。老会员更要服务好哦!"; } else if (vipInfo != null && vipInfo.SetoffUserId == requestParameter.UserId && !string.IsNullOrEmpty(vipInfo.Col21) && Convert.ToDateTime(vipInfo.Col21).AddSeconds(3) < DateTime.Now) //col21:员工集客/或者分销商集客时间 { //rsp.Message = "此客户此前已经被您集客,无需重复集客。!"; } } if (UserStatus.Trim().Equals("-1")) { // 当前会员的集客员工离职时 if (!string.IsNullOrEmpty(tt)) { vipInfo.CouponInfo = tt; //设为门店 vipInfo.SetoffUserId = requestParameter.UserId; //设为门店员工 vipInfo.Col21 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); //集客时间***** vipInfo.Col23 = "1"; } } #endregion vipBll.Update(vipInfo); } #endregion var responseModel = new ScanQRCodeResponseModel() { IsSucess = true, Status = status, VipId = vipId }; return(Request.CreateResponse(HttpStatusCode.OK, responseModel)); } catch (Exception ex) { var responseModel = new ScanQRCodeResponseModel() { IsSucess = false, ErrorMessage = ex.Message }; return(Request.CreateResponse(HttpStatusCode.InternalServerError, "error")); } }
/// <summary> /// 种植 角色菜单 缓存 /// </summary> public void AutoSetOrderNotPayCache() { _CustomerIDList = CustomerBLL.Instance.GetCustomerList(); foreach (var customer in _CustomerIDList) { // _T_loggingSessionInfo.ClientID = customer.Key; _T_loggingSessionInfo.CurrentLoggingManager.Connection_String = customer.Value; // _T_InoutBLL = new T_InoutBLL(_T_loggingSessionInfo); _Inout3Service = new Inout3Service(_T_loggingSessionInfo); _VipBLL = new VipBLL(_T_loggingSessionInfo); // // var t_InoutList = new List<string>(); try { var t_InoutEntitys = _T_InoutBLL.QueryByEntity(new T_InoutEntity { customer_id = customer.Key, Field1 = "0", //未支付 status = "100" //已经正式提交 }, null); if (t_InoutEntitys == null || t_InoutEntitys.Count() <= 0) { continue; } // // roleList = roleEntities.Select(it => it.role_id).ToList(); string productNames = ""; foreach (var t_InoutInfo in t_InoutEntitys) { //每次都重新设置 productNames = ""; var _T_Inout_DetailList = _Inout3Service.GetInoutDetailInfoByOrderId(t_InoutInfo.order_id, _T_loggingSessionInfo.ClientID); if (_T_Inout_DetailList != null && _T_Inout_DetailList.Count > 0)//获取商品信息 { foreach (var _T_Inout_DetailInfo in _T_Inout_DetailList) { if (productNames == "") { productNames += _T_Inout_DetailInfo.item_name + "*" + _T_Inout_DetailInfo.order_qty; } else { productNames += "," + _T_Inout_DetailInfo.item_name + "*" + _T_Inout_DetailInfo.order_qty; } } } try { //获取会员的信息 var vip = _VipBLL.GetByID(t_InoutInfo.vip_no); new SendOrderNotPayMsgBLL().NotPayMessage(t_InoutInfo.actual_amount.ToString(), productNames, t_InoutInfo.Field4, t_InoutInfo.order_no, vip.WeiXinUserId, _T_loggingSessionInfo); } catch { continue; } } } catch { continue; } } }
protected override SetReceiveAmountOrderRD ProcessRequest(APIRequest <SetReceiveAmountOrderRP> pRequest) { SetReceiveAmountOrderRP rp = pRequest.Parameters; SetReceiveAmountOrderRD rd = new SetReceiveAmountOrderRD(); var receiveAmountOrderBll = new ReceiveAmountOrderBLL(CurrentUserInfo); var sysVipCardGradeBLL = new SysVipCardGradeBLL(CurrentUserInfo); //获取折扣表 var vipBLL = new VipBLL(CurrentUserInfo); var unitBLL = new t_unitBLL(CurrentUserInfo); var vipInfo = vipBLL.GetByID(pRequest.UserID); //获取会员信息 if (vipInfo == null) { throw new APIException("没有会员信息") { ErrorCode = 101 }; } var unitInfo = unitBLL.GetByID(rp.UnitId); if (unitInfo == null) { throw new APIException("没有服务门店信息") { ErrorCode = 101 }; } decimal discountAmount = 0; //抵扣金额汇总 decimal couponAmount = 0; //优惠券抵用金额 decimal endAmount = rp.VipEndAmount; //余额 decimal integralAmount = rp.Integral; //获取订单号 TUnitExpandBLL serviceUnitExpand = new TUnitExpandBLL(CurrentUserInfo); string orderNo = serviceUnitExpand.GetUnitOrderNo(); //折扣 decimal discount = 1; if (rp.VipDiscount > 0) { discount = sysVipCardGradeBLL.GetVipDiscount() / 10;//会员折扣 } decimal tempAmount = Math.Round((discount == 0 ? 1 : discount) * rp.TotalAmount, 2, MidpointRounding.AwayFromZero); Guid orderId = Guid.NewGuid(); //积分处理 if (rp.IntegralFlag == 1) { //加入折扣金额 discountAmount = discountAmount + rp.IntegralAmount; } else { integralAmount = 0; } //使用优惠券 if (rp.CouponFlag == 1) { #region 判断优惠券是否是该会员的 var vipcouponMappingBll = new VipCouponMappingBLL(CurrentUserInfo); var vipcouponmappingList = vipcouponMappingBll.QueryByEntity(new VipCouponMappingEntity() { VIPID = vipInfo.VIPID, CouponID = rp.CouponId }, null); if (vipcouponmappingList == null || vipcouponmappingList.Length == 0) { throw new APIException("此张优惠券不是该会员的") { ErrorCode = 103 }; } #endregion #region 判断优惠券是否有效 var couponBll = new CouponBLL(CurrentUserInfo); var couponEntity = couponBll.GetByID(rp.CouponId); if (couponEntity == null) { throw new APIException("无效的优惠券") { ErrorCode = 103 }; } if (couponEntity.Status == 1) { throw new APIException("优惠券已使用") { ErrorCode = 103 }; } if (couponEntity.EndDate < DateTime.Now) { throw new APIException("优惠券已过期") { ErrorCode = 103 }; } var couponTypeBll = new CouponTypeBLL(CurrentUserInfo); var couponTypeEntity = couponTypeBll.GetByID(couponEntity.CouponTypeID); if (couponTypeEntity == null) { throw new APIException("无效的优惠券类型") { ErrorCode = 103 }; } #endregion discountAmount = discountAmount + couponTypeEntity.ParValue ?? 0; couponAmount = couponTypeEntity.ParValue ?? 0; //更新使用记录 var couponUseBll = new CouponUseBLL(CurrentUserInfo); var couponUseEntity = new CouponUseEntity() { CouponUseID = Guid.NewGuid(), CouponID = rp.CouponId, VipID = vipInfo.VIPID, UnitID = rp.UnitId, OrderID = orderId.ToString(), Comment = "商城使用电子券", CustomerID = CurrentUserInfo.ClientID, CreateBy = CurrentUserInfo.UserID, CreateTime = DateTime.Now, LastUpdateBy = CurrentUserInfo.UserID, LastUpdateTime = DateTime.Now, IsDelete = 0 }; couponUseBll.Create(couponUseEntity); //更新CouponType数量 var conponTypeBll = new CouponTypeBLL(CurrentUserInfo); var conponTypeEntity = conponTypeBll.QueryByEntity(new CouponTypeEntity() { CouponTypeID = new Guid(couponEntity.CouponTypeID), CustomerId = CurrentUserInfo.ClientID }, null).FirstOrDefault(); conponTypeEntity.IsVoucher += 1; conponTypeBll.Update(conponTypeEntity); //停用该优惠券 couponEntity.Status = 1; couponBll.Update(couponEntity); } //使用余额 if (rp.VipEndAmountFlag == 1) { var vipAmountBll = new VipAmountBLL(CurrentUserInfo); var vipAmountDetailBll = new VipAmountDetailBLL(CurrentUserInfo); var vipAmountEntity = vipAmountBll.QueryByEntity(new VipAmountEntity() { VipId = vipInfo.VIPID, VipCardCode = vipInfo.VipCode }, null).FirstOrDefault(); if (vipAmountEntity != null) { //判断该会员账户是否被冻结 if (vipAmountEntity.IsLocking == 1) { throw new APIException("账户已被冻结,请先解冻") { ErrorCode = 103 } } ; //判断该会员的账户余额是否大于本次使用的余额 if (vipAmountEntity.EndAmount < rp.VipEndAmount) { throw new APIException(string.Format("账户余额不足,当前余额为【{0}】", vipAmountEntity.EndAmount)) { ErrorCode = 103 } } ; //所剩余额大于商品价格,扣除余额的数量为商品价格 if (tempAmount < rp.VipEndAmount) { rp.VipEndAmount = endAmount = Convert.ToDecimal(tempAmount); } } } //不使用余额,余额为0 else { endAmount = 0; } //实付金额 decimal transAmount = tempAmount - discountAmount; //支付状态 string payStatus = "0"; //支付时间 DateTime?PayDatetTime = null; //实付金额全是由余额支付,支付状态和支付时间全部更新,积分扣减、余额扣减、优惠券使用 if (transAmount == endAmount || transAmount == 0) { payStatus = "10"; PayDatetTime = DateTime.Now; //处理积分抵扣 if (rp.IntegralFlag == 1) { var vipIntegralBll = new VipIntegralBLL(CurrentUserInfo); string sourceId = "20"; //积分抵扣 var IntegralDetail = new VipIntegralDetailEntity() { Integral = -Convert.ToInt32(rp.Integral), IntegralSourceID = sourceId, ObjectId = orderId.ToString() }; if (IntegralDetail.Integral != 0) { //变动前积分 string OldIntegral = (vipInfo.Integration ?? 0).ToString(); //变动积分 string ChangeIntegral = (IntegralDetail.Integral ?? 0).ToString(); var vipIntegralDetailId = vipIntegralBll.AddIntegral(ref vipInfo, unitInfo, IntegralDetail, CurrentUserInfo); //发送微信积分变动通知模板消息 if (!string.IsNullOrWhiteSpace(vipIntegralDetailId)) { var CommonBLL = new CommonBLL(); CommonBLL.PointsChangeMessage(OldIntegral, vipInfo, ChangeIntegral, vipInfo.WeiXinUserId, CurrentUserInfo); } } } //处理余额抵扣 if (rp.VipEndAmountFlag == 1) { var vipAmountBll = new VipAmountBLL(CurrentUserInfo); var vipAmountDetailBll = new VipAmountDetailBLL(CurrentUserInfo); var vipAmountEntity = vipAmountBll.QueryByEntity(new VipAmountEntity() { VipId = vipInfo.VIPID, VipCardCode = vipInfo.VipCode }, null).FirstOrDefault(); if (vipAmountEntity != null) { var detailInfo = new VipAmountDetailEntity() { Amount = -rp.VipEndAmount, AmountSourceId = "1", ObjectId = orderId.ToString() }; var vipAmountDetailId = vipAmountBll.AddVipAmount(vipInfo, unitInfo, ref vipAmountEntity, detailInfo, CurrentUserInfo); if (!string.IsNullOrWhiteSpace(vipAmountDetailId)) {//发送微信账户余额变动模板消息 var CommonBLL = new CommonBLL(); CommonBLL.BalanceChangedMessage(orderNo, vipAmountEntity, detailInfo, vipInfo.WeiXinUserId, vipInfo.VIPID, CurrentUserInfo); } } } } //收款订单 ReceiveAmountOrderEntity receiveAmountOrderEntity = new ReceiveAmountOrderEntity() { OrderId = orderId, OrderNo = orderNo, VipId = vipInfo.VIPID, ServiceUnitId = unitInfo.unit_id, ServiceUserId = rp.EmployeeID, TotalAmount = rp.TotalAmount, VipDiscount = discount * 100, TransAmount = transAmount, PayPoints = integralAmount, AmountFromPayPoints = rp.IntegralAmount, CouponUsePay = couponAmount, AmountAcctPay = endAmount, PayStatus = payStatus, TimeStamp = rp.TimeStamp, PayDatetTime = PayDatetTime, CustomerId = CurrentUserInfo.ClientID }; receiveAmountOrderBll.Create(receiveAmountOrderEntity); //订单奖励 if (transAmount == endAmount || transAmount == 0) { var vipIntegralBll = new VipIntegralBLL(CurrentUserInfo); vipIntegralBll.OrderReward(receiveAmountOrderEntity, null); } rd.orderId = orderId.ToString(); return(rd); } } }
/// <summary> /// 华硕校园 专家登录 /// </summary> /// <returns></returns> public string AmbassadorLoginIn() { string content = string.Empty; var respData = new ambassadorLoginInRespData(); try { //接收参数 string reqContent = HttpContext.Current.Request["ReqContent"]; var reqObj = reqContent.DeserializeJSONTo <ambassadorLoginInReqData>(); reqObj = reqObj == null ? new ambassadorLoginInReqData() : reqObj; //获取客户ID if (!string.IsNullOrEmpty(reqObj.common.customerId)) { customerId = reqObj.common.customerId; } //初始化返回对象 respData.content = new ambassadorLoginInRespContentData(); respData.content.vipList = new List <ambassadorLoginInRespContentDataItem>(); //用户登录信息 var loggingSessionInfo = Default.GetBSLoggingSession(customerId, "1"); OnlineShoppingItemBLL itemService = new OnlineShoppingItemBLL(loggingSessionInfo); #region //组装参数 Dictionary <string, string> pParams = new Dictionary <string, string>(); if (!string.IsNullOrEmpty(reqObj.special.code)) { pParams.Add("pCode", reqObj.special.code); } //是否有此人 var vip = new VipBLL(loggingSessionInfo).Query(new IWhereCondition[] { new EqualsCondition() { FieldName = "VipCode", Value = reqObj.special.code }, new EqualsCondition() { FieldName = "ClientID", Value = customerId } }, null).FirstOrDefault(); if (vip != null) { pParams.Add("pPass", MD5Helper.Encryption(MD5Helper.Encryption(reqObj.special.pass) + vip.Col4)); } else { respData.code = "111"; respData.description = "专家编号或密码错误"; content = respData.ToJSON(); return(content); } #endregion var vipInfo = itemService.AmbassadorLoginIn(pParams); if (vipInfo != null && vipInfo.Count > 0) { List <ambassadorLoginInRespContentDataItem> list = new List <ambassadorLoginInRespContentDataItem>(); foreach (var item in vipInfo) { ambassadorLoginInRespContentDataItem info = new ambassadorLoginInRespContentDataItem(); info.VipID = item.VIPID; info.VipName = item.VipName; info.VipRealName = item.VipRealName; info.VipCode = item.VipCode; info.Phone = item.Phone; info.City = item.City; info.DeliveryAddress = item.DeliveryAddress; info.Province = item.Province; info.CityCode = item.CityCode; info.RoleName = item.RoleName; info.Code = item.VipCode; list.Add(info); } respData.content.vipList = list; } else { respData.code = "111"; respData.description = "专家编号或密码错误"; } } catch (Exception ex) { respData.code = "103"; respData.description = "数据库操作错误"; respData.exception = ex.ToString(); } content = respData.ToJSON(); return(content); }
protected override SetVipCardRD ProcessRequest(DTO.Base.APIRequest <OpenVipCardRP> pRequest) { var rd = new SetVipCardRD(); var para = pRequest.Parameters; var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo; //登录状态信息 var vipBLL = new VipBLL(loggingSessionInfo); //会员业务对象实例化 var vipTagsMappingBLL = new VipTagsMappingBLL(loggingSessionInfo); //会员和标签关系业务对象实例化 var vipCardBLL = new VipCardBLL(loggingSessionInfo); //会员卡业务对象实例化 var vipCardVipMappingBLL = new VipCardVipMappingBLL(loggingSessionInfo); //会员和会员卡关系业务对象实例化 var vipCardStatusChangeLogBLL = new VipCardStatusChangeLogBLL(loggingSessionInfo); //会员卡状态变更业务对象实例化 var vipAddressBLL = new VipAddressBLL(loggingSessionInfo); //会员地址信息业务对象实例化 var pTran = vipCardBLL.GetTran(); //事务 using (pTran.Connection) { try { //创建会员信息 var vipEntity = new VipEntity() { VIPID = Guid.NewGuid().ToString().Replace("-", ""), VipName = para.VipName, VipRealName = para.VipName, //VipCode = "Vip" + vipBLL.GetNewVipCode(loggingSessionInfo.ClientID), //获取会员编号 VipCode = para.VipCardCode, //会员卡号 CouponInfo = loggingSessionInfo.CurrentUserRole.UnitId, //原会集店字段 MembershipStore = loggingSessionInfo.CurrentUserRole.UnitId, //新增的会集店字段 Phone = para.Phone, Birthday = para.Birthday, Gender = para.Gender, Email = para.Email, Col18 = para.IDCard, //身份证 Status = 2, //已注册状态 VipSourceId = "20", //来源开卡 ClientID = loggingSessionInfo.ClientID }; vipBLL.Create(vipEntity, pTran); //保存年龄段标签 var vipTagsMappingEntity = new VipTagsMappingEntity() { MappingId = Guid.NewGuid().ToString().Replace("-", ""), VipId = vipEntity.VIPID, TagsId = para.TagsID }; vipTagsMappingBLL.Create(vipTagsMappingEntity, pTran); //保存会员地址信息 //var vipAddressEntity = new VipAddressEntity() //{ // VIPID = vipEntity.VIPID, // LinkMan = para.VipName, // LinkTel = para.Phone, // CityID = para.CityID, // Address = para.Address, // IsDefault = 1 //}; //vipAddressBLL.Create(vipAddressEntity, pTran); //更新会员卡信息 var vipCardEntity = vipCardBLL.GetByID(para.VipCardID); if (vipCardEntity != null) { #region 返回卡ID rd.VipCardID = vipCardEntity.VipCardID; #endregion //vipCardEntity.VipCardStatusId = 1; if (!string.IsNullOrEmpty(vipCardEntity.MembershipUnit)) { throw new APIException("此会员卡已绑定会员") { ErrorCode = ERROR_CODES.INVALID_BUSINESS } } ; if (vipCardEntity.VipCardStatusId > 0) { throw new APIException("此会员卡状态异常") { ErrorCode = ERROR_CODES.INVALID_BUSINESS } } ; vipCardEntity.MembershipTime = DateTime.Now; vipCardEntity.MembershipUnit = loggingSessionInfo.CurrentUserRole.UnitId; vipCardEntity.IsGift = para.IsGift; //vipCardEntity.SalesUserId = para.SalesUserId; vipCardEntity.SalesUserName = para.SalesUserName; //用户输入名称,后期需要根据姓名查找用户ID,更新到SalesUserId vipCardEntity.CreateBy = loggingSessionInfo.UserID; //开卡人,即入会员工 vipCardBLL.Update(vipCardEntity, pTran); } else { throw new APIException("查不到此会员卡") { ErrorCode = ERROR_CODES.INVALID_BUSINESS } }; //新增会员卡操作状态信息 var vipCardStatusChangeLogEntity = new VipCardStatusChangeLogEntity() { LogID = Guid.NewGuid().ToString().Replace("-", ""), VipCardStatusID = vipCardEntity.VipCardStatusId, VipCardID = para.VipCardID, Action = "开卡", //Reason = "", UnitID = loggingSessionInfo.CurrentUserRole.UnitId, CustomerID = loggingSessionInfo.ClientID }; vipCardStatusChangeLogBLL.Create(vipCardStatusChangeLogEntity, pTran); //绑定会员卡和会员 var vipCardVipMappingEntity = new VipCardVipMappingEntity() { MappingID = Guid.NewGuid().ToString().Replace("-", ""), VIPID = vipEntity.VIPID, VipCardID = para.VipCardID, CustomerID = loggingSessionInfo.ClientID }; vipCardVipMappingBLL.Create(vipCardVipMappingEntity, pTran); pTran.Commit(); //提交事物 } catch (APIException apiEx) { pTran.Rollback();//回滚事物 throw new APIException(apiEx.ErrorCode, apiEx.Message); } catch (Exception ex) { pTran.Rollback();//回滚事物 throw new Exception(ex.Message); } } 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); }
public HttpResponseMessage Amount(string vipId, decimal amount) { Loggers.Debug(new DebugLogInfo() { Message = $"[api/Integral/Amount]接口,参数:\"vipId:{vipId}&&amount:{amount}\"" }); try { string customerid = ConfigurationManager.AppSettings["CustomerId"].Trim(); var loggingSessionInfo = Default.GetLoggingSession(customerid, vipId); loggingSessionInfo.Conn = ConfigurationManager.AppSettings["Conn"].Trim(); var bll = new VipBLL(loggingSessionInfo); var vipInfo = bll.GetByID(vipId); //会员信息 var integralAmountResponseModel = new IntegralAmountResponseModel(); //获取社会化销售配置和积分返现配置 var basicSettingBll = new CustomerBasicSettingBLL(loggingSessionInfo); Hashtable htSetting = basicSettingBll.GetSocialSetting(); //2.获取会员的积分和账户余额 var vipIntegralbll = new VipIntegralBLL(loggingSessionInfo); //var vipIntegralEntity = vipIntegralbll.GetByID(rp.UserID); //根据会员和会员卡号获取积分 var vipIntegralEntity = vipIntegralbll.QueryByEntity( new VipIntegralEntity() { VipID = vipInfo.UserId, VipCardCode = vipInfo.VipCode }, null) .FirstOrDefault(); if (vipIntegralEntity == null) { integralAmountResponseModel.Integral = 0; integralAmountResponseModel.IntegralAmount = 0; } else { decimal validIntegral = vipIntegralEntity.ValidIntegral ?? 0; //会员积分 int totalIntegral = 0; //可使用积分(取整) //if (int.Parse(htSetting["rewardsType"].ToString()) == 1)//按商品奖励 // totalIntegral = (int)Math.Round(bll.GetIntegralBySkuId(skuIdList), 1); //积分使用上限比例 decimal pointsRedeemUpLimit = decimal.Parse(htSetting["pointsRedeemUpLimit"].ToString()) / 100; //3.获取积分与金额的兑换比例 var integralAmountPre = bll.GetIntegralAmountPre(customerid); if (integralAmountPre == 0) { integralAmountPre = (decimal)0.01; } totalIntegral = (int)Math.Round(amount * pointsRedeemUpLimit * integralAmountPre, 1); //可使用的积分 integralAmountResponseModel.Integral = validIntegral > totalIntegral ? totalIntegral : validIntegral; if (amount == 0) { integralAmountResponseModel.Integral = Convert.ToDecimal(vipIntegralEntity.ValidIntegral); } //rd.IntegralAmount = rd.Integral * integralAmountPre; integralAmountResponseModel.IntegralAmount = bll.GetAmountByIntegralPer(loggingSessionInfo.ClientID, integralAmountResponseModel.Integral); integralAmountResponseModel.IntegralDesc = "使用积分" + integralAmountResponseModel.Integral.ToString("0") + ",可兑换" + integralAmountResponseModel.IntegralAmount.ToString( "0.00") + "元"; } integralAmountResponseModel.IsSucess = true; return(Request.CreateResponse(HttpStatusCode.OK, integralAmountResponseModel)); } catch (Exception ex) { var response = new IntegralAmountResponseModel() { IsSucess = false, ErrorMessage = ex.Message }; return(Request.CreateResponse(HttpStatusCode.InternalServerError, response)); } }
/// <summary> /// 计算购卡分润 /// </summary> public void CalculateSalesVipCardOrderJob() { var numCount = 50; var customerIDs = CustomerBLL.Instance.GetCustomerList(); foreach (var customer in customerIDs) { string connString = customer.Value; var count = RedisOpenAPI.Instance.CCSalesCardOrder().GetSalesCardOrderLength(new CC_Order { CustomerID = customer.Key }); if (count.Code != ResponseCode.Success) { BaseService.WriteLog("从redis获取vipcard订单数据失败"); continue; } if (count.Result <= 0) { continue; } if (count.Result < numCount) { numCount = Convert.ToInt32(count.Result); } //DataTable dtAmountDetail = CreateTableAmountDetail(); //DataTable dtAmount = CreateTableAmount(); //DataTable dtSplitProfitRecord = CreateTableSplitProfitRecord(); for (var i = 0; i < numCount; i++) { var response = RedisOpenAPI.Instance.CCSalesCardOrder().GetSalesCardOrder(new CC_Order { CustomerID = customer.Key }); if (response.Code == ResponseCode.Success) { var orderInfo = response.Result.OrderInfo.JsonDeserialize <T_InoutEntity>(); var loggingSessionInfo = CustomerBLL.Instance.GetBSLoggingSession(customer.Key, "RedisSystem"); T_InoutBLL inoutBLL = new T_InoutBLL(loggingSessionInfo); if (orderInfo != null) { VipBLL bllVip = new VipBLL(loggingSessionInfo); T_Inout_DetailBLL bllInoutDetail = new T_Inout_DetailBLL(loggingSessionInfo); T_VirtualItemTypeSettingBLL bllVirtualItemTypeSetting = new T_VirtualItemTypeSettingBLL(loggingSessionInfo); VipCardUpgradeRuleBLL bllVipCardUpgradeRule = new VipCardUpgradeRuleBLL(loggingSessionInfo); VipAmountBLL bllVipAmount = new VipAmountBLL(loggingSessionInfo); VipAmountDetailBLL bllVipAmountDetail = new VipAmountDetailBLL(loggingSessionInfo); T_SplitProfitRecordBLL bllSplitProfitRecord = new T_SplitProfitRecordBLL(loggingSessionInfo); VipAmountEntity entityVipAmount = new VipAmountEntity(); VipAmountDetailEntity entityVipAmountDetail = new VipAmountDetailEntity(); T_SplitProfitRecordEntity entitySplitProfitRecord = new T_SplitProfitRecordEntity(); DataSet dsVipCardLevel = bllVip.GetVipCardLevel(orderInfo.vip_no, loggingSessionInfo.ClientID); var entityInoutDetail = bllInoutDetail.QueryByEntity(new T_Inout_DetailEntity() { order_id = orderInfo.order_id }, null).FirstOrDefault(); if (entityInoutDetail == null) { continue; } var vipCardType = bllVirtualItemTypeSetting.QueryByEntity(new T_VirtualItemTypeSettingEntity() { SkuId = entityInoutDetail.sku_id, IsDelete = 0 }, null).FirstOrDefault(); if (vipCardType != null) { int intVipCardTypeID = Convert.ToInt32(vipCardType.ObjecetTypeId); var entityVipCardUpgradeRule = bllVipCardUpgradeRule.QueryByEntity(new VipCardUpgradeRuleEntity() { VipCardTypeID = intVipCardTypeID, IsPurchaseUpgrade = 1, IsDelete = 0 }, null).SingleOrDefault(); if (entityVipCardUpgradeRule != null) { VipCardProfitRuleBLL bllVipCardProfitRule = new VipCardProfitRuleBLL(loggingSessionInfo); var entityVipCardProfitRule = bllVipCardProfitRule.QueryByEntity(new VipCardProfitRuleEntity() { VipCardTypeID = intVipCardTypeID, IsDelete = 0 }, null); foreach (var ProfitRule in entityVipCardProfitRule) { if (ProfitRule.IsApplyAllUnits == 0) { VipCardProfitRuleUnitMappingBLL bllVipCardProfitRuleUnitMapping = new VipCardProfitRuleUnitMappingBLL(loggingSessionInfo); var vipCardProfitRuleUnitMapping = bllVipCardProfitRuleUnitMapping.QueryByEntity(new VipCardProfitRuleUnitMappingEntity() { CardBuyToProfitRuleId = ProfitRule.CardBuyToProfitRuleId, UnitID = orderInfo.sales_unit_id, IsDelete = 0, CustomerID = loggingSessionInfo.ClientID }, null).SingleOrDefault(); if (vipCardProfitRuleUnitMapping == null) { continue; } } decimal amount = 0; string strAmountSourceId = string.Empty; string strVipId = string.Empty; string strUserType = string.Empty; if (ProfitRule.ProfitOwner == "Employee") { strAmountSourceId = "37"; strVipId = orderInfo.sales_user; strUserType = "User"; } if (ProfitRule.ProfitOwner == "Unit") { strAmountSourceId = "40"; strVipId = orderInfo.sales_unit_id; strUserType = "Unit"; } amount = (decimal)ProfitRule.FirstCardSalesProfitPct * (decimal)orderInfo.actual_amount * (decimal)0.01; var vipAmountDetail = bllVipAmountDetail.QueryByEntity(new VipAmountDetailEntity() { ObjectId = orderInfo.order_id, AmountSourceId = strAmountSourceId }, null); if (vipAmountDetail != null && vipAmountDetail.Length > 0) { continue; } if (amount > 0) { IDbTransaction tran = new JIT.CPOS.BS.DataAccess.Base.TransactionHelper(loggingSessionInfo).CreateTransaction(); try { // DataRow dr_SplitProfitRecord = dtSplitProfitRecord.NewRow(); // dr_SplitProfitRecord["Id"] = Guid.NewGuid(); // dr_SplitProfitRecord["SourceType"] = "Amount"; // dr_SplitProfitRecord["SourceId"] = strAmountSourceId; // dr_SplitProfitRecord["ObjectId"] = orderInfo.order_id; //dr_SplitProfitRecord["UserType"] = strUserType; // dr_SplitProfitRecord["UserId"] = orderInfo.sales_user; // dr_SplitProfitRecord["SplitAmount"] = amount; // dr_SplitProfitRecord["SplitSattus"] = "10"; // dr_SplitProfitRecord["CustomerId"] = loggingSessionInfo.ClientID; // dr_SplitProfitRecord["CreateTime"] = DateTime.Now; // dr_SplitProfitRecord["CreateBy"] = loggingSessionInfo.ClientID; // dr_SplitProfitRecord["LastUpdateTime"] = DateTime.Now; // dr_SplitProfitRecord["LastUpdateBy"] = loggingSessionInfo.ClientID; // dr_SplitProfitRecord["IsDelete"] = 0; // dtSplitProfitRecord.Rows.Add(dr_SplitProfitRecord); // DataRow dr_AmountDetail = dtAmountDetail.NewRow(); // dr_AmountDetail["VipAmountDetailId"] = Guid.NewGuid(); //dr_AmountDetail["VipId"] = strVipId; // dr_AmountDetail["VipCardCode"] = ""; // dr_AmountDetail["UnitID"] = ""; // dr_AmountDetail["UnitName"] = ""; // dr_AmountDetail["SalesAmount"] = 0; // dr_AmountDetail["Amount"] = amount; // dr_AmountDetail["UsedReturnAmount"] = 0; // dr_AmountDetail["Reason"] = "首次售卡分润"; // dr_AmountDetail["EffectiveDate"] = DateTime.Now; // dr_AmountDetail["DeadlineDate"] = Convert.ToDateTime("9999-12-31 23:59:59"); // dr_AmountDetail["AmountSourceId"] = strAmountSourceId; // dr_AmountDetail["ObjectId"] = orderInfo.order_id; // dr_AmountDetail["Remark"] = "首次售卡分润"; // dr_AmountDetail["IsValid"] = 0; // dr_AmountDetail["IsWithdrawCash"] = 0; // dr_AmountDetail["CustomerID"] = loggingSessionInfo.ClientID; // dr_AmountDetail["CreateTime"] = DateTime.Now; // dr_AmountDetail["CreateBy"] = loggingSessionInfo.ClientID; // dr_AmountDetail["LastUpdateBy"] = loggingSessionInfo.ClientID; // dr_AmountDetail["LastUpdateTime"] = DateTime.Now; // dr_AmountDetail["IsDelete"] = 0; // //dr_AmountDetail["IsCalculated"] = 1; // dtAmountDetail.Rows.Add(dr_AmountDetail); entitySplitProfitRecord = new T_SplitProfitRecordEntity() { ID = Guid.NewGuid().ToString(), SourceType = "Amount", SourceId = strAmountSourceId, ObjectId = orderInfo.order_id, UserType = strUserType, UserId = orderInfo.sales_user, SplitAmount = amount, SplitSattus = "10", CustomerID = loggingSessionInfo.ClientID }; bllSplitProfitRecord.Create(entitySplitProfitRecord, tran); entityVipAmountDetail = new VipAmountDetailEntity { VipAmountDetailId = Guid.NewGuid(), VipId = strVipId, Amount = amount, UsedReturnAmount = 0, EffectiveDate = DateTime.Now, DeadlineDate = Convert.ToDateTime("9999-12-31 23:59:59"), AmountSourceId = strAmountSourceId, ObjectId = orderInfo.order_id, CustomerID = loggingSessionInfo.ClientID, Reason = "首次售卡分润", Remark = "首次售卡分润", IsWithdrawCash = 0 }; bllVipAmountDetail.Create(entityVipAmountDetail, (SqlTransaction)tran); entityVipAmount = bllVipAmount.QueryByEntity(new VipAmountEntity() { VipId = orderInfo.sales_user, IsDelete = 0 }, null).SingleOrDefault(); if (entityVipAmount == null) { //DataRow dr_Amount = dtAmount.NewRow(); //dr_Amount["VipId"] = orderInfo.sales_user; //dr_Amount["VipCardCode"] = ""; //dr_Amount["BeginAmount"] = 0; //dr_Amount["InAmount"] = amount; //dr_Amount["OutAmount"] = 0; //dr_Amount["EndAmount"] = amount; //dr_Amount["TotalAmount"] = amount; //dr_Amount["BeginReturnAmount"] = 0; //dr_Amount["InReturnAmount"] = 0; //dr_Amount["OutReturnAmount"] = 0; //dr_Amount["ReturnAmount"] = 0; //dr_Amount["ImminentInvalidRAmount"] = 0; //dr_Amount["InvalidReturnAmount"] = 0; //dr_Amount["ValidReturnAmount"] = 0; //dr_Amount["TotalReturnAmount"] = 0; //dr_Amount["PayPassword"] = ""; //dr_Amount["IsLocking"] = 0; //dr_Amount["CustomerID"] = loggingSessionInfo.ClientID; //dr_Amount["CreateTime"] = DateTime.Now; //dr_Amount["CreateBy"] = loggingSessionInfo.ClientID; //dr_Amount["LastUpdateBy"] = loggingSessionInfo.ClientID; //dr_Amount["LastUpdateTime"] = DateTime.Now; //dr_Amount["IsDelete"] = 0; //dtAmount.Rows.Add(dr_Amount); entityVipAmount = new VipAmountEntity { VipId = strVipId, BeginAmount = 0, InAmount = amount, OutAmount = 0, EndAmount = amount, TotalAmount = amount, BeginReturnAmount = 0, InReturnAmount = 0, OutReturnAmount = 0, ReturnAmount = 0, ImminentInvalidRAmount = 0, InvalidReturnAmount = 0, ValidReturnAmount = 0, TotalReturnAmount = 0, IsLocking = 0, CustomerID = loggingSessionInfo.ClientID, VipCardCode = "" }; bllVipAmount.Create(entityVipAmount, tran); } else { entityVipAmount.InReturnAmount = (entityVipAmount.InReturnAmount == null ? 0 : entityVipAmount.InReturnAmount.Value) + amount; entityVipAmount.TotalReturnAmount = (entityVipAmount.TotalReturnAmount == null ? 0 : entityVipAmount.TotalReturnAmount.Value) + amount; entityVipAmount.ValidReturnAmount = (entityVipAmount.ValidReturnAmount == null ? 0 : entityVipAmount.ValidReturnAmount.Value) + amount; entityVipAmount.ReturnAmount = (entityVipAmount.ReturnAmount == null ? 0 : entityVipAmount.ReturnAmount.Value) + amount; bllVipAmount.Update(entityVipAmount); } tran.Commit(); } catch (Exception) { tran.Rollback(); throw; } } } } } } } } //if (dtAmount.Rows.Count > 0) //{ // Utils.SqlBulkCopy(connString, dtAmount, "VipAmount"); //} //if (dtAmountDetail.Rows.Count > 0 && dtSplitProfitRecord.Rows.Count > 0) //{ // Utils.SqlBulkCopy(connString, dtSplitProfitRecord, "T_SplitProfitRecord"); // Utils.SqlBulkCopy(connString, dtAmountDetail, "VipAmountDetail"); //} } }
protected override GetEventPrizesRD ProcessRequest(DTO.Base.APIRequest <GetEventPrizesRP> pRequest) { GetEventPrizesRD rd = new GetEventPrizesRD(); //string vipID = pRequest.UserID; //string vipID = "f3d925e364e34bf69dfda34fcedc58f8"; string vipName = string.Empty; string reCommandId = pRequest.Parameters.RecommandId; string eventId = pRequest.Parameters.EventId; float longitude = pRequest.Parameters.Longitude; float latitude = pRequest.Parameters.Latitude; string customerId = this.CurrentUserInfo.ClientID; int pointsLotteryFlag = pRequest.Parameters.PointsLotteryFlag; if (string.IsNullOrEmpty(customerId)) { customerId = "f6a7da3d28f74f2abedfc3ea0cf65c01"; } var loggingSessionInfo = Default.GetBSLoggingSession(customerId, "1"); var leventsBll = new LEventsBLL(this.CurrentUserInfo); var vipService = new VipBLL(loggingSessionInfo); var levents = leventsBll.QueryByEntity(new LEventsEntity() { EventID = eventId }, null); Loggers.Debug(new DebugLogInfo() { Message = string.Format("zk levent==null:{0}", null == levents) }); if (null == levents || levents.Length == 0) { return(rd); } var levent = levents.FirstOrDefault(); rd.IsShare = levent.IsShare == null ? 0 : levent.IsShare.Value; rd.BootUrl = levent.BootURL; rd.PosterImageUrl = levent.PosterImageUrl; rd.ShareLogoUrl = levent.ShareLogoUrl; rd.ShareRemark = levent.ShareRemark; rd.OverRemark = levent.OverRemark; if (string.IsNullOrEmpty(levent.EventFlag)) { rd.SignFlag = 0; } else { if (levent.EventFlag.Substring(0, 1) == "1") { rd.SignFlag = 1; } else { rd.SignFlag = 0; } } Loggers.Debug(new DebugLogInfo() { Message = string.Format("zk levent.BootURL:{0}", levent.BootURL) }); return(rd); }
protected override GetVipCardTypeVirtualItemRD ProcessRequest(DTO.Base.APIRequest <GetVipCardTypeVirtualItemRP> pRequest) { var rd = new GetVipCardTypeVirtualItemRD(); var para = pRequest.Parameters; LoggingSessionInfo loggingSessionInfo = Default.GetBSLoggingSession(pRequest.CustomerID, pRequest.UserID); var vipBLL = new VipBLL(loggingSessionInfo); var vipIntegralBLL = new VipIntegralBLL(loggingSessionInfo); var sysVipCardTypeBLL = new SysVipCardTypeBLL(loggingSessionInfo); var vipCardVipMappingBLL = new VipCardVipMappingBLL(loggingSessionInfo); var vipCardBLL = new VipCardBLL(loggingSessionInfo); var vipCardRuleBLL = new VipCardRuleBLL(loggingSessionInfo); var vipT_InoutBLL = new T_InoutBLL(loggingSessionInfo); List <VipCardUpgradeRewardInfo> VipCardUpgradeRewardList = new List <VipCardUpgradeRewardInfo>(); List <VipCardTypeRelateInfo> VipCardTypeRelateList = new List <VipCardTypeRelateInfo>(); //获取当前会员卡等级 VipEntity VipInfo = null; int? CurVipCardLevel = 0; //处理会员开卡礼信息 var VipCardUpgradeRewardInfoList = sysVipCardTypeBLL.GetCardUpgradeRewardList(loggingSessionInfo.ClientID); //定义卡体系信息 DataSet VipCardTypeSystemInfoList = null; string strVipID = string.Empty; switch (para.ApplicationType) { //为1是微信,为2时表示APP请求 case "1": //微信 strVipID = pRequest.UserID; break; case "2": //APP strVipID = para.VipID; //获取会员信息 break; } VipInfo = vipBLL.GetByID(strVipID);//获取会员信息 if (VipInfo != null) { rd.HeadImgUrl = VipInfo.HeadImgUrl == null ? "" : VipInfo.HeadImgUrl; var vipIntegralInfo = vipIntegralBLL.QueryByEntity(new VipIntegralEntity() { VipID = strVipID, VipCardCode = VipInfo.VipCode }, null).FirstOrDefault(); if (vipIntegralInfo != null)//获取当前会员积分 { rd.Integration = vipIntegralInfo.ValidIntegral != null ? vipIntegralInfo.ValidIntegral.Value : 0; } //获取会员卡等级相关信息 var vipCardMappingInfo = vipCardVipMappingBLL.QueryByEntity(new VipCardVipMappingEntity() { VIPID = strVipID, CustomerID = loggingSessionInfo.ClientID }, new OrderBy[] { new OrderBy() { FieldName = "CreateTime", Direction = OrderByDirections.Desc } }).FirstOrDefault(); if (vipCardMappingInfo != null) { var vipCardInfo = vipCardBLL.QueryByEntity(new VipCardEntity() { VipCardID = vipCardMappingInfo.VipCardID, VipCardStatusId = 1 }, null).FirstOrDefault(); if (vipCardInfo != null) { var vipCardTypeInfo = sysVipCardTypeBLL.QueryByEntity(new SysVipCardTypeEntity() { VipCardTypeID = vipCardInfo.VipCardTypeID }, null).FirstOrDefault(); if (vipCardTypeInfo != null)//获取当前会员卡等级信息 { rd.VipCardTypeName = vipCardTypeInfo.VipCardTypeName != null ? vipCardTypeInfo.VipCardTypeName : ""; rd.VipCardLevel = vipCardTypeInfo.VipCardLevel; CurVipCardLevel = vipCardTypeInfo.VipCardLevel; } } } else { var vipCardTypeInfo = sysVipCardTypeBLL.QueryByEntity(new SysVipCardTypeEntity() { VipCardLevel = 1, CustomerID = loggingSessionInfo.ClientID }, null).FirstOrDefault(); if (vipCardTypeInfo != null) { rd.VipCardTypeName = vipCardTypeInfo.VipCardTypeName != null ? vipCardTypeInfo.VipCardTypeName : ""; rd.VipCardLevel = vipCardTypeInfo.VipCardLevel != null ? vipCardTypeInfo.VipCardLevel : 1; CurVipCardLevel = vipCardTypeInfo.VipCardLevel != null ? vipCardTypeInfo.VipCardLevel : 1; } } //获取会员消费金额 decimal VipConsumptionInfo = vipT_InoutBLL.GetVipSumAmount(strVipID); if (VipConsumptionInfo > 0) { rd.VipConsumptionAmount = Convert.ToDecimal(VipConsumptionInfo).ToString("0.00"); } else { rd.VipConsumptionAmount = "0"; } //获取卡等级相关信息(会员卡等级信息、升级条件、基本权益关联虚拟商品) VipCardTypeSystemInfoList = sysVipCardTypeBLL.GetVipCardTypeVirtualItemList(loggingSessionInfo.ClientID, CurVipCardLevel, para.ApplicationType, VipInfo.VIPID); } if (VipCardTypeSystemInfoList != null && VipCardTypeSystemInfoList.Tables[0].Rows.Count > 0) { int flag = 0;//定义下面开卡礼能否进行展示(0=不进,1=进) if (VipCardUpgradeRewardInfoList != null && VipCardUpgradeRewardInfoList.Tables[0].Rows.Count > 0) { flag = 1; //获取开卡礼信息 为之后筛选数据使用 VipCardUpgradeRewardList = DataTableToObject.ConvertToList <VipCardUpgradeRewardInfo>(VipCardUpgradeRewardInfoList.Tables[0]); } var dt = VipCardTypeSystemInfoList.Tables[0]; foreach (DataRow dr in dt.Rows) { var DataInfo = new VipCardTypeRelateInfo(); //VipCardTypeRelateList = new List<VipCardTypeRelateInfo>(); DataInfo.VipCardType = new VipCardTypeInfo(); //会员卡体系 DataInfo.VipCardUpgradeRule = new VipCardUpgradeRuleInfo(); //会员卡升级规则 DataInfo.VipCardRule = new VipCardRuleInfo(); //会员卡基本体系 DataInfo.VipCardUpgradeRewardList = new List <VipCardUpgradeRewardInfo>(); //var VipCardTypeData = new VipCardTypeInfo(); //给会员卡等级赋值 DataInfo.VipCardType.VipCardTypeID = Convert.ToInt32(dr["VipCardTypeID"]); DataInfo.VipCardType.VipCardLevel = Convert.ToInt32(dr["VipCardLevel"]); DataInfo.VipCardType.VipCardTypeName = dr["VipCardTypeName"].ToString(); DataInfo.VipCardType.PicUrl = dr["PicUrl"].ToString(); DataInfo.VipCardType.IsPrepaid = Convert.ToInt32(dr["IsPrepaid"]); DataInfo.VipCardType.IsOnlineSales = Convert.ToInt32(dr["IsOnlineSales"]); DataInfo.VipCardType.ItemID = dr["ItemID"].ToString(); DataInfo.VipCardType.SkuID = dr["SkuID"].ToString(); int cardStatus = 0; //获取卡状态购买信息 0=没购买,1=已购买 pRequest.UserID if (DataInfo.VipCardType.IsPrepaid != 1)//非可储值类型关联订单 { cardStatus = vipT_InoutBLL.GetVirtualItemStatus(loggingSessionInfo.ClientID, strVipID, DataInfo.VipCardType.SkuID); } else//可储值类型关联充值订单 { var RechargeOrderBll = new RechargeOrderBLL(loggingSessionInfo); var RechargeOrderInfo = RechargeOrderBll.QueryByEntity(new RechargeOrderEntity() { OrderDesc = "Upgrade", VipID = strVipID, VipCardTypeId = DataInfo.VipCardType.VipCardTypeID, Status = 1 }, null).FirstOrDefault(); if (RechargeOrderInfo != null)//如果为空需要在订单表里查找下记录 { cardStatus = 1; } else { cardStatus = vipT_InoutBLL.GetVirtualItemStatus(loggingSessionInfo.ClientID, strVipID, DataInfo.VipCardType.SkuID); } } DataInfo.VipCardType.Status = cardStatus; //var VipCardUpgradeRuleData = new VipCardUpgradeRuleInfo(); DataInfo.VipCardUpgradeRule.VipCardTypeID = Convert.ToInt32(dr["VipCardTypeID"]); DataInfo.VipCardUpgradeRule.VipCardUpgradeRuleId = dr["VipCardUpgradeRuleId"].ToString(); DataInfo.VipCardUpgradeRule.IsPurchaseUpgrade = Convert.ToInt32(dr["IsPurchaseUpgrade"]); DataInfo.VipCardUpgradeRule.IsExtraMoney = Convert.ToInt32(dr["IsExtraMoney"]); DataInfo.VipCardUpgradeRule.Prices = Convert.ToDecimal(dr["Prices"]); DataInfo.VipCardUpgradeRule.ExchangeIntegral = Convert.ToInt32(dr["ExchangeIntegral"]); DataInfo.VipCardUpgradeRule.IsRecharge = Convert.ToInt32(dr["IsRecharge"]); DataInfo.VipCardUpgradeRule.OnceRechargeAmount = Convert.ToDecimal(dr["OnceRechargeAmount"]); DataInfo.VipCardUpgradeRule.IsBuyUpgrade = Convert.ToInt32(dr["IsBuyUpgrade"]); DataInfo.VipCardUpgradeRule.BuyAmount = Convert.ToDecimal(dr["BuyAmount"]); DataInfo.VipCardUpgradeRule.OnceBuyAmount = Convert.ToDecimal(dr["OnceBuyAmount"]); //var VipCardRuleData = new VipCardUpgradeRuleInfo(); DataInfo.VipCardRule.VipCardTypeID = Convert.ToInt32(dr["VipCardTypeID"]); DataInfo.VipCardRule.RuleID = Convert.ToInt32(dr["RuleID"]); DataInfo.VipCardRule.CardDiscount = Convert.ToDecimal(dr["CardDiscount"]); DataInfo.VipCardRule.PaidGivePercetPoints = Convert.ToDecimal(dr["PaidGivePercetPoints"]); DataInfo.VipCardRule.PaidGivePoints = Convert.ToDecimal(dr["PaidGivePoints"]); if (flag == 1)//当flag=1的时候进行开卡礼的展示 { DataInfo.VipCardUpgradeRewardList = VipCardUpgradeRewardList.Where(m => m.VipCardTypeID == Convert.ToInt32(dr["VipCardTypeID"])).Select( t => new VipCardUpgradeRewardInfo() { CardUpgradeRewardId = t.CardUpgradeRewardId, VipCardTypeID = t.VipCardTypeID, CouponTypeID = t.CouponTypeID, CouponNum = t.CouponNum, CouponName = t.CouponName, ValidityPeriod = t.BeginTime == null ? ("领取后" + (t.ServiceLife == 0 ? "1天内有效" : t.ServiceLife.ToString() + "天内有效")) : (t.BeginTime.Value.ToString("yyyy-MM-dd") + "至" + t.EndTime.Value.ToString("yyyy-MM-dd")), BeginTime = t.BeginTime, EndTime = t.EndTime, BeginTimeDate = t.BeginTime == null ? "" : t.BeginTime.Value.ToString("yyyy年MM月dd日"), EndTimeDate = t.EndTime == null ? "" : t.EndTime.Value.ToString("yyyy年MM月dd日"), ServiceLife = t.ServiceLife, CouponDesc = t.CouponDesc, ParValue = t.ParValue }).ToList(); } VipCardTypeRelateList.Add(DataInfo); } rd.VipCardTypeItemList = VipCardTypeRelateList; } return(rd); }
protected override GetVipListRD ProcessRequest(DTO.Base.APIRequest <GetVipListRP> pRequest) { var rd = new GetVipListRD(); var para = pRequest.Parameters; var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo; var vipBLL = new VipBLL(loggingSessionInfo); var unitBLL = new t_unitBLL(loggingSessionInfo); int type = 0; //是否有条件查询 //条件参数 List <IWhereCondition> complexCondition = new List <IWhereCondition> { }; //条件查询,支持跨门店 if (!string.IsNullOrWhiteSpace(para.VipCardCode) || !string.IsNullOrWhiteSpace(para.VipName) || !string.IsNullOrWhiteSpace(para.Phone)) { //跨门店查询 if (!string.IsNullOrEmpty(para.VipCardCode)) { if (para.VipTypeID == 1) { complexCondition.Add(new DirectCondition("vc.VipCardISN='" + para.VipCardCode + "' ")); } else { complexCondition.Add(new DirectCondition("( vc.VipCardCode like '" + para.VipCardCode + "%' OR v.VipCode like '" + para.VipCardCode + "%')")); } } if (!string.IsNullOrEmpty(para.VipName)) { complexCondition.Add(new DirectCondition("(v.VipName like '" + para.VipName + "%' OR v.VipRealName like '" + para.VipName + "%')")); } if (!string.IsNullOrEmpty(para.Phone)) { complexCondition.Add(new DirectCondition("v.Phone like '" + para.Phone + "%' ")); } type = 1; }//默认查询,不支持跨门店 //else //{ ////门店对象 //t_unitEntity unitData = unitBLL.GetByID(loggingSessionInfo.CurrentUserRole.UnitId); //string type_id = unitData == null ? "" : unitData.type_id; ////总部 //if (type_id != "2F35F85CF7FF4DF087188A7FB05DED1D") //complexCondition.Add(new LikeCondition() { FieldName = "ul.dst_unit_id", Value = "%" + loggingSessionInfo.CurrentUserRole.UnitId + "%" }); //} complexCondition.Add(new EqualsCondition() { FieldName = "v.ClientID", Value = loggingSessionInfo.ClientID }); //排序参数 List <OrderBy> lstOrder = new List <OrderBy> { }; lstOrder.Add(new OrderBy() { FieldName = "v.CreateTime", Direction = OrderByDirections.Desc }); //调用会员卡管理列表查询 var tempList = vipBLL.GetVipList(complexCondition.ToArray(), lstOrder.ToArray(), type, para.PageSize, para.PageIndex); rd.TotalPageCount = tempList.PageCount; rd.TotalCount = tempList.RowCount; rd.VipInfoList = tempList.Entities.Select(t => new VipInfo() { VipCardID = t.VipCardID, VIPID = t.VIPID, VipCode = t.VipCode, VipCardCode = t.VipCardCode == null ? t.VipCode : t.VipCardCode, VipName = t.VipName ?? "", VipRealName = t.VipRealName ?? "", Phone = t.Phone, Gender = t.Gender, VipCardTypeName = t.VipCardTypeName, VipCardStatusId = t.VipCardStatusId, MembershipTime = t.CreateTime.Value.ToString("yyyy-MM-dd HH:mm"), MembershipUnitName = t.UnitName == null ? "" : t.UnitName }).ToList(); return(rd); }
protected override VipBirthdayRD ProcessRequest(DTO.Base.APIRequest <VipBirthdayRP> pRequest) { var rd = new VipBirthdayRD(); var para = pRequest.Parameters; var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo; var VipBLL = new VipBLL(loggingSessionInfo); try { if (para.Consumption < 0) { throw new APIException("最近消费参数异常!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS } } ; } catch (APIException apiEx) { throw new APIException(apiEx.ErrorCode, apiEx.Message); } string StarDate = null; string EndDate = null; if (para.Consumption == 0) { DateTime Now = DateTime.Now; StarDate = Now.AddMonths(-para.Consumption).Date.ToString(); EndDate = Now.Date.ToString(); } //int? CardStatus = null; //if (para.VipCardStatusID != null) //{ // CardStatus = para.VipCardStatusID.Value; //} DataSet ds = VipBLL.GetVipBirthdayCount(para.Month, para.UnitID, para.Gender, para.VipCardStatusID, StarDate, EndDate, para.PageSize, para.PageIndex); //ExcelHelper m_Test = new ExcelHelper("D:\\ExportTest.xlsx"); //m_Test.DataTableToExcel(ds.Tables[0], "Sheet1", true); #region 赋值 if (ds != null && ds.Tables[0].Rows.Count > 0) { rd = new VipBirthdayRD(); rd.VipBirthdayInfoList = new List <VipBirthdayInfo>(); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { VipBirthdayInfo m = new VipBirthdayInfo(); if (ds.Tables[0].Rows[i]["VipCardCode"] != DBNull.Value) { m.VipCardCode = ds.Tables[0].Rows[i]["VipCardCode"].ToString(); } if (ds.Tables[0].Rows[i]["VipCardTypeName"] != DBNull.Value) { m.VipCardTypeName = ds.Tables[0].Rows[i]["VipCardTypeName"].ToString(); } if (ds.Tables[0].Rows[i]["VipCardStatusId"] != DBNull.Value) { m.VipCardStatusId = int.Parse(ds.Tables[0].Rows[i]["VipCardStatusId"].ToString()); } if (ds.Tables[0].Rows[i]["VipName"] != DBNull.Value) { m.VipName = ds.Tables[0].Rows[i]["VipName"].ToString(); } if (ds.Tables[0].Rows[i]["Phone"] != DBNull.Value) { m.Phone = ds.Tables[0].Rows[i]["Phone"].ToString(); } if (ds.Tables[0].Rows[i]["Gender"] != DBNull.Value) { m.Gender = ds.Tables[0].Rows[i]["Gender"].ToString(); } if (ds.Tables[0].Rows[i]["Birthday"] != DBNull.Value) { m.Birthday = Convert.ToDateTime(ds.Tables[0].Rows[i]["Birthday"]).ToString("MM-dd"); } if (ds.Tables[0].Rows[i]["MembershipUnit"] != DBNull.Value) { m.MembershipUnit = ds.Tables[0].Rows[i]["MembershipUnit"].ToString(); } if (ds.Tables[0].Rows[i]["unit_name"] != DBNull.Value) { m.MembershipUnitName = ds.Tables[0].Rows[i]["unit_name"].ToString(); } if (ds.Tables[0].Rows[i]["MembershipTime"] != DBNull.Value) { m.MembershipTime = Convert.ToDateTime(ds.Tables[0].Rows[i]["MembershipTime"]).ToString("yyyy-MM-dd"); } //最近消费 m.SpendingDateShow = "近月" + para.Consumption.ToString() + "消费"; rd.VipBirthdayInfoList.Add(m); } if (ds.Tables[1].Rows.Count > 0) { for (int j = 0; j < ds.Tables[1].Rows.Count; j++) { rd.TotalCount = int.Parse(ds.Tables[1].Rows[j]["totalrow"].ToString()); rd.TotalPageCount = int.Parse(ds.Tables[1].Rows[j]["totalpage"].ToString());; } } } #endregion if (rd == null) { rd = new VipBirthdayRD(); } return(rd); }
protected override SetVipCardRD ProcessRequest(DTO.Base.APIRequest <SetVipCardRP> pRequest) { var rd = new SetVipCardRD(); var para = pRequest.Parameters; var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo; #region 业务对象 //会员卡 var VipCardBLL = new VipCardBLL(loggingSessionInfo); //余额变动记录 var VipCardBalanceChangeBLL = new VipCardBalanceChangeBLL(loggingSessionInfo); //卡状态变更记录 var VipCardStatusChangeLogBLL = new VipCardStatusChangeLogBLL(loggingSessionInfo); //卡关系 var VipCardVipMappingBLL = new VipCardVipMappingBLL(loggingSessionInfo); //图片 var objectImagesBLL = new ObjectImagesBLL(loggingSessionInfo); //会员 var VipBLL = new VipBLL(loggingSessionInfo); var vipCardTransLogBLL = new VipCardTransLogBLL(loggingSessionInfo); //丰收日交易记录对象示例化 var unitBLL = new TUnitBLL(loggingSessionInfo); //门店业务对象 //事务 var pTran = VipCardBLL.GetTran(); #endregion using (pTran.Connection) { try { if (string.IsNullOrWhiteSpace(para.VipCardID) || para.OperationType <= 0) { throw new APIException("卡ID或者操作类型参数不合法!") { ErrorCode = ERROR_CODES.INVALID_REQUEST_LACK_REQUEST_PARAMETER }; } //定位当前卡业务对象 VipCardEntity changeEntity = VipCardBLL.GetByID(para.VipCardID); if (changeEntity == null) { throw new APIException("当前卡信息对象为NULL!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS }; } #region 返回卡ID rd.VipCardID = changeEntity.VipCardID; #endregion changeEntity.RechargeTotalAmount = changeEntity.RechargeTotalAmount ?? 0; changeEntity.BalanceAmount = changeEntity.BalanceAmount ?? 0; string OldVipCardCode = changeEntity.VipCardCode ?? ""; //原卡号 string NewVipCardCode = ""; //新卡号,获取新卡赋值 decimal OldMoney = changeEntity.BalanceAmount.Value; //原卡当前余额 decimal NewMoney = changeEntity.BalanceAmount.Value + para.BalanceMoney; //原卡当余额+调整金额 //原卡会员映射关系 VipCardVipMappingEntity OldVipCardVipMappingData = VipCardVipMappingBLL.QueryByEntity(new VipCardVipMappingEntity() { VipCardID = para.VipCardID }, null).FirstOrDefault(); if (OldVipCardVipMappingData == null) { throw new APIException("原卡会员关系映射对象为NULL!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS }; } //门店Entity var UnitData = unitBLL.GetByID(loggingSessionInfo.CurrentUserRole.UnitId); //会员 VipEntity VipData = VipBLL.GetByID(OldVipCardVipMappingData.VIPID); #region 卡状态记录对象 VipCardStatusChangeLogEntity AddVCStatusEntity = new VipCardStatusChangeLogEntity(); AddVCStatusEntity.LogID = System.Guid.NewGuid().ToString(); AddVCStatusEntity.VipCardID = para.VipCardID; AddVCStatusEntity.Reason = para.ChangeReason; AddVCStatusEntity.OldStatusID = changeEntity.VipCardStatusId; AddVCStatusEntity.CustomerID = loggingSessionInfo.ClientID; AddVCStatusEntity.Remark = para.Remark; AddVCStatusEntity.UnitID = loggingSessionInfo.CurrentUserRole.UnitId; #endregion #region 新卡 VipCardEntity NewChangeVipCardData = new VipCardEntity(); if (!string.IsNullOrWhiteSpace(para.NewCardCode)) { //查询参数 List <IWhereCondition> complexCondition = new List <IWhereCondition> { }; if (!string.IsNullOrEmpty(para.NewCardCode)) { complexCondition.Add(new DirectCondition("VipCardCode='" + para.NewCardCode + "' or VipCardISN='" + para.NewCardCode.ToString() + "' ")); } //新卡对象 NewChangeVipCardData = VipCardBLL.Query(complexCondition.ToArray(), null).FirstOrDefault(); if (NewChangeVipCardData == null) { throw new APIException("新卡不存在!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS }; } //新卡号赋值 NewVipCardCode = NewChangeVipCardData.VipCardCode ?? ""; //新卡数据赋值 NewChangeVipCardData.VipCardGradeID = changeEntity.VipCardGradeID; NewChangeVipCardData.BatchNo = changeEntity.BatchNo; NewChangeVipCardData.BeginDate = changeEntity.BeginDate; NewChangeVipCardData.EndDate = changeEntity.EndDate; NewChangeVipCardData.TotalAmount = changeEntity.TotalAmount == null ? 0 : changeEntity.TotalAmount.Value; NewChangeVipCardData.BalanceAmount = changeEntity.BalanceAmount == null ? 0 : changeEntity.BalanceAmount.Value; NewChangeVipCardData.BalancePoints = changeEntity.BalancePoints == null ? 0 : changeEntity.BalancePoints.Value; NewChangeVipCardData.BalanceBonus = changeEntity.BalanceBonus == null ? 0 : changeEntity.BalanceBonus.Value; NewChangeVipCardData.CumulativeBonus = changeEntity.CumulativeBonus == null ? 0 : changeEntity.CumulativeBonus.Value; NewChangeVipCardData.PurchaseTotalAmount = changeEntity.PurchaseTotalAmount == null ? 0 : changeEntity.PurchaseTotalAmount.Value; NewChangeVipCardData.PurchaseTotalCount = changeEntity.PurchaseTotalCount == null ? 0 : changeEntity.PurchaseTotalCount.Value; NewChangeVipCardData.CheckCode = changeEntity.CheckCode; NewChangeVipCardData.SingleTransLimit = changeEntity.SingleTransLimit == null ? 0 : changeEntity.SingleTransLimit.Value; NewChangeVipCardData.IsOverrunValid = changeEntity.IsOverrunValid == null ? 0 : changeEntity.IsOverrunValid.Value; NewChangeVipCardData.RechargeTotalAmount = changeEntity.RechargeTotalAmount == null ? 0 : changeEntity.RechargeTotalAmount.Value; NewChangeVipCardData.LastSalesTime = changeEntity.LastSalesTime; NewChangeVipCardData.IsGift = changeEntity.IsGift == null ? 0 : changeEntity.IsGift.Value; NewChangeVipCardData.SalesAmount = changeEntity.SalesAmount; NewChangeVipCardData.SalesUserId = changeEntity.SalesUserId; NewChangeVipCardData.CustomerID = changeEntity.CustomerID; NewChangeVipCardData.MembershipTime = changeEntity.MembershipTime; NewChangeVipCardData.SalesUserName = changeEntity.SalesUserName == null ? "" : changeEntity.SalesUserName; NewChangeVipCardData.CreateBy = changeEntity.CreateBy; } #endregion switch (para.OperationType) { case 1: #region 调整卡余额 //卡更新 //卡内总金额 if (para.BalanceMoney > 0) { changeEntity.RechargeTotalAmount += para.BalanceMoney; if (changeEntity.RechargeTotalAmount < 0) { throw new APIException("调整后的余额小于0!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS }; } } //changeEntity.BalanceAmount = changeEntity.BalanceAmount ?? 0; // changeEntity.BalanceAmount = NewMoney; //执行更新 VipCardBLL.Update(changeEntity, pTran); //新增余额变动记录 VipCardBalanceChangeEntity AddEntity = new VipCardBalanceChangeEntity(); AddEntity.ChangeID = System.Guid.NewGuid().ToString(); AddEntity.VipCardCode = changeEntity.VipCardCode; AddEntity.ChangeAmount = para.BalanceMoney; //变动前卡内余额 AddEntity.ChangeBeforeBalance = OldMoney; //变动后卡内余额 AddEntity.ChangeAfterBalance = NewMoney; AddEntity.ChangeReason = para.ChangeReason; AddEntity.Status = 1; AddEntity.Remark = para.Remark; AddEntity.CustomerID = loggingSessionInfo.ClientID; AddEntity.UnitID = loggingSessionInfo.CurrentUserRole.UnitId; //执行新增 VipCardBalanceChangeBLL.Create(AddEntity, pTran); //增加图片上传 if (!string.IsNullOrEmpty(para.ImageUrl)) { var objectImagesEntity = new ObjectImagesEntity() { ImageId = Guid.NewGuid().ToString(), ObjectId = AddEntity.ChangeID, ImageURL = para.ImageUrl }; objectImagesBLL.Create(objectImagesEntity, pTran); } #region 充值记录 //读取最近一次积分变更记录 List <OrderBy> lstOrder = new List <OrderBy> { }; //排序参数 lstOrder.Add(new OrderBy() { FieldName = "TransTime", Direction = OrderByDirections.Desc }); var transLogInfo = vipCardTransLogBLL.QueryByEntity(new VipCardTransLogEntity() { VipCardCode = changeEntity.VipCardCode, TransType = "C" }, lstOrder.ToArray()).FirstOrDefault(); //期末积分 int newValue = transLogInfo != null ? (transLogInfo.NewValue ?? 0) : 0; var vipCardTransLogEntity = new VipCardTransLogEntity() { VipCardCode = VipData == null ? "" : VipData.VipCode, UnitCode = UnitData == null ? "" : UnitData.UnitCode, TransContent = "余额", TransType = "C", TransTime = DateTime.Now, TransAmount = para.BalanceMoney, LastValue = newValue, //期初金额 NewValue = Convert.ToInt32(para.BalanceMoney) + newValue, //期末金额 CustomerID = loggingSessionInfo.ClientID }; vipCardTransLogBLL.Create(vipCardTransLogEntity, pTran); #endregion #endregion break; case 2: #region 卡升级 //卡类型升级 if (para.VipCardTypeId != 0) { VipCardVipMappingBLL.updateVipCardByType(VipData.VIPID, para.VipCardTypeId, para.ChangeReason, para.Remark, VipData.VipCode, pTran); } //卡号升级 else { #region 原卡 #region 更新原卡 changeEntity.VipCardStatusId = 3; //当前月,累计金额清0 //changeEntity.BalanceAmount = 0; //changeEntity.TotalAmount = 0; VipCardBLL.Update(changeEntity, pTran); //执行 #endregion #region 新增原卡状态记录 AddVCStatusEntity.VipCardStatusID = 3; AddVCStatusEntity.Action = "卡升级"; AddVCStatusEntity.Remark += "已升级为:" + NewChangeVipCardData.VipCardCode; VipCardStatusChangeLogBLL.Create(AddVCStatusEntity, pTran); //执行 #endregion #region 新增原卡余额变动记录 //if (OldMoney > 0) //{ // VipCardBalanceChangeEntity AddOldCardBalanceData = new VipCardBalanceChangeEntity(); // AddOldCardBalanceData.ChangeID = System.Guid.NewGuid().ToString(); // AddOldCardBalanceData.VipCardCode = changeEntity.VipCardCode; // AddOldCardBalanceData.ChangeAmount = -OldMoney; // //变动前卡内余额 // AddOldCardBalanceData.ChangeBeforeBalance = OldMoney; // //变动后卡内余额 // AddOldCardBalanceData.ChangeAfterBalance = 0; // AddOldCardBalanceData.ChangeReason = para.ChangeReason; // AddOldCardBalanceData.Status = 1; // AddOldCardBalanceData.Remark = para.Remark; // AddOldCardBalanceData.CustomerID = loggingSessionInfo.ClientID; // AddOldCardBalanceData.UnitID = loggingSessionInfo.CurrentUserRole.UnitId; // VipCardBalanceChangeBLL.Create(AddOldCardBalanceData, pTran);//执行 // //增加图片上传 // if (!string.IsNullOrEmpty(para.ImageUrl)) // { // var objectImagesEntity = new ObjectImagesEntity() // { // ImageId = Guid.NewGuid().ToString(), // ObjectId = AddOldCardBalanceData.ChangeID, // ImageURL = para.ImageUrl // }; // objectImagesBLL.Create(objectImagesEntity, pTran); // } //} #endregion #endregion #region 新卡 VipData.VipCode = para.NewCardCode; VipBLL.Update(VipData, pTran); #region 更新新卡 if (!string.IsNullOrEmpty(NewChangeVipCardData.MembershipUnit)) { throw new APIException("该会员卡已绑定会员!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS } } ; if (NewChangeVipCardData.VipCardStatusId != 0) { throw new APIException("该会员卡已激活!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS } } ; if (NewChangeVipCardData.VipCardTypeID.Value == changeEntity.VipCardTypeID.Value) { throw new APIException("该卡号与原卡等级相同,请更换卡号后重新尝试!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS } } ; #region 返回新卡卡ID rd.VipCardID = NewChangeVipCardData.VipCardID; #endregion NewChangeVipCardData.MembershipUnit = changeEntity.MembershipUnit; NewChangeVipCardData.VipCardStatusId = 1; VipCardBLL.Update(NewChangeVipCardData, pTran); //执行 #endregion #region 新增新卡卡关系 VipCardVipMappingEntity AddVipCardVipMappingData = new VipCardVipMappingEntity(); AddVipCardVipMappingData.MappingID = System.Guid.NewGuid().ToString(); AddVipCardVipMappingData.VIPID = OldVipCardVipMappingData.VIPID; AddVipCardVipMappingData.VipCardID = NewChangeVipCardData.VipCardID; AddVipCardVipMappingData.CustomerID = loggingSessionInfo.ClientID; VipCardVipMappingBLL.Create(AddVipCardVipMappingData, pTran); //执行 #endregion #region 更新会员编号 //VipEntity SJ_VipData = VipBLL.GetByID(OldVipCardVipMappingData.VIPID); //if (VipData == null) // throw new APIException("会员不存在!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS }; //VipData.VipCode = NewChangeVipCardData.VipCardCode; //VipBLL.Update(VipData, pTran);//执行 #endregion #region 新增新卡状态记录 //新增新卡状态记录 VipCardStatusChangeLogEntity AddNewVCStatusEntity = new VipCardStatusChangeLogEntity(); AddNewVCStatusEntity.LogID = System.Guid.NewGuid().ToString(); AddNewVCStatusEntity.VipCardID = NewChangeVipCardData.VipCardID; AddNewVCStatusEntity.VipCardStatusID = 1; AddNewVCStatusEntity.Reason = para.ChangeReason; AddNewVCStatusEntity.OldStatusID = 0; AddNewVCStatusEntity.CustomerID = loggingSessionInfo.ClientID; AddNewVCStatusEntity.Action = "卡升级"; AddNewVCStatusEntity.Remark = para.Remark + "由旧卡:" + changeEntity.VipCardCode + "升级"; AddNewVCStatusEntity.UnitID = loggingSessionInfo.CurrentUserRole.UnitId; VipCardStatusChangeLogBLL.Create(AddNewVCStatusEntity, pTran); //执行 #endregion #region 新增新卡余额记录 //新增余额记录 //if (OldMoney > 0) //{ // VipCardBalanceChangeEntity AddNewCardBalanceData = new VipCardBalanceChangeEntity(); // AddNewCardBalanceData.ChangeID = System.Guid.NewGuid().ToString(); // AddNewCardBalanceData.VipCardCode = NewChangeVipCardData.VipCardCode; // AddNewCardBalanceData.ChangeAmount = OldMoney; // //变动前卡内余额 // AddNewCardBalanceData.ChangeBeforeBalance = 0; // //变动后卡内余额 // AddNewCardBalanceData.ChangeAfterBalance = NewChangeVipCardData.BalanceAmount == null ? 0 : NewChangeVipCardData.BalanceAmount.Value; // AddNewCardBalanceData.ChangeReason = para.ChangeReason; // AddNewCardBalanceData.Status = 1; // AddNewCardBalanceData.Remark = para.Remark; // AddNewCardBalanceData.CustomerID = loggingSessionInfo.ClientID; // VipCardBalanceChangeBLL.Create(AddNewCardBalanceData, pTran);//执行 // //增加图片上传 // if (!string.IsNullOrEmpty(para.ImageUrl)) // { // var objectImagesEntity = new ObjectImagesEntity() // { // ImageId = Guid.NewGuid().ToString(), // ObjectId = AddNewCardBalanceData.ChangeID, // ImageURL = para.ImageUrl // }; // objectImagesBLL.Create(objectImagesEntity, pTran); // } //} #endregion #endregion } #endregion break; case 3: #region 挂失 changeEntity.VipCardStatusId = 4; //执行更新 VipCardBLL.Update(changeEntity, pTran); //执行 AddVCStatusEntity.VipCardStatusID = 4; AddVCStatusEntity.PicUrl = para.ImageUrl; AddVCStatusEntity.Action = "挂失"; VipCardStatusChangeLogBLL.Create(AddVCStatusEntity, pTran); #endregion break; case 4: #region 冻结 changeEntity.VipCardStatusId = 2; //执行更新 VipCardBLL.Update(changeEntity, pTran); //执行新增 AddVCStatusEntity.VipCardStatusID = 2; AddVCStatusEntity.Action = "冻结"; VipCardStatusChangeLogBLL.Create(AddVCStatusEntity, pTran); #endregion break; case 5: #region 转卡 #region 原卡 #region 更新原卡 changeEntity.VipCardStatusId = 3; //当前月,累计金额清0 changeEntity.BalanceAmount = 0; changeEntity.TotalAmount = 0; VipCardBLL.Update(changeEntity, pTran); //执行 #endregion #region 新增原卡状态记录 AddVCStatusEntity.VipCardStatusID = 3; AddVCStatusEntity.Action = "转卡"; AddVCStatusEntity.Remark += "已转移为:" + NewChangeVipCardData.VipCardCode; VipCardStatusChangeLogBLL.Create(AddVCStatusEntity, pTran); //执行 #endregion #region 新增原卡余额变动记录 if (OldMoney > 0) { VipCardBalanceChangeEntity AddOldZKCardBalanceData = new VipCardBalanceChangeEntity(); AddOldZKCardBalanceData.ChangeID = System.Guid.NewGuid().ToString(); AddOldZKCardBalanceData.VipCardCode = changeEntity.VipCardCode; AddOldZKCardBalanceData.ChangeAmount = -OldMoney; //变动前卡内余额 AddOldZKCardBalanceData.ChangeBeforeBalance = OldMoney; //变动后卡内余额 AddOldZKCardBalanceData.ChangeAfterBalance = 0; AddOldZKCardBalanceData.ChangeReason = para.ChangeReason; AddOldZKCardBalanceData.Status = 1; AddOldZKCardBalanceData.Remark = para.Remark; AddOldZKCardBalanceData.CustomerID = loggingSessionInfo.ClientID; AddOldZKCardBalanceData.UnitID = loggingSessionInfo.CurrentUserRole.UnitId; VipCardBalanceChangeBLL.Create(AddOldZKCardBalanceData, pTran); //执行 //增加图片上传 if (!string.IsNullOrEmpty(para.ImageUrl)) { var objectImagesEntity = new ObjectImagesEntity() { ImageId = Guid.NewGuid().ToString(), ObjectId = AddOldZKCardBalanceData.ChangeID, ImageURL = para.ImageUrl }; objectImagesBLL.Create(objectImagesEntity, pTran); } } #endregion #endregion #region 新卡 #region 更新新卡 if (!string.IsNullOrEmpty(NewChangeVipCardData.MembershipUnit)) { throw new APIException("该会员卡已绑定会员!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS } } ; if (NewChangeVipCardData.VipCardStatusId != 0) { throw new APIException("该会员卡已激活!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS } } ; if (NewChangeVipCardData.VipCardTypeID.Value != changeEntity.VipCardTypeID.Value) { throw new APIException("该卡号与原卡等级不同,请更换卡号后重新尝试!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS } } ; #region 返回新卡卡ID rd.VipCardID = NewChangeVipCardData.VipCardID; #endregion NewChangeVipCardData.MembershipUnit = changeEntity.MembershipUnit; NewChangeVipCardData.VipCardStatusId = 1; VipCardBLL.Update(NewChangeVipCardData, pTran); //执行 #endregion #region 新增新卡卡关系 VipCardVipMappingEntity AddZKVipCardVipMappingData = new VipCardVipMappingEntity(); AddZKVipCardVipMappingData.MappingID = System.Guid.NewGuid().ToString(); AddZKVipCardVipMappingData.VIPID = OldVipCardVipMappingData.VIPID; AddZKVipCardVipMappingData.VipCardID = NewChangeVipCardData.VipCardID; AddZKVipCardVipMappingData.CustomerID = loggingSessionInfo.ClientID; VipCardVipMappingBLL.Create(AddZKVipCardVipMappingData, pTran); //执行 #endregion #region 更新会员编号 //VipEntity ZK_VipData = VipBLL.GetByID(OldVipCardVipMappingData.VIPID); if (VipData == null) { throw new APIException("会员不存在!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS } } ; VipData.VipCode = NewChangeVipCardData.VipCardCode; VipBLL.Update(VipData, pTran); //执行 #endregion #region 新增新卡状态记录 VipCardStatusChangeLogEntity AddNewZKVCStatusEntity = new VipCardStatusChangeLogEntity(); AddNewZKVCStatusEntity.LogID = System.Guid.NewGuid().ToString(); AddNewZKVCStatusEntity.VipCardID = NewChangeVipCardData.VipCardID; AddNewZKVCStatusEntity.VipCardStatusID = 1; AddNewZKVCStatusEntity.Reason = para.ChangeReason; AddNewZKVCStatusEntity.OldStatusID = 0; AddNewZKVCStatusEntity.CustomerID = loggingSessionInfo.ClientID; AddNewZKVCStatusEntity.Action = "转卡"; AddNewZKVCStatusEntity.Remark = para.Remark + para.Remark + "由旧卡:" + changeEntity.VipCardCode + "转移"; AddNewZKVCStatusEntity.UnitID = loggingSessionInfo.CurrentUserRole.UnitId; VipCardStatusChangeLogBLL.Create(AddNewZKVCStatusEntity, pTran); //执行 #endregion #region 新增新卡余额记录 if (OldMoney > 0) { VipCardBalanceChangeEntity AddNewZKCardBalanceData = new VipCardBalanceChangeEntity(); AddNewZKCardBalanceData.ChangeID = System.Guid.NewGuid().ToString(); AddNewZKCardBalanceData.VipCardCode = NewChangeVipCardData.VipCardCode; AddNewZKCardBalanceData.ChangeAmount = OldMoney; //变动前卡内余额 AddNewZKCardBalanceData.ChangeBeforeBalance = 0; //变动后卡内余额 AddNewZKCardBalanceData.ChangeAfterBalance = NewChangeVipCardData.BalanceAmount == null ? 0 : NewChangeVipCardData.BalanceAmount.Value; AddNewZKCardBalanceData.ChangeReason = para.ChangeReason; AddNewZKCardBalanceData.Status = 1; AddNewZKCardBalanceData.Remark = para.Remark; AddNewZKCardBalanceData.CustomerID = loggingSessionInfo.ClientID; AddNewZKCardBalanceData.UnitID = loggingSessionInfo.CurrentUserRole.UnitId; VipCardBalanceChangeBLL.Create(AddNewZKCardBalanceData, pTran); //执行 //增加图片上传 if (!string.IsNullOrEmpty(para.ImageUrl)) { var objectImagesEntity = new ObjectImagesEntity() { ImageId = Guid.NewGuid().ToString(), ObjectId = AddNewZKCardBalanceData.ChangeID, ImageURL = para.ImageUrl }; objectImagesBLL.Create(objectImagesEntity, pTran); } } #endregion #endregion #endregion break; case 6: #region 解挂 changeEntity.VipCardStatusId = 1; //执行更新 VipCardBLL.Update(changeEntity, pTran); //执行新增 AddVCStatusEntity.VipCardStatusID = 1; AddVCStatusEntity.Action = "解挂"; VipCardStatusChangeLogBLL.Create(AddVCStatusEntity, pTran); #endregion break; case 7: #region 解冻 changeEntity.VipCardStatusId = 1; //执行更新 VipCardBLL.Update(changeEntity, pTran); //执行新增 AddVCStatusEntity.VipCardStatusID = 1; AddVCStatusEntity.Action = "解冻"; VipCardStatusChangeLogBLL.Create(AddVCStatusEntity, pTran); #endregion break; case 8: #region 作废 changeEntity.VipCardStatusId = 3; //执行更新 VipCardBLL.Update(changeEntity, pTran); //执行新增 AddVCStatusEntity.VipCardStatusID = 3; AddVCStatusEntity.Action = "作废"; VipCardStatusChangeLogBLL.Create(AddVCStatusEntity, pTran); #endregion break; case 9: #region 唤醒 changeEntity.VipCardStatusId = 1; //执行更新 VipCardBLL.Update(changeEntity, pTran); //执行新增 AddVCStatusEntity.VipCardStatusID = 1; AddVCStatusEntity.Action = "唤醒"; VipCardStatusChangeLogBLL.Create(AddVCStatusEntity, pTran); #endregion break; case 10: #region 激活 changeEntity.VipCardStatusId = 1; //执行更新 VipCardBLL.Update(changeEntity, pTran); //执行新增 AddVCStatusEntity.VipCardStatusID = 1; AddVCStatusEntity.Action = "激活"; VipCardStatusChangeLogBLL.Create(AddVCStatusEntity, pTran); #endregion break; default: throw new APIException("当前操作类型不匹配!") { ErrorCode = ERROR_CODES.INVALID_REQUEST_LACK_REQUEST_PARAMETER }; break; } ; pTran.Commit(); #region 卡升级,转卡操作转移消费记录表 if ((para.OperationType == 2 || para.OperationType == 5) && string.IsNullOrEmpty(para.VipCardTypeId.ToString())) //卡类型升级不执行此操作 { string StrSql = string.Format("update VipCardTransLog set VipCardCode='{0}',OldVipCardCode='{1}' where VipCardCode='{1}'", NewVipCardCode, OldVipCardCode); vipCardTransLogBLL.UpdateVipCardTransLog(StrSql);//执行 } #endregion var eventService = new EventService(); var vipMsg = new EventContract { Operation = OptEnum.Update, EntityType = EntityTypeEnum.Vip, Id = VipData.VIPID }; eventService.PublishMsg(vipMsg); } catch (APIException apiEx) { pTran.Rollback();//回滚事物 throw new APIException(apiEx.ErrorCode, apiEx.Message); } catch (Exception ex) { pTran.Rollback();//回滚事务 throw new APIException(ex.Message); } } return(rd); }
/// <summary> /// 我的小店增加商品 /// </summary> /// <param name="pRequest"></param> /// <returns></returns> private string VipStoreAddItem(string pRequest) { var rp = pRequest.DeserializeJSONTo <APIRequest <VipStoreRP> >(); LoggingSessionInfo loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, "1"); //先判断商品是否存在 if (string.IsNullOrWhiteSpace(rp.Parameters.ItemID)) { return(new ErrorResponse(500, "没有添加商品信息").ToJSON()); } //要传入的商品id组 string[] items = rp.Parameters.ItemID.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); //给用户增加商品 VipStoreBLL vipStoreBlll = new VipStoreBLL(loggingSessionInfo); List <string> arrItem = new List <string>(); for (int i = 0; i < items.Length; i++) { string itemID = items[i]; VipStoreEntity vipstoreEntityO = vipStoreBlll.QueryByEntity( new VipStoreEntity() { ItemID = itemID, VIPID = rp.UserID }, null ).FirstOrDefault(); //如果加入该商品就加入 if (vipstoreEntityO == null && !arrItem.Contains(itemID)) { arrItem.Add(itemID); } } IDbTransaction tran = new JIT.CPOS.BS.DataAccess.Base.TransactionHelper(loggingSessionInfo).CreateTransaction(); foreach (var item in arrItem) { VipStoreEntity vipStoreEntity = new VipStoreEntity() { vipStoreID = Guid.NewGuid().ToString(), VIPID = rp.UserID, ItemID = item, SoldCount = 0 }; vipStoreBlll.Create(vipStoreEntity, tran); } tran.Commit(); //用户是否开通小店 VipBLL vipBll = new VipBLL(loggingSessionInfo); VipEntity vipEntity = vipBll.GetByID(rp.UserID); vipEntity.IsSotre = vipEntity.IsSotre ?? 0; if (vipEntity != null && vipEntity.IsSotre == 0) { vipEntity.IsSotre = 1; vipBll.Update(vipEntity); } return(new SuccessResponse <IAPIResponseData>().ToJSON()); }
protected override GetVipIntegralListRD ProcessRequest(APIRequest <GetVipIntegralListRP> pRequest) { var loggingSessionInfo = Default.GetBSLoggingSession(pRequest.CustomerID, pRequest.UserID); var rd = new GetVipIntegralListRD(); var vipService = new VipBLL(loggingSessionInfo); var unitService = new UnitBLL(loggingSessionInfo); var parameter = pRequest.Parameters; List <IWhereCondition> complexCondition = new List <IWhereCondition>(); complexCondition.Add(new EqualsCondition() { FieldName = "L.CustomerId", Value = loggingSessionInfo.ClientID }); complexCondition.Add(new EqualsCondition() { FieldName = " L.VIPID", Value = loggingSessionInfo.UserID }); if (String.IsNullOrEmpty(parameter.VipCardCode)) //默认当前会员卡编号 { var entity = vipService.GetByID(pRequest.UserID); if (entity != null && !String.IsNullOrEmpty(entity.VipCode)) { parameter.VipCardCode = entity.VipCode; complexCondition.Add(new EqualsCondition() { FieldName = " L.VipCardCode", Value = entity.VipCode }); } } else { complexCondition.Add(new EqualsCondition() { FieldName = " L.VipCardCode", Value = parameter.VipCardCode }); } if (parameter.IntegralType == 1) //收入积分 { complexCondition.Add(new DirectCondition() { Expression = "Integral > 0" }); } else if (parameter.IntegralType == 2) //支出积分 { complexCondition.Add(new DirectCondition() { Expression = "Integral < 0" }); } //分页获取个人积分列表 PagedQueryResult <VipIntegralDetailEntity> IntegralList = unitService.GetMyIntegral(complexCondition.ToArray(), parameter.PageIndex, parameter.PageSize); if (IntegralList.Entities != null) { rd.IntegralList = IntegralList.Entities.Select(m => new IntegralInfo() { UpdateCount = m.UpdateCount, UpdateReason = m.UpdateReason, UpdateTime = m.UpdateTime.ToShortDateString() }).ToList(); } #region 统计 总积分|收入积分|支出积分 /// lst[0]=总积分 /// lst[1]=收入积分 /// lst[2]=支出积分 decimal[] lst = unitService.GetMyTotalIntegral(loggingSessionInfo.ClientID, pRequest.UserID, parameter.VipCardCode); if (lst != null) { rd.ExpenditureAmount = -lst[2]; //转换为正数 rd.IncomeAmount = lst[1]; } #endregion rd.TotalPageCount = IntegralList.PageCount; rd.TotalCount = IntegralList.RowCount; return(rd); }