public DataOperation(List<Model.MigrationDataSet> mds, MainForm form) { this.mds = mds; this.connectionString = System.Configuration.ConfigurationSettings.AppSettings["MySqlConnectionString"]; prod = new Product(); pItem = new ProductItem(); pM = new PriceMaster(); iPrice = new ItemPrice(); categorySet = new ProductCategorySet(); pMap = new ProductMigrationMap(); _prodMgr = new ProductMgr(this.connectionString); _priceMgr = new PriceMasterMgr(this.connectionString); _prodItemMgr = new ProductItemMgr(this.connectionString); _itemPriceMgr = new ItemPriceMgr(this.connectionString); _vendorBrandMgr = new VendorBrandMgr(this.connectionString); _vendorMgr = new VendorMgr(this.connectionString); _pMap = new ProductMigrationMgr(this.connectionString); _productCategorySetMgr = new ProductCategorySetMgr(this.connectionString); _productNoticeSetMgr = new ProductNoticeSetMgr(this.connectionString); _productTagSetMgr = new ProductTagSetMgr(this.connectionString); _productPictureMgr = new ProductPictureMgr(this.connectionString); _proStatusHistoryMgr = new ProductStatusHistoryMgr(connectionString); _proSpecMgr = new ProductSpecMgr(connectionString); _siteMgr = new SiteMgr(connectionString); this.form = form; }
public HttpResponseBase GetPriceMaster() { string json = string.Empty; try { if (!string.IsNullOrEmpty(Request.Params["ProductId"])) { uint productId = uint.Parse(Request.Params["ProductId"]); _priceMasterMgr = new PriceMasterMgr(connectionString); List<PriceMasterCustom> proSiteCustom = _priceMasterMgr.Query(new PriceMaster { product_id = productId, child_id = Convert.ToInt32(productId) }); StringBuilder strJson = new StringBuilder("["); if (proSiteCustom != null) { _itemPriceMgr = new ItemPriceMgr(connectionString); ItemPrice query = new ItemPrice { IsPage = true, Limit = 1 }; foreach (var item in proSiteCustom) { strJson.Append("{"); strJson.AppendFormat("price_master_id:{0},product_id:{1},site_id:{2},site_name:\"{3}\"", item.price_master_id, item.product_id, item.site_id, item.site_name); strJson.AppendFormat(",product_name:\"{0}\",product_name_format:\"{1}\",bonus_percent:{2},default_bonus_percent:{3}", item.product_name, PriceMaster.Product_Name_Op(item.product_name), item.bonus_percent, item.default_bonus_percent); strJson.AppendFormat(",user_level_name:\"{0}\",user_email:\"{1}\",user_level:{2}", item.user_level_name, item.user_email, item.user_level); strJson.AppendFormat(",event_start:\"{0}\",user_id:{1}", item.event_start, item.user_id); strJson.AppendFormat(",event_end:\"{0}\"", item.event_end); strJson.AppendFormat(",cost:\"{0}\"", item.cost); strJson.AppendFormat(",event_cost:\"{0}\"", item.event_cost); strJson.AppendFormat(",price_status:\"{0}\"", item.price_status); //if (item.same_price == 1)//edit by hufeng0813w 2014/06/16 Reason:所有單一商品規格不同價時 也去master表中的價格和活動價格 //{ strJson.AppendFormat(",price:\"{0}\"", item.price); strJson.AppendFormat(",event_price:\"{0}\"", item.event_price); //} strJson.AppendFormat(",status:\"{0}\",accumulated_bonus:{1},bonus_percent_start:\"{2}\",bonus_percent_end:\"{3}\",same_price:{4},valid_start:\"{5}\",valid_end:\"{6}\"", item.status, item.accumulated_bonus, item.bonus_percent_start, item.bonus_percent_end, item.same_price, item.valid_start, item.valid_end); strJson.Append("}"); } } strJson.Append("]"); json = strJson.ToString().Replace("}{", "},{"); } } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "[]"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
public JsonResult GetItemPrice() { List<ItemPriceCustom> itemPrices = new List<ItemPriceCustom>(); try { if (!string.IsNullOrEmpty(Request.Form["PriceMasterId"])) { _itemPriceMgr = new ItemPriceMgr(connectionString); uint priceMasterId = uint.Parse(Request.Form["PriceMasterId"]); itemPrices = _itemPriceMgr.Query(new ItemPrice { price_master_id = priceMasterId }); List<ItemPriceCustom> newAdds = _itemPriceMgr.QueryNewAdd(new ItemPrice { price_master_id = priceMasterId }); if (newAdds != null && newAdds.Count > 0) { newAdds.ForEach(m => m.price_master_id = priceMasterId); itemPrices.AddRange(newAdds); } } } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); } return Json(itemPrices); }
public HttpResponseBase UpdateItemPrice() { string json = string.Empty; try { if (!PriceMaster.CheckProdName(Request.Form["product_name"])) { json = "{success:false,msg:'" + Resources.Product.FORBIDDEN_CHARACTER + "'}"; this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; } JavaScriptSerializer jsSer = new JavaScriptSerializer(); uint priceMasterId = uint.Parse(Request.Form["price_master_id"] ?? "0"); float default_bonus_percent = float.Parse(Request.Form["default_bonus_percent"] ?? "1"); float bonus_percent = float.Parse(Request.Form["bonus_percent"] ?? "1"); int same_price = (Request.Form["same_price"] ?? "") == "on" ? 1 : 0; int accumulated_bonus = (Request.Form["accumulated_bonus"] ?? "") == "on" ? 1 : 0; string start = Request.Form["event_start"] != null ? Request.Form["event_start"] : "0";//edit by zhuoqin0830w 2015/01/14 判斷時間是否為null string end = Request.Form["event_end"] != null ? Request.Form["event_end"] : "0";//edit by zhuoqin0830w 2015/01/14 判斷時間是否為null string bonus_start = Request.Form["bonus_percent_start"] ?? ""; string bonus_end = Request.Form["bonus_percent_end"] ?? ""; string valid_start = Request.Form["valid_start"] ?? "0";//edit by zhuoqin0830w 2015/01/28 判斷時間是否為null string valid_end = Request.Form["valid_end"] ?? "0";//edit by zhuoqin0830w 2015/01/28 判斷時間是否為null string items = Request.Form["Items"]; List<ItemPrice> newPrices = jsSer.Deserialize<List<ItemPrice>>(items); _priceMasterMgr = new PriceMasterMgr(connectionString); _priceMasterTsMgr = new PriceMasterTsMgr(""); PriceMaster priceMaster = _priceMasterMgr.Query(new PriceMaster { price_master_id = priceMasterId }).FirstOrDefault(); if (priceMaster != null) { #region 處理PriceMaster priceMaster.user_id = 0; priceMaster.product_name = PriceMaster.Product_Name_FM(Request.Form["productFormat"] ?? ""); priceMaster.same_price = same_price; priceMaster.accumulated_bonus = Convert.ToUInt32(accumulated_bonus); priceMaster.user_level = uint.Parse(Request.Form["user_level"] ?? "1"); if (!string.IsNullOrEmpty(start)) { priceMaster.event_start = Convert.ToUInt32(CommonFunction.GetPHPTime(start)); } if (!string.IsNullOrEmpty(end)) { priceMaster.event_end = Convert.ToUInt32(CommonFunction.GetPHPTime(end)); } if (!string.IsNullOrEmpty(bonus_start)) { priceMaster.bonus_percent_start = Convert.ToUInt32(CommonFunction.GetPHPTime(bonus_start)); } if (!string.IsNullOrEmpty(bonus_end)) { priceMaster.bonus_percent_end = Convert.ToUInt32(CommonFunction.GetPHPTime(bonus_end)); } if (!string.IsNullOrEmpty(valid_start)) { priceMaster.valid_start = Convert.ToInt32(CommonFunction.GetPHPTime(valid_start)); } if (!string.IsNullOrEmpty(valid_end)) { priceMaster.valid_end = Convert.ToInt32(CommonFunction.GetPHPTime(valid_end)); } if (!string.IsNullOrEmpty(Request.Form["user_id"])) { _usersMgr = new UsersMgr(connectionString); System.Data.DataTable dt_User = _usersMgr.Query(Request.Form["user_id"]); if (dt_User != null && dt_User.Rows.Count > 0) { priceMaster.user_id = Convert.ToUInt32(dt_User.Rows[0]["user_id"]); } } priceMaster.price = Convert.ToInt32(newPrices.Min(m => m.item_money)); priceMaster.event_price = Convert.ToInt32(newPrices.Min(m => m.event_money)); if (same_price == 0) { priceMaster.max_price = Convert.ToInt32(newPrices.Max(m => m.item_money)); priceMaster.max_event_price = Convert.ToInt32(newPrices.Max(m => m.event_money)); } priceMaster.cost = Convert.ToInt32(newPrices.Min(m => m.item_cost)); priceMaster.event_cost = Convert.ToInt32(newPrices.Min(m => m.event_cost)); priceMaster.bonus_percent = bonus_percent; priceMaster.default_bonus_percent = default_bonus_percent; priceMaster.price_status = 2;//申請審核 #endregion bool isExist = false; List<PriceMasterCustom> masterList = _priceMasterMgr.Query(new PriceMaster { site_id = priceMaster.site_id, user_id = priceMaster.user_id, user_level = priceMaster.user_level, product_id = priceMaster.product_id }); List<PriceMasterCustom> resultList = masterList.Where(p => p.price_master_id != priceMaster.price_master_id).ToList(); if (resultList != null && resultList.Count() > 0) { if (priceMaster.user_id != 0 || (priceMaster.user_id == 0 && resultList.Where(p => p.user_id == 0).Count() > 0)) { json = "{success:false,msg:'" + Resources.Product.SITE_EXIST + "'}"; isExist = true; } } if (!isExist) { ArrayList excuteSql = new ArrayList(); Product product = null; if (priceMaster.site_id == 1 && priceMaster.user_level == 1 && priceMaster.user_id == 0) { #region 處理Product _productMgr = new ProductMgr(connectionString); product = _productMgr.Query(new Product { Product_Id = priceMaster.product_id }).FirstOrDefault(); if (product != null) { product.Default_Bonus_Percent = default_bonus_percent; product.Bonus_Percent = bonus_percent; } excuteSql.Add(_productMgr.Update(product, 0)); #endregion #region 處理ProductItem //_productItemMgr = new ProductItemMgr(connectionString); //List<ProductItem> productItems = _productItemMgr.Query(new ProductItem { Product_Id = priceMaster.product_id }); //if (productItems != null) //{ // if (!string.IsNullOrEmpty(start)) // { // productItems.ForEach(m => m.Event_Product_Start = Convert.ToUInt32(CommonFunction.GetPHPTime(start))); // } // if (!string.IsNullOrEmpty(end)) // { // productItems.ForEach(m => m.Event_Product_End = Convert.ToUInt32(CommonFunction.GetPHPTime(end))); // } // newPrices.ForEach(m =>{ // ProductItem pi = productItems.Find(n => n.Item_Id == m.item_id); // pi.Item_Money = m.item_money; // pi.Item_Cost = m.item_cost; // pi.Event_Item_Money = m.event_money; // pi.Event_Item_Cost = m.event_cost; // }); // productItems.ForEach(m => excuteSql.Add(_productItemMgr.Update(m))); //} #endregion } //價格修改 申請審核 PriceUpdateApply priceUpdateApply = new PriceUpdateApply { price_master_id = priceMasterId }; priceUpdateApply.apply_user = Convert.ToUInt32((Session["caller"] as Caller).user_id); //價格審核記錄 PriceUpdateApplyHistory applyHistroy = new PriceUpdateApplyHistory(); applyHistroy.user_id = Convert.ToInt32(priceUpdateApply.apply_user); //applyHistroy.price_status = 1; //applyHistroy.type = 3; applyHistroy.price_status = 1; //edit by wwei0216w 2014/12/16 價格修改時 price_status為 2申請審核 applyHistroy.type = 1;//edit by wwei0216w 所作操作為 1:申請審核的操作 _priceUpdateApplyMgr = new PriceUpdateApplyMgr(connectionString); _priceUpdateApplyHistoryMgr = new PriceUpdateApplyHistoryMgr(connectionString); _tableHistoryMgr = new TableHistoryMgr(connectionString); bool result = true; int apply_id = _priceUpdateApplyMgr.Save(priceUpdateApply); if (apply_id != -1) { priceMaster.apply_id = Convert.ToUInt32(apply_id); applyHistroy.apply_id = apply_id; //excuteSql.Add(_priceMasterMgr.Update(priceMaster)); excuteSql.Add(_priceMasterTsMgr.UpdateTs(priceMaster)); //修改站台價格,不再更新price_master表,改為更新price_master_ts表 edit by xiangwang0413w 2014/07/21 excuteSql.Add(_priceUpdateApplyHistoryMgr.SaveSql(applyHistroy)); //item_price_id==0 新增規格,做新增動作 _itemPriceMgr = new ItemPriceMgr(connectionString); newPrices.FindAll(m => m.item_price_id == 0).ForEach(m => excuteSql.Add(_itemPriceMgr.Save(m))); _functionMgr = new FunctionMgr(connectionString); string function = Request.Params["function"] ?? ""; Function fun = _functionMgr.QueryFunction(function, "/Product/ProductSave"); int functionid = fun == null ? 0 : fun.RowId; HistoryBatch batch = new HistoryBatch { functionid = functionid }; batch.batchno = Request.Params["batch"] ?? ""; batch.kuser = (Session["caller"] as Caller).user_email; if (_tableHistoryMgr.SaveHistory<PriceMaster>(priceMaster, batch, excuteSql)) { //_itemPriceMgr = new ItemPriceMgr(""); _itemPriceTsMgr = new ItemPriceTsMgr(""); foreach (var item in newPrices.FindAll(m => m.item_price_id != 0)) { item.apply_id = (uint)apply_id;//细项与主项使用相同的apply_id excuteSql = new ArrayList(); //excuteSql.Add(_itemPriceMgr.Update(item)); excuteSql.Add(_itemPriceTsMgr.UpdateTs(item));//修改站台價格,不再更新item_price表,改為更新item_price_ts表 edit by xiangwang0413w 2014/07/21 if (!_tableHistoryMgr.SaveHistory<ItemPrice>(item, batch, excuteSql)) { result = false; } } } else { result = false; } } else { result = false; } //若為單一商品,則把product_item.export_flag改為2 edit by xiangwang0413w 2014/06/30 //if (result&&product != null && product.Combination == 1) //{ // _productItemMgr = new ProductItemMgr(connectionString); // ProductItem pro_Item = new ProductItem() { Product_Id = product.Product_Id, Export_flag = 2 }; // _productItemMgr.UpdateExportFlag(pro_Item); //} json = "{success:" + result.ToString().ToLower() + "}"; } } } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "{success:false,msg:'" + Resources.Product.SAVE_FAIL + "'}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
private string QueryHistory(int itemType) { StringBuilder html = new StringBuilder(); try { _historyBatchMgr = new HistoryBatchMgr(connectionString); List<HistoryBatch> batches = _historyBatchMgr.QueryToday(itemType); //edit by hufeng0813w 2014/06/13 batches.Sort(CompareToRowid);//進行一個排序 //end edit by hufeng0813w 2014/06/13 if (batches != null & batches.Count > 0) { html.Append("<html><head><style type=\"text/css\">table{text-align:center; font-size: 13px;border:1px solid #99bce8}caption{text-align:center;border:1px solid #99bce8;} td{border:1px solid #99bce8}.red{color:red;}.green{color:green;}.tstyle{width:250px;}</style></head><body>"); _tableHistoryMgr = new TableHistoryMgr(connectionString); _tableHistoryItemMgr = new TableHistoryItemMgr(connectionString); html.Append("<ul style=\"list-style:none\">"); string channelInfo = ""; int batchIndex = -1; foreach (var batch in batches) { //edit by hufeng0813w Reason:如果是商品對照異動通知 batchIndex++; if (itemType == 1) { channelInfo += "<b>" + batch.channel_name_full + "</b> (外站商品編號:" + batch.channel_detail_id + ")<br/>"; if (batchIndex == 0 || (batches[batchIndex].channel_detail_id == batches[batchIndex - 1].channel_detail_id && batches[batchIndex].channel_name_full == batches[batchIndex].channel_name_full && batches[batchIndex].kdate == batches[batchIndex - 1].kdate) || batchIndex < batches.Count - 1) { continue; } } List<TableHistory> histories = _tableHistoryMgr.Query(new TableHistory { batchno = batch.batchno.ToString() }); if (histories != null && histories.Count > 0) { Array tbls = histories.GroupBy(m => m.table_name).Select(m => m.Key).ToArray(); List<TableHistoryItem> items; uint productId = 0; #region 初始化 StringBuilder pro = new StringBuilder(); StringBuilder spec = new StringBuilder(); StringBuilder category = new StringBuilder(); StringBuilder item = new StringBuilder(); StringBuilder master = new StringBuilder(); StringBuilder price = new StringBuilder(); #endregion foreach (var tbl in tbls) { string tblName = tbl.ToString().ToLower(); bool isAdd = false; #region 針對不同表的處理 switch (tblName) { case "product": #region PRODUCT items = _tableHistoryItemMgr.Query4Batch(new TableHistoryItemQuery { batchno = batch.batchno.ToString(), table_name = tblName }); if (items != null && items.Count > 0) { StringBuilder column_1 = new StringBuilder("<tr><td>欄位名稱</td>"); StringBuilder column_2 = new StringBuilder("<tr><td>修改前</td>"); StringBuilder column_3 = new StringBuilder("<tr><td>修改後</td>"); Array cols = items.GroupBy(m => m.col_name).Select(m => m.Key).ToArray(); foreach (var col in cols) { var tmp = items.FindAll(m => m.col_name == col.ToString()); if (tmp.Count == 1 && string.IsNullOrEmpty(tmp.FirstOrDefault().old_value)) { continue; } else { tmp.Remove(tmp.Find(m => string.IsNullOrEmpty(m.old_value))); var first = tmp.FirstOrDefault(); var last = tmp.LastOrDefault(); if (first == last) { GetParamCon(last, true); } else { GetParamCon(first, true); } GetParamCon(last, false); column_1.AppendFormat("<td>{0}</td>", first.col_chsname); column_2.AppendFormat("<td class=\"red\">{0}</td>", first == last ? last.old_value : first.old_value); column_3.AppendFormat("<td class=\"green\">{0}</td>", last.col_value); isAdd = true; } } if (isAdd) { pro.AppendFormat("<table class=\"tstyle\">{0}</tr>{1}</tr>{2}</tr></table>", column_1, column_2, column_3); } if (productId == 0) { productId = uint.Parse(histories.Find(m => m.table_name == tblName).pk_value); } } #endregion break; case "product_spec": #region SPEC StringBuilder spec_1 = new StringBuilder("<tr><td>修改前</td>"); StringBuilder spec_2 = new StringBuilder("<tr><td>修改後</td>"); Array specIds = histories.FindAll(m => m.table_name.ToLower() == tblName).GroupBy(m => m.pk_value).Select(m => m.Key).ToArray(); foreach (var id in specIds) { items = _tableHistoryItemMgr.Query4Batch(new TableHistoryItemQuery { batchno = batch.batchno.ToString(), table_name = tblName, pk_value = id.ToString() }); if (items.Count == 1 && string.IsNullOrEmpty(items.FirstOrDefault().old_value)) { continue; } else { items.Remove(items.Find(m => string.IsNullOrEmpty(m.old_value))); var first = items.FirstOrDefault(); var last = items.LastOrDefault(); spec_1.AppendFormat("<td class=\"red\">{0}</td>", first == last ? last.old_value : first.old_value); spec_2.AppendFormat("<td class=\"green\">{0}</td>", last.col_value); isAdd = true; } } if (isAdd) { spec.AppendFormat("<table class=\"tstyle\">{0}</tr>{1}</tr></table>", spec_1, spec_2); } if (productId == 0) { _productSpecMgr = new ProductSpecMgr(connectionString); ProductSpec pSpec = _productSpecMgr.Query(new ProductSpec { spec_id = uint.Parse(histories.Find(m => m.table_name == tblName).pk_value) }).FirstOrDefault(); if (pSpec != null) { productId = pSpec.product_id; } } #endregion break; case "product_category_set": #region CATEGORY if (productId == 0) { productId = uint.Parse(histories.Find(m => m.table_name.ToLower() == tblName).pk_value); } items = _tableHistoryItemMgr.Query4Batch(new TableHistoryItemQuery { batchno = batch.batchno.ToString(), table_name = tblName, pk_value = productId.ToString() }); if (items.Count > 0) { var first = items.FirstOrDefault(); var last = items.LastOrDefault(); category.Append("<table class=\"tstyle\"><tr><td>修改前</td><td>修改後</td></tr>"); category.AppendFormat("<tr><td class=\"red\">{0}</td>", first == last ? last.old_value : first.old_value); category.AppendFormat("<td class=\"green\">{0}</td></td></table>", last.col_value); } #endregion break; case "product_item": #region ITEM ProductItem pItem; _productItemMgr = new ProductItemMgr(connectionString); Array itemIds = histories.FindAll(m => m.table_name.ToLower() == tblName).GroupBy(m => m.pk_value).Select(m => m.Key).ToArray(); foreach (var id in itemIds) { isAdd = false; pItem = _productItemMgr.Query(new ProductItem { Item_Id = uint.Parse(id.ToString()) }).FirstOrDefault(); if (pItem != null) { if (productId == 0) { productId = pItem.Product_Id; } string title = pItem.GetSpecName(); string top = "<div style=\"float:left\"><table class=\"tstyle\"><caption>" + title + "</caption><tr><td>欄位名稱</td><td>修改前</td><td>修改后</td></tr>"; string bottom = "</table></div>"; string strContent = "<tr><td>{0}</td><td class=\"red\">{1}</td><td class=\"green\">{2}</td></tr>"; string content = BuildContent(batch.batchno.ToString(), tblName, id.ToString(), strContent, ref isAdd); if (isAdd) { item.Append(top); item.Append(content); item.Append(bottom); } } } #endregion break; case "price_master": #region PRICE_MASTER PriceMaster pMaster; _priceMasterMgr = new PriceMasterMgr(connectionString); Array masterIds = histories.FindAll(m => m.table_name.ToLower() == tblName).GroupBy(m => m.pk_value).Select(m => m.Key).ToArray(); foreach (var id in masterIds) { isAdd = false; pMaster = _priceMasterMgr.Query(new PriceMaster { price_master_id = uint.Parse(id.ToString()) }).FirstOrDefault(); if (pMaster != null) { if (productId == 0) { productId = pMaster.product_id; } string siteName = QuerySiteName(pMaster.site_id.ToString()); string userLevel = QueryParaName(pMaster.user_level.ToString(), "UserLevel"); string userMail = pMaster.user_id == 0 ? "" : QueryMail(pMaster.user_id.ToString()); string childName = string.Empty; if (pMaster.child_id != 0 && pMaster.product_id != pMaster.child_id) { _productMgr = new ProductMgr(connectionString); Product tmpPro = _productMgr.Query(new Product { Product_Id = Convert.ToUInt32(pMaster.child_id) }).FirstOrDefault(); if (tmpPro != null) { childName = tmpPro.Product_Name; } } string title = siteName + " + " + userLevel + (string.IsNullOrEmpty(userMail) ? "" : (" + " + userMail)) + (string.IsNullOrEmpty(childName) ? "<br/>" : "<br/>子商品: " + childName); if (!title.Contains("子商品")) { title += "<br/>"; } string top = "<div style=\"float:left\"><table class=\"tstyle\"><caption>" + title + "</caption><tr><td>欄位名稱</td><td>修改前</td><td>修改后</td></tr>"; string bottom = "</table></div>"; string strContent = "<tr><td>{0}</td><td class=\"red\">{1}</td><td class=\"green\">{2}</td></tr>"; string content = BuildContent(batch.batchno.ToString(), tblName, id.ToString(), strContent, ref isAdd); if (isAdd) { master.Append(top); master.Append(content); master.Append(bottom); } } } #endregion break; case "item_price": #region ITEM_PRICE ItemPriceCustom itemPrice; PriceMaster tmpMaster; _itemPriceMgr = new ItemPriceMgr(connectionString); _priceMasterMgr = new PriceMasterMgr(connectionString); Array priceIds = histories.FindAll(m => m.table_name.ToLower() == tblName).GroupBy(m => m.pk_value).Select(m => m.Key).ToArray(); foreach (var id in priceIds) { isAdd = false; itemPrice = _itemPriceMgr.Query(new ItemPrice { item_price_id = uint.Parse(id.ToString()) }).FirstOrDefault(); if (itemPrice != null) { tmpMaster = _priceMasterMgr.Query(new PriceMaster { price_master_id = itemPrice.price_master_id }).FirstOrDefault(); if (tmpMaster != null) { if (productId == 0) { productId = tmpMaster.product_id; } string siteName = QuerySiteName(tmpMaster.site_id.ToString()); string userLevel = QueryParaName(tmpMaster.user_level.ToString(), "UserLevel"); string userMail = tmpMaster.user_id == 0 ? "" : QueryMail(tmpMaster.user_id.ToString()); string childName = string.Empty; if (tmpMaster.child_id != 0 && tmpMaster.product_id != tmpMaster.child_id) { _productMgr = new ProductMgr(connectionString); Product tmpPro = _productMgr.Query(new Product { Product_Id = Convert.ToUInt32(tmpMaster.child_id) }).FirstOrDefault(); if (tmpPro != null) { childName = tmpPro.Product_Name; } } string strSpec = itemPrice.spec_name_1 + (string.IsNullOrEmpty(itemPrice.spec_name_2) ? "" : (" + " + itemPrice.spec_name_2)); string title = siteName + " + " + userLevel + (string.IsNullOrEmpty(userMail) ? "" : (" + " + userMail)) + (string.IsNullOrEmpty(childName) ? "<br/>" : "<br/>子商品: " + childName) + "<br/>" + strSpec; if (strSpec == "") { title += "<br/>"; } string top = "<div style=\"float:left\"><table class=\"tstyle\"><caption>" + title + "</caption><tr><td>欄位名稱</td><td>修改前</td><td>修改后</td></tr>"; string bottom = "</table></div>"; string strContent = "<tr><td>{0}</td><td class=\"red\">{1}</td><td class=\"green\">{2}</td></tr>"; string content = BuildContent(batch.batchno.ToString(), tblName, id.ToString(), strContent, ref isAdd); if (isAdd) { price.Append(top); price.Append(content); price.Append(bottom); } } } } #endregion break; default: break; } #endregion } #region 單批次拼接 StringBuilder batchHtml = new StringBuilder(); if (pro.Length > 0) { batchHtml.AppendFormat("<tr><td>商品信息</td><td>{0}</td></tr>", pro); } if (spec.Length > 0) { batchHtml.AppendFormat("<tr><td>規格信息</td><td>{0}</td></tr>", spec); } if (category.Length > 0) { batchHtml.AppendFormat("<tr><td>前臺分類信息</td><td>{0}</td></tr>", category); } if (item.Length > 0) { batchHtml.AppendFormat("<tr><td>商品細項信息</td><td>{0}</td></tr>", item); } if (master.Length > 0) { batchHtml.AppendFormat("<tr><td>站臺商品信息</td><td>{0}</td></tr>", master); } if (price.Length > 0) { batchHtml.AppendFormat("<tr><td>站臺價格信息</td><td>{0}</td></tr>", price); }; if (batchHtml.Length > 0) { _productMgr = new ProductMgr(connectionString); Product product = _productMgr.Query(new Product { Product_Id = productId }).FirstOrDefault(); if (product != null) { string brand = string.Empty; _vendorBrandMgr = new VendorBrandMgr(connectionString); VendorBrand vendorBrand = _vendorBrandMgr.GetProductBrand(new VendorBrand { Brand_Id = product.Brand_Id }); if (vendorBrand != null) { brand = vendorBrand.Brand_Name; } html.AppendFormat("<li><table><tr><td colspan='2'>商品編號:<b>{0}</b> 品牌:<b>{1}</b></td></tr>", productId, brand); html.AppendFormat("<tr><td colspan='2'><b>{0}</b> (修改人:{1}", product.Product_Name, batch.kuser); html.AppendFormat(",修改時間:{0})</td></tr>", batch.kdate.ToString("yyyy/MM/dd HH:mm:ss")); html.Append(batchHtml); if (itemType == 1) { html.AppendFormat("<tr><td colspan='2'>{0}</td></tr>", channelInfo); } html.Append("</table></li>"); } } #endregion } } html.Append("</ul>"); html.Append("</body></html>"); } } catch (Exception) { throw; } return html.ToString(); }
public HttpResponseBase QueryLastModifyRecord() { string result = string.Empty; try { if (!string.IsNullOrEmpty(Request.Form["Product_Id"])) { StringBuilder html = new StringBuilder(); int productId = Convert.ToInt32(Request.Form["Product_Id"]); bool isPro = (Request.Form["Type"] ?? "") == "product"; _tableHistoryMgr = new TableHistoryMgr(connectionString); _tableHistoryItemMgr = new TableHistoryItemMgr(connectionString); TableHistory query = new TableHistory { pk_value = productId.ToString() }; if (isPro) { query.table_name = "product"; } TableHistory lastRec = _tableHistoryMgr.QueryLastModifyByProductId(query); if (lastRec != null) { List<TableHistory> histories = _tableHistoryMgr.Query(new TableHistory { batchno = lastRec.batchno }); if (histories != null && histories.Count > 0) { List<string> tbls = histories.GroupBy(m => m.table_name).Select(m => m.Key).ToList(); uint site = 0, level = 0, userid = 0; string[] priceTable = { "price_master", "item_price" }; if (isPro) { tbls.RemoveAll(m => priceTable.Contains(m)); } else { uint.TryParse(Request.Form["Site_id"], out site); uint.TryParse(Request.Form["User_Level"], out level); uint.TryParse(Request.Form["User_id"], out userid); tbls.RemoveAll(m => !priceTable.Contains(m)); } List<TableHistoryItem> items; #region 初始化 StringBuilder pro = new StringBuilder(); StringBuilder spec = new StringBuilder(); StringBuilder category = new StringBuilder(); StringBuilder item = new StringBuilder(); StringBuilder master = new StringBuilder(); StringBuilder price = new StringBuilder(); NotificationController notification = new NotificationController(); #endregion foreach (var tbl in tbls) { string tblName = tbl.ToString().ToLower(); bool isAdd = false; #region 針對不同表的處理 switch (tblName) { case "product": #region PRODUCT items = _tableHistoryItemMgr.Query4Batch(new TableHistoryItemQuery { batchno = lastRec.batchno, table_name = tblName }); if (items != null && items.Count > 0) { StringBuilder column_1 = new StringBuilder("<tr><td style=\"border:1px solid #99bce8;\">欄位名稱</td>"); StringBuilder column_2 = new StringBuilder("<tr><td style=\"border:1px solid #99bce8;\">修改前</td>"); StringBuilder column_3 = new StringBuilder("<tr><td style=\"border:1px solid #99bce8;\">修改後</td>"); Array cols = items.GroupBy(m => m.col_name).Select(m => m.Key).ToArray(); foreach (var col in cols) { var tmp = items.FindAll(m => m.col_name == col.ToString()); if (tmp.Count == 1 && string.IsNullOrEmpty(tmp.FirstOrDefault().old_value)) { continue; } else { tmp.Remove(tmp.Find(m => string.IsNullOrEmpty(m.old_value))); var first = tmp.FirstOrDefault(); var last = tmp.LastOrDefault(); if (first == last) { notification.GetParamCon(last, true); } else { notification.GetParamCon(first, true); } notification.GetParamCon(last, false); column_1.AppendFormat("<td style=\"border:1px solid #99bce8;\">{0}</td>", first.col_chsname); column_2.AppendFormat("<td style=\"border:1px solid #99bce8;color:Red;\">{0}</td>", first == last ? last.old_value : first.old_value);//class=\"red\" column_3.AppendFormat("<td style=\"border:1px solid #99bce8;color:green;\">{0}</td>", last.col_value);//class=\"green\" isAdd = true; } } if (isAdd) { pro.AppendFormat("<table style=\"width:180px;text-align:center;font-size: 13px;border:1px solid #99bce8;\">{0}</tr>{1}</tr>{2}</tr></table>", column_1, column_2, column_3);//class=\"tbptstyle\" } } #endregion break; case "product_spec": #region SPEC StringBuilder spec_1 = new StringBuilder("<tr><td style=\"border:1px solid #99bce8;\">修改前</td>"); StringBuilder spec_2 = new StringBuilder("<tr><td style=\"border:1px solid #99bce8;\">修改後</td>"); Array specIds = histories.FindAll(m => m.table_name.ToLower() == tblName).GroupBy(m => m.pk_value).Select(m => m.Key).ToArray(); foreach (var id in specIds) { items = _tableHistoryItemMgr.Query4Batch(new TableHistoryItemQuery { batchno = lastRec.batchno, table_name = tblName, pk_value = id.ToString() }); if (items.Count == 1 && string.IsNullOrEmpty(items.FirstOrDefault().old_value)) { continue; } else { items.Remove(items.Find(m => string.IsNullOrEmpty(m.old_value))); var first = items.FirstOrDefault(); var last = items.LastOrDefault(); spec_1.AppendFormat("<td class=\"red\" style=\"border:1px solid #99bce8;color:Red;\">{0}</td>", first == last ? last.old_value : first.old_value); spec_2.AppendFormat("<td class=\"green\" style=\"border:1px solid #99bce8;color:green;\">{0}</td>", last.col_value); isAdd = true; } } if (isAdd) { spec.AppendFormat("<table style=\"width:180px;text-align:center;font-size: 13px;border:1px solid #99bce8;\">{0}</tr>{1}</tr></table>", spec_1, spec_2);//class=\"tbptstyle\" } #endregion break; case "product_category_set": #region CATEGORY items = _tableHistoryItemMgr.Query4Batch(new TableHistoryItemQuery { batchno = lastRec.batchno, table_name = tblName, pk_value = productId.ToString() }); if (items.Count > 0) { var first = items.FirstOrDefault(); var last = items.LastOrDefault(); category.Append("<table style=\"width:180px;text-align:center;font-size: 13px;border:1px solid #99bce8;\"><tr><td style=\"border:1px solid #99bce8;\">修改前</td><td style=\"border:1px solid #99bce8;\">修改後</td></tr>");// class=\"tbptstyle\" category.AppendFormat("<tr><td class=\"red\" style=\"border:1px solid #99bce8;color:Red;\">{0}</td>", first == last ? last.old_value : first.old_value); category.AppendFormat("<td class=\"green\" style=\"border:1px solid #99bce8;color:green;\">{0}</td></td></table>", last.col_value); } #endregion break; case "product_item": #region ITEM ProductItem pItem; _productItemMgr = new ProductItemMgr(connectionString); Array itemIds = histories.FindAll(m => m.table_name.ToLower() == tblName).GroupBy(m => m.pk_value).Select(m => m.Key).ToArray(); foreach (var id in itemIds) { isAdd = false; pItem = _productItemMgr.Query(new ProductItem { Item_Id = uint.Parse(id.ToString()) }).FirstOrDefault(); if (pItem != null) { string title = pItem.GetSpecName(); string top = "<div style=\"float:left\"><table style=\"width:180px;text-align:center;font-size: 13px;border:1px solid #99bce8;\"><caption style=\"text-align:center;border:1px solid #99bce8;\">" + title + "</caption><tr><td style=\"border:1px solid #99bce8;\">欄位名稱</td><td style=\"border:1px solid #99bce8;\">修改前</td><td style=\"border:1px solid #99bce8;\">修改后</td></tr>";//class=\"tbstyle\" string bottom = "</table></div>"; string strContent = "<tr><td style=\"border:1px solid #99bce8;\">{0}</td><td class=\"red\" style=\"border:1px solid #99bce8;color:Red;\">{1}</td><td class=\"green\" style=\"border:1px solid #99bce8;color:green;\">{2}</td></tr>"; string content = notification.BuildContent(lastRec.batchno, tblName, id.ToString(), strContent, ref isAdd); if (isAdd) { item.Append(top); item.Append(content); item.Append(bottom); } } } #endregion break; case "price_master": #region PRICE_MASTER PriceMaster pMaster; _pMaster = new PriceMasterMgr(connectionString); Array masterIds = histories.FindAll(m => m.table_name.ToLower() == tblName).GroupBy(m => m.pk_value).Select(m => m.Key).ToArray(); foreach (var id in masterIds) { isAdd = false; pMaster = _pMaster.Query(new PriceMaster { price_master_id = uint.Parse(id.ToString()) }).FirstOrDefault(); if (pMaster != null && pMaster.site_id == site && pMaster.user_level == level && pMaster.user_id == userid) { string siteName = notification.QuerySiteName(pMaster.site_id.ToString()); string userLevel = notification.QueryParaName(pMaster.user_level.ToString(), "UserLevel"); string userMail = pMaster.user_id == 0 ? "" : notification.QueryMail(pMaster.user_id.ToString()); string childName = string.Empty; if (pMaster.child_id != 0 && pMaster.product_id != pMaster.child_id) { _productMgr = new ProductMgr(connectionString); Product tmpPro = _productMgr.Query(new Product { Product_Id = Convert.ToUInt32(pMaster.child_id) }).FirstOrDefault(); if (tmpPro != null) { childName = tmpPro.Product_Name; } } string title = siteName + " + " + userLevel + (string.IsNullOrEmpty(userMail) ? "" : (" + " + userMail)) + (string.IsNullOrEmpty(childName) ? "<br/>" : "<br/>子商品: " + childName); if (!title.Contains("子商品")) { title += "<br/>"; } string top = "<div style=\"float:left\"><table style=\"width:180px;text-align:center;font-size: 13px;border:1px solid #99bce8;\"><caption style=\"text-align:center;border:1px solid #99bce8;\">" + title + "</caption><tr><td style=\"border:1px solid #99bce8;\">欄位名稱</td><td style=\"border:1px solid #99bce8;\">修改前</td><td style=\"border:1px solid #99bce8;\">修改后</td></tr>";// class=\"tbstyle\" string bottom = "</table></div>"; string strContent = "<tr><td style=\"border:1px solid #99bce8;\">{0}</td><td class=\"red\" style=\"border:1px solid #99bce8;color:Red;\">{1}</td><td class=\"green\" style=\"border:1px solid #99bce8;color:green;\">{2}</td></tr>"; string content = notification.BuildContent(lastRec.batchno, tblName, id.ToString(), strContent, ref isAdd); if (isAdd) { master.Append(top); master.Append(content); master.Append(bottom); } } } #endregion break; case "item_price": #region ITEM_PRICE ItemPriceCustom itemPrice; PriceMaster tmpMaster; _itemPriceMgr = new ItemPriceMgr(connectionString); _pMaster = new PriceMasterMgr(connectionString); Array priceIds = histories.FindAll(m => m.table_name.ToLower() == tblName).GroupBy(m => m.pk_value).Select(m => m.Key).ToArray(); foreach (var id in priceIds) { isAdd = false; itemPrice = _itemPriceMgr.Query(new ItemPrice { item_price_id = uint.Parse(id.ToString()) }).FirstOrDefault(); if (itemPrice != null) { tmpMaster = _pMaster.Query(new PriceMaster { price_master_id = itemPrice.price_master_id }).FirstOrDefault(); if (tmpMaster != null && tmpMaster.site_id == site && tmpMaster.user_level == level && tmpMaster.user_id == userid) { string siteName = notification.QuerySiteName(tmpMaster.site_id.ToString()); string userLevel = notification.QueryParaName(tmpMaster.user_level.ToString(), "UserLevel"); string userMail = tmpMaster.user_id == 0 ? "" : notification.QueryMail(tmpMaster.user_id.ToString()); string childName = string.Empty; if (tmpMaster.child_id != 0 && tmpMaster.product_id != tmpMaster.child_id) { _productMgr = new ProductMgr(connectionString); Product tmpPro = _productMgr.Query(new Product { Product_Id = Convert.ToUInt32(tmpMaster.child_id) }).FirstOrDefault(); if (tmpPro != null) { childName = tmpPro.Product_Name; } } string strSpec = itemPrice.spec_name_1 + (string.IsNullOrEmpty(itemPrice.spec_name_2) ? "" : (" + " + itemPrice.spec_name_2)); string title = siteName + " + " + userLevel + (string.IsNullOrEmpty(userMail) ? "" : (" + " + userMail)) + (string.IsNullOrEmpty(childName) ? "<br/>" : "<br/>子商品: " + childName) + "<br/>" + strSpec; if (strSpec == "") { title += "<br/>"; } string top = "<div style=\"float:left\"><table style=\"width:180px;text-align:center;font-size: 13px;border:1px solid #99bce8;\"><caption style=\"text-align:center;border:1px solid #99bce8;\">" + title + "</caption><tr><td style=\"border:1px solid #99bce8;\">欄位名稱</td><td style=\"border:1px solid #99bce8;\">修改前</td><td style=\"border:1px solid #99bce8;\">修改后</td></tr>";//class=\"tbstyle\" string bottom = "</table></div>"; string strContent = "<tr><td style=\"border:1px solid #99bce8;\">{0}</td><td class=\"red\" style=\"border:1px solid #99bce8;color:Red;\">{1}</td><td class=\"green\" style=\"border:1px solid #99bce8;color:green;\">{2}</td></tr>"; string content = notification.BuildContent(lastRec.batchno, tblName, id.ToString(), strContent, ref isAdd); if (isAdd) { price.Append(top); price.Append(content); price.Append(bottom); } } } } #endregion break; default: break; } #endregion } #region 批次拼接 StringBuilder batchHtml = new StringBuilder(); if (pro.Length > 0) { batchHtml.AppendFormat("<tr><td style=\"border:1px solid #99bce8;\">商品信息</td><td style=\"border:1px solid #99bce8;\">{0}</td></tr>", pro); } if (spec.Length > 0) { batchHtml.AppendFormat("<tr><td style=\"border:1px solid #99bce8;\">規格信息</td><td style=\"border:1px solid #99bce8;\">{0}</td></tr>", spec); } if (category.Length > 0) { batchHtml.AppendFormat("<tr><td style=\"border:1px solid #99bce8;\">前臺分類信息</td><td style=\"border:1px solid #99bce8;\">{0}</td></tr>", category); } if (item.Length > 0) { batchHtml.AppendFormat("<tr><td style=\"border:1px solid #99bce8;\">商品細項信息</td><td style=\"border:1px solid #99bce8;\">{0}</td></tr>", item); } if (master.Length > 0) { batchHtml.AppendFormat("<tr><td style=\"border:1px solid #99bce8;\">站臺商品信息</td><td style=\"border:1px solid #99bce8;\">{0}</td></tr>", master); } if (price.Length > 0) { batchHtml.AppendFormat("<tr><td style=\"border:1px solid #99bce8;\">站臺價格信息</td><td style=\"border:1px solid #99bce8;\">{0}</td></tr>", price); }; if (batchHtml.Length > 0) { _productMgr = new ProductMgr(connectionString); Product product = _productMgr.Query(new Product { Product_Id = Convert.ToUInt32(productId) }).FirstOrDefault(); if (product != null) { string brand = string.Empty; vbMgr = new VendorBrandMgr(connectionString); VendorBrand vendorBrand = vbMgr.GetProductBrand(new VendorBrand { Brand_Id = product.Brand_Id }); if (vendorBrand != null) { brand = vendorBrand.Brand_Name; } _historyBatchMgr = new HistoryBatchMgr(connectionString); HistoryBatch batch = _historyBatchMgr.Query(new HistoryBatch { batchno = lastRec.batchno }); html.Append("<html><head><style type=\"text/css\">table{ font-size: 13px;border:1px solid #99bce8}td{border:1px solid #99bce8} .tbstyle{width:180px;text-align:center;} .red{color:Red;}.green{color:green;} caption{text-align:center;border:1px solid #99bce8}</style></head><body>"); html.AppendFormat("<table style=\"font-size: 13px;border:1px solid #99bce8;\"><tr><td colspan='2' style=\"border:1px solid #99bce8;\">商品編號:<b>{0}</b> 品牌:<b>{1}</b></td></tr>", productId, brand); html.AppendFormat("<tr><td colspan='2' style=\"border:1px solid #99bce8;\"><b>{0}</b> (修改人:{1}", product.Product_Name, batch.kuser); html.AppendFormat(",修改時間:{0})</td></tr>", batch.kdate.ToString("yyyy/MM/dd HH:mm:ss")); html.Append(batchHtml); html.Append("</table>"); html.Append("</body></html>"); } } #endregion } result = "{success:true,html:'" + HttpUtility.HtmlEncode(html.ToString()) + "'}"; } else { result = "{success:true,html:''}"; } } } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); result = "{success:true,html:''}"; } this.Response.Clear(); this.Response.Write(result); this.Response.End(); return this.Response; }
public HttpResponseBase PriceVerify() { string json = string.Empty; try { _pMaster = new PriceMasterMgr(connectionString); _pMasterTsMgr = new PriceMasterTsMgr(connectionString); _itemPriceMgr = new ItemPriceMgr(""); _itemPriceTsMgr = new ItemPriceTsMgr(""); _prodMgr = new ProductMgr(connectionString); _tableHistoryMgr = new TableHistoryMgr(connectionString); _pHMgr = new PriceUpdateApplyHistoryMgr(connectionString); List<PriceMaster> priceMasters = JsonConvert.DeserializeObject<List<PriceMaster>>(Request.Params["priceMasters"]); List<PriceUpdateApplyHistory> pHList = new List<PriceUpdateApplyHistory>(); _functionMgr = new FunctionMgr(connectionString); string function = Request.Params["function"] ?? ""; Function fun = _functionMgr.QueryFunction(function, "/ProductList/PriceVerifyList"); int functionid = fun == null ? 0 : fun.RowId; HistoryBatch batch = new HistoryBatch { functionid = functionid, kuser = (Session["caller"] as Caller).user_email }; string batchNo = CommonFunction.GetPHPTime().ToString() + "_" + (Session["caller"] as Caller).user_id + "_"; int operationType = int.Parse(Request.Params["type"]); //edit by xiangwang0413w 2014/08/12 批量審核價格 foreach (var item in priceMasters) { //加上price_master 表中同一個product_id的所有價格 add by hufeng0813w 2014/06/12 Reason 各自定價父商品和子商品的價格狀態要同時更新 List<PriceMaster> ListpM = _pMasterTsMgr.QueryByApplyId(new PriceMaster { product_id = item.product_id, apply_id = item.apply_id }); //價格審核詳情 PriceUpdateApplyHistory pH = new PriceUpdateApplyHistory(); pH.user_id = (Session["caller"] as Caller).user_id; pH.type = operationType; pH.apply_id = (int)ListpM[0].apply_id; foreach (var pM in ListpM) { ArrayList aList = new ArrayList(); uint applyId = pM.apply_id; batch.batchno = batchNo + pM.product_id; ItemPrice ip = new ItemPrice { price_master_id = pM.price_master_id, apply_id = pM.apply_id }; if (operationType == 1)//核可 { pM.apply_id = 0; pM.price_status = 1; pH.price_status = 1; // 價格狀態為 1 :上架 pH.type = 2; //操作動作為2:核可 pHList.Add(pH); aList.Add(_pMaster.Update(pM));//核可更新price_master表 if (pM.product_id != pM.child_id) { aList.Add(_itemPriceMgr.UpdateFromTs(ip)); //將Item_price_ts相對應數據導入Item_price表 aList.Add(_itemPriceTsMgr.DeleteTs(ip)); //更新成功後,刪除item_price_ts相應數據 } } else//駁回 { pM.price_status = 3; pH.price_status = 3; //加個狀態為 申請駁回 pH.type = 3; //操作動作為 3:駁回 pH.remark = Request.Params["reason"]; pHList.Add(pH); if (pM.product_id != pM.child_id) { aList.Add(_itemPriceTsMgr.DeleteTs(ip)); //更新成功後,刪除item_price_ts相應數據 } } aList.Add(_pMasterTsMgr.DeleteTs(new PriceMaster { price_master_id = pM.price_master_id, apply_id = applyId }));//審核完成後刪除price_master_ts表 _tableHistoryMgr.SaveHistory<PriceMaster>(pM, batch, aList); } } if (operationType == 1)//核可 { string[] prodList = (from p in priceMasters select p.product_id.ToString()).ToArray(); //將 獲取 時間 代碼提前 是後面獲得的 時間 相同 uint TimeNow = uint.Parse(CommonFunction.GetPHPTime(DateTime.Now.ToString()).ToString()); for (int i = 0; i < prodList.Length; i++) { ArrayList pList = new ArrayList(); //查詢product Product product = _prodMgr.Query(new Product() { Product_Id = uint.Parse(prodList[i]) })[0]; if (product.Product_Start < TimeNow && product.Product_End > TimeNow) { product.Product_Start = TimeNow; } //p.Product_Status = 5; //價格審核不應該更改商品狀態 edit by xiangwang0413w 20140826 pList.Add(_prodMgr.Update(product)); batch.batchno = batchNo + product.Product_Id; _tableHistoryMgr.SaveHistory<Product>(product, batch, pList); } } //價格審核記錄 _pHMgr.Save(pHList); json = "{success:true}"; } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "{success:false}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
/// <summary> /// 單一商品 /// </summary> /// <param name="priceMaster"></param> /// <param name="batch"></param> /// <param name="applyId"></param> /// <param name="excuteSql"></param> /// <param name="priceType">1為依折扣,2為依活動價</param> // add by zhuoqin0830w 2015/02/10 /// <param name="chkCost">0 為 活動成本 設定 原成本,1 為 活動成本 依 折數 計算</param> //add by zhuoqin0830w 2015/04/02 /// <returns></returns> public bool SaveSingleProduct(PriceMasterCustom priceMaster, HistoryBatch batch, int applyId, ArrayList excuteSql, int priceType, int chkCost) { bool result = false; if (_tableHistoryMgr.SaveHistory<PriceMaster>(priceMaster, batch, excuteSql)) { _itemPriceTsMgr = new ItemPriceTsMgr(""); _itemPriceMgr = new ItemPriceMgr(connectionString); List<ItemPriceCustom> itemPrices = _itemPriceMgr.Query(new ItemPrice() { price_master_id = priceMaster.price_master_id }); DBTableInfo tableInfo = BLL.gigade.Common.CommonFunction.GetDBInfo<ItemPrice>(); IParametersrcImplMgr parametersrcMgr = new ParameterMgr(connectionString); var paras = parametersrcMgr.QueryUsed(new Parametersrc { ParameterType = "ColumnHistory", ParameterCode = tableInfo.DBName, Used = 1 }); List<string> cols = (from p in paras select p.parameterName.Trim().ToLower()).ToList(); var columns = _tableHistoryMgr.Query_COL_Comment(tableInfo.DBName); string pkName = _tableHistoryMgr.Query_TB_PK(tableInfo.DBName); foreach (var item in itemPrices) { item.apply_id = (uint)applyId; if (priceType == 1) { item.event_money = (uint)CommonFunction.ArithmeticalDiscount((int)item.item_money, priceMaster.event_price_discount);// (uint)Math.Round(item.item_money * priceMaster.event_price_discount * 0.01, 0); //add by zhuoqin0830w 2015/04/02 判斷是否是 依原成本設定值 if (chkCost == 1) { //eidt by zhuoqin0830w 更改商品活動成本驗算公式使活動價乘以折扣 2015/02/27 item.event_cost = (uint)CommonFunction.ArithmeticalDiscount((int)item.event_money, priceMaster.event_cost_discount);// (uint)Math.Round(item.item_cost * priceMaster.event_cost_discount * 0.01, 0); } else { item.event_cost = (uint)priceMaster.event_cost; } } else { item.event_money = (uint)priceMaster.event_price; item.event_cost = (uint)priceMaster.event_cost; } excuteSql = new ArrayList(); excuteSql.Add(_itemPriceTsMgr.UpdateTs(item)); if (_tableHistoryMgr.SaveHistory<ItemPrice>(item, batch, excuteSql, cols, columns, pkName)) { result = true; } } } return result; }