public ContentResult GetRetreatgoodsGY(Lib.GridPager pager, string queryStr) { IQueryable <T_WDTGoods> queryData = db.T_WDTGoods.Where(a => a.goods_type == 1).AsQueryable(); if (!string.IsNullOrEmpty(queryStr)) { queryData = queryData.Where(a => a.goods_name != null && a.goods_name.Contains(queryStr) || a.goods_no != null && a.goods_no.Contains(queryStr)); } pager.totalRows = queryData.Count(); //分页 queryData = queryData.OrderBy(c => c.goods_no).Skip((pager.page - 1) * pager.rows).Take(pager.rows); List <T_WDTGoods> list = new List <T_WDTGoods>(); foreach (var item in queryData) { T_WDTGoods i = new T_WDTGoods(); i = item; list.Add(i); } string json = "{\"total\":" + pager.totalRows + ",\"rows\":" + JsonConvert.SerializeObject(list) + "}"; return(Content(json)); }
//产品禁用/启用 public JsonResult DisableEditSave(int ids, int type) { //string username = Server.UrlDecode(Request.Cookies["username"].Value); T_WDTGoods model = db.T_WDTGoods.SingleOrDefault(a => a.ID == ids);// int s = 0; if (type == 1)//禁用 { model.spec_aux_unit_name = "1"; db.Entry <T_WDTGoods>(model).State = System.Data.Entity.EntityState.Modified; } if (type == 2)//启用 { model.spec_aux_unit_name = null; db.Entry <T_WDTGoods>(model).State = System.Data.Entity.EntityState.Modified; } T_OperaterLog log = new T_OperaterLog() { Module = "启用/禁用", OperateContent = type + "产品" + model.goods_no + "1禁用2启用产品", Operater = Server.UrlDecode(Request.Cookies["Nickname"].Value), OperateTime = DateTime.Now, PID = ids }; db.T_OperaterLog.Add(log); s = db.SaveChanges(); if (s > 0) { return(Json(new { State = "Success" }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { State = "Faile" }, JsonRequestBehavior.AllowGet)); } }
public JsonResult UpToGY(string ids)//上传到旺店通 { using (TransactionScope sc = new TransactionScope()) { string shibai = "0"; try { var aa = ""; string[] Ids = ids.Split(','); for (int j = 0; j < Ids.Length; j++) { Dictionary <string, string> dic = new Dictionary <string, string>(); int id = Convert.ToInt32(Ids[j]); T_HtSuNing ordermodel = db.T_HtSuNing.SingleOrDefault(a => a.ID == id); if (ordermodel.Istijiao == 1) { return(Json(new { State = "Faile", Message = "" + ordermodel.OrderNumber + "已提交到旺店通,不能重复提交" }, JsonRequestBehavior.AllowGet)); } string ShopName = ""; ShopName = "3011"; string tid = ordermodel.OrderNumber; //int trade_status = 10; //int pay_status = 2; //int delivery_term = 1; DateTime trade_time = DateTime.Parse(ordermodel.CreateTime.ToString()); DateTime pay_time = DateTime.Parse(ordermodel.CreateTime.ToString()); string buyer_nick = ordermodel.CustomerName; string receiver_name = ordermodel.CustomerName; string receiver_province = ordermodel.Province; string receiver_city = ordermodel.City; string receiver_district = ordermodel.Area; string receiver_address = ordermodel.Address; string receiver_mobile = ordermodel.Telephone; // int logistics_type = -1; string seller_memo = ordermodel.CustomerRemarks; decimal paid = 0.00m; List <T_HtSuNingItem> orderItems = db.T_HtSuNingItem.Where(a => a.PorderID == tid).ToList(); string order_list = ""; for (int i = 0; i < orderItems.Count; i++) { decimal num = decimal.Parse(orderItems[i].num.ToString()); decimal UnitPrice = decimal.Parse(orderItems[i].UnitPrice.ToString()); paid += num * UnitPrice; string goods_no = orderItems[i].ProductCode; string spec_no = orderItems[i].ProductCode; // string Guid = System.Guid.NewGuid().ToString(); T_WDTGoods cofig = db.T_WDTGoods.SingleOrDefault(s => s.goods_no == goods_no); string goods_name = ""; if (cofig != null) { goods_name = cofig.goods_name; } string oid = Guid.NewGuid().ToString(); if (order_list == "") { order_list += "{" + "\"oid\": \"" + oid + "\"," + "\"num\": \"" + num + "\"," + "\"price\": \"" + UnitPrice + "\"," + "\"status\": \"40\"," + "\"refund_status\": \"0\"," + "\"adjust_amount\": \"0\"," + "\"discount\": \"0\"," + "\"share_discount\": \"0\"," + "\"goods_id\": \"" + goods_no + "\"," + "\"goods_no\": \"" + goods_no + "\"," + "\"spec_no\": \"" + goods_no + "\"," + "\"goods_name\": \"" + goods_name + "\"," + "\"cid\": \"\"" + "}"; } else { order_list += ",{" + "\"oid\": \"" + oid + "\"," + "\"num\": \"" + num + "\"," + "\"price\": \"" + UnitPrice + "\"," + "\"status\": \"40\"," + "\"refund_status\": \"0\"," + "\"adjust_amount\": \"0\"," + "\"discount\": \"0\"," + "\"share_discount\": \"0\"," + "\"goods_id\": \"" + goods_no + "\"," + "\"goods_no\": \"" + goods_no + "\"," + "\"spec_no\": \"" + goods_no + "\"," + "\"goods_name\": \"" + goods_name + "\"," + "\"cid\": \"\"" + "}"; } } //旺店通 dic.Remove("shop_no"); dic.Add("shop_no", ShopName); string cmd = "[{" + "\"tid\": \"" + tid + "\"," + "\"trade_status\": \"30\"," + "\"pay_status\": \"2\"," + "\"delivery_term\": \"1\"," + "\"trade_time\": \"" + trade_time + "\"," + "\"pay_time\": \"" + pay_time + "\"," + "\"buyer_nick\": \"" + buyer_nick + "\"," + "\"buyer_email\": \"\"," + "\"receiver_name\": \"" + receiver_name + "\"," + "\"receiver_province\": \"" + receiver_province + "\"," + "\"receiver_city\": \"" + receiver_city + "\"," + "\"receiver_district\": \"" + receiver_district + "\"," + "\"receiver_address\": \"" + receiver_address + "\"," + "\"receiver_mobile\": \"" + receiver_mobile + "\"," + "\"receiver_zip\": \"\"," + "\"logistics_type\": \"-1\"," + "\"buyer_message\": \"\"," + "\"seller_memo\": \"" + seller_memo + "\"," + "\"post_amount\": \"0\"," + "\"cod_amount\": \"0\"," + "\"ext_cod_fee\": \"0\"," + "\"paid\": \"" + paid + "\"," + "\"order_list\": [" + order_list + "]}]"; dic.Remove("trade_list"); dic.Remove("sid"); dic.Remove("appkey"); dic.Remove("timestamp"); dic.Add("trade_list", cmd); dic.Add("sid", "hhs2"); dic.Add("appkey", "hhs2-ot"); dic.Add("timestamp", GetTimeStamp()); aa = CreateParam(dic, true); string ret = Post("http://api.wangdian.cn/openapi2/trade_push.php", aa); JsonData jsonData = null; jsonData = JsonMapper.ToObject(ret); string sd = jsonData[0].ToString(); if (sd == "0") { int sdz = int.Parse(jsonData[2].ToString()); if (sdz > 0) { T_HtSuNing model = db.T_HtSuNing.Single(a => a.ID == id); model.Istijiao = 1; db.SaveChanges(); } else { shibai += tid + ","; } } else { shibai += tid + ","; } } sc.Complete(); if (shibai != "0") { return(Json(new { State = "Faile", Message = "" + shibai + "提交旺店通失败,请与技术人员联系" }, JsonRequestBehavior.AllowGet)); } return(Json(new { State = "Success" }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { State = "Faile", Message = ex.Message }, JsonRequestBehavior.AllowGet)); } } }
public JsonResult PrintReturn(string ISqualified) { string name = Server.UrlDecode(Request.Cookies["Nickname"].Value); using (TransactionScope sc = new TransactionScope()) { if (ISqualified == "合格") //合格数据 { T_ReturnPrint print = new T_ReturnPrint() { PostTime = DateTime.Now, PostUser = name, PrintNO = "POA" + DateTime.Now.Ticks, PrintType = "合格" }; string PrintNO = print.PrintNO; db.T_ReturnPrint.Add(print); var returntostorageDetails = db.ReturnPrintQualifiedData(name).ToList(); foreach (var item in returntostorageDetails) { string goods_no = item.item_code; T_ReturnPrintDetail detail = new T_ReturnPrintDetail() { PrintNO = print.PrintNO, ProductCode = goods_no, ProductName = item.item_name, Qty = item.qty, SpecName = "", UnitName = "" }; T_WDTGoods goods = db.T_WDTGoods.FirstOrDefault(a => a.goods_no == goods_no); if (goods != null) { detail.SpecName = goods.spec_name; detail.UnitName = goods.unit_name; } db.T_ReturnPrintDetail.Add(detail); } string sql = "update T_ReturnToStoragelet set PrintNO_qualified='" + print.PrintNO + "' where PrintNO_qualified is null and Pid in ( select ID from T_ReturnToStorage where SortingName='" + name + "') "; // db.T_ReturnToStoragelet.SqlQuery(sql); try { db.Database.ExecuteSqlCommand(sql); db.SaveChanges(); List <T_ReturnPrintDetail> printDetails = db.T_ReturnPrintDetail. Where(a => a.PrintNO == PrintNO).ToList(); sc.Complete(); return(Json(new { state = "Success", rows = printDetails, printInfo = print })); } catch (DbUpdateException e) { return(Json(new { state = "Fail", rows = "", printInfo = print })); } } else //不合格数据 { T_ReturnPrint print = new T_ReturnPrint() { PostTime = DateTime.Now, PostUser = name, PrintNO = "POB" + DateTime.Now.Ticks, PrintType = "不合格" }; string PrintNO = print.PrintNO; db.T_ReturnPrint.Add(print); var returntostorageDetails = db.ReturnPrintUnqualifiedData(name).ToList(); string sql = "update T_ReturnToStoragelet set PrintNO_unqualified='" + print.PrintNO + "' where PrintNO_unqualified is null Pid in ( select ID from T_ReturnToStorage where SortingName='" + name + "') "; // db.T_ReturnToStoragelet.SqlQuery(sql); db.Database.ExecuteSqlCommand(sql); foreach (var item in returntostorageDetails) { string goods_no = item.item_code; T_ReturnPrintDetail detail = new T_ReturnPrintDetail() { PrintNO = PrintNO, ProductCode = goods_no, ProductName = item.item_name, Qty = item.qty, SpecName = "", UnitName = "" }; T_WDTGoods goods = db.T_WDTGoods.FirstOrDefault(a => a.goods_no == goods_no); if (goods != null) { detail.SpecName = goods.spec_name; detail.UnitName = goods.unit_name; } db.T_ReturnPrintDetail.Add(detail); } db.SaveChanges(); List <T_ReturnPrintDetail> printDetails = db.T_ReturnPrintDetail. Where(a => a.PrintNO == PrintNO).ToList(); sc.Complete(); return(Json(new { state = "Success", rows = printDetails, printInfo = print })); } } }
public string UpToGY(int ID) { using (TransactionScope sc = new TransactionScope()) { string shibai = "0"; var aa = ""; try { Dictionary <string, string> dic = new Dictionary <string, string>(); T_WDTHandOrder ordermodel = db.T_WDTHandOrder.SingleOrDefault(a => a.ID == ID && a.Isdelete == 0); string tid = ordermodel.OrderID; //int trade_status = 10; //int pay_status = 2; //int delivery_term = 1; DateTime trade_time = DateTime.Parse(ordermodel.SingleShotTime.ToString()); DateTime pay_time = DateTime.Parse(ordermodel.SingleShotTime.ToString()); string buyer_nick = ordermodel.MemberName; string receiver_name = ordermodel.DeliveryName; string ShopName = ordermodel.shopName; string receiver_province = ordermodel.ProvinceAddress; string receiver_city = ordermodel.CityAddress; string receiver_district = ordermodel.AreaAddress; string receiver_address = ordermodel.address; string receiver_mobile = ordermodel.DeliveryNumber; // decimal post_amount = decimal.Parse(ordermodel.PostAmount.ToString()); // int logistics_type = -1; string seller_memo = ordermodel.Remarks; decimal paid = decimal.Parse(ordermodel.Cost.ToString()); List <T_WDTHandOrderDetail> orderItems = db.T_WDTHandOrderDetail.Where(a => a.PorderID == tid).ToList(); string order_list = ""; for (int i = 0; i < orderItems.Count; i++) { decimal num = decimal.Parse(orderItems[i].num.ToString()); decimal UnitPrice = decimal.Parse(orderItems[i].UnitPrice.ToString()); string goods_no = orderItems[i].ProductCode; string spec_no = orderItems[i].ProductCode; // string Guid = System.Guid.NewGuid().ToString(); T_WDTGoods cofig = db.T_WDTGoods.SingleOrDefault(s => s.goods_no == goods_no); string goods_name = ""; if (cofig != null) { goods_name = cofig.goods_name; } if (order_list == "") { order_list += "{" + "\"oid\": \"" + tid + "\"," + "\"num\": \"" + num + "\"," + "\"price\": \"" + UnitPrice + "\"," + "\"status\": \"40\"," + "\"refund_status\": \"0\"," + "\"adjust_amount\": \"0\"," + "\"discount\": \"0\"," + "\"share_discount\": \"0\"," + "\"goods_id\": \"" + goods_no + "\"," + "\"goods_no\": \"" + goods_no + "\"," + "\"spec_no\": \"" + goods_no + "\"," + "\"goods_name\": \"" + goods_name + "\"," + "\"cid\": \"\"" + "}"; } else { order_list += ",{" + "\"oid\": \"" + tid + "\"," + "\"num\": \"" + num + "\"," + "\"price\": \"" + UnitPrice + "\"," + "\"status\": \"40\"," + "\"refund_status\": \"0\"," + "\"adjust_amount\": \"0\"," + "\"discount\": \"0\"," + "\"share_discount\": \"0\"," + "\"goods_id\": \"" + goods_no + "\"," + "\"goods_no\": \"" + goods_no + "\"," + "\"spec_no\": \"" + goods_no + "\"," + "\"goods_name\": \"" + goods_name + "\"," + "\"cid\": \"\"" + "}"; } } //旺店通 T_WDTshop queryData = db.T_WDTshop.SingleOrDefault(a => a.shop_name == ShopName); if (queryData != null) { string Code = queryData.shop_no; dic.Add("shop_no", Code); } else { return("0"); } string cmd = "[{" + "\"tid\": \"" + tid + "\"," + "\"trade_status\": \"30\"," + "\"pay_status\": \"2\"," + "\"delivery_term\": \"1\"," + "\"trade_time\": \"" + trade_time + "\"," + "\"pay_time\": \"" + pay_time + "\"," + "\"buyer_nick\": \"" + buyer_nick + "\"," + "\"buyer_email\": \"\"," + "\"receiver_name\": \"" + receiver_name + "\"," + "\"receiver_province\": \"" + receiver_province + "\"," + "\"receiver_city\": \"" + receiver_city + "\"," + "\"receiver_district\": \"" + receiver_district + "\"," + "\"receiver_address\": \"" + receiver_address + "\"," + "\"receiver_mobile\": \"" + receiver_mobile + "\"," + "\"receiver_zip\": \"\"," + "\"logistics_type\": \"8\"," + "\"buyer_message\": \"\"," + "\"seller_memo\": \"" + seller_memo + "\"," + "\"post_amount\": \"0\"," + "\"cod_amount\": \"0\"," + "\"ext_cod_fee\": \"0\"," + "\"paid\": \"" + paid + "\"," + "\"order_list\": [" + order_list + "]}]"; dic.Remove("trade_list"); dic.Remove("sid"); dic.Remove("appkey"); dic.Remove("timestamp"); dic.Add("trade_list", cmd); dic.Add("sid", "hhs2"); dic.Add("appkey", "hhs2-ot"); dic.Add("timestamp", GetTimeStamp()); aa = CreateParam(dic, true); string ret = Post("http://api.wangdian.cn/openapi2/trade_push.php", aa); JsonData jsonData = null; jsonData = JsonMapper.ToObject(ret); string sd = jsonData[0].ToString(); if (sd == "0") { int sdz = int.Parse(jsonData[2].ToString()); sc.Complete(); if (sdz > 0) { return("1"); } } return("0"); } catch (Exception ex) { return("0"); } } }
//单个产品同步 public JsonResult WDTGoodsTbS(string query) { if (query == "" || query == null) { return(Json(new { State = "Faile" }, JsonRequestBehavior.AllowGet)); } App_Code.GY gy = new App_Code.GY(); JsonData jsonData = null; //string ret = gy.httpGetStr("http://192.168.8.89:3980/material/GetMaterialData?code=" + query.Trim()); try { string ret = gy.httpGetStr("http://222.240.26.98:3980/material/GetMaterialData?code=" + query.Trim()); string ssx = Regex.Unescape(ret); jsonData = JsonMapper.ToObject(ret); } catch (WebException ex) { return(Json(new { State = "Faile", Message = ex.Message }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { State = "Faile", Message = ex.Message }, JsonRequestBehavior.AllowGet)); } //if (jsonData[0][0]==null) //{ // return Json(new { State = "Faile" }, JsonRequestBehavior.AllowGet); //} if (jsonData != null && jsonData.Count > 0) { for (int i = 0; i < jsonData.Count; i++) { string SPEC = ""; if (jsonData[i]["SPEC"] != null) { SPEC = jsonData[i]["SPEC"].ToString(); } string NAME = jsonData[i]["NAME"].ToString(); string UNIT = jsonData[i]["UNIT"].ToString(); string BARCODE = ""; if (jsonData[i]["BARCODE"] != null) { BARCODE = jsonData[i]["BARCODE"].ToString(); } string code = jsonData[i]["CODE"].ToString();; T_WDTGoods list = db.T_WDTGoods.FirstOrDefault(s => s.goods_no == code); if (list == null) { T_WDTGoods WDTGoods = new T_WDTGoods(); WDTGoods.goods_no = code; WDTGoods.goods_name = NAME; WDTGoods.short_name = NAME; WDTGoods.goods_type = 1; WDTGoods.unit_name = UNIT; WDTGoods.spec_count = 1; WDTGoods.spec_code = code; WDTGoods.spec_no = code; WDTGoods.barcode = BARCODE; WDTGoods.spec_name = SPEC; WDTGoods.lowest_price = 0; WDTGoods.wholesale_price = 0; WDTGoods.retail_price = 0; db.T_WDTGoods.Add(WDTGoods); db.SaveChanges(); } else { list.unit_name = UNIT; list.spec_name = SPEC; db.Entry <T_WDTGoods>(list).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } } return(Json(new { State = "Success" }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { State = "Faile", Message = "NC不存在" + query }, JsonRequestBehavior.AllowGet)); } }
public JsonResult WDTGoodsTb() { DataTable dt = new DataTable(); using (SqlConnection conn = new SqlConnection()) { string sql = "select * from dbo.T_Bas_Goods "; conn.ConnectionString = "Data Source=120.24.176.207;Initial Catalog=ebms3;User ID=erp_ggpt;Password=erp_ggpt123"; conn.Open(); DataSet ds = new DataSet(); SqlDataAdapter da = new SqlDataAdapter(sql, conn); da.Fill(ds); dt = ds.Tables[0]; List <T_WDTGoods> list = db.T_WDTGoods.ToList(); //foreach (var deleteItem in list) //{ // db.T_WDTGoods.Remove(deleteItem); //} // db.SaveChanges(); for (int i = 0; i < dt.Rows.Count; i++) { string code = dt.Rows[i]["Code"].ToString(); T_WDTGoods lisst = list.FirstOrDefault(s => s.goods_no == code); if (lisst == null) { T_WDTGoods WDTGoods = new T_WDTGoods(); WDTGoods.goods_no = dt.Rows[i]["Code"].ToString(); WDTGoods.goods_name = dt.Rows[i]["Name"].ToString(); WDTGoods.short_name = dt.Rows[i]["Name"].ToString(); WDTGoods.goods_type = 1; WDTGoods.spec_count = 1; WDTGoods.spec_code = dt.Rows[i]["Code"].ToString(); WDTGoods.spec_no = dt.Rows[i]["Code"].ToString(); WDTGoods.barcode = dt.Rows[i]["BarCode"].ToString(); WDTGoods.spec_name = dt.Rows[i]["Spec"].ToString(); WDTGoods.lowest_price = decimal.Parse(dt.Rows[i]["Price"].ToString()); WDTGoods.wholesale_price = decimal.Parse(dt.Rows[i]["Price"].ToString()); WDTGoods.retail_price = decimal.Parse(dt.Rows[i]["Price"].ToString()); db.T_WDTGoods.Add(WDTGoods); db.SaveChanges(); } } } // App_Code.GY gy = new App_Code.GY(); // dic.Clear(); //// dic.Add("spec_no", "80005200026840"); // dic.Add("sid", "hhs2"); // dic.Add("appkey", "hhs2-ot"); // dic.Add("timestamp", GetTimeStamp()); // var cmd = CreateParam(dic, true); // string ret = gy.DoPostnew("http://121.41.177.115/openapi2/goods_query.php", cmd, Encoding.UTF8); // string ssx = Regex.Unescape(ret); // JsonData jsonData = null; // jsonData = JsonMapper.ToObject(ret); //string iscode = jsonData["code"].ToString(); //if (iscode != "0") //{ // return Json("", JsonRequestBehavior.AllowGet); //} //JsonData jsontrades = jsonData["shoplist"]; //List<T_WDTshop> delMod = db.T_WDTshop.AsQueryable().ToList(); //foreach (var item in delMod) //{ // db.T_WDTshop.Remove(item); //} //db.SaveChanges(); //int s = 0; //for (int i = 0; i < jsontrades.Count; i++) //{ // T_WDTshop WDTshop = new T_WDTshop(); // WDTshop.platform_id = jsontrades[i]["platform_id"].ToString(); // WDTshop.sub_platform_id = jsontrades[i]["sub_platform_id"].ToString(); // WDTshop.shop_id = jsontrades[i]["shop_id"].ToString(); // WDTshop.shop_no = jsontrades[i]["shop_no"].ToString(); // WDTshop.shop_name = jsontrades[i]["shop_name"].ToString(); // WDTshop.account_id = jsontrades[i]["account_id"].ToString(); // WDTshop.account_nick = jsontrades[i]["account_nick"].ToString(); // WDTshop.province = jsontrades[i]["province"].ToString(); // WDTshop.city = jsontrades[i]["city"].ToString(); // WDTshop.district = jsontrades[i]["district"].ToString(); // WDTshop.address = jsontrades[i]["address"].ToString(); // WDTshop.contact = jsontrades[i]["contact"].ToString(); // WDTshop.zip = jsontrades[i]["zip"].ToString(); // WDTshop.mobile = jsontrades[i]["mobile"].ToString(); // WDTshop.telno = jsontrades[i]["telno"].ToString(); // db.T_WDTshop.Add(WDTshop); // s += db.SaveChanges(); //} //if (s > 0) //{ // return Json(new { State = "Success" }, JsonRequestBehavior.AllowGet); //} return(Json(new { State = "Faile" }, JsonRequestBehavior.AllowGet)); }