public string GetOrderByShopBYcode(string platform_code) { GY gy = new GY(); string cmd = "{" + "\"appkey\":\"171736\"," + "\"method\":\"gy.erp.trade.get\"," + "\"page_no\":1," + "\"page_size\":10," + "\"platform_code\":\"" + platform_code + "\"," + "\"sessionkey\":\"f5885504d9c84d1d8146200a4841f4b7\"" + "}"; string sign = gy.Sign(cmd); cmd = cmd.Replace("}", ",\"sign\":\"" + sign + "\"}"); string ret = gy.DoPost("http://api.guanyierp.com/rest/erp_open", cmd); JsonData jsonData = null; jsonData = JsonMapper.ToObject(ret); Thread.Sleep(1600); if (jsonData.Count == 6 || jsonData["orders"].Count == 0) { cmd = "{" + "\"appkey\":\"171736\"," + "\"method\":\"gy.erp.trade.history.get\"," + "\"page_no\":1," + "\"page_size\":10," + "\"platform_code\":\"" + platform_code + "\"," + "\"sessionkey\":\"f5885504d9c84d1d8146200a4841f4b7\"" + "}"; sign = gy.Sign(cmd); cmd = cmd.Replace("}", ",\"sign\":\"" + sign + "\"}"); ret = gy.DoPost("http://api.guanyierp.com/rest/erp_open", cmd); } return(ret); }
public JsonResult ViewReceiptAddSave(T_Receipt model, string jsonStr) { using (TransactionScope sc = new TransactionScope()) { try { GY gy = new GY(); string cmd = ""; cmd = "{" + "\"appkey\":\"171736\"," + "\"method\":\"gy.erp.trade.get\"," + "\"page_no\":1," + "\"page_size\":10," + "\"platform_code\":\"" + model.OrderCode + "\"," + "\"sessionkey\":\"f5885504d9c84d1d8146200a4841f4b7\"" + "}"; string sign = gy.Sign(cmd); cmd = cmd.Replace("}", ",\"sign\":\"" + sign + "\"}"); string ret = gy.DoPost("http://api.guanyierp.com/rest/erp_open", cmd); JsonData jsonData = null; jsonData = JsonMapper.ToObject(ret); if (jsonData.Count == 6 || jsonData["orders"].Count == 0) { cmd = "{" + "\"appkey\":\"171736\"," + "\"method\":\"gy.erp.trade.history.get\"," + "\"page_no\":1," + "\"page_size\":10," + "\"platform_code\":\"" + model.OrderCode + "\"," + "\"sessionkey\":\"f5885504d9c84d1d8146200a4841f4b7\"" + "}"; sign = gy.Sign(cmd); cmd = cmd.Replace("}", ",\"sign\":\"" + sign + "\"}"); ret = gy.DoPost("http://api.guanyierp.com/rest/erp_open", cmd); jsonData = null; jsonData = JsonMapper.ToObject(ret); if (jsonData.Count == 6 || jsonData["orders"].Count == 0) { return(Json(new { State = "Faile", Message = "订单号不存在" })); } } JsonData jsonOrders = jsonData["orders"][0]; List <T_ReceiptDetails> details = Com.Deserialize <T_ReceiptDetails>(jsonStr); //T_OrderList order = db.T_OrderList.Find(model.OrderId); string code = "SKSJ"; string date = DateTime.Now.ToString("yyyyMMdd"); List <T_Receipt> list = db.T_Receipt.Where(s => s.Code.Contains(date)).OrderByDescending(s => s.ID).ToList(); if (list.Count == 0) { code += date + "0001"; } else { string old = list[0].Code.Substring(12); int newCode = int.Parse(old) + 1; code += date + newCode.ToString().PadLeft(4, '0'); } model.Code = code; model.Date = DateTime.Now; model.IsDelete = 0; model.ShopDate = DateTime.Parse(jsonOrders["createtime"].ToString()); model.PostUser = UserModel.Nickname; model.PrintCount = 0; db.T_Receipt.Add(model); db.SaveChanges(); if (details != null) { foreach (var item in details) { item.ReceiptOrderID = model.ID; db.T_ReceiptDetails.Add(item); } db.SaveChanges(); } sc.Complete(); return(Json(new { State = "Success" }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { State = "Faile", Message = ex.Message }, JsonRequestBehavior.AllowGet)); } } }
public JsonResult Approve(int id) { T_ManualOrder order = new T_ManualOrder(); order = db.T_ManualOrder.Find(id); if (order != null) { try { using (TransactionScope sc = new TransactionScope()) { order.orderstatus = 1; db.SaveChanges(); //详情 IQueryable <T_ManualorderDetail> details = null; details = db.T_ManualorderDetail.Where(a => a.OrderCode.Equals(order.platform_code)); //构造商品明细 string detail = ""; foreach (var item in details) { detail += "{\"qty\":" + item.qty + ",\"price\":\"" + item.price + "\",\"note\":\"\",\"refund\":0,\"item_code\":\"" + System.Web.HttpContext.Current.Server.UrlEncode(item.item_code) + "\"}"; } //构造付款信息 必须要付款信息 否则全让利了 应收成0 string payment = ""; //discount_fee 让利直接给出 无效 此字段改成实收金额 payment += "{\"pay_type_code\":\"wangyin\",\"payment\":\"" + order.payment + "\"}"; GY gy = new GY(); string cmd = ""; cmd = "{" + "\"appkey\":\"171736\"," + "\"method\":\"gy.erp.trade.add\"," + "\"sessionkey\":\"f5885504d9c84d1d8146200a4841f4b7\"," + "\"order_type_code\":\"" + order.order_type_code + "\"," + "\"platform_code\":\"" + order.platform_code + "\"," + "\"shop_code\":\"" + order.shop_code + "\"," + "\"express_code\":\"" + order.express_code + "\"," + "\"receiver_province\":\"" + order.receiver_province + "\"," + "\"receiver_city\":\"" + order.receiver_city + "\"," + "\"receiver_district\":\"" + order.receiver_district + "\"," + "\"warehouse_code\":\"" + order.warehouse_code + "\"," + "\"vip_code\":\"" + order.vip_code + "\"," + "\"vip_name\":\"" + order.vip_name + "\"," + "\"receiver_name\":\"" + order.receiver_name + "\"," + "\"receiver_address\":\"" + order.receiver_address + "\"," + "\"receiver_mobile\":\"" + order.receiver_mobile + "\"," + "\"receiver_phone\":\"" + order.receiver_phone + "\"," + "\"deal_datetime\":\"" + order.deal_datetime.ToString() + "\"," + "\"pay_datetime\":\"" + order.deal_datetime.ToString() + "\"," + "\"buyer_memo\":\"" + order.buyer_memo + "\"," + "\"seller_memo\":\"" + order.seller_memo + "\"," + "\"business_man_code\":\"" + order.business_man_code + "\"," + "\"payments\":[" + payment + "]," + //payment 支付金额 设置了也无效 应该是根据明细里面的单价 自动算出来的 "\"details\":[" + detail + "]" + "}"; string sign = gy.Sign(cmd); string comcode = "{" + "\"appkey\":\"171736\"," + "\"method\":\"gy.erp.trade.add\"," + "\"sessionkey\":\"f5885504d9c84d1d8146200a4841f4b7\"," + "\"order_type_code\":\"" + order.order_type_code + "\"," + "\"platform_code\":\"" + order.platform_code + "\"," + "\"shop_code\":\"" + order.shop_code + "\"," + "\"express_code\":\"" + order.express_code + "\"," + "\"receiver_province\":\"" + order.receiver_province + "\"," + "\"receiver_city\":\"" + order.receiver_city + "\"," + "\"receiver_district\":\"" + order.receiver_district + "\"," + "\"warehouse_code\":\"" + order.warehouse_code + "\"," + "\"vip_code\":\"" + order.vip_code + "\"," + "\"vip_name\":\"" + order.vip_name + "\"," + "\"receiver_name\":\"" + order.receiver_name + "\"," + "\"receiver_address\":\"" + order.receiver_address + "\"," + "\"receiver_mobile\":\"" + order.receiver_mobile + "\"," + "\"receiver_phone\":\"" + order.receiver_phone + "\"," + "\"deal_datetime\":\"" + order.deal_datetime.ToString() + "\"," + "\"pay_datetime\":\"" + order.deal_datetime.ToString() + "\"," + "\"sign\":\"" + sign + "\"," + "\"buyer_memo\":\"" + order.buyer_memo + "\"," + "\"seller_memo\":\"" + order.seller_memo + "\"," + "\"business_man_code\":\"" + order.business_man_code + "\"," + "\"payments\":[" + payment + "]," + "\"details\":[" + detail + "]" + "}"; string ret = gy.DoPost("http://api.guanyierp.com/rest/erp_open", comcode); JsonData jsonData = null; jsonData = JsonMapper.ToObject(ret); string result = jsonData[0].ToString(); if (result == "True") { sc.Complete(); return(Json(new { State = "Success" }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { State = "Faile", Message = "数据有误,请联系管理员" }, JsonRequestBehavior.AllowGet)); } } } catch (Exception ex) { return(Json(new { State = "Faile", Message = ex.Message }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { State = "Faile", Message = "数据出错,请联系技术人员" }, JsonRequestBehavior.AllowGet)); } }
/// <summary> /// 查询管易订单 /// </summary> /// <param name="code"></param> /// <returns></returns> public JsonResult GetReceiptByGy(string code) { GY gy = new GY(); string cmd = ""; cmd = "{" + "\"appkey\":\"171736\"," + "\"method\":\"gy.erp.trade.get\"," + "\"page_no\":1," + "\"page_size\":10," + "\"platform_code\":\"" + code + "\"," + "\"sessionkey\":\"f5885504d9c84d1d8146200a4841f4b7\"" + "}"; string sign = gy.Sign(cmd); cmd = cmd.Replace("}", ",\"sign\":\"" + sign + "\"}"); string ret = gy.DoPost("http://api.guanyierp.com/rest/erp_open", cmd); JsonData jsonData = null; jsonData = JsonMapper.ToObject(ret); if (jsonData.Count == 6 || jsonData["orders"].Count == 0) { cmd = "{" + "\"appkey\":\"171736\"," + "\"method\":\"gy.erp.trade.history.get\"," + "\"page_no\":1," + "\"page_size\":10," + "\"platform_code\":\"" + code + "\"," + "\"sessionkey\":\"f5885504d9c84d1d8146200a4841f4b7\"" + "}"; sign = gy.Sign(cmd); cmd = cmd.Replace("}", ",\"sign\":\"" + sign + "\"}"); ret = gy.DoPost("http://api.guanyierp.com/rest/erp_open", cmd); jsonData = null; jsonData = JsonMapper.ToObject(ret); if (jsonData.Count == 6 || jsonData["orders"].Count == 0) { return(Json(new { State = "Faile", Message = "订单号不存在" })); } } JsonData jsonOrders = jsonData["orders"][0]; //订单信息 string platform_code = isNULL(jsonOrders["platform_code"]).ToString(); //店铺名称 string shop_name = isNULL(jsonOrders["shop_name"]).ToString(); //旺旺帐号 string vip_name = isNULL(jsonOrders["vip_name"]).ToString(); string receiver_name = isNULL(jsonOrders["receiver_name"]).ToString(); string payment = isNULL(jsonOrders["payment"]).ToString(); T_Receipt model = new T_Receipt(); model.OrderCode = code; model.Receivings = receiver_name; model.Money = decimal.Parse(payment); model.Vip_Name = receiver_name; model.StorName = shop_name; List <T_ReceiptDetails> DetailsList = new List <T_ReceiptDetails>(); JsonData jsonDetails = jsonOrders["details"]; for (int i = 0; i < jsonDetails.Count; i++) { T_ReceiptDetails DetailsModel = new T_ReceiptDetails(); DetailsModel.ProductName = jsonDetails[i]["item_name"] == null ? "" : jsonDetails[i]["item_name"].ToString(); DetailsModel.Unit = jsonDetails[i]["item_simple_name"] == null ? "" : jsonDetails[i]["item_simple_name"].ToString(); DetailsModel.Qty = jsonDetails[i]["qty"] == null ? 0 : int.Parse(jsonDetails[i]["qty"].ToString()); DetailsList.Add(DetailsModel); } var json = new { rows = (from r in DetailsList select new T_ReceiptDetails { ProductName = r.ProductName, Unit = r.Unit, Qty = r.Qty }).ToArray() }; return(Json(new { State = "Success", ModelList = model, Json = json }, JsonRequestBehavior.AllowGet)); }
public JsonResult Check(string UserName, int approveID, int status, string memo) { using (TransactionScope sc = new TransactionScope()) { try { int TotalStep = db.T_ReissueConfig.ToList().Count; T_ReissueApprove approve = db.T_ReissueApprove.Find(approveID); string name = approve.ApproveName; T_Reissue model = db.T_Reissue.Find(approve.Pid); approve.ApproveName = UserName; approve.ApproveStatus = status; approve.ApproveTime = DateTime.Now; approve.Memo = memo; model.Status = status; db.SaveChanges(); if (status == 2)//不同意 { model.Step = model.Step + 1; db.SaveChanges(); } else//同意 { int type = db.T_ReissueReson.SingleOrDefault(s => s.Reson.Equals(model.ReissueReson)).Type; int LastStep = db.T_ReissueConfig.OrderByDescending(s => s.Step).FirstOrDefault(s => s.Reson == type).Step; if (LastStep > model.Step)//判断是否存在下一级 { //获得下一级审核部门 string nextapproveType = db.T_ReissueConfig.OrderBy(s => s.Step).FirstOrDefault(s => s.Reson == type && s.Step > model.Step).ApproveType; T_ReissueApprove newApprove = new T_ReissueApprove(); newApprove.ApproveStatus = -1; newApprove.ApproveName = nextapproveType; newApprove.ApproveTime = null; newApprove.Pid = approve.Pid; db.T_ReissueApprove.Add(newApprove); db.SaveChanges(); model.Status = 0; model.Step = model.Step + 1; db.SaveChanges(); } if (name.Equals("售后主管") || name.Equals("呼吸机主管"))//售后主管审核后直接加入补发货 { //T_OrderList order = db.T_OrderList.Find(model.OrderId); //List<T_Reissue> reissue = db.T_Reissue.Where(s => s.OrderCode.Equals(model.OrderCode) && s.IsDelete == 0).ToList(); ////判断是否为第一次补发 //if (reissue.Count() == 1) //{ // order.ReissueStatus = 2; //} //List<T_ReissueDetail> reiDetails = db.T_ReissueDetail.Where(s => s.ReissueId == model.ID).ToList(); //foreach (var item in reiDetails) //{ // T_OrderDetail Orderdetail = db.T_OrderDetail.FirstOrDefault(s => s.oid.Equals(order.code) && s.item_code.Equals(item.ProductCode)); // if (Orderdetail != null) // { // Orderdetail.ReissueStatus = 1; // Orderdetail.ReissueQty += item.Num; // } //} db.SaveChanges(); #region 加入快递赔付 if (model.ReissueReson.Equals("快递破损")) { GY gy = new GY(); string cmd = ""; cmd = "{" + "\"appkey\":\"171736\"," + "\"method\":\"gy.erp.trade.get\"," + "\"page_no\":1," + "\"page_size\":10," + "\"platform_code\":\"" + model.OrderCode + "\"," + "\"sessionkey\":\"f5885504d9c84d1d8146200a4841f4b7\"" + "}"; string sign = gy.Sign(cmd); cmd = cmd.Replace("}", ",\"sign\":\"" + sign + "\"}"); string ret = gy.DoPost("http://api.guanyierp.com/rest/erp_open", cmd); JsonData jsonData = null; jsonData = JsonMapper.ToObject(ret); if (jsonData.Count == 6 || jsonData["orders"].Count == 0) { cmd = "{" + "\"appkey\":\"171736\"," + "\"method\":\"gy.erp.trade.history.get\"," + "\"page_no\":1," + "\"page_size\":10," + "\"platform_code\":\"" + model.OrderCode + "\"," + "\"sessionkey\":\"f5885504d9c84d1d8146200a4841f4b7\"" + "}"; sign = gy.Sign(cmd); cmd = cmd.Replace("}", ",\"sign\":\"" + sign + "\"}"); ret = gy.DoPost("http://api.guanyierp.com/rest/erp_open", cmd); jsonData = null; jsonData = JsonMapper.ToObject(ret); if (jsonData.Count == 6 || jsonData["orders"].Count == 0) { return(Json(new { State = "Faile", Message = "订单号不存在" })); } } JsonData jsonOrders = jsonData["orders"][0]; var deliver = jsonOrders["deliverys"][0]; //快递单号 string mail_no = isNULL(deliver["mail_no"]).ToString(); //订单金额 string amount = isNULL(jsonOrders["amount"]).ToString(); //快递名称 string express_name = isNULL(jsonOrders["express_name"]).ToString(); T_ExpressIndemnity Inde = new T_ExpressIndemnity { PostUserName = model.PostUser, Date = DateTime.Now, OrderNum = model.OrderCode, wangwang = model.VipCode, ShopName = model.StoreName, RetreatExpressNum = mail_no, State = "0", OrderMoney = Convert.ToDouble(amount), Type = "破损", Second = "0", CurrentApproveName = "快递组", IsDelete = 0, ExpressName = express_name, IndemnityMoney = 0 }; db.T_ExpressIndemnity.Add(Inde); db.SaveChanges(); List <T_ReissuePic> picList = db.T_ReissuePic.Where(s => s.ReissueId == model.ID).ToList(); foreach (var item in picList) { T_ExpressIndemnityPic expressPic = new T_ExpressIndemnityPic { EID = Inde.ID, PicURL = item.Url }; db.T_ExpressIndemnityPic.Add(expressPic); } db.SaveChanges(); } else if (model.ReissueReson.Equals("丢件")) { GY gy = new GY(); string cmd = ""; cmd = "{" + "\"appkey\":\"171736\"," + "\"method\":\"gy.erp.trade.get\"," + "\"page_no\":1," + "\"page_size\":10," + "\"platform_code\":\"" + model.OrderCode + "\"," + "\"sessionkey\":\"f5885504d9c84d1d8146200a4841f4b7\"" + "}"; string sign = gy.Sign(cmd); cmd = cmd.Replace("}", ",\"sign\":\"" + sign + "\"}"); string ret = gy.DoPost("http://api.guanyierp.com/rest/erp_open", cmd); JsonData jsonData = null; jsonData = JsonMapper.ToObject(ret); if (jsonData.Count == 6 || jsonData["orders"].Count == 0) { cmd = "{" + "\"appkey\":\"171736\"," + "\"method\":\"gy.erp.trade.history.get\"," + "\"page_no\":1," + "\"page_size\":10," + "\"platform_code\":\"" + model.OrderCode + "\"," + "\"sessionkey\":\"f5885504d9c84d1d8146200a4841f4b7\"" + "}"; sign = gy.Sign(cmd); cmd = cmd.Replace("}", ",\"sign\":\"" + sign + "\"}"); ret = gy.DoPost("http://api.guanyierp.com/rest/erp_open", cmd); jsonData = null; jsonData = JsonMapper.ToObject(ret); if (jsonData.Count == 6 || jsonData["orders"].Count == 0) { return(Json(new { State = "Faile", Message = "订单号不存在" })); } } JsonData jsonOrders = jsonData["orders"][0]; var deliver = jsonOrders["deliverys"][0]; //快递单号 string mail_no = isNULL(deliver["mail_no"]).ToString(); //订单金额 string amount = isNULL(jsonOrders["amount"]).ToString(); //快递名称 string express_name = isNULL(jsonOrders["express_name"]).ToString(); T_ExpressIndemnity Inde = new T_ExpressIndemnity { PostUserName = model.PostUser, Date = DateTime.Now, OrderNum = model.OrderCode, wangwang = model.VipCode, ShopName = model.StoreName, RetreatExpressNum = mail_no, State = "0", OrderMoney = Convert.ToDouble(amount), Type = "丢件", Second = "0", CurrentApproveName = "快递组", IsDelete = 0, ExpressName = express_name, IndemnityMoney = 0 }; db.T_ExpressIndemnity.Add(Inde); db.SaveChanges(); } #endregion if (PostGy(model) != "True") { return(Json(new { State = "Faile", Message = "上传管易错误,请联系管理员" }, JsonRequestBehavior.AllowGet)); } } } db.SaveChanges(); List <T_ModularNotaudited> ModularNotaudited = db.T_ModularNotaudited.Where(a => a.ModularName == "补发货未审核").ToList(); if (ModularNotaudited.Count > 0) { foreach (var item in ModularNotaudited) { db.T_ModularNotaudited.Remove(item); } db.SaveChanges(); } string RetreatAppRoveSql = "select isnull(ApproveUser,ApproveName) as PendingAuditName,COUNT(*) as NotauditedNumber from T_ReissueApprove where Pid in ( select ID from T_Reissue where IsDelete=0 ) and ApproveStatus=-1 and ApproveTime is null GROUP BY ApproveName,ApproveUser "; List <Modular> RetreatAppRoveQuery = db.Database.SqlQuery <Modular>(RetreatAppRoveSql).ToList(); string Nickname = Server.UrlDecode(Request.Cookies["Nickname"].Value); for (int e = 0; e < RetreatAppRoveQuery.Count; e++) { string PendingAuditName = RetreatAppRoveQuery[e].PendingAuditName; T_ModularNotaudited NotauditedModel = db.T_ModularNotaudited.SingleOrDefault(a => a.ModularName == "补发货未审核" && a.PendingAuditName == PendingAuditName); if (NotauditedModel != null) { NotauditedModel.NotauditedNumber = RetreatAppRoveQuery[e].NotauditedNumber; db.Entry <T_ModularNotaudited>(NotauditedModel).State = System.Data.EntityState.Modified; } else { T_ModularNotaudited ModularNotauditedModel = new T_ModularNotaudited(); ModularNotauditedModel.ModularName = "补发货未审核"; ModularNotauditedModel.NotauditedNumber = RetreatAppRoveQuery[e].NotauditedNumber; ModularNotauditedModel.PendingAuditName = RetreatAppRoveQuery[e].PendingAuditName; ModularNotauditedModel.ToupdateDate = DateTime.Now; ModularNotauditedModel.ToupdateName = Nickname; db.T_ModularNotaudited.Add(ModularNotauditedModel); } db.SaveChanges(); } sc.Complete(); return(Json(new { State = "Success" }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { State = "Faile", Message = ex.Message }, JsonRequestBehavior.AllowGet)); } } }
/// <summary> /// 提交管易 /// </summary> /// <returns></returns> public string PostGy(T_Reissue model) { string shangp = ""; List <T_ReissueDetail> commodel = db.T_ReissueDetail.Where(a => a.ReissueId == model.ID).ToList(); for (int i = 0; i < commodel.Count; i++) { if (i == commodel.Count - 1) { shangp += "{\"qty\":" + commodel[i].Num + ",\"price\":0,\"note\":\"\",\"refund\":0,\"item_code\":\"" + commodel[i].ProductCode + "\"}"; } else { shangp += "{\"qty\":" + commodel[i].Num + ",\"price\":0,\"note\":\"\",\"refund\":0,\"item_code\":\"" + commodel[i].ProductCode + "\"},"; } } string datetime = DateTime.Parse(model.SingleTime.ToString()).ToString("yyyy-MM-dd hh:mm:ss"); string sellerremarks = ""; if (!string.IsNullOrWhiteSpace(model.SalesRemark)) { sellerremarks = Regex.Replace(model.SalesRemark.ToUpper().Replace((char)32, ' ').Replace((char)13, ' ').Replace((char)10, ' '), "[ \\[ \\] \\^ \t \\-×――(^)$%~!@#$…&%¥—+=<>《》!!???::•`·、。,;;\"‘’“”-]", "☆").Replace("☆", "").Replace(" ", ""); } else { sellerremarks = ""; } string BuyersRemarks = ""; if (!string.IsNullOrWhiteSpace(model.BuyRemark)) { BuyersRemarks = Regex.Replace(model.BuyRemark.ToUpper().Replace((char)32, ' ').Replace((char)13, ' ').Replace((char)10, ' '), "[ \\[ \\] \\^ \t \\-×――(^)$%~!@#$…&%¥—+=<>《》!!???::•`·、。,;;\"‘’“”-]", "☆").Replace("☆", "").Replace(" ", ""); } else { BuyersRemarks = ""; } string[] address = model.AddressMessage.Split('-'); string receiver_province = ""; string receiver_city = ""; string receiver_district = ""; if (address.Length >= 1) { receiver_province = address[0]; } if (address.Length >= 2) { receiver_city = address[1]; } if (address.Length >= 3) { receiver_district = address[2]; } DateTime dtshottime = DateTime.Now; DateTime shoptime = dtshottime.AddDays(-3); List <T_Reissue> ReissOrederModelList = db.T_Reissue.Where(a => a.OrderCode == model.OrderCode && a.CreatDate >= shoptime).ToList(); string sellerRemarksList = ""; if (ReissOrederModelList.Count >= 2) { sellerRemarksList = "三天内多次补发换货," + sellerremarks + "制单人:" + model.PostUser; } else { sellerRemarksList = sellerremarks + "制单人:" + model.PostUser; } GY gy = new GY(); string cmd = ""; cmd = "{" + "\"appkey\":\"171736\"," + "\"method\":\"gy.erp.trade.add\"," + "\"sessionkey\":\"f5885504d9c84d1d8146200a4841f4b7\"," + "\"platform_code\":\"" + model.NewOrderCode + "\"," + "\"order_type_code\":\"" + model.OrderType + "\"," + "\"shop_code\":\"" + model.StoreCode + "\"," + "\"express_code\":\"" + model.ExpressName + "\"," + "\"receiver_province\":\"" + receiver_province + "\"," + "\"receiver_city\":\"" + receiver_city + "\"," + "\"receiver_district\":\"" + receiver_district + "\"," + "\"warehouse_code\":\"" + model.WarhouseName + "\"," + "\"vip_code\":\"" + model.VipCode + "\"," + "\"vip_name\":\"" + model.VipName + "\"," + "\"receiver_name\":\"" + model.ReceivingName + "\"," + "\"receiver_address\":\"" + model.Address + "\"," + "\"receiver_zip\":\"" + model.PostalCode + "\"," + "\"receiver_mobile\":\"" + model.TelPhone + "\"," + "\"receiver_phone\":\"" + model.Phone + "\"," + "\"deal_datetime\":\"" + datetime + "\"," + "\"buyer_memo\":\"" + BuyersRemarks + "\"," + "\"seller_memo\":\"" + sellerRemarksList + "\"," + "\"business_man_code\":\"" + model.BusinessName + "\"," + "\"details\":[" + shangp + "]" + "}"; string sign = gy.Sign(cmd); string comcode = "{" + "\"appkey\":\"171736\"," + "\"method\":\"gy.erp.trade.add\"," + "\"sessionkey\":\"f5885504d9c84d1d8146200a4841f4b7\"," + "\"platform_code\":\"" + model.NewOrderCode + "\"," + "\"order_type_code\":\"" + model.OrderType + "\"," + "\"shop_code\":\"" + model.StoreCode + "\"," + "\"express_code\":\"" + model.ExpressName + "\"," + "\"receiver_province\":\"" + receiver_province + "\"," + "\"receiver_city\":\"" + receiver_city + "\"," + "\"receiver_district\":\"" + receiver_district + "\"," + "\"warehouse_code\":\"" + model.WarhouseName + "\"," + "\"vip_code\":\"" + model.VipCode + "\"," + "\"vip_name\":\"" + model.VipName + "\"," + "\"receiver_name\":\"" + model.ReceivingName + "\"," + "\"receiver_address\":\"" + model.Address + "\"," + "\"receiver_zip\":\"" + model.PostalCode + "\"," + "\"receiver_mobile\":\"" + model.TelPhone + "\"," + "\"receiver_phone\":\"" + model.Phone + "\"," + "\"deal_datetime\":\"" + datetime + "\"," + "\"buyer_memo\":\"" + BuyersRemarks + "\"," + "\"sign\":\"" + sign + "\"," + "\"seller_memo\":\"" + sellerRemarksList + "\"," + // "\"receiver_province\":\"" + listmodel.address + "\"," + "\"business_man_code\":\"" + model.BusinessName + "\"," + "\"details\":[" + shangp + "]" + "}"; string ret = gy.DoPost("http://api.guanyierp.com/rest/erp_open", comcode); JsonData jsonData = null; jsonData = JsonMapper.ToObject(ret); string sd = jsonData[0].ToString(); return(sd); }
public JsonResult Check(string UserName, int approveID, int status, string memo) { using (TransactionScope sc = new TransactionScope()) { try { int TotalStep = db.T_ExchangeCenterConfig.ToList().Count; T_ExchangeCenterApprove approve = db.T_ExchangeCenterApprove.Find(approveID); string name = approve.ApproveName; T_ExchangeCenter model = db.T_ExchangeCenter.Find(approve.Pid); approve.ApproveName = UserName; approve.ApproveStatus = status; approve.ApproveTime = DateTime.Now; approve.Memo = memo; db.SaveChanges(); if (status == 2)//不同意 { model.Status = status; model.Step = model.Step + 1; db.SaveChanges(); } else//同意 { int type = db.T_ExchangeReson.SingleOrDefault(s => s.Reson.Equals(model.ExchangeReson)).Type; int LastStep = db.T_ExchangeCenterConfig.OrderByDescending(s => s.Step).FirstOrDefault(s => s.Reson == type).Step; if (LastStep > model.Step)//判断是否存在下一级 { //获得下一级审核部门 string nextapproveType = db.T_ExchangeCenterConfig.OrderBy(s => s.Step).FirstOrDefault(s => s.Reson == type && s.Step > model.Step).ApproveType; T_ExchangeCenterApprove newApprove = new T_ExchangeCenterApprove(); newApprove.ApproveStatus = -1; newApprove.ApproveName = nextapproveType; newApprove.ApproveTime = null; newApprove.Pid = approve.Pid; db.T_ExchangeCenterApprove.Add(newApprove); db.SaveChanges(); model.Status = 0; model.Step = model.Step + 1; db.SaveChanges(); } if (name.Equals("售后主管") || name.Equals("呼吸机主管"))//售后主管审核后直接加入补发货 { //T_OrderList order = db.T_OrderList.Find(model.OrderId); List <T_ExchangeDetail> exchangedetail = db.T_ExchangeDetail.Where(s => s.ExchangeCenterId == model.ID).ToList(); #region 加入快递赔付 if (model.ExchangeReson.Equals("快递破损")) { GY gy = new GY(); string cmd = ""; cmd = "{" + "\"appkey\":\"171736\"," + "\"method\":\"gy.erp.trade.get\"," + "\"page_no\":1," + "\"page_size\":10," + "\"platform_code\":\"" + model.OrderCode + "\"," + "\"sessionkey\":\"f5885504d9c84d1d8146200a4841f4b7\"" + "}"; string sign = gy.Sign(cmd); cmd = cmd.Replace("}", ",\"sign\":\"" + sign + "\"}"); string ret = gy.DoPost("http://api.guanyierp.com/rest/erp_open", cmd); JsonData jsonData = null; jsonData = JsonMapper.ToObject(ret); if (jsonData.Count == 6 || jsonData["orders"].Count == 0) { cmd = "{" + "\"appkey\":\"171736\"," + "\"method\":\"gy.erp.trade.history.get\"," + "\"page_no\":1," + "\"page_size\":10," + "\"platform_code\":\"" + model.OrderCode + "\"," + "\"sessionkey\":\"f5885504d9c84d1d8146200a4841f4b7\"" + "}"; sign = gy.Sign(cmd); cmd = cmd.Replace("}", ",\"sign\":\"" + sign + "\"}"); ret = gy.DoPost("http://api.guanyierp.com/rest/erp_open", cmd); jsonData = null; jsonData = JsonMapper.ToObject(ret); if (jsonData.Count == 6 || jsonData["orders"].Count == 0) { return(Json(new { State = "Faile", Message = "订单号不存在" })); } } JsonData jsonOrders = jsonData["orders"][0]; var deliver = jsonOrders["deliverys"][0]; //快递单号 string mail_no = isNULL(deliver["mail_no"]).ToString(); //订单金额 string amount = isNULL(jsonOrders["amount"]).ToString(); //快递名称 string express_name = isNULL(jsonOrders["express_name"]).ToString(); T_ExpressIndemnity Inde = new T_ExpressIndemnity { PostUserName = model.PostUser, Date = DateTime.Now, OrderNum = model.OrderCode, wangwang = model.VipCode, ShopName = model.StoreName, RetreatExpressNum = mail_no, State = "0", OrderMoney = Convert.ToDouble(amount), Type = "破损", Second = "0", CurrentApproveName = "快递组", IsDelete = 0, ExpressName = express_name, IndemnityMoney = 0 }; db.T_ExpressIndemnity.Add(Inde); db.SaveChanges(); List <T_ExchangePic> picList = db.T_ExchangePic.Where(s => s.ExchangeId == model.ID).ToList(); foreach (var item in picList) { T_ExpressIndemnityPic expressPic = new T_ExpressIndemnityPic { EID = Inde.ID, PicURL = item.Url }; db.T_ExpressIndemnityPic.Add(expressPic); } db.SaveChanges(); } #endregion //#region 新增订单数据 //string newOrderCode = ""; //string newCode = ""; //string usedOrderCode = model.OrderCode; //string userCode = order.code; //List<T_OrderList> HEmodel = db.T_OrderList.Where(a => a.platform_code.Contains(usedOrderCode)).ToList(); //List<T_OrderList> orderList = db.T_OrderList.Where(a => a.code.Contains(userCode)).ToList(); //if (HEmodel.Count > 1) //{ // string HEmodelCount = HEmodel.Count.ToString(); // newOrderCode = usedOrderCode + HEmodelCount; //} //else // newOrderCode = usedOrderCode + "1"; //if (orderList.Count > 1) //{ // string listCount = orderList.Count.ToString(); // newCode = userCode + listCount; //} //else // newCode = userCode + "1"; //model.NewOrderCode = newOrderCode; //db.SaveChanges(); //T_OrderList newOrder = new T_OrderList //{ // code = newCode, // order_type_name = "换货订单", // platform_code = newOrderCode, // createtime = DateTime.Now, // dealtime = model.SingleTime.ToString(), // cod = order.cod, // approve = order.approve, // delivery_state = order.delivery_state, // warehouse_code = model.ReturnWarhouse, // warehouse_name = db.T_Warehouses.SingleOrDefault(s => s.code.Equals(model.ReturnWarhouse)).name, // shop_code = model.StoreCode, // shop_name = model.StoreName, // express_code = model.ReturnExpressName, // express_name = db.T_Express.SingleOrDefault(s => s.Code.Equals(model.ReturnExpressName)).Name, // buyer_memo = model.BuyRemark, // seller_memo = model.SalesRemark, // vip_code = model.VipCode, // vip_name = model.VipName, // receiver_name = model.ReceivingName, // receiver_mobile = model.ReceivingTelPhone, // receiver_phone = model.ReceivingPhone, // receiver_zip = model.NeedPostalCode, // receiver_area = model.AddressMessage, // receiver_address = model.ReceivingAddress, // payCode = order.payCode, // vipIdCard = order.vipIdCard, // vipRealName = order.vipRealName, // vipEmail = order.vipEmail, // amount = 0, // payment_amount = 0, // post_fee = 0, // discount_fee = 0, // payment = 0, // qty = "1", // weight_origin = "0", // post_cost = 0, // mail_no = model.ReturnExpressCode, // platform_flag = "0", // IsGeneralize = 0, // Status_CashBack = 0, // Status_Retreat = 0, // Status_ExpressIndemnity = 0, // ExchangeStatus = 0, // ReissueStatus = 0 //}; //db.T_OrderList.Add(newOrder); //db.SaveChanges(); //foreach (var item in exchangedetail) //{ // T_OrderDetail Orderdetail = db.T_OrderDetail.FirstOrDefault(s => s.oid.Equals(order.code) && s.item_code.Equals(item.SendProductCode)); // if (Orderdetail != null)//修改原订单详情换货状态与换货数量 // { // Orderdetail.ExchangeStatus = 1; // Orderdetail.ExchangeQty += item.SendProductNum; // db.SaveChanges(); // } // T_OrderDetail t = new T_OrderDetail // { // oid = newCode, // refund = 0, // item_code = item.NeedProductCode, // item_name = item.NeedProductName, // item_simple_name = "", // sku_code = "", // sku_name = "", // qty = 0, // price = 0, // amount = 0, // discount_fee = 0, // amount_after = 0, // post_fee = 0, // platform_item_name = "", // platform_sku_name = "", // note = "", // ExchangeStatus = 0, // ExchangeQty = 0, // ReissueStatus = 0, // ReissueQty = 0, // RetreatQty = 0, // RetreatStatus = 0 // }; // db.T_OrderDetail.Add(t); // db.SaveChanges(); //} //#endregion #region 加入补发货 string remark = ""; T_Reissue re = db.T_Reissue.FirstOrDefault(s => s.OrderCode.Equals(model.OrderCode) && s.IsDelete == 0); if (re != null) { var date = Convert.ToDateTime(DateTime.Now).ToString("yyyyMMdd"); var modeldate = Convert.ToDateTime(re.CreatDate).ToString("yyyyMMdd"); if (re != null && int.Parse(date) - int.Parse(modeldate) <= 3) { remark = model.SystemRemark + "3天内补发货重复"; } } //更改订单主表补发货状态 //else //{ // order.ReissueStatus = 1; // db.SaveChanges(); //} T_Reissue reissue = new T_Reissue { OrderCode = model.OrderCode, NewOrderCode = "8" + DateTime.Now.ToString("yyyyMMddHHmmss"), VipName = model.VipName, StoreName = model.StoreName, WarhouseName = model.NeedWarhouse, ExpressName = model.NeedExpress, OrderType = "Return", SingleTime = model.SingleTime, ReceivingName = model.ReceivingName, PostalCode = model.NeedPostalCode, Phone = model.ReceivingPhone, TelPhone = model.ReceivingTelPhone, VipCode = model.VipCode, Address = model.ReceivingAddress, AddressMessage = model.AddressMessage, SalesRemark = model.SalesRemark, BuyRemark = model.BuyRemark, StoreCode = model.StoreCode, Step = 0, Status = -2, BusinessName = Com.GetReissueName(model.StoreCode, model.ExchangeReson), PostUser = model.PostUser, DraftName = Com.GetReissueName(model.StoreCode, model.ExchangeReson), CreatDate = DateTime.Now, IsDelete = 0, ReissueReson = model.ExchangeReson, SystemRemark = remark }; db.T_Reissue.Add(reissue); db.SaveChanges(); IQueryable <T_ExchangeDetail> detail = db.T_ExchangeDetail.Where(s => s.ExchangeCenterId == model.ID); foreach (var item in detail) { T_ReissueDetail items = new T_ReissueDetail { ProductCode = item.NeedProductCode, ProductName = item.NeedProductName, Num = item.NeedProductNum, ReissueId = reissue.ID }; db.T_ReissueDetail.Add(items); } db.SaveChanges(); #endregion #region 判断仓库是否收货 T_ReturnToStorage storge = db.T_ReturnToStorage.SingleOrDefault(s => s.Retreat_expressNumber.Equals(model.ReturnExpressCode)); if (storge != null) { //List<T_ExchangeCenter> exchange = db.T_ExchangeCenter.Where(s => s.OrderCode.Equals(model.OrderCode) && s.IsDelete == 0).ToList(); model.WarhouseStatus = 1; model.Status = 1; T_ExchangeCenterApprove approve1 = db.T_ExchangeCenterApprove.SingleOrDefault(s => s.ApproveName.Equals("仓库") && !s.ApproveTime.HasValue && s.Pid == model.ID); approve1.ApproveName = "仓库"; approve1.ApproveStatus = 1; approve1.ApproveTime = DateTime.Now; //判断是否第一次换货,如果是则修改订单状态为已收货 //if (exchange.Count() == 1) //{ // order.ExchangeStatus = 2; //} } #endregion } } List <T_ModularNotaudited> ModularNotaudited = db.T_ModularNotaudited.Where(a => a.ModularName == "换货未审核").ToList(); if (ModularNotaudited.Count > 0) { foreach (var item in ModularNotaudited) { db.T_ModularNotaudited.Remove(item); } db.SaveChanges(); } string RetreatAppRoveSql = " select isnull(ApproveUser,ApproveName) as PendingAuditName,COUNT(*) as NotauditedNumber from T_ExchangeCenterApprove where Pid in ( select ID from T_ExchangeCenter where IsDelete=0 ) and ApproveStatus=-1 and ApproveTime is null GROUP BY ApproveName,ApproveUser"; List <Modular> RetreatAppRoveQuery = db.Database.SqlQuery <Modular>(RetreatAppRoveSql).ToList(); string Nickname = Server.UrlDecode(Request.Cookies["Nickname"].Value); for (int e = 0; e < RetreatAppRoveQuery.Count; e++) { string PendingAuditName = RetreatAppRoveQuery[e].PendingAuditName; T_ModularNotaudited NotauditedModel = db.T_ModularNotaudited.SingleOrDefault(a => a.ModularName == "换货未审核" && a.PendingAuditName == PendingAuditName); if (NotauditedModel != null) { NotauditedModel.NotauditedNumber = RetreatAppRoveQuery[e].NotauditedNumber; db.Entry <T_ModularNotaudited>(NotauditedModel).State = System.Data.EntityState.Modified; } else { T_ModularNotaudited ModularNotauditedModel = new T_ModularNotaudited(); ModularNotauditedModel.ModularName = "换货未审核"; ModularNotauditedModel.NotauditedNumber = RetreatAppRoveQuery[e].NotauditedNumber; ModularNotauditedModel.PendingAuditName = RetreatAppRoveQuery[e].PendingAuditName; ModularNotauditedModel.ToupdateDate = DateTime.Now; ModularNotauditedModel.ToupdateName = Nickname; db.T_ModularNotaudited.Add(ModularNotauditedModel); } db.SaveChanges(); } sc.Complete(); return(Json(new { State = "Success" }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { State = "Faile", Message = ex.Message }, JsonRequestBehavior.AllowGet)); } } }
public ContentResult TBguanyi() { GY gy = new GY(); string cmd = "{" + "\"appkey\":\"171736\"," + "\"method\":\"gy.erp.items.get\"," + "\"page_no\":1," + "\"page_size\":50," + "\"sessionkey\":\"f5885504d9c84d1d8146200a4841f4b7\"" + "}"; string sign = gy.Sign(cmd); cmd = cmd.Replace("}", ",\"sign\":\"" + sign + "\"}"); string ret = gy.DoPost("http://api.guanyierp.com/rest/erp_open", cmd); JsonData jsonData = null; jsonData = JsonMapper.ToObject(ret); // jsonData["success"] int shuliang = int.Parse(jsonData["total"].ToString()); int i = 0; int yeshu = shuliang / 50 + (shuliang % 50 == 0 ? 0 : 1); for (int x = 1; x <= yeshu; x++) { cmd = "{" + "\"appkey\":\"171736\"," + "\"method\":\"gy.erp.items.get\"," + "\"page_no\":" + x + "," + "\"page_size\":50," + "\"sessionkey\":\"f5885504d9c84d1d8146200a4841f4b7\"" + "}"; sign = gy.Sign(cmd); cmd = cmd.Replace("}", ",\"sign\":\"" + sign + "\"}"); ret = gy.DoPost("http://api.guanyierp.com/rest/erp_open", cmd); jsonData = null; jsonData = JsonMapper.ToObject(ret); T_goodsGY model = new T_goodsGY(); int ss = 50; if (x == yeshu) { ss = int.Parse(shuliang.ToString().Substring(shuliang.ToString().Length - 2, 2)); } for (int z = 0; z < ss; z++) { i++; JsonData skus = jsonData["items"][z]; DateTime create_date = new DateTime(); string name = ""; string code = ""; string note = ""; string combine = ""; double weight = 0; string simple_name = ""; string category_code = ""; string category_name = ""; string supplier_code = ""; string item_unit_code = ""; double package_point = 0; double sales_point = 0; decimal sales_price = 0; decimal purchase_price = 0; decimal agent_price = 0; decimal cost_price = 0; string pic_url = ""; string stock_status_code = ""; if (skus["create_date"] != null) { create_date = DateTime.Parse(skus["create_date"].ToString()); } if (skus["name"] != null) { name = skus["name"].ToString(); } if (skus["code"] != null) { code = skus["code"].ToString(); } if (skus["note"] != null) { note = skus["note"].ToString(); } if (skus["combine"] != null) { combine = skus["combine"].ToString(); } if (skus["weight"] != null) { weight = double.Parse(skus["weight"].ToString()); } if (skus["simple_name"] != null) { simple_name = skus["simple_name"].ToString(); } if (skus["category_code"] != null) { category_code = skus["category_code"].ToString(); } if (skus["category_name"] != null) { category_name = skus["category_name"].ToString(); } if (skus["supplier_code"] != null) { supplier_code = skus["supplier_code"].ToString(); } if (skus["item_unit_code"] != null) { item_unit_code = skus["item_unit_code"].ToString(); } if (skus["package_point"] != null) { package_point = double.Parse(skus["package_point"].ToString()); } if (skus["sales_point"] != null) { sales_point = double.Parse(skus["sales_point"].ToString()); } if (skus["sales_price"] != null) { sales_price = decimal.Parse(skus["sales_price"].ToString()); } if (skus["purchase_price"] != null) { purchase_price = decimal.Parse(skus["purchase_price"].ToString()); } if (skus["agent_price"] != null) { agent_price = decimal.Parse(skus["agent_price"].ToString()); } if (skus["cost_price"] != null) { cost_price = decimal.Parse(skus["cost_price"].ToString()); } if (skus["pic_url"] != null) { pic_url = skus["pic_url"].ToString(); } if (skus["stock_status_code"] != null) { stock_status_code = skus["stock_status_code"].ToString(); } List <T_goodsGY> Querymodel = db.T_goodsGY.Where(a => a.code == code).ToList(); if (Querymodel.Count == 0) { model.create_date = create_date; model.name = name; model.code = code; model.note = note; model.weight = weight; model.combine = combine; model.simple_name = simple_name; model.category_code = category_code; model.category_name = category_name; model.supplier_code = supplier_code; model.item_unit_code = item_unit_code; model.package_point = package_point; model.sales_point = sales_point; model.sales_price = sales_price; model.purchase_price = purchase_price; model.agent_price = agent_price; model.cost_price = cost_price; model.stock_status_code = stock_status_code; model.pic_url = pic_url; db.T_goodsGY.Add(model); db.SaveChanges(); } } } if (i == shuliang) { return(Content(i.ToString())); } else { return(Content("0")); } }