/// <summary> /// 创建工单 /// </summary> /// <param name="order"></param> /// <returns></returns> public ActionResult Dispatch(string orderId, long serviceUserId, string serviceUserName, string serviceUserPhone) { try { var userId = ApiUser.Current.UserId; string serviceCompanyId = ""; string repairUserId = ""; var repairType = RepairType.App; var flag = os.Dispatch(orderId, userId, serviceUserId, serviceUserName, serviceUserPhone, ref serviceCompanyId, ref repairUserId, ref repairType); if (flag) { new Task(new Action(() => { //发送短信 SMSManager.Instance.SendNotify(serviceUserPhone, orderId.ToString()); //消息推送 var obj = new { title = "新订单提醒", content = string.Format("您有一个新的服务工单:{0}", orderId), orderId = orderId, page = string.Format("/orderDetail/{0}", orderId) }; var tagList = new List <string> { serviceCompanyId.ToString(), serviceUserId.ToString() }; var resultMsg = PushMassageHelper.Push(Newtonsoft.Json.JsonConvert.SerializeObject(obj), tagList, PushMassageHelper.AppType.WX); Logger.InfoFormat("个推推送结果{0}===={1}", serviceCompanyId, resultMsg); })).Start(); //判断报修终端 if (repairType == RepairType.Wx) { //发送公共号消息 new Task(new Action(() => { var resultMsg = os.SendWxTmpMsg(repairUserId, orderId, OrderState.Sended); Logger.InfoFormat("微信消息推送{0}===={1}", orderId, resultMsg); })).Start(); } return(Json(new { success = "派单成功" } , JsonRequestBehavior.AllowGet)); } else { return(Json(new { error = "服务器繁忙,请稍后再试试" } , JsonRequestBehavior.AllowGet)); } } catch (Exception e) { Logger.Error("派单异常", e); return(Json(new { error = "服务器繁忙,请稍后再试试" } , JsonRequestBehavior.AllowGet)); } }
/// <summary> /// 微信手工单 /// 2017-05-26 /// </summary> public ActionResult WxHandWorkOrder(MainOrder mainOrder) { long deviceId = DeviceService.Instance.WxDeviceWrite(mainOrder); if (deviceId > 0) { //创建新工单 var wxUser = Session["WxUser"] as WeiXinUser; var user = new AuthAccountServer().Get(wxUser.openid); mainOrder.MainOrderId = SequNo.NewId; mainOrder.DeviceId = deviceId; mainOrder.UserId = user.User.UserId; ServiceCompany serviceCompany = CompanyService.Instance.GetServiceCompany(mainOrder.ServiceCompanyId); var serviceUsers = UserService.Instance.ServiceCompanyUserList(mainOrder.ServiceCompanyId); //判断RepairImages 是否为空 不为空要更新图片 if (!string.IsNullOrEmpty(mainOrder.RepairImages)) { new PictureService().UpdatePicOuterId(mainOrder.RepairImages, mainOrder.MainOrderId); } var flag = OrderService.Instance.Create(mainOrder, serviceCompany); if (flag) { //判断包修人员信息有没有更改 if (mainOrder.ContactsPhone != user.User.Phone || mainOrder.Contacts != user.User.RealName || mainOrder.UseCompanyName != user.User.CompanyName) { new Task(new Action(() => { user.User.Phone = mainOrder.ContactsPhone; user.User.RealName = mainOrder.Contacts; user.User.CompanyName = mainOrder.UseCompanyName; UserService.Instance.Edit(user.User); })).Start(); } new Task(new Action(() => { if (serviceUsers != null) { foreach (var item in serviceUsers) { if (item.RoleKey == UserType.SvcCompanyUserAdmin || item.RoleKey == (UserType.UseCompanyUserAdmin | UserType.SvcCompanyUserAdmin)) { SMSManager.Instance.SendNotify(item.Phone, mainOrder.MainOrderId.ToString()); } } } //消息推送 var obj = new { title = "新订单提醒", content = string.Format("您有一个新的服务工单:{0}", mainOrder.MainOrderId), orderId = mainOrder.MainOrderId, page = string.Format("/orderDetail/{0}", mainOrder.MainOrderId) }; var tagList = new List <string> { serviceCompany.ServiceCompanyId.ToString(), "1" }; var resultMsg = PushMassageHelper.Push(Newtonsoft.Json.JsonConvert.SerializeObject(obj), tagList, PushMassageHelper.AppType.WX); Logger.InfoFormat("个推推送结果{0}===={1}", serviceCompany.ServiceCompanyId, resultMsg); })).Start(); //发送短信 //判断报修终端 if (mainOrder.RepairType == RepairType.Wx) { //发送公共号消息 new Task(new Action(() => { var resultMsg = os.SendWxTmpMsg(mainOrder.UserId, mainOrder.MainOrderId, OrderState.Created); Logger.InfoFormat("微信消息推送{0}===={1}", mainOrder.UserId, resultMsg); })).Start(); } return(Json(new { success = "创建成功", id = mainOrder.MainOrderId.ToString() }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { error = "服务器繁忙,请稍后再试试" } , JsonRequestBehavior.AllowGet)); } } else { return(Json(new { error = "服务器繁忙,请稍后再试试" } , JsonRequestBehavior.AllowGet)); } }
/// <summary> /// 创建工单 /// </summary> /// <param name="order"></param> /// <returns></returns> public ActionResult Create(MainOrder order) { try { var areaId = ApiUser.Current.AreaId; if (order.DeviceId.HasValue && order.DeviceId > 0) { var device = ds.Get(order.DeviceId.Value); areaId = device != null ? device.AreaId : ApiUser.Current.AreaId; } order.UseCompanyId = ApiUser.Current.UseCompanyId; order.ServiceCompanyId = order.ServiceCompanyId ?? ApiUser.Current.ServiceCompanyId; order.UserId = ApiUser.Current.UserId; order.AreaId = areaId; order.MainOrderId = SequNo.NewId; order.LastEditTime = DateTime.Now; //判断RepairImages 是否为空 不为空要更新图片 if (!string.IsNullOrEmpty(order.RepairImages)) { new PictureService().UpdatePicOuterId(order.RepairImages, order.MainOrderId); } var serviceCompany = cs.GetServiceCompany(order.ServiceCompanyId); var serviceUsers = new UserService().ServiceCompanyUserList(order.ServiceCompanyId); var flag = os.Create(order, ApiUser.Current, serviceCompany); if (flag) { new Task(new Action(() => { if (serviceUsers != null) { foreach (var item in serviceUsers) { if (item.RoleKey == UserType.SvcCompanyUserAdmin || item.RoleKey == (UserType.UseCompanyUserAdmin | UserType.SvcCompanyUserAdmin)) { SMSManager.Instance.SendNotify(item.Phone, order.MainOrderId.ToString()); } } } //消息推送 var obj = new { title = "新订单提醒", content = string.Format("您有一个新的服务工单:{0}", order.MainOrderId), orderId = order.MainOrderId, page = string.Format("/orderDetail/{0}", order.MainOrderId) }; var tagList = new List <string> { serviceCompany.ServiceCompanyId.ToString(), "1" }; var resultMsg = PushMassageHelper.Push(Newtonsoft.Json.JsonConvert.SerializeObject(obj), tagList, PushMassageHelper.AppType.WX); Logger.InfoFormat("个推推送结果{0}===={1}", serviceCompany.ServiceCompanyId, resultMsg); })).Start(); //发送短信 //判断报修终端 if (order.RepairType == RepairType.Wx) { //发送公共号消息 new Task(new Action(() => { var resultMsg = os.SendWxTmpMsg(order.UserId, order.MainOrderId, OrderState.Created); Logger.InfoFormat("微信消息推送{0}===={1}", order.UserId, resultMsg); })).Start(); } return(Json(new { success = "创建成功", id = order.MainOrderId.ToString() }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { error = "服务器繁忙,请稍后再试试" } , JsonRequestBehavior.AllowGet)); } } catch (Exception e) { Logger.Error("创建工单异常", e); return(Json(new { error = "服务器繁忙,请稍后再试试" } , JsonRequestBehavior.AllowGet)); } }