Exemplo n.º 1
0
 public string Save(ProductStatusHistory save)
 {
     try
     {
         return _historyDao.Save(save);
     }
     catch (Exception ex)
     {
         throw new Exception("ProductStatusHistoryMgr-->SaveNoProductId" + ex.Message, ex);
     }
 }
Exemplo n.º 2
0
 public string InsertIntoProductStatusHistory(ProductStatusHistory psh)
 {
     try
     {
         return _iproductRemoveReason.InsertIntoProductStatusHistory(psh);
     }
     catch (Exception ex)
     {
         throw new Exception("ProductRemoveReasonMgr-->InsertIntoProductStatusHistory-->" + ex.Message, ex);
     }
 }
Exemplo n.º 3
0
        public HttpResponseBase vaiteVerifyBack()
        {
            string resultStr = "{success:false}";
            bool result = true;
            try
            {
                string productIds = Request.Params["productIds"];
                string backReason = Request.Params["backReason"];

                Caller _caller = (Session["caller"] as Caller);
                _applyMgr = new ProductStatusApplyMgr(connectionString);
                _statusHistoryMgr = new ProductStatusHistoryMgr(connectionString);
                _prodMgr = new ProductMgr(connectionString);
                _tableHistoryMgr = new TableHistoryMgr(connectionString);
                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)
                    {
                        ProductStatusApply queryApply = _applyMgr.Query(new ProductStatusApply { product_id = uint.Parse(item) });
                        uint prev_status = queryApply.prev_status;
                        product.Product_Status = prev_status;
                        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 = 3;           //操作類型(駁回)
                        save.product_status = int.Parse(product.Product_Status.ToString());
                        save.remark = backReason;
                        sqls.Add(_statusHistoryMgr.Save(save));

                        batch.batchno = batchNo + product.Product_Id;

                        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;
        }
Exemplo n.º 4
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;
        }
Exemplo n.º 5
0
        public HttpResponseBase verifyApply()
        {
            List<QueryandVerifyCustom> resultList = new List<QueryandVerifyCustom>();
            string result = "{success:false}";
            bool resl = true;
            try
            {
                string prodcutIdStr = Request.Params["prodcutIdStr"];
                string[] productIds = prodcutIdStr.Split(',');
                string method = Request.Params["method"];
                Caller _caller = (Session["caller"] as Caller);
                _prodMgr = new ProductMgr(connectionString);
                _applyMgr = new ProductStatusApplyMgr(connectionString);
                _statusHistoryMgr = new ProductStatusHistoryMgr(connectionString);
                _tableHistoryMgr = new TableHistoryMgr(connectionString);
                _functionMgr = new FunctionMgr(connectionString);
                string function = Request.Params["function"] ?? "";
                Function fun = _functionMgr.QueryFunction(function, "/ProductList") ?? _functionMgr.QueryFunction(function, "/ProductList/ReplaceVerify");
                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 + "_";

                string msg = "";
                foreach (string item in productIds.Distinct())
                {
                    ArrayList sqls = new ArrayList();
                    Product update = _prodMgr.Query(new Product { Product_Id = uint.Parse(item) }).FirstOrDefault();
                    //選擇自動上架時間時更改商品上架時間為選定時間
                    if (method.Equals("3"))
                    {
                        update.Product_Start = uint.Parse(BLL.gigade.Common.CommonFunction.GetPHPTime(Request.Params["product_start"]).ToString());
                        method = "1";
                    }
                    //若當前商品狀態不是新建商品或下架,則跳過申請
                    if (update.Product_Status != 0 && update.Product_Status != 6 && update.Product_Status!=7)
                    {
                        break;
                    }
                    //判斷商品是否失格 則 直接取消申請  add by  zhuoqin0830w 20105/07/01
                    if (update.off_grade == 1)
                    {
                        msg += "【" + update.Product_Id + "】商品是失格商品,不可申請審核!</br>";
                        break;
                    }
                    ProductStatusApply apply = new ProductStatusApply();
                    apply.product_id = uint.Parse(item);
                    apply.prev_status = update.Product_Status;
                    apply.online_mode = uint.Parse(method);
                    sqls.Add(_applyMgr.Save(apply));

                    ProductStatusHistory history = new ProductStatusHistory();
                    history.product_id = uint.Parse(item);
                    history.user_id = uint.Parse(_caller.user_id.ToString());
                    history.type = 1;               //操作類型        ???????????????????                      
                    history.product_status = 1;     //操作後狀態
                    //edit by zhuoqin0830w  2015/06/30  添加備註欄位
                    history.remark = Request.Form["Remark"];
                    sqls.Add(_statusHistoryMgr.Save(history));

                    batch.batchno = batchNo + update.Product_Id;
                    update.Product_Status = 1;    //狀態 -> 申請審核
                    sqls.Add(_prodMgr.Update(update, _caller.user_id));
                    if (!_tableHistoryMgr.SaveHistory<Product>(update, batch, sqls))
                    {
                        resl = false;
                    }
                    //若當前商品為單一商品並且商品狀態為新建商品,則將product_item.export_flag改為1
                    if (resl && update.Combination == 1 && apply.prev_status == 0)
                    {
                        _productItemMgr = new ProductItemMgr(connectionString);
                        ProductItem proItem = new ProductItem() { Product_Id = update.Product_Id, Export_flag = 1 };
                        _productItemMgr.UpdateExportFlag(proItem);
                    }
                }
                result = "{success:" + resl.ToString().ToLower() + ",'msg':'" + msg + "'}";
            }
            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(result);
            Response.End();
            return this.Response;
        }
