/// <summary> /// 推广分享设置 /// </summary> /// <param name="para"></param> /// <param name="bllSpreadSetting"></param> /// <param name="imageBll"></param> public void SaveSpreadSetting(SetCTWEventRP para, T_CTW_SpreadSettingBLL bllSpreadSetting, ObjectImagesBLL imageBll, WApplicationInterfaceEntity wapentity, out string QRCodeUrl) { QRCodeUrl = string.Empty; string QRCodeId = string.Empty; if (!string.IsNullOrEmpty(para.CTWEventId)) { bllSpreadSetting.DeleteByCTWEventID(para.CTWEventId); } foreach (var sItem in para.SpreadSettingList) { var bgimageEntity = new ObjectImagesEntity(); bgimageEntity.ImageURL = sItem.BGImageUrl; bgimageEntity.ObjectId = ""; bgimageEntity.CreateBy = loggingSessionInfo.UserID; bgimageEntity.IsDelete = 0; bgimageEntity.CustomerId = loggingSessionInfo.ClientID; bgimageEntity.ImageId = Guid.NewGuid().ToString(); imageBll.Create(bgimageEntity); if (sItem.SpreadType == "Focus") { bool IsSuccess = true; CreateFocusQRCode(para, sItem.LogoUrl, wapentity, out QRCodeUrl, out QRCodeId, out IsSuccess); if (!IsSuccess) { throw new APIException(111, "关注二维码生成失败!请重新提交"); } //imageEntity = new ObjectImagesEntity(); //imageEntity.ImageURL = QRCodeUrl; //imageEntity.ObjectId = ""; //imageEntity.CreateBy = loggingSessionInfo.UserID; //imageEntity.IsDelete = 0; //imageEntity.CustomerId = loggingSessionInfo.ClientID; //imageEntity.ImageId = Guid.NewGuid().ToString(); //imageBll.Create(imageEntity); } entitySpreadSetting = new T_CTW_SpreadSettingEntity() { SpreadType = sItem.SpreadType, Title = sItem.Title, ImageId = bgimageEntity.ImageId, Summary = sItem.Summary, PromptText = sItem.PromptText, LeadPageQRCodeImageId = QRCodeId, LeadPageSharePromptText = sItem.LeadPageSharePromptText, LeadPageFocusPromptText = sItem.LeadPageFocusPromptText, LeadPageRegPromptText = sItem.LeadPageRegPromptText, LogoUrl = sItem.LogoUrl, CustomerId = loggingSessionInfo.ClientID, CTWEventId = new Guid(strCTWEventId) }; bllSpreadSetting.Create(entitySpreadSetting); } }
/// <summary> /// 保存更新促销活动信息 /// </summary> /// <param name="para"></param> /// <returns></returns> public void SavePanicbuyingEvent(SetCTWEventRP para, T_CTW_PanicbuyingEventKVBLL bllPanicbuyingEventKV, ObjectImagesBLL imageBll, T_CTW_LEventInteractionBLL bllCustomerInteraction, string strThemeId, out string strStartDate, out string strEndDate) { strStartDate = string.Empty; strEndDate = string.Empty; var PanicbuyingEvent = para.PanicbuyingEventInfo; imageEntity = new ObjectImagesEntity(); imageEntity.ImageURL = PanicbuyingEvent.ImageUrl; imageEntity.ObjectId = ""; imageEntity.CreateBy = loggingSessionInfo.UserID; imageEntity.IsDelete = 0; imageEntity.CustomerId = loggingSessionInfo.ClientID; imageEntity.ImageId = Guid.NewGuid().ToString(); imageBll.Create(imageEntity); if (!string.IsNullOrEmpty(para.CTWEventId)) { bllPanicbuyingEventKV.DeleteByCTWEventID(para.CTWEventId); } entityPanicbuyingEventKV = new T_CTW_PanicbuyingEventKVEntity() { CTWEventId = new Guid(strCTWEventId), EventName = PanicbuyingEvent.EventName, ImageId = imageEntity.ImageId }; bllPanicbuyingEventKV.Create(entityPanicbuyingEventKV); if (!string.IsNullOrEmpty(para.CTWEventId)) { bllCustomerInteraction.DeleteByCTWEventID(para.CTWEventId); } foreach (var eventid in PanicbuyingEvent.PanicbuyingEventId) { ///互动类型与(游戏或促销)关联 entityInteraction = new T_CTW_LEventInteractionEntity() { CTWEventId = new Guid(strCTWEventId), ThemeId = new Guid(strThemeId), InteractionType = para.InteractionType, DrawMethodCode = para.DrawMethodCode, LeventId = eventid.ToString(), CustomerId = loggingSessionInfo.ClientID }; bllCustomerInteraction.Create(entityInteraction); } DataSet ds = bllCustomerInteraction.GetPanicbuyingEventDate(strCTWEventId); if (ds != null && ds.Tables[0].Rows.Count > 0) { strStartDate = ds.Tables[0].Rows[0]["BeginTime"].ToString(); strEndDate = ds.Tables[0].Rows[0]["EndTime"].ToString(); } }
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 EmptyResponseData ProcessRequest(APIRequest <SetVipAmountRP> pRequest) { var rd = new EmptyResponseData(); var para = pRequest.Parameters; var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo; //登录状态信息 var vipAmountBLL = new VipAmountBLL(loggingSessionInfo); var vipAmountDetailBLL = new VipAmountDetailBLL(loggingSessionInfo); var objectImagesBLL = new ObjectImagesBLL(loggingSessionInfo); //图片表业务对象实例化 var unitBLL = new t_unitBLL(loggingSessionInfo); var vipBLL = new VipBLL(loggingSessionInfo); var vipInfo = vipBLL.GetByID(para.VipID); var unitInfo = unitBLL.GetByID(loggingSessionInfo.CurrentUserRole.UnitId); var pTran = vipAmountBLL.GetTran(); //事务 var vipAmountEntity = vipAmountBLL.QueryByEntity(new VipAmountEntity() { VipId = vipInfo.VIPID, VipCardCode = vipInfo.VipCode }, null).FirstOrDefault(); using (pTran.Connection) { try { var amountDetail = new VipAmountDetailEntity() { Amount = para.Amount, AmountSourceId = para.AmountSourceID, ObjectId = "", Reason = para.Reason, Remark = para.Remark }; string vipAmountDetailId = string.Empty; if (para.AmountSourceID == "23") { //人工调整余额 vipAmountDetailId = vipAmountBLL.AddVipAmount(vipInfo, unitInfo, ref vipAmountEntity, amountDetail, pTran, loggingSessionInfo); if (!string.IsNullOrWhiteSpace(vipAmountDetailId)) {//发送微信账户余额变动模板消息 var CommonBLL = new CommonBLL(); CommonBLL.BalanceChangedMessage("人工调整", vipAmountEntity, amountDetail, vipInfo.WeiXinUserId, vipInfo.VIPID, loggingSessionInfo); } } else if (para.AmountSourceID == "24") { //人工调整返现 vipAmountDetailId = vipAmountBLL.AddReturnAmount(vipInfo, unitInfo, vipAmountEntity, ref amountDetail, pTran, loggingSessionInfo); if (!string.IsNullOrWhiteSpace(vipAmountDetailId)) {//发送返现到账通知微信模板消息 var CommonBLL = new CommonBLL(); CommonBLL.CashBackMessage("人工调整", amountDetail.Amount, vipInfo.WeiXinUserId, vipInfo.VIPID, loggingSessionInfo); } } //增加图片上传 if (!string.IsNullOrEmpty(para.ImageUrl)) { var objectImagesEntity = new ObjectImagesEntity() { ImageId = Guid.NewGuid().ToString(), ObjectId = vipAmountDetailId, ImageURL = para.ImageUrl }; objectImagesBLL.Create(objectImagesEntity); } pTran.Commit(); //提交事物 } catch (APIException apiEx) { pTran.Rollback();//回滚事物 throw new APIException(apiEx.ErrorCode, apiEx.Message); } catch (Exception ex) { pTran.Rollback();//回滚事物 throw new Exception(ex.Message); } } return(rd); }
protected override EmptyResponseData ProcessRequest(APIRequest <SetExtendRP> pRequest) { //SessionManager.GetLoggingSessionByCustomerId(pRequest.CustomerID); var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo; if (loggingSessionInfo == null) { throw new APIException("用户未登录") { ErrorCode = ERROR_CODES.INVALID_REQUEST } } ; var bll = new SetoffEventBLL(this.CurrentUserInfo); var objectImagesBll = new ObjectImagesBLL(this.CurrentUserInfo); var setoffToolsBll = new SetoffToolsBLL(this.CurrentUserInfo); var setoffPosterBll = new SetoffPosterBLL(this.CurrentUserInfo); var setoffEventBll = new SetoffEventBLL(this.CurrentUserInfo); var pTran = bll.GetTran(); //获取已发布的集客行动 var SetoffEvenResult = bll.QueryByEntity(new SetoffEventEntity() { SetoffType = 3, Status = "10" }, null).ToList(); if (SetoffEvenResult.Count > 1) { throw new APIException("数据异常,只能一条分销拓展!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS } } ; else if (SetoffEvenResult.Count == 1) { var Result = SetoffEvenResult.First(); #region 新增招募海报、海报集客工具关系 foreach (var PosterItem in pRequest.Parameters.PosterList) { //图片表 var ObjectImageData = new ObjectImagesEntity(); ObjectImageData.ImageId = System.Guid.NewGuid().ToString("N"); ObjectImageData.ImageURL = PosterItem.ImageUrl; ObjectImageData.Description = "招募海报"; ObjectImageData.CustomerId = loggingSessionInfo.ClientID; 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 = loggingSessionInfo.ClientID; 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 = loggingSessionInfo.ClientID; setoffToolsBll.Create(SetoffToolsData);// } #endregion #region 新增集客工具关系 foreach (var ToolsItem in pRequest.Parameters.CommonList) { 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 = loggingSessionInfo.ClientID; setoffToolsBll.Create(SetoffToolsData);// } #endregion } else { //原集客行动状态设置为失效 setoffEventBll.SetFailStatus(3); #region 新建集客行动 //集客行动 var SetoffEvenData = new SetoffEventEntity();//集客行动 SetoffEvenData.SetoffEventID = System.Guid.NewGuid(); SetoffEvenData.SetoffType = 3; SetoffEvenData.Status = "10"; SetoffEvenData.CustomerId = loggingSessionInfo.ClientID; setoffEventBll.Create(SetoffEvenData);// #region 新增集客海报、海报集客工具关系 foreach (var PosterItem in pRequest.Parameters.PosterList) { //图片表 var ObjectImageData = new ObjectImagesEntity(); ObjectImageData.ImageId = System.Guid.NewGuid().ToString("N"); ObjectImageData.ImageURL = PosterItem.ImageUrl; ObjectImageData.Description = "招募海报"; ObjectImageData.CustomerId = loggingSessionInfo.ClientID; 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 = loggingSessionInfo.ClientID; 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 = loggingSessionInfo.ClientID; setoffToolsBll.Create(SetoffToolsData);// } #endregion #region 新增集客工具关系 foreach (var ToolsItem in pRequest.Parameters.CommonList) { //判断是否添加重复集客工具 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 = loggingSessionInfo.ClientID; setoffToolsBll.Create(SetoffToolsData);// } #endregion #endregion } return(new EmptyResponseData()); } } }
protected override SetVipCardRD ProcessRequest(DTO.Base.APIRequest <SetVipCardRP> pRequest) { var rd = new SetVipCardRD(); var para = pRequest.Parameters; var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo; #region 业务对象 //会员卡 var VipCardBLL = new VipCardBLL(loggingSessionInfo); //余额变动记录 var VipCardBalanceChangeBLL = new VipCardBalanceChangeBLL(loggingSessionInfo); //卡状态变更记录 var VipCardStatusChangeLogBLL = new VipCardStatusChangeLogBLL(loggingSessionInfo); //卡关系 var VipCardVipMappingBLL = new VipCardVipMappingBLL(loggingSessionInfo); //图片 var objectImagesBLL = new ObjectImagesBLL(loggingSessionInfo); //会员 var VipBLL = new VipBLL(loggingSessionInfo); var vipCardTransLogBLL = new VipCardTransLogBLL(loggingSessionInfo); //丰收日交易记录对象示例化 var unitBLL = new TUnitBLL(loggingSessionInfo); //门店业务对象 //事务 var pTran = VipCardBLL.GetTran(); #endregion using (pTran.Connection) { try { if (string.IsNullOrWhiteSpace(para.VipCardID) || para.OperationType <= 0) { throw new APIException("卡ID或者操作类型参数不合法!") { ErrorCode = ERROR_CODES.INVALID_REQUEST_LACK_REQUEST_PARAMETER }; } //定位当前卡业务对象 VipCardEntity changeEntity = VipCardBLL.GetByID(para.VipCardID); if (changeEntity == null) { throw new APIException("当前卡信息对象为NULL!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS }; } #region 返回卡ID rd.VipCardID = changeEntity.VipCardID; #endregion changeEntity.RechargeTotalAmount = changeEntity.RechargeTotalAmount ?? 0; changeEntity.BalanceAmount = changeEntity.BalanceAmount ?? 0; string OldVipCardCode = changeEntity.VipCardCode ?? ""; //原卡号 string NewVipCardCode = ""; //新卡号,获取新卡赋值 decimal OldMoney = changeEntity.BalanceAmount.Value; //原卡当前余额 decimal NewMoney = changeEntity.BalanceAmount.Value + para.BalanceMoney; //原卡当余额+调整金额 //原卡会员映射关系 VipCardVipMappingEntity OldVipCardVipMappingData = VipCardVipMappingBLL.QueryByEntity(new VipCardVipMappingEntity() { VipCardID = para.VipCardID }, null).FirstOrDefault(); if (OldVipCardVipMappingData == null) { throw new APIException("原卡会员关系映射对象为NULL!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS }; } //门店Entity var UnitData = unitBLL.GetByID(loggingSessionInfo.CurrentUserRole.UnitId); //会员 VipEntity VipData = VipBLL.GetByID(OldVipCardVipMappingData.VIPID); #region 卡状态记录对象 VipCardStatusChangeLogEntity AddVCStatusEntity = new VipCardStatusChangeLogEntity(); AddVCStatusEntity.LogID = System.Guid.NewGuid().ToString(); AddVCStatusEntity.VipCardID = para.VipCardID; AddVCStatusEntity.Reason = para.ChangeReason; AddVCStatusEntity.OldStatusID = changeEntity.VipCardStatusId; AddVCStatusEntity.CustomerID = loggingSessionInfo.ClientID; AddVCStatusEntity.Remark = para.Remark; AddVCStatusEntity.UnitID = loggingSessionInfo.CurrentUserRole.UnitId; #endregion #region 新卡 VipCardEntity NewChangeVipCardData = new VipCardEntity(); if (!string.IsNullOrWhiteSpace(para.NewCardCode)) { //查询参数 List <IWhereCondition> complexCondition = new List <IWhereCondition> { }; if (!string.IsNullOrEmpty(para.NewCardCode)) { complexCondition.Add(new DirectCondition("VipCardCode='" + para.NewCardCode + "' or VipCardISN='" + para.NewCardCode.ToString() + "' ")); } //新卡对象 NewChangeVipCardData = VipCardBLL.Query(complexCondition.ToArray(), null).FirstOrDefault(); if (NewChangeVipCardData == null) { throw new APIException("新卡不存在!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS }; } //新卡号赋值 NewVipCardCode = NewChangeVipCardData.VipCardCode ?? ""; //新卡数据赋值 NewChangeVipCardData.VipCardGradeID = changeEntity.VipCardGradeID; NewChangeVipCardData.BatchNo = changeEntity.BatchNo; NewChangeVipCardData.BeginDate = changeEntity.BeginDate; NewChangeVipCardData.EndDate = changeEntity.EndDate; NewChangeVipCardData.TotalAmount = changeEntity.TotalAmount == null ? 0 : changeEntity.TotalAmount.Value; NewChangeVipCardData.BalanceAmount = changeEntity.BalanceAmount == null ? 0 : changeEntity.BalanceAmount.Value; NewChangeVipCardData.BalancePoints = changeEntity.BalancePoints == null ? 0 : changeEntity.BalancePoints.Value; NewChangeVipCardData.BalanceBonus = changeEntity.BalanceBonus == null ? 0 : changeEntity.BalanceBonus.Value; NewChangeVipCardData.CumulativeBonus = changeEntity.CumulativeBonus == null ? 0 : changeEntity.CumulativeBonus.Value; NewChangeVipCardData.PurchaseTotalAmount = changeEntity.PurchaseTotalAmount == null ? 0 : changeEntity.PurchaseTotalAmount.Value; NewChangeVipCardData.PurchaseTotalCount = changeEntity.PurchaseTotalCount == null ? 0 : changeEntity.PurchaseTotalCount.Value; NewChangeVipCardData.CheckCode = changeEntity.CheckCode; NewChangeVipCardData.SingleTransLimit = changeEntity.SingleTransLimit == null ? 0 : changeEntity.SingleTransLimit.Value; NewChangeVipCardData.IsOverrunValid = changeEntity.IsOverrunValid == null ? 0 : changeEntity.IsOverrunValid.Value; NewChangeVipCardData.RechargeTotalAmount = changeEntity.RechargeTotalAmount == null ? 0 : changeEntity.RechargeTotalAmount.Value; NewChangeVipCardData.LastSalesTime = changeEntity.LastSalesTime; NewChangeVipCardData.IsGift = changeEntity.IsGift == null ? 0 : changeEntity.IsGift.Value; NewChangeVipCardData.SalesAmount = changeEntity.SalesAmount; NewChangeVipCardData.SalesUserId = changeEntity.SalesUserId; NewChangeVipCardData.CustomerID = changeEntity.CustomerID; NewChangeVipCardData.MembershipTime = changeEntity.MembershipTime; NewChangeVipCardData.SalesUserName = changeEntity.SalesUserName == null ? "" : changeEntity.SalesUserName; NewChangeVipCardData.CreateBy = changeEntity.CreateBy; } #endregion switch (para.OperationType) { case 1: #region 调整卡余额 //卡更新 //卡内总金额 if (para.BalanceMoney > 0) { changeEntity.RechargeTotalAmount += para.BalanceMoney; if (changeEntity.RechargeTotalAmount < 0) { throw new APIException("调整后的余额小于0!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS }; } } //changeEntity.BalanceAmount = changeEntity.BalanceAmount ?? 0; // changeEntity.BalanceAmount = NewMoney; //执行更新 VipCardBLL.Update(changeEntity, pTran); //新增余额变动记录 VipCardBalanceChangeEntity AddEntity = new VipCardBalanceChangeEntity(); AddEntity.ChangeID = System.Guid.NewGuid().ToString(); AddEntity.VipCardCode = changeEntity.VipCardCode; AddEntity.ChangeAmount = para.BalanceMoney; //变动前卡内余额 AddEntity.ChangeBeforeBalance = OldMoney; //变动后卡内余额 AddEntity.ChangeAfterBalance = NewMoney; AddEntity.ChangeReason = para.ChangeReason; AddEntity.Status = 1; AddEntity.Remark = para.Remark; AddEntity.CustomerID = loggingSessionInfo.ClientID; AddEntity.UnitID = loggingSessionInfo.CurrentUserRole.UnitId; //执行新增 VipCardBalanceChangeBLL.Create(AddEntity, pTran); //增加图片上传 if (!string.IsNullOrEmpty(para.ImageUrl)) { var objectImagesEntity = new ObjectImagesEntity() { ImageId = Guid.NewGuid().ToString(), ObjectId = AddEntity.ChangeID, ImageURL = para.ImageUrl }; objectImagesBLL.Create(objectImagesEntity, pTran); } #region 充值记录 //读取最近一次积分变更记录 List <OrderBy> lstOrder = new List <OrderBy> { }; //排序参数 lstOrder.Add(new OrderBy() { FieldName = "TransTime", Direction = OrderByDirections.Desc }); var transLogInfo = vipCardTransLogBLL.QueryByEntity(new VipCardTransLogEntity() { VipCardCode = changeEntity.VipCardCode, TransType = "C" }, lstOrder.ToArray()).FirstOrDefault(); //期末积分 int newValue = transLogInfo != null ? (transLogInfo.NewValue ?? 0) : 0; var vipCardTransLogEntity = new VipCardTransLogEntity() { VipCardCode = VipData == null ? "" : VipData.VipCode, UnitCode = UnitData == null ? "" : UnitData.UnitCode, TransContent = "余额", TransType = "C", TransTime = DateTime.Now, TransAmount = para.BalanceMoney, LastValue = newValue, //期初金额 NewValue = Convert.ToInt32(para.BalanceMoney) + newValue, //期末金额 CustomerID = loggingSessionInfo.ClientID }; vipCardTransLogBLL.Create(vipCardTransLogEntity, pTran); #endregion #endregion break; case 2: #region 卡升级 //卡类型升级 if (para.VipCardTypeId != 0) { VipCardVipMappingBLL.updateVipCardByType(VipData.VIPID, para.VipCardTypeId, para.ChangeReason, para.Remark, VipData.VipCode, pTran); } //卡号升级 else { #region 原卡 #region 更新原卡 changeEntity.VipCardStatusId = 3; //当前月,累计金额清0 //changeEntity.BalanceAmount = 0; //changeEntity.TotalAmount = 0; VipCardBLL.Update(changeEntity, pTran); //执行 #endregion #region 新增原卡状态记录 AddVCStatusEntity.VipCardStatusID = 3; AddVCStatusEntity.Action = "卡升级"; AddVCStatusEntity.Remark += "已升级为:" + NewChangeVipCardData.VipCardCode; VipCardStatusChangeLogBLL.Create(AddVCStatusEntity, pTran); //执行 #endregion #region 新增原卡余额变动记录 //if (OldMoney > 0) //{ // VipCardBalanceChangeEntity AddOldCardBalanceData = new VipCardBalanceChangeEntity(); // AddOldCardBalanceData.ChangeID = System.Guid.NewGuid().ToString(); // AddOldCardBalanceData.VipCardCode = changeEntity.VipCardCode; // AddOldCardBalanceData.ChangeAmount = -OldMoney; // //变动前卡内余额 // AddOldCardBalanceData.ChangeBeforeBalance = OldMoney; // //变动后卡内余额 // AddOldCardBalanceData.ChangeAfterBalance = 0; // AddOldCardBalanceData.ChangeReason = para.ChangeReason; // AddOldCardBalanceData.Status = 1; // AddOldCardBalanceData.Remark = para.Remark; // AddOldCardBalanceData.CustomerID = loggingSessionInfo.ClientID; // AddOldCardBalanceData.UnitID = loggingSessionInfo.CurrentUserRole.UnitId; // VipCardBalanceChangeBLL.Create(AddOldCardBalanceData, pTran);//执行 // //增加图片上传 // if (!string.IsNullOrEmpty(para.ImageUrl)) // { // var objectImagesEntity = new ObjectImagesEntity() // { // ImageId = Guid.NewGuid().ToString(), // ObjectId = AddOldCardBalanceData.ChangeID, // ImageURL = para.ImageUrl // }; // objectImagesBLL.Create(objectImagesEntity, pTran); // } //} #endregion #endregion #region 新卡 VipData.VipCode = para.NewCardCode; VipBLL.Update(VipData, pTran); #region 更新新卡 if (!string.IsNullOrEmpty(NewChangeVipCardData.MembershipUnit)) { throw new APIException("该会员卡已绑定会员!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS } } ; if (NewChangeVipCardData.VipCardStatusId != 0) { throw new APIException("该会员卡已激活!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS } } ; if (NewChangeVipCardData.VipCardTypeID.Value == changeEntity.VipCardTypeID.Value) { throw new APIException("该卡号与原卡等级相同,请更换卡号后重新尝试!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS } } ; #region 返回新卡卡ID rd.VipCardID = NewChangeVipCardData.VipCardID; #endregion NewChangeVipCardData.MembershipUnit = changeEntity.MembershipUnit; NewChangeVipCardData.VipCardStatusId = 1; VipCardBLL.Update(NewChangeVipCardData, pTran); //执行 #endregion #region 新增新卡卡关系 VipCardVipMappingEntity AddVipCardVipMappingData = new VipCardVipMappingEntity(); AddVipCardVipMappingData.MappingID = System.Guid.NewGuid().ToString(); AddVipCardVipMappingData.VIPID = OldVipCardVipMappingData.VIPID; AddVipCardVipMappingData.VipCardID = NewChangeVipCardData.VipCardID; AddVipCardVipMappingData.CustomerID = loggingSessionInfo.ClientID; VipCardVipMappingBLL.Create(AddVipCardVipMappingData, pTran); //执行 #endregion #region 更新会员编号 //VipEntity SJ_VipData = VipBLL.GetByID(OldVipCardVipMappingData.VIPID); //if (VipData == null) // throw new APIException("会员不存在!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS }; //VipData.VipCode = NewChangeVipCardData.VipCardCode; //VipBLL.Update(VipData, pTran);//执行 #endregion #region 新增新卡状态记录 //新增新卡状态记录 VipCardStatusChangeLogEntity AddNewVCStatusEntity = new VipCardStatusChangeLogEntity(); AddNewVCStatusEntity.LogID = System.Guid.NewGuid().ToString(); AddNewVCStatusEntity.VipCardID = NewChangeVipCardData.VipCardID; AddNewVCStatusEntity.VipCardStatusID = 1; AddNewVCStatusEntity.Reason = para.ChangeReason; AddNewVCStatusEntity.OldStatusID = 0; AddNewVCStatusEntity.CustomerID = loggingSessionInfo.ClientID; AddNewVCStatusEntity.Action = "卡升级"; AddNewVCStatusEntity.Remark = para.Remark + "由旧卡:" + changeEntity.VipCardCode + "升级"; AddNewVCStatusEntity.UnitID = loggingSessionInfo.CurrentUserRole.UnitId; VipCardStatusChangeLogBLL.Create(AddNewVCStatusEntity, pTran); //执行 #endregion #region 新增新卡余额记录 //新增余额记录 //if (OldMoney > 0) //{ // VipCardBalanceChangeEntity AddNewCardBalanceData = new VipCardBalanceChangeEntity(); // AddNewCardBalanceData.ChangeID = System.Guid.NewGuid().ToString(); // AddNewCardBalanceData.VipCardCode = NewChangeVipCardData.VipCardCode; // AddNewCardBalanceData.ChangeAmount = OldMoney; // //变动前卡内余额 // AddNewCardBalanceData.ChangeBeforeBalance = 0; // //变动后卡内余额 // AddNewCardBalanceData.ChangeAfterBalance = NewChangeVipCardData.BalanceAmount == null ? 0 : NewChangeVipCardData.BalanceAmount.Value; // AddNewCardBalanceData.ChangeReason = para.ChangeReason; // AddNewCardBalanceData.Status = 1; // AddNewCardBalanceData.Remark = para.Remark; // AddNewCardBalanceData.CustomerID = loggingSessionInfo.ClientID; // VipCardBalanceChangeBLL.Create(AddNewCardBalanceData, pTran);//执行 // //增加图片上传 // if (!string.IsNullOrEmpty(para.ImageUrl)) // { // var objectImagesEntity = new ObjectImagesEntity() // { // ImageId = Guid.NewGuid().ToString(), // ObjectId = AddNewCardBalanceData.ChangeID, // ImageURL = para.ImageUrl // }; // objectImagesBLL.Create(objectImagesEntity, pTran); // } //} #endregion #endregion } #endregion break; case 3: #region 挂失 changeEntity.VipCardStatusId = 4; //执行更新 VipCardBLL.Update(changeEntity, pTran); //执行 AddVCStatusEntity.VipCardStatusID = 4; AddVCStatusEntity.PicUrl = para.ImageUrl; AddVCStatusEntity.Action = "挂失"; VipCardStatusChangeLogBLL.Create(AddVCStatusEntity, pTran); #endregion break; case 4: #region 冻结 changeEntity.VipCardStatusId = 2; //执行更新 VipCardBLL.Update(changeEntity, pTran); //执行新增 AddVCStatusEntity.VipCardStatusID = 2; AddVCStatusEntity.Action = "冻结"; VipCardStatusChangeLogBLL.Create(AddVCStatusEntity, pTran); #endregion break; case 5: #region 转卡 #region 原卡 #region 更新原卡 changeEntity.VipCardStatusId = 3; //当前月,累计金额清0 changeEntity.BalanceAmount = 0; changeEntity.TotalAmount = 0; VipCardBLL.Update(changeEntity, pTran); //执行 #endregion #region 新增原卡状态记录 AddVCStatusEntity.VipCardStatusID = 3; AddVCStatusEntity.Action = "转卡"; AddVCStatusEntity.Remark += "已转移为:" + NewChangeVipCardData.VipCardCode; VipCardStatusChangeLogBLL.Create(AddVCStatusEntity, pTran); //执行 #endregion #region 新增原卡余额变动记录 if (OldMoney > 0) { VipCardBalanceChangeEntity AddOldZKCardBalanceData = new VipCardBalanceChangeEntity(); AddOldZKCardBalanceData.ChangeID = System.Guid.NewGuid().ToString(); AddOldZKCardBalanceData.VipCardCode = changeEntity.VipCardCode; AddOldZKCardBalanceData.ChangeAmount = -OldMoney; //变动前卡内余额 AddOldZKCardBalanceData.ChangeBeforeBalance = OldMoney; //变动后卡内余额 AddOldZKCardBalanceData.ChangeAfterBalance = 0; AddOldZKCardBalanceData.ChangeReason = para.ChangeReason; AddOldZKCardBalanceData.Status = 1; AddOldZKCardBalanceData.Remark = para.Remark; AddOldZKCardBalanceData.CustomerID = loggingSessionInfo.ClientID; AddOldZKCardBalanceData.UnitID = loggingSessionInfo.CurrentUserRole.UnitId; VipCardBalanceChangeBLL.Create(AddOldZKCardBalanceData, pTran); //执行 //增加图片上传 if (!string.IsNullOrEmpty(para.ImageUrl)) { var objectImagesEntity = new ObjectImagesEntity() { ImageId = Guid.NewGuid().ToString(), ObjectId = AddOldZKCardBalanceData.ChangeID, ImageURL = para.ImageUrl }; objectImagesBLL.Create(objectImagesEntity, pTran); } } #endregion #endregion #region 新卡 #region 更新新卡 if (!string.IsNullOrEmpty(NewChangeVipCardData.MembershipUnit)) { throw new APIException("该会员卡已绑定会员!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS } } ; if (NewChangeVipCardData.VipCardStatusId != 0) { throw new APIException("该会员卡已激活!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS } } ; if (NewChangeVipCardData.VipCardTypeID.Value != changeEntity.VipCardTypeID.Value) { throw new APIException("该卡号与原卡等级不同,请更换卡号后重新尝试!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS } } ; #region 返回新卡卡ID rd.VipCardID = NewChangeVipCardData.VipCardID; #endregion NewChangeVipCardData.MembershipUnit = changeEntity.MembershipUnit; NewChangeVipCardData.VipCardStatusId = 1; VipCardBLL.Update(NewChangeVipCardData, pTran); //执行 #endregion #region 新增新卡卡关系 VipCardVipMappingEntity AddZKVipCardVipMappingData = new VipCardVipMappingEntity(); AddZKVipCardVipMappingData.MappingID = System.Guid.NewGuid().ToString(); AddZKVipCardVipMappingData.VIPID = OldVipCardVipMappingData.VIPID; AddZKVipCardVipMappingData.VipCardID = NewChangeVipCardData.VipCardID; AddZKVipCardVipMappingData.CustomerID = loggingSessionInfo.ClientID; VipCardVipMappingBLL.Create(AddZKVipCardVipMappingData, pTran); //执行 #endregion #region 更新会员编号 //VipEntity ZK_VipData = VipBLL.GetByID(OldVipCardVipMappingData.VIPID); if (VipData == null) { throw new APIException("会员不存在!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS } } ; VipData.VipCode = NewChangeVipCardData.VipCardCode; VipBLL.Update(VipData, pTran); //执行 #endregion #region 新增新卡状态记录 VipCardStatusChangeLogEntity AddNewZKVCStatusEntity = new VipCardStatusChangeLogEntity(); AddNewZKVCStatusEntity.LogID = System.Guid.NewGuid().ToString(); AddNewZKVCStatusEntity.VipCardID = NewChangeVipCardData.VipCardID; AddNewZKVCStatusEntity.VipCardStatusID = 1; AddNewZKVCStatusEntity.Reason = para.ChangeReason; AddNewZKVCStatusEntity.OldStatusID = 0; AddNewZKVCStatusEntity.CustomerID = loggingSessionInfo.ClientID; AddNewZKVCStatusEntity.Action = "转卡"; AddNewZKVCStatusEntity.Remark = para.Remark + para.Remark + "由旧卡:" + changeEntity.VipCardCode + "转移"; AddNewZKVCStatusEntity.UnitID = loggingSessionInfo.CurrentUserRole.UnitId; VipCardStatusChangeLogBLL.Create(AddNewZKVCStatusEntity, pTran); //执行 #endregion #region 新增新卡余额记录 if (OldMoney > 0) { VipCardBalanceChangeEntity AddNewZKCardBalanceData = new VipCardBalanceChangeEntity(); AddNewZKCardBalanceData.ChangeID = System.Guid.NewGuid().ToString(); AddNewZKCardBalanceData.VipCardCode = NewChangeVipCardData.VipCardCode; AddNewZKCardBalanceData.ChangeAmount = OldMoney; //变动前卡内余额 AddNewZKCardBalanceData.ChangeBeforeBalance = 0; //变动后卡内余额 AddNewZKCardBalanceData.ChangeAfterBalance = NewChangeVipCardData.BalanceAmount == null ? 0 : NewChangeVipCardData.BalanceAmount.Value; AddNewZKCardBalanceData.ChangeReason = para.ChangeReason; AddNewZKCardBalanceData.Status = 1; AddNewZKCardBalanceData.Remark = para.Remark; AddNewZKCardBalanceData.CustomerID = loggingSessionInfo.ClientID; AddNewZKCardBalanceData.UnitID = loggingSessionInfo.CurrentUserRole.UnitId; VipCardBalanceChangeBLL.Create(AddNewZKCardBalanceData, pTran); //执行 //增加图片上传 if (!string.IsNullOrEmpty(para.ImageUrl)) { var objectImagesEntity = new ObjectImagesEntity() { ImageId = Guid.NewGuid().ToString(), ObjectId = AddNewZKCardBalanceData.ChangeID, ImageURL = para.ImageUrl }; objectImagesBLL.Create(objectImagesEntity, pTran); } } #endregion #endregion #endregion break; case 6: #region 解挂 changeEntity.VipCardStatusId = 1; //执行更新 VipCardBLL.Update(changeEntity, pTran); //执行新增 AddVCStatusEntity.VipCardStatusID = 1; AddVCStatusEntity.Action = "解挂"; VipCardStatusChangeLogBLL.Create(AddVCStatusEntity, pTran); #endregion break; case 7: #region 解冻 changeEntity.VipCardStatusId = 1; //执行更新 VipCardBLL.Update(changeEntity, pTran); //执行新增 AddVCStatusEntity.VipCardStatusID = 1; AddVCStatusEntity.Action = "解冻"; VipCardStatusChangeLogBLL.Create(AddVCStatusEntity, pTran); #endregion break; case 8: #region 作废 changeEntity.VipCardStatusId = 3; //执行更新 VipCardBLL.Update(changeEntity, pTran); //执行新增 AddVCStatusEntity.VipCardStatusID = 3; AddVCStatusEntity.Action = "作废"; VipCardStatusChangeLogBLL.Create(AddVCStatusEntity, pTran); #endregion break; case 9: #region 唤醒 changeEntity.VipCardStatusId = 1; //执行更新 VipCardBLL.Update(changeEntity, pTran); //执行新增 AddVCStatusEntity.VipCardStatusID = 1; AddVCStatusEntity.Action = "唤醒"; VipCardStatusChangeLogBLL.Create(AddVCStatusEntity, pTran); #endregion break; case 10: #region 激活 changeEntity.VipCardStatusId = 1; //执行更新 VipCardBLL.Update(changeEntity, pTran); //执行新增 AddVCStatusEntity.VipCardStatusID = 1; AddVCStatusEntity.Action = "激活"; VipCardStatusChangeLogBLL.Create(AddVCStatusEntity, pTran); #endregion break; default: throw new APIException("当前操作类型不匹配!") { ErrorCode = ERROR_CODES.INVALID_REQUEST_LACK_REQUEST_PARAMETER }; break; } ; pTran.Commit(); #region 卡升级,转卡操作转移消费记录表 if ((para.OperationType == 2 || para.OperationType == 5) && string.IsNullOrEmpty(para.VipCardTypeId.ToString())) //卡类型升级不执行此操作 { string StrSql = string.Format("update VipCardTransLog set VipCardCode='{0}',OldVipCardCode='{1}' where VipCardCode='{1}'", NewVipCardCode, OldVipCardCode); vipCardTransLogBLL.UpdateVipCardTransLog(StrSql);//执行 } #endregion var eventService = new EventService(); var vipMsg = new EventContract { Operation = OptEnum.Update, EntityType = EntityTypeEnum.Vip, Id = VipData.VIPID }; eventService.PublishMsg(vipMsg); } catch (APIException apiEx) { pTran.Rollback();//回滚事物 throw new APIException(apiEx.ErrorCode, apiEx.Message); } catch (Exception ex) { pTran.Rollback();//回滚事务 throw new APIException(ex.Message); } } return(rd); }
public void CreateQRCode(SetCTWEventRP para, WApplicationInterfaceEntity wapentity, string strPageParamJson, out string strQRCode, out string QRCodeUrl, out string RedirectUrl) { #region 获取Page信息 var pageBll = new SysPageBLL(loggingSessionInfo); //根据活动的抽奖方式获取:“HB” “BigDial“ string strPageKey = string.Empty; switch (para.DrawMethodCode) { case "HB": strPageKey = "RedPacket"; break; case "DZP": strPageKey = "BigDial"; break; case "QN": strPageKey = "Questionnaire"; break; default: strPageKey = "NewsActivityList"; break; } #endregion #region 生成URL var Domain = ConfigurationManager.AppSettings["interfacehost"].Replace("http://", ""); var Domain1 = ConfigurationManager.AppSettings["interfacehost1"].Replace("http://", ""); string URL = string.Empty; #region 系统模块 var page = pageBll.GetPageByCustomerIdAndPageKey(loggingSessionInfo.ClientID, strPageKey).SingleOrDefault(); if (page == null) { throw new APIException("未找到Page信息") { ErrorCode = 341 } } ; string path = string.Empty; //要替换的路径 string urlTemplate = page.URLTemplate; //模板URL string json = page.JsonValue; // JSON体 var jsonDic = json.DeserializeJSONTo <Dictionary <string, object> >(); //转换后的字典 var htmls = jsonDic["htmls"].ToJSON().DeserializeJSONTo <Dictionary <string, object>[]>().ToList(); //htmls是一个数组,里面有他的很多属性 Dictionary <string, object> html = null; //选择的html信息 var defaultHtmlId = jsonDic["defaultHtml"].ToString(); html = htmls.Find(t => t["id"].ToString() == defaultHtmlId); //默认的htmlid***** if (html != null) { path = html["path"].ToString(); } //判断高级oauth认证 var scope = "snsapi_userinfo"; //if (jsonDic.ContainsKey("scope"))//必须要判断key里是否包含scope //{ // scope = (jsonDic["scope"] == null || jsonDic["scope"].ToString() == "") ? "snsapi_base" : "snsapi_userinfo"; //} //判断是否有定制,没有则取JSON体中的默认 //找出订制内容 if (page != null) { //看是否有htmls的定制(Node值=2) if (page.Node == "2") { var nodeValue = page.NodeValue; //在Json解析后的集合中找到path html = htmls.Find(t => t["id"].ToString() == nodeValue); if (html != null) { path = html["path"].ToString(); } } } //读取配置信息域名,检查不用http://开头,如果有则去除 var IsAuth = false; //TODO:判断页面是否需要Auth认证,如果页面需要证则再判断这个客户有没有Auth认证,Type=3 if (page.IsAuth == 1) { //判断这个客户是否是认证客户,type=3 var applicationBll = new WApplicationInterfaceBLL(loggingSessionInfo); var application = applicationBll.GetByID(wapentity.ApplicationId);//取默认的第一个 if (application.WeiXinTypeId == "3") { IsAuth = true; } } //替换URL模板 #region 替换URL模板 urlTemplate = urlTemplate.Replace("_pageName_", path); //用path替换掉_pageName_***(可以查看红包或者客服的path信息即可以知道) var paraDic = strPageParamJson.DeserializeJSONTo <Dictionary <string, object>[]>(); foreach (var item in paraDic) //这里key和value对于活动来说,其实就是活动的eventId,和eventId的值 { if (item.ContainsKey("key") && item.ContainsKey("value")) { urlTemplate = urlTemplate.Replace("{" + item["key"] + "}", item["value"].ToString()); } } #endregion //根据规则组织URL #region 组织URL //读取配置文件中的域名 if (string.IsNullOrEmpty(Domain)) { throw new APIException("微信管理:未配置域名,请在web.config中添加<add key='host' value=''/>") { ErrorCode = 342 } } ; if (IsAuth) { //需要认证(传参数时,需要传递applicationId,对于一个商户有多个微信服务号的,不能取默认的第一个,而是精确地取固定的微信服务号) //通过urlTemplate(用path替换了_pageName_),生成了goUrl URL = string.Format("http://{0}/WXOAuth/AuthUniversal.aspx?customerId={1}&applicationId={2}&goUrl={3}&scope={4}", Domain.Trim('/'), loggingSessionInfo.ClientID, wapentity.ApplicationId, HttpUtility.UrlEncode(string.Format("{0}{1}", Domain.Trim('/'), urlTemplate)), scope); } else { //不需要认证 URL = string.Format("http://{0}/WXOAuth/NoAuthGoto.aspx?customerId={1}&goUrl={2}", Domain.Trim('/'), loggingSessionInfo.ClientID, HttpUtility.UrlEncode(string.Format("{0}{1}", Domain.Trim('/'), urlTemplate.Trim('/')))); } RedirectUrl = URL; #endregion #endregion #endregion string sourcePath = HttpContext.Current.Server.MapPath("/QRCodeImage/qrcode.jpg"); string targetPath = HttpContext.Current.Server.MapPath("/QRCodeImage/"); string currentDomain = "http://" + HttpContext.Current.Request.Url.Host;//当前项目域名 QRCodeUrl = Utils.GenerateQRCode(URL, currentDomain, sourcePath, targetPath); ObjectImagesBLL bllObjectImages = new ObjectImagesBLL(loggingSessionInfo); ObjectImagesEntity entityObjectImages = new ObjectImagesEntity(); entityObjectImages = new ObjectImagesEntity() { ImageId = Utils.NewGuid(), CustomerId = loggingSessionInfo.ClientID, ImageURL = QRCodeUrl, ObjectId = strCTWEventId, Title = "", Description = "创意仓库活动二维码" }; //把下载下来的图片的地址存到ObjectImages bllObjectImages.Create(entityObjectImages); strQRCode = entityObjectImages.ImageId.ToString(); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; try { string xmlStr = string.Empty; using (var stream = context.Request.InputStream) { using (var rd = new StreamReader(stream, System.Text.Encoding.UTF8)) { xmlStr = rd.ReadToEnd(); JIT.Utility.Log.Loggers.Debug(new Utility.Log.DebugLogInfo() { Message = string.Format("用户维权:收到的通知信息:{0}", xmlStr) }); } } var doc = new XmlDocument(); doc.LoadXml(xmlStr); var dic = new Dictionary <string, string>(); var ds = new DataSet(); //遍历参数节点 var list = doc.SelectNodes("xml/*"); foreach (XmlNode item in list) { if (item.Name != "PicInfo") { dic[item.Name] = item.InnerText; } else { //将图片读取到DS中 var stream = new StringReader("<PicInfo>" + item.InnerXml + "</PicInfo>"); var reader = new XmlTextReader(stream); ds.ReadXml(reader); } } #region 维权对象,不带图片 #endregion #region 图片对象 //遍历ds,向图片表插入数据 #endregion var notify = dic.ToJSON().DeserializeJSONTo <WXRightOrdersEntity>(); var customerWxMappingBll = new TCustomerWeiXinMappingBLL(Default.GetAPLoggingSession("")); var customerId = customerWxMappingBll.GetCustomerIdByAppId(notify.AppId); if (customerId == "") { throw new APIException("客户ID为空") { ErrorCode = 121 }; } var currentUserInfo = Default.GetBSLoggingSession(customerId, "1"); var bll = new WXRightOrdersBLL(currentUserInfo); //根据维权单号,查询是否有数据 var entity = bll.QueryByEntity(new WXRightOrdersEntity() { FeedBackId = notify.FeedBackId }, null); #region 验签 ////支付中心URL //var url = System.Configuration.ConfigurationManager.AppSettings["paymentcenterUrl"]; //url = "http://121.199.42.125:6002/DevPayTest.ashx";//测试,正式需删除此行 //var customerID = "e703dbedadd943abacf864531decdac1";//先写死测试 //var paraSign = new Dictionary<string, string>(); //paraSign["openid"] = notify.OpenId; //paraSign["timestamp"] = notify.TimeStamp; //var request = new //{ // AppID = notify.AppId, // ClientID = customerID, // UserID = notify.OpenId, // Parameters = paraSign //}; //string content = string.Format("action=WXGetSign&request={0}", request.ToJSON()); //string resStr = string.Empty; //try //{ // resStr = JIT.Utility.Web.HttpClient.PostQueryString(url, content); //} //catch (Exception ex) //{ // JIT.Utility.Log.Loggers.Exception(new Utility.Log.ExceptionLogInfo(ex)); // throw ex; //} //var dicGetSign = resStr.DeserializeJSONTo<Dictionary<string, object>>(); //if (Convert.ToInt32(dicGetSign["ResultCode"]) < 100) //{ // var dicData = dicGetSign["Datas"].ToJSON().DeserializeJSONTo<Dictionary<string, string>>(); // var sign = dicData["Sign"].ToString(); // if (sign != notify.AppSignature) // throw new Exception(string.Format("验签失败,原:{0}\t新:{1}", notify.AppSignature, sign)); //} //else //{ // throw new Exception(string.Format("错误信息:{0}", dicGetSign["Message"])); //} #endregion var conEntity = bll.QueryByEntity(new WXRightOrdersEntity() { FeedBackId = notify.FeedBackId }, null).FirstOrDefault(); switch (notify.MsgType) { case "request": //新的维权 //TODO:新增记录 JIT.Utility.Log.Loggers.Debug(new Utility.Log.DebugLogInfo() { Message = string.Format("新增一条用户维权:{0}", notify.ToJSON()) }); if (entity != null) { //删除原有的维权单 bll.Delete(entity); } notify.Status = 10; var rightOrderId = Guid.NewGuid(); notify.RightOrdersId = rightOrderId; notify.CustomerId = customerId; bll.Create(notify); var objectImages = new ObjectImagesEntity(); var objectImageList = new List <ObjectImagesEntity>(); var imageBll = new ObjectImagesBLL(currentUserInfo); int i = 0; foreach (DataRow row in ds.Tables[0].Rows) { i++; objectImages.ImageURL = row[0].ToString(); objectImages.ObjectId = Convert.ToString(rightOrderId); objectImages.ImageId = Convert.ToString(Guid.NewGuid()); objectImages.DisplayIndex = i; objectImages.CustomerId = customerId; //将维权单的url插入到图片表中 imageBll.Create(objectImages); } //var feedBackPara = new //{ // PayChannelID = 9, // FeedBackID = notify.FeedBackId, // OpenID = notify.OpenId //}; //var feedBackRequest = new //{ // AppID = notify.AppId, // ClientID = customerID, // UserID = notify.OpenId, // Parameters = paraSign //}; //content = string.Format("action=WXGetUpdateFeedBackUrl&request={0}", feedBackRequest.ToJSON()); //resStr = string.Empty; //try //{ // resStr = JIT.Utility.Web.HttpClient.PostQueryString(url, content); //} //catch (Exception ex) //{ // throw ex; //} //var dicFeedBack = resStr.DeserializeJSONTo<Dictionary<string, object>>(); //if (Convert.ToInt32(dicFeedBack["ResultCode"]) < 100) //{ // var dicData = dicFeedBack["Datas"].ToJSON().DeserializeJSONTo<Dictionary<string, string>>(); // var feedBackUrl = dicData["Url"].ToString(); // string resStrFeedBack = string.Empty; // try // { // resStrFeedBack = JIT.Utility.Web.HttpClient.GetQueryString(feedBackUrl); // dicFeedBack = resStrFeedBack.DeserializeJSONTo<Dictionary<string, object>>(); // } // catch (Exception ex) // { // throw ex; // } //} //else //{ // throw new Exception(string.Format("错误信息:{0}", dicGetSign["Message"])); //} break; case "confirm": //客户同意解决 //TODO:对已有的记录Update JIT.Utility.Log.Loggers.Debug(new Utility.Log.DebugLogInfo() { Message = string.Format("客户同意维权解决:{0}", notify.ToJSON()) }); if (conEntity != null) { conEntity.Status = 50; conEntity.MsgType = "confirm"; conEntity.Reason = notify.Reason; conEntity.TimeStamp = notify.TimeStamp; bll.Update(conEntity); } break; case "reject": //客户拒绝解决 //TODO:对已有的记录Update,同时如何处理?? JIT.Utility.Log.Loggers.Debug(new Utility.Log.DebugLogInfo() { Message = string.Format("客户拒绝维权解决:{0}", notify.ToJSON()) }); if (conEntity != null) { conEntity.Status = 60; conEntity.MsgType = "reject"; conEntity.Reason = notify.Reason; conEntity.TimeStamp = notify.TimeStamp; bll.Update(conEntity); } break; default: break; } #region 向表中记录调用的微信接口 var wxInterfaceLogBll = new WXInterfaceLogBLL(currentUserInfo); var wxInterfaceLogEntity = new WXInterfaceLogEntity(); wxInterfaceLogEntity.LogId = Guid.NewGuid(); wxInterfaceLogEntity.InterfaceUrl = "微信公众号配置的维权URL"; wxInterfaceLogEntity.AppId = notify.AppId; wxInterfaceLogEntity.OpenId = notify.OpenId; wxInterfaceLogEntity.RequestParam = notify.ToJSON(); wxInterfaceLogEntity.IsSuccess = 1; wxInterfaceLogBll.Create(wxInterfaceLogEntity); #endregion } catch (Exception ex) { JIT.Utility.Log.Loggers.Exception(new Utility.Log.ExceptionLogInfo(ex)); context.Response.Write(ex); } }
/// <summary> /// 保存更新游戏信息 /// </summary> /// <param name="para"></param> /// <returns></returns> public void SaveGameEvent(SetCTWEventRP para, LPrizesBLL bllPrize, T_CTW_LEventInteractionBLL bllCustomerInteraction, string strThemeId, out string strStartDate, out string strEndDate, out string strGameEventGuid) { strGameEventGuid = string.Empty; var imageBll = new ObjectImagesBLL(loggingSessionInfo); LEventsBLL bllGameEvent = new LEventsBLL(loggingSessionInfo); var eventEntity = new LEventsEntity(); strStartDate = para.GameEventInfo.BeginTime; strEndDate = para.GameEventInfo.EndTime + " 23:59:59"; if (string.IsNullOrEmpty(para.GameEventInfo.LeventId)) { strGameEventGuid = Guid.NewGuid().ToString(); eventEntity.EventID = strGameEventGuid; eventEntity.Title = para.GameEventInfo.Title; eventEntity.BeginTime = para.GameEventInfo.BeginTime; eventEntity.EndTime = para.GameEventInfo.EndTime; eventEntity.DrawMethodId = GetDrawMethodIdByDrawMethodCode(para.DrawMethodCode); eventEntity.PersonCount = para.GameEventInfo.PersonCount; eventEntity.PointsLottery = para.GameEventInfo.PointsLottery; eventEntity.LotteryNum = para.GameEventInfo.LotteryNum; eventEntity.IsDelete = 0; if (DateTime.Compare(Convert.ToDateTime(para.GameEventInfo.BeginTime), Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"))) <= 0 && DateTime.Compare(Convert.ToDateTime(para.GameEventInfo.EndTime), Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"))) >= 0) { eventEntity.EventStatus = 20; //10=未开始,20=运行中,30=暂停,40=结束 } else if (DateTime.Compare(Convert.ToDateTime(para.GameEventInfo.BeginTime), Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"))) > 0) { eventEntity.EventStatus = 10; //10=未开始,20=运行中,30=暂停,40=结束 } eventEntity.IsCTW = 1; eventEntity.CustomerId = loggingSessionInfo.ClientID; bllGameEvent.Create(eventEntity); } else { strGameEventGuid = para.GameEventInfo.LeventId; eventEntity = bllGameEvent.GetByID(strGameEventGuid); eventEntity.Title = para.GameEventInfo.Title; eventEntity.BeginTime = para.GameEventInfo.BeginTime; eventEntity.EndTime = para.GameEventInfo.EndTime; eventEntity.DrawMethodId = GetDrawMethodIdByDrawMethodCode(para.DrawMethodCode); eventEntity.PersonCount = para.GameEventInfo.PersonCount; eventEntity.PointsLottery = para.GameEventInfo.PointsLottery; eventEntity.LotteryNum = para.GameEventInfo.LotteryNum; bllGameEvent.Update(eventEntity); } ///图片 if (para.GameEventInfo.ImageList.Count > 0) { imageBll.DeleteByObjectID(strGameEventGuid); foreach (var i in para.GameEventInfo.ImageList) { imageEntity = new ObjectImagesEntity(); imageEntity.ImageURL = i.ImageURL; imageEntity.ObjectId = strGameEventGuid; imageEntity.CreateBy = loggingSessionInfo.UserID; imageEntity.ImageId = Guid.NewGuid().ToString(); imageEntity.BatId = i.BatId; imageEntity.RuleId = para.GameEventInfo.RuleId ?? 1; imageEntity.RuleContent = para.GameEventInfo.RuleContent; imageEntity.IsDelete = 0; imageEntity.CustomerId = loggingSessionInfo.ClientID; imageBll.Create(imageEntity); } } //奖品信息 var entityPrize = new LPrizesEntity(); var redisPrizePoolsBLL = new JIT.CPOS.BS.BLL.RedisOperationBLL.PrizePools.RedisPrizePoolsBLL(); if (!string.IsNullOrEmpty(para.GameEventInfo.LeventId)) { //bllPrize.Delete(new LPrizesEntity() { EventId = para.GameEventInfo.LeventId }); bllPrize.DeletePrizesByEventId(para.GameEventInfo.LeventId); CC_PrizePool prizePool = new CC_PrizePool(); prizePool.CustomerId = loggingSessionInfo.ClientID; prizePool.EventId = para.GameEventInfo.LeventId; redisPrizePoolsBLL.DeletePrizePoolsList(prizePool); } if (para.GameEventInfo.PrizeList.Count > 0) { foreach (var i in para.GameEventInfo.PrizeList) { entityPrize.EventId = strGameEventGuid; entityPrize.PrizeTypeId = i.PrizeTypeId; entityPrize.Point = i.Point; entityPrize.CouponTypeID = i.CouponTypeID; entityPrize.PrizeName = i.PrizeName; entityPrize.CountTotal = i.PrizeCount; entityPrize.CreateBy = loggingSessionInfo.UserID; entityPrize.PrizesID = Guid.NewGuid().ToString(); bllPrize.SavePrize(entityPrize); } //入奖品池队列 LPrizePoolsBLL bllPools = new LPrizePoolsBLL(loggingSessionInfo); DataSet dsPools = bllPools.GetPrizePoolsByEvent(loggingSessionInfo.ClientID, strGameEventGuid); if (dsPools != null && dsPools.Tables.Count > 0 && dsPools.Tables[0].Rows.Count > 0) { var poolTemp = DataTableToObject.ConvertToList <CC_PrizePool>(dsPools.Tables[0]); var poolsList = Utils.GetRandomList <CC_PrizePool>(poolTemp); //随机列表 if (poolsList != null && poolsList.Count > 0) { CC_PrizePool prizePool = new CC_PrizePool(); prizePool.CustomerId = loggingSessionInfo.ClientID; prizePool.EventId = strGameEventGuid; redisPrizePoolsBLL.DeletePrizePoolsList(prizePool); redisPrizePoolsBLL.SetPrizePoolsToRedis(poolsList); } } } if (!string.IsNullOrEmpty(para.CTWEventId)) { bllCustomerInteraction.DeleteByCTWEventID(para.CTWEventId); } ///互动类型与(游戏或促销)关联 entityInteraction = new T_CTW_LEventInteractionEntity() { CTWEventId = new Guid(strCTWEventId), ThemeId = new Guid(strThemeId), InteractionType = para.InteractionType, DrawMethodCode = para.DrawMethodCode, LeventId = strGameEventGuid, OriginalLeventId = new Guid(para.OriginalLeventId), CustomerId = loggingSessionInfo.ClientID }; bllCustomerInteraction.Create(entityInteraction); }
/// <summary> /// 保存 /// </summary> public string SaveBrandDetailData() { var service = new BrandDetailBLL(CurrentUserInfo); var objectImagesBLL = new ObjectImagesBLL(CurrentUserInfo); var propService = new PropService(CurrentUserInfo); BrandDetailEntity obj = new BrandDetailEntity(); string content = string.Empty; string error = ""; var responseData = new ResponseData(); string key = string.Empty; string item_id = string.Empty; if (Request("item") != null && Request("item") != string.Empty) { key = Request("item").ToString().Trim(); } if (Request("item_id") != null && Request("item_id") != string.Empty) { item_id = Request("item_id").ToString().Trim(); } obj = key.DeserializeJSONTo <BrandDetailEntity>(); if (obj.BrandName == null || obj.BrandName.Trim().Length == 0) { responseData.success = false; responseData.msg = "名称不能为空"; return(responseData.ToJSON()); } if (obj.BrandCode == null || obj.BrandCode.Trim().Length == 0) { responseData.success = false; responseData.msg = "代码不能为空"; return(responseData.ToJSON()); } if (item_id.Trim().Length == 0) { obj.BrandId = Utils.NewGuid(); obj.CustomerId = this.CurrentUserInfo.CurrentUser.customer_id; service.Create(obj); var tmpImageList = objectImagesBLL.QueryByEntity(new ObjectImagesEntity() { ObjectId = obj.BrandId }, null); if (tmpImageList != null && tmpImageList.Length > 0) { foreach (var tmpImageItem in tmpImageList) { objectImagesBLL.Delete(tmpImageItem); } } if (obj.ItemImageList != null) { foreach (var tmpImageItem in obj.ItemImageList) { tmpImageItem.ObjectId = obj.BrandId; tmpImageItem.CustomerId = this.CurrentUserInfo.CurrentUser.customer_id; objectImagesBLL.Create(tmpImageItem); } } service.SetBrandAndPropSyn(obj.BrandId, obj.BrandName, 1, 0, out error); } else { obj.BrandId = item_id; obj.CustomerId = CurrentUserInfo.CurrentUser.customer_id; service.Update(obj, false); var tmpImageList = objectImagesBLL.QueryByEntity( new ObjectImagesEntity() { ObjectId = obj.BrandId }, null); if (tmpImageList != null && tmpImageList.Length > 0) { foreach (var tmpImageItem in tmpImageList) { objectImagesBLL.Delete(tmpImageItem); } } if (obj.ItemImageList != null) { foreach (var tmpImageItem in obj.ItemImageList) { tmpImageItem.ObjectId = obj.BrandId; tmpImageItem.CustomerId = this.CurrentUserInfo.CurrentUser.customer_id; objectImagesBLL.Create(tmpImageItem); } } service.SetBrandAndPropSyn(obj.BrandId, obj.BrandName, 1, 0, out error); } responseData.success = true; responseData.msg = error; content = responseData.ToJSON(); return(content); }
private void DownloadQRCode() { string weixinDomain = ConfigurationManager.AppSettings["original_url"]; string sourcePath = this.CurrentContext.Server.MapPath("/QRCodeImage/qrcode.jpg"); string targetPath = this.CurrentContext.Server.MapPath("/QRCodeImage/"); string currentDomain = this.CurrentContext.Request.Url.Host; string itemId = FormatParamValue(Request("item_id")); //商品ID string itemName = FormatParamValue(Request("item_name")); //商品名 string imageURL; ObjectImagesBLL objectImagesBLL = new ObjectImagesBLL(CurrentUserInfo); //查找是否已经生成了二维码 ObjectImagesEntity[] objectImagesEntityArray = objectImagesBLL.QueryByEntity(new ObjectImagesEntity() { ObjectId = itemId, Description = "自动生成的产品二维码" }, null); if (objectImagesEntityArray.Length == 0) { imageURL = Utils.GenerateQRCode(weixinDomain + "/HtmlApps/Auth.html?pageName=GoodsDetail&rootPage=true&customerId=" + CurrentUserInfo.ClientID + "&goodsId=" + itemId, currentDomain, sourcePath, targetPath); //把下载下来的图片的地址存到ObjectImages objectImagesBLL.Create(new ObjectImagesEntity() { ImageId = Utils.NewGuid(), CustomerId = CurrentUserInfo.ClientID, ImageURL = imageURL, ObjectId = itemId, Title = itemName , Description = "自动生成的产品二维码" }); Loggers.Debug(new DebugLogInfo() { Message = "二维码已生成,imageURL:" + imageURL }); } else { imageURL = objectImagesEntityArray[0].ImageURL; } string imagePath = targetPath + imageURL.Substring(imageURL.LastIndexOf("/")); Loggers.Debug(new DebugLogInfo() { Message = "二维码路径,imagePath:" + imageURL }); try { //要下载的文件名 FileInfo DownloadFile = new FileInfo(imagePath); if (DownloadFile.Exists) { CurrentContext.Response.Clear(); CurrentContext.Response.AddHeader("Content-Disposition", "attachment;filename=\"" + System.Web.HttpUtility.UrlEncode(itemName, System.Text.Encoding.UTF8) + ".jpg" + "\""); CurrentContext.Response.AddHeader("Content-Length", DownloadFile.Length.ToString()); CurrentContext.Response.ContentType = "application/octet-stream"; CurrentContext.Response.TransmitFile(DownloadFile.FullName); CurrentContext.Response.Flush(); } else { Loggers.Debug(new DebugLogInfo() { Message = "二维码未找到" }); } } catch (Exception ex) { CurrentContext.Response.ContentType = "text/plain"; CurrentContext.Response.Write(ex.Message); } finally { CurrentContext.Response.End(); } }
protected override EmptyResponseData ProcessRequest(APIRequest <SetVipIntegralRP> pRequest) { var rd = new EmptyResponseData(); var para = pRequest.Parameters; var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo; //登录状态信息 var vipIntegralDetail = new VipIntegralDetailBLL(loggingSessionInfo); //积分变更业务对象实例化 var objectImagesBLL = new ObjectImagesBLL(loggingSessionInfo); //图片表业务对象实例化 var unitBLL = new t_unitBLL(loggingSessionInfo); var vipIntegralBLL = new VipIntegralBLL(loggingSessionInfo); var vipBLL = new VipBLL(loggingSessionInfo); var vipInfo = vipBLL.GetByID(para.VipID); var unitInfo = unitBLL.GetByID(loggingSessionInfo.CurrentUserRole.UnitId); var pTran = vipIntegralDetail.GetTran(); //事务 var vipIntegral = vipIntegralBLL.GetByID(para.VipID); using (pTran.Connection) { try { var IntegralDetail = new VipIntegralDetailEntity() { Integral = para.Qty, IntegralSourceID = para.IntegralSourceID, ObjectId = "", Reason = para.Reason, Remark = para.Remark }; if (IntegralDetail.Integral != 0) { //变动前积分 string OldIntegral = string.Empty; if (vipIntegral != null) { OldIntegral = (vipIntegral.ValidIntegral ?? 0).ToString(); } else { OldIntegral = "0"; } //变动积分 string ChangeIntegral = (IntegralDetail.Integral ?? 0).ToString(); string vipIntegralDetailId = vipIntegralBLL.AddIntegral(ref vipInfo, unitInfo, IntegralDetail, pTran, loggingSessionInfo); //发送微信积分变动通知模板消息 if (!string.IsNullOrWhiteSpace(vipIntegralDetailId)) { var CommonBLL = new CommonBLL(); CommonBLL.PointsChangeMessage(OldIntegral, vipInfo, ChangeIntegral, vipInfo.WeiXinUserId, loggingSessionInfo); } //增加图片上传 if (!string.IsNullOrEmpty(para.ImageUrl)) { var objectImagesEntity = new ObjectImagesEntity() { ImageId = Guid.NewGuid().ToString(), ObjectId = vipIntegralDetailId, ImageURL = para.ImageUrl }; objectImagesBLL.Create(objectImagesEntity); } } pTran.Commit(); //提交事物 } catch (APIException apiEx) { pTran.Rollback();//回滚事物 throw new APIException(apiEx.ErrorCode, apiEx.Message); } catch (Exception ex) { pTran.Rollback();//回滚事物 throw new Exception(ex.Message); } } return(rd); }
/// <summary> /// 上传图片通用方法 /// </summary> /// <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()); }
private void DownloadQRCode() { string weixinDomain = ConfigurationManager.AppSettings["original_url"]; string sourcePath = this.CurrentContext.Server.MapPath("/QRCodeImage/qrcode.jpg"); string targetPath = this.CurrentContext.Server.MapPath("/QRCodeImage/"); string currentDomain = this.CurrentContext.Request.Url.Host;//当前项目域名 if (currentDomain == "localhost") { currentDomain += ":2330"; } string itemId = FormatParamValue(Request("item_id")); //商品ID string itemName = FormatParamValue(Request("item_name")); //商品名 string imageURL; ObjectImagesBLL objectImagesBLL = new ObjectImagesBLL(CurrentUserInfo); //查找是否已经生成了二维码 ObjectImagesEntity[] objectImagesEntityArray = objectImagesBLL.QueryByEntity(new ObjectImagesEntity() { ObjectId = itemId, Description = "自动生成的产品二维码" }, null); if (objectImagesEntityArray.Length == 0) { string applicationId = ""; //根据CustomerId去取公众号信息 var list = new WApplicationInterfaceBLL(CurrentUserInfo).QueryByEntity(new WApplicationInterfaceEntity { CustomerId = CurrentUserInfo.ClientID, IsDelete = 0 }, null).ToList(); if (list != null && list.Count > 0) { applicationId = list.FirstOrDefault().ApplicationId; } else { //Response.Write("<br>"); //Response.Write("没有获取微信标识"); throw new Exception("该商户没有绑定微信公众号,无法生成商品二维码"); } var wapentity = list.FirstOrDefault();//获取公众号信息 //http://api.dev.chainclouds.com // http://api.dev.chainclouds.com/WXOAuth/AuthUniversal.aspx?customerId=049b0a8f641f4ca7b17b0b7b6291de1f&applicationId=1D7A01FC1E7D41ECBAC2696D0D363315&goUrl=api.dev.chainclouds.com/HtmlApps/html/public/shop/goods_detail.html?rootPage=true&rootPage=true&goodsId=DBF5326F4C5B4B0F8508AB54B0B0EBD4&ver=1448273310707&scope=snsapi_userinfo string itemUrl = weixinDomain + "/WXOAuth/AuthUniversal.aspx?customerId=" + CurrentUserInfo.ClientID + "&applicationId=" + applicationId + "&goUrl=" + weixinDomain + "/HtmlApps/html/public/shop/goods_detail.html?goodsId=" + itemId + "&scope=snsapi_userinfo"; // string itemUrl = "http://*****:*****@"/HeadImage/qrcodeBack.jpg", imageURL, itemName); } //把下载下来的图片的地址存到ObjectImages objectImagesBLL.Create(new ObjectImagesEntity() { ImageId = Utils.NewGuid(), CustomerId = CurrentUserInfo.ClientID, ImageURL = imageURL, ObjectId = itemId, Title = itemName , Description = "自动生成的产品二维码" }); Loggers.Debug(new DebugLogInfo() { Message = "二维码已生成,imageURL:" + imageURL }); } else { imageURL = objectImagesEntityArray[0].ImageURL; } string imagePath = ""; if (imageURL.IndexOf("HeadImage") > -1) { string dirPath = System.AppDomain.CurrentDomain.BaseDirectory; var imageName = imageURL.Substring(imageURL.IndexOf("HeadImage")).Replace("/", @"\"); imagePath = dirPath + imageName;//整个 } else { //兼容老的存放地址 imagePath = targetPath + imageURL.Substring(imageURL.LastIndexOf("/")); } Loggers.Debug(new DebugLogInfo() { Message = "二维码路径,imagePath:" + imageURL }); try { //要下载的文件名 FileInfo DownloadFile = new FileInfo(imagePath); if (DownloadFile.Exists) { CurrentContext.Response.Clear(); CurrentContext.Response.AddHeader("Content-Disposition", "attachment;filename=\"" + System.Web.HttpUtility.UrlEncode(itemName, System.Text.Encoding.UTF8) + ".jpg" + "\""); CurrentContext.Response.AddHeader("Content-Length", DownloadFile.Length.ToString()); CurrentContext.Response.ContentType = "application/octet-stream"; CurrentContext.Response.TransmitFile(DownloadFile.FullName); CurrentContext.Response.Flush(); } else { Loggers.Debug(new DebugLogInfo() { Message = "二维码未找到" }); } } catch (Exception ex) { CurrentContext.Response.ContentType = "text/plain"; CurrentContext.Response.Write(ex.Message); } finally { CurrentContext.Response.End(); } }