public HttpResponseBase UpdateItemPrice() { string json = string.Empty; try { BLL.gigade.Model.Vendor vendorModel = (BLL.gigade.Model.Vendor)Session["vendor"]; int writerID = (int)vendorModel.vendor_id; JavaScriptSerializer jsSer = new JavaScriptSerializer(); uint priceMasterId = uint.Parse(Request.Form["price_master_id"] ?? "0"); int same_price = (Request.Form["same_price"] ?? "") == "on" ? 1 : 0; string start = Request.Form["event_start"] ?? ""; string end = Request.Form["event_end"] ?? ""; string valid_start = Request.Form["valid_start"]; string valid_end = Request.Form["valid_end"]; string items = Request.Form["Items"]; List<ItemPrice> newPrices = jsSer.Deserialize<List<ItemPrice>>(items); _priceMasterTempMgr = new PriceMasterTempMgr(connectionString); PriceMasterCustom PriceMasterTemp = _priceMasterTempMgr.QueryProdSiteByVendor(new PriceMasterTemp { price_master_id = priceMasterId }).FirstOrDefault(); if (PriceMasterTemp != null) { #region 處理PriceMasterTemp PriceMasterTemp.product_name = Request.Form["product_name"] ?? ""; PriceMasterTemp.same_price = same_price; PriceMasterTemp.user_level = 1;//会员等级默认为 1:普通会员 PriceMasterTemp.user_id = 0; PriceMasterTemp.site_id = 1;//默认站台为吉甲地 if (!string.IsNullOrEmpty(start)) { PriceMasterTemp.event_start = Convert.ToUInt32(CommonFunction.GetPHPTime(start)); } if (!string.IsNullOrEmpty(end)) { PriceMasterTemp.event_end = Convert.ToUInt32(CommonFunction.GetPHPTime(end)); } if (!string.IsNullOrEmpty(valid_start)) { PriceMasterTemp.valid_start = Convert.ToInt32(CommonFunction.GetPHPTime(valid_start)); } if (!string.IsNullOrEmpty(valid_end)) { PriceMasterTemp.valid_end = Convert.ToInt32(CommonFunction.GetPHPTime(valid_end)); } PriceMasterTemp.price = Convert.ToInt32(newPrices.Min(m => m.item_money)); PriceMasterTemp.event_price = Convert.ToInt32(newPrices.Min(m => m.event_money)); if (same_price == 0) { PriceMasterTemp.max_price = Convert.ToInt32(newPrices.Max(m => m.item_money)); PriceMasterTemp.max_event_price = Convert.ToInt32(newPrices.Max(m => m.event_money)); } PriceMasterTemp.cost = Convert.ToInt32(newPrices.Min(m => m.item_cost)); PriceMasterTemp.event_cost = Convert.ToInt32(newPrices.Min(m => m.event_cost)); #endregion bool isExist = false; List<PriceMasterCustom> masterList = _priceMasterTempMgr.QueryProdSiteByVendor(new PriceMasterTemp { site_id = PriceMasterTemp.site_id, user_id = PriceMasterTemp.user_id, user_level = PriceMasterTemp.user_level, product_id = Convert.ToString(PriceMasterTemp.vendor_product_id) }); List<PriceMasterCustom> resultList = masterList.Where(p => p.price_master_id != PriceMasterTemp.price_master_id).ToList(); if (resultList != null && resultList.Count() > 0) { if (PriceMasterTemp.user_id != 0 || (PriceMasterTemp.user_id == 0 && resultList.Where(p => p.user_id == 0).Count() > 0)) { json = "{success:false,msg:'" + Resources.VendorProduct.SITE_EXIST + "'}"; isExist = true; } } if (!isExist) { ArrayList excuteSql = new ArrayList(); // ProductTemp productTemp = null; if (PriceMasterTemp.site_id == 1 && PriceMasterTemp.user_level == 1 && PriceMasterTemp.user_id == 0) { //没有购物金。所以不处理product_temp //#region 處理productTemp //_productTempMgr = new ProductTempMgr(connectionString); //productTemp = _productTempMgr.GetProTempByVendor(new ProductTemp { product_id = PriceMasterTemp.vendor_product_id, Create_Channel = 2 }).FirstOrDefault(); //excuteSql.Add(_productTempMgr.Update(productTemp)); //#endregion #region 處理ProductItem _productItemTempMgr = new ProductItemTempMgr(connectionString); List<ProductItemTemp> productItems = _productItemTempMgr.QueryByVendor(new ProductItemTemp { Product_Id = Convert.ToString(PriceMasterTemp.vendor_product_id), Writer_Id = writerID }); 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 => productItems.Find(n => n.Item_Id == m.item_id).Item_Money = m.item_money); newPrices.ForEach(m => productItems.Find(n => n.Item_Id == m.item_id).Item_Cost = m.item_cost); newPrices.ForEach(m => productItems.Find(n => n.Item_Id == m.item_id).Event_Item_Money = m.event_money); newPrices.ForEach(m => productItems.Find(n => n.Item_Id == m.item_id).Event_Item_Cost = m.event_cost); productItems.ForEach(m => excuteSql.Add(_productItemTempMgr.UpdateByVendor(m))); } #endregion } bool result = true; //处理PriceMasterTemp excuteSql.Add(_priceMasterTempMgr.UpdateTs(PriceMasterTemp)); _itemPriceTempMgr = new ItemPriceTempMgr(connectionString); if (!_itemPriceTempMgr.UpdateByVendor(excuteSql))//执行sql语句 { result = false; } 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.VendorProduct.SAVE_FAIL + "'}"; } 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"])) { _itemPriceTempMgr = new ItemPriceTempMgr(connectionString); uint priceMasterId = uint.Parse(Request.Form["PriceMasterId"]); itemPrices = _itemPriceTempMgr.QueryByVendor(new ItemPrice { price_master_id = priceMasterId }); List<ItemPriceCustom> newAdds = _itemPriceTempMgr.QueryNewAdd(new ItemPrice { price_master_id = priceMasterId }); //说明:当itempricetemp中没有该条数据时,则从product_item_temp 中获取数据信息 edit by shuangshuang0420j 20140909 15:02 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); }