示例#1
0
 public List<ProdVdReqQuery> QueryProdVdReqList(ProdVdReqQuery query, out int totalCount)
 {
     try
     {
         return _prodVbReqdao.QueryProdVdReqList(query, out totalCount);
     }
     catch (Exception ex)
     {
         throw new Exception("ProdVdReqMgr.QueryProdVdReqList-->" + ex.Message, ex);
     }
 }
        public HttpResponseBase ProductDown()
        {
            string json = "{success:true}";
            _prodVdReq = new ProdVdReqMgr(connectionString);
            _productMgr = new ProductMgr(connectionString);
            try
            {
                if (!string.IsNullOrEmpty(Request.Form["Product_Id"]))
                {
                    string[] pro_Ids = Request.Form["Product_Id"].Split('|');
                    BLL.gigade.Model.Vendor vendor = Session["vendor"] as BLL.gigade.Model.Vendor;
                    uint product_end = 0;
                    string dtime = CommonFunction.DateTimeToString(Convert.ToDateTime(DateTime.Now.ToString()));
                    var explain = Request.Form["explain"] ?? "";
                    if (!string.IsNullOrEmpty(Request.Form["Product_End"]))
                    {
                        dtime = CommonFunction.DateTimeToString(Convert.ToDateTime(Request.Form["Product_End"].ToString()));
                        product_end = Convert.ToUInt32(CommonFunction.GetPHPTime(Request.Form["Product_End"]));
                    }

                    foreach (string str in pro_Ids.Distinct())
                    {
                        if (!string.IsNullOrEmpty(str))
                        {
                            uint product_id = uint.Parse(str);
                            Product pro = _productMgr.Query(new Product { Product_Id = product_id }).FirstOrDefault();
                            if (product_end == 0)//說明是立即下架,就用原來的時間
                            {
                                product_end = pro.Product_End;
                            }
                            if (pro != null && pro.Product_Status == 5)// && pro.user_id == (Session["caller"] as Caller).user_id
                            {
                                ProdVdReqQuery prodQuery = new ProdVdReqQuery();
                                prodQuery.vendor_id = Convert.ToInt32(vendor.vendor_id);
                                prodQuery.product_id = Convert.ToInt32(product_id);
                                prodQuery.req_status = 1;
                                int totalCount = 0;
                                ProdVdReq prodRquery = _prodVdReq.QueryProdVdReqList(prodQuery, out totalCount).FirstOrDefault();



                                if (prodRquery == null)
                                {
                                    prodRquery = new ProdVdReq();
                                    prodRquery.vendor_id = Convert.ToInt32(vendor.vendor_id);
                                    prodRquery.product_id = Convert.ToInt32(product_id);
                                    prodRquery.req_status = 1;
                                    prodRquery.req_datatime = Convert.ToDateTime(dtime);
                                    prodRquery.req_type = 2;
                                    prodRquery.explain = explain + dtime;

                                    if (_prodVdReq.Insert(prodRquery) < 0)
                                    {
                                        json = "{success:false,msg:0}";//返回json數據
                                    }
                                }
                                else
                                {
                                    prodRquery.vendor_id = Convert.ToInt32(vendor.vendor_id);
                                    prodRquery.product_id = Convert.ToInt32(product_id);
                                    prodRquery.req_status = 1;
                                    prodRquery.req_datatime = Convert.ToDateTime(dtime);
                                    prodRquery.req_type = 2;
                                    prodRquery.explain = explain + dtime;
                                    if (_prodVdReq.Update(prodRquery) < 0)
                                    {
                                        json = "{success:false,msg:0}";//返回json數據
                                    }
                                }
                            }
                        }
                    }
                }
                //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;
        }
        public HttpResponseBase ProductUp()
        {
            string json = "{success:true}";
            BLL.gigade.Model.Vendor vendor = Session["vendor"] as BLL.gigade.Model.Vendor;
            _prodVdReq = new ProdVdReqMgr(connectionString);
            _productMgr = new ProductMgr(connectionString);
            try
            {
                if (!string.IsNullOrEmpty(Request.Form["Product_Id"]))
                {
                    string[] pro_Ids = Request.Form["Product_Id"].Split('|');
                    foreach (string str in pro_Ids.Distinct())
                    {
                        if (!string.IsNullOrEmpty(str))
                        {
                            uint product_id = uint.Parse(str);
                            Product pro = _productMgr.Query(new Product { Product_Id = product_id }).FirstOrDefault();
                            if (pro != null && pro.Product_Status != 5)
                            {
                                ProdVdReqQuery prodQuery = new ProdVdReqQuery();
                                prodQuery.vendor_id = Convert.ToInt32(vendor.vendor_id);
                                prodQuery.product_id = Convert.ToInt32(product_id);
                                prodQuery.req_status = 1;
                                int totalCount = 0;
                                ProdVdReq prodRquery = _prodVdReq.QueryProdVdReqList(prodQuery, out totalCount).FirstOrDefault();


                                if (prodRquery == null)
                                {
                                    prodRquery = new ProdVdReq();
                                    prodRquery.vendor_id = Convert.ToInt32(vendor.vendor_id);
                                    prodRquery.product_id = Convert.ToInt32(product_id);
                                    prodRquery.req_status = 1;
                                    prodRquery.req_datatime = DateTime.Now;
                                    prodRquery.req_type = 1;
                                    if (_prodVdReq.Insert(prodRquery) < 0)
                                    {
                                        json = "{success:false,msg:0}";//返回json數據
                                    }
                                }
                                else
                                {
                                    prodRquery.vendor_id = Convert.ToInt32(vendor.vendor_id);
                                    prodRquery.product_id = Convert.ToInt32(product_id);
                                    prodRquery.req_status = 1;
                                    prodRquery.req_datatime = DateTime.Now;
                                    prodRquery.req_type = 1;
                                    if (_prodVdReq.Update(prodRquery) < 0)
                                    {
                                        json = "{success:false,msg:0}";//返回json數據
                                    }
                                }
                            }
                        }
                    }
                }
                //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;
        }
示例#4
0
        public List<ProdVdReqQuery> QueryProdVdReqList(ProdVdReqQuery query, out int totalCount)
        {
            StringBuilder sql = new StringBuilder();
            try
            {
                query.Replace4MySQL();
                StringBuilder strCols = new StringBuilder("select pvr.rid,pvr.vendor_id,v.vendor_name_full,v.vendor_name_simple as vendor_name, ");
                strCols.Append("pvr.product_id,p.product_name,p.product_status,psta.parameterName as statusName,p.brand_id,vb.brand_name,");
                strCols.Append("  pvr.req_status,pvr.req_datatime,pvr.`explain`, ");
                strCols.Append("pvr.req_type, pvr.user_id,u.user_name,pvr.reply_note, ");
                strCols.AppendFormat(" pvr.reply_datetime ");
                StringBuilder strTbls = new StringBuilder(" from prod_vd_req pvr  ");
                strTbls.Append(" LEFT JOIN vendor v on v.vendor_id=pvr.vendor_id ");
                strTbls.Append(" LEFT JOIN product p on p.product_id=pvr.product_id ");
                strTbls.Append(" LEFT JOIN vendor_brand vb on vb.brand_id =p.brand_id and pvr.vendor_id=vb.vendor_id ");
                strTbls.Append("  LEFT JOIN (select * from  t_parametersrc  tp where   tp.parameterType  ='product_status') psta on psta.parameterCode= p.product_status ");
                strTbls.Append(" LEFT JOIN users u on u.user_id=pvr.user_id ");
                StringBuilder strCondi = new StringBuilder(" where 1=1 ");
                //if (!string.IsNullOrEmpty(query.vendor_name))
                //{
                //    strCondi.AppendFormat(" and ( v.vendor_name_simple LIKE '%{0}%'", query.vendor_name);
                //    strCondi.AppendFormat(" OR  v.vendor_name_simple LIKE '%{0}%' )", query.vendor_name);
                //}
                if (query.brand_id != 0)
                {
                    strCondi.AppendFormat(" and p.brand_id ={0} ", query.brand_id);
                }
                if (query.rid != 0)
                {
                    strCondi.AppendFormat(" and pvr.rid ={0} ", query.rid);
                }
                if (query.product_id != 0)
                {
                    strCondi.AppendFormat(" and pvr.product_id ={0}", query.product_id);
                }
                if (query.req_status != 0)
                {
                    strCondi.AppendFormat(" and pvr.req_status ={0}", query.req_status);
                }
                if (query.time_start != DateTime.MinValue)
                {
                    strCondi.AppendFormat(" and pvr.req_datatime >='{0}'", CommonFunction.DateTimeToString(query.time_start));
                }
                if (query.time_end != DateTime.MinValue)
                {
                    strCondi.AppendFormat(" and pvr.req_datatime <='{0}'", CommonFunction.DateTimeToString(query.time_end));
                }
                if (query.req_type != 0)
                {
                    strCondi.AppendFormat(" and pvr.req_type ={0}", query.req_type);
                }
                string strCount = "select count(*)  as totalCount " + strTbls.ToString() + strCondi.ToString();
                sql.Append(strCount + ";");
                System.Data.DataTable _dt = _dbAccess.getDataTable(strCount);
                totalCount = 0;
                if (_dt != null && _dt.Rows.Count > 0)
                {
                    totalCount = Convert.ToInt32(_dt.Rows[0]["totalCount"]);
                }

                strCondi.Append(" order by pvr.req_datatime desc ");
                if (query.IsPage)
                {
                    strCondi.AppendFormat(" limit {0},{1}", query.Start, query.Limit);
                }
                string sqlstr = strCols.ToString() + strTbls.ToString() + strCondi.ToString();
                sql.Append(sqlstr + ";");
                return _dbAccess.getDataTableForObj<ProdVdReqQuery>(sqlstr);
            }
            catch (Exception ex)
            {
                throw new Exception("ProdVdReqDao.QueryProdVdReqList-->" + ex.Message + sql.ToString(), ex);
            }
        }
        public HttpResponseBase ProdVdReqPass()
        {
            string resultStr = "{success:true}";
            try
            {
                string rIdAndProdId = Request.Params["rIdAndProdId"];
                string[] rIdAndProdIdS = rIdAndProdId.Split(';');

                foreach (string item in rIdAndProdIdS)
                {
                    var rid = item.Split(',')[0];
                    var product_id = item.Split(',')[1];


                    ProdVdReqQuery prodQuery = new ProdVdReqQuery();
                    prodQuery.rid = int.Parse(rid);
                    prodQuery.product_id = int.Parse(product_id);
                    int totalCount = 0;
                    ProdVdReq prodRquery = _prodVdReq.QueryProdVdReqList(prodQuery, out totalCount).FirstOrDefault();
                    _prodMgr = new ProductMgr(connectionString);
                    Product p = _prodMgr.Query(new Product { Product_Id = Convert.ToUInt32(prodRquery.product_id) }).FirstOrDefault();
                    if (p.Product_Status != 5 && prodRquery.req_type == 1)
                    {

                        resultStr = "{success:false,msg:\"" + "請先核可商品狀態,以完成上下架申請" + "\"}";//返回json數據
                        break;
                    }
                    else if (p.Product_Status != 6 && prodRquery.req_type == 2)
                    {
                        resultStr = "{success:false,msg:\"" + "請先核可商品狀態,以完成上下架申請" + "\"}";//返回json數據
                        break;
                    }
                    else
                    {
                        prodRquery.req_status = 2;
                        prodRquery.reply_datetime = DateTime.Now;
                        prodRquery.user_id = int.Parse((System.Web.HttpContext.Current.Session["caller"] as Caller).user_id.ToString());
                        if (_prodVdReq.Update(prodRquery) < 0)
                        {
                            resultStr = "{success:false,msg'" + Resources.Product.SAVE_FAIL + "'}";
                        }
                    }
                }
                //resultStr = "{success:true,msg'" + Resources.Product.SAVE_SUCCESS + "'}";
            }
            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);
                resultStr = "{success:false,msg'" + Resources.Product.SAVE_FAIL + "'}";
            }

            Response.Clear();
            Response.Write(resultStr);
            Response.End();
            return this.Response;
        }
        public HttpResponseBase ProdVdReqBack()
        {
            string resultStr = "{success:true}";
            try
            {
                string rIdAndProdId = Request.Params["rIdAndProdId"];
                string[] rIdAndProdIdS = rIdAndProdId.Split(';');
                string backReason = Request.Params["backReason"];

                foreach (string item in rIdAndProdIdS)
                {
                    var rid = item.Split(',')[0];
                    var product_id = item.Split(',')[1];

                    ProdVdReqQuery prodQuery = new ProdVdReqQuery();
                    prodQuery.rid = int.Parse(rid);
                    prodQuery.product_id = int.Parse(product_id);
                    int totalCount = 0;
                    ProdVdReq prodRquery = _prodVdReq.QueryProdVdReqList(prodQuery, out totalCount).FirstOrDefault();

                    if (prodRquery != null)
                    {
                        //prodQuery.rid = int.Parse(rid);
                        //prodQuery.product_id = int.Parse(product_id);
                        prodRquery.req_status = 3;
                        prodRquery.reply_note = backReason;
                        prodRquery.reply_datetime = DateTime.Now;
                        prodRquery.user_id = int.Parse((System.Web.HttpContext.Current.Session["caller"] as Caller).user_id.ToString());
                        if (_prodVdReq.Update(prodRquery) < 0)
                        {
                            resultStr = "{success:false,msg:0}";//返回json數據
                        }
                    }
                    else
                    {
                        resultStr = "{success:false,msg:0}";//返回json數據
                    }
                }

            }
            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;
        }
        public HttpResponseBase ProdVdReqListQuery()
        {
            string json = string.Empty;
            try
            {
                ProdVdReqQuery query = new ProdVdReqQuery();
                #region 查询条件填充

                query.IsPage = true;
                query.Start = int.Parse(Request.Form["start"] ?? "0");
                if (!string.IsNullOrEmpty(Request.Form["limit"]))
                {
                    query.Limit = Convert.ToInt32(Request.Form["limit"]);
                }
                if (!string.IsNullOrEmpty(Request.Form["brand_id"]))
                {
                    query.brand_id = Convert.ToUInt32(Request.Form["brand_id"]);
                }
                if (!string.IsNullOrEmpty(Request.Form["product_id"]))
                {
                    query.product_id = int.Parse(Request.Form["product_id"]);
                }
                if (!string.IsNullOrEmpty(Request.Form["req_status"]))
                {
                    query.req_status = int.Parse(Request.Form["req_status"]);
                }
                if (!string.IsNullOrEmpty(Request.Form["time_start"]))
                {
                    query.time_start = Convert.ToDateTime(Convert.ToDateTime(Request.Form["time_start"]).ToString("yyyy/MM/dd HH:mm:ss"));
                }
                if (!string.IsNullOrEmpty(Request.Form["time_end"]))
                {
                    query.time_end = Convert.ToDateTime(Convert.ToDateTime(Request.Form["time_end"]).ToString("yyyy/MM/dd HH:mm:ss"));
                }
                if (!string.IsNullOrEmpty(Request.Form["req_type"]))
                {
                    query.req_type = int.Parse(Request.Form["req_type"]);
                }


                #endregion
                _prodVdReq = new ProdVdReqMgr(connectionString);
                int totalCount = 0;
                List<ProdVdReqQuery> pros = _prodVdReq.QueryProdVdReqList(query, out totalCount);
                IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
                //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式     
                timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
                json = "{succes:true,totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(pros, Formatting.Indented, timeConverter) + "}";
            }
            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 = "{succes:true,totalCount:0,data:[]}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }