public static int SaveTireStockWhite(string pids) { var result = -99; using (var dbHelper = new Tuhu.Component.Common.SqlDbHelper(ConnectionHelper.GetDecryptConn("Gungnir"))) { dbHelper.BeginTransaction(); foreach (var pid in pids.Split(';')) { var isUpdate = DalStockoutStatus.FetchPidStatus(dbHelper, pid); if (isUpdate) { result = DalStockoutStatus.UpdateWhite(dbHelper, pid); } else { result = DalStockoutStatus.InsertWhite(dbHelper, pid); } if (result <= 0) { dbHelper.Rollback(); return(result); } } dbHelper.Commit(); return(1); } }
/// <summary> /// 修改大客户美容服务码 /// </summary> /// <param name="model"></param> /// <param name="pkids"></param> /// <returns></returns> public static bool UpdateBeautyServicePackageDetailCodes(ServiceCodeDetail model, string user, ServiceCodeDetail oldCode) { var result = false; try { if (model.StartTime != null && model.EndTime != null) { using (var dbhelper = new Tuhu.Component.Common.SqlDbHelper(writeConnStr)) { dbhelper.BeginTransaction(); var upResult = true; if (model.PackageDetailCodeId > 0) { var oldValue = BeautyServicePackageDal.GetBeautyServicePackageDetailCodeByPKID(model.PackageDetailCodeId); if (oldValue != null) { #region 只更新服务码起止时间 其余数据保持不变 var newValue = new BeautyServicePackageDetailCode { PKID = model.PackageDetailCodeId, UserId = oldValue.UserId, PackageDetailId = oldValue.PackageDetailId, ServiceCode = oldValue.ServiceCode, IsActive = oldValue.IsActive, StartTime = model.StartTime, EndTime = model.EndTime, PackageCode = oldValue.PackageCode, VipUserId = oldValue.VipUserId }; #endregion upResult = BeautyServicePackageDal.UpdateBeautyServicePackageDetailCodes(dbhelper, newValue); } else { upResult = false; } } if (upResult) { using (var client = new ServiceCodeClient()) { var kxChangeCodeTimeModel = new ChangeCodeTimeRequest { ServiceCodes = new List <string>() { model.ServiceCode }, OverdueTime = model.EndTime }; var kxChangeResult = client.ChangeOverdueTime(kxChangeCodeTimeModel); kxChangeResult.ThrowIfException(true); if (kxChangeResult.Success && kxChangeResult.Result != null && kxChangeResult.Result.SuccessServiceCode.Count() > 0 && string.Equals(kxChangeResult.Result.SuccessServiceCode.FirstOrDefault(), model.ServiceCode)) { result = true; dbhelper.Commit(); var log = new BaoYangOprLog { LogType = "修改大客户美容服务码", IdentityID = oldCode.ServiceCode, OldValue = JsonConvert.SerializeObject(oldCode), NewValue = JsonConvert.SerializeObject(model), Remarks = $"修改服务码有效期:服务码开始时间从{oldCode.StartTime}变更为{model.StartTime},结束时间从{oldCode.EndTime}变更为{model.EndTime}", OperateUser = user, }; LoggerManager.InsertLog("BeautyOprLog", log); } else { throw new Exception($"快修服务修改服务码有效期失败,请求信息:{JsonConvert.SerializeObject(kxChangeCodeTimeModel)},返回信息:{JsonConvert.SerializeObject(kxChangeResult)}"); } } } } } } catch (Exception ex) { Logger.Error(ex.Message, ex); } return(result); }
/// <summary> /// 删除违章查询省份配置 /// </summary> /// <param name="provinceId"></param> /// <returns></returns> public bool DeletePeccancyProvinceConfig(int provinceId, string user) { var result = false; try { using (var dbhelper = new Tuhu.Component.Common.SqlDbHelper(grconnectionString)) { var oldValue = DalPeccancyQueryConfig.GetPeccancyProvinceConfigByProvinceId(provinceId); if (oldValue != null) { var cityConfigs = DalPeccancyQueryConfig.GetPeccancyCitiesByProvinceId(provinceId); if (cityConfigs != null && cityConfigs.Any()) { dbhelper.BeginTransaction(); var deleteProvince = DalPeccancyQueryConfig.DeletePeccancyCityConfigByProvinceId(dbhelper, provinceId); var deleteCity = DalPeccancyQueryConfig.DeletePeccancyProvinceConfig(dbhelper, provinceId);//同时删除该省份下的所有城市配置 if (deleteProvince && deleteCity) { dbhelper.Commit(); result = true; #region 除的省份和城市记录日志 var logs = new List <PeccancyConfigOprLogModel>(); var provinceLog = new PeccancyConfigOprLogModel { LogType = "PeccancyProvinceConfig", IdentityId = $"{oldValue.ProvinceId}", OperationType = "Delete", OldValue = JsonConvert.SerializeObject(oldValue), NewValue = null, Remarks = $"删除 违章查询省份:{oldValue.ProvinceName} 的配置", Operator = user, }; logs.Add(provinceLog); foreach (var city in cityConfigs) { var cityLog = new PeccancyConfigOprLogModel { LogType = "PeccancyCityConfig", IdentityId = $"{city.CityId}", OperationType = "Delete", OldValue = JsonConvert.SerializeObject(city), NewValue = null, Remarks = $"删除 违章查询城市:{city.CityName} 的配置", Operator = user, }; logs.Add(cityLog); } if (logs.Any()) { logs.ForEach(s => LoggerManager.InsertLog("PeccancyConfigOprLog", s)); } #endregion } } else { result = DalPeccancyQueryConfig.DeletePeccancyProvinceConfig(dbhelper, provinceId); if (result) { var log = new PeccancyConfigOprLogModel { LogType = "PeccancyProvinceConfig", IdentityId = $"{oldValue.ProvinceId}", OperationType = "Delete", OldValue = JsonConvert.SerializeObject(oldValue), NewValue = null, Remarks = $"删除 违章查询省份:{oldValue.ProvinceName} 的配置", Operator = user, }; LoggerManager.InsertLog("PeccancyConfigOprLog", log); } } } else { result = true; } } } catch (Exception ex) { Logger.Error("DeletePeccancyProvinceConfig", ex); } return(result); }