public override void OnLoad(HttpContext context) { base.OnLoad(context); requestBody = new RequestBody(); requestBody.accessToken = context.Request["accessToken"]; if (requestBody.accessToken == null || requestBody.accessToken.Trim().Length == 0) { SystemResponse.Output(SystemResponse.TYPE_NULLPARAMETER, out statusCode, out responseJson); } else { //验证用户 TokenHelper token = new TokenHelper(); UserTokenModel userTokenModel = token.getUserToken(requestBody.accessToken); if (userTokenModel == null) { SystemResponse.Output(SystemResponse.TYPE_EXPIRE, out statusCode, out responseJson); } else { object model = new object(); if (model != null) { responseBody = new ResponseBody(); responseJson = JsonConvert.SerializeObject(responseBody, Formatting.Indented); } else { SystemResponse.Output(SystemResponse.TYPE_NULL, out statusCode, out responseJson); } } } }
public override void OnLoad(HttpContext context) { base.OnLoad(context); requestBody = new RequestBody(); requestBody.accessToken = context.Request["accessToken"]; requestBody.page = Convert.ToInt32(context.Request["page"]); requestBody.pageSize = Convert.ToInt32(context.Request["pageSize"]); requestBody.oid = Convert.ToInt32(context.Request["oid"]); if (requestBody.accessToken == null || requestBody.accessToken.Trim().Length == 0 || requestBody.oid == 0) { SystemResponse.Output(SystemResponse.TYPE_NULLPARAMETER, out statusCode, out responseJson); } else { //验证用户 TokenHelper token = new TokenHelper(); UserTokenModel userTokenModel = token.getUserToken(requestBody.accessToken); if (userTokenModel == null) { SystemResponse.Output(SystemResponse.TYPE_EXPIRE, out statusCode, out responseJson); } else { ModelAdo <OrderSupplierModel> orderModel = new ModelAdo <OrderSupplierModel>(); List <OrderSupplierModel> models = null; int pagenumber = requestBody.page == 0 ? 1 : requestBody.page; int totalCount = 1; orderModel.PageSize = requestBody.pageSize == 0 ? orderModel.PageSize : requestBody.pageSize; if (requestBody.oid == 0) { models = orderModel.GetList(pagenumber, " cuid=?cuid ", "", out totalCount, "", new MySqlParameter("?cuid", userTokenModel.uid) ); } else { models = orderModel.GetList(pagenumber, " cuid=?cuid AND oid=?oid", "", out totalCount, "", new MySqlParameter("?cuid", Convert.ToInt32(userTokenModel.uid)), new MySqlParameter("?oid", requestBody.oid) ); } if (models.Count >= 1) { responseBody = new ResponseBody { page = 1, pageTotal = (totalCount + orderModel.PageSize - 1) / orderModel.PageSize, total = totalCount, suppliers = models }; responseJson = JsonConvert.SerializeObject(responseBody, Formatting.Indented); } else { SystemResponse.Output(SystemResponse.TYPE_NULL, out statusCode, out responseJson); } } } }
public override void OnLoad(HttpContext context) { base.OnLoad(context); requestBody = new RequestBody(); requestBody.userName = context.Request["userName"]; requestBody.userPwd = context.Request["userPwd"]; requestBody.userType = context.Request["userType"]; requestBody.bpuserid = context.Request["bpuserid"]; requestBody.channelid = context.Request["channelid"]; requestBody.deviceToken = context.Request["deviceToken"]; requestBody.deviceType = context.Request["deviceType"]; if (requestBody.userType == null || requestBody.userName == null || requestBody.userPwd == null) { SystemResponse.Output(SystemResponse.TYPE_NULLPARAMETER, out statusCode, out responseJson); } else { string password = StringHelper.StringToMD5(requestBody.userPwd); ModelAdo <UserModel> userModel = new ModelAdo <UserModel>(); UserModel model = userModel.GetModel(" rid=?rid and name =?name and password=?password", "", new MySqlParameter("?rid", requestBody.userType), new MySqlParameter("?name", requestBody.userName), new MySqlParameter("?password", password)); if (model == null) { SystemResponse.Output(SystemResponse.TYPE_LOGIN_ERROR, out statusCode, out responseJson); } else { DateTime dt = DateTime.Now; string accessToken = StringHelper.StringToMD5(dt.ToString()); TokenHelper token = new TokenHelper(); UserTokenModel modelUserToken = new UserTokenModel(); modelUserToken.uid = model.id.ToString(); modelUserToken.rid = model.rid; modelUserToken.accessToken = accessToken; modelUserToken.bpuserId = requestBody.bpuserid; modelUserToken.channelId = requestBody.channelid; modelUserToken.deviceToken = requestBody.deviceToken; modelUserToken.deviceType = Convert.ToInt32(requestBody.deviceType); modelUserToken.loginTime = StringHelper.ConvertDateTimeInt(DateTime.Now); modelUserToken.isLogin = 1; token.updateToken(modelUserToken); responseBody = new ResponseBody { accessToken = accessToken, uid = model.id.ToString(), userName = model.name, nickName = model.nickname, userAvatar = model.avatar, userType = model.rid }; responseJson = JsonConvert.SerializeObject(responseBody, Formatting.Indented); } } }
public override void OnLoad(HttpContext context) { base.OnLoad(context); requestBody = new RequestBody(); requestBody.accessToken = context.Request["accessToken"]; if (requestBody.accessToken == null || requestBody.accessToken.Trim().Length == 0) { SystemResponse.Output(SystemResponse.TYPE_NULLPARAMETER, out statusCode, out responseJson); } else { //验证用户 TokenHelper token = new TokenHelper(); UserTokenModel userTokenModel = token.getUserToken(requestBody.accessToken); if (userTokenModel == null) { SystemResponse.Output(SystemResponse.TYPE_EXPIRE, out statusCode, out responseJson); } else { ModelAdo <UserModel> userModel = new ModelAdo <UserModel>(); List <UserModel> models = userModel.GetList(" id NOT IN (?id) AND status != 1", "", "", new MySqlParameter("?id", userTokenModel.uid)); if (models != null) { List <Friend> Friends = new List <Friend>(); foreach (UserModel model in models) { Friend friend = new Friend(); friend.id = model.id; friend.name = model.name; friend.avatar = model.avatar; Friends.Add(friend); } responseBody = new ResponseBody(); responseBody.Friends = Friends; responseJson = JsonConvert.SerializeObject(responseBody, Formatting.Indented); } else { SystemResponse.Output(SystemResponse.TYPE_NULL, out statusCode, out responseJson); } } } }
public override void OnLoad(HttpContext context) { base.OnLoad(context); requestBody = new RequestBody(); requestBody.userName = context.Request["userName"]; requestBody.userPwd = context.Request["userPwd"]; requestBody.userType = context.Request["userType"]; if (requestBody.userName == null || requestBody.userPwd == null || requestBody.userType == null) { SystemResponse.Output(SystemResponse.TYPE_NULLPARAMETER, out statusCode, out responseJson); } else { string password = StringHelper.StringToMD5(requestBody.userPwd); ModelAdo <UserModel> userModel = new ModelAdo <UserModel>(); UserModel model = userModel.GetModel(" rid=?rid and name =?name", "", new MySqlParameter("?rid", requestBody.userType), new MySqlParameter("?name", requestBody.userName)); if (model != null) { SystemResponse.Output(SystemResponse.TYPE_EXIST, out statusCode, out responseJson); } else { UserModel token = new UserModel(); token.rid = Convert.ToInt32(requestBody.userType); token.name = requestBody.userName; token.password = password; token.ctime = StringHelper.ConvertDateTimeInt(DateTime.Now); if (userModel.Insert(token) >= 1) { responseJson = JsonConvert.SerializeObject(responseBody, Formatting.Indented); } else { SystemResponse.Output(SystemResponse.TYPE_REGISTER_ERROR, out statusCode, out responseJson); } } } }
public override void OnLoad(HttpContext context) { base.OnLoad(context); requestBody = new RequestBody(); requestBody.accessToken = context.Request["accessToken"]; if (requestBody.accessToken == null || requestBody.accessToken.Trim().Length == 0) { SystemResponse.Output(SystemResponse.TYPE_NULLPARAMETER, out statusCode, out responseJson); } else { //验证用户 TokenHelper token = new TokenHelper(); UserTokenModel tokenModel = token.getUserToken(requestBody.accessToken); if (tokenModel == null) { SystemResponse.Output(SystemResponse.TYPE_EXPIRE, out statusCode, out responseJson); } else { tokenModel.isLogin = 0; tokenModel.loginTime = 0; tokenModel.accessToken = ""; tokenModel.bpuserId = ""; tokenModel.channelId = ""; tokenModel.deviceToken = ""; tokenModel.deviceType = 0; if (token.updateToken(tokenModel) >= 1) { SystemResponse.Output(SystemResponse.TYPE_OK, out statusCode, out responseJson); } else { SystemResponse.Output(SystemResponse.TYPE_NULL, out statusCode, out responseJson); } } } }
public override void OnLoad(HttpContext context) { base.OnLoad(context); requestBody = new RequestBody(); requestBody.accessToken = context.Request["accessToken"]; requestBody.page = Convert.ToInt32(context.Request["page"]); requestBody.pageSize = Convert.ToInt32(context.Request["pageSize"]); requestBody.status = Convert.ToInt32(context.Request["status"]); if (requestBody.accessToken == null || requestBody.accessToken.Trim().Length == 0) { SystemResponse.Output(SystemResponse.TYPE_NULLPARAMETER, out statusCode, out responseJson); } else { //验证用户 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> orderModel = new ModelAdo <OrderModel>(); List <OrderModel> models = null; int pagenumber = requestBody.page == 0 ? 1 : requestBody.page; int totalCount = 1; orderModel.PageSize = requestBody.pageSize == 0 ? orderModel.PageSize : requestBody.pageSize; if (requestBody.status == 0) { models = orderModel.GetList(pagenumber, " uid=?uid ", "", out totalCount, "", new MySqlParameter("?uid", userTokenModel.uid) ); } else { models = orderModel.GetList(pagenumber, " uid=?uid AND ostatus=?ostatus", "", out totalCount, "", new MySqlParameter("?uid", Convert.ToInt32(userTokenModel.uid)), new MySqlParameter("?ostatus", requestBody.status) ); } if (models.Count >= 1) { //构建返回对象 List <Order> orders = new List <Order>(); foreach (OrderModel model in models) { Order order = new Order(); order.uid = model.uid.ToString(); order.title = model.title; order.createDate = string.Format("{0:d}", StringHelper.GetNomalTime(model.createDate)); order.status = model.ostatus; order.price = model.amount.ToString("f2"); order.oid = model.id.ToString(); order.type = model.otid; Ext from = new Ext(); from.uid = model.uid.ToString(); from.city = model.address1; from.date = string.Format("{0:d}", StringHelper.GetNomalTime(model.time1)); order.from = from; Ext to = new Ext(); to.uid = model.uid.ToString(); to.city = model.address2; to.date = string.Format("{0:d}", StringHelper.GetNomalTime(model.time2)); order.to = to; orders.Add(order); } responseBody = new ResponseBody { page = 1, pageTotal = (totalCount + orderModel.PageSize - 1) / orderModel.PageSize, total = totalCount, orders = orders }; responseJson = JsonConvert.SerializeObject(responseBody, Formatting.Indented); } else { SystemResponse.Output(SystemResponse.TYPE_NULL, out statusCode, out responseJson); } } } }
public override void OnLoad(HttpContext context) { base.OnLoad(context); requestBody = new RequestBody(); requestBody.accessToken = context.Request["accessToken"]; requestBody.oid = context.Request["oid"]; requestBody.action = Convert.ToInt32(context.Request["action"]); requestBody.amount = Convert.ToDecimal(context.Request["money"]); if (requestBody.accessToken == null || requestBody.accessToken.Trim().Length == 0 || requestBody.oid.Length == 0 || requestBody.action == 0) { SystemResponse.Output(SystemResponse.TYPE_NULLPARAMETER, out statusCode, out responseJson); } else if (requestBody.action == 2 && requestBody.amount == 0) { SystemResponse.Output(SystemResponse.TYPE_NULLPARAMETER, out statusCode, out responseJson); } else { //验证用户 TokenHelper token = new TokenHelper(); UserTokenModel userTokenModel = token.getUserToken(requestBody.accessToken); if (userTokenModel == null) { SystemResponse.Output(SystemResponse.TYPE_EXPIRE, out statusCode, out responseJson); } else { ModelAdo <OrderUserModel> modelAdo = new ModelAdo <OrderUserModel>(); //核对有没有供应商已抢单 OrderUserModel sendOrder = modelAdo.GetModel(" oid =?oid AND status=2", "", new MySqlParameter("?oid", requestBody.oid)); //核对供应商与订单状态 OrderUserModel model = modelAdo.GetModel("oid=?oid AND uid=?uid", "", new MySqlParameter("?oid", requestBody.oid), new MySqlParameter("?uid", userTokenModel.uid)); //数据是否存在派单中间表 if (model != null) { #region 供应商确认抢单【派单中间表已存在,并且订单状态为2,派单中】 if (2 == requestBody.action && sendOrder == null) { model.status = 2; model.amount = requestBody.amount; model.createTime = StringHelper.ConvertDateTimeInt(DateTime.Now); model.remark = "被供应商抢单的订单"; //修改订单状态为3,并录入相关抢单数据 ModelAdo <OrderModel> orderModelAdo = new ModelAdo <OrderModel>(); OrderModel orderModel = orderModelAdo.GetModel("id=?id", "", new MySqlParameter("?id", requestBody.oid) ); if (orderModel != null) { orderModel.ostatus = 3; orderModel.sendUid = Convert.ToInt32(userTokenModel.uid); orderModel.sendTime = model.createTime; orderModel.sendRemark = "供应商抢单并输入价格 【待处理订单】"; orderModel.sendAmount = model.amount; if (orderModelAdo.Update(orderModel) >= 1) { if (modelAdo.Update(model) >= 1) { SystemResponse.Output(SystemResponse.TYPE_OK, out statusCode, out responseJson); } else { SystemResponse.Output(SystemResponse.TYPE_ERROR, out statusCode, out responseJson); } } } else { SystemResponse.Output(SystemResponse.TYPE_ERROR, out statusCode, out responseJson); } } #endregion #region 用户退回订单 【派单中间表已存在,并且订单状态为3,待处理订单】 else if (3 == requestBody.action && sendOrder != null && sendOrder.uid == Convert.ToInt32(userTokenModel.uid)) { //修改订单状态为2,并清除相关抢单数据 ModelAdo <OrderModel> orderModelAdo = new ModelAdo <OrderModel>(); OrderModel orderModel = orderModelAdo.GetModel("id=?id", "", new MySqlParameter("?id", requestBody.oid) ); if (orderModel != null) { orderModel.ostatus = 2; orderModel.sendUid = 0; orderModel.sendTime = 0; orderModel.sendRemark = "供应商退回抢单【派单中】"; orderModel.sendAmount = 0; if (orderModelAdo.Update(orderModel) >= 1) { model.status = 3; model.remark = "被供应商退回的订单"; modelAdo.Update(model); SystemResponse.Output(SystemResponse.TYPE_OK, out statusCode, out responseJson); } else { SystemResponse.Output(SystemResponse.TYPE_NO_PERMISSON, out statusCode, out responseJson); } } else { SystemResponse.Output(SystemResponse.TYPE_ERROR, out statusCode, out responseJson); } } #endregion #region 其他操作 else { SystemResponse.Output(SystemResponse.TYPE_NO_PERMISSON, out statusCode, out responseJson); } #endregion } else { SystemResponse.Output(SystemResponse.TYPE_NO_PERMISSON, out statusCode, out responseJson); } } } }
public override void OnLoad(HttpContext context) { base.OnLoad(context); requestBody = new RequestBody(); requestBody.accessToken = context.Request["accessToken"]; requestBody.oid = Convert.ToInt32(context.Request["oid"]); if (requestBody.accessToken == null || requestBody.accessToken.Trim().Length == 0 || requestBody.oid == 0) { SystemResponse.Output(SystemResponse.TYPE_NULLPARAMETER, out statusCode, out responseJson); } else { //验证用户 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> orderModel = new ModelAdo <OrderModel>(); OrderModel model = orderModel.GetModel("id=?id", "", new MySqlParameter("?id", requestBody.oid) ); if (model != null) { responseBody = new ResponseBody(); responseBody.uid = model.uid; responseBody.title = model.title; responseBody.subtitle = model.subtitle; responseBody.createDate = string.Format("{0:d}", StringHelper.GetNomalTime(model.createDate)); responseBody.status = model.ostatus; responseBody.no = model.no; responseBody.price = model.amount.ToString("f2"); responseBody.contact = model.contact; responseBody.contactAddress = model.contactAdress; responseBody.contactOPhone = model.contactOPhone; responseBody.contactPhone = model.contactPhone; responseBody.payment = model.payment; responseBody.type = model.otid; responseBody.remark = model.remark; Ext from = new Ext(); from.uid = model.uid; from.city = model.address1; from.date = string.Format("{0:d}", StringHelper.GetNomalTime(model.time1)); responseBody.from = from; Ext to = new Ext(); to.uid = model.uid; to.city = model.address2; to.date = string.Format("{0:d}", StringHelper.GetNomalTime(model.time2)); responseBody.to = to; if (model.ostatus == 3) { Send send = new Send(); send.date = string.Format("{0:d}", StringHelper.GetNomalTime(model.sendTime)); send.suid = model.sendUid; send.price = model.sendAmount.ToString("f2"); send.remark = model.sendRemark; responseBody.send = send; } responseJson = JsonConvert.SerializeObject(responseBody, Formatting.Indented); } else { SystemResponse.Output(SystemResponse.TYPE_NULL, out statusCode, out responseJson); } } } }
public override void OnLoad(HttpContext context) { base.OnLoad(context); requestBody = new RequestBody(); requestBody.accessToken = context.Request["accessToken"]; requestBody.oid = context.Request["oid"]; requestBody.action = Convert.ToInt32(context.Request["action"]); if (requestBody.accessToken == null || requestBody.accessToken.Trim().Length == 0 || requestBody.oid.Length == 0 || requestBody.action == 0) { SystemResponse.Output(SystemResponse.TYPE_NULLPARAMETER, out statusCode, out responseJson); } else { //验证用户 TokenHelper token = new TokenHelper(); UserTokenModel userTokenModel = token.getUserToken(requestBody.accessToken); if (userTokenModel == null) { SystemResponse.Output(SystemResponse.TYPE_EXPIRE, out statusCode, out responseJson); } else { #region 客服取消供应商抢单数据、修改订单状态回派单中 if (requestBody.action == 2) { //获取当前订单信息 ModelAdo <OrderModel> modelAdo = new ModelAdo <OrderModel>(); OrderModel order = modelAdo.GetModel("id=?oid AND ostatus=?ostatus", "", new MySqlParameter("?oid", requestBody.oid), new MySqlParameter("?ostatus", 3)); if (order != null) { //获取派单供应商对应订单中间表数据 ModelAdo <OrderUserModel> ouModelAdo = new ModelAdo <OrderUserModel>(); OrderUserModel orderUser = ouModelAdo.GetModel("oid=?oid AND uid=?uid", "", new MySqlParameter("?oid", requestBody.oid), new MySqlParameter("?uid", order.sendUid)); orderUser.amount = 0; orderUser.remark = "被供应商退回抢单数据"; orderUser.createTime = 0; orderUser.status = 1; if (ouModelAdo.Update(orderUser) >= 1) { order.ostatus = 2; order.sendUid = 0; order.sendTime = 0; order.sendRemark = "被供应商退回抢单数据"; order.sendAmount = 0; if (modelAdo.Update(order) >= 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); } } #endregion #region 客服确认供应商抢单数据 else if (requestBody.action == 4) { //获取当前订单信息 ModelAdo <OrderModel> modelAdo = new ModelAdo <OrderModel>(); OrderModel order = modelAdo.GetModel("id=?oid AND ostatus=?ostatus", "", new MySqlParameter("?oid", requestBody.oid), new MySqlParameter("?ostatus", 3)); order.ostatus = 4; order.sendRemark = "客服确认供应商抢单数据"; if (order != null) { if (modelAdo.Update(order) >= 1) { //删除派单供应商对应订单中间表数据 ModelAdo <OrderUserModel> ouModelAdo = new ModelAdo <OrderUserModel>(); int delCount = ouModelAdo.ExecuteSql("DELETE FROM ct_order_user WHERE oid=?oid", new MySqlParameter("?oid", requestBody.oid)); if (delCount >= 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); } } #endregion #region 客服确认关闭已确认数据 else if (requestBody.action == 5) { //获取当前订单信息 ModelAdo <OrderModel> closeModelAdo = new ModelAdo <OrderModel>(); OrderModel closeOrder = closeModelAdo.GetModel("id=?oid AND ostatus=?ostatus", "", new MySqlParameter("?oid", requestBody.oid), new MySqlParameter("?ostatus", 4)); closeOrder.ostatus = 5; closeOrder.sendRemark = "客服确认完成订单数据"; if (closeOrder != null) { if (closeModelAdo.Update(closeOrder) >= 1) { SystemResponse.Output(SystemResponse.TYPE_OK, out statusCode, out responseJson); //删除派单供应商对应订单中间表数据 ModelAdo <OrderUserModel> ouModelAdo = new ModelAdo <OrderUserModel>(); int delCount = ouModelAdo.ExecuteSql("DELETE FROM ct_order_user WHERE oid=?oid", new MySqlParameter("?oid", requestBody.oid)); //if (delCount >= 1) //{ //} //else //{ //} } else { SystemResponse.Output(SystemResponse.TYPE_NULL, out statusCode, out responseJson); } } else { SystemResponse.Output(SystemResponse.TYPE_NULL, out statusCode, out responseJson); } } #endregion #region 其他 else { SystemResponse.Output(SystemResponse.TYPE_NULLPARAMETER, out statusCode, out responseJson); } #endregion } } }
public override void OnLoad(HttpContext context) { base.OnLoad(context); requestBody = new RequestBody(); requestBody.accessToken = context.Request["accessToken"]; requestBody.withId = Convert.ToInt32(context.Request["withId"]); requestBody.page = Convert.ToInt32(context.Request["page"]); requestBody.pageSize = Convert.ToInt32(context.Request["pageSize"]); if (requestBody.accessToken == null || requestBody.accessToken.Trim().Length == 0 || requestBody.withId == 0) { SystemResponse.Output(SystemResponse.TYPE_NULLPARAMETER, out statusCode, out responseJson); } else { //验证用户 TokenHelper token = new TokenHelper(); UserTokenModel userTokenModel = token.getUserToken(requestBody.accessToken); if (userTokenModel == null) { SystemResponse.Output(SystemResponse.TYPE_EXPIRE, out statusCode, out responseJson); } else { //获取消息列表 ModelAdo <MsgModel> modelAdo = new ModelAdo <MsgModel>(); int pagenumber = requestBody.page == 0 ? 1 : requestBody.page; int totalCount = 1; modelAdo.PageSize = requestBody.pageSize == 0 ? modelAdo.PageSize : requestBody.pageSize; List <MsgModel> models = models = modelAdo.GetList(pagenumber, "(ufrom=?ufrom AND uto=?uto) or (uto=?ufrom AND ufrom=?uto)", "createTime DESC ", out totalCount, "", new MySqlParameter("?ufrom", userTokenModel.uid), new MySqlParameter("?uto", requestBody.withId) ); if (models.Count >= 1) { //构建返回对象 List <Msg> msgs = new List <Msg>(); models.Sort(new idComparer()); foreach (MsgModel model in models) { Msg msg = new Msg(); msg.id = model.id; msg.content = model.content; msg.createTime = string.Format("{0:yyyy/MM/dd HH:mm:ss}", StringHelper.GetNomalTime(model.createTime)); msg.ufrom = model.ufrom; msg.uto = model.uto; msg.type = model.type; msg.status = model.status; msgs.Add(msg); //处理数据为已读 if (msg.status == 0) { model.status = 1; modelAdo.Update(model); } } responseBody = new ResponseBody { page = 1, pageTotal = (totalCount + modelAdo.PageSize - 1) / modelAdo.PageSize, total = totalCount, msgs = msgs }; responseJson = JsonConvert.SerializeObject(responseBody, Formatting.Indented); } else { SystemResponse.Output(SystemResponse.TYPE_NULL, out statusCode, out responseJson); } } } }
public override void OnLoad(HttpContext context) { base.OnLoad(context); requestBody = new RequestBody(); requestBody.accessToken = context.Request["accessToken"]; requestBody.uTo = Convert.ToInt32(context.Request["to"]); requestBody.content = context.Request["content"]; if (requestBody.content.Length == 0 || requestBody.accessToken.Trim().Length == 0 || requestBody.uTo == 0) { SystemResponse.Output(SystemResponse.TYPE_NULLPARAMETER, out statusCode, out responseJson); } else { //验证用户 TokenHelper token = new TokenHelper(); UserTokenModel fromModel = token.getUserToken(requestBody.accessToken); UserTokenModel toModel = token.getUserToken(requestBody.uTo); if (fromModel == null) { SystemResponse.Output(SystemResponse.TYPE_EXPIRE, out statusCode, out responseJson); } else { int msgstatus = 0; #region 入库至本地 ModelAdo <MsgModel> modelAdo = new ModelAdo <MsgModel>(); MsgModel msg = new MsgModel(); msg.ufrom = Convert.ToInt32(fromModel.uid); msg.uto = requestBody.uTo; msg.content = requestBody.content; msg.createTime = StringHelper.ConvertDateTimeInt(DateTime.Now); msg.status = msgstatus; if (modelAdo.Insert(msg) >= 1) { #region 百度推送 if (toModel != null && toModel.bpuserId.Length >= 1 && toModel.channelId.Length >= 1) { //获取插入本地数据 MsgModel msgPush = modelAdo.GetModel("ufrom=?ufrom AND uto=?uto AND createTime=?createTime AND status=0", "", new MySqlParameter("?ufrom", msg.ufrom), new MySqlParameter("?uto", msg.uto), new MySqlParameter("?createTime", msg.createTime)); if (msgPush != null) { try { //百度配置信息 string secretKey = ConfigurationManager.AppSettings["baidu_secret_key"]; string apiKey = ConfigurationManager.AppSettings["baidu_api_key"]; uint depolyStatus = uint.Parse(ConfigurationManager.AppSettings["baidu_depoly_status"]); String messages = ""; TimeSpan ts = (DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0)); uint unixTime = (uint)ts.TotalSeconds; string messageksy = "api"; uint message_type = 1; BaiduPush Bpush = new BaiduPush("POST", secretKey); if (toModel.deviceType == 1) { message_type = 1; toModel.deviceType = 4; IOSNotification notifaction = new IOSNotification(); notifaction.id = msgPush.id; notifaction.ufrom = msgPush.ufrom; notifaction.uto = msgPush.uto; notifaction.content = msgPush.content.Trim(); notifaction.createTime = string.Format("{0:yyyy/MM/dd HH:mm:ss}", System.DateTime.Now); notifaction.type = msgPush.type; notifaction.status = 1; IOSAPS aps = new IOSAPS() { alert = "收到一条新消息", }; notifaction.aps = aps; messages = notifaction.getJsonString(); } else { message_type = 0; toModel.deviceType = 3; BaiduPushNotification notifaction = new BaiduPushNotification(); notifaction.title = ""; //构建custom_content信息 BaiduDescription bdMsg = new BaiduDescription(); bdMsg.id = msgPush.id; bdMsg.ufrom = msgPush.ufrom; bdMsg.uto = msgPush.uto; bdMsg.content = msgPush.content; bdMsg.createTime = string.Format("{0:yyyy/MM/dd HH:mm:ss}", System.DateTime.Now); bdMsg.type = msgPush.type; bdMsg.status = 1; notifaction.description = "收到一条新消息"; notifaction.custom_content = bdMsg; messages = notifaction.getJsonString(); } PushOptions pOpts = new PushOptions("push_msg", apiKey, toModel.bpuserId.ToString(), toModel.channelId.ToString(), Convert.ToUInt32(toModel.deviceType), messages, messageksy, unixTime); pOpts.message_type = message_type; pOpts.deploy_status = depolyStatus; pOpts.push_type = 1; string response = Bpush.PushMessage(pOpts); responseJson = response; msgstatus = 1; //处理数据为已读 if (msg.status == 0) { msgPush.status = 1; modelAdo.Update(msgPush); } //SystemResponse.Output(SystemResponse.TYPE_OK, out statusCode, out responseJson); //responseJson = strBDMsg; } catch (Exception ex) { responseJson = ex.ToString(); SystemResponse.Output(SystemResponse.TYPE_ERROR, out statusCode, out responseJson); } } #endregion } else { SystemResponse.Output(SystemResponse.TYPE_ERROR, out statusCode, out responseJson); } #endregion } } } }
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); } } } }