public Model.Custom.PriceMasterProductCustom Query(PriceMasterTemp priceMasterTemp) { priceMasterTemp.Replace4MySQL(); StringBuilder stb = new StringBuilder(); try { stb.Append("select a.price_type,a.product_price_list,b.product_name,b.default_bonus_percent,b.bonus_percent,a.bag_check_money,b.accumulated_bonus,b.bonus_percent_start,b.bonus_percent_end,"); stb.Append(" b.price,b.event_price,b.cost,b.event_cost,b.event_start,b.event_end,b.same_price,b.valid_start,b.valid_end,a.show_listprice,a.product_mode from product_temp a right join "); stb.AppendFormat("price_master_temp b on a.writer_id=b.writer_id and a.combo_type=b.combo_type and a.product_id=b.product_id and a.combo_type={0} where a.writer_id={1}", priceMasterTemp.combo_type, priceMasterTemp.writer_Id); stb.AppendFormat(" and b.product_id='{0}' and b.child_id='{1}'", priceMasterTemp.product_id, priceMasterTemp.child_id); return _dbAccess.getSinggleObj<Model.Custom.PriceMasterProductCustom>(stb.ToString()); } catch (Exception ex) { throw new Exception("PriceMasterTempDao.Query-->" + ex.Message + stb.ToString(), ex); } }
public string Save(PriceMasterTemp priceMaster) { priceMaster.Replace4MySQL(); StringBuilder strSql = new StringBuilder(""); try { strSql.Append("insert into price_master_temp(`writer_id`,`product_id`,`site_id`,`user_level`,`user_id`,`product_name`,`bonus_percent`,`default_bonus_percent`,"); strSql.Append("`same_price`,`event_start`,`event_end`,`price_status`,`price`,`event_price`,`child_id`,`combo_type`,`cost`,`event_cost`,`accumulated_bonus`,`bonus_percent_start`"); strSql.AppendFormat(",`bonus_percent_end`,`max_price`,`max_event_price`,`valid_start`,`valid_end`)values({0},'{1}',{2},{3}", priceMaster.writer_Id, string.IsNullOrEmpty(priceMaster.product_id) ? priceMaster.product_id.ToString() : priceMaster.product_id, priceMaster.site_id, priceMaster.user_level); strSql.AppendFormat(",{0},'{1}',{2},{3},{4},", priceMaster.user_id, priceMaster.product_name, priceMaster.bonus_percent, priceMaster.default_bonus_percent, priceMaster.same_price); strSql.AppendFormat("{0},{1},{2},{3},", priceMaster.event_start, priceMaster.event_end, priceMaster.price_status, priceMaster.price); strSql.AppendFormat("{0},'{1}',{2},{3},{4},{5},", priceMaster.event_price, priceMaster.child_id, priceMaster.combo_type, priceMaster.cost, priceMaster.event_cost, priceMaster.accumulated_bonus); strSql.AppendFormat("{0},{1},{2},{3},{4},{5});select @@identity;", priceMaster.bonus_percent_start, priceMaster.bonus_percent_end, priceMaster.max_price, priceMaster.max_event_price, priceMaster.valid_start, priceMaster.valid_end); return strSql.ToString(); } catch (Exception ex) { throw new Exception("PriceMasterTempDao.Save-->" + ex.Message + strSql.ToString(), ex); } }
public string Update(PriceMasterTemp priceMaster) { priceMaster.Replace4MySQL(); try { StringBuilder strSql = new StringBuilder("set sql_safe_updates=0;update price_master_temp set "); strSql.AppendFormat(" writer_id={0},site_id={1},user_level={2},user_id={3},", priceMaster.writer_Id, priceMaster.site_id, priceMaster.user_level, priceMaster.user_id); strSql.AppendFormat("product_name='{0}',bonus_percent={1},default_bonus_percent={2},", priceMaster.product_name, priceMaster.bonus_percent, priceMaster.default_bonus_percent); strSql.AppendFormat("same_price={0},price_status={1},event_start={2},", priceMaster.same_price, priceMaster.price_status, priceMaster.event_start); strSql.AppendFormat("event_end={0},price={1},event_price={2},accumulated_bonus = {3}", priceMaster.event_end, priceMaster.price, priceMaster.event_price, priceMaster.accumulated_bonus); strSql.AppendFormat(",bonus_percent_start={0},bonus_percent_end={1}", priceMaster.bonus_percent_start, priceMaster.bonus_percent_end); strSql.AppendFormat(",cost={0},event_cost={1},child_id={2},max_price={3} ", priceMaster.cost, priceMaster.event_cost, priceMaster.child_id, priceMaster.max_price); strSql.AppendFormat(",max_event_price={0},valid_start={1},valid_end={2} ", priceMaster.max_event_price, priceMaster.valid_start, priceMaster.valid_end); strSql.AppendFormat(" where writer_id={0} and combo_type={1} and product_id='{2}' and child_id='{3}';", priceMaster.writer_Id, priceMaster.combo_type, priceMaster.product_id, priceMaster.child_id); strSql.AppendFormat("set sql_safe_updates = 1;"); return strSql.ToString(); } catch (Exception ex) { throw new Exception("PriceMasterTempDao.Update-->" + ex.Message, ex); } }
public HttpResponseBase SaveItemPrice() { string json = string.Empty; string msg = string.Empty; try { BLL.gigade.Model.Vendor vendorModel = (BLL.gigade.Model.Vendor)Session["vendor"]; int writerID = (int)vendorModel.vendor_id; //获取前台输入的信息 JavaScriptSerializer jsSer = new JavaScriptSerializer(); string items = Request.Form["Items"]; int same_price = (Request.Form["same_price"] ?? "") == "on" ? 1 : 0; string start = Request.Form["event_product_start"] ?? Request.Form["event_start"]; string end = Request.Form["event_product_end"] ?? Request.Form["event_end"]; string valid_start = Request.Form["valid_start"]; string valid_end = Request.Form["valid_end"]; #region product_item_temp 获取product_item_temp和product_temp的数据 ProductTemp proTemp = new ProductTemp(); List<ProductItemTemp> proItemTemps = jsSer.Deserialize<List<ProductItemTemp>>(items); if (!string.IsNullOrEmpty(Request.Form["ProductId"])) { proTemp.Product_Id = Request.Form["ProductId"].ToString(); proItemTemps.ForEach(m => m.Product_Id = proTemp.Product_Id); } //if (!string.IsNullOrEmpty(Request.Form["OldProductId"])) //{ // proTemp.Product_Id = Request.Form["OldProductId"].ToString(); // proItemTemps.ForEach(m => m.Product_Id = proTemp.Product_Id); //} if (!string.IsNullOrEmpty(start)) { proItemTemps.ForEach(m => m.Event_Product_Start = Convert.ToUInt32(CommonFunction.GetPHPTime(start))); } if (!string.IsNullOrEmpty(end)) { proItemTemps.ForEach(m => m.Event_Product_End = Convert.ToUInt32(CommonFunction.GetPHPTime(end))); } if (!string.IsNullOrEmpty(Request.Form["product_price_list"])) { uint product_price_list = 0; uint.TryParse(Request.Form["product_price_list"] ?? "0", out product_price_list); proTemp.Product_Price_List = product_price_list; } if (!string.IsNullOrEmpty(Request.Form["bag_check_money"])) { proTemp.Bag_Check_Money = uint.Parse(Request.Form["bag_check_money"]); } proTemp.show_listprice = Convert.ToUInt32((Request.Form["show_listprice"] ?? "") == "on" ? 1 : 0); proTemp.Writer_Id = writerID; proTemp.Combo_Type = COMBO_TYPE; proItemTemps.ForEach(m => m.Writer_Id = proTemp.Writer_Id); proTemp.Create_Channel = 2; _productTempMgr = new ProductTempMgr(connectionString); #region PriceMasterTemp 获取PriceMasterTemp的数据 PriceMasterTemp priceMasterTemp = new PriceMasterTemp { price_status = 1, same_price = same_price }; priceMasterTemp.product_id = proTemp.Product_Id; priceMasterTemp.combo_type = COMBO_TYPE; priceMasterTemp.product_name = Request.Form["product_name"] ?? ""; priceMasterTemp.writer_Id = proTemp.Writer_Id; priceMasterTemp.site_id = 1;//默認站臺1:吉甲地 priceMasterTemp.user_level = 1; priceMasterTemp.price = Convert.ToInt32(proItemTemps.Min(m => m.Item_Money)); priceMasterTemp.event_price = Convert.ToInt32(proItemTemps.Min(m => m.Event_Item_Money)); priceMasterTemp.cost = Convert.ToInt32(proItemTemps.Min(m => m.Item_Cost)); priceMasterTemp.event_cost = Convert.ToInt32(proItemTemps.Min(m => m.Event_Item_Cost)); if (same_price == 0) { priceMasterTemp.max_price = Convert.ToInt32(proItemTemps.Max(m => m.Item_Money)); priceMasterTemp.max_event_price = Convert.ToInt32(proItemTemps.Max(m => m.Event_Item_Money)); } 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)); } #endregion //执行 _productItemTempMgr = new ProductItemTempMgr(connectionString); _priceMasterTempMgr = new PriceMasterTempMgr(connectionString); if (_productItemTempMgr.UpdateCostMoney(proItemTemps) && _productTempMgr.PriceBonusInfoSaveByVendor(proTemp) > 0)//供應商商品無購物金 { bool result = false; PriceMasterTemp query = new PriceMasterTemp { writer_Id = priceMasterTemp.writer_Id, product_id = proTemp.Product_Id, combo_type = COMBO_TYPE }; if (_priceMasterTempMgr.QueryByVendor(query) == null)//插入 { result = _priceMasterTempMgr.Save(new List<PriceMasterTemp> { priceMasterTemp }, null, null); } else//更新 { result = _priceMasterTempMgr.UpdateByVendor(new List<PriceMasterTemp> { priceMasterTemp }, null); } json = "{success:" + result.ToString().ToLower() + "}"; } else { json = "{success:false}"; } #endregion } 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 string ComboPriceSave() { string json = "{success:true}"; if (!PriceMaster.CheckProdName(Request.Form["product_name"])) { return "{success:false,msg:'" + Resources.Product.FORBIDDEN_CHARACTER + "'}"; } ProductTemp pTemp = new ProductTemp(); List<PriceMasterTemp> pMasterListT = new List<PriceMasterTemp>(); List<PriceMaster> pMasterList = new List<PriceMaster>(); List<List<ItemPrice>> ItemPList = new List<List<ItemPrice>>(); PriceMasterTemp pMasterTemp = new PriceMasterTemp(); if (!string.IsNullOrEmpty(Request.Form["OldProductId"])) { pTemp.Product_Id = Request.Form["OldProductId"]; pMasterTemp.product_id = Request.Form["OldProductId"]; } string paramValue = Request.Params["paramValue"]; #region 參數 int writer_id = (Session["caller"] as Caller).user_id; string product_name = PriceMaster.Product_Name_FM(Request.Params["product_name"]); string price_type = Request.Params["price_type"]; string product_price_list = Request.Params["product_price_list"]; string default_bonus_percent = Request.Params["default_bonus_percent"]; string price = Request.Params["price"]; string cost = Request.Params["cost"]; string max_price = Request.Params["max_price"]; string bonus_percent = Request.Params["bonus_percent"]; string event_price = Request.Params["event_price"]; string event_cost = Request.Params["event_cost"]; string max_event_price = Request.Params["max_event_price"]; string event_start = Request.Params["event_start"]; string event_end = Request.Params["event_end"]; string site_id = Request.Params["site_id"]; string user_level = Request.Params["user_level"]; string user_mail = Request.Params["user_mail"]; string bag_check_money = Request.Params["bag_check_money"] == "" ? "0" : Request.Params["bag_check_money"]; string accumulated_bonus = Request.Params["accumulated_bonus"]; string bonus_percent_start = Request.Params["bonus_percent_start"]; string bonus_percent_end = Request.Params["bonus_percent_end"]; string same_price = Request.Params["same_price"]; string show_listprice = Request.Params["show_listprice"]; string valid_start = Request.Params["valid_start"]; string valid_end = Request.Params["valid_end"]; #endregion List<MakePriceCustom> PriceStore = new List<MakePriceCustom>(); if (price_type == "2")//各自定價 { JavaScriptSerializer jss = new JavaScriptSerializer(); string priceStr = Request.Params["priceStr"]; PriceStore = jss.Deserialize<List<MakePriceCustom>>(priceStr); } if (!string.IsNullOrEmpty(Request.Params["product_id"])) { #region 正式表操作 List<PriceMaster> pMList = new List<PriceMaster>(); //插入price_master _priceMasterMgr = new PriceMasterMgr(connectionString); _priceMasterTsMgr = new PriceMasterTsMgr(connectionString); PriceMaster pMaster = new PriceMaster(); //查詢price_master if (!string.IsNullOrEmpty(Request.Params["price_master_id"])) { pMaster = _priceMasterMgr.Query(new PriceMaster { price_master_id = uint.Parse(Request.Params["price_master_id"]) }).FirstOrDefault(); } pMaster.product_id = uint.Parse(Request.Params["product_id"]); pMaster.child_id = int.Parse(Request.Params["product_id"]); pMaster.site_id = uint.Parse(site_id); uint userId = 0; if (!string.IsNullOrEmpty(Request.Form["user_mail"])) { _usersMgr = new UsersMgr(connectionString); System.Data.DataTable dt_User = _usersMgr.Query(Request.Form["user_mail"]); if (dt_User != null && dt_User.Rows.Count > 0) { userId = Convert.ToUInt32(dt_User.Rows[0]["user_id"]); } } if (userId != 0) { pMaster.user_id = userId; } if (user_level != "") { pMaster.user_level = uint.Parse(user_level); } pMaster.product_name = product_name; pMaster.bonus_percent = float.Parse(bonus_percent); pMaster.cost = int.Parse(cost); pMaster.price = int.Parse(price); pMaster.max_price = int.Parse(max_price); pMaster.max_event_price = int.Parse(max_event_price); pMaster.default_bonus_percent = float.Parse(default_bonus_percent); pMaster.event_price = int.Parse(event_price); pMaster.event_cost = int.Parse(event_cost); pMaster.same_price = int.Parse(same_price); pMaster.price_status = 2;//申請審核 pMaster.accumulated_bonus = uint.Parse(accumulated_bonus); #region 時間 活動時間 if (event_start != "") { pMaster.event_start = Convert.ToUInt32(CommonFunction.GetPHPTime(event_start)); } if (event_end != "") { pMaster.event_end = Convert.ToUInt32(CommonFunction.GetPHPTime(event_end)); } if (bonus_percent_start != "") { pMaster.bonus_percent_start = Convert.ToUInt32(CommonFunction.GetPHPTime(bonus_percent_start)); } if (bonus_percent_end != "") { pMaster.bonus_percent_end = Convert.ToUInt32(CommonFunction.GetPHPTime(bonus_percent_end)); } if (!string.IsNullOrEmpty(valid_start)) { pMaster.valid_start = Convert.ToInt32(CommonFunction.GetPHPTime(valid_start)); } if (!string.IsNullOrEmpty(valid_end)) { pMaster.valid_end = Convert.ToInt32(CommonFunction.GetPHPTime(valid_end)); } #endregion _functionMgr = new FunctionMgr(connectionString); string function = Request.Params["function"] ?? ""; Function fun = _functionMgr.QueryFunction(function, "/ProductCombo"); 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; List<ItemPrice> update = new List<ItemPrice>(); if (price_type == "2") //各自定價 { CreateList(PriceStore, pMaster, null, same_price, ItemPList, pMasterListT, pMasterList, update); } pMasterList.Add(pMaster); try { //價格修改 申請審核 PriceUpdateApply priceUpdateApply = new PriceUpdateApply(); 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.type = 1;//edit by wwei0216w 所作操作為 1:申請審核的操作 _priceUpdateApplyMgr = new PriceUpdateApplyMgr(connectionString); _priceUpdateApplyHistoryMgr = new PriceUpdateApplyHistoryMgr(connectionString); _tableHistoryMgr = new TableHistoryMgr(connectionString); ArrayList excuteSql = new ArrayList(); if (!string.IsNullOrEmpty(Request.Params["price_master_id"])) { #region 修改 priceUpdateApply.price_master_id = pMaster.price_master_id; PriceMaster priceMster = _priceMasterMgr.QueryPMaster(new PriceMaster() { site_id = uint.Parse(site_id), user_level = uint.Parse(user_level == "" ? "0" : user_level), user_id = userId, product_id = uint.Parse(Request.Params["product_id"]), price_master_id = uint.Parse(Request.Params["price_master_id"]) }); //更新price_master if (priceMster != null) { json = "{success:true,msg:'" + Resources.Product.SITE_EXIST + "'}"; } else { int apply_id = _priceUpdateApplyMgr.Save(priceUpdateApply); if (apply_id != -1) { bool flag = false; foreach (var item in pMasterList) { item.apply_id = (uint)apply_id; excuteSql = new ArrayList(); if (item == pMaster) { pMaster.apply_id = Convert.ToUInt32(apply_id); applyHistroy.apply_id = apply_id; excuteSql.Add(_priceUpdateApplyHistoryMgr.SaveSql(applyHistroy)); } //excuteSql.Add(_priceMasterMgr.Update(item)); excuteSql.Add(_priceMasterTsMgr.UpdateTs(item));//edit by xiangwang0413w 2014/07/16 將數據更新到pirce_master_ts表 flag = _tableHistoryMgr.SaveHistory<PriceMaster>(item, batch, excuteSql); } if (flag) { //更新item_price //_itemPriceMgr = new ItemPriceMgr(""); _itemPriceTsMgr = new ItemPriceTsMgr(connectionString); foreach (var iPrice in update) { iPrice.apply_id = (uint)apply_id; excuteSql = new ArrayList(); //excuteSql.Add(_itemPriceMgr.Update(iPrice)); excuteSql.Add(_itemPriceTsMgr.UpdateTs(iPrice));//edit by xiangwang0413w 2014/07/17 將數據更新到pirce_master_ts表 if (!_tableHistoryMgr.SaveHistory<ItemPrice>(iPrice, batch, excuteSql)) { json = "{success:true,msg:'" + Resources.Product.EDIT_FAIL + "'}"; } } json = "{success:true,msg:'" + Resources.Product.EDIT_SUCCESS + "'}"; } else { json = "{success:true,msg:'" + Resources.Product.EDIT_FAIL + "'}"; } } else { json = "{success:true,msg:'" + Resources.Product.EDIT_FAIL + "'}"; } } #endregion } else { #region 新增 string msg = string.Empty; int status = 0; List<ItemPrice> iprice = (ItemPList == null || ItemPList.Count == 0) ? null : ItemPList[pMasterList.IndexOf(pMaster)]; int priceMasterId = _priceMasterMgr.Save(pMaster, iprice, null, ref msg); if (priceMasterId != -1) { priceUpdateApply.price_master_id = Convert.ToUInt32(priceMasterId); int apply_id = _priceUpdateApplyMgr.Save(priceUpdateApply); if (apply_id != -1) { pMaster = _priceMasterMgr.Query(new PriceMaster { price_master_id = Convert.ToUInt32(priceMasterId) }).FirstOrDefault(); pMaster.apply_id = Convert.ToUInt32(apply_id); excuteSql.Add(_priceMasterMgr.Update(pMaster)); excuteSql.Add(_priceMasterTsMgr.UpdateTs(pMaster)); //edit by xiangwang0413w 2014/07/22 更新price_master_ts表後同時更新price_master_ts表,以便價格審核 foreach (var item in pMasterList.FindAll(m => m.product_id != m.child_id)) { iprice = (ItemPList == null || ItemPList.Count == 0) ? null : ItemPList[pMasterList.IndexOf(item)]; priceMasterId = _priceMasterMgr.Save(item, iprice, null, ref msg); pMaster = _priceMasterMgr.Query(new PriceMaster { price_master_id = Convert.ToUInt32(priceMasterId) }).FirstOrDefault(); if (priceMasterId != -1) { priceUpdateApply.price_master_id = Convert.ToUInt32(priceMasterId); pMaster = _priceMasterMgr.Query(new PriceMaster { price_master_id = Convert.ToUInt32(priceMasterId) }).FirstOrDefault(); pMaster.apply_id = Convert.ToUInt32(apply_id); excuteSql.Add(_priceMasterMgr.Update(pMaster)); excuteSql.Add(_priceMasterTsMgr.UpdateTs(pMaster)); //edit by xiangwang0413w 2014/07/22 更新price_master_ts表後同時更新price_master_ts表,以便價格審核 } else { status = 2; } } } else { status = 3; } } else { status = 3; } excuteSql.Add(_priceUpdateApplyHistoryMgr.SaveSql(applyHistroy)); _tableHistoryMgr = new TableHistoryMgr(connectionString); if (_tableHistoryMgr.SaveHistory<PriceMaster>(pMaster, batch, excuteSql)) { status = 1; } else { status = 2; } //foreach (var item in pMasterList) //{ // List<ItemPrice> iprice = (ItemPList == null || ItemPList.Count == 0) ? null : ItemPList[pMasterList.IndexOf(item)]; // int priceMasterId = _priceMasterMgr.Save(item, iprice, null, ref msg); // if (apply_id != -1) // { // pMaster = _priceMasterMgr.Query(new PriceMaster { price_master_id = Convert.ToUInt32(priceMasterId) }).FirstOrDefault(); // } // if (priceMasterId != -1) // { // if (item != pMaster) { status = 1; continue; } // priceUpdateApply.price_master_id = Convert.ToUInt32(priceMasterId); // int apply_id = _priceUpdateApplyMgr.Save(priceUpdateApply); // if (apply_id != -1) // { // pMaster = _priceMasterMgr.Query(new PriceMaster { price_master_id = Convert.ToUInt32(priceMasterId) }).FirstOrDefault(); // pMaster.apply_id = Convert.ToUInt32(apply_id); // applyHistroy.apply_id = apply_id; // excuteSql.Add(_priceMasterMgr.Update(pMaster)); // excuteSql.Add(_priceMasterTsMgr.UpdateTs(pMaster)); //edit by xiangwang0413w 2014/07/22 更新price_master_ts表後同時更新price_master_ts表,以便價格審核 // excuteSql.Add(_priceUpdateApplyHistoryMgr.SaveSql(applyHistroy)); // _tableHistoryMgr = new TableHistoryMgr(connectionString); // if (_tableHistoryMgr.SaveHistory<PriceMaster>(pMaster, batch, excuteSql)) // { // status = 1; // } // else { status = 2; } // } // else { status = 2; } // } // else { status = 3; } //} if (status == 1) { json = "{success:true,msg:'" + Resources.Product.ADD_SUCCESS + "'}"; } else if (status == 2) { json = "{success:false,msg:'" + Resources.Product.SAVE_FAIL + "'}"; } else { json = "{success:false,msg:'" + msg + "'}"; } #endregion } } 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 + "'}"; } #endregion } else { #region 新增至臨時表 try { _productTempMgr = new ProductTempMgr(connectionString); _pMasterTempMgr = new PriceMasterTempMgr(connectionString); //product_temp pTemp.Product_Price_List = uint.Parse(product_price_list); pTemp.Writer_Id = writer_id; pTemp.Combo_Type = COMBO_TYPE; pTemp.Price_type = int.Parse(price_type); pTemp.Bag_Check_Money = uint.Parse(bag_check_money); pTemp.show_listprice = uint.Parse(show_listprice); pTemp.Bonus_Percent = float.Parse(bonus_percent); pTemp.Default_Bonus_Percent = float.Parse(default_bonus_percent); //Price_Master pMasterTemp.product_name = product_name; ; pMasterTemp.default_bonus_percent = float.Parse(default_bonus_percent); pMasterTemp.writer_Id = writer_id; pMasterTemp.combo_type = COMBO_TYPE; //默認站臺1:吉甲地,(按統一價格比例拆分)會員等級1:普通會員 pMasterTemp.site_id = 1; pMasterTemp.user_level = 1; pMasterTemp.same_price = int.Parse(same_price); pMasterTemp.accumulated_bonus = uint.Parse(accumulated_bonus); pMasterTemp.bonus_percent = float.Parse(bonus_percent); pMasterTemp.price = int.Parse(price); pMasterTemp.cost = int.Parse(cost); pMasterTemp.max_price = int.Parse(max_price); pMasterTemp.max_event_price = int.Parse(max_event_price); pMasterTemp.event_price = int.Parse(event_price); pMasterTemp.event_cost = int.Parse(event_cost); #region 時間 活動時間 if (event_start != "") { pMasterTemp.event_start = Convert.ToUInt32(CommonFunction.GetPHPTime(event_start)); } if (event_end != "") { pMasterTemp.event_end = Convert.ToUInt32(CommonFunction.GetPHPTime(event_end)); } if (bonus_percent_start != "") { pMasterTemp.bonus_percent_start = Convert.ToUInt32(CommonFunction.GetPHPTime(bonus_percent_start)); pTemp.Bonus_Percent_Start = Convert.ToUInt32(CommonFunction.GetPHPTime(bonus_percent_start)); } if (bonus_percent_end != "") { pMasterTemp.bonus_percent_end = Convert.ToUInt32(CommonFunction.GetPHPTime(bonus_percent_end)); pTemp.Bonus_Percent_End = Convert.ToUInt32(CommonFunction.GetPHPTime(bonus_percent_end)); } if (!string.IsNullOrEmpty(valid_start)) { pMasterTemp.valid_start = Convert.ToInt32(CommonFunction.GetPHPTime(valid_start)); } if (!string.IsNullOrEmpty(valid_end)) { pMasterTemp.valid_end = Convert.ToInt32(CommonFunction.GetPHPTime(valid_end)); } #endregion pMasterTemp.price_status = 1; _productItemMgr = new ProductItemMgr(connectionString); string oldProductId = "0"; if (!string.IsNullOrEmpty(Request.Form["OldProductId"])) { oldProductId = Request.Form["OldProductId"]; } List<ItemPrice> update = new List<ItemPrice>(); if (price_type == "2") { _combTempMgr = new ProductComboTempMgr(connectionString); List<ProductComboCustom> combResultList = _combTempMgr.priceComboQuery(new ProductComboCustom { Writer_Id = writer_id, Parent_Id = int.Parse(oldProductId.ToString()) }); bool match = true; if (combResultList.Count() > 0) { int countBySearchPile = combResultList.GroupBy(m => m.Pile_Id).Count(); //庫中原有價格數據 int countByStorePile = PriceStore.GroupBy(m => m.Pile_Id).Count(); //頁面store數據 //判斷群組數量是否相同 if (countBySearchPile == countByStorePile) { for (int i = 1; i <= countBySearchPile; i++) { //組合類型為固定或任選時pile_id為0; var tempSearch = combResultList.Where(m => m.Pile_Id == (combResultList[0].Pile_Id == 0 ? 0 : i)).ToList().GroupBy(m => m.Child_Id).ToList(); var tempPrice = PriceStore.Where(m => m.Pile_Id == (combResultList[0].Pile_Id == 0 ? 0 : i)).ToList().GroupBy(m => m.Child_Id).ToList(); //判斷當前組中子商品的數量是否相同 if (tempSearch.Count() == tempPrice.Count()) { foreach (var item in tempPrice) { if (tempSearch.Where(m => m.Key == item.Key.ToString()).ToList().Count() <= 0)//edit 2014/09/24 { match = false; break; } } } else { match = false; break; } } } else { match = false; } } else { match = false; } if (!match) { _combTempMgr = new ProductComboTempMgr(connectionString); _combTempMgr.comboPriceDelete(new ProductComboTemp { Writer_Id = writer_id, Combo_Type = COMBO_TYPE, Parent_Id = oldProductId }); PriceStore.ForEach(rec => rec.price_master_id = 0); } CreateList(PriceStore, null, pMasterTemp, same_price, ItemPList, pMasterListT, pMasterList, update); } pMasterListT.Add(pMasterTemp); //如果原價格為複製價格,則需刪除原複製價格並將child_id設為oldProductId if (oldProductId != "0") { pMasterListT.ForEach(m => { if (m.child_id == "0") { m.child_id = oldProductId; } }); } //查詢 PriceMasterProductCustom queryReust = _pMasterTempMgr.Query(new PriceMasterTemp() { writer_Id = writer_id, child_id = oldProductId, product_id = oldProductId, combo_type = COMBO_TYPE }); //檢查價格類型是否有變動,如果有則刪除原有價格數據 if (queryReust != null) { if (!price_type.Equals(queryReust.price_type.ToString())) { _combTempMgr = new ProductComboTempMgr(connectionString); _combTempMgr.comboPriceDelete(new ProductComboTemp { Writer_Id = writer_id, Combo_Type = COMBO_TYPE, Parent_Id = oldProductId.ToString() }); queryReust = null; } } if (queryReust == null)//插入 { if (price_type == "1") { _pMasterTempMgr.Save(pMasterListT, null, null); } else { _pMasterTempMgr.Save(pMasterListT, ItemPList, null); } } else//更新 { if (price_type == "1") { _pMasterTempMgr.Update(pMasterListT, null); } else { _pMasterTempMgr.Update(pMasterListT, update); } } _productTempMgr.PriceBonusInfoSave(pTemp); } 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 + "'}"; } #endregion } return json; }
public string Delete(PriceMasterTemp priceMasterTemp) { try { StringBuilder strSql = new StringBuilder("set sql_safe_updates = 0;delete from price_master_temp"); strSql.AppendFormat(" where writer_id={0} and combo_type={1}", priceMasterTemp.writer_Id, priceMasterTemp.combo_type); strSql.AppendFormat(" and product_id='{0}';set sql_safe_updates = 1;", priceMasterTemp.product_id); return strSql.ToString(); } catch (Exception ex) { throw new Exception("PriceMasterTempDao.Delete-->" + ex.Message, ex); } }
public string VendorMove2PriceMaster(PriceMasterTemp priceMasterTemp) { try { StringBuilder stb = new StringBuilder("insert into price_master(`product_id`,`site_id`,`user_level`,`user_id`,`product_name`,`accumulated_bonus`"); stb.Append(",`bonus_percent`,`default_bonus_percent`,`same_price`,`event_start`,`event_end`,`price_status`,`price`,`event_price`,`cost`,`event_cost`,`bonus_percent_start`,`bonus_percent_end`,`max_price`,`max_event_price`,`valid_start`,`valid_end`,`child_id`) select {0} as product_id,"); stb.Append("site_id,user_level,user_id,product_name,accumulated_bonus,bonus_percent,default_bonus_percent,same_price,event_start,event_end,price_status,price,event_price,cost,event_cost,bonus_percent_start,bonus_percent_end,max_price,max_event_price,valid_start,valid_end,"); if (priceMasterTemp.combo_type == 2) { stb.Append(" {0} as child_id"); } else if (priceMasterTemp.combo_type == 1) { stb.Append(" 0 as child_id"); } stb.Append(" from price_master_temp where 1=1"); if (priceMasterTemp.writer_Id != 0) { stb.AppendFormat(" and writer_id = {0}", priceMasterTemp.writer_Id); } stb.AppendFormat(" and combo_type={0}", priceMasterTemp.combo_type); stb.AppendFormat(" and product_id='{0}';select @@identity;", priceMasterTemp.product_id); return stb.ToString(); } catch (Exception ex) { throw new Exception("PriceMasterTempDao.VendorMove2PriceMaster-->" + ex.Message, ex); } }
public List<Model.Custom.PriceMasterCustom> QueryProdSiteByVendor(PriceMasterTemp priceMasterTemp) { priceMasterTemp.Replace4MySQL(); StringBuilder strSql = new StringBuilder(""); try { strSql.Append("select price_master_id,accumulated_bonus,product_id as vendor_product_id,site.site_id,site.site_name,pmt.user_level,t.parametername as user_level_name,pmt.user_id,product_name,bonus_percent,default_bonus_percent,"); strSql.Append(" same_price,accumulated_bonus,event_start,event_end,price_status,price,event_price,cost,event_cost,child_id ,pmt.user_id,user_email,s.parametername as status,bonus_percent_start,bonus_percent_end,max_price,max_event_price,valid_start,valid_end from price_master_temp pmt "); strSql.Append(" left join site on site.site_id=pmt.site_id left join users on users.user_id=pmt.user_id "); strSql.Append(" left join (select parametercode,parametername from t_parametersrc where parametertype='userlevel') t on t.parametercode=pmt.user_level"); strSql.Append(" left join (select parametercode,parametername from t_parametersrc where parametertype='price_status') s on s.parametercode=pmt.price_status where 1=1"); if (!string.IsNullOrEmpty(priceMasterTemp.product_id) && priceMasterTemp.product_id != "0") { strSql.AppendFormat(" and product_id='{0}'", priceMasterTemp.product_id); } if (priceMasterTemp.user_id != 0) { strSql.AppendFormat(" and pmt.user_id={0}", priceMasterTemp.user_id); } if (priceMasterTemp.user_level != 0) { strSql.AppendFormat(" and pmt.user_level={0}", priceMasterTemp.user_level); } if (priceMasterTemp.site_id != 0) { strSql.AppendFormat(" and site.site_id={0}", priceMasterTemp.site_id); } if (priceMasterTemp.price_master_id != 0) { strSql.AppendFormat(" and price_master_id={0}", priceMasterTemp.price_master_id); } if (!string.IsNullOrEmpty(priceMasterTemp.child_id) && priceMasterTemp.child_id != "0") { strSql.AppendFormat(" and child_id='{0}'", priceMasterTemp.child_id); } return _dbAccess.getDataTableForObj<Model.Custom.PriceMasterCustom>(strSql.ToString()); } catch (Exception ex) { throw new Exception("PriceMasterTempDao.QueryProdSiteByVendor-->" + ex.Message + strSql.ToString(), ex); } }
public List<Model.Custom.PriceMasterCustom> QueryProdSiteByVendor(PriceMasterTemp priceMasterTemp) { try { return _priceMasterTempDao.QueryProdSiteByVendor(priceMasterTemp); } catch (Exception ex) { throw new Exception("PriceMasterTempMgr-->QueryProdSite-->" + ex.Message, ex); } }
public Model.Custom.PriceMasterProductCustomTemp QueryByVendor(PriceMasterTemp priceMasterTemp) { try { return _priceMasterTempDao.QueryByVendor(priceMasterTemp); } catch (Exception ex) { throw new Exception("PriceMasterTempMgr-->QueryByVendor-->" + ex.Message, ex); } }
public string DeleteByVendor(PriceMasterTemp priceMasterTemp) { return _priceMasterTempDao.DeleteByVendor(priceMasterTemp); }
public string SaveFromPriceMasterByMasterId(PriceMasterTemp priceMasterTemp) { return _priceMasterTempDao.SaveFromPriceMasterByMasterId(priceMasterTemp); }
public int Vendor_TempMove2Pro(int writerId, int combo_type, string product_Id, ProductTemp pt) { ArrayList sqls = new ArrayList(); int product_id = 0; ProductTempMgr proTempMgr = new ProductTempMgr(""); ProductTemp proTemp = new ProductTemp { Combo_Type = combo_type, Product_Id = product_Id, Create_Channel = 2 };//1:後台管理者(manage_user) edit by xiagnwang0413w 2014/08/09 string movePro = proTempMgr.Vendor_MoveProduct(proTemp); sqls.Add(proTempMgr.Vendor_Delete(proTemp)); ProductNoticeSetTempMgr proNoticeSetTempMgr = new ProductNoticeSetTempMgr(""); ProductNoticeSetTemp proNoticeSetTemp = new ProductNoticeSetTemp { Combo_Type = combo_type, product_id = product_Id }; sqls.Add(proNoticeSetTempMgr.Vendor_MoveNotice(proNoticeSetTemp)); sqls.Add(proNoticeSetTempMgr.Vendor_Delete(proNoticeSetTemp)); ProductTagSetTempMgr proTagSetTempMgr = new ProductTagSetTempMgr(""); ProductTagSetTemp proTagSetTemp = new ProductTagSetTemp { Combo_Type = combo_type, product_id = product_Id }; sqls.Add(proTagSetTempMgr.Vendor_MoveTag(proTagSetTemp)); sqls.Add(proTagSetTempMgr.Vendor_Delete(proTagSetTemp)); ProductPictureTempImplMgr proPicTempMgr = new ProductPictureTempImplMgr(""); ProductPictureTemp proPictureTemp = new ProductPictureTemp { combo_type = combo_type, product_id = product_Id }; sqls.Add(proPicTempMgr.Vendor_MoveToProductPicture(proPictureTemp)); sqls.Add(proPicTempMgr.Vendor_Delete(proPictureTemp)); ProductCategorySetTempMgr proCateSetTempMgr = new ProductCategorySetTempMgr(""); ProductCategorySetTemp proCategorySetTemp = new ProductCategorySetTemp { Combo_Type = combo_type, Product_Id = product_Id.ToString() }; sqls.Add(proCateSetTempMgr.Vendor_TempMoveCategory(proCategorySetTemp)); sqls.Add(proCateSetTempMgr.Vendor_TempDelete(proCategorySetTemp)); //product_status_history.type 1,申請審核 2,核可 3,駁回 4,下架 5,新建商品 6,上架 7,系統移轉建立 8,取消送審 parametertype='verify_operate_type' //product_status_history.product_status 0,新建立商品 1,申請審核 2,審核通過 5,上架 6,下架 20,供應商新建商品 parametertype='product_status' ProductStatusHistoryMgr proStatusHistoryMgr = new ProductStatusHistoryMgr(""); sqls.Add(proStatusHistoryMgr.SaveNoProductId(new ProductStatusHistory { product_status = 20, user_id = Convert.ToUInt32(pt.Writer_Id), type = 5 }));//供應商新建立商品 sqls.Add(proStatusHistoryMgr.SaveNoProductId(new ProductStatusHistory { product_status = 0, user_id = Convert.ToUInt32(writerId), type = 2 })); //管理員核可 ItemPriceTempMgr itemTempPriceMgr = new ItemPriceTempMgr(""); sqls.Add(itemTempPriceMgr.Vendor_Delete(product_Id, combo_type, 0)); PriceMasterTempMgr priceMasterTempMgr = new PriceMasterTempMgr(""); PriceMasterTemp priceMasterTemp = new PriceMasterTemp { product_id = product_Id, combo_type = combo_type }; sqls.Add(priceMasterTempMgr.Vendor_Delete(priceMasterTemp)); //判斷是單一商品還是組合商品 if (combo_type == 1) {//單一商品 IProductItemImplDao piDao = new ProductItemDao(connectionStr); ProductItemTempMgr proItemTempMgr = new ProductItemTempMgr(""); ProductItemTemp proItemTemp = new ProductItemTemp { Product_Id = product_Id }; string selItem = proItemTempMgr.VendorQuerySql(proItemTemp); string moveItem = proItemTempMgr.VendorMoveProductItem(proItemTemp);//方法修改了writerId sqls.Add(proItemTempMgr.DeleteVendorSql(proItemTemp)); ProductSpecTempMgr proSpecTempMgr = new ProductSpecTempMgr(""); ProductSpecTemp proSpecTemp = new ProductSpecTemp { product_id = product_Id }; sqls.Add(proSpecTempMgr.VendorTempMoveSpec(proSpecTemp)); sqls.Add(proSpecTempMgr.VendorTempDelete(proSpecTemp)); string priceMaster = priceMasterTempMgr.VendorMove2PriceMaster(priceMasterTemp); ItemPriceMgr itemPriceMgr = new ItemPriceMgr(""); string itemPrice = itemPriceMgr.SaveFromItem(pt.Writer_Id, pt.Product_Id); // add 處理price_mater_temp and product_combo_temp sqls.Add(proTempMgr.VendorEditCM(proTemp)); product_id = _productDao.TempMove2Pro(movePro, "", moveItem, "", selItem, priceMaster, itemPrice, sqls); if (product_id > 0) { piDao.UpdateErpId(product_id.ToString()); } return product_id; } else {//組合商品 ProductComboTempMgr pcTempMgr = new ProductComboTempMgr(""); ProductComboTemp proComboTemp = new ProductComboTemp { Parent_Id = product_Id }; sqls.Add(pcTempMgr.Vendor_TempMoveCombo(proComboTemp)); sqls.Add(pcTempMgr.TempDeleteByVendor(proComboTemp)); string selPrice = priceMasterTempMgr.SelectChild(priceMasterTemp); string priceMaster = priceMasterTempMgr.VendorMove2PriceMaster(priceMasterTemp); ItemPriceTempMgr itemPriceTempMgr = new ItemPriceTempMgr(""); string itemPrice = itemPriceTempMgr.VendorMove2ItemPrice(); sqls.Add(itemPriceTempMgr.Vendor_Delete(product_Id, combo_type, 0)); return _productDao.TempMove2Pro(movePro, "", "", "", selPrice, priceMaster, itemPrice, sqls); } //記錄的sql語句 //insert into product(product_id,brand_id,product_vendor_code,product_name,product_price_list,product_spec,spec_title_1,spec_title_2,product_freight_set,product_buy_limit,product_status,product_hide,product_mode,product_sort,product_start,product_end,page_content_1,page_content_2,page_content_3,product_keywords,product_recommend,product_password,product_total_click,expect_time,product_image,product_createdate,product_updatedate,product_ipfrom,goods_area,goods_image1,goods_image2,city,bag_check_money,combination,bonus_percent,default_bonus_percent,bonus_percent_start,bonus_percent_end,tax_type,cate_id,fortune_quota,fortune_freight,product_media,ignore_stock,shortage,stock_alarm,price_type,user_id,show_listprice,expect_msg,create_channel ) select 15164 as product_id,brand_id,product_vendor_code,product_name,product_price_list,product_spec,spec_title_1,spec_title_2,product_freight_set,product_buy_limit,'0' as product_status,product_hide,product_mode,product_sort,product_start,product_end,page_content_1,page_content_2,page_content_3,product_keywords,product_recommend,product_password,product_total_click,expect_time,product_image,1411033321 as product_createdate,product_updatedate,product_ipfrom,goods_area,goods_image1,goods_image2,city,bag_check_money,combination,bonus_percent,default_bonus_percent,bonus_percent_start,bonus_percent_end,tax_type,cate_id,fortune_quota,fortune_freight,product_media,ignore_stock,shortage,stock_alarm,price_type,writer_id,show_listprice,expect_msg,create_channel from product_temp where 1=1 and combo_type=2 and create_channel=2 and product_id='T578'; //select price_master_id,product_id,child_id from price_master_temp where 1=1 and combo_type=2 and product_id='T578'; //insert into price_master(`product_id`,`site_id`,`user_level`,`user_id`,`product_name`,`accumulated_bonus`,`bonus_percent`,`default_bonus_percent`,`same_price`,`event_start`,`event_end`,`price_status`,`price`,`event_price`,`child_id`,`cost`,`event_cost`,`bonus_percent_start`,`bonus_percent_end`,`max_price`,`max_event_price`,`valid_start`,`valid_end`) //select 15164 as product_id,site_id,user_level,user_id,product_name,accumulated_bonus,bonus_percent,default_bonus_percent,same_price,event_start,event_end,price_status,price,event_price,15164 as child_id,cost,event_cost,bonus_percent_start,bonus_percent_end,max_price,max_event_price,valid_start,valid_end from price_master_temp where 1=1 and combo_type=2 and product_id='T578';select @@identity; //insert into item_price(`price_master_id`,`item_id`,`item_money`,`item_cost`,`event_money`,`event_cost`) select 5699 as price_master_id,item_id,item_money,item_cost,event_money,event_cost from item_price_temp where price_master_id=1751 //set sql_safe_updates = 0;update price_master set child_id=15164 where price_master_id=5699; set sql_safe_updates = 1; //set sql_safe_updates = 0;delete from product_temp where product_id='T578';set sql_safe_updates = 1 //insert into product_notice_set(product_id,notice_id) select 15164 as product_id,notice_id from product_notice_set_temp where 1=1 and combo_type = 2 and product_id='T578'; //set sql_safe_updates=0;delete from product_notice_set_temp where product_id='T578';set sql_safe_updates=1; //insert into product_tag_set(`product_id`,`tag_id`) select 15164 as product_id,tag_id from product_tag_set_temp where 1=1 and combo_type=2 and product_id='T578'; //set sql_safe_updates=0;delete from product_tag_set_temp where product_id='T578';set sql_safe_updates=1; //insert into product_picture(product_id,image_filename,image_sort,image_state,image_createdate) select 15164 as product_id,image_filename,image_sort,image_state,image_createdate from product_picture_temp where 1=1 and product_id='T578' and combo_type=2; //set sql_safe_updates=0; delete from product_picture_temp where product_id='T578';set sql_safe_updates = 1; //insert into product_category_set(product_id,category_id,brand_id) select 15164 as product_id,category_id,brand_id from product_category_set_temp where 1=1 and product_id='T578' and combo_type = 2 //set sql_safe_updates = 0; delete from product_category_set_temp where 1=1 and combo_type = 2 and product_id='T578';set sql_safe_updates = 1; //set sql_safe_updates = 0; insert into product_status_history (`product_id`,`user_id`,`create_time`,`type`,`product_status`,`remark`) values (15164,0,now(),5,20,'');set sql_safe_updates = 1; //set sql_safe_updates = 0; insert into product_status_history (`product_id`,`user_id`,`create_time`,`type`,`product_status`,`remark`) values (15164,122,now(),2,0,'');set sql_safe_updates = 1; //set sql_safe_updates=0;delete item_price_temp from price_master_temp left join item_price_temp on item_price_temp.price_master_id=price_master_temp.price_master_id where 1=1 and price_master_temp.product_id='T578' and price_master_temp.combo_type=2 ;set sql_safe_updates=1; //set sql_safe_updates = 0;delete from price_master_temp where 1=1 and product_id='T578' and combo_type=2;set sql_safe_updates = 1; //insert into product_combo(`parent_id`,`child_id`,`s_must_buy`,`g_must_buy`,`pile_id`,`buy_limit`) select 15164 as parent_id,child_id,s_must_buy,g_must_buy,pile_id,buy_limit from product_combo_temp where 1=1 and parent_id='T578'; //set sql_safe_updates = 0; delete from product_combo_temp where writer_id = 0 and parent_id='T578'; set sql_safe_updates= 1; //set sql_safe_updates=0;delete item_price_temp from price_master_temp left join item_price_temp on item_price_temp.price_master_id=price_master_temp.price_master_id where 1=1 and price_master_temp.product_id='T578' and price_master_temp.combo_type=2 ;set sql_safe_updates=1; //SELECT * from product where product_id='15164' }
public int TempMove2Pro(int writerId, int combo_type, string product_Id) { ArrayList sqls = new ArrayList(); int product_id = 0; ProductTempMgr proTempMgr = new ProductTempMgr(""); ProductTemp proTemp = new ProductTemp { Writer_Id = writerId, Combo_Type = combo_type, Product_Id = product_Id, Create_Channel = 1 };//1:後台管理者(manage_user) edit by xiagnwang0413w 2014/08/09 string movePro = proTempMgr.MoveProduct(proTemp); sqls.Add(proTempMgr.Delete(proTemp)); /*********start*********/ //將ProductDeliverySetTemp表數據導入正式表 edit by xiangwang0413w 2014/11/06 IProductDeliverySetTempImplMgr _proDelSetTemp = new ProductDeliverySetTempMgr(""); var proDelSetTemp = new ProductDeliverySetTemp { Writer_Id = writerId, Combo_Type = combo_type, Product_id = int.Parse(product_Id) }; sqls.Add(_proDelSetTemp.MoveProductDeliverySet(proDelSetTemp)); sqls.Add(_proDelSetTemp.Delete(proDelSetTemp)); /*******end***********/ ProductNoticeSetTempMgr proNoticeSetTempMgr = new ProductNoticeSetTempMgr(""); ProductNoticeSetTemp proNoticeSetTemp = new ProductNoticeSetTemp { Writer_Id = writerId, Combo_Type = combo_type, product_id = product_Id }; sqls.Add(proNoticeSetTempMgr.MoveNotice(proNoticeSetTemp)); sqls.Add(proNoticeSetTempMgr.Delete(proNoticeSetTemp)); ProductTagSetTempMgr proTagSetTempMgr = new ProductTagSetTempMgr(""); ProductTagSetTemp proTagSetTemp = new ProductTagSetTemp { Writer_Id = writerId, Combo_Type = combo_type, product_id = product_Id }; sqls.Add(proTagSetTempMgr.MoveTag(proTagSetTemp)); sqls.Add(proTagSetTempMgr.Delete(proTagSetTemp)); ProductPictureTempImplMgr proPicTempMgr = new ProductPictureTempImplMgr(""); ProductPictureTemp proPictureTemp = new ProductPictureTemp { writer_Id = writerId, combo_type = combo_type, product_id = product_Id }; sqls.Add(proPicTempMgr.MoveToProductPicture(proPictureTemp, 1));//更新說明圖表 sqls.Add(proPicTempMgr.MoveToProductPicture(proPictureTemp, 2));//更新APP圖表 sqls.Add(proPicTempMgr.Delete(proPictureTemp, 1));//刪除說明圖臨時表 sqls.Add(proPicTempMgr.Delete(proPictureTemp, 2)); //刪除app臨時表 add by wwei0216w 2014/11/11 ProductCategorySetTempMgr proCateSetTempMgr = new ProductCategorySetTempMgr(""); ProductCategorySetTemp proCategorySetTemp = new ProductCategorySetTemp { Writer_Id = writerId, Combo_Type = combo_type, Product_Id = product_Id.ToString() }; sqls.Add(proCateSetTempMgr.TempMoveCategory(proCategorySetTemp)); sqls.Add(proCateSetTempMgr.TempDelete(proCategorySetTemp)); ProductStatusHistoryMgr proStatusHistoryMgr = new ProductStatusHistoryMgr(""); sqls.Add(proStatusHistoryMgr.SaveNoProductId(new ProductStatusHistory { product_status = 0, user_id = Convert.ToUInt32(writerId), type = 5 })); ItemPriceTempMgr itemTempPriceMgr = new ItemPriceTempMgr(""); sqls.Add(itemTempPriceMgr.Delete(product_Id, combo_type, writerId)); PriceMasterTempMgr priceMasterTempMgr = new PriceMasterTempMgr(""); PriceMasterTemp priceMasterTemp = new PriceMasterTemp { writer_Id = writerId, product_id = product_Id, combo_type = combo_type }; sqls.Add(priceMasterTempMgr.Delete(priceMasterTemp)); //判斷是單一商品還是組合商品 if (combo_type == 1) {//單一商品 IProductItemImplDao piDao = new ProductItemDao(connectionStr); ProductItemTempMgr proItemTempMgr = new ProductItemTempMgr(""); ProductItemTemp proItemTemp = new ProductItemTemp { Writer_Id = writerId, Product_Id = product_Id }; string selItem = proItemTempMgr.QuerySql(proItemTemp); string moveItem = proItemTempMgr.MoveProductItem(proItemTemp); sqls.Add(proItemTempMgr.DeleteSql(proItemTemp)); /*************start*課程相關*****************/ //CourseDetailItem ICourseDetailItemTempImplMgr _cdItemMgr = new CourseDetailItemTempMgr(""); string moveCourDetaItem = _cdItemMgr.MoveCourseDetailItem(writerId); sqls.Add(_cdItemMgr.DeleteSql(writerId)); //CourseProduct ICourseProductTempImplMgr _courProdTempMgr = new CourseProductTempMgr(""); var courProdTemp = new CourseProductTemp { Writer_Id = writerId, Product_Id = uint.Parse(product_Id) }; string moveCourProd = _courProdTempMgr.MoveCourseProduct(courProdTemp); sqls.Add(_courProdTempMgr.DeleteSql(courProdTemp)); /*************end**********************************/ ProductSpecTempMgr proSpecTempMgr = new ProductSpecTempMgr(""); ProductSpecTemp proSpecTemp = new ProductSpecTemp { Writer_Id = writerId, product_id = product_Id }; sqls.Add(proSpecTempMgr.TempMoveSpec(proSpecTemp)); sqls.Add(proSpecTempMgr.TempDelete(proSpecTemp)); string priceMaster = priceMasterTempMgr.Move2PriceMaster(priceMasterTemp); ItemPriceMgr itemPriceMgr = new ItemPriceMgr(""); string itemPrice = itemPriceMgr.SaveFromItem(writerId, product_Id); product_id = _productDao.TempMove2Pro(movePro, moveCourProd, moveItem, moveCourDetaItem, selItem, priceMaster, itemPrice, sqls); //把商品推薦屬性臨時表中的數據moveto商品推薦屬性表中,然後刪除商品推薦臨時表 通過product_id指定商品推薦屬性對應的商品 #region 推薦商品屬性插入recommended_product_attribute表中做記錄 if (_rProductAttribute.ExsitInTemp(writerId, int.Parse(product_Id), combo_type) > 0)//判斷臨時表中是否存在 product_Id為傳入的productId { DataTable _dt = _rProductAttribute.GetTempList(writerId, int.Parse(product_Id), combo_type); RecommendedProductAttribute rPA = new RecommendedProductAttribute(); rPA.product_id = Convert.ToUInt32(product_id); rPA.time_start = 0; rPA.time_end = 0; rPA.expend_day = Convert.ToUInt32(_dt.Rows[0]["expend_day"]); rPA.months = _dt.Rows[0]["months"].ToString(); rPA.combo_type = 1; if (_rProductAttribute.GetMsgByProductId(product_id) > 0)//如果大於0,表示推薦表中存在數據 { if (_rProductAttribute.Update(rPA) > 0) { _rProductAttribute.DeleteTemp(writerId, int.Parse(product_Id), combo_type);//刪除臨時表中的數據 } } else { if (_rProductAttribute.Save(rPA) > 0) { _rProductAttribute.DeleteTemp(writerId, int.Parse(product_Id), combo_type);//刪除臨時表中的數據 } } } #endregion if (product_id > 0) { piDao.UpdateErpId(product_id.ToString()); } return product_id; } else {//組合商品 ProductComboTempMgr pcTempMgr = new ProductComboTempMgr(""); ProductComboTemp proComboTemp = new ProductComboTemp { Writer_Id = writerId, Parent_Id = product_Id }; sqls.Add(pcTempMgr.TempMoveCombo(proComboTemp)); sqls.Add(pcTempMgr.TempDelete(proComboTemp)); string selPrice = priceMasterTempMgr.SelectChild(priceMasterTemp); string priceMaster = priceMasterTempMgr.Move2PriceMasterByMasterId(); ItemPriceTempMgr itemPriceTempMgr = new ItemPriceTempMgr(""); string itemPrice = itemPriceTempMgr.Move2ItemPrice(); sqls.Add(itemPriceTempMgr.Delete(product_Id, combo_type, writerId)); product_id = _productDao.TempMove2Pro(movePro, "", "", "", selPrice, priceMaster, itemPrice, sqls); //把商品推薦屬性臨時表中的數據moveto商品推薦屬性表中,然後刪除商品推薦臨時表 通過product_id指定商品推薦屬性對應的商品 #region 推薦商品屬性插入recommended_product_attribute表中做記錄 if (_rProductAttribute.ExsitInTemp(writerId, int.Parse(product_Id), combo_type) > 0)//判斷臨時表中是否存在 product_Id為傳入的productId { DataTable _dt = _rProductAttribute.GetTempList(writerId, int.Parse(product_Id), combo_type); RecommendedProductAttribute rPA = new RecommendedProductAttribute(); rPA.product_id = Convert.ToUInt32(product_id); rPA.time_start = 0; rPA.time_end = 0; rPA.expend_day = Convert.ToUInt32(_dt.Rows[0]["expend_day"]); rPA.months = _dt.Rows[0]["months"].ToString(); rPA.combo_type = 2; if (_rProductAttribute.GetMsgByProductId(product_id) > 0)//如果大於0,表示推薦表中存在數據 { if (_rProductAttribute.Update(rPA) > 0) { _rProductAttribute.DeleteTemp(writerId, int.Parse(product_Id), combo_type);//刪除臨時表中的數據 } } else { if (_rProductAttribute.Save(rPA) > 0) { _rProductAttribute.DeleteTemp(writerId, int.Parse(product_Id), combo_type);//刪除臨時表中的數據 } } } return product_id; #endregion } }
/// <summary> /// 批量新增組合商品價格 /// </summary> /// <param name="pmc"></param> /// <param name="batch"></param> /// <param name="typePrice"></param> /// <param name="list_priceMaster"></param> /// <param name="chkCost">0 為 活動成本 設定 原成本,1 為 活動成本 依 折數 計算</param> //add by zhuoqin0830w 2015/04/02 /// <returns></returns> public string AddItemProduct(PriceMasterCustom pmc, HistoryBatch batch, string typePrice, List<PriceMaster> list_priceMaster, int chkCost) { ProductTemp pTemp = new ProductTemp(); //List<List<ItemPrice>> ItemPList = new List<List<ItemPrice>>(); PriceMasterTemp pMasterTemp = new PriceMasterTemp(); string json = "{success:true}"; if (!string.IsNullOrEmpty(pmc.product_id.ToString())) { #region 正式表操作 //插入price_master _priceMasterMgr = new PriceMasterMgr(connectionString); _priceMasterTsMgr = new PriceMasterTsMgr(connectionString); PriceMaster gigade = list_priceMaster.Where(m => m.product_id == pmc.product_id).FirstOrDefault(); PriceMaster pMaster = new PriceMaster(); pMaster.product_id = pmc.product_id; if (pmc.combination == 1) { pMaster.child_id = 0; } else if (pmc.combination != 1 && pmc.combination != 0) { pMaster.child_id = Convert.ToInt32(pmc.product_id); } pMaster.site_id = pmc.site_id; uint userId = 0; if (userId != 0) { pMaster.user_id = userId; } if (pmc.user_level.ToString() != "") { pMaster.user_level = pmc.user_level; } pMaster.product_name = pmc.product_name; pMaster.bonus_percent = gigade.bonus_percent; pMaster.cost = pmc.cost_at; pMaster.price = pmc.price_at; pMaster.max_price = pmc.max_price; pMaster.max_event_price = pmc.max_price; pMaster.default_bonus_percent = gigade.default_bonus_percent; if (typePrice == "discount") { pMaster.event_price = CommonFunction.ArithmeticalDiscount(pmc.price, pmc.event_price_discount);//Convert.ToInt32(Convert.ToDouble(pmc.price) * (pmc.event_price_discount * 0.01)); //add by zhuoqin0830w 2015/04/02 判斷是否是 依原成本設定值 if (chkCost == 1) { //eidt by zhuoqin0830w 更改商品活動成本驗算公式使活動價乘以折扣 2015/02/27 pMaster.event_cost = CommonFunction.ArithmeticalDiscount(pmc.event_price, pmc.event_cost_discount);// Convert.ToInt32(Convert.ToDouble(pmc.cost) * (pmc.event_cost_discount * 0.01)); } else { pMaster.event_cost = pmc.event_cost; } } else { pMaster.event_price = pmc.event_price; pMaster.event_cost = pmc.event_cost; } pMaster.same_price = gigade.same_price; pMaster.price_status = 2;//申請審核 pMaster.accumulated_bonus = gigade.accumulated_bonus; #region 時間 活動時間 if (pmc.event_start.ToString() != "") { pMaster.event_start = pmc.event_start; } if (pmc.event_end.ToString() != "") { pMaster.event_end = pmc.event_end; } #endregion //價格修改 申請審核 PriceUpdateApply priceUpdateApply = new PriceUpdateApply(); 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.type = 1;//edit by wwei0216w 所作操作為 1:申請審核的操作 _priceUpdateApplyMgr = new PriceUpdateApplyMgr(connectionString); _priceUpdateApplyHistoryMgr = new PriceUpdateApplyHistoryMgr(connectionString); _tableHistoryMgr = new TableHistoryMgr(connectionString); ArrayList excuteSql = new ArrayList(); #region 新增 string msg = string.Empty; int status = 0; int priceMasterId = 0; IPriceMasterImplMgr i = new PriceMasterMgr(connectionString); List<ItemPrice> iprice = i.AddSingleProduct(pmc, typePrice); var result = _priceMasterMgr.Query(pMaster); if (result.Count > 0) { priceMasterId = -1; msg = pMaster.product_id.ToString(); return msg; } if (typePrice == "discount") { pMaster.price = CommonFunction.ArithmeticalDiscount(pmc.price, pmc.price_discount);// Convert.ToInt32(Convert.ToDouble(pmc.price) * (pmc._discount * 0.01)); pMaster.cost = CommonFunction.ArithmeticalDiscount(pmc.cost, pmc.cost_discount);// Convert.ToInt32(Convert.ToDouble(pmc.cost) * (pmc._cost_discount * 0.01)); pMaster.event_price = CommonFunction.ArithmeticalDiscount(pmc.price, pmc.event_price_discount);// Convert.ToInt32(Convert.ToDouble(pmc.price) * (pmc.event_price_discount * 0.01)); //add by zhuoqin0830w 2015/04/02 判斷是否是 依原成本設定值 if (chkCost == 1) { pMaster.event_cost = CommonFunction.ArithmeticalDiscount(pmc.event_price, pmc.event_cost_discount);// Convert.ToInt32(Convert.ToDouble(pmc.cost) * (pmc.event_cost_discount * 0.01)); } else { pMaster.event_cost = pmc.cost; } } priceMasterId = _priceMasterMgr.Save(pMaster, iprice, null, ref msg); if (priceMasterId != -1) { priceUpdateApply.price_master_id = Convert.ToUInt32(priceMasterId); //價格更新申請記錄(設置更新記錄中,更新的價格id) int apply_id = _priceUpdateApplyMgr.Save(priceUpdateApply);//價格更新申請記錄(新增或者更新價格后,將記錄下來插入該表)返回更新記錄的Id號 if (apply_id != -1) { pMaster = _priceMasterMgr.Query(new PriceMaster { price_master_id = Convert.ToUInt32(priceMasterId) }).FirstOrDefault(); pMaster.apply_id = Convert.ToUInt32(apply_id); applyHistroy.apply_id = apply_id; excuteSql.Add(_priceMasterMgr.Update(pMaster)); excuteSql.Add(_priceMasterTsMgr.UpdateTs(pMaster)); //edit by xiangwang0413w 2014/07/22 更新price_master_ts表後同時更新price_master_ts表,以便價格審核 excuteSql.Add(_priceUpdateApplyHistoryMgr.SaveSql(applyHistroy)); _tableHistoryMgr = new TableHistoryMgr(connectionString); if (_tableHistoryMgr.SaveHistory<PriceMaster>(pMaster, batch, excuteSql)) { status = 1; } else { status = 2; } } else { status = 2; } } else { status = 3; } if (status == 1) { return "success"; } else if (status == 2) { return json = "商品:" + pmc.product_name + Resources.Product.SAVE_FAIL + "'}"; } else { return json = msg; } #endregion #endregion } return ""; }
public string SaveFromPriceMaster(PriceMasterTemp priceMasterTemp) { priceMasterTemp.Replace4MySQL(); try { StringBuilder strSql = new StringBuilder("insert into price_master_temp(`writer_id`,`product_id`,`site_id`,`user_level`,`user_id`,`product_name`,`accumulated_bonus`"); strSql.Append(",`bonus_percent`,`default_bonus_percent`,`same_price`,`event_start`,`event_end`,`price_status`,`price`,`event_price`,`child_id`,`combo_type`,`cost`,`event_cost`,`bonus_percent_start`,`bonus_percent_end`,`max_price`,`max_event_price`,valid_start,valid_end) select "); strSql.AppendFormat("{0} as writer_id,product_id,site_id,user_level,user_id,'' AS product_name,accumulated_bonus", priceMasterTemp.writer_Id); strSql.AppendFormat(",bonus_percent,default_bonus_percent,same_price,event_start,event_end,{0} as price_status,price,event_price,child_id", priceMasterTemp.price_status); strSql.AppendFormat(",{0} as combo_type,cost,event_cost,bonus_percent_start,bonus_percent_end,max_price,max_event_price,valid_start,valid_end from price_master where product_id='{1}' and site_id=1 and user_level=1 and user_id=0", priceMasterTemp.combo_type, priceMasterTemp.product_id); return strSql.ToString(); ///ediy by wwei0216w 2015/8/27 /* 修改代碼 '' AS product_name * 修改原因: * 商品名稱添加前後綴后,複製商品時,價格名稱部份會連前後綴一起複製,導致商品沒有前後綴的添加記錄,為避免該問題 * 複製商品時,價格名稱部份將不會再進行複製 */ } catch (Exception ex) { throw new Exception("PriceMasterTempDao.SaveFromPriceMaster-->" + ex.Message, ex); } }
public string SaveFromPriceMasterByMasterId(PriceMasterTemp priceMasterTemp) { try { StringBuilder stb = new StringBuilder("insert into price_master_temp(`writer_id`,`combo_type`,`product_id`,`site_id`,`user_level`,`user_id`,`product_name`,`accumulated_bonus`"); stb.Append(",`bonus_percent`,`default_bonus_percent`,`same_price`,`event_start`,`event_end`,`price_status`,`price`,`event_price`,`child_id`,`cost`,`event_cost`,`bonus_percent_start`,`bonus_percent_end`,`max_price`,`max_event_price`) "); stb.AppendFormat("select {0} as writer_id,{1} as combo_type, product_id,", priceMasterTemp.writer_Id, priceMasterTemp.combo_type); stb.Append("site_id,user_level,user_id,'' AS product_name,accumulated_bonus,bonus_percent,default_bonus_percent,same_price,event_start,event_end,price_status,price,event_price,child_id,cost,event_cost,bonus_percent_start,bonus_percent_end,max_price,max_event_price"); stb.Append(" from price_master where price_master_id = {0};select @@identity;"); return stb.ToString(); ///ediy by wwei0216w 2015/8/27 /* 修改代碼 '' AS product_name * 修改原因: * 商品名稱添加前後綴后,複製商品時,價格名稱部份會連前後綴一起複製,導致商品沒有前後綴的添加記錄,為避免該問題 * 複製商品時,價格名稱部份將不會再進行複製 */ } catch (Exception ex) { throw new Exception("PriceMasterTempDao.SaveFromPriceMasterByMasterId-->" + ex.Message, ex); } }
public string VendorMove2PriceMaster(PriceMasterTemp priceMasterTemp) { try { return _priceMasterTempDao.VendorMove2PriceMaster(priceMasterTemp); } catch (Exception ex) { throw new Exception("PriceMasterTempMgr-->VendorMove2PriceMaster-->" + ex.Message, ex); } }
public string DeleteByVendor(PriceMasterTemp priceMasterTemp) { StringBuilder strSql = new StringBuilder(); try { strSql.Append("set sql_safe_updates = 0;delete from price_master_temp "); strSql.AppendFormat(" where writer_id={0} ", priceMasterTemp.writer_Id); strSql.AppendFormat(" and combo_type={0}", priceMasterTemp.combo_type); if (!string.IsNullOrEmpty(priceMasterTemp.product_id) && priceMasterTemp.product_id != "0") { strSql.AppendFormat(" and product_id='{0}' ;", priceMasterTemp.product_id); } strSql.Append("set sql_safe_updates = 1;"); return strSql.ToString(); } catch (Exception ex) { throw new Exception("PriceMasterTempDao.DeleteByVendor-->" + ex.Message + strSql.ToString(), ex); } }
public string ChildDelete(PriceMasterTemp priceMasterTemp) { return _priceMasterTempDao.ChildDelete(priceMasterTemp); }
public string VendorSaveFromPriceMaster(PriceMasterTemp priceMasterTemp, string old_product_id) {//20140905 供應商複製 priceMasterTemp.Replace4MySQL(); try { StringBuilder strSql = new StringBuilder("insert into price_master_temp(`writer_id`,`product_id`,`site_id`,`user_level`,`user_id`,`product_name`,`accumulated_bonus`"); strSql.Append(",`bonus_percent`,`default_bonus_percent`,`same_price`,`event_start`,`event_end`,`price_status`,`price`,`event_price`,`child_id`,`combo_type`,`cost`,`event_cost`,`bonus_percent_start`,`bonus_percent_end`,`max_price`,`max_event_price`,`valid_start`,`valid_end`) select "); strSql.AppendFormat("{0} as writer_id,'{1}' as product_id,site_id,user_level,user_id,product_name,accumulated_bonus", priceMasterTemp.writer_Id, priceMasterTemp.product_id); strSql.AppendFormat(",bonus_percent,default_bonus_percent,same_price,event_start,event_end,{0} as price_status,price,event_price, '{1}' as child_id", priceMasterTemp.price_status, priceMasterTemp.product_id); strSql.AppendFormat(",{0} as combo_type,cost,event_cost,bonus_percent_start,bonus_percent_end,max_price,max_event_price,valid_start,valid_end ", priceMasterTemp.combo_type); uint productid = 0; if (uint.TryParse(old_product_id, out productid)) { strSql.AppendFormat(" from price_master where product_id={0} ", old_product_id); } else { strSql.AppendFormat(" from price_master_temp where product_id='{0}' ", old_product_id); } strSql.Append(" and site_id=1 and user_level=1 and user_id=0 ;"); return strSql.ToString(); } catch (Exception ex) { throw new Exception("PriceMasterTempDao.VendorSaveFromPriceMaster-->" + ex.Message, ex); } }
public List<PriceMasterTemp> queryChild(PriceMasterTemp query) { return _priceMasterTempDao.queryChild(query); }
/// <summary> /// 管理員核可供應商建立的商品時將商品價格主檔信息由臨時表移動除 /// </summary> /// <param name="priceMasterTemp">臨時表中的數據對象</param> /// <returns>此操作的sql語句</returns> public string Vendor_Delete(PriceMasterTemp priceMasterTemp) { StringBuilder strSql = new StringBuilder("set sql_safe_updates = 0;delete from price_master_temp where 1=1"); if (priceMasterTemp.writer_Id != 0) { strSql.AppendFormat(" and writer_id={0}", priceMasterTemp.writer_Id); } strSql.AppendFormat(" and product_id='{0}' and combo_type={1};set sql_safe_updates = 1;", priceMasterTemp.product_id, priceMasterTemp.combo_type); return strSql.ToString(); }
public HttpResponseBase SaveItemPrice() { string json = string.Empty; string msg = 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(); string items = Request.Form["Items"]; float default_bonus_percent = 0; float.TryParse(Request.Form["default_bonus_percent"] ?? "1", out default_bonus_percent); float bonus_percent = 0; float.TryParse(Request.Form["bonus_percent"] ?? "1", out bonus_percent); 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_product_start"] ?? Request.Form["event_start"]; string end = Request.Form["event_product_end"] ?? Request.Form["event_end"]; string bonus_start = Request.Form["bonus_percent_start"]; string bonus_end = Request.Form["bonus_percent_end"]; string valid_start = Request.Form["valid_start"]; string valid_end = Request.Form["valid_end"]; if (!string.IsNullOrEmpty(Request.Form["ProductId"]) && !string.IsNullOrEmpty(Request.Form["site_name"])) { #region price_master,item_price 新增站台价格 List<ItemPrice> itemPrices = jsSer.Deserialize<List<ItemPrice>>(items); PriceMaster priceMaster = new PriceMaster { bonus_percent = bonus_percent, default_bonus_percent = default_bonus_percent }; if (!string.IsNullOrEmpty(start)) { priceMaster.event_start = Convert.ToUInt32(CommonFunction.GetPHPTime(start)); } if (!string.IsNullOrEmpty(end)) { priceMaster.event_end = Convert.ToUInt32(CommonFunction.GetPHPTime(end)); } priceMaster.product_name = PriceMaster.Product_Name_FM(Request.Form["product_name"]); priceMaster.site_id = uint.Parse(Request.Form["site_name"]); priceMaster.product_id = uint.Parse(Request.Form["ProductId"]); priceMaster.user_level = uint.Parse(Request.Form["user_level"] ?? "1"); priceMaster.same_price = same_price; priceMaster.accumulated_bonus = Convert.ToUInt32(accumulated_bonus); priceMaster.price_status = 2;//申請審核 priceMaster.price = Convert.ToInt32(itemPrices.Min(m => m.item_money)); priceMaster.event_price = Convert.ToInt32(itemPrices.Min(m => m.event_money)); priceMaster.cost = Convert.ToInt32(itemPrices.Min(m => m.item_cost)); priceMaster.event_cost = Convert.ToInt32(itemPrices.Min(m => m.event_cost)); if (same_price == 0) { priceMaster.max_price = Convert.ToInt32(itemPrices.Max(m => m.item_money)); priceMaster.max_event_price = Convert.ToInt32(itemPrices.Max(m => m.event_money)); } if (!string.IsNullOrEmpty(bonus_start)) { priceMaster.bonus_percent_start = Convert.ToUInt32(CommonFunction.GetPHPTime(bonus_start)); } if (!string.IsNullOrEmpty(bonus_start)) { 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)); } _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"]); } Resource.CoreMessage = new CoreResource("Product"); _priceMasterMgr = new PriceMasterMgr(connectionString); _priceMasterTsMgr = new PriceMasterTsMgr(""); int priceMasterId = _priceMasterMgr.Save(priceMaster, itemPrices, null, ref msg); if (priceMasterId != -1) { //價格修改 申請審核 PriceUpdateApply priceUpdateApply = new PriceUpdateApply { price_master_id = Convert.ToUInt32(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); int apply_id = _priceUpdateApplyMgr.Save(priceUpdateApply); if (apply_id != -1) { priceMaster = _priceMasterMgr.Query(new PriceMaster { price_master_id = Convert.ToUInt32(priceMasterId) }).FirstOrDefault(); priceMaster.apply_id = Convert.ToUInt32(apply_id); applyHistroy.apply_id = apply_id; ArrayList excuteSql = new ArrayList(); excuteSql.Add(_priceMasterMgr.Update(priceMaster)); excuteSql.Add(_priceMasterTsMgr.UpdateTs(priceMaster));//edit by xiangwang0413w 2014/07/22 更新price_master_ts表後用時更新price_master_ts表,以便價格審核 excuteSql.Add(_priceUpdateApplyHistoryMgr.SaveSql(applyHistroy)); _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; _tableHistoryMgr = new TableHistoryMgr(connectionString); if (_tableHistoryMgr.SaveHistory<PriceMaster>(priceMaster, batch, excuteSql)) { json = "{success:true}"; } else { json = "{success:false,msg:'" + Resources.Product.SAVE_FAIL + "'}"; } } else { json = "{success:false,msg:'" + Resources.Product.SAVE_FAIL + "'}"; } } else { json = "{success:false,msg:'" + msg + "'}"; } #endregion } else { #region product_item_temp 修改临时表数据 ProductTemp proTemp = new ProductTemp { Bonus_Percent = bonus_percent, Default_Bonus_Percent = default_bonus_percent }; List<ProductItemTemp> proItemTemps = jsSer.Deserialize<List<ProductItemTemp>>(items); if (!string.IsNullOrEmpty(Request.Form["OldProductId"])) { proTemp.Product_Id = Request.Form["OldProductId"]; proItemTemps.ForEach(m => m.Product_Id = proTemp.Product_Id); } if (!string.IsNullOrEmpty(start)) { proTemp.Bonus_Percent_Start = Convert.ToUInt32(CommonFunction.GetPHPTime(start)); proItemTemps.ForEach(m => m.Event_Product_Start = proTemp.Bonus_Percent_Start); } if (!string.IsNullOrEmpty(end)) { proTemp.Bonus_Percent_End = Convert.ToUInt32(CommonFunction.GetPHPTime(end)); proItemTemps.ForEach(m => m.Event_Product_End = proTemp.Bonus_Percent_End); } if (!string.IsNullOrEmpty(Request.Form["product_price_list"])) { uint product_price_list = 0; uint.TryParse(Request.Form["product_price_list"] ?? "0", out product_price_list); proTemp.Product_Price_List = product_price_list; } if (!string.IsNullOrEmpty(Request.Form["bag_check_money"])) { proTemp.Bag_Check_Money = uint.Parse(Request.Form["bag_check_money"]); } proTemp.show_listprice = Convert.ToUInt32((Request.Form["show_listprice"] ?? "") == "on" ? 1 : 0); proTemp.Writer_Id = (Session["caller"] as Caller).user_id; proTemp.Combo_Type = COMBO_TYPE; proItemTemps.ForEach(m => m.Writer_Id = proTemp.Writer_Id); _productTempMgr = new ProductTempMgr(connectionString); #region PriceMasterTemp PriceMasterTemp priceMasterTemp = new PriceMasterTemp { price_status = 1, default_bonus_percent = default_bonus_percent, bonus_percent = bonus_percent, same_price = same_price }; priceMasterTemp.accumulated_bonus = Convert.ToUInt32(accumulated_bonus); priceMasterTemp.product_id = proTemp.Product_Id; priceMasterTemp.combo_type = COMBO_TYPE; priceMasterTemp.product_name = PriceMaster.Product_Name_FM(Request.Form["product_name"] ?? ""); priceMasterTemp.writer_Id = proTemp.Writer_Id; priceMasterTemp.site_id = 1;//默認站臺1:吉甲地 priceMasterTemp.user_level = 1; priceMasterTemp.price = Convert.ToInt32(proItemTemps.Min(m => m.Item_Money)); priceMasterTemp.event_price = Convert.ToInt32(proItemTemps.Min(m => m.Event_Item_Money)); priceMasterTemp.cost = Convert.ToInt32(proItemTemps.Min(m => m.Item_Cost)); priceMasterTemp.event_cost = Convert.ToInt32(proItemTemps.Min(m => m.Event_Item_Cost)); if (same_price == 0) { priceMasterTemp.max_price = Convert.ToInt32(proItemTemps.Max(m => m.Item_Money)); priceMasterTemp.max_event_price = Convert.ToInt32(proItemTemps.Max(m => m.Event_Item_Money)); } if (!string.IsNullOrEmpty(bonus_start)) { priceMasterTemp.bonus_percent_start = Convert.ToUInt32(CommonFunction.GetPHPTime(bonus_start)); } if (!string.IsNullOrEmpty(bonus_start)) { priceMasterTemp.bonus_percent_end = Convert.ToUInt32(CommonFunction.GetPHPTime(bonus_end)); } 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)); } #endregion _productItemTempMgr = new ProductItemTempMgr(connectionString); _priceMasterTempMgr = new PriceMasterTempMgr(connectionString); if (_productItemTempMgr.UpdateCostMoney(proItemTemps) && _productTempMgr.PriceBonusInfoSave(proTemp) > 0) { bool result = false; PriceMasterTemp query = new PriceMasterTemp { writer_Id = priceMasterTemp.writer_Id, product_id = proTemp.Product_Id, combo_type = COMBO_TYPE }; if (_priceMasterTempMgr.Query(query) == null)//插入 { result = _priceMasterTempMgr.Save(new List<PriceMasterTemp> { priceMasterTemp }, null, null); } else//更新 { result = _priceMasterTempMgr.Update(new List<PriceMasterTemp> { priceMasterTemp }, null); } json = "{success:" + result.ToString().ToLower() + "}"; } else { json = "{success:false}"; } #endregion } } 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; }
public HttpResponseBase GetPriceMaster() { string json = string.Empty; try { if (!string.IsNullOrEmpty(Request.Form["ProductId"])) { uint productId = uint.Parse(Request.Form["ProductId"]); _priceMasterMgr = new PriceMasterMgr(connectionString); List<PriceMasterCustom> proSiteCustom = _priceMasterMgr.Query(new PriceMaster { product_id = productId }); StringBuilder strJson = new StringBuilder("["); if (proSiteCustom != null) { 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:{0},user_id:{1},user_email:\"{2}\",user_level_name:\"{3}\"", item.user_level, item.user_id, item.user_email, item.user_level_name); strJson.AppendFormat(",event_start:\"{0}\"", item.event_start); strJson.AppendFormat(",event_end:\"{0}\",status:\"{1}\",accumulated_bonus:\"{2}\"", item.event_end, item.status, item.accumulated_bonus); strJson.AppendFormat(",bonus_percent_start:\"{0}\",bonus_percent_end:\"{1}\",valid_start:\"{2}\",valid_end:\"{3}\"", item.bonus_percent_start, item.bonus_percent_end, item.valid_start, item.valid_end); if (item.same_price == 1) { strJson.Append(",same_price:\"on\""); strJson.AppendFormat(",item_cost:{0},item_money:{1}", item.cost, item.price); strJson.AppendFormat(",event_cost:{0},event_money:{1}", item.event_cost, item.event_price); } strJson.Append("}"); } } strJson.Append("]"); json = strJson.ToString().Replace("}{", "},{"); } else { int writer_id = (Session["caller"] as Caller).user_id; PriceMasterTemp query = new PriceMasterTemp { writer_Id = writer_id, combo_type = COMBO_TYPE }; if (!string.IsNullOrEmpty(Request.Form["OldProductId"])) { query.product_id = Request.Form["OldProductId"]; } _priceMasterTempMgr = new PriceMasterTempMgr(connectionString); json = JsonConvert.SerializeObject(_priceMasterTempMgr.Query(query)); } } 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 string SelectChild(PriceMasterTemp priceMasterTemp) {//edit jialei 20140917 加判斷writerId try { StringBuilder strSql = new StringBuilder("select price_master_id,product_id,child_id from price_master_temp where 1=1"); if (priceMasterTemp.writer_Id != 0) { strSql.AppendFormat(" and writer_id = {0}", priceMasterTemp.writer_Id); } strSql.AppendFormat(" and combo_type={0} ", priceMasterTemp.combo_type); strSql.AppendFormat("and product_id='{0}';", priceMasterTemp.product_id); return strSql.ToString(); } catch (Exception ex) { throw new Exception("PriceMasterTempDao.SelectChild-->" + ex.Message, ex); } }
public void CreateList(List<MakePriceCustom> PriceStore, PriceMaster pMaster, PriceMasterTemp pMasterTemp, string same_price, List<List<ItemPrice>> ItemPList, List<PriceMasterTemp> pMasterListT, List<PriceMaster> pMasterList, List<ItemPrice> update) { _productItemMgr = new ProductItemMgr(connectionString); if (PriceStore.Count > 0) { //先遍歷群組 var piles = PriceStore.GroupBy(rec => rec.Pile_Id).ToList(); piles.ForEach(rec => { if (same_price == "1") { //循環grid的每一行 rec.ToList().ForEach(row => { //生成price_master if (pMasterTemp != null) { PriceMasterTemp pmT = pMasterTemp.Clone() as PriceMasterTemp; pmT.product_name = row.Product_Name; pmT.child_id = row.Child_Id.ToString(); pmT.price = int.Parse(row.item_money.ToString()); pmT.max_price = int.Parse(row.item_money.ToString()); //edit by xinglu0624w reason 子商品需要给 max_price 值 pmT.max_event_price = 0; pmT.cost = int.Parse(row.item_cost.ToString()); pmT.event_price = int.Parse(row.event_money.ToString()); pmT.event_cost = int.Parse(row.event_cost.ToString()); pmT.valid_start = pMasterTemp.valid_start; pmT.valid_end = pMasterTemp.valid_end; pMasterListT.Add(pmT); } else { PriceMaster priceMa = pMaster.Clone() as PriceMaster; priceMa.product_name = row.Product_Name; priceMa.child_id = int.Parse(row.Child_Id.ToString()); priceMa.price = int.Parse(row.item_money.ToString()); priceMa.max_price = int.Parse(row.item_money.ToString()); priceMa.max_event_price = 0; priceMa.cost = int.Parse(row.item_cost.ToString()); priceMa.event_price = int.Parse(row.event_money.ToString()); priceMa.event_cost = int.Parse(row.event_cost.ToString()); priceMa.price_master_id = row.price_master_id; pMasterList.Add(priceMa); } if (row.price_master_id == 0)//新增 { //生成item_price List<ProductItem> piList = _productItemMgr.Query(new ProductItem { Product_Id = row.Child_Id }); List<ItemPrice> iList = new List<ItemPrice>(); piList.ForEach(item => { ItemPrice iP = new ItemPrice(); iP.item_id = item.Item_Id; iP.item_money = row.item_money; iP.item_cost = row.item_cost; iP.event_money = row.event_money; iP.event_cost = row.event_cost; iList.Add(iP); }); ItemPList.Add(iList); } else //更新 { ItemPrice ip = new ItemPrice(); ip.item_price_id = row.item_price_id; ip.price_master_id = row.price_master_id; ip.item_money = row.item_money; ip.item_cost = row.item_cost; ip.event_money = row.event_money; ip.event_cost = row.event_cost; update.Add(ip); } }); } else //處理各自定價-規格不同價 { var children = rec.GroupBy(c => c.Child_Id).ToList(); children.ForEach(c => { List<ItemPrice> differentPrice = new List<ItemPrice>(); //生成price_mater var rowData = (from ci in c where ci.Child_Id == c.Key select new { ci.Product_Name, ci.price_master_id }).ToList().First(); if (pMasterTemp != null) { PriceMasterTemp pmT = pMasterTemp.Clone() as PriceMasterTemp; pmT.product_name = rowData.Product_Name; pmT.child_id = c.Key.ToString(); pmT.price = int.Parse(c.FirstOrDefault().item_money.ToString()); pmT.max_price = int.Parse(c.FirstOrDefault().item_money.ToString()); //edit by hufeng0813w 2014/06/16 Reason:規格不同價時子商品也需要cost,event_cost,event_money pmT.max_event_price = int.Parse(c.FirstOrDefault().event_money.ToString()); pmT.cost = int.Parse(c.FirstOrDefault().item_cost.ToString()); pmT.event_price = int.Parse(c.FirstOrDefault().event_money.ToString()); pmT.event_cost = int.Parse(c.FirstOrDefault().event_cost.ToString()); //edit by hufeng0813w 2014/06/16 pMasterListT.Add(pmT); } else { PriceMaster priceMa = pMaster.Clone() as PriceMaster; priceMa.price_master_id = uint.Parse(rowData.price_master_id.ToString()); priceMa.product_name = rowData.Product_Name; priceMa.child_id = int.Parse(c.Key.ToString()); priceMa.price = int.Parse(c.FirstOrDefault().item_money.ToString()); priceMa.max_price = int.Parse(c.FirstOrDefault().item_money.ToString()); //edit by hufeng0813w 2014/06/16 Reason:規格不同價時子商品也需要cost,event_cost,event_money priceMa.max_event_price = int.Parse(c.FirstOrDefault().event_money.ToString()); priceMa.cost = int.Parse(c.FirstOrDefault().item_cost.ToString()); priceMa.event_price = int.Parse(c.FirstOrDefault().event_money.ToString()); priceMa.event_cost = int.Parse(c.FirstOrDefault().event_cost.ToString()); //edit by hufeng0813w 2014/06/16 pMasterList.Add(priceMa); } c.ToList().ForEach(row => { //生成item_price ItemPrice iP = new ItemPrice(); iP.item_id = row.item_id; iP.item_money = row.item_money; iP.item_cost = row.item_cost; iP.event_money = row.event_money; iP.event_cost = row.event_cost; iP.item_price_id = row.item_price_id; iP.price_master_id = row.price_master_id; differentPrice.Add(iP); update.Add(iP); }); ItemPList.Add(differentPrice); }); } }); } //為保證ItemPList.Count=pMasterListT.Count ItemPList.Add(null); }
public List<PriceMasterTemp> queryChild(PriceMasterTemp query) { try { StringBuilder strSql = new StringBuilder("select price_master_id,product_id,child_id from price_master_temp where "); strSql.AppendFormat("writer_id = {0} and combo_type={1} ", query.writer_Id, query.combo_type); strSql.AppendFormat("and product_id='{0}'", query.product_id); return _dbAccess.getDataTableForObj<PriceMasterTemp>(strSql.ToString()); } catch (Exception ex) { throw new Exception("PriceMasterTempDao.queryChild-->" + ex.Message, ex); } }
public string VendorSelectChild(PriceMasterTemp priceMaster) { //20140905 複製供應商 try { StringBuilder strSql = new StringBuilder("select price_master_id,product_id,child_id"); uint productid = 0; if (uint.TryParse(priceMaster.product_id, out productid)) { strSql.AppendFormat(" from price_master where product_id = {0} ", productid); } else { strSql.AppendFormat(" from price_master_temp where product_id = '{0}' ", priceMaster.product_id); } strSql.AppendFormat(" and site_id=1 and user_level=1 and user_id=0 "); return strSql.ToString(); } catch (Exception ex) { throw new Exception("PriceMasterDao.VendorSelectChild-->" + ex.Message, ex); } }
public HttpResponseBase GetPriceMaster() { string json = string.Empty; bool isEdit = false; try { BLL.gigade.Model.Vendor vendorModel = (BLL.gigade.Model.Vendor)Session["vendor"]; int writerID = (int)vendorModel.vendor_id; uint pid = 0; if (!string.IsNullOrEmpty(Request.Form["ProductId"])) { if (uint.TryParse(Request.Form["ProductId"].ToString(), out pid)) { _priceMasterMgr = new PriceMasterMgr(connectionString); List<PriceMasterCustom> proSiteCustom = _priceMasterMgr.Query(new PriceMaster { product_id = pid }); StringBuilder strJson = new StringBuilder("["); if (proSiteCustom != null) { 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}\",bonus_percent:{1},default_bonus_percent:{2}", item.product_name, item.bonus_percent, item.default_bonus_percent); strJson.AppendFormat(",user_level:{0},user_id:{1},user_email:\"{2}\",user_level_name:\"{3}\"", item.user_level, item.user_id, item.user_email, item.user_level_name); strJson.AppendFormat(",event_start:\"{0}\"", item.event_start); strJson.AppendFormat(",event_end:\"{0}\",status:\"{1}\",accumulated_bonus:\"{2}\"", item.event_end, item.status, item.accumulated_bonus); strJson.AppendFormat(",bonus_percent_start:\"{0}\",bonus_percent_end:\"{1}\",valid_start:\"{2}\",valid_end:\"{3}\"", item.bonus_percent_start, item.bonus_percent_end, item.valid_start, item.valid_end); if (item.same_price == 1) { strJson.Append(",same_price:\"on\""); strJson.AppendFormat(",item_cost:{0},item_money:{1}", item.cost, item.price); strJson.AppendFormat(",event_cost:{0},event_money:{1}", item.event_cost, item.event_price); } strJson.Append("}"); } } strJson.Append("]"); json = strJson.ToString().Replace("}{", "},{"); } else { _priceMasterTempMgr = new PriceMasterTempMgr(connectionString); PriceMasterTemp query = new PriceMasterTemp(); query.writer_Id = writerID; query.combo_type = COMBO_TYPE; query.product_id = Request.Form["ProductId"].ToString(); if (!string.IsNullOrEmpty(Request.Params["IsEdit"])) { isEdit = Request.Params["IsEdit"].ToString() == "true" ? true : false; } if (isEdit) { List<PriceMasterCustom> proSiteCustom = _priceMasterTempMgr.QueryProdSiteByVendor(query); StringBuilder strJson = new StringBuilder("["); if (proSiteCustom != null) { 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.vendor_product_id, item.site_id, item.site_name); strJson.AppendFormat(",product_name:\"{0}\",bonus_percent:{1},default_bonus_percent:{2}", item.product_name, item.bonus_percent, item.default_bonus_percent); strJson.AppendFormat(",user_level:{0},user_id:{1},user_email:\"{2}\",user_level_name:\"{3}\"", item.user_level, item.user_id, item.user_email, item.user_level_name); strJson.AppendFormat(",event_start:\"{0}\"", item.event_start); strJson.AppendFormat(",event_end:\"{0}\",status:\"{1}\",accumulated_bonus:\"{2}\"", item.event_end, item.status, item.accumulated_bonus); strJson.AppendFormat(",bonus_percent_start:\"{0}\",bonus_percent_end:\"{1}\",valid_start:\"{2}\",valid_end:\"{3}\"", item.bonus_percent_start, item.bonus_percent_end, item.valid_start, item.valid_end); if (item.same_price == 1) { strJson.Append(",same_price:\"on\""); strJson.AppendFormat(",item_cost:{0},item_money:{1}", item.cost, item.price); strJson.AppendFormat(",event_cost:{0},event_money:{1}", item.event_cost, item.event_price); } strJson.Append("}"); } } strJson.Append("]"); json = strJson.ToString().Replace("}{", "},{"); } else { json = JsonConvert.SerializeObject(_priceMasterTempMgr.QueryByVendor(query)); } } } } 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; }