Exemplo n.º 6
0
        public HttpResponseBase ProductUp()
        {
            string json = "{success:true}";
            try
            {
                if (!string.IsNullOrEmpty(Request.Form["Product_Id"]))
                {
                    string[] pro_Ids = Request.Form["Product_Id"].Split('|');

                    _functionMgr = new FunctionMgr(connectionString);
                    string function = Request.Params["function"] ?? "";
                    Function fun = _functionMgr.QueryFunction(function, "/ProductList");
                    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 + "_";

                    _prodMgr = new ProductMgr(connectionString);
                    _tableHistoryMgr = new TableHistoryMgr(connectionString);
                    _productStatusHistoryMgr = new ProductStatusHistoryMgr("");
                    ProductStatusHistory proStatusHistory = new ProductStatusHistory { product_status = 5, type = 6, user_id = Convert.ToUInt32((Session["caller"] as Caller).user_id) };
                    ArrayList sqls;
                    foreach (string str in pro_Ids.Distinct())
                    {
                        if (!string.IsNullOrEmpty(str))
                        {
                            uint product_id = uint.Parse(str);
                            Product pro = _prodMgr.Query(new Product { Product_Id = product_id }).FirstOrDefault();
                            //上架商品不能為失格商品  eidt by  zhuoqin0830w 20105/07/01  pro.off_grade != 1
                            string msg = "";
                            if (pro.off_grade == 1)
                            {
                                msg += "【" + pro.Product_Id + "】商品是失格商品,不可上架!</br>";
                                json = "{success:false,'msg':'" + msg + "'}";
                                break;
                            }
                            if (pro != null && pro.Product_Status == 2)//&& pro.user_id == (Session["caller"] as Caller).user_id 
                            {
                                pro.Product_Status = 5;//上架
                                pro.Product_Start = Convert.ToUInt32(CommonFunction.GetPHPTime());
                                sqls = new ArrayList();
                                sqls.Add(_prodMgr.Update(pro));

                                batch.batchno = batchNo + pro.Product_Id;

                                proStatusHistory.product_id = product_id;
                                //edit by zhuoqin0830w  2015/06/26  添加備註欄位
                                proStatusHistory.remark = Request.Form["Remark"];
                                sqls.Add(_productStatusHistoryMgr.Save(proStatusHistory));
                                if (!_tableHistoryMgr.SaveHistory<Product>(pro, batch, sqls))
                                {
                                    json = "{success:false}";
                                }
                            }
                        }
                    }
                }
            }
            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.º 7
0
        public HttpResponseBase ProductDown(int type = 1)
        {
            string json = "{success:true}";
            try
            {
                if (!string.IsNullOrEmpty(Request.Form["Product_Id"]))
                {
                    string[] pro_Ids = Request.Form["Product_Id"].Split('|');
                    uint product_end =0 ;
                    if (!string.IsNullOrEmpty(Request.Form["Product_End"]))
                    {
                        product_end = Convert.ToUInt32(CommonFunction.GetPHPTime(Request.Form["Product_End"]));
                    }
                    //立即下架不改變下架時間
                    //else
                    //{
                    //    product_end = Convert.ToUInt32(CommonFunction.GetPHPTime());
                    //}

                    _functionMgr = new FunctionMgr(connectionString);
                    string function = Request.Params["function"] ?? "";
                    Function fun = _functionMgr.QueryFunction(function, "/ProductList");
                    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 + "_";

                    _prodMgr = new ProductMgr(connectionString);
                    _tableHistoryMgr = new TableHistoryMgr(connectionString);
                    _productStatusHistoryMgr = new ProductStatusHistoryMgr("");
                    ProductStatusHistory proStatusHistory = new ProductStatusHistory { product_status = 6, type = 4, user_id = Convert.ToUInt32((Session["caller"] as Caller).user_id) };
                    ArrayList sqls;
                    foreach (string str in pro_Ids.Distinct())
                    {
                        if (!string.IsNullOrEmpty(str))
                        {
                            uint product_id = uint.Parse(str);
                            Product pro = _prodMgr.Query(new Product { Product_Id = product_id }).FirstOrDefault();
                            if (type == 1 && product_end == 0)//說明是立即下架,就用原來的時間
                            {
                                product_end = pro.Product_End;
                            }
                            //edit by zhuoqin0830w  2015/06/26  添加備註欄位
                            string remark = "";
                            if (pro != null && pro.Product_Status == 5)// && pro.user_id == (Session["caller"] as Caller).user_id
                            {
                                switch (type)
                                {
                                    case 1:
                                        pro.Product_Status = 6;//下架
                                        remark = Request.Form["UnShelve"]; //edit by zhuoqin0830w  2015/06/26  添加備註欄位
                                        pro.Product_End = product_end;  //將 pro.Product_End = product_end 代碼提前  避免下架不販售的時候沒有下架時間  edit by zhuoqin0830w  2015/07/15
                                        break;
                                    case 2:
                                        pro.Product_Status = 99;//下架不販售
                                        remark = Request.Form["Remark"]; //edit by zhuoqin0830w  2015/06/26  添加備註欄位
                                        IProductExtImplMgr _prodExtMgr = new ProductExtMgr(connectionString);
                                        _prodExtMgr.UpdatePendDel(product_id, true);
                                        break;
                                }

                                sqls = new ArrayList();
                                sqls.Add(_prodMgr.Update(pro));
                                batch.batchno = batchNo + pro.Product_Id;
                                proStatusHistory.product_id = product_id;
                                //edit by zhuoqin0830w  2015/06/26  添加備註欄位
                                proStatusHistory.remark = remark;
                                sqls.Add(_productStatusHistoryMgr.Save(proStatusHistory));
                                if (!_tableHistoryMgr.SaveHistory<Product>(pro, batch, sqls))
                                {
                                    json = "{success:false}";
                                }
                            }
                        }
                    }
                }
            }
            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.º 8
0
        public string SetProductRmoveDown()
        {

            int resultone = 0;
            int resulttwo = 0;
            int resultthree = 0;
            string startRunInfo = "";
            string endRunInfo = "";
            try
            {
                //if (Request.Url.Host == "mng.gigade100.com")//判断是否为正式线
                //{
                //    return "{success:false,data:'',msg:'未驗收,暫不執行!'}";
                //}
                //else
                //{
                startRunInfo = DateTime.Now.ToString() + ": SetProductRmoveDown Start";
                _proRemoveMgr = new ProductRemoveReasonMgr(connectionString);

                ProductRemoveReason prr = new ProductRemoveReason();
                ProductRemoveReason prrtwo = new ProductRemoveReason();
                Product pt = new Product();
                ProductStatusHistory psh = new ProductStatusHistory();

                #region 往临时表中插入数据/或者更新数据  sql可以统一执行
                //獲取到上架商品庫存<=0,並且排除掉庫存為0可販賣機暫停售賣的商品
                DataTable _dt = _proRemoveMgr.GetStockLessThanZero();
                //获取到临时表中的数据
                DataTable _dttwo = _proRemoveMgr.GetProductRemoveReasonList();
                //判断临时表是否存在,如果不存在,则插入数据
                StringBuilder str = new StringBuilder();
                if (_dt.Rows.Count > 0)
                {
                    for (int i = 0; i < _dt.Rows.Count; i++)
                    {
                        DataRow[] dr = _dttwo.Select("product_id=" + _dt.Rows[i]["product_id"]);
                        if (dr.Length <= 0)//小于等于0  无需处理编辑数据,因为获取的库存都是等于或者小于0的
                        {
                            prr.create_name = "system";
                            prr.create_time = Convert.ToInt32(CommonFunction.GetPHPTime(CommonFunction.DateTimeToString(DateTime.Now)));
                            prr.product_id = Convert.ToUInt32(_dt.Rows[i]["product_id"]);
                            prr.product_num = Convert.ToInt32(_dt.Rows[i]["item_stock"]);
                            str.AppendFormat(_proRemoveMgr.InsertProductRemoveReason(prr));
                        }
                    }
                }
                //获取出临时表中要删除的数据 
                DataTable _dtthree = _proRemoveMgr.GetDeleteProductRemoveReasonList();
                for (int b = 0; b < _dtthree.Rows.Count; b++)
                {
                    prr.product_id = Convert.ToUInt32(_dtthree.Rows[b]["product_id"]);
                    str.AppendFormat(_proRemoveMgr.DeleteProductRemoveReason(prr));
                }
                if (str.ToString().Length > 0)
                {
                    resultone = _proRemoveMgr.ProductRemoveReasonTransact(str.ToString());
                }
                else
                {
                    resultone = 1;
                }
                #endregion

                #region 缺货商品下架
                DataTable _dtNew = _proRemoveMgr.GetStockMsg();
                StringBuilder strsql = new StringBuilder();
                if (_dtNew.Rows.Count > 0)
                {
                    for (int j = 0; j < _dtNew.Rows.Count; j++)
                    {
                        int time = Convert.ToInt32(_dtNew.Rows[j]["create_time"]);
                        DateTime dttime = CommonFunction.GetNetTime(time);
                        TimeSpan ts = DateTime.Now - dttime;
                        prrtwo.product_id = Convert.ToUInt32(_dtNew.Rows[j]["product_id"]);
                        pt.Product_Id = Convert.ToUInt32(_dtNew.Rows[j]["product_id"]);
                        pt.Product_Status = 7;//7为缺货系统下架
                        psh.product_id = Convert.ToUInt32(_dtNew.Rows[j]["product_id"]);
                        psh.user_id = 2;
                        psh.create_time = DateTime.Now;
                        psh.type = 9;//缺货系统下架
                        psh.product_status = 7;
                        psh.remark = "系统账号插入";
                        if (ts.Days >= (_dtNew.Rows[j]["outofstock_days_stopselling"] == "" ? 0 : Convert.ToInt32(_dtNew.Rows[j]["outofstock_days_stopselling"])))//表示可以下架,执行下架工作
                        {
                            //改变product表中商品的状态
                            strsql.AppendFormat(_proRemoveMgr.UpdateProductStatus(pt));
                            //网记录表中插入一条数据
                            strsql.AppendFormat(_proRemoveMgr.InsertIntoProductStatusHistory(psh));
                            //删除临时表中的数据
                            strsql.AppendFormat(_proRemoveMgr.DeleteProductRemoveReason(prrtwo));
                        }
                    }
                }
                if (strsql.ToString().Length > 0)
                {
                    resulttwo = _proRemoveMgr.ProductRemoveReasonTransact(strsql.ToString());
                }
                else
                {
                    resulttwo = 1;
                }
                #endregion

                #region 缺货商品状态改为申请审核
                DataTable _dtOutofStock = _proRemoveMgr.GetOutofStockMsg();
                StringBuilder strslqmsg = new StringBuilder();
                StringBuilder strslqmsgtwo = new StringBuilder();
                if (_dtOutofStock.Rows.Count > 0)
                {
                    for (int z = 0; z < _dtOutofStock.Rows.Count; z++)
                    {
                        if (Convert.ToInt32(_dtOutofStock.Rows[z]["item_stock"]) > 0)
                        {
                            pt.Product_Id = Convert.ToUInt32(_dtOutofStock.Rows[z]["product_id"]);
                            pt.Product_Status = 1;//1表示申请审核
                            _proRemoveMgr.UpdateProductStatus(pt);
                            psh.product_id = Convert.ToUInt32(_dtOutofStock.Rows[z]["product_id"]);
                            psh.user_id = 2;
                            psh.create_time = DateTime.Now;
                            psh.type = 1;//1表示申请审核
                            psh.product_status = 1;//申请审核
                            psh.remark = "系统账号插入";
                            strslqmsg.AppendFormat(_proRemoveMgr.UpdateProductStatus(pt));
                            strslqmsg.AppendFormat(_proRemoveMgr.InsertIntoProductStatusHistory(psh));
                        }
                        prr.product_id = Convert.ToUInt32(_dtOutofStock.Rows[z]["product_id"]);//根据product_id删除数据
                        strslqmsgtwo.AppendFormat(_proRemoveMgr.DeleteProductRemoveReason(prr));
                    }
                }

                if (strslqmsg.ToString().Length > 0)
                {
                    resultthree = _proRemoveMgr.ProductRemoveReasonTransact(strslqmsg.ToString() + strslqmsgtwo.ToString());
                }
                else
                {
                    if (strslqmsgtwo.ToString().Length > 0)
                    {
                        _proRemoveMgr.ProductRemoveReasonTransact(strslqmsgtwo.ToString());
                    }
                    resultthree = 1;
                }
                #endregion

                if (resultone > 0 && resulttwo > 0 && resultthree > 0)
                {
                    SaleStatus();
                    //DataTable _excelMsg = _proRemoveMgr.GetStockMsg();
                    //ExeclProductRmoveDownMsg(_excelMsg);
                    endRunInfo = DateTime.Now.ToString() + ": SetProductRmoveDown End ";
                    WriterInfo("SetProductRmoveDown-Success", startRunInfo, endRunInfo);
                    return "{success:true}";
                }
                else
                {
                    endRunInfo = DateTime.Now.ToString() + ": SetProductRmoveDown End ";
                    WriterInfo("SetProductRmoveDown-Fail", startRunInfo, endRunInfo);
                    return "{success:false}";
                }
                //}
            }
            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);
                endRunInfo = DateTime.Now.ToString() + "SetProductRmoveDown: " + ex.Message;
                WriterInfo("SetProductRmoveDown", startRunInfo, endRunInfo);
                return "{success:false,data:'',msg:" + ex.Message + "}";
            }
        }
Exemplo n.º 9
0
 public string InsertIntoProductStatusHistory(ProductStatusHistory psh)
 {
     StringBuilder sb = new StringBuilder();
     sb.AppendFormat(@"insert into product_status_history (`product_id`,`user_id`,`create_time`,`type`,`product_status`,`remark`)");
     sb.AppendFormat(" values ({0},{1},now(),{2},{3},'{4}');",psh.product_id,2, psh.type,psh.product_status,psh.remark);
     if (psh.product_status == 1)
     {
         sb.AppendFormat(@"insert into product_status_apply(`product_id`,`prev_status`,`apply_time`,`online_mode`)");
         sb.AppendFormat("values('{0}','{1}',now(),'{2}');", psh.product_id, 7, 2);//在这里online_mode为审核之后直接下架
     }
     try
     {
         return sb.ToString();
     }
     catch (Exception ex)
     {
         throw new Exception("ProductRemoveReasonDao.InsertIntoProductStatusHistory-->" + ex.Message + sb.ToString(), ex);
     }
 }