public static bool CheckOrderAttach(int OrderID, string configName) { BLL.Order order = new BLL.Order(); Common.Entity.Order oInfo = order.GetOrderByPKID(OrderID); IList <string> orderCars = order.GetCarsOrder(OrderID); JArray requireJObj = JArray.Parse(ConfigurationManager.AppSettings[configName]); IList <string> filesRequire = _getMatchingAttach(oInfo, orderCars, requireJObj); String uploadTempPath = ConfigurationManager.AppSettings["uploadPath"]; string tempPath = oInfo.Code.Split(new char[] { '-' })[1]; uploadTempPath = uploadTempPath + "\\OrdersPic\\" + tempPath.Substring(0, 4) + "\\" + tempPath + "\\"; foreach (string s in filesRequire) { if ("9" == s) { //9,B,C,D,E都为合同 if (!(File.Exists(string.Format("{0}{1}fufAttach9.jpg", uploadTempPath, oInfo.Code)) || File.Exists(string.Format("{0}{1}fufAttachB.jpg", uploadTempPath, oInfo.Code)) || File.Exists(string.Format("{0}{1}fufAttachC.jpg", uploadTempPath, oInfo.Code)) || File.Exists(string.Format("{0}{1}fufAttachD.jpg", uploadTempPath, oInfo.Code)) || File.Exists(string.Format("{0}{1}fufAttachE.jpg", uploadTempPath, oInfo.Code)))) { return(false); } } else { if (!File.Exists(string.Format("{0}{1}fufAttach{2}.jpg", uploadTempPath, oInfo.Code, s))) { return(false); } } } return(true); }
private static IList <string> _getMatchingAttach(Common.Entity.Order order, IList <string> orderCars, JArray jaCondation) { IList <string> filesRequire = new List <string>(); foreach (JObject jo in jaCondation) { bool matchCondation = true; foreach (JProperty jp in jo.Properties()) { string jpValue = jp.Value.Value <string>(); switch (jp.Name) { case "Cartype": if (jpValue.IndexOf('!') == 0) { matchCondation &= !orderCars.Contains(jpValue.Substring(1)); } else { matchCondation &= orderCars.Contains(jpValue); } break; case "Require": break; default: var orderValue = GetPropValue(order, jp.Name); if (null != orderValue) { if (jpValue.IndexOf('!') == 0) { matchCondation &= (orderValue.ToString() != jpValue.Substring(1)); } else { matchCondation &= (orderValue.ToString() == jpValue); } } else { matchCondation = false; } break; } if (!matchCondation) { break; } } if (matchCondation) { filesRequire = filesRequire.Union(jo["Require"].Value <string>().Split(new char[] { ',' })).ToList <string>(); } } return(filesRequire); }
/// <summary> /// 获取订单实体对象 /// </summary> /// <param name="context">上下文对象</param> public void GetOrderByPKID(HttpContext context) { int orderId = Convert.ToInt32(context.Request["orderId"]); if (orderId > 0) { Common.Entity.Order model = new Common.Entity.Order(); model = new BLL.Order().GetOrderByPKID(orderId); context.Response.Write(JsonConvert.SerializeObject(model)); } }
/// <summary> /// 获取全部订单信息 /// </summary> /// <param name="context">上下文对象</param> public void GetOrdersAllPager(HttpContext context) { int totalCount = 0; // 总记录数 int pageIndex = Convert.ToInt32(context.Request["page"]); // 当前页 int pageSize = Convert.ToInt32(context.Request["rows"]); // 页码大小 Common.Entity.Order filter = new Common.Entity.Order(); if (!string.IsNullOrEmpty(context.Request.Form["OrdersearchContext"])) { filter = JsonConvert.DeserializeObject <Common.Entity.Order>(context.Request.Form["OrdersearchContext"]); } var list = new BLL.Order().GetOrdersAllPager(pageIndex, pageSize, filter, out totalCount); int totalPages = CommonFunction.CalculateTotalPage(pageSize, totalCount); var ResultData = new CommonFunction.DataResult <Common.Entity.Order>() { totalCount = totalCount, totalpages = totalPages, currPage = pageIndex, dataList = list, }; context.Response.Write(JsonConvert.SerializeObject(ResultData)); }
public void SaveData(HttpContext context) { bool isConfirmData = bool.Parse(ZJRequest.GetFormString("isConfirmData")); string opType = ZJRequest.GetFormString("info[opType]"); string BuyWay = ZJRequest.GetFormString("info[BuyWay]"); string orderNo = ZJRequest.GetFormString("info[OrderNo]"); DateTime CreateTime = Convert.ToDateTime(context.Request.Form["info[CreateTime]"]); string PurchaseType = ZJRequest.GetFormString("info[PurchaseType]"); string OrderState = ZJRequest.GetFormString("info[OrderState]"); string CarUse = ZJRequest.GetFormString("info[CarUse]"); int OffAddressOnCardReport = (ZJRequest.GetFormInt("info[OffAddressOnCardReport]")); int InvoiceDiffer = ZJRequest.GetFormInt("info[InvoiceDiffer]"); int IsApplyMaxCustomerResources = ZJRequest.GetFormInt("info[IsApplyMaxCustomerResources]"); int hiddenDealerId = ZJRequest.GetFormInt("info[hiddenDealerId]"); int hiddenCustomerId = ZJRequest.GetFormInt("info[hiddenCustomerId]"); string RecordName = ZJRequest.GetFormString("info[RecordName]"); string Watchmaker = ZJRequest.GetFormString("info[Watchmaker]"); int DifferentPlace = ZJRequest.GetFormInt("info[DifferentPlace]"); string InvoiceCustomerInfo = ZJRequest.GetFormString("info[FN_InvoiceName]"); Common.Entity.Order order = new Common.Entity.Order(); order.BuyWay = BuyWay; order.Code = orderNo; order.CreateTime = CreateTime; order.PurchaseType = PurchaseType; order.OrderState = OrderState; order.CarUse = CarUse; order.OffAddressOnCardReport = OffAddressOnCardReport; order.InvoiceAndCustomerAtypism = InvoiceDiffer; order.IsApplyMaxCustomerResources = IsApplyMaxCustomerResources; order.CustomerID = hiddenCustomerId; order.DealerID = hiddenDealerId; order.RecordName = RecordName; order.Watchmaker = Watchmaker; order.DifferentPlace = DifferentPlace; order.OrderType = 1; // 订单类别:订单为1,销售单为2 order.InvoiceCustomerInfo = InvoiceCustomerInfo; string result = ""; List <Common.Entity.Order> list = new List <Common.Entity.Order>(); string username = context.User.Identity.Name; Common.SysUserEntity model = new BLL.sysUser().GetSysUserByLoginName(username); if (opType == "update") { order.PKID = Convert.ToInt32(context.Request["info[HidOrderID]"]); if (new BLL.Order().GetOrderByPKID(order.PKID).ToExamineState >= 300) { result = "已经进行配车的订单无法进行更改。"; } } Hashtable CarDemandSort2Guid = new Hashtable(); string arrCar = context.Request.Form["arrCar"]; List <Common.Entity.CarPurchase> carsDemand = JsonConvert.DeserializeObject <List <Common.Entity.CarPurchase> >(arrCar); bool hasInvalidData = false; IDictionary <string, IList <Common.Entity.CarPurchase> > demandCars = new Dictionary <string, IList <Common.Entity.CarPurchase> >(); demandCars.Add("exist", new List <Common.Entity.CarPurchase>()); demandCars.Add("new", new List <Common.Entity.CarPurchase>()); foreach (Common.Entity.CarPurchase cd in carsDemand) { cd.IsApplyMaxCustomerResources = "1"; cd.OrderID = order.PKID; if ((0 == cd.PKID)) { demandCars["new"].Add(cd); CarDemandSort2Guid.Add(cd.AddSortNo, cd.PKID); } else { demandCars["exist"].Add(cd); } if ("COASTER" == cd.CarName.Trim().ToUpper()) { if (string.IsNullOrEmpty(cd.OldNo) || string.IsNullOrEmpty(cd.RuckSack)) { hasInvalidData = true; } } } IDictionary <string, IList <Common.Entity.CarRecord> > payCars = new Dictionary <string, IList <Common.Entity.CarRecord> >(); List <Common.Entity.CarRecord> parList = new List <Common.Entity.CarRecord>(); payCars.Add("exist", new List <Common.Entity.CarRecord>()); payCars.Add("new", new List <Common.Entity.CarRecord>()); if (hasInvalidData && ("协商" != order.OrderState)) { order.OrderState = "协商"; result = "订单已经被强制设置为协商状态,有不符合规范的订购信息(请检查COASTER车型信息是否填写完全)。"; } if (opType == "update") { new BLL.Order().Update(order, demandCars, payCars); //new BLL.Order().Update(order, carsDemand, parList); } else { new BLL.Order().Add(model.Name, order, demandCars, payCars); } if ((isConfirmData) && string.IsNullOrEmpty(result)) { int?demandCount = demandCars["new"].Sum(p => p.RequirementNumber) + demandCars["exist"].Sum(p => p.RequirementNumber); if (!CommonFunction.CheckOrderAttach(order.PKID, "attachRequireOrder")) { result = "电子资料不全。具体要求查看在线帮助。"; } else if ((demandCount > 0) && new BLL.Order().CheckSubmitOrders(order.CustomerID, order.DealerID)) { bool directSubmit = bool.Parse(ConfigurationManager.AppSettings["directSubmitOrders"]); new BLL.Order().SubmitOrders(model.Name, order.PKID.ToString("D"), order.CustomerID.ToString("D"), order.DealerID, directSubmit); } else { result = "订单已保存,但订单不符合提交需求,请修改后提交。请检查<BR>1.车辆需求是否填写<BR>2.经销店以及客户联系人是否填写<BR>"; } } context.Response.Write("{\"msg\":\" " + result + "\",\"state\":\"true\"}"); }