Exemplo n.º 1
0
        public HttpResponseBase PriceVerify()
        {
            string json = string.Empty;
            try
            {
                _pMaster = new PriceMasterMgr(connectionString);
                _pMasterTsMgr = new PriceMasterTsMgr(connectionString);
                _itemPriceMgr = new ItemPriceMgr("");
                _itemPriceTsMgr = new ItemPriceTsMgr("");
                _prodMgr = new ProductMgr(connectionString);
                _tableHistoryMgr = new TableHistoryMgr(connectionString);
                _pHMgr = new PriceUpdateApplyHistoryMgr(connectionString);

                List<PriceMaster> priceMasters = JsonConvert.DeserializeObject<List<PriceMaster>>(Request.Params["priceMasters"]);

                List<PriceUpdateApplyHistory> pHList = new List<PriceUpdateApplyHistory>();

                _functionMgr = new FunctionMgr(connectionString);
                string function = Request.Params["function"] ?? "";
                Function fun = _functionMgr.QueryFunction(function, "/ProductList/PriceVerifyList");
                int functionid = fun == null ? 0 : fun.RowId;
                HistoryBatch batch = new HistoryBatch { functionid = functionid, kuser = (Session["caller"] as Caller).user_email };
                string batchNo = CommonFunction.GetPHPTime().ToString() + "_" + (Session["caller"] as Caller).user_id + "_";

                int operationType = int.Parse(Request.Params["type"]);
                //edit by xiangwang0413w 2014/08/12 批量審核價格
                foreach (var item in priceMasters)
                {
                    //加上price_master 表中同一個product_id的所有價格 add by hufeng0813w 2014/06/12 Reason 各自定價父商品和子商品的價格狀態要同時更新
                    List<PriceMaster> ListpM = _pMasterTsMgr.QueryByApplyId(new PriceMaster { product_id = item.product_id, apply_id = item.apply_id });

                    //價格審核詳情
                    PriceUpdateApplyHistory pH = new PriceUpdateApplyHistory();
                    pH.user_id = (Session["caller"] as Caller).user_id;
                    pH.type = operationType;
                    pH.apply_id = (int)ListpM[0].apply_id;
                    foreach (var pM in ListpM)
                    {
                        ArrayList aList = new ArrayList();
                        uint applyId = pM.apply_id;
                        batch.batchno = batchNo + pM.product_id;
                        ItemPrice ip = new ItemPrice { price_master_id = pM.price_master_id, apply_id = pM.apply_id };
                        if (operationType == 1)//核可
                        {
                            pM.apply_id = 0;
                            pM.price_status = 1;

                            pH.price_status = 1; // 價格狀態為 1 :上架
                            pH.type = 2; //操作動作為2:核可
                            pHList.Add(pH);

                            aList.Add(_pMaster.Update(pM));//核可更新price_master表
                            if (pM.product_id != pM.child_id)
                            {
                                aList.Add(_itemPriceMgr.UpdateFromTs(ip));  //將Item_price_ts相對應數據導入Item_price表
                                aList.Add(_itemPriceTsMgr.DeleteTs(ip)); //更新成功後,刪除item_price_ts相應數據
                            }
                        }
                        else//駁回
                        {
                            pM.price_status = 3;
                            pH.price_status = 3; //加個狀態為 申請駁回
                            pH.type = 3; //操作動作為 3:駁回
                            pH.remark = Request.Params["reason"];
                            pHList.Add(pH);
                            if (pM.product_id != pM.child_id)
                            {
                                aList.Add(_itemPriceTsMgr.DeleteTs(ip)); //更新成功後,刪除item_price_ts相應數據
                            }
                        }
                        aList.Add(_pMasterTsMgr.DeleteTs(new PriceMaster { price_master_id = pM.price_master_id, apply_id = applyId }));//審核完成後刪除price_master_ts表
                        _tableHistoryMgr.SaveHistory<PriceMaster>(pM, batch, aList);
                    }
                }

                if (operationType == 1)//核可
                {
                    string[] prodList = (from p in priceMasters select p.product_id.ToString()).ToArray();

                    //將 獲取 時間 代碼提前  是後面獲得的 時間 相同
                    uint TimeNow = uint.Parse(CommonFunction.GetPHPTime(DateTime.Now.ToString()).ToString());

                    for (int i = 0; i < prodList.Length; i++)
                    {
                        ArrayList pList = new ArrayList();
                        //查詢product
                        Product product = _prodMgr.Query(new Product() { Product_Id = uint.Parse(prodList[i]) })[0];
                        if (product.Product_Start < TimeNow && product.Product_End > TimeNow)
                        {
                            product.Product_Start = TimeNow;
                        }
                        //p.Product_Status = 5; //價格審核不應該更改商品狀態 edit by xiangwang0413w 20140826
                        pList.Add(_prodMgr.Update(product));
                        batch.batchno = batchNo + product.Product_Id;
                        _tableHistoryMgr.SaveHistory<Product>(product, batch, pList);
                    }

                }
                //價格審核記錄
                _pHMgr.Save(pHList);
                json = "{success:true}";
            }
            catch (Exception ex)
            {
                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);
                json = "{success:false}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
Exemplo n.º 2
0
        public HttpResponseBase vaiteVerifyPass()
        {
            string resultStr = "{success:false}";
            bool result = true;
            try
            {
                Caller _caller = (Session["caller"] as Caller);
                _applyMgr = new ProductStatusApplyMgr(connectionString);
                _statusHistoryMgr = new ProductStatusHistoryMgr(connectionString);
                _prodMgr = new ProductMgr(connectionString);
                _pMaster = new PriceMasterMgr(connectionString);
                _tableHistoryMgr = new TableHistoryMgr(connectionString);
                string productIds = Request.Params["prodcutIdStr"];
                string[] products = productIds.Split(',');

                _functionMgr = new FunctionMgr(connectionString);
                string function = Request.Params["function"] ?? "";
                Function fun = _functionMgr.QueryFunction(function, "/ProductList/VerifyList");
                int functionid = fun == null ? 0 : fun.RowId;
                HistoryBatch batch = new HistoryBatch { functionid = functionid, kuser = (Session["caller"] as Caller).user_email };
                string batchNo = CommonFunction.GetPHPTime().ToString() + "_" + (Session["caller"] as Caller).user_id + "_";

                foreach (string item in products)
                {
                    Product product = _prodMgr.Query(new Product { Product_Id = uint.Parse(item) }).FirstOrDefault();

                    ArrayList sqls = new ArrayList();
                    if (_applyMgr.Query(new ProductStatusApply { product_id = uint.Parse(item) }) != null)
                    {
                        batch.batchno = batchNo + product.Product_Id;
                        //更改商品价格之状态
                        PriceMaster pmQuery = new PriceMaster();
                        if (product.Combination != 0 && product.Combination != 1)   //组合商品
                        {
                            pmQuery.child_id = int.Parse(item);
                        }
                        else
                        {
                            pmQuery.child_id = 0;
                        }
                        pmQuery.product_id = uint.Parse(item);
                        pmQuery.price_status = 2;       //只更改价格状态为申请审核的商品价格        
                        List<PriceMaster> pmResultList = _pMaster.PriceMasterQuery(pmQuery);
                        if (pmResultList != null && pmResultList.Count() > 0)
                        {
                            _pHMgr = new PriceUpdateApplyHistoryMgr(connectionString);
                            List<PriceUpdateApplyHistory> pHList = new List<PriceUpdateApplyHistory>();
                            foreach (var pm in pmResultList)
                            {
                                ArrayList priceUpdateSqls = new ArrayList();
                                pm.price_status = 1;      //价格状态为上架
                                pm.apply_id = 0;
                                priceUpdateSqls.Add(_pMaster.Update(pm));
                                if (!_tableHistoryMgr.SaveHistory<PriceMaster>(pm, batch, priceUpdateSqls))
                                {
                                    result = false;
                                    break;
                                }

                                //价格异动记录(price_update_apply_history)                            
                                PriceUpdateApplyHistory pH = new PriceUpdateApplyHistory();
                                pH.apply_id = int.Parse(pm.apply_id.ToString());
                                pH.user_id = (Session["caller"] as Caller).user_id;
                                pH.price_status = 1;
                                pH.type = 1;
                                pHList.Add(pH);
                            }
                            if (!_pHMgr.Save(pHList))
                            {
                                result = false;
                                break;
                            }
                        }

                        //更改商品之状态
                        ProductStatusApply queryApply = _applyMgr.Query(new ProductStatusApply { product_id = uint.Parse(item) });
                        uint online_mode = queryApply.online_mode;
                        //申請狀態為審核後立即上架時將上架時間改為當前時間,商品狀態改為上架
                        if (online_mode == 2)
                        {
                            product.Product_Status = 5;
                            product.Product_Start = uint.Parse(BLL.gigade.Common.CommonFunction.GetPHPTime(DateTime.Now.ToLongTimeString()).ToString());
                        }
                        else
                        {
                            product.Product_Status = 2;
                            //product.Product_Start = online_mode;
                        }
                        sqls.Add(_prodMgr.Update(product, _caller.user_id));

                        ProductStatusHistory save = new ProductStatusHistory();
                        save.product_id = product.Product_Id;
                        save.user_id = uint.Parse(_caller.user_id.ToString());
                        save.type = 2;           //操作類型(核可)
                        save.product_status = int.Parse(product.Product_Status.ToString());

                        sqls.Add(_statusHistoryMgr.Save(save));         //保存历史记录

                        sqls.Add(_applyMgr.Delete(queryApply));         //刪除審核申請表中的數據

                        if (!_tableHistoryMgr.SaveHistory<Product>(product, batch, sqls))
                        {
                            result = false;
                            break;
                        }
                    }
                    else
                    {
                        result = false;
                        break;
                    }
                }
                resultStr = "{success:" + result.ToString().ToLower() + "}";
            }
            catch (Exception ex)
            {
                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);
            }

            Response.Clear();
            Response.Write(resultStr);
            Response.End();
            return this.Response;
        }