public bool ReUpdateDiscount(PromotionsAmountDiscountCustom model, string oldEventId) { ArrayList arryList = new ArrayList(); try { arryList.Add(_prodpromoDao.DeleteProdProm(oldEventId));//修改時先刪除原有的prodprom if (model.product_id == 999999) { ProductCategorySet pcsModel = new ProductCategorySet(); pcsModel.Brand_Id = 0; pcsModel.Category_Id = model.category_id; pcsModel.Product_Id = 999999; arryList.Add(_prodCategSet.DeleteProdCateSet(pcsModel.Category_Id)); arryList.Add(_prodCategSet.SaveProdCategorySet(pcsModel)); } else { if (model.url_by == 1) { if (model.brand_id != 0)//當品牌不為空時講該品牌下的所有商品加入set表 { arryList.Add(_prodCategSet.DeleteProdCateSet(model.category_id));//brand_id不為0時先刪除set表中數據,在新增 QueryVerifyCondition query = new QueryVerifyCondition(); query.brand_id = Convert.ToUInt32(model.brand_id); query.site_ids = model.site; query.combination = 1; query.IsPage = false; int totalCount = 0; List<QueryandVerifyCustom> qvcList = _promoMainDao.GetProList(query, out totalCount); foreach (QueryandVerifyCustom qvcItem in qvcList) { ProductCategorySet pcsModel = new ProductCategorySet(); pcsModel.Product_Id = qvcItem.product_id; pcsModel.Brand_Id = Convert.ToUInt32(model.brand_id); pcsModel.Category_Id = model.category_id; //刪除已有的 新增異動的 arryList.Add(_prodCategSet.SaveProdCategorySet(pcsModel)); } } } else//非專區 { if (model.event_type == "M1") { arryList.Add(_prodCategSet.DeleteProdCateSet(model.category_id));//幾件幾折的非專區時先刪除set表中數據,在新增 } if (model.product_id != 0) { arryList.Add(_prodCategSet.DeleteProdCateSet(model.category_id));//非專區時先刪除set表中數據,在新增 ProductCategorySet pcsModel = new ProductCategorySet(); pcsModel.Product_Id = Convert.ToUInt32(model.product_id); pcsModel.Brand_Id = _prodDao.Query(new Product { Product_Id = pcsModel.Product_Id }).FirstOrDefault().Brand_Id; pcsModel.Category_Id = model.category_id; arryList.Add(_prodCategSet.SaveProdCategorySet(pcsModel)); } else if (model.brand_id != 0) { arryList.Add(_prodCategSet.DeleteProdCateSet(model.category_id));//非專區時先刪除set表中數據,在新增 QueryVerifyCondition query = new QueryVerifyCondition(); query.brand_id = Convert.ToUInt32(model.brand_id); query.site_ids = model.site; query.combination = 1; int totalCount = 0; query.IsPage = false; List<QueryandVerifyCustom> qvcList = _promoMainDao.GetProList(query, out totalCount); foreach (QueryandVerifyCustom qvcItem in qvcList) { ProductCategorySet pcsModel = new ProductCategorySet(); pcsModel.Product_Id = qvcItem.product_id; pcsModel.Brand_Id = Convert.ToUInt32(model.brand_id); pcsModel.Category_Id = model.category_id; arryList.Add(_prodCategSet.SaveProdCategorySet(pcsModel)); } } else if (model.class_id != 0) { arryList.Add(_prodCategSet.DeleteProdCateSet(model.category_id));//非專區時先刪除set表中數據,在新增 VendorBrandSetDao _vbsDao = new VendorBrandSetDao(connStr); List<VendorBrandSet> brandIDs = _vbsDao.Query(new VendorBrandSet { class_id = (uint)model.class_id }); if (brandIDs.Count > 0) { QueryVerifyCondition query = new QueryVerifyCondition(); foreach (VendorBrandSet item in brandIDs) { query.brand_ids += item.brand_id + ","; } query.brand_ids = query.brand_ids.TrimEnd(','); query.site_ids = model.site; query.combination = 1; query.IsPage = false; int totalCount = 0; List<QueryandVerifyCustom> qvcList = _promoMainDao.GetProList(query, out totalCount); foreach (QueryandVerifyCustom qvcItem in qvcList) { ProductCategorySet pcsModel = new ProductCategorySet(); pcsModel.Product_Id = qvcItem.product_id; pcsModel.Brand_Id = Convert.ToUInt32(model.brand_id); pcsModel.Category_Id = model.category_id; arryList.Add(_prodCategSet.SaveProdCategorySet(pcsModel)); } } } } } if (model.event_id != "") { arryList.Add(_proAllDao.DelPromAll(oldEventId)); } PromoAll pamodel = new PromoAll(); pamodel.event_id = model.event_id; pamodel.event_type = model.event_type; pamodel.brand_id = model.brand_id; pamodel.class_id = model.class_id; pamodel.category_id = Convert.ToInt32(model.category_id); pamodel.startTime = model.start; pamodel.end = model.end; pamodel.status = model.status; pamodel.kuser = model.kuser; pamodel.kdate = model.created; pamodel.muser = model.muser; pamodel.mdate = model.modified; pamodel.status = model.status; pamodel.product_id = model.product_id; pamodel.class_id = model.class_id; pamodel.brand_id = model.brand_id; arryList.Add(_proAllDao.SavePromAll(pamodel)); ProductCategory pcmodel = _proCateDao.GetModelById(Convert.ToUInt32(model.category_id)); pcmodel.category_id = Convert.ToUInt32(model.category_id); pcmodel.banner_image = model.banner_image; pcmodel.category_link_url = model.category_link_url; pcmodel.category_display = Convert.ToUInt32(model.status); pcmodel.category_name = model.name; pcmodel.category_updatedate = (uint)BLL.gigade.Common.CommonFunction.GetPHPTime(model.modified.ToString()); pcmodel.category_father_id = model.category_father_id; arryList.Add(_proCateDao.UpdateProdCate(pcmodel)); arryList.Add(_padDao.UpdatePromoAmountDis(model)); return _mysqlDao.ExcuteSqls(arryList); } catch (Exception ex) { throw new Exception("PromotionsAmountDiscountDao-->ReUpdate-->" + ex.Message, ex); } }
public bool ReSaveDiscount(PromotionsAmountDiscountCustom model) { ArrayList arryList = new ArrayList(); try { if (model.product_id == 999999) { ProductCategorySet pcsModel = new ProductCategorySet(); pcsModel.Brand_Id = 0; pcsModel.Category_Id = model.category_id; pcsModel.Product_Id = 999999; arryList.Add(_prodCategSet.SaveProdCategorySet(pcsModel)); } else { //刪除全館商品 ProductCategorySet qgSet = new ProductCategorySet(); qgSet.Category_Id = model.category_id; qgSet.Product_Id = 999999;//全館商品刪除 id=999999 //根據category_id刪除product_category_set表數據 if (model.url_by == 1) { if (model.brand_id != 0)//專區時當品牌不為空時講該品牌下的所有商品加入set表 { arryList.Add(_prodCategSet.DelProdCateSetByCPID(qgSet)); QueryVerifyCondition query = new QueryVerifyCondition(); query.brand_id = Convert.ToUInt32(model.brand_id); query.site_ids = model.site; query.combination = 1; query.IsPage = false; int totalCount = 0; List<QueryandVerifyCustom> qvcList = _promoMainDao.GetProList(query, out totalCount); foreach (QueryandVerifyCustom qvcItem in qvcList) { ProductCategorySet pcsModel = new ProductCategorySet(); pcsModel.Product_Id = qvcItem.product_id; pcsModel.Brand_Id = Convert.ToUInt32(model.brand_id); pcsModel.Category_Id = model.category_id; arryList.Add(_prodCategSet.SaveProdCategorySet(pcsModel)); } } } else//非專區時 { if (model.event_type == "M1") { arryList.Add(_prodCategSet.DelProdCateSetByCPID(qgSet)); } if (model.product_id != 0) { arryList.Add(_prodCategSet.DelProdCateSetByCPID(qgSet)); ProductCategorySet pcsModel = new ProductCategorySet(); pcsModel.Product_Id = Convert.ToUInt32(model.product_id); pcsModel.Brand_Id = _prodDao.Query(new Product { Product_Id = pcsModel.Product_Id }).FirstOrDefault().Brand_Id; pcsModel.Category_Id = model.category_id; arryList.Add(_prodCategSet.SaveProdCategorySet(pcsModel)); } else if (model.brand_id != 0) { arryList.Add(_prodCategSet.DelProdCateSetByCPID(qgSet)); QueryVerifyCondition query = new QueryVerifyCondition(); query.brand_id = Convert.ToUInt32(model.brand_id); query.site_ids = model.site; query.combination = 1; query.IsPage = false; int totalCount = 0;//篩選出該品牌下符合條件的商品 List<QueryandVerifyCustom> qvcList = _promoMainDao.GetProList(query, out totalCount); foreach (QueryandVerifyCustom qvcItem in qvcList) { ProductCategorySet pcsModel = new ProductCategorySet(); pcsModel.Product_Id = qvcItem.product_id; pcsModel.Brand_Id = Convert.ToUInt32(model.brand_id); pcsModel.Category_Id = model.category_id; arryList.Add(_prodCategSet.SaveProdCategorySet(pcsModel)); } } else if (model.class_id != 0) { arryList.Add(_prodCategSet.DelProdCateSetByCPID(qgSet)); VendorBrandSetDao _vbsDao = new VendorBrandSetDao(connStr); List<VendorBrandSet> brandIDs = _vbsDao.Query(new VendorBrandSet { class_id = (uint)model.class_id }); if (brandIDs.Count > 0) { QueryVerifyCondition query = new QueryVerifyCondition(); foreach (VendorBrandSet item in brandIDs) { query.brand_ids += item.brand_id + ","; } query.brand_ids = query.brand_ids.TrimEnd(','); query.site_ids = model.site; query.combination = 1; query.IsPage = false; int totalCount = 0; List<QueryandVerifyCustom> qvcList = _promoMainDao.GetProList(query, out totalCount); foreach (QueryandVerifyCustom qvcItem in qvcList) { ProductCategorySet pcsModel = new ProductCategorySet(); pcsModel.Product_Id = qvcItem.product_id; pcsModel.Brand_Id = Convert.ToUInt32(model.brand_id); pcsModel.Category_Id = model.category_id; arryList.Add(_prodCategSet.SaveProdCategorySet(pcsModel)); } } } } } PromoAll pamodel = new PromoAll(); pamodel.event_id = model.event_id; pamodel.event_type = model.event_type; pamodel.brand_id = model.brand_id; pamodel.class_id = model.class_id; pamodel.category_id = Convert.ToInt32(model.category_id); pamodel.startTime = model.start; pamodel.end = model.end; pamodel.status = model.status; pamodel.kuser = model.kuser; pamodel.kdate = model.created; pamodel.muser = model.kuser; pamodel.mdate = model.created; pamodel.product_id = model.product_id; pamodel.class_id = model.class_id; pamodel.brand_id = model.brand_id; arryList.Add(_proAllDao.SavePromAll(pamodel)); ProductCategory pcmodel = _proCateDao.GetModelById(Convert.ToUInt32(model.category_id)); pcmodel.category_id = Convert.ToUInt32(model.category_id); pcmodel.banner_image = model.banner_image; pcmodel.category_link_url = model.category_link_url; pcmodel.category_display = Convert.ToUInt32(model.status); pcmodel.category_name = model.name; pcmodel.category_father_id = model.category_father_id; arryList.Add(_proCateDao.UpdateProdCate(pcmodel)); arryList.Add(_padDao.UpdatePromoAmountDis(model)); return _mysqlDao.ExcuteSqls(arryList); } catch (Exception ex) { throw new Exception("PromotionsAmountDiscountMgr-->ReSaveDiscount-->" + ex.Message, ex); } }