public static ServicePersonViewModel GetServicePerson(string customerId, string userId, string servicePersonId) { var loggingSessionInfo = Default.GetBSLoggingSession(customerId, userId); var bll = new GLServicePersonInfoBLL(loggingSessionInfo); var person = bll.GetByID(servicePersonId); var taskBll = new GLServiceTaskBLL(loggingSessionInfo); var list = taskBll.Query(new IWhereCondition[] { new EqualsCondition { DateTimeAccuracy = null, FieldName = "UserID", Value = servicePersonId } }, null); var orderCount = list.Count(task => task.ServiceDate != null && (task.ServiceDate.Value.Date == DateTime.Now.Date)); return(new ServicePersonViewModel { Mobile = person.Mobile, Name = person.Name, OrderCount = person.OrderCount, Picture = person.Picture, ServicePersonId = servicePersonId, Star = person.Star, TodayOrder = orderCount }); }
/// <summary> /// 获取所有未定预约单信息 /// </summary> /// <param name="pRequest"></param> /// <returns></returns> public string GetRunningServiceOrder(string pRequest) { var rd = new APIResponse <GetRunningServiceOrderRD>(); try { var rp = pRequest.DeserializeJSONTo <APIRequest <GetRunningServiceOrderRP> >(); if (rp.Parameters == null) { throw new ArgumentException(); } rp.Parameters.Validate(); var rdData = new GetRunningServiceOrderRD(); rdData.SubOrderList = ServiceOrderManager.Instance.GetRunningServiceOrder(); rd.Data = rdData; rd.ResultCode = 0; #region 自动保存师傅信息 try { var loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, rp.UserID); GLServicePersonInfoBLL glspiblll = new GLServicePersonInfoBLL(loggingSessionInfo); GLServicePersonInfoEntity glspie = glspiblll.GetByID(rp.UserID); if (glspie == null) { T_UserBLL bll = new T_UserBLL(loggingSessionInfo); T_UserEntity tue = bll.GetUserEntityByID(rp.UserID); string headImage = ""; //获取头像 DataSet ds = bll.GetObjectImages(rp.UserID); if (ds != null && ds.Tables != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { headImage = ds.Tables[0].Rows[0]["ImageURL"] == null ? "" : ds.Tables[0].Rows[0]["ImageURL"].ToString(); } if (tue != null) { glspie = new GLServicePersonInfoEntity(); glspie.UserID = tue.user_id; glspie.Name = tue.user_name; glspie.Mobile = tue.user_telephone; glspie.Picture = headImage; glspie.OrderCount = 0; glspie.Star = 5; glspie.CustomerID = tue.customer_id; glspiblll.Create(glspie); } } } catch (Exception ex) { } #endregion } catch (Exception ex) { rd.Message = ex.Message; rd.ResultCode = 101; } return(rd.ToJSON()); }
/// <summary> /// 提交预约订单 /// </summary> /// <param name="pRequest"></param> /// <returns></returns> private string SubmitAppOrder(string pRequest) { var rd = new APIResponse <SubmitAppOrderRD>(); var rdData = new SubmitAppOrderRD(); var rp = pRequest.DeserializeJSONTo <APIRequest <SubmitAppOrderRP> >(); if (rp.Parameters == null) { throw new ArgumentException(); } if (rp.Parameters != null) { rp.Parameters.Validate(); } var loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, rp.UserID); #region 提交预约单 //根据订单号获取订单ID GLProductOrderBLL glpobll = new GLProductOrderBLL(loggingSessionInfo); GLProductOrderEntity glpoe = glpobll.GetProductOrderByOrderNo(rp.CustomerID, rp.Parameters.OrderNO); //更新客户VipID //if (glpoe != null && !string.IsNullOrEmpty(rp.Parameters.VipID)) if (glpoe != null && !string.IsNullOrEmpty(rp.UserID)) { glpoe.VipID = rp.UserID; glpoe.CustomerGender = rp.Parameters.Gender; glpoe.CustomerName = rp.Parameters.Surname; glpobll.Update(glpoe); } //插入预约 GLServiceOrderBLL glsobll = new GLServiceOrderBLL(loggingSessionInfo); GLServiceOrderEntity glsoe = glsobll.GetGLServiceOrderEntityByOrderID(rp.CustomerID, glpoe.ProductOrderID); ServiceOrderDataAccess orderManager = new ServiceOrderDataAccess(loggingSessionInfo); if (glsoe == null) { glsoe = new GLServiceOrderEntity(); } //订单ID glsoe.ProductOrderID = glpoe.ProductOrderID; glsoe.ServiceType = rp.Parameters.ServiceType; glsoe.ServiceDate = rp.Parameters.ServiceOrderDate; glsoe.ServiceDateEnd = rp.Parameters.ServiceOrderDateEnd; glsoe.ServiceAddress = rp.Parameters.ServiceAddress; glsoe.CustomerMessage = rp.Parameters.Msg; glsoe.Latitude = Convert.ToDecimal(rp.Parameters.Latitude); glsoe.Longitude = Convert.ToDecimal(rp.Parameters.Longitude); glsoe.CustomerID = rp.CustomerID; if (!string.IsNullOrEmpty(glsoe.ServiceOrderID)) { //删除预约单 glsobll.Update(glsoe); //删除预约单设备 orderManager.DeleteInstallDeviceList(glsoe.CustomerID, glsoe.ServiceOrderID); } else { glsoe.ServiceOrderID = GreeCommon.GetGuid(); glsobll.Create(glsoe); } //插入安装设备 orderManager.SaveInstallDeviceList(glsoe, rp.Parameters.DeviceList); //预约单管理 //SubscribeOrderViewModel order = orderManager.GetSubscribeOrder(rp.CustomerID, rp.Parameters.OrderNO); SubscribeOrderViewModel order = orderManager.GetSubscribeOrderDetail(rp.CustomerID, glsoe.ServiceOrderID); ServiceOrderManager.Instance.AddServiceOrder(order); rdData.ServiceOrderNO = glsoe.ServiceOrderID; #endregion #region 推送信息给服务师傅IOS,Android消息推送 GLServicePersonInfoBLL glspibll = new GLServicePersonInfoBLL(loggingSessionInfo); DataSet dsPerson = glspibll.GetServicePerson(rp.CustomerID, string.Empty); string msg = rp.Parameters.Msg; if (dsPerson != null && dsPerson.Tables != null && dsPerson.Tables[0].Rows.Count > 0) { foreach (DataRow row in dsPerson.Tables[0].Rows) { new PushIOSMessage(loggingSessionInfo).PushMessage(row["ServicePersonID"].ToString(), msg); new PushAndroidMessage(loggingSessionInfo).PushMessage(row["ServicePersonID"].ToString(), msg); } } #endregion rd.Data = rdData; rd.ResultCode = 0; return(rd.ToJSON()); }