public void ProcessRequest(HttpContext context) { if (context.Request["oid"] == null) { status = 0; msg = "订单编号参数不能为空!"; goto returnJson; } string pageSize = context.Request["pageSize"]; string oid = context.Request["oid"]; ModelAdo <SupplierOrderModel> supplierSendModel = new ModelAdo <SupplierOrderModel>(); if (pageSize != null) { supplierSendModel.PageSize = int.Parse(pageSize); } int RecordCount = supplierSendModel.GetRecordCount(" userType=0 "); List <SupplierOrderModel> list = supplierSendModel.GetList(" userType=0 AND (oid=?oid or status is NULL) ", "", "", new MySqlParameter("?oid", oid)); //List<SupplierOrderModel> list = supplierSendModel.GetList("select * from tv_view_supplier_order where userType=0 AND (oid=1 or status is NULL) "); if (list.Count == 0) { status = 0; msg = "未能找到数据集合!"; goto returnJson; } else { pageData = new { recordCount = RecordCount, pageSize = supplierSendModel.PageSize }; Data = from model in list select new { uid = model.uid, status = model.status, oid = model.oid }; output = new { pageData = pageData, Data = Data }; } returnJson: Dictionary <string, object> returnJson = new Dictionary <string, object> { { "status", status }, { "msg", msg }, { "output", output } }; string json = JsonConvert.SerializeObject(returnJson, Formatting.Indented); context.Response.ContentType = "application/json"; context.Response.Write(json); }
public void ProcessRequest(HttpContext context) { if (context.Request["oid"] == null) { status = 0; msg = "订单编号参数不能为空!"; goto returnJson; } if (context.Request["type"] == null) { status = 0; msg = "派单类型参数不能为空!"; goto returnJson; } if (context.Request["stid"] == null) { status = 0; msg = "供应商组编号参数不能为空!"; goto returnJson; } int oid = Int32.Parse(context.Request["oid"]); int type = Int32.Parse(context.Request["type"]); string stid = context.Request["stid"]; ModelAdo <OrderSTypeModel> orderSTypeModel = new ModelAdo <OrderSTypeModel>(); if (type == 1) { int RecordCount = orderSTypeModel.GetRecordCount(" oid = " + oid); if (RecordCount >= 1) { //删除原有中间表数据 int tempSize = orderSTypeModel.ExecuteSql("DELETE FROM ct_order_stype WHERE oid = ?oid", new MySqlParameter("?oid", oid)); if (tempSize == 0) { //删除成功,插入数据 } else { //未能正确删除数据 status = 0; msg = "数据处理失败集合!"; goto returnJson; } } //直接插入数据 JArray jsonStid = JArray.Parse(stid); if (jsonStid.Count == 0) { //供应商组不能为空 status = 0; msg = "供应商组不能为空!"; goto returnJson; } string insertStr = "INSERT INTO ct_order_stype(oid,stid,status) VALUES"; foreach (int item in jsonStid) { insertStr += "(" + oid + "," + item + ",1),"; } insertStr = insertStr.Substring(0, insertStr.Length - 1); output = insertStr; } if (0 == 0) { status = 0; msg = "未能找到数据集合!"; goto returnJson; } else { } returnJson: Dictionary <string, object> returnJson = new Dictionary <string, object> { { "status", status }, { "msg", msg }, { "output", output } }; string json = JsonConvert.SerializeObject(returnJson, Formatting.Indented); context.Response.ContentType = "application/json"; context.Response.Write(json); }
public override void OnLoad(HttpContext context) { base.OnLoad(context); requestBody = new RequestBody(); requestBody.accessToken = context.Request["accessToken"]; requestBody.oid = context.Request["oid"]; requestBody.uid = context.Request["uid"]; if (requestBody.accessToken == null || requestBody.accessToken.Trim().Length == 0 || requestBody.oid.Length == 0 || requestBody.uid.Length == 0) { SystemResponse.Output(SystemResponse.TYPE_NULLPARAMETER, out statusCode, out responseJson); } else { List <int> values = JsonConvert.DeserializeObject <List <int> >(requestBody.uid); //验证用户 TokenHelper token = new TokenHelper(); UserTokenModel userTokenModel = token.getUserToken(requestBody.accessToken); if (userTokenModel == null) { SystemResponse.Output(SystemResponse.TYPE_EXPIRE, out statusCode, out responseJson); } else { //获取订单表数据 ModelAdo <OrderModel> modelAdoOrder = new ModelAdo <OrderModel>(); OrderModel orderModel = modelAdoOrder.GetModel("(id=?id AND ostatus=?ostatus) or (id=?id AND ostatus=?ostatus1) ", "", new MySqlParameter("?id", requestBody.oid), new MySqlParameter("?ostatus", 2), new MySqlParameter("?ostatus1", 1)); if (orderModel != null) { ModelAdo <OrderUserModel> modelAdo = new ModelAdo <OrderUserModel>(); int existCount = modelAdo.GetRecordCount("oid=?oid", new MySqlParameter("?oid", requestBody.oid)); if (existCount >= 1) { int delCount = modelAdo.ExecuteSql("DELETE FROM ct_order_user WHERE oid=?oid", new MySqlParameter("?oid", requestBody.oid)); if (delCount >= 1) { StringBuilder sbValues = new StringBuilder(); sbValues.Append(" INSERT INTO ct_order_user(oid,uid,status,remark) VALUES "); for (int i = 0; i < values.Count; i++) { sbValues.Append("(" + requestBody.oid + "," + values[i] + ",1,'派送中的订单'),"); } sbValues.Remove(sbValues.Length - 1, 1).Append(";"); int inCount = modelAdo.ExecuteSql(sbValues.ToString()); if (inCount >= 1) { if (orderModel != null) { orderModel.ostatus = 2; modelAdoOrder.Update(orderModel); } SystemResponse.Output(SystemResponse.TYPE_OK, out statusCode, out responseJson); } else { SystemResponse.Output(SystemResponse.TYPE_NULL, out statusCode, out responseJson); } } else { SystemResponse.Output(SystemResponse.TYPE_ERROR, out statusCode, out responseJson); } } else { StringBuilder sbValues = new StringBuilder(); sbValues.Append(" INSERT INTO ct_order_user(oid,uid,status) VALUES "); for (int i = 0; i < values.Count; i++) { sbValues.Append("(" + requestBody.oid + "," + values[i] + ",1),"); } sbValues.Remove(sbValues.Length - 1, 1).Append(";"); int inCount = modelAdo.ExecuteSql(sbValues.ToString()); if (inCount >= 1) { SystemResponse.Output(SystemResponse.TYPE_OK, out statusCode, out responseJson); } else { SystemResponse.Output(SystemResponse.TYPE_NULL, out statusCode, out responseJson); } } } else { SystemResponse.Output(SystemResponse.TYPE_NULL, out statusCode, out responseJson); } } } }