/// <summary> /// customerinfo赋值 /// </summary> /// <returns></returns> private CustomerLoadInfo GetCustomerLoadInfo() { var customerBasicSettingBLL = new CustomerBasicSettingBLL(this.CurrentUserInfo); CustomerLoadInfo custome = new CustomerLoadInfo() { customerID = this.CurrentUserInfo.ClientID, customerName = this.CurrentUserInfo.ClientName }; DataRow dr = customerBasicSettingBLL.GetCustomerInfo(CurrentUserInfo.ClientID).Tables[0].Rows[0]; custome.customerCode = dr["customer_code"].ToString(); //商户简称 var ShortNameData = customerBasicSettingBLL.QueryByEntity(new CustomerBasicSettingEntity() { CustomerID = this.CurrentUserInfo.ClientID, SettingCode = "CustomerShortName" }, null).FirstOrDefault(); if (ShortNameData == null) { custome.customerName = dr["customer_name"].ToString(); } else { custome.customerName = ShortNameData.SettingValue; } //商户Logo var Data = customerBasicSettingBLL.QueryByEntity(new CustomerBasicSettingEntity() { CustomerID = this.CurrentUserInfo.ClientID, SettingCode = "WebLogo" }, null).FirstOrDefault(); custome.BusinessLogo = Data == null ? "" : Data.SettingValue; return(custome); }
/// <summary> /// 种植/更新BasicSetting缓存 /// </summary> /// <param name="strCustomerId"></param> /// <param name="basicSettingList"></param> public void SetBasicSetting(string strCustomerId) { try { LoggingSessionInfo _loggingSessionInfo = new LoggingSessionInfo(); LoggingManager CurrentLoggingManager = new LoggingManager(); var connection = GetCustomerConn(strCustomerId); _loggingSessionInfo.ClientID = strCustomerId; CurrentLoggingManager.Connection_String = connection; _loggingSessionInfo.CurrentLoggingManager = CurrentLoggingManager; CustomerBasicSettingBLL bllBasicSetting = new CustomerBasicSettingBLL(_loggingSessionInfo); List <CustomerBasicSettingEntity> listBasicSetting = bllBasicSetting.QueryByEntity(new CustomerBasicSettingEntity() { CustomerID = strCustomerId, IsDelete = 0 }, null).ToList(); RedisOpenAPI.Instance.CCBasicSetting().SetBasicSetting(new CC_BasicSetting() { CustomerId = strCustomerId, SettingList = listBasicSetting.Select(b => new Setting { SettingCode = b.SettingCode, SettingDesc = b.SettingDesc, SettingValue = b.SettingValue }).ToList() }); } catch (Exception ex) { throw new Exception("设置缓存失败!" + ex.Message); } }
protected override SearchStoreListRD ProcessRequest(APIRequest <SearchStoreListRP> pRequest) { SearchStoreListRD rd = new SearchStoreListRD(); var UnitServiceBll = new UnitService(base.CurrentUserInfo); //查询全部或查询附近 根据CityCode判断 string customerID = pRequest.CustomerID; CustomerBasicSettingBLL customerBasic = new CustomerBasicSettingBLL(this.CurrentUserInfo); //获取配置表中指定的附近范围值。 double RangeAccessoriesStores = customerBasic.SearchRangeAccessoriesStores(); //执行查询 var list = UnitServiceBll.FuzzyQueryStores(pRequest.Parameters.NameLike, pRequest.Parameters.CityCode, pRequest.Parameters.Position, pRequest.Parameters.PageIndex, pRequest.Parameters.PageSize, pRequest.Parameters.StoreID, pRequest.Parameters.IncludeHQ, customerID, RangeAccessoriesStores); foreach (var item in list) { if (item.Distance.HasValue) { if (item.Distance.Value <= 500) { item.DistanceDesc = string.Format("{0}米", item.Distance.Value.ToString("f0")); } else { var km = item.Distance.Value / 1000; item.DistanceDesc = string.Format("{0}公里", km.ToString("f1")); } } } rd.StoreListInfo = list; return(rd); }
public string IsAld() { var customerBasicSettingBLL = new CustomerBasicSettingBLL(this.CurrentUserInfo); string str = customerBasicSettingBLL.GetIsAld(); return(str); }
protected override GetSuperRetailTraderItemDetailRD ProcessRequest(APIRequest <GetSuperRetailTraderItemDetailRP> pRequest) { GetSuperRetailTraderItemDetailRP rp = pRequest.Parameters; GetSuperRetailTraderItemDetailRD rd = new GetSuperRetailTraderItemDetailRD(); OnlineShoppingItemBLL itemService = new OnlineShoppingItemBLL(CurrentUserInfo); var superRetailTraderItemMappingBll = new T_SuperRetailTraderItemMappingBLL(CurrentUserInfo); var superRetailTraderSkuMappingBll = new T_SuperRetailTraderSkuMappingBLL(CurrentUserInfo); var superRetailTraderConfigBll = new T_SuperRetailTraderConfigBLL(CurrentUserInfo); var customerBasicSettingBll = new CustomerBasicSettingBLL(CurrentUserInfo); //获取商品详细信息 var ItemDetail = superRetailTraderItemMappingBll.GetSuperRetailTraderItemDetail(rp.ItemId); //获取Sku详细信息 var skuList = superRetailTraderSkuMappingBll.GetSuperRetailTraderSkuDetail(rp.ItemId, pRequest.CustomerID); //获取分销商配置信息 T_SuperRetailTraderConfigEntity superRetailTraderConfigEntity = superRetailTraderConfigBll.QueryByEntity(new T_SuperRetailTraderConfigEntity() { CustomerId = CurrentUserInfo.ClientID }, null).FirstOrDefault(); #region 商品图片 var dsImages = itemService.GetItemImageList(rp.ItemId); if (dsImages != null && dsImages.Tables.Count > 0 && dsImages.Tables[0].Rows.Count > 0) { rd.ImageList = DataTableToObject.ConvertToList <ImageInfo>(dsImages.Tables[0]); } #endregion rd.ItemId = ItemDetail.ItemId; rd.ItemName = ItemDetail.ItemName; rd.Prop1 = ItemDetail.Prop1Name; rd.Prop2 = ItemDetail.Prop2Name; rd.Price = ItemDetail.Price; rd.DistributerPrice = Math.Round(Convert.ToDecimal(ItemDetail.DistributerCostPrice / Convert.ToDecimal(superRetailTraderConfigEntity.Cost / 100)), 2, MidpointRounding.AwayFromZero); //分销价格 成本价 / 成本占比 if (rd.Price == 0) //价格为零,折扣为10折 { rd.Discount = 1; } else { rd.Discount = Math.Round(rd.DistributerPrice / rd.Price, 2, MidpointRounding.AwayFromZero); //折扣 } rd.ItemIntroduce = ItemDetail.ItemIntroduce; rd.SkuList = skuList.Select(n => new APISkuInfo() { SkuID = n.SkuId, PropName1 = n.PropName1, PropName2 = n.PropName2, DistributerPrice = Math.Round(Convert.ToDecimal(n.DistributerCostPrice / Convert.ToDecimal(superRetailTraderConfigEntity.Cost / 100)), 2, MidpointRounding.AwayFromZero), //分销价格 成本价 / 成本占比 DistributerStock = Convert.ToInt32(n.DistributerStock) - Convert.ToInt32(n.SalesPrice), SoldQty = Convert.ToInt32(n.SalesQty) }).ToList(); rd.DeliveryDesc = customerBasicSettingBll.GetSettingValueByCode("DeliveryStrategy"); return(rd); }
protected override GetMemberBenefitsRD ProcessRequest(APIRequest <EmptyRequestParameter> pRequest) { GetMemberBenefitsRD rd = new GetMemberBenefitsRD(); var customerBasicSettingBll = new CustomerBasicSettingBLL(CurrentUserInfo); rd.MemberBenefits = customerBasicSettingBll.GetMemberBenefits(pRequest.CustomerID); return(rd); }
/// <summary> ///获取客户分类信息 /// </summary> /// <returns></returns> public string GetCousCustomerType() { var customerBasicSettingBLL = new CustomerBasicSettingBLL(this.CurrentUserInfo); DataSet ds = customerBasicSettingBLL.GetCousCustomerType(); if (ds != null && ds.Tables.Count > 0) { return(string.Format("{0}", ds.Tables[0].ToJSON())); } return(string.Format("{{\"data\":''}}")); }
private void LoadSkuProp() { CustomerBasicSettingBLL customerBasicSettingBLL = new CustomerBasicSettingBLL(CurrentUserInfo); SKUExist = customerBasicSettingBLL.CheckSKUExist(); var skuPropService = new JIT.CPOS.BS.BLL.SkuPropServer(CurrentUserInfo); var source = skuPropService.GetSkuPropList(); SkuProInfos = source; //价格类型集合(jifeng.cao 20140221) var itemPriceTypeService = new JIT.CPOS.BS.BLL.ItemPriceTypeService(CurrentUserInfo); var list = itemPriceTypeService.GetItemPriceTypeList(); ItemPriceTypeInfos = list; }
/// <summary> /// 获取优惠券码 /// </summary> /// <param name="loggingSession"></param> /// <param name="strCustomerId"></param> /// <returns></returns> public string GetCouponNum(LoggingSessionInfo loggingSession, string strCustomerId) { string uperStr = StringUtil.GetRandomUperStr(4); string strBackInt = StringUtil.GetRandomStrInt(8); string strAllInt = StringUtil.GetRandomStrInt(12); string strCouponNumRole = string.Empty; string strCouponCode = string.Empty; //判断是否有特殊的优惠券编码 BasicSetting.BasicSettingBLL bllBasicSetting = new BasicSetting.BasicSettingBLL(); var basicSettingList = bllBasicSetting.GetBasicSetting(strCustomerId); if (basicSettingList.Count > 0) { var query = from q in basicSettingList.AsEnumerable() where q.SettingCode.Contains("CouponNumRole") select q; if (query.FirstOrDefault() != null) { strCouponNumRole = query.FirstOrDefault().SettingValue; } } else { CustomerBasicSettingBLL bllBasic = new CustomerBasicSettingBLL(loggingSession); var entityBasic = bllBasic.QueryByEntity(new CustomerBasicSettingEntity() { SettingCode = "CouponNumRole" }, null).SingleOrDefault(); if (entityBasic != null) { strCouponNumRole = entityBasic.SettingValue; } } if (!string.IsNullOrEmpty(strCouponNumRole) && strCouponNumRole == "1")//设置了“1”,则使用全是数字的优惠券编码规则 { strCouponCode = strAllInt; } else { strCouponCode = uperStr + "-" + strBackInt; } return(strCouponCode); }
protected override GetDisplaynoneRD ProcessRequest(APIRequest <EmptyRequestParameter> pRequest) { GetDisplaynoneRD rd = new GetDisplaynoneRD(); var UnitServiceBll = new UnitService(base.CurrentUserInfo); CustomerBasicSettingBLL customerBasic = new CustomerBasicSettingBLL(this.CurrentUserInfo); bool isShowAll = customerBasic.CheckIsAllAccessoriesStores(); //判断是否显示所有门店 bool isShowSearch = customerBasic.CheckIsSearchAccessoriesStores(); //判断是否显示搜索栏 string forwardingMessageLogo = customerBasic.GetForwardingMessageLogo(); //转发消息图标 string forwardingMessageTitle = customerBasic.GetForwardingMessageTitle(); //转发消息默认标题 string forwardingMessageSummary = customerBasic.GetForwardingMessageSummary(); //转发消息默认摘要文字 rd.IsAllAccessoriesStores = isShowAll; //是否显示全部 rd.IsSearchAccessoriesStores = isShowSearch; //是否显示搜索栏 rd.ForwardingMessageLogo = forwardingMessageLogo; //转发消息图标 rd.ForwardingMessageTitle = forwardingMessageTitle; //转发消息默认标题 rd.ForwardingMessageSummary = forwardingMessageSummary; //转发消息默认摘要文字 return(rd); }
protected override GetBusinessBasisConfigInfoRD ProcessRequest(DTO.Base.APIRequest <GetBusinessBasisConfigInfoRP> pRequest) { var rd = new GetBusinessBasisConfigInfoRD(); var para = pRequest.Parameters; var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo; var customerBasicSettingBLL = new CustomerBasicSettingBLL(loggingSessionInfo); #region 商户基础信息 DataRow dr = customerBasicSettingBLL.GetCustomerInfo(loggingSessionInfo.ClientID).Tables[0].Rows[0]; rd.customer_name = dr["customer_name"].ToString();//商户全称 // var ResultList = customerBasicSettingBLL.GetBusinessBasisConfigInfo(loggingSessionInfo.ClientID); //var Data1 = ResultList.FirstOrDefault(m => m.SettingCode.Equals("BusinessLogo")); var Data = ResultList.FirstOrDefault(m => m.SettingCode.Equals("CustomerShortName")); rd.CustomerShortName = Data == null ? "" : Data.SettingValue; //商户简称 var Data1 = ResultList.FirstOrDefault(m => m.SettingCode.Equals("WebLogo")); rd.WebLogo = Data1 == null ? "" : Data1.SettingValue; //商户Logo var Data2 = ResultList.FirstOrDefault(m => m.SettingCode.Equals("CustomerPhone")); rd.CustomerPhone = Data2 == null ? "" : Data2.SettingValue; //客户电话 //var Data3 = ResultList.FirstOrDefault(m => m.SettingCode.Equals("ShareTitle")); var Data3 = ResultList.FirstOrDefault(m => m.SettingCode.Equals("ForwardingMessageTitle")); rd.ForwardingMessageTitle = Data3 == null ? "" : Data3.SettingValue;//分享标题 //var Data4 = ResultList.FirstOrDefault(m => m.SettingCode.Equals("ShareImageUrl")); var Data4 = ResultList.FirstOrDefault(m => m.SettingCode.Equals("ForwardingMessageLogo")); rd.ForwardingMessageLogo = Data4 == null ? "" : Data4.SettingValue;//分享图片 //var Data5 = ResultList.FirstOrDefault(m => m.SettingCode.Equals("ShareContent")); var Data5 = ResultList.FirstOrDefault(m => m.SettingCode.Equals("ForwardingMessageSummary")); rd.ForwardingMessageSummary = Data5 == null ? "" : Data5.SettingValue; //分享摘要内容 var Data6 = ResultList.FirstOrDefault(m => m.SettingCode.Equals("GuideLinkUrl")); rd.GuideLinkUrl = Data6 == null ? "" : Data6.SettingValue; //引导链接 var Data7 = ResultList.FirstOrDefault(m => m.SettingCode.Equals("GuideQRCode")); rd.GuideQRCode = Data7 == null ? "" : Data7.SettingValue; //引导二维码 var Data8 = ResultList.FirstOrDefault(m => m.SettingCode.Equals("CustomerGreeting")); rd.CustomerGreeting = Data8 == null ? "" : Data8.SettingValue; //欢迎去 #endregion return(rd); }
protected override GetCustomerBasicSettingRD ProcessRequest(DTO.Base.APIRequest <GetCustomerBasicSettingRP> pRequest) { var rd = new GetCustomerBasicSettingRD(); var para = pRequest.Parameters; var customerBasicSettingBLL = new CustomerBasicSettingBLL(CurrentUserInfo); if (!string.IsNullOrWhiteSpace(para.SettingCode)) { var Data = new JIT.CPOS.BS.Entity.CustomerBasicSettingEntity(); JIT.CPOS.BS.BLL.RedisOperationBLL.BasicSetting.BasicSettingBLL bllBasicSetting = new JIT.CPOS.BS.BLL.RedisOperationBLL.BasicSetting.BasicSettingBLL(); var basicSettingList = bllBasicSetting.GetBasicSetting(CurrentUserInfo.ClientID); if (basicSettingList != null && basicSettingList.Count > 0) { Data = basicSettingList.Where(b => b.SettingCode == para.SettingCode).FirstOrDefault(); } else { //查询参数 var complexCondition = new List <IWhereCondition> { }; complexCondition.Add(new EqualsCondition() { FieldName = "CustomerID", Value = CurrentUserInfo.ClientID }); complexCondition.Add(new DirectCondition("SettingCode='" + para.SettingCode + "' ")); Data = customerBasicSettingBLL.Query(complexCondition.ToArray(), null).FirstOrDefault(); } if (Data != null) { rd.SettingValue = Data.SettingValue; } else { rd.SettingValue = "欢迎光临!请问有什么可以帮助到您?"; } } return(rd); }
private string GetWeixinShareUrl(string pRequest) { var rp = pRequest.DeserializeJSONTo <APIRequest <EmptyRequestParameter> >(); LoggingSessionInfo loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, "1"); try { CustomerBasicSettingBLL CustomerBasicSettingBll = new CustomerBasicSettingBLL(loggingSessionInfo); string url = CustomerBasicSettingBll.GetSettingValueByCode("ShareWeixinPage"); var rsp = new SuccessResponse <IAPIResponseData>(); rsp.Message = url; return(rsp.ToJSON()); } catch (Exception) { return(new ErrorResponse() { ResultCode = 500, Message = "查询错误" }.ToJSON()); } }
protected override GetDisplaynoneRD ProcessRequest(DTO.Base.APIRequest <GetDisplaynoneRP> pRequest) { GetDisplaynoneRD rd = new GetDisplaynoneRD(); var customerId = pRequest.Parameters.CustomerId; var textId = pRequest.Parameters.TextId; var currentUserInfo = Default.GetBSLoggingSession(customerId, "1"); var UnitServiceBll = new UnitService(currentUserInfo); CustomerBasicSettingBLL customerBasic = new CustomerBasicSettingBLL(currentUserInfo); bool isShowAll = customerBasic.CheckIsAllAccessoriesStores(); //判断是否显示所有门店 bool isShowSearch = customerBasic.CheckIsSearchAccessoriesStores(); //判断是否显示搜索栏 string forwardingMessageLogo = customerBasic.GetForwardingMessageLogo(); //转发消息图标 string forwardingMessageTitle = customerBasic.GetForwardingMessageTitle(); //转发消息默认标题 string forwardingMessageSummary = customerBasic.GetForwardingMessageSummary(); //转发消息默认摘要文字 rd.IsAllAccessoriesStores = isShowAll; //是否显示全部 rd.IsSearchAccessoriesStores = isShowSearch; //是否显示搜索栏 rd.ForwardingMessageLogo = forwardingMessageLogo; //转发消息图标 rd.ForwardingMessageTitle = forwardingMessageTitle; //转发消息默认标题 rd.ForwardingMessageSummary = forwardingMessageSummary; //转发消息默认摘要文字 return(rd); }
protected override EmptyResponseData ProcessRequest(DTO.Base.APIRequest <SetOffActionRP> pRequest) { var rd = new EmptyResponseData(); var para = pRequest.Parameters; var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo; var SetoffEventBll = new SetoffEventBLL(loggingSessionInfo); var IincentiveRuleBll = new IincentiveRuleBLL(loggingSessionInfo); var ObjectImagesBll = new ObjectImagesBLL(loggingSessionInfo); var SetoffToolsBll = new SetoffToolsBLL(loggingSessionInfo); var SetoffPosterBll = new SetoffPosterBLL(loggingSessionInfo); var CustomerBasicSettingBll = new CustomerBasicSettingBLL(loggingSessionInfo); // var pTran = SetoffEventBll.GetTran(); string _CustomerId = loggingSessionInfo.ClientID; if (para.SetOffActionList.Count > 0) { //using (pTran.Connection) //{ try { foreach (var item in para.SetOffActionList) { List <CustomerBasicSettingEntity> settingList = new List <CustomerBasicSettingEntity>(); //基础配置数据 //获取已发布的集客行动 var SetoffEvenResult = SetoffEventBll.QueryByEntity(new SetoffEventEntity() { SetoffType = item.SetoffType, Status = "10", CustomerId = loggingSessionInfo.ClientID }, null).ToList(); if (SetoffEvenResult.Count > 1) { throw new APIException("数据异常,只能有一种集客行动!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS } } ; if (SetoffEvenResult.Count > 0) { var Result = SetoffEvenResult.First(); //集客行动 var RuleData = IincentiveRuleBll.QueryByEntity(new IincentiveRuleEntity() { SetoffEventID = Result.SetoffEventID, CustomerId = loggingSessionInfo.ClientID }, null).FirstOrDefault(); if (RuleData == null) { throw new APIException("数据异常,找不到奖励规则!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS } } ; //判断奖励是否变动 if (item.SetoffRegAwardType != RuleData.SetoffRegAwardType || item.SetoffRegPrize != RuleData.SetoffRegPrize || item.SetoffOrderPer != RuleData.SetoffOrderPer || item.SetoffOrderTimers != RuleData.SetoffOrderTimers || item.IsEnabled != Convert.ToInt32(RuleData.Status)) { //原集客行动状态设置为失效 SetoffEventBll.SetFailStatus(item.SetoffType, loggingSessionInfo.ClientID); #region 规则变动,重新新建集客行动 //集客行动 //集客行动 var SetoffEvenData = new SetoffEventEntity(); //集客行动 SetoffEvenData.SetoffEventID = System.Guid.NewGuid(); SetoffEvenData.SetoffType = item.SetoffType; SetoffEvenData.Status = "10"; SetoffEvenData.CustomerId = _CustomerId; SetoffEventBll.Create(SetoffEvenData); // var IincentiveRuleData = new IincentiveRuleEntity(); //奖励规则 IincentiveRuleData.IincentiveRuleID = System.Guid.NewGuid(); IincentiveRuleData.SetoffEventID = SetoffEvenData.SetoffEventID; IincentiveRuleData.SetoffType = item.SetoffType; IincentiveRuleData.ApplyUnit = 0; IincentiveRuleData.SetoffRegAwardType = item.SetoffRegAwardType; IincentiveRuleData.SetoffRegPrize = item.SetoffRegPrize; IincentiveRuleData.SetoffOrderPer = item.SetoffOrderPer; IincentiveRuleData.SetoffOrderTimers = item.SetoffOrderTimers; IincentiveRuleData.Status = item.IsEnabled.ToString(); IincentiveRuleData.CustomerId = _CustomerId; IincentiveRuleBll.Create(IincentiveRuleData); // #region 新增集客海报、海报集客工具关系 foreach (var PosterItem in item.SetoffPosterList) { //图片表 var ObjectImageData = new ObjectImagesEntity(); ObjectImageData.ImageId = System.Guid.NewGuid().ToString("N"); ObjectImageData.ImageURL = PosterItem.ImageUrl; ObjectImageData.Description = "集客海报"; ObjectImageData.CustomerId = _CustomerId; ObjectImagesBll.Create(ObjectImageData); // //集客海报 var SetoffPosterData = new SetoffPosterEntity(); SetoffPosterData.SetoffPosterID = System.Guid.NewGuid(); SetoffPosterData.Name = PosterItem.Name; SetoffPosterData.Desc = "集客海报"; SetoffPosterData.ImageId = ObjectImageData.ImageId; SetoffPosterData.Status = "10"; SetoffPosterData.CustomerId = _CustomerId; SetoffPosterBll.Create(SetoffPosterData); //海报工具关系 var SetoffToolsData = new SetoffToolsEntity(); SetoffToolsData.SetoffToolID = System.Guid.NewGuid(); SetoffToolsData.SetoffEventID = SetoffEvenData.SetoffEventID; SetoffToolsData.ToolType = "SetoffPoster"; SetoffToolsData.ObjectId = SetoffPosterData.SetoffPosterID.ToString(); SetoffToolsData.Status = "10"; SetoffToolsData.CustomerId = _CustomerId; SetoffToolsBll.Create(SetoffToolsData); // } #endregion #region 新增集客工具关系 foreach (var ToolsItem in item.SetoffTools) { //判断是否添加重复集客工具 bool Flag = SetoffEventBll.IsToolsRepeat(SetoffEvenData.SetoffEventID.ToString(), ToolsItem.ObjectId); if (Flag) { throw new APIException("集客行动不能添加相同的集客工具!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS } } ; var SetoffToolsData = new SetoffToolsEntity(); SetoffToolsData.SetoffToolID = System.Guid.NewGuid(); SetoffToolsData.SetoffEventID = SetoffEvenData.SetoffEventID; SetoffToolsData.ToolType = ToolsItem.ToolType; SetoffToolsData.ObjectId = ToolsItem.ObjectId; SetoffToolsData.Status = "10"; SetoffToolsData.CustomerId = _CustomerId; SetoffToolsBll.Create(SetoffToolsData); // } #endregion #endregion #region 更新配置奖励系数 //集客销售订单分润配置 //var SettingData = CustomerBasicSettingBll.QueryByEntity(new CustomerBasicSettingEntity() { SettingCode = "GetVipUserOrderPer", CustomerID = CurrentUserInfo.ClientID, IsDelete = 0 }, null).FirstOrDefault(); //if (SettingData != null) //{ // SettingData.SettingValue = IincentiveRuleData.SetoffOrderPer.ToString(); // CustomerBasicSettingBll.Update(SettingData); //} if (IincentiveRuleData.SetoffType == 2) { settingList.Add(new CustomerBasicSettingEntity() { SettingCode = "GetVipUserOrderPer", SettingValue = (IincentiveRuleData.SetoffOrderPer ?? 0).ToString() }); } if (IincentiveRuleData.SetoffRegAwardType == 2) { settingList.Add(new CustomerBasicSettingEntity() { SettingCode = "InvitePartnersPoints", SettingValue = (IincentiveRuleData.SetoffRegPrize ?? 0).ToString() }); } CustomerBasicSettingBll.SaveCustomerBasicInfo(loggingSessionInfo.ClientID, settingList); //集客注册奖励配置 #endregion } else { #region 新增集客海报、海报集客工具关系 foreach (var PosterItem in item.SetoffPosterList) { //图片表 var ObjectImageData = new ObjectImagesEntity(); ObjectImageData.ImageId = System.Guid.NewGuid().ToString("N"); ObjectImageData.ImageURL = PosterItem.ImageUrl; ObjectImageData.Description = "集客海报"; ObjectImageData.CustomerId = _CustomerId; ObjectImagesBll.Create(ObjectImageData); // //集客海报 var SetoffPosterData = new SetoffPosterEntity(); SetoffPosterData.SetoffPosterID = System.Guid.NewGuid(); SetoffPosterData.Name = PosterItem.Name; SetoffPosterData.Desc = "集客海报"; SetoffPosterData.ImageId = ObjectImageData.ImageId; SetoffPosterData.Status = "10"; SetoffPosterData.CustomerId = _CustomerId; SetoffPosterBll.Create(SetoffPosterData); //海报工具关系 var SetoffToolsData = new SetoffToolsEntity(); SetoffToolsData.SetoffToolID = System.Guid.NewGuid(); SetoffToolsData.SetoffEventID = Result.SetoffEventID; SetoffToolsData.ToolType = "SetoffPoster"; SetoffToolsData.ObjectId = SetoffPosterData.SetoffPosterID.ToString(); SetoffToolsData.Status = "10"; SetoffToolsData.CustomerId = _CustomerId; SetoffToolsBll.Create(SetoffToolsData); // } #endregion #region 新增集客工具关系 foreach (var ToolsItem in item.SetoffTools) { // if (Result == null) { throw new APIException("数据异常,未找到集客行动!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS } } ; //判断是否添加重复集客工具 bool Flag = SetoffEventBll.IsToolsRepeat(Result.SetoffEventID.ToString(), ToolsItem.ObjectId); if (Flag) { throw new APIException("集客行动不能添加相同的集客工具!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS } } ; var SetoffToolsData = new SetoffToolsEntity(); SetoffToolsData.SetoffToolID = System.Guid.NewGuid(); SetoffToolsData.SetoffEventID = Result.SetoffEventID; SetoffToolsData.ToolType = ToolsItem.ToolType; SetoffToolsData.ObjectId = ToolsItem.ObjectId; SetoffToolsData.Status = "10"; SetoffToolsData.CustomerId = _CustomerId; SetoffToolsBll.Create(SetoffToolsData); // } #endregion } } else { //原集客行动状态设置为失效 SetoffEventBll.SetFailStatus(item.SetoffType, loggingSessionInfo.ClientID); #region 新建集客行动 //集客行动 var SetoffEvenData = new SetoffEventEntity(); //集客行动 SetoffEvenData.SetoffEventID = System.Guid.NewGuid(); SetoffEvenData.SetoffType = item.SetoffType; SetoffEvenData.Status = "10"; SetoffEvenData.CustomerId = _CustomerId; SetoffEventBll.Create(SetoffEvenData); // var IincentiveRuleData = new IincentiveRuleEntity(); //奖励规则 IincentiveRuleData.IincentiveRuleID = System.Guid.NewGuid(); IincentiveRuleData.SetoffEventID = SetoffEvenData.SetoffEventID; IincentiveRuleData.SetoffType = item.SetoffType; IincentiveRuleData.ApplyUnit = 0; IincentiveRuleData.SetoffRegAwardType = item.SetoffRegAwardType; IincentiveRuleData.SetoffRegPrize = item.SetoffRegPrize; IincentiveRuleData.SetoffOrderPer = item.SetoffOrderPer; IincentiveRuleData.SetoffOrderTimers = item.SetoffOrderTimers; IincentiveRuleData.Status = item.IsEnabled.ToString(); IincentiveRuleData.CustomerId = _CustomerId; IincentiveRuleBll.Create(IincentiveRuleData); // #region 新增集客海报、海报集客工具关系 foreach (var PosterItem in item.SetoffPosterList) { //图片表 var ObjectImageData = new ObjectImagesEntity(); ObjectImageData.ImageId = System.Guid.NewGuid().ToString("N"); ObjectImageData.ImageURL = PosterItem.ImageUrl; ObjectImageData.Description = "集客海报"; ObjectImageData.CustomerId = _CustomerId; ObjectImagesBll.Create(ObjectImageData); // //集客海报 var SetoffPosterData = new SetoffPosterEntity(); SetoffPosterData.SetoffPosterID = System.Guid.NewGuid(); SetoffPosterData.Name = PosterItem.Name; SetoffPosterData.Desc = "集客海报"; SetoffPosterData.ImageId = ObjectImageData.ImageId; SetoffPosterData.Status = "10"; SetoffPosterData.CustomerId = _CustomerId; SetoffPosterBll.Create(SetoffPosterData); //海报工具关系 var SetoffToolsData = new SetoffToolsEntity(); SetoffToolsData.SetoffToolID = System.Guid.NewGuid(); SetoffToolsData.SetoffEventID = SetoffEvenData.SetoffEventID; SetoffToolsData.ToolType = "SetoffPoster"; SetoffToolsData.ObjectId = SetoffPosterData.SetoffPosterID.ToString(); SetoffToolsData.Status = "10"; SetoffToolsData.CustomerId = _CustomerId; SetoffToolsBll.Create(SetoffToolsData); // } #endregion #region 新增集客工具关系 foreach (var ToolsItem in item.SetoffTools) { //判断是否添加重复集客工具 bool Flag = SetoffEventBll.IsToolsRepeat(SetoffEvenData.SetoffEventID.ToString(), ToolsItem.ObjectId); if (Flag) { throw new APIException("集客行动不能添加相同的集客工具!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS } } ; var SetoffToolsData = new SetoffToolsEntity(); SetoffToolsData.SetoffToolID = System.Guid.NewGuid(); SetoffToolsData.SetoffEventID = SetoffEvenData.SetoffEventID; SetoffToolsData.ToolType = ToolsItem.ToolType; SetoffToolsData.ObjectId = ToolsItem.ObjectId; SetoffToolsData.Status = "10"; SetoffToolsData.CustomerId = _CustomerId; SetoffToolsBll.Create(SetoffToolsData); // } #endregion #endregion #region 更新配置奖励系数 if (IincentiveRuleData.SetoffType == 2) { //同步到原CustomerBasicSetting集客销售订单分润配置 //var SettingData = CustomerBasicSettingBll.QueryByEntity(new CustomerBasicSettingEntity() { SettingCode = "GetVipUserOrderPer", CustomerID = CurrentUserInfo.ClientID, IsDelete = 0 }, null).FirstOrDefault(); //if (SettingData != null) //{ // SettingData.SettingValue = (IincentiveRuleData.SetoffOrderPer ?? 0).ToString(); // CustomerBasicSettingBll.Update(SettingData); //} settingList.Add(new CustomerBasicSettingEntity() { SettingCode = "GetVipUserOrderPer", SettingValue = (IincentiveRuleData.SetoffOrderPer ?? 0).ToString() }); } if (IincentiveRuleData.SetoffRegAwardType == 2) { //同步到原CustomerBasicSetting集客销售订单分润配置 //var SettingData = CustomerBasicSettingBll.QueryByEntity(new CustomerBasicSettingEntity() { SettingCode = "InvitePartnersPoints", CustomerID = CurrentUserInfo.ClientID, IsDelete = 0 }, null).FirstOrDefault(); //if (SettingData != null) //{ // SettingData.SettingValue = (IincentiveRuleData.SetoffRegPrize ?? 0).ToString(); // CustomerBasicSettingBll.Update(SettingData); //} settingList.Add(new CustomerBasicSettingEntity() { SettingCode = "InvitePartnersPoints", SettingValue = (IincentiveRuleData.SetoffRegPrize ?? 0).ToString() }); } CustomerBasicSettingBll.SaveCustomerBasicInfo(loggingSessionInfo.ClientID, settingList); #endregion } } // //pTran.Commit(); } catch (APIException ex) { //pTran.Rollback(); throw ex; } //} } return(rd); }
protected override GetVipIntegralInfoListRD ProcessRequest(DTO.Base.APIRequest <GetVipIntegralInfoListRP> pRequest) { LoggingSessionInfo loggingSessionInfo = Default.GetBSLoggingSession(pRequest.CustomerID, pRequest.UserID); SysVipCardTypeBLL bll = new SysVipCardTypeBLL(loggingSessionInfo); VipCardRuleBLL VipCardRuleService = new VipCardRuleBLL(loggingSessionInfo); var vipCardVipMappingBLL = new VipCardVipMappingBLL(loggingSessionInfo); var vipCardBLL = new VipCardBLL(loggingSessionInfo); var vipCardTypeBLL = new SysVipCardTypeBLL(loggingSessionInfo); var rd = new GetVipIntegralInfoListRD(); string[] CustomerBaseSettingCode = new string[] { "IntegralAmountPer", "PointsRedeemLowestLimit", "PointsRedeemUpLimit", "PointsValidPeriod" }; string[] CustomerBaseSettingDesc = new string[] { "积分抵扣比例", "账户积分累计满", "每单可使用积分上限", "积分有效期" }; CustomerBasicSettingBLL CustomerBasicSettingService = new CustomerBasicSettingBLL(loggingSessionInfo); //循环获取积分信息 for (int i = 0; i < CustomerBaseSettingCode.Length; i++) { var entity = CustomerBasicSettingService.QueryByEntity(new CustomerBasicSettingEntity() { CustomerID = loggingSessionInfo.ClientID, IsDelete = 0, SettingCode = CustomerBaseSettingCode[i] }, null).FirstOrDefault(); if (entity != null) { rd.VipIntegralInfoList.Add(new VipIntegralInfo() { CustomerBaseSettingDesc = CustomerBaseSettingDesc[i], CustomerBaseSettingValue = entity.SettingValue }); } else { rd.VipIntegralInfoList.Add(new VipIntegralInfo() { CustomerBaseSettingDesc = CustomerBaseSettingDesc[i], CustomerBaseSettingValue = "0" }); } } //获取会员 卡映射关系 var vipCardMappingInfo = vipCardVipMappingBLL.QueryByEntity(new VipCardVipMappingEntity() { VIPID = pRequest.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) { //获取卡升级规则信息 var cardrulemodel = VipCardRuleService.QueryByEntity(new VipCardRuleEntity() { VipCardTypeID = vipCardTypeInfo.VipCardTypeID }, null).FirstOrDefault(); if (cardrulemodel != null) { if (cardrulemodel.PaidGivePoints > 0) //积分 { rd.VipIntegralInfoList.Add(new VipIntegralInfo() { CustomerBaseSettingDesc = "每消费" + Convert.ToInt32(cardrulemodel.PaidGivePoints) + "元返 1积分", CustomerBaseSettingValue = Convert.ToInt32(cardrulemodel.PaidGivePoints) + "" }); } if (cardrulemodel.PaidGivePercetPoints > 0) //积分比例 { rd.VipIntegralInfoList.Add(new VipIntegralInfo() { CustomerBaseSettingDesc = "消费返积分比例" + Convert.ToInt32(cardrulemodel.PaidGivePercetPoints) + "%", CustomerBaseSettingValue = Convert.ToInt32(cardrulemodel.PaidGivePercetPoints) + "" }); } } } } } return(rd); }
protected override GetVIPCardRD ProcessRequest(DTO.Base.APIRequest <GetVIPCardRP> pRequest) { GetVIPCardRD Data = new GetVIPCardRD(); var rd = new GetVIPCardListRD(); var para = pRequest.Parameters; var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo; #region 业务对象 //会员卡 var VipCardBLL = new VipCardBLL(loggingSessionInfo); //会员 var VipBLL = new VipBLL(loggingSessionInfo); //卡状态变更记录 var VipCardStatusChangeLogBLL = new VipCardStatusChangeLogBLL(loggingSessionInfo); //卡与Vip关系 var VipCardVipMappingBLL = new VipCardVipMappingBLL(loggingSessionInfo); //门店 var unitBll = new t_unitBLL(loggingSessionInfo); //员工 var UserBLL = new T_UserBLL(loggingSessionInfo); //卡类型 var SysVipCardTypeBLL = new SysVipCardTypeBLL(loggingSessionInfo); //商户配置 var CustomerBasicSettingBLL = new CustomerBasicSettingBLL(loggingSessionInfo); //积分 var VipIntegralBLL = new VipIntegralBLL(loggingSessionInfo); #endregion #region 会员卡 VipCardEntity resultData = null; if (!string.IsNullOrWhiteSpace(para.VipID)) { //会员编号获取详情 VipCardVipMappingEntity m_VipMappingData = VipCardVipMappingBLL.QueryByEntity(new VipCardVipMappingEntity() { VIPID = para.VipID }, null).FirstOrDefault(); if (m_VipMappingData != null && !string.IsNullOrWhiteSpace(m_VipMappingData.VipCardID)) { resultData = VipCardBLL.GetByID(para.VipCardID); } } else { if (!string.IsNullOrWhiteSpace(para.VipCardID)) { //卡ID获取详情 resultData = VipCardBLL.GetByID(para.VipCardID); } else { //刷卡获取详情 List <IWhereCondition> complexCondition = new List <IWhereCondition> { }; if (!string.IsNullOrEmpty(para.VipCardISN)) { complexCondition.Add(new DirectCondition("VipCardCode='" + para.VipCardISN + "' or VipCardISN='" + para.VipCardISN.ToString() + "' ")); } resultData = VipCardBLL.Query(complexCondition.ToArray(), null).FirstOrDefault(); } } //try //{ // if (resultData == null) // throw new APIException("该卡不存在!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS }; //} //catch (APIException apiEx) //{ // throw new APIException(apiEx.ErrorCode, apiEx.Message); //} #endregion #region 卡关系 VipCardVipMappingEntity VipCardVipMappingData = null; if (resultData != null) { VipCardVipMappingData = VipCardVipMappingBLL.QueryByEntity(new VipCardVipMappingEntity() { VipCardID = resultData.VipCardID }, null).FirstOrDefault(); } //else //{ // return Data; //} #endregion #region 门店 t_unitEntity unidData = null; if (resultData != null && !string.IsNullOrWhiteSpace(resultData.MembershipUnit)) { unidData = unitBll.GetByID(resultData.MembershipUnit); } #endregion #region 会员,积分 VipEntity VipData = null; VipIntegralEntity IntegralData = null; //string VIPID = VipCardVipMappingData == null ? "" : VipCardVipMappingData.VIPID; string VIPID = para.VipID; if (!string.IsNullOrWhiteSpace(VIPID)) { VipData = VipBLL.NewGetByID(VIPID); //IntegralData = VipIntegralBLL.GetByID(VIPID); IntegralData = VipIntegralBLL.QueryByEntity(new VipIntegralEntity() { VipID = VipData.VIPID, VipCardCode = VipData.VipCode }, null).FirstOrDefault(); } #endregion #region 员工 T_UserEntity UserData = null; if (resultData != null && !string.IsNullOrWhiteSpace(resultData.CreateBy)) { UserData = UserBLL.GetByID(resultData.CreateBy); } #endregion #region 响应对象赋值 if (resultData != null) { //卡 Data.VipCardID = resultData.VipCardID; Data.VipCardCode = resultData.VipCardCode; Data.VipCardISN = resultData.VipCardISN; Data.CraeteUserName = UserData == null ? "" : UserData.user_name; Data.VipCardStatusId = resultData.VipCardStatusId.Value; Data.MembershipTime = resultData.MembershipTime == null ? "" : resultData.MembershipTime.Value.ToString("yyyy-MM-dd"); Data.MembershipUnitName = unidData == null ? "" : unidData.unit_name; //Data.TotalAmount = resultData.RechargeTotalAmount == null ? 0 : resultData.RechargeTotalAmount.Value; //Data.BalanceAmount = resultData.BalanceAmount == null ? 0 : resultData.BalanceAmount.Value; Data.BeginDate = resultData.BeginDate; Data.EndDate = "永久有效"; Data.SalesUserName = resultData.SalesUserName == null ? "" : resultData.SalesUserName; #region 卡类型名称 SysVipCardTypeEntity SysVipCardTypeData = SysVipCardTypeBLL.GetByID(resultData.VipCardTypeID); Data.VipCardName = SysVipCardTypeData == null ? "" : SysVipCardTypeData.VipCardTypeName; #endregion #region 状态变更记录列表 var VipCardStatusChangeLogArray = VipCardStatusChangeLogBLL.Query (new IWhereCondition[] { new EqualsCondition() { FieldName = "VipCardID", Value = resultData.VipCardID } }, new OrderBy[] { new OrderBy() { FieldName = "CreateTime", Direction = OrderByDirections.Desc } }).ToList(); //转换业务对象 Data.StatusLogList = (from t in VipCardStatusChangeLogArray select new VipCardStatusChangeLog() { CreateTime = t.CreateTime.Value.ToString("yyyy-MM-dd"), UnitName = t.UnitName == null ? "" : t.UnitName, Action = t.Action == null ? "" : t.Action, ChangeReason = t.Reason == null ? "" : t.Reason, Remark = t.Remark == null ? "" : t.Remark, CreateBy = t.CreateByName, ImageUrl = t.PicUrl == null ? "" : t.PicUrl }).ToList(); #endregion } #region 会员 if (VipData != null) { Data.VipID = VipData.VIPID; Data.VipCode = VipData.VipCode; if (Data.VipCardCode == null) { Data.VipCardCode = VipData.VipCode; } if (!string.IsNullOrWhiteSpace(VipData.VipRealName)) { Data.VipName = VipData.VipRealName; } else { Data.VipName = VipData.VipName ?? ""; } Data.Phone = VipData.Phone; Data.Birthday = VipData.Birthday == null ? "" : VipData.Birthday; Data.Gender = VipData.Gender ?? 0; //Data.Integration = VipData.Integration == null ? 0 : VipData.Integration.Value; //会员创建人姓名 T_UserEntity VipUserData = null; if (resultData != null && !string.IsNullOrWhiteSpace(resultData.CreateBy)) { VipUserData = UserBLL.GetByID(resultData.CreateBy); } Data.VipCreateByName = VipUserData == null ? "" : VipUserData.user_name; Data.IDNumber = VipData.IDNumber == null ? "" : VipData.IDNumber; #region 会员生日是否可修改字段赋值 //Col22 字段赋值 ////CustomerBasicSettingEntity SettingData = CustomerBasicSettingBLL.QueryByEntity(new CustomerBasicSettingEntity() { SettingCode = "FSR_NotTwoUpdateVipBirthday" }, null).FirstOrDefault(); ////if (SettingData != null) Data.Col22 = VipData.Col22 == null ? "Y" : VipData.Col22; #endregion } #endregion #region 积分 if (IntegralData != null) { Data.Integration = IntegralData.ValidIntegral != null ? IntegralData.ValidIntegral.Value : 0; Data.CumulativeIntegral = IntegralData.CumulativeIntegral != null ? IntegralData.CumulativeIntegral.Value : 0; } #endregion #region 余额和返现 var vipAmountBLL = new VipAmountBLL(loggingSessionInfo); var vipAmountInfo = vipAmountBLL.QueryByEntity(new VipAmountEntity() { VipId = VipData.VIPID, VipCardCode = VipData.VipCode }, null).FirstOrDefault(); if (vipAmountInfo != null) { Data.TotalAmount = vipAmountInfo.TotalAmount == null ? 0 : vipAmountInfo.TotalAmount.Value; Data.BalanceAmount = vipAmountInfo.EndAmount == null ? 0 : vipAmountInfo.EndAmount.Value; Data.ValidReturnAmount = vipAmountInfo.ValidReturnAmount == null ? 0 : vipAmountInfo.ValidReturnAmount.Value; Data.TotalReturnAmount = vipAmountInfo.TotalReturnAmount == null ? 0 : vipAmountInfo.TotalReturnAmount.Value; } #endregion #endregion return(Data); }
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); } }
protected override GetPanicbuyingKJItemDetailRD ProcessRequest(APIRequest <GetPanicBuyingKJItemDetailRP> pRequest) { GetPanicBuyingKJItemDetailRP rp = pRequest.Parameters; GetPanicbuyingKJItemDetailRD rd = new GetPanicbuyingKJItemDetailRD(); OnlineShoppingItemBLL itemService = new OnlineShoppingItemBLL(CurrentUserInfo); ItemService itemServiceBll = new ItemService(CurrentUserInfo); var customerBasicSettingBll = new CustomerBasicSettingBLL(CurrentUserInfo); var panicbuyingEventBll = new PanicbuyingEventBLL(CurrentUserInfo); var panicbuyingKJEventItemMappingBll = new PanicbuyingKJEventItemMappingBLL(CurrentUserInfo); var panicbuyingKJEventSkuMappingBll = new PanicbuyingKJEventSkuMappingBLL(CurrentUserInfo); var panicbuyingKJEventJoinBll = new PanicbuyingKJEventJoinBLL(CurrentUserInfo); var panicbuyingKJEventJoinDetailBll = new PanicbuyingKJEventJoinDetailBLL(CurrentUserInfo); var vipBll = new VipBLL(CurrentUserInfo); var vipEntity = vipBll.GetByID(pRequest.UserID); if (vipEntity != null) { rd.HeadImageUrl = vipEntity.HeadImgUrl; } #region 判断是否已经参与 rd.isPromoted = 0; if (!string.IsNullOrEmpty(rp.KJEventJoinId)) { var panicbuyingKJEventJoinEntity = panicbuyingKJEventJoinBll.GetByID(rp.KJEventJoinId); if (panicbuyingKJEventJoinEntity == null) { rd.isPromoted = 0; } else { rd.isPromoted = 1; var VipData = vipBll.GetByID(panicbuyingKJEventJoinEntity.VipId); rd.HeadImageUrl = VipData.HeadImgUrl; } } #endregion //为复用原来接口所设置参数 DateTime dtBeginTime = Convert.ToDateTime("9999/01/01"); DateTime dtEndTime = Convert.ToDateTime("9999/01/01"); #region 价活动商品基本信息 KJEventItemDetailInfo eventItemInfo = panicbuyingEventBll.GetKJEventWithItemDetail(rp.EventId, rp.ItemId); if (eventItemInfo != null) { rd.ItemId = eventItemInfo.ItemId; rd.ItemName = eventItemInfo.ItemName; rd.MinPrice = eventItemInfo.MinPrice; rd.MinBasePrice = eventItemInfo.MinBasePrice; rd.SinglePurchaseQty = eventItemInfo.SinglePurchaseQty; rd.PromotePersonCount = eventItemInfo.PromotePersonCount; rd.CurrentQty = eventItemInfo.CurrentQty; rd.SoldQty = eventItemInfo.SoldQty; rd.EventEndTime = eventItemInfo.EventEndTime.ToString("yyyy-MM-dd HH:mm:ss"); rd.Seconds = Convert.ToInt64(eventItemInfo.EventEndTime.Subtract(DateTime.Now).TotalSeconds < 0 ? 0 : eventItemInfo.EventEndTime.Subtract(DateTime.Now).TotalSeconds); rd.PropName1 = eventItemInfo.Prop1Name; rd.PropName2 = eventItemInfo.Prop2Name; rd.ItemIntroduce = eventItemInfo.ItemIntroduce; #endregion #region if (eventItemInfo.EventEndTime < DateTime.Now) { rd.isEventEnd = 0; } else if (eventItemInfo.EventBeginTime > DateTime.Now) {//活动未开始 rd.isEventEnd = 2; rd.Seconds = Convert.ToInt64(eventItemInfo.EventBeginTime.Subtract(DateTime.Now).TotalSeconds < 0 ? 0 : eventItemInfo.EventBeginTime.Subtract(DateTime.Now).TotalSeconds); } else { rd.isEventEnd = 1; } #endregion #region 商品图片 var dsImages = itemService.GetItemImageList(rp.ItemId); if (dsImages != null && dsImages.Tables.Count > 0 && dsImages.Tables[0].Rows.Count > 0) { rd.ImageList = DataTableToObject.ConvertToList <ImageInfo>(dsImages.Tables[0]); } #endregion #region 商品详情页 if (rp.type == 1) { #region 关于商品所有Sku信息 var dsSkus = itemServiceBll.GetItemSkuList(rp.ItemId, pRequest.UserID, pRequest.CustomerID, dtBeginTime, dtEndTime); var panicbuyingKJEventSkuMappingList = panicbuyingKJEventSkuMappingBll.QueryByEntity(new PanicbuyingKJEventSkuMappingEntity() { EventItemMappingID = eventItemInfo.EventItemMappingID }, null).ToList(); if (dsSkus != null && dsSkus.Tables.Count > 0 && dsSkus.Tables[0].Rows.Count > 0) { rd.SkuInfoList = DataTableToObject.ConvertToList <ItemSkuInfo>(dsSkus.Tables[0]); } rd.SkuInfoList = rd.SkuInfoList.Join(panicbuyingKJEventSkuMappingList, n => n.skuId, m => m.SkuID, (n, m) => new ItemSkuInfo() { skuId = n.skuId, skuProp1 = n.skuProp1, skuProp2 = n.skuProp2, BasePrice = m.BasePrice.ToString(), price = m.Price.ToString(), SalesCount = m.SoldQty.ToString(), Stock = (m.Qty - m.SoldQty).ToString(), }).Distinct().ToList(); #endregion #region 商品属性 var dsProp1 = panicbuyingKJEventItemMappingBll.GetKJItemProp1List(rp.ItemId, rp.EventId); if (dsProp1 != null && dsProp1.Tables.Count > 0 && dsProp1.Tables[0].Rows.Count > 0) { rd.Prop1List = DataTableToObject.ConvertToList <SkuProp1>(dsProp1.Tables[0]); } #endregion rd.status = 1; } #endregion #region 帮砍页面 if (rp.type == 2 && rd.isPromoted == 1) { if (!string.IsNullOrEmpty(rp.SkuId)) { KJItemSkuInfo kJItemSkuInfo = panicbuyingKJEventSkuMappingBll.GetKJItemSkuInfo(rp.EventId, rp.SkuId, rp.KJEventJoinId); rd.SkuInfoList = new List <ItemSkuInfo>(); ItemSkuInfo itemSkuInfo = new ItemSkuInfo(); itemSkuInfo.skuId = kJItemSkuInfo.skuId; itemSkuInfo.skuProp1 = kJItemSkuInfo.skuProp1; itemSkuInfo.skuProp2 = kJItemSkuInfo.skuProp2; itemSkuInfo.price = kJItemSkuInfo.price.ToString(); itemSkuInfo.Stock = kJItemSkuInfo.Stock; rd.SkuInfoList.Add(itemSkuInfo); rd.BargainedPrice = kJItemSkuInfo.price - kJItemSkuInfo.SalesPrice; rd.MinPrice = kJItemSkuInfo.price; rd.MinBasePrice = kJItemSkuInfo.BasePrice; rd.EventSKUMappingId = kJItemSkuInfo.EventSKUMappingId; double EventTime = Convert.ToInt64(eventItemInfo.EventEndTime.Subtract(DateTime.Now).TotalSeconds < 0 ? 0 : eventItemInfo.EventEndTime.Subtract(DateTime.Now).TotalSeconds); double tempTime = (kJItemSkuInfo.CreateTime.AddHours(Convert.ToDouble(eventItemInfo.BargaingingInterval)) - DateTime.Now).TotalSeconds; if (EventTime > tempTime) { rd.Seconds = Convert.ToInt64(tempTime < 0 ? 0 : tempTime); } else { rd.Seconds = Convert.ToInt64(EventTime < 0 ? 0 : EventTime); } decimal tempPrice = rd.MinPrice - rd.MinBasePrice; if (tempPrice != 0) { rd.BargainedRate = Math.Round(rd.BargainedPrice / (tempPrice), 2); } else { rd.BargainedRate = 0; } if (!string.IsNullOrEmpty(rp.KJEventJoinId)) { var panicbuyingKJEventJoinDetailEntity = panicbuyingKJEventJoinDetailBll.QueryByEntity(new PanicbuyingKJEventJoinDetailEntity() { KJEventJoinId = new Guid(rp.KJEventJoinId), VipId = pRequest.UserID }, null).FirstOrDefault(); if (panicbuyingKJEventJoinDetailEntity == null) { rd.status = 2; } else { rd.status = 3; } } else { rd.status = 2; } } } #endregion rd.DeliveryDesc = customerBasicSettingBll.GetSettingValueByCode("DeliveryStrategy"); rd.CustomerShortName = customerBasicSettingBll.GetSettingValueByCode("CustomerShortName"); rd.WebLogo = customerBasicSettingBll.GetSettingValueByCode("WebLogo"); rd.QRCodeURL = customerBasicSettingBll.GetSettingValueByCode("GuideQRCode"); } else { throw new APIException("此活动已不存在") { ErrorCode = 100 }; } return(rd); }
/// <summary> /// pageload /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { string content = string.Empty; if (string.IsNullOrEmpty(Request["method"])) { //MenuList = DataLoader.LoadFrom<ClientMenuButtonEntity>( // new SessionManager().CurrentUserLoginInfo.UserOPRight.Tables[0], // new DirectPropertyNameMapping()).Where(c => // string.IsNullOrEmpty(c.ButtonText)).ToArray(); //var loggingSessionInfo = this.Session["loggingSessionInfo"] as LoggingSessionInfo; var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo; if (loggingSessionInfo == null) { this.Response.Redirect("~/GoSso.aspx"); } else { if (lblLoginUserName != null) { lblLoginUserName.InnerText = loggingSessionInfo.CurrentUser.User_Name;//因为ChildPage.Master的前台页面Inherits="JIT.CPOS.BS.Web.Framework.MasterPage.CPOS" 但是不含有 lblLoginUserName } } AppSysService appSysService = new AppSysService(loggingSessionInfo); this.MenuList = appSysService.GetRoleMenusList(loggingSessionInfo, loggingSessionInfo.CurrentUserRole.RoleId);//根据当前用户的角色,来取他拥有的页面 var dbMenuIds = appSysService.GetMenuIds(Request.Url); if (dbMenuIds.Count == 0 && !string.IsNullOrWhiteSpace(Mid)) { dbMenuIds.Add(Mid); } foreach (var dbMenuId in dbMenuIds) { string tempMid = string.Empty; string tempPMenuID = string.Empty; string tempMMenuID = string.Empty; if (!string.IsNullOrWhiteSpace(dbMenuId)) { tempMid = dbMenuId; } //PMenuId { var currentMenu = MenuList.Where(p => p.Menu_Id == tempMid).SingleOrDefault(); if (currentMenu != null) { if (!string.IsNullOrWhiteSpace(currentMenu.Parent_Menu_Id)) { tempPMenuID = currentMenu.Parent_Menu_Id; } } } //MMenuId { var currentMenu = MenuList.Where(p => p.Menu_Id == tempPMenuID).SingleOrDefault(); if (currentMenu != null) { if (!string.IsNullOrWhiteSpace(currentMenu.Parent_Menu_Id)) { tempMMenuID = currentMenu.Parent_Menu_Id; } } } //防止多条menuId if (!string.IsNullOrWhiteSpace(tempMMenuID)) { Mid = tempMid; PMenuID = tempPMenuID; MMenuID = tempMMenuID; break; } else if (!string.IsNullOrWhiteSpace(tempPMenuID) && string.IsNullOrWhiteSpace(PMenuID)) { Mid = tempMid; PMenuID = tempPMenuID; } else if (!string.IsNullOrWhiteSpace(tempMid) && string.IsNullOrWhiteSpace(Mid)) { Mid = tempMid; } } #region 旧代码 //this.MenuList = appSysService.GetRoleMenusList(loggingSessionInfo, // loggingSessionInfo.CurrentUserRole.RoleId);//根据当前用户的角色,来取他拥有的页面 //MMenuID = Request.QueryString["MMenuID"] == null ? "" : Request.QueryString["MMenuID"].ToString(); //PMenuID = Request.QueryString["PMenuID"] == null ? "" : Request.QueryString["PMenuID"].ToString(); //if (PMenuID == "") //{ // var currentMenu = MenuList.Where(p => p.Menu_Id == Mid).SingleOrDefault(); // if (currentMenu != null) // { // PMenuID = currentMenu.Parent_Menu_Id; // } //} //if (MMenuID == "") //{ // var currentMenu = MenuList.Where(p => p.Menu_Id == PMenuID).SingleOrDefault(); // if (currentMenu != null) // { // MMenuID = currentMenu.Parent_Menu_Id; // } //} #endregion if (!IsPostBack) { //Jermyn20140703 修改logo图片来源 CustomerBasicSettingBLL customerBSServer = new CustomerBasicSettingBLL(loggingSessionInfo); var customerBSList = customerBSServer.QueryByEntity(new CustomerBasicSettingEntity { CustomerID = loggingSessionInfo.CurrentUser.customer_id.Trim() , SettingCode = "WebLogo" , IsDelete = 0 }, null); if (customerBSList == null || customerBSList.Length == 0 || customerBSList[0] == null || customerBSList[0].SettingValue == null || customerBSList[0].SettingValue.Equals("")) { //Jermyn20131202 添加logo图片 PropService propServer = new PropService(loggingSessionInfo); string strLogo = propServer.GetWebLogo(); if (strLogo == null || strLogo.Equals("")) { } else { strWebLogo = strLogo; } } else { strWebLogo = customerBSList[0].SettingValue; } } } else { switch (Request["method"]) { case "LogOut": content = LogOut(); break; case "KeepSession": content = ""; break; } Response.Write(content); HttpContext.Current.ApplicationInstance.CompleteRequest(); //Response.End(); } }
protected override EmptyResponseData ProcessRequest(DTO.Base.APIRequest <SetRewardsSettingRP> pRequest) { var rd = new EmptyResponseData(); var para = pRequest.Parameters; var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo; var customerBasicSettingBLL = new CustomerBasicSettingBLL(loggingSessionInfo); ResponseData res = new ResponseData(); List <CustomerBasicSettingEntity> list = new List <CustomerBasicSettingEntity>(); if (para.IntegralAmountPer == 0 || para.IntegralAmountPer == null) //控制积分是否能被使用 { para.EnableIntegral = 0; } else { para.EnableIntegral = 1; } if (!string.IsNullOrEmpty(para.RewardsType.ToString())) { list.Add(new CustomerBasicSettingEntity() { SettingCode = "RewardsType", SettingValue = para.RewardsType.ToString() }); } if (!string.IsNullOrEmpty(para.EnableIntegral.ToString())) { list.Add(new CustomerBasicSettingEntity() { SettingCode = "EnableIntegral", SettingValue = para.EnableIntegral.ToString() }); } if (!string.IsNullOrEmpty(para.EnableRewardCash.ToString())) { list.Add(new CustomerBasicSettingEntity() { SettingCode = "EnableRewardCash", SettingValue = para.EnableRewardCash.ToString() }); } if (!string.IsNullOrEmpty(para.RewardPointsPer.ToString())) { list.Add(new CustomerBasicSettingEntity() { SettingCode = "RewardPointsPer", SettingValue = para.RewardPointsPer.ToString() }); } if (!string.IsNullOrEmpty(para.IntegralAmountPer.ToString())) { list.Add(new CustomerBasicSettingEntity() { SettingCode = "IntegralAmountPer", SettingValue = para.IntegralAmountPer.ToString() }); } if (!string.IsNullOrEmpty(para.RewardCashPer.ToString())) { list.Add(new CustomerBasicSettingEntity() { SettingCode = "RewardCashPer", SettingValue = para.RewardCashPer.ToString() }); } if (!string.IsNullOrEmpty(para.PointsRedeemUpLimit.ToString())) { list.Add(new CustomerBasicSettingEntity() { SettingCode = "PointsRedeemUpLimit", SettingValue = para.PointsRedeemUpLimit.ToString() }); } if (!string.IsNullOrEmpty(para.CashRedeemUpLimit.ToString())) { list.Add(new CustomerBasicSettingEntity() { SettingCode = "CashRedeemUpLimit", SettingValue = para.CashRedeemUpLimit.ToString() }); } if (!string.IsNullOrEmpty(para.PointsRedeemLowestLimit.ToString())) { list.Add(new CustomerBasicSettingEntity() { SettingCode = "PointsRedeemLowestLimit", SettingValue = para.PointsRedeemLowestLimit.ToString() }); } if (!string.IsNullOrEmpty(para.CashRedeemLowestLimit.ToString())) { list.Add(new CustomerBasicSettingEntity() { SettingCode = "CashRedeemLowestLimit", SettingValue = para.CashRedeemLowestLimit.ToString() }); } if (!string.IsNullOrEmpty(para.PointsOrderUpLimit.ToString())) { list.Add(new CustomerBasicSettingEntity() { SettingCode = "PointsOrderUpLimit", SettingValue = para.PointsOrderUpLimit.ToString() }); } if (!string.IsNullOrEmpty(para.CashOrderUpLimit.ToString())) { list.Add(new CustomerBasicSettingEntity() { SettingCode = "CashOrderUpLimit", SettingValue = para.CashOrderUpLimit.ToString() }); } if (!string.IsNullOrEmpty(para.PointsValidPeriod.ToString())) { list.Add(new CustomerBasicSettingEntity() { SettingCode = "PointsValidPeriod", SettingValue = para.PointsValidPeriod.ToString() }); } if (!string.IsNullOrEmpty(para.CashValidPeriod.ToString())) { list.Add(new CustomerBasicSettingEntity() { SettingCode = "CashValidPeriod", SettingValue = para.CashValidPeriod.ToString() }); } int i = customerBasicSettingBLL.SaveCustomerBasicInfo(loggingSessionInfo.ClientID, list); return(rd); }
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)); } }
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)); } }
protected override GetConfigRD ProcessRequest(DTO.Base.APIRequest <GetConfigRP> pRequest) { var rd = new GetConfigRD(); var customerId = CurrentUserInfo.ClientID; var trrBll = new T_RewardRecordBLL(CurrentUserInfo);//打赏记录 var userBll = new T_UserBLL(CurrentUserInfo); var cbsBll = new CustomerBasicSettingBLL(CurrentUserInfo); var trcBll = new T_RewardConfigBLL(CurrentUserInfo); var cbsEntity = cbsBll.QueryByEntity(new CustomerBasicSettingEntity() { CustomerID = customerId }, null).FirstOrDefault(); var trcEntitys = trcBll.QueryByEntity(new T_RewardConfigEntity() { CustomerId = customerId }, null); //获取员工 var userInfo = new T_UserEntity(); var employeeId = pRequest.Parameters.EmployeeID; if (!string.IsNullOrEmpty(employeeId)) { userInfo = userBll.QueryByEntity(new T_UserEntity() { user_id = employeeId, customer_id = customerId }, null).FirstOrDefault(); //员工头像 var _ObjectImagesBLL = new ObjectImagesBLL(CurrentUserInfo); var userImg = _ObjectImagesBLL.QueryByEntity(new ObjectImagesEntity() { ObjectId = employeeId, CustomerId = customerId }, null).OrderByDescending(p => p.CreateTime).FirstOrDefault(); //星级 var oeBll = new ObjectEvaluationBLL(CurrentUserInfo); var oeList = oeBll.QueryByEntity(new ObjectEvaluationEntity() { ObjectID = employeeId, Type = 4, CustomerID = customerId }, null); var oeinfo = (from p in oeList.AsEnumerable() group p by p.ObjectID into g select new { g.Key, SumValue = g.Average(p => p.StarLevel) }).ToArray().FirstOrDefault(); //打赏数据 var rewardCount = trrBll.QueryByEntity(new T_RewardRecordEntity() { RewardedOP = employeeId, PayStatus = 2, CustomerId = customerId }, null).Length; //员工信息 rd.UserInfo = new List <UserInfo>(); rd.UserInfo.Add(new UserInfo() { UserName = userInfo.user_name, UserPhoto = userImg != null ? userImg.ImageURL : string.Empty, StarLevel = oeinfo != null ? Convert.ToInt32(oeinfo.SumValue) : 0, RewardCount = rewardCount }); } //打赏类型 if (cbsEntity != null) { switch (cbsEntity.SettingValue) { case "1": rd.Type = 1; break; case "2": rd.Type = 2; break; default: rd.Type = 0; //0或空(null)为两者 break; } } else { rd.Type = 0;//两者 } //打赏金额列表 rd.AmountList = new List <RewardAmountInfo>(); foreach (var item in trcEntitys) { rd.AmountList.Add(new RewardAmountInfo() { Amount = item.RewardAmount }); } return(rd); }
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); }
public string GetCustomerBasicSetting(string pRequest) { CustomerBasicSettingRD rd = new CustomerBasicSettingRD(); try { var rp = pRequest.DeserializeJSONTo <APIRequest <EmptyRequestParameter> >(); var loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, "1"); var bll = new CustomerBasicSettingBLL(loggingSessionInfo); var ds = bll.GetCustomerBaiscSettingInfo(rp.CustomerID); //获取CusertomerBaiscSettingInfo中配置的数据 var dtBasicSetting = bll.GetBaiscSettingInfoFromRedis(rp.CustomerID); List <CustomerImageInfo> list = new List <CustomerImageInfo> { }; Dictionary <string, string> DicVersion = new Dictionary <string, string>(); if (ds != null && ds.Tables.Count > 0) { if (dtBasicSetting.Rows.Count > 0) { for (int i = 0; i < dtBasicSetting.Rows.Count; i++) { DataRow row = dtBasicSetting.Rows[i]; if (row["SettingCode"].ToString().Equals("AboutUs")) { rd.AboutUs = DicVersion[row["SettingCode"].ToString()] = row["SettingValue"].ToString(); } if (row["SettingCode"].ToString().Equals("BrandRelated")) { rd.BrandRelated = DicVersion[row["SettingCode"].ToString()] = row["SettingValue"].ToString(); } if (row["SettingCode"].ToString().Equals("BrandStory")) { rd.BrandStory = DicVersion[row["SettingCode"].ToString()] = row["SettingValue"].ToString(); } if (row["SettingCode"].ToString().Equals("IntegralAmountPer")) { rd.IntegralAmountPer = DicVersion[row["SettingCode"].ToString()] = row["SettingValue"].ToString(); } if (row["SettingCode"].ToString().Equals("SMSSign")) { rd.SMSSign = DicVersion[row["SettingCode"].ToString()] = row["SettingValue"].ToString(); } if (row["SettingCode"].ToString().Equals("ForwardingMessageLogo")) { rd.ForwardingMessageLogo = DicVersion[row["SettingCode"].ToString()] = row["SettingValue"].ToString(); } if (row["SettingCode"].ToString().Equals("ForwardingMessageTitle")) { rd.ForwardingMessageTitle = DicVersion[row["SettingCode"].ToString()] = row["SettingValue"].ToString(); } if (row["SettingCode"].ToString().Equals("ForwardingMessageSummary")) { rd.ForwardingMessageSummary = DicVersion[row["SettingCode"].ToString()] = row["SettingValue"].ToString(); } if (row["SettingCode"].ToString().Equals("WhatCommonPoints")) { rd.WhatCommonPoints = DicVersion[row["SettingCode"].ToString()] = row["SettingValue"].ToString(); } if (row["SettingCode"].ToString().Equals("GetPoints")) { rd.GetPoints = DicVersion[row["SettingCode"].ToString()] = row["SettingValue"].ToString(); } if (row["SettingCode"].ToString().Equals("SetSalesPoints")) { rd.SetSalesPoints = DicVersion[row["SettingCode"].ToString()] = row["SettingValue"].ToString(); } } } if (ds.Tables[1].Rows.Count > 0) { foreach (DataRow item in ds.Tables[1].Rows) { var ImageList = new CustomerImageInfo() { ImageId = item["ImageId"].ToString(), ImageUrl = item["ImageUrl"].ToString() }; list.Add(ImageList); } } rd.ImageList = list.ToArray(); //图片集合 } var rsp = new SuccessResponse <IAPIResponseData>(rd); return(rsp.ToJSON()); } catch (Exception ex) { throw new APIException(ex.Message); } }
protected override SetSignInRD ProcessRequest(DTO.Base.APIRequest <SetSignInRP> pRequest) { SetSignInRD rd = new SetSignInRD(); string customerCode = pRequest.Parameters.CustomerCode; string phone = pRequest.Parameters.LoginName; string password = pRequest.Parameters.Password; if (string.IsNullOrEmpty(customerCode)) { throw new APIException("客户代码不能为空") { ErrorCode = Error_CustomerCode_NotNull }; } WMenuBLL menuServer = new WMenuBLL(Default.GetAPLoggingSession("")); string customerId = menuServer.GetCustomerIDByCustomerCode(customerCode); if (string.IsNullOrEmpty(customerId)) { throw new APIException("客户代码对应的客户不存在") { ErrorCode = Error_CustomerCode_NotExist }; } var currentUserInfo = Default.GetBSLoggingSession(customerId, "1"); VipBLL vipBll = new VipBLL(currentUserInfo); #region 判断用户是否存在 if (!vipBll.JudgeUserExist(phone, customerId)) { throw new APIException("用户名无效") { ErrorCode = Error_UserName_InValid }; } #endregion #region 判断密码是否正确 if (!vipBll.JudgeUserPasswordExist(phone, customerId, password)) { throw new APIException("登录密码错误") { ErrorCode = Error_Password_InValid }; } #endregion #region 判断是否有登录连锁掌柜App权限 var userRolesDs = vipBll.GetUserRoles(phone, customerId, password); bool flag = false; foreach (DataRow row in userRolesDs.Tables[0].Rows) { if (row["Def_App_Code"].ToString().ToUpper() == "APP") { flag = true; break; } } if (!flag) { throw new APIException("该账号无权登录本系统") { ErrorCode = Error_Password_InValid }; } #endregion #region 判断该客服人员是否有客服或操作订单的权限 //if (!vipBll.JudgeUserRoleExist(phone, customerId, password)) //{ // throw new APIException("该账号无权登录本系统") { ErrorCode = Error_Password_InValid }; //} #endregion #region 获取UserId var ds = vipBll.GetUserIdByUserNameAndPassword(phone, customerId, password); rd.UserId = ds.Tables[0].Rows[0]["user_id"].ToString(); rd.UserName = ds.Tables[0].Rows[0]["user_name"].ToString(); rd.Status = int.Parse(ds.Tables[0].Rows[0]["user_status"].ToString()); rd.CustomerId = customerId; var T_SuperRetailTraderbll = new T_SuperRetailTraderBLL(currentUserInfo); var T_SuperRetailTraderInfo = T_SuperRetailTraderbll.QueryByEntity(new T_SuperRetailTraderEntity() { CustomerId = customerId, SuperRetailTraderFromId = rd.UserId, SuperRetailTraderFrom = "User" }, new OrderBy[] { new OrderBy() { FieldName = "CreateTime", Direction = OrderByDirections.Desc } }).FirstOrDefault(); if (T_SuperRetailTraderInfo != null) { rd.SuperRetailTraderID = T_SuperRetailTraderInfo.SuperRetailTraderID.ToString(); } #endregion //如果状态不等于1,就说明已经停用, if (rd.Status != 1) { throw new APIException("该员工已经被停用,请联系管理员") { ErrorCode = Error_Password_InValid }; } #region 获取角色列表 var roleCodeDs = vipBll.GetRoleCodeByUserId(rd.UserId, customerId); var tmp = roleCodeDs.Tables[0].AsEnumerable().Select(t => new RoleCodeInfo() { RoleCode = t["role_code"].ToString() }); #endregion rd.UnitId = vipBll.GetUnitByUserId(rd.UserId);//获取会集店 TUnitBLL tUnitBLL = new TUnitBLL(currentUserInfo); if (!string.IsNullOrEmpty(rd.UnitId)) { rd.UnitName = tUnitBLL.GetByID(rd.UnitId).UnitName; } else { rd.UnitName = ""; } //app登陆用户权限 add by henry 2015-3-26 var roleCodeList = vipBll.GetAppMenuByUserId(rd.UserId); //app登陆用户权限 add by henry 2015-3-26 List <string> lst = new List <string>(); if (roleCodeDs.Tables[0] != null && roleCodeDs.Tables[0].Rows.Count > 0) { foreach (DataRow item in roleCodeDs.Tables[0].Rows) { var menuList = new JIT.CPOS.BS.DataAccess.AppSysService(currentUserInfo).GetRoleMenus(currentUserInfo.ClientID, item["role_id"] + ""); if (menuList != null) { lst.AddRange(menuList.Select(m => m.Menu_Code).Distinct().ToList()); } } } rd.MenuCodeList = new List <Menu>(); foreach (var item in lst.Distinct().ToList()) { rd.MenuCodeList.Add(new Menu() { MenuCode = item }); } //if (roleCodeList != null) //{ // rd.MenuCodeList = DataTableToObject.ConvertToList<Menu>(roleCodeList.Tables[0]); //} rd.RoleCodeList = tmp.ToArray(); rd.CustomerName = currentUserInfo.ClientName; //销售员头像 ObjectImagesBLL _ObjectImagesBLL = new ObjectImagesBLL(currentUserInfo); ObjectImagesEntity en = new ObjectImagesEntity(); en.ObjectId = rd.UserId;//根据获取的用户ID List <ObjectImagesEntity> ImgList = _ObjectImagesBLL.QueryByEntity(en, null).OrderByDescending(p => p.CreateTime).ToList(); if (ImgList != null && ImgList.Count != 0) { // string fileDNS = customerBasicSettingBll.GetSettingValueByCode("FileDNS"); ;//http://182.254.156.57:811 rd.HeadImg = ImgList[0].ImageURL; } #region 获取appLogo //基础数据初始化 CustomerBasicSettingBLL customerBasicSettingBLL = new CustomerBasicSettingBLL(currentUserInfo); List <CustomerBasicCodeInfo> customerBasicCodeList = new List <CustomerBasicCodeInfo>(); //查询条件 CustomerBasicSettingEntity customerBasicSettingEntity = new CustomerBasicSettingEntity() { CustomerID = currentUserInfo.ClientID, SettingCode = "WebLogo" }; //执行查询 List <CustomerBasicSettingEntity> customerBasicSettingEntityList = customerBasicSettingBLL.QueryByEntity(customerBasicSettingEntity, null).ToList(); foreach (var a in customerBasicSettingEntityList) { CustomerBasicCodeInfo customerBasicCodeInfo = new CustomerBasicCodeInfo(); if (a.SettingCode.Equals("WebLogo")) { customerBasicCodeInfo.WebLogo = a.SettingValue.ToString(); } customerBasicCodeList.Add(customerBasicCodeInfo); } rd.CustomerBasicCodeList = customerBasicCodeList; #endregion 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; } } }
protected override EmptyResponseData ProcessRequest(DTO.Base.APIRequest <SetBusinessBasisConfigRP> pRequest) { var rd = new EmptyResponseData(); var para = pRequest.Parameters; var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo; var customerBasicSettingBLL = new CustomerBasicSettingBLL(loggingSessionInfo); //ap库配置 //var APloggingSessionInfo = Default.GetBSLoggingSession(loggingSessionInfo.ClientID, "1"); //APloggingSessionInfo.CurrentLoggingManager.Connection_String = ConfigurationManager.AppSettings["Conn_ap"]; //var t_customerBLL = new t_customerBLL(APloggingSessionInfo); #region 基础配置集合赋值 var list = new List <CustomerBasicSettingEntity>(); if (!string.IsNullOrWhiteSpace(para.CustomerShortName)) { //var APCustomerData = t_customerBLL.GetByID(APloggingSessionInfo.ClientID); //if (APCustomerData != null) //{ // APCustomerData.customer_name = para.customer_name; // t_customerBLL.Update(APCustomerData); //} list.Add(new CustomerBasicSettingEntity() {//商户简称 SettingCode = "CustomerShortName", SettingValue = para.CustomerShortName }); } if (!string.IsNullOrWhiteSpace(para.WebLogo)) { list.Add(new CustomerBasicSettingEntity() {//商户Logo //SettingCode = "BusinessLogo", SettingCode = "WebLogo", SettingValue = para.WebLogo }); } if (!string.IsNullOrWhiteSpace(para.CustomerPhone)) { list.Add(new CustomerBasicSettingEntity() {//客服电话 SettingCode = "CustomerPhone", SettingValue = para.CustomerPhone }); } if (!string.IsNullOrWhiteSpace(para.ForwardingMessageTitle)) { list.Add(new CustomerBasicSettingEntity() {//分享标题 //SettingCode = "ShareTitle", SettingCode = "ForwardingMessageTitle", SettingValue = para.ForwardingMessageTitle }); } if (!string.IsNullOrWhiteSpace(para.ForwardingMessageLogo)) { list.Add(new CustomerBasicSettingEntity() {//分享图片 //SettingCode = "ShareImageUrl", SettingCode = "ForwardingMessageLogo", SettingValue = para.ForwardingMessageLogo }); } if (!string.IsNullOrWhiteSpace(para.ForwardingMessageSummary)) { list.Add(new CustomerBasicSettingEntity() {//分享摘要内容 //SettingCode = "ShareContent", SettingCode = "ForwardingMessageSummary", SettingValue = para.ForwardingMessageSummary }); } if (!string.IsNullOrWhiteSpace(para.GuideLinkUrl)) { list.Add(new CustomerBasicSettingEntity() {//引导链接 SettingCode = "GuideLinkUrl", SettingValue = para.GuideLinkUrl }); } if (!string.IsNullOrWhiteSpace(para.GuideQRCode)) { list.Add(new CustomerBasicSettingEntity() {//引导二维码 SettingCode = "GuideQRCode", SettingValue = para.GuideQRCode }); } if (!string.IsNullOrWhiteSpace(para.CustomerGreeting)) { list.Add(new CustomerBasicSettingEntity() {//客服欢迎语 SettingCode = "CustomerGreeting", SettingValue = para.CustomerGreeting }); } else { list.Add(new CustomerBasicSettingEntity() {//客服欢迎语 SettingCode = "CustomerGreeting", SettingValue = "感谢您关注" + para.CustomerShortName + "!您的支持是我们无限的动力~", }); } #endregion if (list.Count > 0) { customerBasicSettingBLL.SaveCustomerBasicInfo(loggingSessionInfo.ClientID, list); } //发布到js文件里 EmptyRequest commonRequest = new EmptyRequest(); commonRequest.Parameters = new EmptyRequestParameter(); commonRequest.UserID = ""; commonRequest.CustomerID = CurrentUserInfo.ClientID; commonRequest.OpenID = ""; commonRequest.Token = Guid.NewGuid().ToString(); commonRequest.ChannelId = ""; commonRequest.Locale = "1"; //发布 var url = ConfigurationManager.AppSettings["interfacehost"] + "/ApplicationInterface/Gateway.ashx"; //正式 //var url = "http://121.199.42.125:5012/Gateway.ashx"; //测试 if (string.IsNullOrEmpty(url)) { throw new Exception("未配置平台接口URL:interfacehost"); } url += "?type=Product&action=WX.SysPage.CreateCustomerConfig"; var postContent = string.Format("req={0}", commonRequest.ToJSON()); var strAldRsp = HttpWebClient.DoHttpRequest(url, postContent); var aldRsp = strAldRsp.DeserializeJSONTo <CreateCustomerConfigReponse>(); if (aldRsp == null || aldRsp.ResultCode != 0 || !aldRsp.IsSuccess) { throw new Exception("发布配置到文件失败"); } return(rd); }
/// <summary> /// 上传图片通用方法 /// </summary> /// <param name="pRequest"></param> /// <returns></returns> protected string UploadFiles(string pRequest) { var rp = pRequest.DeserializeJSONTo <APIRequest <UploadFilesRP> >(); rp.Parameters.Validate(); var loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, rp.UserID); var rd = new EmptyRD(); var objectImageBll = new ObjectImagesBLL(loggingSessionInfo); //图片BLL实例化 var customerBasicSettingBll = new CustomerBasicSettingBLL(loggingSessionInfo); string expandName = rp.Parameters.ExpandName; //随机生成文件名称 string fileName = StringUtil.GetRandomStr(18).ToLower() + "." + expandName; //允许上传的扩展名 string allowExpandName = customerBasicSettingBll.GetSettingValueByCode("AllowUploadExpandName"); allowExpandName = !string.IsNullOrEmpty(allowExpandName) ? allowExpandName : "gif,jpg,jpeg,png,bmp";//设置缺省图片格式 //不允许 if (allowExpandName.IndexOf(expandName) == -1) { var rsp = new SuccessResponse <IAPIResponseData>(rd); rsp.ResultCode = 1; rsp.Message = "请上传" + allowExpandName + "格式的文件"; return(rsp.ToJSON()); } //转base64的编码,获取流 MemoryStream stream = new MemoryStream(Convert.FromBase64String(rp.Parameters.Base64str)); byte[] bytes = new byte[stream.Length]; stream.Read(bytes, 0, bytes.Length); stream.Seek(0, SeekOrigin.Begin); if (allowExpandName.IndexOf(expandName) > -1) { //允许上传的图片最大限制 string uploadImageMax = customerBasicSettingBll.GetSettingValueByCode("UploadImageMax"); if (!string.IsNullOrEmpty(uploadImageMax)) { int maxSize = int.Parse(uploadImageMax); if (stream.Length > maxSize) { var rsp = new SuccessResponse <IAPIResponseData>(rd); rsp.ResultCode = 1; rsp.Message = "请上传" + maxSize + "M以内的图片"; return(rsp.ToJSON()); } } } //文件目录 string uploadFilePath = customerBasicSettingBll.GetSettingValueByCode("UploadFilePath"); uploadFilePath = string.IsNullOrEmpty(uploadFilePath)? "/Images/":uploadFilePath;//如果为空,就取默认的 uploadFilePath += DateTime.Now.Year + "/" + DateTime.Now.Month + "." + DateTime.Now.Day + "/"; if (!IOUtil.ExistsFile(IOUtil.MapPath(uploadFilePath))) { IOUtil.CreateDirectoryIfNotExists(IOUtil.MapPath(uploadFilePath)); } // 把 byte[] 写入文件 FileStream fs = new FileStream(IOUtil.MapPath(uploadFilePath) + fileName, FileMode.Create);//通过IOUtil.MapPath由网络目录转换成物理目录 BinaryWriter bw = new BinaryWriter(fs); bw.Write(bytes); bw.Close(); fs.Close(); objectImageBll.Create(new ObjectImagesEntity() { ImageId = Guid.NewGuid().ToString(), ObjectId = rp.Parameters.ObjectID, ImageURL = uploadFilePath + fileName }); //文件DNS地址 string fileDNS = customerBasicSettingBll.GetSettingValueByCode("FileDNS");; var rsp1 = new SuccessResponse <IAPIResponseData>(rd); rsp1.Message = fileDNS + uploadFilePath + fileName;//当前上传的图片路径 return(rsp1.ToJSON()); }