public static int ExamUpdatePrice(QiangGouProductModel model) { using (var dbHelper = new SqlDbHelper(ConnectionHelper.GetDecryptConn("Gungnir"))) { return(dbHelper.ExecuteNonQuery(@"UPDATE Activity..tbl_FlashSaleProducts_Temp WITH(ROWLOCK) SET Price=@Price WHERE ActivityID=@ActivityID AND PID=@PID", CommandType.Text, new SqlParameter[] { new SqlParameter("@Price", model.Price), new SqlParameter("@PID", model.PID), new SqlParameter("@ActivityID", model.ActivityID) })); } }
public ActionResult ExamUpdatePrice(QiangGouProductModel model) { var result = QiangGouManager.ExamUpdatePrice(model); if (result > 0) { var oprLog = new Tuhu.Provisioning.DataAccess.Entity.OprLog(); oprLog.Author = ThreadIdentity.Operator.Name; oprLog.ChangeDatetime = DateTime.Now; oprLog.AfterValue = model.ActivityID.ToString(); oprLog.ObjectType = "FlashSale"; oprLog.Operation = "审核页面改" + model.PID + "价格:改为" + model.Price; new OprLogManager().AddOprLog(oprLog); } return(Json(result)); }
public static int InsertFlashSaleProductsLog(QiangGouProductModel logEntity, string HashKey) { try { var conn = ConfigurationManager.ConnectionStrings["Tuhu_log"].ConnectionString; if (SecurityHelp.IsBase64Formatted(conn)) { conn = SecurityHelp.DecryptAES(conn); } var sql = @"INSERT INTO tuhu_log.[dbo].[FlashSaleProductsLog]([ActivityID],[PID],[HashKey],[Position],[Price],[Label],[TotalQuantity] ,[MaxQuantity],[SaleOutQuantity],[ProductName],[InstallAndPay] ,[IsUsePCode],[Channel],[FalseOriginalPrice],[IsJoinPlace],[IsShow],[InstallService])VALUES(@ActivityId,@Pid,@HashKey, @Position,@Price,@Label,@TotalQuantity,@MaxQuantity,@SaleOutQuantity,@ProductName, @InstallAndPay,@IsUsePCode,@Channel,@FalseOriginalPrice,@IsJoinPlace,@IsShow,@InstallService) "; var dbhelper = new SqlDbHelper(conn); using (var cmd = new SqlCommand(sql)) { cmd.CommandType = CommandType.Text; cmd.Parameters.AddWithValue("@ActivityId", logEntity.ActivityID); cmd.Parameters.AddWithValue("@Pid", logEntity.PID); cmd.Parameters.AddWithValue("@HashKey", HashKey); cmd.Parameters.AddWithValue("@Position", logEntity.Position); cmd.Parameters.AddWithValue("@Price", logEntity.Price); cmd.Parameters.AddWithValue("@Label", logEntity.Label); cmd.Parameters.AddWithValue("@TotalQuantity", logEntity.TotalQuantity); cmd.Parameters.AddWithValue("@MaxQuantity", logEntity.MaxQuantity); cmd.Parameters.AddWithValue("@SaleOutQuantity", logEntity.SaleOutQuantity); cmd.Parameters.AddWithValue("@ProductName", logEntity.ProductName); cmd.Parameters.AddWithValue("@InstallAndPay", logEntity.InstallAndPay); cmd.Parameters.AddWithValue("@IsUsePCode", logEntity.IsUsePCode); cmd.Parameters.AddWithValue("@Channel", logEntity.Channel); cmd.Parameters.AddWithValue("@FalseOriginalPrice", logEntity.FalseOriginalPrice); cmd.Parameters.AddWithValue("@IsJoinPlace", logEntity.IsJoinPlace); cmd.Parameters.AddWithValue("@IsShow", logEntity.IsShow); cmd.Parameters.AddWithValue("@InstallService", logEntity.InstallService); return(dbhelper.ExecuteNonQuery(cmd)); } } catch (Exception e) { Console.WriteLine(e); throw; } }
public static int ExamUpdatePrice(QiangGouProductModel model) => DALQiangGou.ExamUpdatePrice(model);
public static IEnumerable <QiangGouProductModel> CheckPIDSamePriceInOtherActivity(QiangGouProductModel product) => DALQiangGou.CheckPIDSamePriceInOtherActivity(product);
private ActionResult CheckExcelData(IEnumerable <QiangGouSeckillImportModel> data) { int excelRow = 1; List <QiangGouProductModel> products = new List <QiangGouProductModel>(); List <string> errorMessage = new List <string>(); Dictionary <string, string> installPay = new Dictionary <string, string>() { { "不限", "" }, { "在线支付", "PayOnline" }, { "到店安装", "InstallAtShop" }, { "在线支付且到店安装", "PayOnlineAndInstallAtShop" } }; Dictionary <string, bool> isUseCode = new Dictionary <string, bool>() { { "使用", true }, { "不使用", false } }; Dictionary <string, bool> isyes = new Dictionary <string, bool>() { { "是", true }, { "否", false } }; Dictionary <string, string> channels = new Dictionary <string, string> { { "全部", "all" }, { "仅网站", "pc" }, { "仅APP", "app" } }; List <string> tags = new List <string>() { "无", "热卖", "秒杀", "限量" }; foreach (var model in data) { excelRow++; StringBuilder sb = new StringBuilder(); #region PID if (string.IsNullOrWhiteSpace(model.PID)) { sb.Append("PID为空_"); } #endregion #region 排序 int postion = 0; if (!string.IsNullOrWhiteSpace(model.排序) && !int.TryParse(model.排序, out postion)) { sb.Append("排序不合法_"); } #endregion #region 促销价 decimal activityPrice = 0; if (!string.IsNullOrWhiteSpace(model.秒杀价) && !decimal.TryParse(model.秒杀价, out activityPrice)) { sb.Append("促销价不合法_"); } #endregion #region 伪原价 decimal falsePrice = 0; if (!string.IsNullOrWhiteSpace(model.伪原价) && !decimal.TryParse(model.伪原价, out falsePrice)) { sb.Append("伪原价不合法_"); } #endregion #region 每人限购 int max = 0; if (!string.IsNullOrWhiteSpace(model.每人限购) && !int.TryParse(model.每人限购, out max)) { sb.Append("每人限购不合法_"); } #endregion #region 总限购 int total = 0; if (!string.IsNullOrWhiteSpace(model.秒杀库存) && !int.TryParse(model.秒杀库存, out total)) { sb.Append("总限购不合法_"); } #endregion #region 优惠券 if (string.IsNullOrWhiteSpace(model.优惠券)) { model.优惠券 = "不使用"; } if (!isUseCode.ContainsKey(model.优惠券)) { sb.Append("优惠券不合法_"); } #endregion #region 显示 if (string.IsNullOrWhiteSpace(model.显示)) { model.显示 = "是"; } if (!isyes.ContainsKey(model.显示)) { sb.Append("显示不合法_"); } #endregion var error = sb.ToString(); if (!string.IsNullOrWhiteSpace(error)) { errorMessage.Add("第" + excelRow + "行:" + error); } else { var productModel = new QiangGouProductModel() { PID = model.PID, Position = postion, ProductName = model.秒杀标题, Price = activityPrice, FalseOriginalPrice = falsePrice, MaxQuantity = max, TotalQuantity = total, IsUsePCode = isUseCode[model.优惠券], Channel = "all", IsShow = isyes[model.显示] }; //var assembalModel = QiangGouManager.AssemblyProductInstalService(productModel); products.Add(productModel); } } return(Content(JsonConvert.SerializeObject(new { data = products, error = errorMessage, code = 1 }))); }
private ActionResult CheckExcelData(IEnumerable <QiangGouImportModel> data, string aid) { int excelRow = 1; List <QiangGouProductModel> products = new List <QiangGouProductModel>(); List <string> errorMessage = new List <string>(); Dictionary <string, string> installPay = new Dictionary <string, string>() { { "不限", "" }, { "在线支付", "PayOnline" }, { "到店安装", "InstallAtShop" }, { "在线支付且到店安装", "PayOnlineAndInstallAtShop" } }; Dictionary <string, bool> isUseCode = new Dictionary <string, bool>() { { "使用", true }, { "不使用", false } }; Dictionary <string, bool> isyes = new Dictionary <string, bool>() { { "是", true }, { "否", false } }; Dictionary <string, string> channels = new Dictionary <string, string> { { "全部", "all" }, { "仅网站", "pc" }, { "仅APP", "app" } }; List <string> tags = new List <string>() { "无", "热卖", "秒杀", "限量" }; foreach (var model in data) { excelRow++; StringBuilder sb = new StringBuilder(); #region PID if (string.IsNullOrWhiteSpace(model.PID)) { sb.Append("PID为空_"); } #endregion #region 排序 int postion = 0; if (!string.IsNullOrWhiteSpace(model.排序) && !int.TryParse(model.排序, out postion)) { sb.Append("排序不合法_"); } #endregion #region 促销价 decimal activityPrice = 0; if (!string.IsNullOrWhiteSpace(model.促销价) && !decimal.TryParse(model.促销价, out activityPrice)) { sb.Append("促销价不合法_"); } #endregion #region 伪原价 decimal falsePrice = 0; if (!string.IsNullOrWhiteSpace(model.伪原价) && !decimal.TryParse(model.伪原价, out falsePrice)) { sb.Append("伪原价不合法_"); } #endregion #region 每人限购 int max = 0; if (!string.IsNullOrWhiteSpace(model.每人限购) && !int.TryParse(model.每人限购, out max)) { sb.Append("每人限购不合法_"); } #endregion #region 总限购 int total = 0; if (!string.IsNullOrWhiteSpace(model.总限购) && !int.TryParse(model.总限购, out total)) { sb.Append("总限购不合法_"); } //int total = 0; //var saleoutQty = 0; //if (!string.IsNullOrEmpty(model.PID)) // saleoutQty = QiangGouManager.SelectFlashSaleSaleOutQuantity(aid, model.PID)??0; //if (!string.IsNullOrWhiteSpace(model.总限购) && !int.TryParse(model.总限购, out total)) // sb.Append("总限购不合法_"); //else if(!string.IsNullOrWhiteSpace(model.总限购)&&saleoutQty > Convert.ToInt32(model.总限购)) //{ // sb.Append("总限购数量小于已经售出数量请调整_"); //} #endregion #region 安装和支付方式 if (string.IsNullOrWhiteSpace(model.安装和支付方式)) { model.安装和支付方式 = "不限"; } if (!installPay.ContainsKey(model.安装和支付方式)) { sb.Append("安装和支付方式不合法_"); } #endregion #region 优惠券 if (string.IsNullOrWhiteSpace(model.优惠券)) { model.优惠券 = "使用"; } if (!isUseCode.ContainsKey(model.优惠券)) { sb.Append("优惠券不合法_"); } #endregion #region 道 if (string.IsNullOrWhiteSpace(model.道)) { model.道 = "全部"; } if (!channels.ContainsKey(model.道)) { sb.Append("渠道不合法_"); } #endregion #region 是否加入会长限购 if (string.IsNullOrWhiteSpace(model.是否加入会场限购)) { model.是否加入会场限购 = "否"; } if (!isyes.ContainsKey(model.是否加入会场限购)) { sb.Append("是否加入会场限购不合法_"); } #endregion #region 标签 if (string.IsNullOrWhiteSpace(model.标签)) { model.标签 = "无"; } if (!tags.Contains(model.标签)) { sb.Append("标签不合法_"); } #endregion #region 显示 if (string.IsNullOrWhiteSpace(model.显示)) { model.显示 = "是"; } if (!isyes.ContainsKey(model.显示)) { sb.Append("显示不合法_"); } #endregion var error = sb.ToString(); if (!string.IsNullOrWhiteSpace(error)) { errorMessage.Add("第" + excelRow + "行:" + error); } else { var productModel = new QiangGouProductModel() { PID = model.PID, Position = postion, ProductName = model.称, Price = activityPrice, FalseOriginalPrice = falsePrice, MaxQuantity = max, TotalQuantity = total, InstallAndPay = installPay[model.安装和支付方式], IsUsePCode = isUseCode[model.优惠券], Channel = channels[model.道], IsJoinPlace = isyes[model.是否加入会场限购], Label = model.标签, IsShow = isyes[model.显示] }; var assembalModel = QiangGouManager.AssemblyProductInstalService(productModel); products.Add(assembalModel); } } return(Content(JsonConvert.SerializeObject(new { data = products, error = errorMessage, code = 1 }))); }
public static IEnumerable <QiangGouProductModel> CheckPIDSamePriceInOtherActivity(QiangGouProductModel product) { var dic = new Dictionary <string, string>(); using (var dbHelper = new SqlDbHelper(ConnectionHelper.GetDecryptConn("Gungnir"))) { var cmd = new SqlCommand(@"SELECT FS.ActivityID,FSP.Price,FSP.PID FROM Activity..tbl_FlashSale AS FS WITH ( NOLOCK ) JOIN Activity..tbl_FlashSaleProducts AS FSP WITH ( NOLOCK ) ON FSP.ActivityID = FS.ActivityID WHERE FS.EndDateTime > GETDATE() AND FSP.PID = @PID AND FSP.Price <> @Price AND FS.ActivityID<>@ActivityID AND ActiveType IN ( 0, 1 )" ); cmd.CommandType = CommandType.Text; cmd.Parameters.AddWithValue("@PID", product.PID); cmd.Parameters.AddWithValue("@Price", product.Price); cmd.Parameters.AddWithValue("@ActivityID", product.ActivityID); var dt = dbHelper.ExecuteDataTable(cmd); if (dt == null || dt.Rows.Count == 0) { return(null); } return(dt.ConvertTo <QiangGouProductModel>()); } }