/// <summary> /// 操作商品細項 /// </summary> /// <param name="pe">需要操作的商品條件</param> /// <returns>操作是否成功</returns> public bool UpdateProductExt(List<ProductExtCustom> lists , Caller _caller,string controlId) { bool flag = true; IFunctionImplMgr _functionMgr = new FunctionMgr(conStr); //用於找到控件的function信息 ITableHistoryImplMgr _tableHistoryMgr; //用於歷史記錄保存的類 IProductExtImplMgr _productExtMgr = new ProductExtMgr(conStr); try { Function fun = _functionMgr.QueryFunction(controlId, "/ProductParticulars/Index"); ArrayList aList = new ArrayList(); _tableHistoryMgr = new TableHistoryMgr(conStr);//實例化歷史記錄的類 HistoryBatch batch = new HistoryBatch { functionid = fun.RowId }; Int64 n_Time = CommonFunction.GetPHPTime(); batch.kuser = _caller.user_email; foreach (ProductExtCustom item in lists) { aList.Add(pei.UpdateProductExt(item)); batch.batchno = n_Time + "_" + "2" + "_" + item.Product_id;//add by wwei0216w 2015/7/6 註:將item_id改為product_id 統一使用product_id查詢 flag = _tableHistoryMgr.SaveHistory<ProductExtCustom>(item, batch, aList); if(flag == false) { throw new Exception("ProductExtMgr-->UpdateProductExt Exception!" ); } } return flag; } catch (Exception ex) { throw new Exception("ProductExtMgr-->UpdateProductExt-->" + ex.Message, ex); } }
public bool UpdateIpodCheck(IpodQuery query,IpoNvdQuery ipoNvd_query) { Boolean result = false; try { ArrayList aList = new ArrayList(); ITableHistoryImplMgr _tableHistoryMgr = new TableHistoryMgr(conStr);//實例化歷史記錄的類 Int64 n_Time = BLL.gigade.Common.CommonFunction.GetPHPTime(); Function myFun = new Function(); myFun.FunctionCode = "/WareHouse/Check"; List<Function> funList = _functionMgr.Query(myFun); int functionid = funList.Count == 0 ? 0 : funList[0].RowId; HistoryBatch batch = new HistoryBatch { functionid = functionid }; batch.kuser = query.user_email; //獲取添加IpoNvd的SQL string ipoNvdSql = _IpodDao.GetInsertIpoNvdSql(ipoNvd_query); aList.Add(ipoNvdSql); //獲取歷史記錄SQL string Check = _IpodDao.UpdateIpodCheck(query); //獲取修改庫存SQL string Stock = string.Empty; ProductItem item = new ProductItem(); item = _IpodDao.GetStockHistorySql(query, out Stock); batch.batchno = n_Time + "_" + query.change_user + "_" + item.Product_Id; if (item != null) { item.Item_Stock = query.item_stock; aList.Add(Stock); aList.Add(Check); result = _tableHistoryMgr.SaveHistory<ProductItem>(item, batch, aList); } //獲取修改商品Ignore SQL string Ignore_Stock = string.Empty; Product product = new Product(); product = _IpodDao.GetIgnoreHistorySql(query, out Ignore_Stock); if (product != null) { product.Ignore_Stock = 0; aList.Clear(); aList.Add(Ignore_Stock); result = _tableHistoryMgr.SaveHistory<Product>(product, batch, aList); } return result; } catch (Exception ex) { throw new Exception("IpoMgr-->UpdateIpodCheck-->" + ex.Message, ex); } }
//add by wwei0216w 2015/1/28 /// <summary> /// 查詢商品的Status信息 /// </summary> /// <param name="p">查詢條件</param> /// <returns>List<ProductCustom>集合</returns> public Product UpdateSaleStatus(uint porductId) { if (porductId == 0) return null; List<Product> prods; List<ProductItem> prodItems; PriceMaster gigaPriceMaster = new PriceMaster(); Int64 dateTime = Common.CommonFunction.GetPHPTime(DateTime.Now.ToString()); //獲得當前時間戳 ITableHistoryImplMgr _tableHistoryMgr = new TableHistoryMgr(connectionStr); ProductCustom product = _productDao.QueryProductInfo(porductId, out prods, out prodItems, out gigaPriceMaster);//查找單一商,子項庫存是否有為0 if (gigaPriceMaster == null) { gigaPriceMaster = new PriceMaster(); }; gigaPriceMaster.product_id = porductId; if (product == null) return product; try { if (product.Vendor_Status == 2) //供應商下架 { product.Sale_Status = 24; } else if (product.Brand_Status == 2) //品牌下架 { product.Sale_Status = 25; } else if (product.Product_Status != 5) //商品未上架 { product.Sale_Status = 21; } else if (product.Product_Start > dateTime || dateTime > product.Product_End) //上架時間未滿足 { product.Sale_Status = 22; } else if (product.Price_Status != 1 || EstimatePrice(gigaPriceMaster)) //價格未審核,或價格==0 { product.Sale_Status = 23; } else if (product.Shortage == 1) //商品停賣 { product.Sale_Status = 11; } else if (product.Ignore_Stock == 0 && prodItems.Count > 0) //庫存不足 { product.Sale_Status = 12; } else { if (product.Combination != 1 && prods != null) //非單一商品 { List<Product> li = prods.FindAll(m => m.Sale_Status == 11); //查詢該組合商品的子商品中是否有販售狀態等於停賣(11)的 List<Product> li2 = prods.FindAll(m => m.Sale_Status == 12);//查詢該組合商品的子商品中是否有販售狀態等於庫存不足(12)的 if (li.Count > 0) //子商品停賣(組合商品用) { product.Sale_Status = 13; } else if (li2.Count > 0)//子商品庫存不足(組合商品用) { product.Sale_Status = 14; } } else { product.Sale_Status = 0; } } } catch (Exception ex) { throw new Exception("ProductMgr-->QuerySaleStatus" + ex.Message, ex); } return product; }
public int UpdateItemStock(ProductItem query,string path,BLL.gigade.Model.Caller user) { Boolean result = false; try { ArrayList aList = new ArrayList(); ITableHistoryImplMgr _tableHistoryMgr = new TableHistoryMgr(connectionStr);//實例化歷史記錄的類 Int64 n_Time = BLL.gigade.Common.CommonFunction.GetPHPTime(); Function myFun = new Function(); myFun.FunctionCode = path; List<Function> funList = _functionMgr.Query(myFun); int functionid = funList.Count == 0 ? 0 : funList[0].RowId; HistoryBatch batch = new HistoryBatch { functionid = functionid }; batch.kuser = user.user_email; //獲取歷史記錄SQL string Check = productItemDao.UpdateItemStock(query); //獲取修改庫存SQL ProductItem item = new ProductItem(); item = productItemDao.Query(query).Count > 0 ? productItemDao.Query(query)[0] : item; batch.batchno = n_Time + "_" + user.user_id + "_" + item.Product_Id; if (item != null) { item.Item_Stock = item.Item_Stock +query.Item_Stock; aList.Add(Check); result = _tableHistoryMgr.SaveHistory<ProductItem>(item, batch, aList); } ////獲取修改商品Ignore SQL //string Ignore_Stock = string.Empty; //Product product = new Product(); //product = productItemDao.GetTaxByItem(query.Item_Id); //if (product != null) //{ // product.Ignore_Stock = 0; // aList.Clear(); // aList.Add(Ignore_Stock); // result = _tableHistoryMgr.SaveHistory<Product>(product, batch, aList); //} return 1; } catch (Exception ex) { throw new Exception("ProductItemMgr-->UpdateItemStock" + ex.Message, ex); } }
/// <summary> /// 修改商品站台價格表(price_master)信息時,申請審核以及保存價格審核記錄 /// </summary> /// <param name="priceMasters">price_master列表</param> /// <param name="caller"></param> /// <returns>返品錯誤信息</returns> public bool UpdatePriceMasters(List<Model.PriceMaster> priceMasters, Caller caller, out string msg) { msg = string.Empty; bool result = false; try { string batchNo = CommonFunction.GetPHPTime().ToString() + "_" + caller.user_id + "_"; PriceMasterTsMgr _priceMasterTsMgr = new PriceMasterTsMgr(connectionString); HistoryBatch batch = new HistoryBatch(); batch.kuser = caller.user_email; //價格修改 申請審核 PriceUpdateApply priceUpdateApply = new PriceUpdateApply(); priceUpdateApply.apply_user = (uint)caller.user_id; //價格審核記錄 PriceUpdateApplyHistory applyHistroy = new PriceUpdateApplyHistory(); applyHistroy.user_id = (int)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 _priceUpdateApplyMgr = new PriceUpdateApplyMgr(connectionString); PriceUpdateApplyHistoryMgr _priceUpdateApplyHistoryMgr = new PriceUpdateApplyHistoryMgr(connectionString); TableHistoryMgr _tableHistoryMgr = new TableHistoryMgr(connectionString); foreach (var pM in priceMasters) { ArrayList excuteSql = new ArrayList(); priceUpdateApply.price_master_id = pM.price_master_id; int apply_id = _priceUpdateApplyMgr.Save(priceUpdateApply); if (apply_id != -1) { pM.apply_id = (uint)apply_id; pM.price_status = 2;//申請審核 applyHistroy.apply_id = apply_id; batch.batchno = batchNo + pM.product_id;//批號 excuteSql.Add(_priceMasterTsMgr.UpdateTs(pM));//將修改數據保存至price_master_ts表 excuteSql.Add(_priceUpdateApplyHistoryMgr.SaveSql(applyHistroy));//保存審核記錄 if (!_tableHistoryMgr.SaveHistory<PriceMaster>(pM, batch, excuteSql)) msg += pM.product_id.ToString() + ";"; else { result = true; } } } } catch (Exception e) { msg += e.Message; } return result; }