/// <summary> /// 关联客户端小程序 /// </summary> /// <returns></returns> public ActionResult LinkClient() { int appId = Context.GetRequestInt("appId", 0); if (appId <= 0) { return(View("PageError", new Return_Msg() { Msg = "系统繁忙appid_null!", code = "500" })); } XcxAppAccountRelation appAcountRelation = XcxAppAccountRelationBLL.SingleModel.GetModelByaccountidAndAppid(appId, dzaccount.Id.ToString()); if (appAcountRelation == null) { return(View("PageError", new Return_Msg() { Msg = "系统繁忙relation_null!", code = "500" })); } ViewBag.appId = appId; FootbathXcxRelation xcxRelation = FootbathXcxRelationBLL.SingleModel.GetModelByTechnicianAid(appId); List <XcxAppAccountRelation> clientAccountRelationList = XcxAppAccountRelationBLL.SingleModel.GetClientList(dzaccount.Id.ToString()); List <FootbathClientModel> clientModelList = new List <FootbathClientModel>(); if (clientAccountRelationList != null && clientAccountRelationList.Count > 0) { foreach (XcxAppAccountRelation client in clientAccountRelationList) { FootbathClientModel clientModel = new FootbathClientModel(); clientModel.aid = client.Id; OpenAuthorizerConfig authModel = OpenAuthorizerConfigBLL.SingleModel.GetListByaccoundidAndRid(dzaccount.Id.ToString(), client.Id).FirstOrDefault(); clientModel.xcxName = "未绑定"; if (authModel != null) { clientModel.xcxName = authModel.nick_name; } clientModel.relation = FootbathXcxRelationBLL.SingleModel.GetModelByClientAid(client.Id); clientModelList.Add(clientModel); } } if (xcxRelation != null) { xcxRelation.clientXcxName = "未绑定"; foreach (FootbathClientModel clienModel in clientModelList) { if (clienModel.aid == xcxRelation.clientAid) { xcxRelation.clientXcxName = clienModel.xcxName; } } } return(View(new { xcxRelation, clientModelList, appId })); }
/// <summary> /// 取消关联 /// </summary> /// <returns></returns> public ActionResult CancelClientLink() { int appId = Context.GetRequestInt("appId", 0); if (appId <= 0) { return(Json(new { isok = false, msg = "系统繁忙appId_null" })); } int clientAid = Context.GetRequestInt("clientAid", 0); if (clientAid <= 0) { return(Json(new { isok = false, msg = "系统繁忙clientAid_null" })); } XcxAppAccountRelation clientRelation = XcxAppAccountRelationBLL.SingleModel.GetModelByaccountidAndAppid(clientAid, dzaccount.Id.ToString()); if (clientRelation == null) { return(Json(new { isok = false, msg = "客户端小程序不存在" })); } XcxAppAccountRelation technicianRelation = XcxAppAccountRelationBLL.SingleModel.GetModelByaccountidAndAppid(appId, dzaccount.Id.ToString()); if (technicianRelation == null) { return(Json(new { isok = false, msg = "技师端小程序不存在" })); } FootbathXcxRelation XcxRelation = FootbathXcxRelationBLL.SingleModel.GetValidModel(dzaccount.Id.ToString(), technicianRelation.Id, clientRelation.Id); if (XcxRelation == null) { return(Json(new { isok = false, msg = "系统繁忙_relation_null" })); } XcxRelation.state = -1; if (FootbathXcxRelationBLL.SingleModel.Update(XcxRelation, "state")) { return(Json(new { isok = true, msg = "操作成功" })); } else { return(Json(new { isok = false, msg = "操作失败" })); } }
/// <summary> /// 关联客户端 /// </summary> /// <returns></returns> public ActionResult SaveClientLink() { int appId = Context.GetRequestInt("appId", 0); if (appId <= 0) { return(Json(new { isok = false, msg = "系统繁忙appId_null" })); } int clientAid = Context.GetRequestInt("clientAid", 0); if (clientAid <= 0) { return(Json(new { isok = false, msg = "系统繁忙clientAid_null" })); } XcxAppAccountRelation clientRelation = XcxAppAccountRelationBLL.SingleModel.GetModelByaccountidAndAppid(clientAid, dzaccount.Id.ToString()); if (clientRelation == null) { return(Json(new { isok = false, msg = "客户端小程序不存在" })); } XcxAppAccountRelation technicianRelation = XcxAppAccountRelationBLL.SingleModel.GetModelByaccountidAndAppid(appId, dzaccount.Id.ToString()); if (technicianRelation == null) { return(Json(new { isok = false, msg = "技师端小程序不存在" })); } FootbathXcxRelation clientXcxRelation = FootbathXcxRelationBLL.SingleModel.GetModelByClientAid(clientRelation.Id); if (clientXcxRelation != null) { clientXcxRelation.state = -1; if (!FootbathXcxRelationBLL.SingleModel.Update(clientXcxRelation, "state")) { return(Json(new { isok = false, msg = "系统繁忙,client_error" })); } } FootbathXcxRelation technicianXcxRelation = FootbathXcxRelationBLL.SingleModel.GetModelByTechnicianAid(technicianRelation.Id); if (technicianXcxRelation != null) { technicianXcxRelation.state = -1; if (!FootbathXcxRelationBLL.SingleModel.Update(technicianXcxRelation, "state")) { return(Json(new { isok = false, msg = "系统繁忙,technician_error" })); } } bool isok = false; string msg = string.Empty; FootbathXcxRelation model = FootbathXcxRelationBLL.SingleModel.GetModelByTechnicianAidAndClientAid(dzaccount.Id.ToString(), technicianRelation.Id, clientRelation.Id); if (model != null) { model.state = 0; isok = FootbathXcxRelationBLL.SingleModel.Update(model, "state"); } else { model = new FootbathXcxRelation(); model.clientAid = clientRelation.Id; model.technicianAid = technicianRelation.Id; model.accountId = dzaccount.Id.ToString(); isok = Convert.ToInt32(FootbathXcxRelationBLL.SingleModel.Add(model)) > 0; } msg = isok ? "操作成功" : "操作失败"; return(Json(new { isok, msg })); }