public static bool DeleteBeautyServicePackageDetail(int pkid, BeautyServicePackageDetail oldValue, string operateUser) { bool result = false; try { result = BeautyServicePackageDal.DeleteBeautyServicePackageDetail(pkid); var log = new BeautyOprLog { LogType = "DeleteBeautyServicePackageDetail", IdentityID = $"{pkid}", OldValue = JsonConvert.SerializeObject(oldValue), NewValue = null, Remarks = $"删除集团客户礼包详情,详情ID:{pkid}", OperateUser = operateUser, }; LoggerManager.InsertLog("BeautyOprLog", log); } catch (Exception ex) { Logger.Error(ex.Message, ex); }; return(result); }
public Tuple <bool, string> DeleteImportBankMRActivityByBatchCode(string batchCode, string operateUser) { try { var result = TuhuGrouponDbScopeManager.Execute(conn => BankMRActivityDal.DeleteImportBankMRActivityByBatchCode(conn, batchCode)); if (result) { var log = new BeautyOprLog { LogType = "DeleteImportBankMRActivityUsers", IdentityID = $"{batchCode}", OldValue = null, NewValue = null, Remarks = $"活动场次删除用户规则,batchCode:{batchCode},", OperateUser = operateUser, }; LoggerManager.InsertLog("BeautyOprLog", log); } return(Tuple.Create(result, "")); } catch (Exception ex) { Logger.Warn(ex.Message, ex); return(Tuple.Create(false, ex.Message)); } }
public static bool InsertBeautyServicePackageDetail(BeautyServicePackageDetail packageDetail) { bool result = false; try { var insertResult = BeautyServicePackageDal.InsertBeautyServicePackageDetail(packageDetail); result = insertResult.Item1; var log = new BeautyOprLog { LogType = "InsertBeautyServicePackageDetail", IdentityID = $"{insertResult.Item2}", OldValue = null, NewValue = JsonConvert.SerializeObject(packageDetail), Remarks = $"插入礼包详情,礼包ID:{packageDetail.PackageId}", OperateUser = packageDetail.CreateUser, }; LoggerManager.InsertLog("BeautyOprLog", log); } catch (Exception ex) { Logger.Error(ex.Message, ex); }; return(result); }
/// <summary> /// 插入银行活动组配置 /// </summary> /// <param name="config"></param> /// <param name="operateUser"></param> /// <returns></returns> public bool InsertBankActivityGroupConfig(BankActivityGroupConfig config, string operateUser) { bool result = false; try { TuhuGrouponDbScopeManager.Execute(conn => result = BankMRActivityDal.InsertBankActivityGroupConfig(conn, config)); var log = new BeautyOprLog { LogType = "InsertBankActivityGroupConfig", IdentityID = config.ActivityId.ToString(), OldValue = null, NewValue = JsonConvert.SerializeObject(config), Remarks = $"插入银行活动组配置,活动ID:{config.ActivityId}", OperateUser = operateUser, }; LoggerManager.InsertLog("BeautyOprLog", log); } catch (Exception ex) { Logger.Error(ex.Message, ex); }; return(result); }
/// <summary> /// 更新银行活动组名 /// </summary> /// <param name="conn"></param> /// <param name="groupId"></param> /// <param name="groupName"></param> /// <returns></returns> public bool UpdateBankActivityGroupNameByGroupId(Guid groupId, string groupName, string operateUser) { bool result = false; try { var oldValue = SelectBankActivityGroupConfigByGroupId(groupId, 1, 10).Item1.FirstOrDefault()?.GroupName; TuhuGrouponDbScopeManager.Execute(conn => result = BankMRActivityDal.UpdateBankActivityGroupNameByGroupId(conn, groupId, groupName)); var log = new BeautyOprLog { LogType = "UpdateBankActivityGroupNameByGroupId", IdentityID = groupId.ToString(), OldValue = oldValue, NewValue = groupName, Remarks = $"更新银行活动组名,GroupId:{groupId}", OperateUser = operateUser, }; LoggerManager.InsertLog("BeautyOprLog", log); } catch (Exception ex) { Logger.Error(ex.Message, ex); } return(result); }
/// <summary> /// 更新银行活动组配置 /// </summary> /// <param name="config"></param> /// <param name="operateUser"></param> /// <returns></returns> public bool UpdateBankActivityGroupConfigByPKID(BankActivityGroupConfig config, string operateUser) { bool result = false; try { var oldValue = TuhuGrouponDbScopeManagerReadOnly.Execute(conn => BankMRActivityDal.SelectBankActivityGroupConfigByPKID(conn, config.PKID)); TuhuGrouponDbScopeManager.Execute(conn => result = BankMRActivityDal.UpdateBankActivityGroupConfigByPKID(conn, config)); var log = new BeautyOprLog { LogType = "UpdateBankActivityGroupConfigByPKID", IdentityID = config.PKID.ToString(), OldValue = JsonConvert.SerializeObject(oldValue), NewValue = JsonConvert.SerializeObject(config), Remarks = $"更新银行活动组配置,PKID:{config.PKID}", OperateUser = operateUser, }; LoggerManager.InsertLog("BeautyOprLog", log); } catch (Exception ex) { Logger.Error(ex.Message, ex); } return(result); }
/// <summary> /// 更新限购配置 /// </summary> /// <param name="config"></param> /// <returns></returns> public bool UpdateBankMRActivityLimitConfig(BankMRActivityLimitConfig config, string operateUser) { bool result = false; try { var oldValue = FetchBankMRActivityLimitConfig(config.ActivityId); TuhuGrouponDbScopeManager.Execute(conn => result = BankMRActivityDal.UpdateBankMRActivityLimitConfig(conn, config)); UpdateBankMRActivityRoundLimitCount(config.ActivityId, config.RoundLimit); var log = new BeautyOprLog { LogType = "UpdateBankMRActivityLimitConfig", IdentityID = config.ActivityId.ToString(), OldValue = JsonConvert.SerializeObject(oldValue), NewValue = JsonConvert.SerializeObject(config), Remarks = $"更新银行美容限购配置,活动ID:{config.ActivityId}", OperateUser = operateUser, }; LoggerManager.InsertLog("BeautyOprLog", log); } catch (Exception ex) { Logger.Error(ex.Message, ex); }; return(result); }
/// <summary> /// 根据ID删除银行活动组配置 /// </summary> /// <param name="id"></param> /// <param name="operateUser"></param> /// <returns></returns> public bool DeleteBankActivityGroupConfigByPKID(int pkid, string operateUser) { bool result = false; try { var oldValue = TuhuGrouponDbScopeManager.Execute(conn => BankMRActivityDal.SelectBankActivityGroupConfigByPKID(conn, pkid)); TuhuGrouponDbScopeManager.Execute(conn => result = BankMRActivityDal.DeleteBankActivityGroupConfigByPKID(conn, pkid)); var log = new BeautyOprLog { LogType = "DeleteBankActivityGroupConfigByPKID", IdentityID = pkid.ToString(), OldValue = JsonConvert.SerializeObject(oldValue), NewValue = null, Remarks = $"删除银行活动组配置,{pkid}:{pkid}", OperateUser = operateUser, }; LoggerManager.InsertLog("BeautyOprLog", log); } catch (Exception ex) { Logger.Error(ex.Message, ex); } return(result); }
/// <summary> /// 批量向活动场次中导入用户 /// </summary> /// <param name="list">用户</param> /// <param name="roundIds">场次ID</param> /// <param name="operateUser">操作人</param> /// <returns></returns> public bool BatchImportBankMRActivityUsers(List <BankMRActivityUser> list, List <int> roundIds, string operateUser, string importRoundType, string note) { var result = false; string batchCode = $"{DateTime.Now.ToString("yyyyMMddHHmmssfff")}|{importRoundType}"; try { if (list != null && list.Any() && roundIds != null && roundIds.Any()) { TuhuGrouponDbScopeManager.CreateTransaction(conn => { foreach (var roundId in roundIds) { list.ForEach(r => { r.ActivityRoundId = roundId; r.BatchCode = batchCode; }); var batchSize = 2000; var index = 0; while (index < list.Count) { var batch = list.Skip(index).Take(batchSize); var importResult = handler.BatchImportBankMRActivityUsers(conn, batch); if (!importResult) { throw new Exception("银行美容第" + index + 1 + "批导入失败"); } index += batchSize; } var log = new BeautyOprLog { LogType = "BatchImportBankMRActivityUsers", IdentityID = $"{batchCode}", OldValue = null, NewValue = $"导入用户数量{list.Count()}", Remarks = $"活动场次导入用户规则,场次ID:{roundId},{note}", OperateUser = operateUser, }; LoggerManager.InsertLog("BeautyOprLog", log); } result = true; }); } } catch (Exception ex) { Logger.Error("BatchImportBankMRActivityUsers", ex); } return(result); }
public static bool UpdateBeautyServicePackage(BeautyServicePackage package) { bool result = false; try { var oldValue = GetBeautyServicePackage(package.PKID); var writeStr = BeautyServicePackageDal.GetTuhuGrouponWriteConnstr(); using (var dbhelper = new SqlDbHelper(writeStr)) { dbhelper.BeginTransaction(); var updateBeautyServicePackageResult = BeautyServicePackageDal.UpdateBeautyServicePackage(dbhelper, package); BeautyServicePackageDal.UpdateBeautyServicePackageDetailCooperateIdByPackageId(dbhelper, package.PKID, package.CooperateId); if (!updateBeautyServicePackageResult) { throw new Exception("更新兑换码配置失败"); } if (package.IsPackageCodeGenerated && (package.PackageCodeStartTime != oldValue.PackageCodeStartTime || package.PackageCodeEndTime != oldValue.PackageCodeEndTime)) { var updateBeautyServicePackageCodeTimeResult = BeautyServicePackageDal.UpdateBeautyServicePackageCodeTime(dbhelper, package.PKID, package.PackageCodeStartTime, package.PackageCodeEndTime); if (!updateBeautyServicePackageCodeTimeResult) { throw new Exception("更新兑换码时间失败"); } } dbhelper.Commit(); result = true; var log = new BeautyOprLog { LogType = "UpdateBeautyServicePackage", IdentityID = $"{package.PKID}", OldValue = JsonConvert.SerializeObject(oldValue), NewValue = JsonConvert.SerializeObject(package), Remarks = $"修改集团客户礼包,礼包ID为:{package.PKID}", OperateUser = package.UpdateUser, }; LoggerManager.InsertLog("BeautyOprLog", log); } } catch (Exception ex) { Logger.Error(ex.Message, ex); }; return(result); }
public bool SaveBeautyPopUpWindowsConfig(BeautyPopUpWindowsConfig model, string userName) { var result = false; try { var log = new BeautyOprLog { LogType = "SaveBeautyPopUpWindowsConfig", IdentityID = $"{model.PKID}", OldValue = null, NewValue = Newtonsoft.Json.JsonConvert.SerializeObject(model), OperateUser = userName, Remarks = $"新增美容弹窗配置", }; if (model.PKID <= 0) { int pkid = 0; result = DALBeautyHomePageConfig.InsertBeautyPopUpConfig(model, out pkid); log.IdentityID = pkid.ToString(); } else { var oldModel = GetBeautyPopUpWindowsConfigById(model.PKID); if (oldModel.IsRegion) { oldModel.RegionList = GetBeautyPopUpWindowsRegionConfigs(oldModel.PKID)?.ToList(); } log.OldValue = Newtonsoft.Json.JsonConvert.SerializeObject(oldModel); log.Remarks = $"更新美容弹窗配置"; result = DALBeautyHomePageConfig.UpdateBeautyPopUpConfig(model); } if (result) { LoggerManager.InsertLog("BeautyOprLog", log); } } catch (Exception ex) { Logger.Log(Level.Error, ex, "SaveBeautyPopUpWindowsConfig"); throw ex; } return(result); }
public JsonResult SaveBeautyBannerConfig(BeautyHomePageConfig model) { var result = false; string msg = string.Empty; try { var log = new BeautyOprLog { LogType = "SaveBeautyBannerConfig", IdentityID = $"{model.Id}", OldValue = null, NewValue = JsonConvert.SerializeObject(model), OperateUser = User.Identity.Name, Remarks = $"新增美容首页Banner配置", }; if (model.Id > 0) { var oldModel = BeautyHomePageConfigManager.GetBeautyHomePageConfigById(model.Id) ?? new BeautyHomePageConfig(); oldModel.Region = JsonConvert.SerializeObject(MeiRongAcitivityConfigManager.GetRegion(model.Id, 3)); log.OldValue = JsonConvert.SerializeObject(oldModel); log.Remarks = $"更新美容首页Banner配置"; result = BeautyHomePageConfigManager.UpdateBeautyHomePageBannerConfig(model); } else { int outId = 0; result = BeautyHomePageConfigManager.InsertBeautyHomePageBannerConfig(model, ref outId); log.IdentityID = outId.ToString(); } if (result) { LoggerManager.InsertLog("BeautyOprLog", log); UpdateBeautyBannerCache(model.Channel); } } catch (Exception ex) { msg = ex.Message; } return(Json(new { Result = result, Msg = msg })); }
/// <summary> /// 批量导入银行活动白名单 /// </summary> /// <param name="list">白名单</param> /// <param name="operateUser">操作人</param> /// <returns></returns> public bool BatchImportBankActivityWhiteUsers(List <BankActivityWhiteUsers> list, string operateUser) { var result = false; try { if (list != null && list.Any()) { TuhuGrouponDbScopeManager.CreateTransaction(conn => { var batchSize = 2000; var index = 0; while (index < list.Count) { var batch = list.Skip(index).Take(batchSize); var importResult = handler.BatchImportBankActivityWhiteUsers(conn, batch); if (!importResult) { throw new Exception("银行活动白名单第" + index + 1 + "批导入失败"); } index += batchSize; } var log = new BeautyOprLog { LogType = "BatchImportBankMRActivityUsers", IdentityID = "", OldValue = null, NewValue = $"导入白名单数量{list.Count()}", Remarks = "批量导入银行活动白名单", OperateUser = operateUser, }; LoggerManager.InsertLog("BeautyOprLog", log); result = true; }); } } catch (Exception ex) { Logger.Error("BatchImportBankMRActivityUsers", ex); } return(result); }
public async Task <bool> InsertInvalidateBeautyYearCardLog(IEnumerable <string> serviceCodes, int yearCardId, string operateUser, bool result) { bool insertResult = true; if (serviceCodes != null && serviceCodes.Any()) { foreach (var serviceCode in serviceCodes) { var log = new BeautyOprLog { LogType = _yearCardLogType, IdentityID = $"{yearCardId}", OldValue = serviceCode, NewValue = result ? $"作废成功" : "作废失败", Remarks = $"作废美容年卡服务码", OperateUser = operateUser, }; insertResult = await LoggerManager.InsertLogAsync("BeautyOprLog", log); } } return(insertResult); }
public ActionResult UpsertBeautyServicePackageLimitConfig(BeautyServicePackageLimitConfig config) { var result = false; var msg = string.Empty; //if (config != null && config.PackageDetailId > 0 && ((!string.IsNullOrEmpty(config.CycleType) && config.CycleLimit > 0) // || !string.IsNullOrEmpty(config.ProvinceIds))) if (config != null && config.PackageDetailId > 0) { config.CycleLimit = config.CycleLimit; var limitConfigManager = new LimitConfigManager(config); var oldValue = limitConfigManager.GetBeautyServicePackageLimitConfig(); if (config.PKID > 0) { result = limitConfigManager.UpdateBeautyServicePackageLimitConfig(); } else { result = limitConfigManager.InsertBeautyServicePackageLimitConfig(); } var log = new BeautyOprLog { LogType = config.PKID > 0 ? "UpsertBeautyServicePackageLimitConfig" : "InsertBeautyServicePackageLimitConfig", IdentityID = $"{config?.PKID}", OldValue = JsonConvert.SerializeObject(oldValue), NewValue = JsonConvert.SerializeObject(config), Remarks = $"修改限购次数,ID为:{config?.PKID}", OperateUser = HttpContext.User.Identity.Name }; LoggerManager.InsertLog("BeautyOprLog", log); } else { msg = "配置信息不全"; } return(Json(new { Status = result, Msg = msg }, JsonRequestBehavior.AllowGet)); }
public bool DeleteBeautyYearCardCofing(int pkid, string user) { try { var oldObject = GetBeautyYearCardConfigDetail(pkid); var result = DalBeautyYearCardConfig.DeleteBeautyYearCardConfig(pkid); var log = new BeautyOprLog { LogType = "UpdateBeautyYearCardConfig", IdentityID = $"{pkid}", OldValue = JsonConvert.SerializeObject(oldObject), NewValue = null, Remarks = $"删除美容年卡配置", OperateUser = user, }; LoggerManager.InsertLog("BeautyOprLog", log); return(result); } catch (Exception ex) { logger.Error($"DeleteBeautyYearCardCofing:{ex.Message}", ex); return(false); } }
public bool SaveBeautyYearCardConfig(BeautyYearCardModel model, string user) { try { if (model.PKID > 0)//编辑 { model.BeautyYearCardRegions.ForEach(f => { f.CityId = (f.IsAllCity ? null : f.CityId); }); var oldObject = GetBeautyYearCardConfigDetail(model.PKID); var log = new BeautyOprLog { LogType = "UpdateBeautyYearCardConfig", IdentityID = $"{model.PKID}", OldValue = JsonConvert.SerializeObject(oldObject), NewValue = JsonConvert.SerializeObject(model), Remarks = $"更新美容年卡配置", OperateUser = user, }; model.BeautyYearCardRegions.ForEach(f => { f.CityId = (f.IsAllCity ? null : f.CityId); }); var result = DalBeautyYearCardConfig.UpdateBeautyYearCardConfig(model); LoggerManager.InsertLog("BeautyOprLog", log); return(result); } else//新增 { model.CardPrice = Math.Round(model.CardPrice); using (var client = new ProductClient()) { var product = DalBeautyYearCardConfig.GetParentProuductInfo(BeautyYearCardProductId); if (product == null) { return(false); } var pid = client.CreateProductV2(new Service.Product.Models.WholeProductInfo { ProductID = BeautyYearCardProductId, Image_filename = model.CardImageUrl, Description = model.CardName, DefinitionName = product.Item3, PrimaryParentCategory = product.Item2, CatalogName = product.Item1, DisplayName = model.CardName, Name = model.CardName, cy_list_price = model.CardPrice, cy_marketing_price = model.CardPrice, }, user, Service.Product.Enum.ChannelType.MenDian); pid.ThrowIfException(true); if (!string.IsNullOrEmpty(pid.Result)) { model.PID = pid.Result; model.BeautyYearCardRegions.ForEach(f => { f.CityId = (f.IsAllCity ? null : f.CityId); }); var result = DalBeautyYearCardConfig.CreateBeautyYearCardConfig(model); var log = new BeautyOprLog { LogType = "CreateBeautyYearCardConfig", IdentityID = $"{result}", OldValue = null, NewValue = JsonConvert.SerializeObject(model), Remarks = $"创建美容年卡配置", OperateUser = user, }; LoggerManager.InsertLog("BeautyOprLog", log); return(result > 0); } return(false); } } } catch (Exception ex) { logger.Error($"SaveBeautyYearCardConfig:{ex.Message}", ex); return(false); } }
public static Tuple <bool, string> UpdateBeautyServicePackageDetail(BeautyServicePackageDetail packageDetail) { bool result = false; var msg = string.Empty; var writeStr = BeautyServicePackageDal.GetTuhuGrouponWriteConnstr(); using (var dbhelper = new SqlDbHelper(writeStr)) { try { var oldValue = GetBeautyServicePackageDetail(packageDetail.PKID); dbhelper.BeginTransaction(); var updatePackageDetailResult = BeautyServicePackageDal.UpdateBeautyServicePackageDetail(dbhelper, packageDetail); if (!updatePackageDetailResult) { throw new Exception("更新服务码配置失败"); } if (packageDetail.IsServiceCodeGenerated && (oldValue.ServiceCodeStartTime != packageDetail.ServiceCodeStartTime || oldValue.ServiceCodeEndTime != packageDetail.ServiceCodeEndTime)) { if (oldValue.ServiceCodeNum > 10000) { throw new Exception("大于10000暂时不支持修改"); } var updateServiceCodeTimeResult = BeautyServicePackageDal.UpdateServiceCodeTime(dbhelper, packageDetail.PKID, packageDetail.ServiceCodeStartTime, packageDetail.ServiceCodeEndTime); if (!updateServiceCodeTimeResult) { throw new Exception("更新服务码时间失败"); } if (oldValue.ServiceCodeEndTime != packageDetail.ServiceCodeEndTime && packageDetail.ServiceCodeEndTime != null) { var serviceCodes = (GetBeautyServicePackageDetailCodesByPackageDetailId(packageDetail.PKID))?.Select(t => t.ServiceCode)?.ToList(); if (serviceCodes != null && serviceCodes.Any()) { using (var client = new ServiceCodeClient()) { var batchSize = 1000; var index = 0; while (index < serviceCodes.Count) { var batchCodes = serviceCodes.Skip(index).Take(batchSize).ToList(); var kxChangeCodeTimeModel = new ChangeCodeTimeRequest { ServiceCodes = batchCodes, OverdueTime = Convert.ToDateTime(packageDetail.ServiceCodeEndTime) }; var kxChangeResult = client.ChangeOverdueTime(kxChangeCodeTimeModel); if (!kxChangeResult.Success) { throw kxChangeResult.Exception; } if (kxChangeResult.Result != null && kxChangeResult.Result.FailServiceCode != null && kxChangeResult.Result.FailServiceCode.Any()) { var serviceCodeFailedLog = new BeautyOprLog { LogType = "ChangeOverdueTimeFailedCodes", IdentityID = $"{packageDetail.PKID}", OldValue = null, NewValue = JsonConvert.SerializeObject(kxChangeResult.Result.FailServiceCode), Remarks = $"修改服务码过期时间失败", OperateUser = packageDetail.UpdateUser, }; LoggerManager.InsertLog("BeautyOprLog", serviceCodeFailedLog); } index += batchSize; } } } } } dbhelper.Commit(); result = true; var log = new BeautyOprLog { LogType = "UpdateBeautyServicePackageDetail", IdentityID = $"{packageDetail.PKID}", OldValue = JsonConvert.SerializeObject(oldValue), NewValue = JsonConvert.SerializeObject(packageDetail), Remarks = $"修改集团客户礼包详情,详情ID为{packageDetail.PKID}", OperateUser = packageDetail.UpdateUser, }; LoggerManager.InsertLog("BeautyOprLog", log); } catch (Exception ex) { msg = ex.Message; dbhelper.Rollback(); Logger.Error(ex.Message, ex); }; } return(new Tuple <bool, string>(result, msg)); }
/// <summary> /// 根据批次号更新服务码起始时间 /// </summary> /// <param name="user"></param> /// <param name="batchCode"></param> /// <param name="startTime"></param> /// <param name="endTime"></param> /// <returns></returns> public static async Task <Tuple <bool, string> > UpdateBeautyServiceCodeTimeByBatchCode(string user, string batchCode, DateTime startTime, DateTime endTime) { var result = false; var msg = string.Empty; try { var writeStr = BeautyServicePackageDal.GetTuhuGrouponWriteConnstr(); using (var dbhelper = new SqlDbHelper(writeStr)) { dbhelper.BeginTransaction(); var updateCodeResult = BeautyServicePackageDal.UpdateBeautyServicePackageDetailCodeTimeByBatchCode(dbhelper, batchCode, startTime, endTime); if (!updateCodeResult) { throw new Exception("根据批次号更新服务码时间失败,方法UpdateBeautyServicePackageDetailCodeTimeByBatchCode"); } var serviceCodes = BeautyServicePackageDal.SelectServiceCodesByBatchCode(batchCode); if (serviceCodes != null && serviceCodes.Any()) { if (serviceCodes.Count() > 10000) { throw new Exception("暂时不支持服务码数量大于10000的修改操作"); } using (var client = new ServiceCodeClient()) { var batchSize = 1000; var index = 0; while (index < serviceCodes.Count()) { var batchCodes = serviceCodes.Skip(index).Take(batchSize).ToList(); var kxChangeCodeTimeModel = new ChangeCodeTimeRequest { ServiceCodes = batchCodes, OverdueTime = endTime }; var kxChangeResult = client.ChangeOverdueTime(kxChangeCodeTimeModel); if (!kxChangeResult.Success) { throw kxChangeResult.Exception; } if (kxChangeResult.Result != null && kxChangeResult.Result.FailServiceCode != null && kxChangeResult.Result.FailServiceCode.Any()) { var serviceCodeFailedLog = new BeautyOprLog { LogType = "ChangeOverdueTimeFailedCodes", IdentityID = $"{batchCode}", OldValue = null, NewValue = JsonConvert.SerializeObject(kxChangeResult.Result.FailServiceCode), Remarks = $"根据批次号修改服务码过期时间失败,批次:{batchCode},OverdueTime应该改为:{endTime}", OperateUser = user, }; LoggerManager.InsertLog("BeautyOprLog", serviceCodeFailedLog); } index += batchSize; } dbhelper.Commit(); result = true; } } } } catch (Exception ex) { msg = ex.Message; Logger.Error(ex.Message, ex); } return(new Tuple <bool, string>(result, msg)); }
/// <summary> /// 插入或更新银行美容活动配置 /// </summary> /// <param name="config">插入活动配置</param> /// <param name="adConfig">广告位配置</param> /// <param name="operateUser">操作人</param> /// <returns></returns> public bool UpsertBankMRActivityConfig(BankMRActivityConfig config, IEnumerable <BankMRActivityAdConfig> adConfig, string operateUser) { var result = false; try { TuhuGrouponDbScopeManager.CreateTransaction(conn => { if (config.ActivityId != null && config.ActivityId != Guid.Empty) { var currentActivity = GetBankMRActivityConfigByActivityId(config.ActivityId); if (!string.Equals(currentActivity.RoundCycleType, config.RoundCycleType) || currentActivity.StartTime != config.StartTime || currentActivity.EndTime != config.EndTime)//如果活动场次周期类型变了,则需要重新生成活动场次 { BankMRActivityDal.SetBankMRActivityRoundDisable(conn, config.ActivityId); var roundResult = handler.GenerateBankMRActivityRound(conn, config); if (!roundResult) { throw new Exception("生成银行美容活动场次失败"); } } var updateResult = BankMRActivityDal.UpdateBankMRActivityConfig(conn, config); if (!updateResult) { throw new Exception("更新银行美容活动配置失败"); } var log = new BeautyOprLog { LogType = "UpdateBankMRActivityConfig", IdentityID = config.ActivityId.ToString(), OldValue = JsonConvert.SerializeObject(currentActivity), NewValue = JsonConvert.SerializeObject(config), Remarks = $"修改银行美容活动配置,活动ID:{config.ActivityId}", OperateUser = operateUser, }; LoggerManager.InsertLog("BeautyOprLog", log); } else { config.ActivityId = Guid.NewGuid(); adConfig?.ForEach(s => s.ActivityId = config.ActivityId); var insertResult = BankMRActivityDal.InsertBankMRActivityConfig(conn, config); if (insertResult) { var roundResult = handler.GenerateBankMRActivityRound(conn, config); if (!roundResult) { throw new Exception("生成银行美容活动场次失败"); } } else { throw new Exception("插入银行美容活动配置失败"); } var log = new BeautyOprLog { LogType = "InsertBankMRActivityConfig", IdentityID = config.ActivityId.ToString(), OldValue = null, NewValue = JsonConvert.SerializeObject(config), Remarks = $"插入银行美容活动配置,活动ID:{config.ActivityId}", OperateUser = operateUser, }; LoggerManager.InsertLog("BeautyOprLog", log); } if (adConfig != null && adConfig.Any()) { foreach (var ad in adConfig) { if (ad != null && ad.ActivityId != Guid.Empty) { BankMRActivityDal.UpsertBankMRActivityAdConfig(conn, ad); } } var oldAdConfig = BankMRActivityDal.SelectBankMRActivityAdConfigByActivityId(conn, config.ActivityId); var adLog = new BeautyOprLog() { LogType = "UpsertBankMRActivityAdConfig", IdentityID = config.ActivityId.ToString(), OldValue = oldAdConfig != null && oldAdConfig.Any() ? JsonConvert.SerializeObject(oldAdConfig) : string.Empty, NewValue = JsonConvert.SerializeObject(adConfig), Remarks = $"修改银行广告位配置,活动ID:{config.ActivityId}", OperateUser = operateUser, }; LoggerManager.InsertLog("BeautyOprLog", adLog); } result = true; }); } catch (Exception ex) { Logger.Error(ex.Message, ex); } return(result); }