| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173 |
- using CallCenter.Utility;
- using CallCenterApi.BLL;
- using CallCenterApi.DB;
- using CallCenterApi.Interface.App_Start;
- using CallCenterApi.Interface.Controllers.Base;
- using CallCenterApi.Interface.Controllers.workorder;
- using CallCenterApi.Interface.Models.Input;
- using CallCenterAPI.WechatSDK;
- using CallCenterAPI.WechatSDK.Models;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.IO;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- namespace CallCenterApi.Interface.Controllers.weixin
- {
- public class WxLoginController : BaseController
- {
- private readonly BLL.T_Sys_UserAccount userAccountBLL = new BLL.T_Sys_UserAccount();
- private readonly BLL.T_Cus_CustomerBaseNew customerBaseBLL = new BLL.T_Cus_CustomerBaseNew();
- private readonly BLL.T_Cus_CustomerFinance finbll = new BLL.T_Cus_CustomerFinance();
- //private readonly BLL.T_Cus_RegionCategory bllCus = new T_Cus_RegionCategory();
- ///// <summary>
- ///// 绑定微信号
- ///// </summary>
- ///// <param name="wxLoginDto"></param>
- ///// <returns></returns>
- //public ActionResult Login(WxLoginDto wxLoginDto)
- //{
- // var res = Redirect("获取微信openId", wxLoginDto.RedirectUrl);
- // var temp = WxHelper.GetOpenId(wxLoginDto);
- // if (string.IsNullOrWhiteSpace(temp.OpenId))
- // return res;
- // //openId => 用户
- // //如果不存在,跳转至登录页面
- // res = Redirect("绑定微信号", "");
- // return res;
- //}
- /// <summary>
- /// 绑定微信号 - 员工和业主分开登陆
- /// </summary>
- /// <param name="login"></param>
- /// <returns></returns>
- public ActionResult Login(WxLoginDto login)
- {
- #region 把其他OpenId更新为空
- var userAccount = userAccountBLL.GetModelByOpenid(login.OpenId);
- if (userAccount != null)
- {
- userAccount.F_WxOpenId = "";
- userAccountBLL.Update(userAccount);
- }
- var modelcustomer = customerBaseBLL.GetModelList(" F_WxOpenId='" + login.OpenId + "'").FirstOrDefault(); //customerBaseBLL.GetModelByOpenid(login.OpenId);
- if (modelcustomer != null)
- {
- modelcustomer.F_WxOpenId = "";
- customerBaseBLL.Update(modelcustomer);
- }
- #endregion
- if (login.UserType == 1)
- {
- Dictionary<string, string> paras = new Dictionary<string, string>();
- string sql = " select * from T_Sys_UserAccount (NOLOCK) where F_UserCode=@F_UserCode and F_PassWord=@F_PassWord and F_DeleteFlag = 0 ";
- paras.Add("@F_UserCode", login.UserCode);
- paras.Add("@F_PassWord", login.Password);
- var dt = DbHelperSQL.Query(sql, paras).Tables[0];
- if (dt != null && dt.Rows.Count > 0)
- {
- //var user = userAccountBLL.GetModel(login.UserCode); //20180926 次方法查询有漏洞
- var user = userAccountBLL.DataTableToList(dt).ToList().FirstOrDefault();
- user.F_WxOpenId = login.OpenId;
- int UserType = 0;
- //部门
- Model.T_Sys_Department modelDep = new BLL.T_Sys_Department().GetModel(user.F_DeptId);
- if (modelDep == null)
- return Error("获取失败!");
- #region 部门角色
- //部门角色(-1管理员,1接待部,2案场经理、项目负责人,3销售部总经理、物业部总经理、工程总经理、设计总经理,4区域客服,5业主(客户档案))
- if (user.F_RoleId == 17 || user.F_RoleId == 57)
- {
- //-1管理员
- UserType = -1;
- }
- else
- {
- UserType = 0;
- #region
- ////部门操作权限:1接待部,2办理人员,3区域客服,4监管
- //if (modelDep.F_Type == 1)
- //{
- // //1--接待部
- // UserType = 1;
- //}
- //else if (modelDep.F_Type == 2)
- //{
- // //2--办理人员
- // UserType = 2;
- //}
- //else if (modelDep.F_Type == 3)
- //{
- // //3--区域客服
- // UserType = 3;
- //}
- //else if (modelDep.F_Type == 4)
- //{
- // //4--监管
- // UserType = 4;
- //}
- //else
- //{
- // UserType = 0;
- //}
- #endregion
- }
- #endregion
- var obj = new
- {
- openid = login.OpenId,
- usercode = login.UserCode,
- usertype = UserType
- };
- if (userAccountBLL.Update(user))
- return Success("绑定成功", obj);
- else
- return Error("绑定失败");
- }
- return Error("账号或密码错误,请重新登录");
- }
- else if (login.UserType == 5)
- {
- //客户档案登录 - 用戶信息不存在时,登录客户档案业主账号
- Dictionary<string, string> paras_Customer = new Dictionary<string, string>();
- // F_RelationShipClassID IN (1,2) 用户类型:0来电用户; 1准业主; 2不是准业主或是亲戚朋友
- //首次密码默认为身份证后6位信息
- //F_CustomerClassID >= 0 为业主或租户,且F_RelationShipClassID = 0为会员账号 2、登录最早的信息
- string sql_Customer = " select * from dbo.T_Cus_CustomerBaseNew (NOLOCK) where F_CustomerCode=@F_UserCode and F_WxPassword=@F_PassWord and F_DeleteFlag = 0 ORDER BY F_CreatedOn ASC ";
- paras_Customer.Add("@F_UserCode", login.UserCode);
- paras_Customer.Add("@F_PassWord", login.Password);
- var dt_Customer = DbHelperSQL.Query(sql_Customer, paras_Customer).Tables[0];
- if (dt_Customer != null && dt_Customer.Rows.Count > 0)
- {
- //var customer = customerBaseBLL.GetModel(login.UserCode); //20180926 次方法查询有漏洞
- var customer = customerBaseBLL.DataTableToList(dt_Customer).ToList().FirstOrDefault();
- customer.F_WxOpenId = login.OpenId;
- #region 新加 - 登录后同时获取用户账号,openid,和角色
- //5--业主(客户档案会员)
- //int UserType = 5;
- var obj = new
- {
- openid = login.OpenId,
- usercode = login.UserCode,
- companyname = customer.F_CompanyName,
- companyaddress=customer.F_CompanyAddress,
- };
- #endregion
- if (customerBaseBLL.Update(customer))
- return Success("绑定成功!", obj);
- else
- return Error("绑定失败!");
- }
- return Error("账号或密码错误或者没有注册,请重新登录");
- }
- return Error("绑定失败");
- }
- /// <summary>
- /// 绑定微信号 - 员工和业主统一登陆 - 不用
- /// </summary>
- /// <param name="login"></param>
- /// <returns></returns>
- //[WechatActionFilter]
- public ActionResult Login2(WxLoginDto login)
- {
- Dictionary<string, string> paras = new Dictionary<string, string>();
- string sql = " select * from T_Sys_UserAccount (NOLOCK) where F_UserCode=@F_UserCode and F_PassWord=@F_PassWord and F_DeleteFlag = 0 ";
- paras.Add("@F_UserCode", login.UserCode);
- paras.Add("@F_PassWord", login.Password);
- var dt = DbHelperSQL.Query(sql, paras).Tables[0];
- #region 把其他OpenId更新为空
- var userAccount = userAccountBLL.GetModelByOpenid(login.OpenId);
- if (userAccount != null)
- {
- userAccount.F_WxOpenId = "";
- userAccountBLL.Update(userAccount);
- }
- var modelcustomer = customerBaseBLL.GetModelList(" F_WxOpenId='" + login.OpenId + "'").FirstOrDefault();//.GetModelByOpenid(login.OpenId);
- if (modelcustomer != null)
- {
- modelcustomer.F_WxOpenId = "";
- customerBaseBLL.Update(modelcustomer);
- }
- #endregion
- if (dt != null && dt.Rows.Count > 0)
- {
- var user = userAccountBLL.GetModel(login.UserCode);
- user.F_WxOpenId = login.OpenId;
- //int UserType = 0;
- //部门
- Model.T_Sys_Department modelDep = new BLL.T_Sys_Department().GetModel(user.F_DeptId);
- if (modelDep == null)
- return Error("获取失败!");
- #region 部门角色
- ////部门角色(-1管理员,1接待部,2案场经理、项目负责人,3销售部总经理、物业部总经理、工程总经理、设计总经理,4区域客服,5业主(客户档案))
- //if (user.F_RoleId == 17)
- //{
- // //-1管理员
- // UserType = -1;
- //}
- //else
- //{
- // //部门操作权限:1接待部,2办理人员,3区域客服,4监管
- // if (modelDep.F_Type == 1)
- // {
- // //1--接待部
- // UserType = 1;
- // }
- // else if (modelDep.F_Type == 2)
- // {
- // //2--办理人员
- // UserType = 2;
- // }
- // else if (modelDep.F_Type == 3)
- // {
- // //3--区域客服
- // UserType = 3;
- // }
- // else if (modelDep.F_Type == 4)
- // {
- // //4--监管
- // UserType = 4;
- // }
- // else
- // {
- // UserType = 0;
- // }
- //}
- #endregion
- var obj = new
- {
- openid = login.OpenId,
- usercode = login.UserCode,
- //usertype = UserType
- };
- if (userAccountBLL.Update(user))
- {
- return Success("绑定成功", obj);
- }
- else
- {
- return Error("绑定失败");
- }
- }
- else
- {
- //客户档案登录 - 用戶信息不存在时,登录客户档案业主账号
- Dictionary<string, string> paras_Customer = new Dictionary<string, string>();
- // F_RelationShipClassID IN (1,2) 用户类型:0来电用户; 1准业主; 2不是准业主或是亲戚朋友
- //首次密码默认为身份证后6位信息
- //F_CustomerClassID >= 0 为业主或租户,且F_RelationShipClassID = 0为会员账号 2、登录最早的信息
- string sql_Customer = " select * from dbo.T_Cus_CustomerBaseNew (NOLOCK) where F_CustomerCode=@F_UserCode and F_PassWord=@F_PassWord and F_DeleteFlag = 0 ";
- paras_Customer.Add("@F_UserCode", login.UserCode);
- paras_Customer.Add("@F_PassWord", login.Password);
- var dt_Customer = DbHelperSQL.Query(sql_Customer, paras_Customer).Tables[0];
- if (dt_Customer != null && dt_Customer.Rows.Count > 0)
- {
- var customer = customerBaseBLL.GetModelList(" F_CustomerCode='" + login.UserCode + "'").FirstOrDefault(); //customerBaseBLL.GetModel(login.UserCode);
- customer.F_WxOpenId = login.OpenId;
- #region 新加 - 登录后同时获取用户账号,openid,和角色
- //5--业主(客户档案会员)
- //int UserType = 5;
- var obj = new
- {
- openid = login.OpenId,
- usercode = login.UserCode,
- //usertype = UserType
- };
- #endregion
- if (customerBaseBLL.Update(customer))
- {
- return Success("绑定成功!", obj);
- }
- else
- {
- return Error("绑定失败!");
- }
- }
- else
- {
- return Error("账号或密码错误,请重新登录");
- }
- //return Error("账号或密码错误,请重新登录");
- }
- }
- /// <summary>
- /// 获取微信openid
- /// </summary>
- /// <param name="login"></param>
- /// <returns></returns>
- public ActionResult GetOpenId(WxLoginDto wld)
- {
- wld.RedirectUrl = RequestString.GetUrlReferrer();
- if (string.IsNullOrEmpty(wld.OpenId))
- {
- var temp = WxHelper.GetOpenId(wld);
- if (string.IsNullOrWhiteSpace(temp.OpenId))
- {
- return Redirect("请求", temp.RedirectUrl);
- }
- wld.OpenId = temp.OpenId;
- #region 获取是否绑定用户表
- //获取是否绑定用户表
- var usertemp = new BLL.T_Sys_UserAccount().GetModelByOpenid(wld.OpenId);
- if (usertemp != null)
- {
- //部门
- Model.T_Sys_Department modelDep = new BLL.T_Sys_Department().GetModel(usertemp.F_DeptId);
- if (modelDep == null)
- return Error("获取失败!");
- wld.UserCode = usertemp.F_UserCode;
- #region 部门角色
- if (usertemp.F_RoleId == 17)
- {
- //-1管理员
- wld.UserType = -1;
- }
- else
- {
- wld.UserType = 0;
- #region
- ////部门操作权限:1接待部,2办理人员,3区域客服,4监管
- //if (modelDep.F_Type == 1)
- //{
- // //1--接待部
- // wld.UserType = 1;
- //}
- //else if (modelDep.F_Type == 2)
- //{
- // //2--办理人员
- // wld.UserType = 2;
- //}
- //else if (modelDep.F_Type == 3)
- //{
- // //3--区域客服
- // wld.UserType = 3;
- //}
- //else if (modelDep.F_Type == 4)
- //{
- // //4--监管
- // wld.UserType = 4;
- //}
- //else
- //{
- // wld.UserType = 0;
- //}
- #endregion
- }
- #endregion
- }
- else
- {
- var customertemp = customerBaseBLL.GetModelByOpenid(wld.OpenId);
- if (customertemp != null)
- {
- wld.UserCode = customertemp.F_CustomerCode;
- //5--业主(客户档案会员)
- wld.UserType = 5;
- }
- else
- {
- wld.UserCode = "";
- }
- //wld.UserCode = "";
- }
- #endregion
- }
- var model = new BLL.T_Sys_Users().GetModel(wld.OpenId);
- if (model == null)
- {
- model = new Model.T_Sys_Users();
- model.F_OpenId = wld.OpenId;
- model.F_Type = 1;
- model.F_CreateTime = DateTime.Now;
- new BLL.T_Sys_Users().Add(model);
- }
- var newobj = new
- {
- openid = wld.OpenId,
- usercode = wld.UserCode,
- usertype = wld.UserType,
- };
- return Success("成功", newobj);
- }
-
- /// <summary>
- /// 修改密码
- /// </summary>
- /// <returns></returns>
- [WechatActionFilter]
- public ActionResult UpdatePassWord()
- {
- string stropenid = HttpUtility.UrlDecode(RequestString.GetFormString("openid"));
- //5--业主(客户档案会员)
- int usertype = RequestString.GetInt("usertype", 0);
- //原密码
- string oldpwd = RequestString.GetFormString("oldpwd").Trim();
- string pwd = RequestString.GetFormString("pwd").Trim();
- string repeatpwd = RequestString.GetFormString("repeatpwd").Trim();
- if (usertype == 0)
- return Error("无权修改密码");
- if (string.IsNullOrWhiteSpace(oldpwd))
- return Error("请输入原密码");
- if (string.IsNullOrWhiteSpace(pwd))
- return Error("请输入新密码");
- if (string.IsNullOrWhiteSpace(repeatpwd))
- return Error("请再次输入新密码");
- if (!pwd.Equals(repeatpwd))
- return Error("两个新密码不同,请重新输入");
- var model = new Model.T_Sys_UserAccount();
- var modelCus = new Model.T_Cus_CustomerBaseNew();
- //坐席表
- if (usertype < 5)
- {
- model = userAccountBLL.GetModelByOpenid(stropenid);
- if (model != null)
- {
- if (!model.F_Password.Equals(oldpwd)) return Error("原密码不正确");
- model.F_Password = pwd;
- if (userAccountBLL.Update(model))
- return Success("重置密码成功");
- }
- return Error("重置密码失败");
- }
- //客户档案表
- modelCus = customerBaseBLL.GetModelList(" F_WxOpenId='" + stropenid + "'").FirstOrDefault();//customerBaseBLL.GetModelByOpenid(stropenid);
- if (modelCus != null)
- {
- if (!modelCus.F_WxPassword.Equals(oldpwd)) return Error("原密码不正确");
- modelCus.F_WxPassword = pwd;
- if (customerBaseBLL.Update(modelCus))
- return Success("重置密码成功");
- }
- return Error("重置密码失败");
- }
- #region
- workorder.WoBillController blcon = new WoBillController();
- /// <summary>
- /// 获取所有业务
- /// </summary>
- /// <returns></returns>
- [WechatActionFilter]
- public ActionResult GetBusList()
- {
- var list = blcon.GetBusAllList();
- return Success("获取信息列表成功", list);
- }
- /// <summary>
- /// 获取业务内容
- /// </summary>
- /// <returns></returns>
- [WechatActionFilter]
- public ActionResult GetBusInfo()
- {
- string strbusid = HttpUtility.UrlDecode(RequestString.GetQueryString("busid"));
- if (string.IsNullOrEmpty(strbusid))
- return Error("参数错误");
- var model = blcon.GetBusInfo(strbusid);
- if (model != null)
- return Success("获取信息成功", model);
- else
- return Error("获取信息失败");
- }
- /// <summary>
- /// 获取开票列表
- /// </summary>
- /// <returns></returns>
- [WechatActionFilter]
- public ActionResult GetBillList()
- {
- DataTable dt = new DataTable();
- string stropenid = HttpUtility.UrlDecode(RequestString.GetQueryString("openid"));
- string strbtime = HttpUtility.UrlDecode(RequestString.GetQueryString("btime"));
- string stretime = HttpUtility.UrlDecode(RequestString.GetQueryString("etime"));
- string strpageindex = RequestString.GetQueryString("pageindex");
- int pageindex = 1;
- string strpagesize = RequestString.GetQueryString("pagesize");
- int pagesize = 10;
- if (strpageindex.Trim() != "")
- {
- pageindex = Convert.ToInt32(strpageindex);
- }
- if (strpagesize.Trim() != "")
- {
- pagesize = Convert.ToInt32(strpagesize);
- }
- var obj=blcon.GetLists(stropenid, strbtime, stretime, pageindex, pagesize);
- return Content(obj.ToJson());
- }
- /// <summary>
- /// 获取开票详情
- /// </summary>
- /// <returns></returns>
- [WechatActionFilter]
- public ActionResult GetBillInfo()
- {
- string strbillid = HttpUtility.UrlDecode(RequestString.GetQueryString("billid"));
- if (string.IsNullOrEmpty(strbillid))
- return Error("参数错误");
- var model = blcon.GetBillInfo(strbillid);
- if (model != null)
- return Success("获取信息成功", model);
- else
- return Error("获取信息失败");
- }
- /// <summary>
- /// 开票
- /// </summary>
- /// <returns></returns>
- [WechatActionFilter]
- public ActionResult AddBill()
- {
- string billtype = RequestString.GetFormString("billtype");//发票类型
- string cusname = RequestString.GetFormString("cusname");//客户名称
- string taxidnum = RequestString.GetFormString("taxidnum");//纳税人识别号
- string address = RequestString.GetFormString("address");//地址
- string phone = RequestString.GetFormString("phone");//电话
- string bank = RequestString.GetFormString("bank");//开户行
- string bankaccount = RequestString.GetFormString("bankaccount");//开户行账号
- string proname = RequestString.GetFormString("proname");//项目名称
- string models = RequestString.GetFormString("models");//型号
- string unit = RequestString.GetFormString("unit");//单位
- string amount = RequestString.GetFormString("amount");//数量
- string unitprice = RequestString.GetFormString("unitprice");//单价
- string sumprice = RequestString.GetFormString("sumprice");//金额
- string taxrate = RequestString.GetFormString("taxrate");//税率
- string taxamount = RequestString.GetFormString("taxamount");//税额
- string billingMethod = RequestString.GetFormString("billingmethod");//开票方式:快递/自取
- string billingTime = RequestString.GetFormString("billingtime");//开票时间
- string remark = RequestString.GetFormString("remark");//备注
- string stropenid = HttpUtility.UrlDecode(RequestString.GetFormString("openid"));
- Model.T_Wo_Bill dModel = new Model.T_Wo_Bill();
- #region 保存基本信息
- dModel.F_BillType = billtype;
- dModel.F_CusName = cusname;
- dModel.F_TaxIDNum = taxidnum;
- dModel.F_Address = address;
- dModel.F_Phone = phone;
- dModel.F_Bank = bank;
- dModel.F_BankAccount = bankaccount;
- dModel.F_ProName = proname;
- dModel.F_Models = models;
- dModel.F_Unit = unit;
- dModel.F_Amount = amount;
- dModel.F_UnitPrice = unitprice;
- dModel.F_SumPrice = sumprice;
- dModel.F_TaxRate = taxrate;
- dModel.F_TaxAmount = taxamount;
- dModel.F_BillingMethod = billingMethod;
- dModel.F_BillingTime = billingTime;
- dModel.F_Remark = remark;
- dModel.F_Openid = stropenid;
- dModel.F_CreateOn = DateTime.Now;
- dModel.F_State = 0;
- #endregion
- var res=blcon.addbills(dModel);
- if (res)
- return Success("保存成功");
- else
- return Error("保存失败");
- }
- #endregion
- #region 获取公司详情
- //获取公司信息
- [WechatActionFilter]
- public ActionResult GetInfo()
- {
- string stropenid = HttpUtility.UrlDecode(RequestString.GetQueryString("openid"));
- var model=customerBaseBLL.GetModelByOpenid(stropenid);
- if (model != null)
- {
- var obj = new
- {
- model.F_CompanyName,//公司名称
- model.F_CompanyLogo,//logo
- model.F_CustomerCode,//编号
- model.F_CycleStart,//服务周期-开始时间
- model.F_CycleEnd,//服务周期-结束时间
- model.F_ChargeType,//收费类型:1月度,2季度,3年度
- model.F_Charges,//收费
- model.F_TaxNumber,//公司税号
- model.F_CompanyAddress,//公司地址
- };
- return Success("获取成功", obj);
- }
- return Error("获取失败");
- }
- //获取财税信息
- //[WechatActionFilter]
- public ActionResult GetFinc()
- {
- string stropenid = HttpUtility.UrlDecode(RequestString.GetQueryString("openid"));
- var model = customerBaseBLL.GetModelByOpenid(stropenid);
- if (model != null)
- {
- var finmodel = finbll.GetModelList(" F_CustomerId=" + model.F_CustomerId).FirstOrDefault();
- if (finmodel != null)
- {
- var obj = new
- {
- model.F_CompanyName,//公司名称
- model.F_CompanyLogo,//logo
- model.F_CustomerCode,//编号
- finmodel.F_CusFinId,
- finmodel.F_CustomerId,
- finmodel.F_MonthState,
- finmodel.F_AnnualIncome,
- finmodel.F_AnnualProfit,
- finmodel.F_AnnualCost,
- finmodel.F_AnnualPersonCount,
- finmodel.F_AnnualWages,
- finmodel.F_QuarterlyCost,
- finmodel.F_QuarterlyPersonCount,
- finmodel.F_QuarterlyWages,
- finmodel.F_QuarterlyIncome,
- finmodel.F_QPVAT,
- finmodel.F_QPSurtax,
- finmodel.F_QPTaxes,
- finmodel.F_QPConTax,
- finmodel.F_QPPerinTax,
- finmodel.F_QPStampTax,
- finmodel.F_QPOtherTax
- };
- return Success("获取成功", obj);
- }
- }
- return Error("获取失败");
- }
- #endregion
- #region 工单
- /// <summary>
- /// 工单列表
- /// </summary>
- //[WechatActionFilter]
- public ActionResult GetWoList()
- {
- workorder.WorkOrderController wo = new workorder.WorkOrderController();
- var config = new BLL.T_Sys_SystemConfig().GetModelList(" F_ParamCode='TimeLimitDays' ").FirstOrDefault();
- int days = config != null ? Convert.ToInt32(config.F_ParamValue) : 60; //默认60天
- DataTable dt = new DataTable();
- int recordCount = 0;
- string stropenid = HttpUtility.UrlDecode(RequestString.GetQueryString("openid"));
- //客户姓名,电话,工单号
- string keyword = HttpUtility.UrlDecode(RequestString.GetQueryString("keyword"));
- //工单状态
- int states = RequestString.GetInt("states", -1);
- string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
- string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
- string strpageindex = RequestString.GetQueryString("page");
- int pageindex = 1;
- string strpagesize = RequestString.GetQueryString("pagesize");
- int pagesize = 10;
- #region sql 语句相关处理
- string sql = " ";
- //获取坐席表信息
- var ua = userAccountBLL.GetModelList(" F_WxOpenId='" + stropenid + "'").FirstOrDefault();
- //获取客户档案(业主)表信息
- var modelCustomer = customerBaseBLL.GetModelList(" F_WxOpenId='" + stropenid.Trim() + "'").FirstOrDefault();
-
- if (!string.IsNullOrEmpty(sql))
- {
- sql += " and IsDel=0 ";
- //客户姓名,电话,房间号,工单号,接待描述
- if (!string.IsNullOrEmpty(keyword))
- {
- sql += " and (CustomerTel like '%" + keyword + "%' or Customer like '%" + keyword + "%' or WorkOrderID like '%" + keyword + "%' or Detail like '%" + keyword + "%' ) ";
- }
- if (states >= 0)
- {
- #region 权限限制
- if (ua != null)
- {
- string uwhere = " ";
- switch (states)
- {
- case 0://待指派的
- //sql += " and State ='0' and CreateUser= '" + ua.F_UserCode + "' ";
- //3区域客服可以看到区域待指派工单
- if (ua.F_RoleId != 17)
- {
- uwhere += " and CreateUser='" + ua.F_UserCode + "' ";
- }
- sql += " and State =0 " + uwhere;
- break;
- case 1://待接单的
- sql += " and State =1 and WorkOrderID in ( '" + wo.GetDJDWorkOrderID(ua.F_UserCode) + "') ";
- break;
- case 2://待完成的(待处理)
- sql += " and State =1 and WorkOrderID in ( '" + wo.GetDWCWorkOrderID(ua.F_UserCode) + "') ";
- break;
- case 3://已完成的
- sql += " and State =2 and LastDealUser = '" + ua.F_UserCode + "' ";
- break;
- case 4://我参与的
- sql += " and (CreateUser= '" + ua.F_UserCode + "' or WorkOrderID in ( '" + wo.GetCYWorkOrderID(ua.F_UserCode) + "')) ";
- break;
- case 5://超期工单 - 设置两个月的处理时效,两个月内未解决的工单都直接汇总到这里
- sql += $" and DATEADD(DAY,{days},CreateTime) < GETDATE() AND State < 2 ";
- break;
- }
- }
- else if (modelCustomer != null)
- {
- sql += " and CustomerID=" + modelCustomer.F_CustomerId;
- }
- else
- {
- sql = "";
- }
- #endregion
- }
- if (strstarttime.Trim() != "" && strstarttime != "undefined")
- {
- sql += " and datediff(day,CreateTime,'" + strstarttime + "')<=0 ";
- }
- if (strendtime.Trim() != "" && strendtime != "undefined")
- {
- sql += " and datediff(day,CreateTime,'" + strendtime + "')>=0 ";
- }
- #endregion
- if (strpageindex.Trim() != "")
- {
- pageindex = Convert.ToInt32(strpageindex);
- }
- if (strpagesize.Trim() != "")
- {
- pagesize = Convert.ToInt32(strpagesize);
- }
- string cols = "*,dbo.GetDictionaryName(Source) as GDLYName,dbo.GetDictionaryName(Type) as GDLXName,dbo.GetDictionaryName(TypeClass) as TypeClassName,dbo.GetUserName(CreateUser) as CreateUserNameRel,dbo.GetUserName(LastDealUser) as LastDealUserNameRel,dbo.GetUserName(AuditUser) as AuditUserNameRel,dbo.GetDeptName(ResponDept) as ResponDeptName";
- dt = BLL.PagerBLL.GetListPager(
- "T_Wo_WorkOrder (NOLOCK)",
- "WorkOrderID",
- cols,
- sql,
- "ORDER BY CreateTime DESC,State asc",
- pagesize,
- pageindex,
- true,
- out recordCount);
- }
- var obj = new
- {
- state = "success",
- message = "成功",
- rows = dt,
- total = recordCount
- };
- return Content(obj.ToJson());
- }
- /// <summary>
- /// 工单详情
- /// </summary>
- [WechatActionFilter]
- public ActionResult GetWoInfo()
- {
- string strworkorderid = HttpUtility.UrlDecode(RequestString.GetQueryString("workorderid"));
- string stropenid = HttpUtility.UrlDecode(RequestString.GetQueryString("openid"));
- if (string.IsNullOrEmpty(strworkorderid))
- return Error("参数错误");
- if (string.IsNullOrEmpty(stropenid))
- return Error("参数错误!");
- string sql = "select *,dbo.GetDictionaryName(Type) as GDLXName,dbo.GetDictionaryName(TypeClass) as YWLXName,dbo.GetDictionaryName(Source) as GDLYName,dbo.GetUserName(CreateUser) as CreateUserName,dbo.GetUserName(LastDealUser) as LastDealUserNameRel,dbo.GetUserName(AuditUser) as AuditUserNameRel,dbo.GetUserName(ResponUser) as ResponUserName,dbo.GetDeptName(ResponDept) AS ComplaintDepartment "
- + " from T_Wo_WorkOrder where WorkOrderID ='" + strworkorderid + "' ";
- var dt = DbHelperSQL.Query(sql).Tables[0];
- if (dt.Rows.Count > 0)
- {
- var config = new BLL.T_Sys_SystemConfig().GetModelList(" F_ParamCode='PlayPath' ").FirstOrDefault();
- var configfj = new BLL.T_Sys_SystemConfig().GetModelList(" F_ParamCode='FileUrlPath' ").FirstOrDefault();
- if (configfj != null)
- {
- dt = BindFileData(dt, configfj.F_ParamValue);
- }
- string gcsql = "select *,dbo.GetUserName(ToUser) as ToUserName, dbo.GetDeptName(ToDept) as ToDeptName,dbo.GetUserName(SureUser) as SureUserName,dbo.GetUserName(DealUser) as DealUserName,dbo.GetUserName(CreateUser) as CreateUserName,case Type when 1 then convert(decimal(18,2),DATEDIFF(minute, CreateTime, ISNULL(DealTime, GETDATE()))/60.00) else 0 end as totalhour "
- + "from T_Wo_WorkOrderItem where IsDel=0 and WorkOrderID ='" + dt.Rows[0]["WorkOrderId"] + "'";
- var gcdt = DbHelperSQL.Query(gcsql).Tables[0];
- dt.Columns.Add("FilePath", typeof(string));
- if (configfj != null || config != null)
- {
- foreach (DataRow bldr in dt.Rows)
- {
- if (bldr["CallID"] != null && config != null)
- {
- bldr["FilePath"] = GetCallPath(bldr["CallID"].ToString(), config.F_ParamValue);
- }
- }
- }
- var obj = new
- {
- data = dt,
- item = gcdt
- };
- return Success("查询成功", obj);
- }
- return Error("查询失败");
- }
-
- /// <summary>
- /// 处理工单
- /// </summary>
- /// <returns></returns>
- [WechatActionFilter]
- public ActionResult DealWorkOrder()
- {
- DataTable dt = new DataTable();
- string orderid = RequestString.GetFormString("orderid");
- int isend = RequestString.GetInt("isend", 0); //处理方式 1结束 0转派
- //int ltype = RequestString.GetInt("ltype", 0); //处理方式 1结束 0转派
- int clbm = RequestString.GetInt("clbm", 0); //部门id
- int clid = RequestString.GetInt("clid", 0); //用户接收人id
- string cont = RequestString.GetFormString("cont"); //处理内容
- //string detail = RequestString.GetFormString("detail");
- string stropenid = HttpUtility.UrlDecode(RequestString.GetFormString("openid"));
- workorder.WorkOrderController wo = new workorder.WorkOrderController();
- bool res = wo.DealWXWorkOrder(orderid, isend, clbm, clid, cont, stropenid);
- if (res)
- {
- return Success("操作成功");
- }
- else
- {
- return Error("操作失败");
- }
- }
- /// <summary>
- /// 接单 - 确认工单
- /// </summary>
- /// <returns></returns>
- [WechatActionFilter]
- public ActionResult SureWorkOrder()
- {
- string stropenid = HttpUtility.UrlDecode(RequestString.GetFormString("openid"));
- string orderid = RequestString.GetFormString("orderid");
- if (!string.IsNullOrEmpty(stropenid))
- {
- var ua = new BLL.T_Sys_UserAccount().GetModelList(" F_WxOpenId='" + stropenid + "'").FirstOrDefault();
- if (ua != null)
- {
- Model.T_Wo_WorkOrder model = new BLL.T_Wo_WorkOrder().GetModelList(" WorkOrderID='" + orderid + "'").FirstOrDefault();
- if (model != null)
- {
- Model.T_Wo_WorkOrderItem item = new BLL.T_Wo_WorkOrderItem().GetModelList(" WorkOrderID='" + orderid + "' and isdel=0 and Type=1 ").OrderByDescending(p => p.CreateTime).FirstOrDefault();
- if (item != null && item.State == 0 && ("," + item.ToUser + ",").Contains("," + ua.F_UserCode + ","))
- {
- item.SureUser = ua.F_UserCode;
- item.State = 1;
- item.SureTime = DateTime.Now;
- if (new BLL.T_Wo_WorkOrderItem().Update(item))
- {
- return Success("接单成功!");
- }
- }
- return Error("操作失败,工单还没有派单!");
- }
- }
- return Error("操作失败");
- }
- return Error("参数错误");
- }
- #endregion
- #region 微信工单
- ///// <summary>
- ///// 获取工单列表
- ///// </summary>
- ///// <returns></returns>
- //[WechatActionFilter]
- //public ActionResult GetList()
- //{
- // workorder.WorkOrderController wo = new workorder.WorkOrderController();
- // var config = new BLL.T_Sys_SystemConfig().GetModelList(" F_ParamCode='TimeLimitDays' ").FirstOrDefault();
- // int days = config != null ? Convert.ToInt32(config.F_ParamValue) : 60; //默认60天
- // DataTable dt = new DataTable();
- // int recordCount = 0;
- // string stropenid = HttpUtility.UrlDecode(RequestString.GetQueryString("openid"));
- // //客户姓名,电话,房间号,工单号
- // string keyword = HttpUtility.UrlDecode(RequestString.GetQueryString("keyword"));
- // //工单状态(ltype:)
- // string strltype = HttpUtility.UrlDecode(RequestString.GetQueryString("ltype"));
- // //工单状态
- // int states = RequestString.GetInt("states", -1);
- // //工单来源
- // int strtype = RequestString.GetInt("type", 0);
- // //工单类型
- // int strtypeclass = RequestString.GetInt("typeclass", 0);
- // //工单起止时间
- // string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
- // string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
- // //来电单位
- // string lddep = HttpUtility.UrlDecode(RequestString.GetQueryString("lddep"));
- // //20180329 来电弹屏工单记录根据反馈单位获取列表 可以看到同一坐席组的所有人的工单记录
- // string fkdep = HttpUtility.UrlDecode(RequestString.GetQueryString("fkdep"));
- // int isldtp = RequestString.GetQueryInt("isldtp", 0);
- // //微信列表(0未审核微信列表,1已审核微信列表)
- // int isaudit = RequestString.GetInt("isaudit", -1);
- // string strpageindex = RequestString.GetQueryString("page");
- // int pageindex = 1;
- // string strpagesize = RequestString.GetQueryString("pagesize");
- // int pagesize = 10;
- // #region sql 语句相关处理
- // string sql = " ";
- // //获取坐席表信息
- // var ua = userAccountBLL.GetModelList(" F_WxOpenId='" + stropenid + "'").FirstOrDefault();
- // //获取客户档案(业主)表信息
- // var modelCustomer = customerBaseBLL.GetModelList(" F_WxOpenId='" + stropenid.Trim() + "'").FirstOrDefault();
- // #region 权限限制
- // string mobile = "", roomno = "";
- // int customerid = 0, areaid = 0, proid = 0, buildingid = 0;
- // if (ua != null)
- // {
- // int deptid = ua.F_DeptId; //部门id
- // string deptCode = ua.F_DeptCode; //部门code
- // int userRegionId = ua.RegionId; //项目id
- // //部门信息
- // var modelDep = new BLL.T_Sys_Department().GetModel(deptid);
- // int depType = 0, depRegion = 0;
- // if (modelDep != null)
- // {
- // depType = modelDep.F_Type ?? 0; //部门操作权限:1接待部,2办理人员,3区域客服,4监管
- // depRegion = modelDep.F_Header ?? 0; //部门权限范围:9全部,1区域,2项目,3期
- // }
- // if (ua.F_RoleId != 17)
- // {
- // if (depType == 2)
- // {
- // if (depRegion == 1)
- // {
- // // 查看该区域工单
- // //sql += $" and IsUserSend = (SELECT TOP 1 F_ParentId FROM dbo.T_Cus_RegionCategory WHERE F_RegionId = {userRegionId}) ";
- // sql += $" and IsUserSend = {userRegionId} ";
- // }
- // else if (depRegion == 2)
- // {
- // // 查看该项目工单
- // sql += $" and IsAdminSend = {userRegionId} ";
- // }
- // }
- // else if (depType == 3)
- // {
- // if (depRegion == 1)
- // {
- // // 查看该区域工单
- // //sql += $" and IsUserSend = (SELECT TOP 1 F_ParentId FROM dbo.T_Cus_RegionCategory WHERE F_RegionId = {userRegionId}) ";
- // sql += $" and IsUserSend = {userRegionId} ";
- // }
- // }
- // else if (depType == 4)
- // {
- // if (depRegion == 2)
- // {
- // // 查看该项目工单
- // sql += $" and IsAdminSend = {userRegionId} ";
- // }
- // else if (depRegion == 9)
- // {
- // // 查看该部门工单(包括一级,二级)
- // string deptCodeNew = String.Empty;
- // int deptCodeIndex = 0; //变量声明
- // string deptCodeN = deptCode.TrimEnd('|'); //去掉最后一个|
- // deptCodeIndex = deptCodeN.LastIndexOf("|"); //获得|的索引
- // deptCodeNew = deptCodeN.Substring(0, deptCodeIndex + 1); //获得目标字符串(//去掉最后一个|后面的字符串)
- // //============== 部门权限条件 - 部门 ================
- // string arrUser = " select F_UserCode from T_Sys_UserAccount where F_DeptCode LIKE '" + deptCodeNew + "%' ";
- // sql += $" and WorkOrderID in (SELECT DISTINCT WorkOrderID FROM dbo.T_Wo_WorkOrderItem WHERE ToUser IN ({arrUser})) ";
- // }
- // }
- // }
- // string uwhere = " ";
- // switch (strltype)
- // {
- // case "0"://待指派的
- // //sql += " and State ='0' and CreateUser= '" + ua.F_UserCode + "' ";
- // if (ua.F_RoleId != 17 && depType != 1 && depType != 3)
- // {
- // uwhere += " and CreateUser='" + ua.F_UserCode + "' ";
- // }
- // sql += " and State ='0' " + uwhere;
- // break;
- // case "1"://待接单的
- // sql += " and State ='1' and WorkOrderID in ( '" + wo.GetDJDWorkOrderID(ua.F_UserCode) + "') ";
- // break;
- // case "2"://待完成的
- // sql += " and State ='1' and WorkOrderID in ( '" + wo.GetDWCWorkOrderID(ua.F_UserCode) + "') ";
- // break;
- // case "3"://已完成的
- // sql += " and State ='2' and LastDealUser = '" + ua.F_UserCode + "' ";
- // break;
- // case "4"://我参与的
- // sql += " and (CreateUser= '" + ua.F_UserCode + "' or WorkOrderID in ( '" + wo.GetCYWorkOrderID(ua.F_UserCode) + "')) ";
- // break;
- // case "5"://超期工单 - 设置两个月的处理时效,两个月内未解决的工单都直接汇总到这里
- // sql += $" and DATEADD(DAY,{days},CreateTime) < GETDATE() AND State < 2 ";
- // break;
- // }
- // }
- // else if (modelCustomer != null)
- // {
- // #region 根据openid获取所有工单号
- // //var wxuser = new BLL.T_Sys_Users().GetModelList(" F_OpenId='" + stropenid.Trim() + "' and F_Type=1 ").FirstOrDefault();
- // //if (wxuser != null)
- // //{
- // // sql += " and id in (select distinct F_WorkOrderID from T_WO_UserWorkOrder where F_UserId='" + wxuser.F_Id + "') ";
- // //}
- // #endregion
- // // ============== 项目权限 - 项目 ============== 不通过项目查询,因为客户可能有多个项目的房产
- // // ============== 电话,区域,项目,楼号,房间号权限条件 - 电话 ================
- // //通过相关电话,区域,项目,楼号,房间号(CustomerTel,IsUserSend,IsAdminSend,IsTimeOut,Address)查询该用户查看的工单
- // //mobile = modelCustomer.F_LegalTel;
- // customerid = modelCustomer.F_CustomerId;
- // //int CustomerClassID = modelCustomer.F_CustomerClassID ?? 0;
- // ////F_Layer区域id F_CategoryId所购项目id F_CustomerType楼号 F_BusinessLicenseID房间号
- // //areaid = modelCustomer.F_Layer ?? 0;
- // //proid = modelCustomer.F_CategoryId ?? 0;
- // //buildingid = modelCustomer.F_CustomerType ?? 0;
- // //roomno = modelCustomer.F_BusinessLicenseID;
- // ////查询业主和相关的亲属租户名下工单
- // //sql += $" and CustomerTel IN (SELECT DISTINCT F_Mobile FROM dbo.T_Cus_CustomerBase WHERE F_CustomerClassID = {customerid} OR F_CustomerId = {customerid}) ";
- // //if (CustomerClassID == 0)
- // //{
- // // //业主查看房屋所有工单
- // // sql += $" and CustomerID IN (SELECT DISTINCT F_CustomerId FROM dbo.T_Cus_CustomerBase WHERE F_CustomerClassID = {customerid} OR F_CustomerId = {customerid}) ";
- // //}
- // //else
- // //{
- // // //租户只可查看自己工单
- // // sql += $" and CustomerID = {customerid} ";
- // //}
- // ////查询相关房间号下工单
- // //if (areaid > 0 && proid > 0 && buildingid > 0 && !string.IsNullOrEmpty(roomno))
- // //{
- // // sql += $" and F_Layer = {areaid} and F_CategoryId = {proid} and F_CustomerType = {buildingid} and F_BusinessLicenseID = '{roomno}' ";
- // //}
- // }
- // else
- // {
- // sql = "";
- // }
- // #endregion
- // if (!string.IsNullOrEmpty(sql))
- // {
- // sql += " and IsDel=0 ";
- // //客户姓名,电话,房间号,工单号,接待描述
- // if (!string.IsNullOrEmpty(keyword))
- // {
- // sql += " and (CustomerTel like '%" + keyword + "%' or Customer like '%" + keyword + "%' or Address like '%" + keyword + "%' or WorkOrderID like '%" + keyword + "%' or Detail like '%" + keyword + "%' ) ";
- // }
- // if (isaudit >= 0)
- // {
- // sql += " and IsAudit = " + isaudit + " "; // ANd Type = (SELECT F_DictionaryValueId FROM dbo.T_Sys_DictionaryValue (NOLOCK) WHERE F_DictionaryFlag = 'GDLY' AND F_Name = '微信')
- // }
- // if (states >= 0)
- // sql += " and State = " + states + " ";
- // if (strtype > 0)
- // {
- // sql += " and Type = " + strtype + " ";
- // }
- // if (strtypeclass > 0)
- // {
- // sql += " and TypeClass = " + strtypeclass + " ";
- // }
- // if (lddep.Trim() != "" && lddep != "undefined")
- // {
- // sql += " and Address = '" + lddep.Trim() + "' ";
- // }
- // if (fkdep.Trim() != "" && fkdep != "undefined")
- // {
- // sql += " and Source = '" + fkdep.Trim() + "' ";
- // }
- // if (strstarttime.Trim() != "" && strstarttime != "undefined")
- // {
- // sql += " and datediff(day,CreateTime,'" + strstarttime + "')<=0 ";
- // }
- // if (strendtime.Trim() != "" && strendtime != "undefined")
- // {
- // sql += " and datediff(day,CreateTime,'" + strendtime + "')>=0 ";
- // }
- // #endregion
- // if (strpageindex.Trim() != "")
- // {
- // pageindex = Convert.ToInt32(strpageindex);
- // }
- // if (strpagesize.Trim() != "")
- // {
- // pagesize = Convert.ToInt32(strpagesize);
- // }
- // string cols = "*,dbo.GetDictionaryName(Source) as GDLYName,dbo.GetDictionaryName(Type) as GDLXName,dbo.GetDictionaryName(TypeClass) as TypeClassName,dbo.GetUserName(CreateUser) as CreateUserNameRel,dbo.GetUserName(LastDealUser) as LastDealUserNameRel,dbo.GetUserName(AuditUser) as AuditUserNameRel,dbo.GetDeptName(ResponDept) as ResponDeptName";
- // dt = BLL.PagerBLL.GetListPager(
- // "T_Wo_WorkOrder (NOLOCK)",
- // "WorkOrderID",
- // cols,
- // sql,
- // "ORDER BY CreateTime DESC",
- // pagesize,
- // pageindex,
- // true,
- // out recordCount);
- // }
- // var obj = new
- // {
- // state = "success",
- // message = "成功",
- // rows = dt,
- // total = recordCount
- // };
- // return Content(obj.ToJson());
- //}
- ///// <summary>
- ///// 获取可催办工单列表
- ///// </summary>
- ///// <returns></returns>
- //[WechatActionFilter]
- //public ActionResult GetNotDoneWorkList()
- //{
- // workorder.WorkOrderController wo = new workorder.WorkOrderController();
- // DataTable dt = new DataTable();
- // int recordCount = 0;
- // string stropenid = HttpUtility.UrlDecode(RequestString.GetQueryString("openid"));
- // //客户姓名,电话,房间号,工单号
- // string keyword = HttpUtility.UrlDecode(RequestString.GetQueryString("keyword"));
- // //工单状态
- // string strltype = HttpUtility.UrlDecode(RequestString.GetQueryString("ltype"));
- // //工单状态
- // int states = RequestString.GetInt("states", -1);
- // //工单来源
- // int strtype = RequestString.GetInt("type", 0);
- // //工单类型
- // int strtypeclass = RequestString.GetInt("typeclass", 0);
- // //工单起止时间
- // string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
- // string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
- // //区域id
- // int areaid = RequestString.GetInt("areaid", 0);
- // //项目id
- // int regionid = RequestString.GetInt("regionid", 0);
- // //期id
- // int buldingid = RequestString.GetInt("buldingid", 0);
- // string uid = HttpUtility.UrlDecode(RequestString.GetQueryString("userid") == "" ? "0" : HttpUtility.UrlDecode(RequestString.GetQueryString("userid")));
- // string strpageindex = RequestString.GetQueryString("page");
- // int pageindex = 1;
- // string strpagesize = RequestString.GetQueryString("pagesize");
- // int pagesize = 10;
- // string sql = " and isdel=0 and State != 2 ";
- // //获取坐席表信息
- // var ua = userAccountBLL.GetModelList(" F_WxOpenId='" + stropenid + "'").FirstOrDefault();
- // //获取客户档案(业主)表信息
- // var modelCustomer = customerBaseBLL.GetModelList(" F_WxOpenId='" + stropenid.Trim() + "'").FirstOrDefault();
- // if (ua != null)
- // {
- // #region 权限限制
- // int deptid = ua.F_DeptId; //部门id
- // string deptCode = ua.F_DeptCode; //部门code
- // int userRegionId = ua.RegionId; //项目id
- // //部门信息
- // var modelDep = new BLL.T_Sys_Department().GetModel(deptid);
- // int depType = 0, depRegion = 0;
- // if (modelDep != null)
- // {
- // depType = modelDep.F_Type ?? 0; //部门操作权限:1接待部,2办理人员,3区域客服,4监管
- // depRegion = modelDep.F_Header ?? 0; //部门权限范围:9全部,1区域,2项目,3期
- // }
- // if (ua.F_RoleId != 17)
- // {
- // if (depType == 2)
- // {
- // if (depRegion == 1)
- // {
- // // 查看该区域工单
- // //sql += $" and IsUserSend = (SELECT TOP 1 F_ParentId FROM dbo.T_Cus_RegionCategory WHERE F_RegionId = {userRegionId}) ";
- // sql += $" and IsUserSend = {userRegionId} ";
- // }
- // else if (depRegion == 2)
- // {
- // // 查看该项目工单
- // sql += $" and IsAdminSend = {userRegionId} ";
- // }
- // }
- // else if (depType == 3)
- // {
- // if (depRegion == 1)
- // {
- // // 查看该区域工单
- // //sql += $" and IsUserSend = (SELECT TOP 1 F_ParentId FROM dbo.T_Cus_RegionCategory WHERE F_RegionId = {userRegionId}) ";
- // sql += $" and IsUserSend = {userRegionId} ";
- // }
- // }
- // else if (depType == 4)
- // {
- // if (depRegion == 2)
- // {
- // // 查看该项目工单
- // sql += $" and IsAdminSend = {userRegionId} ";
- // }
- // else if (depRegion == 9)
- // {
- // // 查看该部门工单(包括一级,二级)
- // string deptCodeNew = String.Empty;
- // int deptCodeIndex = 0; //变量声明
- // string deptCodeN = deptCode.TrimEnd('|'); //去掉最后一个|
- // deptCodeIndex = deptCodeN.LastIndexOf("|"); //获得|的索引
- // deptCodeNew = deptCodeN.Substring(0, deptCodeIndex + 1); //获得目标字符串(//去掉最后一个|后面的字符串)
- // //============== 部门权限条件 - 部门 ================
- // string arrUser = " select F_UserCode from T_Sys_UserAccount where F_DeptCode LIKE '" + deptCodeNew + "%' ";
- // sql += $" and WorkOrderID in (SELECT DISTINCT WorkOrderID FROM dbo.T_Wo_WorkOrderItem WHERE ToUser IN ({arrUser})) ";
- // }
- // }
- // }
- // #endregion
- // //客户姓名,电话,房间号,工单号
- // if (!string.IsNullOrEmpty(keyword))
- // {
- // sql += " and (CustomerTel like '%" + keyword + "%' or Customer like '%" + keyword + "%' or Address like '%" + keyword + "%' or WorkOrderID like '%" + keyword + "%' ) ";
- // }
- // if (states >= 0)
- // sql += " and State = " + states + " ";
- // if (areaid > 0)
- // sql += " and IsUserSend = " + areaid + " ";
- // if (regionid > 0)
- // sql += " and IsAdminSend = " + regionid + " ";
- // if (buldingid > 0)
- // sql += " and IsTimeOut = " + buldingid + " ";
- // //坐席工号
- // if (uid.Trim() != "" && uid != "0")
- // {
- // sql += " and CreateUser = '" + uid + "' ";
- // }
- // if (strtype > 0)
- // {
- // sql += " and Type = " + strtype + " ";
- // }
- // if (strtypeclass > 0)
- // {
- // sql += " and TypeClass = " + strtype + " ";
- // }
- // if (strstarttime.Trim() != "" && strstarttime != "undefined")
- // {
- // sql += " and datediff(day,CreateTime,'" + strstarttime + "')<=0 ";
- // }
- // if (strendtime.Trim() != "" && strendtime != "undefined")
- // {
- // sql += " and datediff(day,CreateTime,'" + strendtime + "')>=0 ";
- // }
- // if (strpageindex.Trim() != "")
- // {
- // pageindex = Convert.ToInt32(strpageindex);
- // }
- // if (strpagesize.Trim() != "")
- // {
- // pagesize = Convert.ToInt32(strpagesize);
- // }
- // dt = BLL.PagerBLL.GetListPager(
- // "T_Wo_WorkOrder",
- // "T_Wo_WorkOrder.ID",
- // "*,(SELECT F_RegionName FROM dbo.T_Cus_RegionCategory WHERE F_RegionId = dbo.T_Wo_WorkOrder.IsUserSend) AS areaname,(SELECT F_RegionName FROM dbo.T_Cus_RegionCategory WHERE F_RegionId = dbo.T_Wo_WorkOrder.IsAdminSend) AS proname,(SELECT F_RegionName FROM dbo.T_Cus_RegionCategory WHERE F_RegionId = dbo.T_Wo_WorkOrder.IsTimeOut) AS buildingname,dbo.GetDictionaryName(Type) as GDLYName,dbo.GetDictionaryName(Ownerrelationsid) as OwnerrelationsName,dbo.GetDictionaryName(TypeClass) as TypeClassName,dbo.GetUserName(CreateUser) as CreateUserNameRel,dbo.GetUserName(LastDealUser) as LastDealUserNameRel,dbo.GetUserName(AuditUser) as AuditUserNameRel,(SELECT TOP 1 F_DeptName FROM dbo.T_Sys_Department WHERE F_DeptId = Source) AS complaintTypeName",
- // sql,
- // "ORDER BY T_Wo_WorkOrder.ID desc",
- // pagesize,
- // pageindex,
- // true,
- // out recordCount);
- // dt.Columns.Add("CBCount", typeof(int));
- // foreach (DataRow dr in dt.Rows)
- // {
- // var list = new BLL.T_Wo_WorkOrderItem().GetList(" WorkOrderID='" + dr["WorkOrderID"].ToString() + "' and IsDel=0 and Type=2 and ','+ToUser+',' like ',%" + ua.F_UserCode + "%,' ").Tables[0];
- // dr["CBCount"] = list.Rows.Count;
- // }
- // }
- // var obj = new
- // {
- // state = "success",
- // message = "成功",
- // rows = dt,
- // total = recordCount
- // };
- // return Content(obj.ToJson());
- //}
- ///// <summary>
- ///// 新增工单
- ///// </summary>
- ///// <returns></returns>
- //[WechatActionFilter]
- //public ActionResult AddWorkOrder()
- //{
- // DataTable dt = new DataTable();
- // //工单来源
- // int gdly = RequestString.GetFormInt("gdly", 0);
- // //工单类型
- // int gdlx = RequestString.GetFormInt("gdlx", 0);
- // //客户id
- // int customerid = RequestString.GetFormInt("customerid", 0);
- // //客户姓名
- // string callCustomer = RequestString.GetFormString("callCustomer");
- // //联系电话
- // string tel = RequestString.GetFormString("tel");
- // //处理部门
- // string fkdep = RequestString.GetFormString("fkdep");
- // //客服类类型
- // string kfdepid = RequestString.GetFormString("kfdepid");
- // //受理人 - 审核人工号
- // string auditusercode = RequestString.GetFormString("auditusercode");
- // //工单状态
- // int gdzt = RequestString.GetFormInt("gdzt", 0);
- // //接待描述 - 反馈内容
- // string fkcont = RequestString.GetFormString("fkcont");
- // string callid = HttpUtility.UrlDecode(RequestString.GetFormString("callid"));
- // string files = RequestString.GetFormString("files");
- // //咨询类工单指派部门
- // int clbm = RequestString.GetFormInt("clbm", 0);
- // //备注
- // string note = RequestString.GetFormString("note");
- // #region 添加验证判断
- // if (string.IsNullOrEmpty(callCustomer))
- // return Error("姓名不能为空!");
- // if (string.IsNullOrEmpty(tel))
- // return Error("电话不能为空!");
- // #endregion
- // string workOrder = DateTime.Now.ToString("yyyyMMddHHmmssfff"); //工单编号
- // string stropenid = HttpUtility.UrlDecode(RequestString.GetFormString("openid"));
- // var wxuser = new BLL.T_Sys_Users().GetModelList(" F_OpenId='" + stropenid.Trim() + "' and F_Type=1 ").FirstOrDefault();
- // var model = userAccountBLL.GetModelByOpenid(stropenid);
- // var modelCustomer = customerBaseBLL.GetModelList(" F_WxOpenId='" + stropenid.Trim() + "'").FirstOrDefault(); //customerBaseBLL.GetModelByOpenid(stropenid);
- // string usercode = "";
- // if (model != null)
- // {
- // usercode = model.F_UserCode;
- // }
- // else if (modelCustomer != null)
- // {
- // usercode = modelCustomer.F_CustomerCode;
- // customerid = modelCustomer.F_CustomerId;
- // }
- // workorder.WorkOrderController wo = new workorder.WorkOrderController();
- // string workorderid = wo.AddWXWorkOrder(workOrder, gdly, gdlx, customerid, callCustomer, tel, fkdep, kfdepid, auditusercode, fkcont, files, gdzt, note, usercode,-1);
- // if (string.IsNullOrEmpty(workorderid))
- // {
- // return Error("新增失败");
- // }
- // else
- // {
- // #region 咨询类工单指派至部门
- // //工单类型(107咨询,108投诉)
- // if (gdlx == 107)
- // {
- // //需要审核后,再处理
- // //bool b = wo.DealWXWorkOrder(workOrder, 0, 0, clbm, 0, "", fkcont, stropenid);
- // }
- // #endregion
- // //暂时排除客户档案用户(F_UserId无法区分是住户添加 还是管理员添加) - 后期完善
- // if (wxuser != null)
- // {
- // Model.T_WO_UserWorkOrder tbu = new Model.T_WO_UserWorkOrder();
- // tbu.F_UserId = wxuser.F_Id;
- // tbu.F_WorkOrderId = workorderid;
- // new BLL.T_WO_UserWorkOrder().Add(tbu);
- // }
- // return Success("新增成功", workorderid);
- // }
- //}
- ///// <summary>
- ///// 修改工单
- ///// </summary>
- ///// <returns></returns>
- //[WechatActionFilter]
- //public ActionResult UpdateWorkOrder()
- //{
- // DataTable dt = new DataTable();
- // //工单id
- // string workorderid = RequestString.GetFormString("orderid");
- // //工单来源
- // int gdly = RequestString.GetFormInt("gdly", 0);
- // //工单类型
- // int gdlx = RequestString.GetFormInt("gdlx", 0);
- // //客户id
- // int customerid = RequestString.GetFormInt("customerid", 0);
- // //客户姓名
- // string callCustomer = RequestString.GetFormString("callCustomer");
- // //联系电话
- // string tel = RequestString.GetFormString("tel");
- // //处理部门
- // string fkdep = RequestString.GetFormString("fkdep");
- // //客服类类型
- // string kfdepid = RequestString.GetFormString("kfdepid");
- // //受理人 - 审核人工号
- // string auditusercode = RequestString.GetFormString("auditusercode");
- // //接待描述 - 反馈内容
- // string fkcont = RequestString.GetFormString("fkcont");
- // string files = RequestString.GetFormString("files");
- // //备注
- // string note = RequestString.GetFormString("note");
- // string stropenid = HttpUtility.UrlDecode(RequestString.GetFormString("openid"));
- // //var wxuser = new BLL.T_Sys_Users().GetModelList(" F_OpenId='" + stropenid.Trim() + "' and F_Type=1 ").FirstOrDefault();
- // if (!string.IsNullOrEmpty(stropenid))
- // {
- // var ua = new BLL.T_Sys_UserAccount().GetModelList(" F_WxOpenId='" + stropenid + "'").FirstOrDefault();
- // if (ua != null)
- // {
- // WorkOrderController wo = new WorkOrderController();
- // if (!string.IsNullOrEmpty(workorderid))
- // {
- // var models = new BLL.T_Wo_WorkOrder().GetModelList(" WorkOrderID='" + workorderid + "'");
- // if (models.Count > 0)
- // {
- // var model = models.FirstOrDefault();
- // string detail = model.Detail;
- // model.Type = gdly; //工单来源
- // model.TypeClass = gdlx; //投诉类型 -工单类型
- // model.Customer = callCustomer; //客户姓名
- // model.CustomerTel = tel; //联系电话
- // //model.CustomerID = customerid; //用户档案Id
- // model.Source = fkdep; //处理部门 反馈单位
- // model.CreateUserID = kfdepid; //客服类类型
- // model.AuditUser = auditusercode; //受理人 - 审核人工号
- // //model.CreateUser = ua.F_UserCode; //接待人(工号)
- // //model.State = 0; //工单状态
- // //反馈内容
- // var detailutf8 = System.Web.HttpUtility.UrlDecode(fkcont, System.Text.Encoding.UTF8);
- // model.Detail = detailutf8;
- // if (new BLL.T_Wo_WorkOrder().Update(model))
- // {
- // //添加工单修改操作日志
- // wo.WriteWorkOrderLog(workorderid, detail, detailutf8, ua.F_UserCode, 0, "", 1, "修改工单(微信端)");
- // return Success("修改成功!");
- // }
- // }
- // }
- // }
- // }
- // return Error("修改失败!");
- //}
- ///// <summary>
- ///// 处理工单
- ///// </summary>
- ///// <returns></returns>
- //[WechatActionFilter]
- //public ActionResult DealWorkOrder()
- //{
- // DataTable dt = new DataTable();
- // string orderid = RequestString.GetFormString("orderid");
- // int isend = RequestString.GetInt("isend", 0); //0转派
- // int ltype = RequestString.GetInt("ltype", 0); //处理方式 1结束 0转派
- // int clbm = RequestString.GetInt("clbm", 0); //部门id
- // int clid = RequestString.GetInt("clid", 0); //用户接收人id
- // string cont = RequestString.GetFormString("cont"); //处理内容
- // string detail = RequestString.GetFormString("detail");
- // string stropenid = HttpUtility.UrlDecode(RequestString.GetFormString("openid"));
- // workorder.WorkOrderController wo = new workorder.WorkOrderController();
- // bool res = wo.DealWXWorkOrder(orderid, isend, ltype, clbm, clid, cont, detail, stropenid);
- // if (res)
- // {
- // return Success("操作成功");
- // }
- // else
- // {
- // return Error("操作失败");
- // }
- //}
- ///// <summary>
- ///// 接单 - 确认工单
- ///// </summary>
- ///// <returns></returns>
- //[WechatActionFilter]
- //public ActionResult SureWorkOrder()
- //{
- // string stropenid = HttpUtility.UrlDecode(RequestString.GetFormString("openid"));
- // string orderid = RequestString.GetFormString("orderid");
- // if (!string.IsNullOrEmpty(stropenid))
- // {
- // var ua = new BLL.T_Sys_UserAccount().GetModelList(" F_WxOpenId='" + stropenid + "'").FirstOrDefault();
- // if (ua != null)
- // {
- // Model.T_Wo_WorkOrder model = new BLL.T_Wo_WorkOrder().GetModelList(" WorkOrderID='" + orderid + "'").FirstOrDefault();
- // if (model != null)
- // {
- // Model.T_Wo_WorkOrderItem item = new BLL.T_Wo_WorkOrderItem().GetModelList(" WorkOrderID='" + orderid + "' and isdel=0 and Type=1 ").OrderByDescending(p => p.CreateTime).FirstOrDefault();
- // if (item != null && item.State == 0 && ("," + item.ToUser + ",").Contains("," + ua.F_UserCode + ","))
- // {
- // item.SureUser = ua.F_UserCode;
- // item.State = 1;
- // item.SureTime = DateTime.Now;
- // if (new BLL.T_Wo_WorkOrderItem().Update(item))
- // {
- // return Success("接单成功!");
- // }
- // }
- // return Error("操作失败,工单还没有派单!");
- // }
- // }
- // return Error("操作失败");
- // }
- // return Error("参数错误");
- //}
- ///// <summary>
- ///// 催办工单(管理员,业主)
- ///// </summary>
- ///// <returns></returns>
- //[WechatActionFilter]
- //public ActionResult RemindWorkOrder()
- //{
- // string stropenid = HttpUtility.UrlDecode(RequestString.GetFormString("openid"));
- // if (!string.IsNullOrEmpty(stropenid))
- // {
- // var ua = new BLL.T_Sys_UserAccount().GetModelList(" F_WxOpenId='" + stropenid + "'").FirstOrDefault();
- // string usercode = string.Empty;
- // string username = string.Empty;
- // if (ua != null)
- // {
- // usercode = ua.F_UserCode;
- // username = ua.F_UserName;
- // }
- // else
- // {
- // //获取客户档案(业主)表信息
- // var modelCustomer = customerBaseBLL.GetModelList(" F_WxOpenId='" + stropenid.Trim() + "'").FirstOrDefault();
- // if (modelCustomer != null)
- // {
- // usercode = modelCustomer.F_CustomerCode;
- // username = modelCustomer.F_CompanyName;
- // }
- // }
- // if (string.IsNullOrEmpty(usercode))
- // return Error("参数错误!");
- // string orderid = RequestString.GetFormString("orderid");
- // string cont = RequestString.GetFormString("cont");
- // string callid = RequestString.GetFormString("callid");
- // Model.T_Wo_WorkOrder model = new BLL.T_Wo_WorkOrder().GetModelList(" WorkOrderID='" + orderid + "'").FirstOrDefault();
- // if (model != null)
- // {
- // Model.T_Wo_WorkOrderItem itemlast = new BLL.T_Wo_WorkOrderItem().GetModelList(" WorkOrderID='" + orderid + "' and IsDel=0 and Type=1 and (State=0 or State=1) ").FirstOrDefault();
- // Model.T_Wo_WorkOrderItem item = new Model.T_Wo_WorkOrderItem();
- // if (itemlast != null)
- // {
- // item.ToDept = itemlast.ToDept;
- // item.ToUser = itemlast.ToUser;
- // }
- // else
- // {
- // var cu = new BLL.T_Sys_UserAccount().GetModel(model.CreateUser);
- // if (cu != null)
- // {
- // item.ToDept = cu.F_DeptId;
- // item.ToUser = cu.F_UserCode;
- // }
- // else {
- // var modelCus = customerBaseBLL.GetModelList(" F_CustomerCode='" + model.CreateUser + "'").FirstOrDefault(); //customerBaseBLL.GetModel(model.CreateUser);
- // if (modelCus != null)
- // {
- // item.ToDept = 0;
- // item.ToUser = modelCus.F_LegalTel;
- // }
- // }
- // }
- // item.WorkOrderID = orderid;
- // item.Type = 2;
- // item.Detail = cont;
- // item.CallID = callid;
- // item.State = 0;
- // item.IsDel = 0;
- // item.IsLast = 0;
- // item.IsStart = 0;
- // item.IsTimeOut = 0;
- // item.CreateUser = usercode; // ua.F_UserCode;
- // item.CreateTime = DateTime.Now;
- // long itemid = new BLL.T_Wo_WorkOrderItem().Add(item);
- // if (itemid > 0 && !string.IsNullOrEmpty(item.ToUser))
- // {
- // foreach (string ur in item.ToUser.Split(','))
- // {
- // Model.T_Msg_List msg = new Model.T_Msg_List();
- // msg.Type = 1;
- // msg.ToUser = ur;
- // msg.ToID = Int32.Parse(itemid.ToString());
- // msg.Detail = username + "向你催办了工单,单号:" + model.WorkOrderID;
- // msg.State = 0;
- // msg.IsDel = 0;
- // msg.CreateUser = usercode;
- // msg.CreateDate = DateTime.Now;
- // new BLL.T_Msg_List().Add(msg);
- // }
- // return Success("催办成功!");
- // }
- // }
- // }
- // return Error("参数错误");
- //}
- ///// <summary>
- ///// 退回工单
- ///// </summary>
- ///// <param name="input"></param>
- ///// <returns></returns>
- //[WechatActionFilter]
- //public ActionResult BackWorkOrder()
- //{
- // string stropenid = HttpUtility.UrlDecode(RequestString.GetFormString("openid"));
- // if (!string.IsNullOrEmpty(stropenid))
- // {
- // var ua = new BLL.T_Sys_UserAccount().GetModelList(" F_WxOpenId='" + stropenid + "'").FirstOrDefault();
- // if (ua != null)
- // {
- // string orderid = RequestString.GetFormString("orderid");
- // var model = new BLL.T_Wo_WorkOrder().GetModelList(" WorkOrderID='" + orderid + "'").FirstOrDefault();
- // //验证信息
- // if (model == null)
- // {
- // return Error("工单不存在");
- // }
- // model.State = 0;
- // if (new BLL.T_Wo_WorkOrder().Update(model))
- // {
- // var modelItem = new BLL.T_Wo_WorkOrderItem().GetModelList(" IsDel=0 and Type=1 and (state='0' and ','+ToUser+',' like '%," + ua.F_UserCode + ",%') and WorkOrderID = '" + orderid + "' ").FirstOrDefault();
- // if (modelItem != null)
- // {
- // modelItem.State = 6;
- // new BLL.T_Wo_WorkOrderItem().Update(modelItem);
- // }
- // return Success("操作成功");
- // }
- // return Error("操作失败");
- // }
- // }
- // return Error("操作失败");
- //}
- ///// <summary>
- ///// 评论工单(管理人员,业主)
- ///// </summary>
- ///// <returns></returns>
- //[WechatActionFilter]
- //public ActionResult CommentWorkOrder()
- //{
- // string stropenid = HttpUtility.UrlDecode(RequestString.GetFormString("openid"));
- // if (!string.IsNullOrEmpty(stropenid))
- // {
- // var ua = new BLL.T_Sys_UserAccount().GetModelList(" F_WxOpenId='" + stropenid + "'").FirstOrDefault();
- // string usercode = string.Empty;
- // string username = string.Empty;
- // if (ua != null)
- // {
- // usercode = ua.F_UserCode;
- // username = ua.F_UserName;
- // }
- // else
- // {
- // //获取客户档案(业主)表信息
- // var modelCustomer = customerBaseBLL.GetModelList(" F_WxOpenId='" + stropenid.Trim() + "'").FirstOrDefault();
- // if (modelCustomer != null)
- // {
- // usercode = modelCustomer.F_CustomerCode;
- // username = modelCustomer.F_CompanyName;
- // }
- // }
- // if (string.IsNullOrEmpty(usercode))
- // return Error("参数错误!");
- // string orderid = RequestString.GetFormString("orderid");
- // string cont = RequestString.GetFormString("cont");
- // string file = RequestString.GetFormString("file");
- // Model.T_Wo_WorkOrder model = new BLL.T_Wo_WorkOrder().GetModelList(" WorkOrderID='" + orderid + "'").FirstOrDefault();
- // if (model != null)
- // {
- // Model.T_Wo_WorkOrderItem item = new Model.T_Wo_WorkOrderItem();
- // item.WorkOrderID = orderid;
- // item.Type = 3; //评论
- // item.Detail = cont;
- // item.Files = file;
- // item.State = 0;
- // item.IsDel = 0;
- // item.IsStart = 0;
- // item.IsTimeOut = 0;
- // item.IsLast = 0;
- // item.CreateUser = usercode;
- // item.CreateTime = DateTime.Now;
- // if (new BLL.T_Wo_WorkOrderItem().Add(item) > 0)
- // {
- // return Success("评论成功!");
- // }
- // }
- // }
- // return Error("操作失败");
- //}
- ///// <summary>
- ///// 刪除工单
- ///// </summary>
- ///// <returns></returns>
- //[WechatActionFilter]
- //public ActionResult DelWorkOrder(string[] ids)
- //{
- // string stropenid = HttpUtility.UrlDecode(RequestString.GetFormString("openid"));
- // if (!string.IsNullOrEmpty(stropenid))
- // {
- // var ua = new BLL.T_Sys_UserAccount().GetModelList(" F_WxOpenId='" + stropenid + "'").FirstOrDefault();
- // if (ua != null)
- // {
- // if (ids != null && ids.Length > 0)
- // {
- // string idd = " ";
- // foreach (string str in ids)
- // {
- // idd += str + ",";
- // }
- // string sql = "update T_Wo_WorkOrder set IsDel=1,DelUser='" + ua.F_UserCode + "',DelTime=getdate() where ID in (" + idd.TrimEnd(',') + ")";
- // if (!string.IsNullOrEmpty(idd.Trim()))
- // {
- // if (DbHelperSQL.ExecuteSql(sql) > 0)
- // {
- // return Success("删除成功");
- // }
- // }
- // else
- // {
- // return Error("请选择记录");
- // }
- // }
- // else
- // {
- // return Error("获取参数失败");
- // }
- // }
- // }
- // return Error("操作失败");
- //}
- ///// <summary>
- ///// 获取工单详情
- ///// </summary>
- ///// <returns></returns>
- //[WechatActionFilter]
- //public ActionResult GetWorkOrder()
- //{
- // string strworkorderid = HttpUtility.UrlDecode(RequestString.GetQueryString("workorderid"));
- // string stropenid = HttpUtility.UrlDecode(RequestString.GetQueryString("openid"));
- // if (string.IsNullOrEmpty(strworkorderid))
- // return Error("参数错误");
- // if (string.IsNullOrEmpty(stropenid))
- // return Error("参数错误!");
- // #region pc端工单也可以查看,所以注释(注释功能只能查看自己创建的工单)
- // //var wxuser = new BLL.T_Sys_Users().GetModelList(" F_OpenId='" + stropenid.Trim() + "' and F_Type=1 ").FirstOrDefault();
- // //if (wxuser != null)
- // //{
- // // var tbu = new BLL.T_WO_UserWorkOrder().GetList(" F_UserId='" + wxuser.F_Id + "' and F_WorkOrderId=" + strworkorderid + " ").Tables[0];
- // // if (tbu.Rows.Count > 0)
- // // {
- // // }
- // //}
- // #endregion
- // string sql = "select *,dbo.GetDictionaryName(Type) as GDLXName,dbo.GetDictionaryName(TypeClass) as YWLXName,dbo.GetDictionaryName(Source) as GDLYName,dbo.GetUserName(CreateUser) as CreateUserName,dbo.GetUserName(LastDealUser) as LastDealUserNameRel,dbo.GetUserName(AuditUser) as AuditUserNameRel,dbo.GetUserName(ResponUser) as ResponUserName,dbo.GetDeptName(ResponDept) AS ComplaintDepartment "
- // + " from T_Wo_WorkOrder where WorkOrderID ='" + strworkorderid + "' ";
- // var dt = DbHelperSQL.Query(sql).Tables[0];
- // if (dt.Rows.Count > 0)
- // {
- // var config = new BLL.T_Sys_SystemConfig().GetModelList(" F_ParamCode='PlayPath' ").FirstOrDefault();
- // var configfj = new BLL.T_Sys_SystemConfig().GetModelList(" F_ParamCode='FileUrlPath' ").FirstOrDefault();
- // if (configfj != null)
- // {
- // dt = BindFileData(dt, configfj.F_ParamValue);
- // }
- // string gcsql = "select *,dbo.GetUserName(CreateUser) as UserName "
- // + "from T_Wo_WorkOrderItem where IsDel=0 and WorkOrderID ='" + dt.Rows[0]["WorkOrderId"] + "'";
- // var gcdt = DbHelperSQL.Query(gcsql).Tables[0];
- // dt.Columns.Add("FilePath", typeof(string));
- // if (configfj != null || config != null)
- // {
- // foreach (DataRow bldr in dt.Rows)
- // {
- // if (bldr["CallID"] != null && config != null)
- // {
- // bldr["FilePath"] = GetCallPath(bldr["CallID"].ToString(), config.F_ParamValue);
- // }
- // }
- // }
- // var obj = new
- // {
- // data = dt,
- // item = gcdt
- // };
- // return Success("查询成功", obj);
- // }
- // return Error("查询失败");
- //}
- ///// <summary>
- ///// 获取工单明细列表
- ///// </summary>
- ///// <returns></returns>
- //[WechatActionFilter]
- //public ActionResult GetItemList()
- //{
- // string sql = " and IsDel=0 ";
- // DataTable dt = new DataTable();
- // string strid = HttpUtility.UrlDecode(RequestString.GetQueryString("workorderid"));
- // string strtype = HttpUtility.UrlDecode(RequestString.GetQueryString("type"));
- // string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
- // string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
- // string strpageindex = RequestString.GetQueryString("page");
- // int pageindex = 1;
- // string strpagesize = RequestString.GetQueryString("pagesize");
- // int pagesize = 10;
- // if (strid.Trim() != "" && strid != "undefined")
- // {
- // sql += " and WorkOrderID = '" + strid.Trim() + "' ";
- // }
- // if (strtype.Trim() != "" && strtype != "undefined")
- // {
- // sql += " and Type = '" + strtype.Trim() + "' ";
- // }
- // if (strstarttime.Trim() != "" && strstarttime != "undefined")
- // {
- // sql += " and datediff(day,CreateTime,'" + strstarttime + "')<=0 ";
- // }
- // if (strendtime.Trim() != "" && strendtime != "undefined")
- // {
- // sql += " and datediff(day,CreateTime,'" + strendtime + "')>=0 ";
- // }
- // if (strpageindex.Trim() != "")
- // {
- // pageindex = Convert.ToInt32(strpageindex);
- // }
- // if (strpagesize.Trim() != "")
- // {
- // pagesize = Convert.ToInt32(strpagesize);
- // }
- // int recordCount = 0;
- // dt = BLL.PagerBLL.GetListPager(
- // "T_Wo_WorkOrderItem",
- // "T_Wo_WorkOrderItem.ID",
- // "*,dbo.GetUserName(ToUser) as ToUserName, dbo.GetDeptName(ToDept) as ToDeptName,dbo.GetUserName(SureUser) as SureUserName,dbo.GetUserName(DealUser) as DealUserName,dbo.GetUserName(CreateUser) as CreateUserName,case Type when 1 then convert(decimal(18,2),DATEDIFF(minute, CreateTime, ISNULL(DealTime, GETDATE()))/60.00) else 0 end as totalhour",
- // sql,
- // "ORDER BY T_Wo_WorkOrderItem.ID desc",
- // pagesize,
- // pageindex,
- // true,
- // out recordCount);
- // var obj = new
- // {
- // state = "success",
- // message = "成功",
- // rows = dt,
- // total = recordCount
- // };
- // return Content(obj.ToJson());
- //}
- ///// <summary>
- ///// 获取工作动态列表 - 工单明细动态列表 - 管理员功能
- ///// </summary>
- ///// <returns></returns>
- //[WechatActionFilter]
- //public ActionResult GetWorkOrderItemList()
- //{
- // DataTable dt = new DataTable();
- // string stropenid = HttpUtility.UrlDecode(RequestString.GetQueryString("openid"));
- // //string stropenid = "oXF5e1mWpX5DajW5_yjNLPKb8ThE";
- // //获取客户档案(业主)表信息
- // var model = userAccountBLL.GetModelList(" F_WxOpenId='" + stropenid + "'").FirstOrDefault();
- // string sql = " and IsDel=0 ";
- // string daytype = HttpUtility.UrlDecode(RequestString.GetQueryString("daytype"));
- // string strpageindex = RequestString.GetQueryString("page");
- // int pageindex = 1;
- // string strpagesize = RequestString.GetQueryString("pagesize");
- // int pagesize = 10;
- // #region 权限限制
- // //if (model != null) {
- // // var sqlUser = "";
- // // //部门信息
- // // var modelDep = new BLL.T_Sys_Department().GetModel(model.F_DeptId);
- // // int depType = 0, depRegion = 0;
- // // if (modelDep != null)
- // // {
- // // depType = modelDep.F_Type ?? 0; //部门操作权限:1接待部,2办理人员,3区域客服,4监管
- // // depRegion = modelDep.F_Header ?? 0; //部门权限范围:9全部,1区域,2项目,3期
- // // }
- // // //根据部门查询工单(可查看当前部门工单)
- // // string deptCode = model.F_DeptCode; //部门code
- // // int userRegionId = model.RegionId; //项目id
- // // ////接待部(坐席)可以看到所有的工单
- // // //if (model.F_RoleId != 17 && depType != 1)
- // // //{
- // // // //if (depType == 2 || depType == 3)
- // // // //{
- // // // // // ============== 项目权限 - 项目 ==============
- // // // // sqlUser += $" and IsAdminSend = {userRegionId} ";
- // // // //}
- // // // //else if (depType == 4)
- // // // //{
- // // // // // 查看该部门工单(包括一级,二级)
- // // // // string deptCodeNew = String.Empty;
- // // // // int deptCodeIndex = 0; //变量声明
- // // // // string deptCodeN = deptCode.TrimEnd('|'); //去掉最后一个|
- // // // // deptCodeIndex = deptCodeN.LastIndexOf("|"); //获得|的索引
- // // // // deptCodeNew = deptCodeN.Substring(0, deptCodeIndex + 1); //获得目标字符串(//去掉最后一个|后面的字符串)
- // // // // // ============== 部门权限条件 - 部门 ================
- // // // // string arrUser = " select F_UserCode from T_Sys_UserAccount where F_DeptCode LIKE '" + deptCodeNew + "%' ";
- // // // // sql += $" and ToUser IN ({arrUser}) and WorkOrderID IN (SELECT WorkOrderID FROM dbo.T_Wo_WorkOrder WHERE 1=1 {sqlUser} ) ";
- // // // //}
- // // //}
- // //}
- // #endregion
- // switch (daytype)
- // {
- // case "today":
- // sql += " and DateDiff(dd,CreateTime,getdate())=0 ";
- // break;
- // case "yesterday":
- // sql += " and DateDiff(dd,CreateTime,getdate())=1 ";
- // break;
- // case "month":
- // sql += " and DateDiff(mm,CreateTime,getdate())=0 ";
- // break;
- // default:
- // break;
- // }
- // if (strpageindex.Trim() != "")
- // {
- // pageindex = Convert.ToInt32(strpageindex);
- // }
- // if (strpagesize.Trim() != "")
- // {
- // pagesize = Convert.ToInt32(strpagesize);
- // }
- // int recordCount = 0;
- // dt = BLL.PagerBLL.GetListPager(
- // "T_Wo_WorkOrderItem",
- // "T_Wo_WorkOrderItem.ID",
- // "*,dbo.GetUserName(ToUser) as ToUserName, dbo.GetDeptName(ToDept) as ToDeptName,dbo.GetUserName(SureUser) as SureUserName,dbo.GetUserName(DealUser) as DealUserName,dbo.GetUserName(CreateUser) as CreateUserName,case Type when 1 then convert(decimal(18,2),DATEDIFF(minute, CreateTime, ISNULL(DealTime, GETDATE()))/60.00) else 0 end as totalhour",
- // sql,
- // "ORDER BY T_Wo_WorkOrderItem.ID desc",
- // pagesize,
- // pageindex,
- // true,
- // out recordCount);
- // var obj = new
- // {
- // state = "success",
- // message = "成功",
- // rows = dt,
- // total = recordCount
- // };
- // return Content(obj.ToJson());
- //}
- #endregion
- #region 附件和语音文件
- /// <summary>
- /// 获取留言路径
- /// </summary>
- /// <param name="lid">留言id</param>
- /// <param name="prefix">前缀</param>
- /// <returns></returns>
- public string GetLeavePath(string lid, string prefix)
- {
- string path = string.Empty;
- var liuyan = new BLL.T_Call_LeaveRecord().GetModelList(" F_Id='" + lid + "' ").FirstOrDefault();
- if (liuyan != null)
- {
- if (!string.IsNullOrEmpty(liuyan.F_RecFileUrl))
- {
- path = prefix + liuyan.F_RecFileUrl;
- }
- }
- return path;
- }
- /// <summary>
- /// 获取通话录音路径
- /// </summary>
- /// <param name="cid">通话id</param>
- /// <param name="prefix">前缀</param>
- /// <returns></returns>
- public string GetCallPath(string cid, string prefix)
- {
- string path = string.Empty;
- var luyin = new BLL.T_Call_CallRecords().GetModelList(" callid='" + cid + "' ").FirstOrDefault();
- if (luyin != null)
- {
- if (!string.IsNullOrEmpty(luyin.FilePath))
- {
- var ym = prefix;
- ym = ym.Substring(0, ym.Length - 1);
- path = ym + luyin.FilePath.Substring(luyin.FilePath.IndexOf(':') + 1).Replace('\\', '/');
- }
- }
- return path;
- }
- /// <summary>
- /// 获取附件数据
- /// </summary>
- /// <param name="ids">附件id,多个用英文逗号,隔开</param>
- /// <param name="prefix">前缀</param>
- /// <returns></returns>
- public DataTable GetFileData(string ids, string prefix)
- {
- DataTable dt = DbHelperSQL.Query("select * from T_Sys_Accessories where F_FileId in (" + ids + ")").Tables[0];
- foreach (DataRow dr in dt.Rows)
- {
- dr["F_FileUrl"] = prefix + dr["F_FileUrl"].ToString();
- }
- return dt;
- }
- /// <summary>
- /// 绑定附件信息
- /// </summary>
- /// <param name="dt"></param>
- /// <param name="prefix"></param>
- /// <returns></returns>
- public DataTable BindFileData(DataTable dt, string prefix)
- {
- dt.Columns.Add("File", typeof(object));
- foreach (DataRow dr in dt.Rows)
- {
- if (dr["Files"] != null && dr["Files"].ToString() != "")
- {
- dr["File"] = GetFileData(dr["Files"].ToString(), prefix);
- }
- }
- return dt;
- }
- #endregion
- #region 上传附件
- /// <summary>
- /// 上传附件
- /// </summary>
- /// <returns></returns>
- public ActionResult UpLoadProcess(string id, string name, string type, string lastModifiedDate, int size, HttpPostedFileBase file)
- {
- try
- {
- string stropenid = HttpUtility.UrlDecode(RequestString.GetFormString("openid"));
- string filePathName = string.Empty;
- string path = "/Upload/Files/" + DateTime.Now.ToString("yyyy/MM/dd") + "/";
- string localPath = Server.MapPath(Path.Combine(HttpRuntime.AppDomainAppPath, path));
- if (Request.Files.Count == 0)
- {
- return Error("保存失败");
- }
- string ex = Path.GetExtension(file.FileName);
- filePathName = DateTime.Now.ToString("yyyyMMddHHmmssfff") + "_" + Guid.NewGuid().ToString("N") + ex;
- if (!System.IO.Directory.Exists(localPath))
- {
- System.IO.Directory.CreateDirectory(localPath);
- }
- file.SaveAs(Path.Combine(localPath, filePathName));
- #region 添加日志
- Model.T_Sys_Accessories model_T_Sys_Accessories = new Model.T_Sys_Accessories();
- model_T_Sys_Accessories.F_AddTime = DateTime.Now;//上传时间
- model_T_Sys_Accessories.F_FileName = filePathName;//附件名称
- model_T_Sys_Accessories.F_FileType = type;//附件类型
- model_T_Sys_Accessories.F_FileUrl = path + filePathName;//附件地址
- model_T_Sys_Accessories.F_Size = size;
- model_T_Sys_Accessories.F_UserCode = stropenid;//上传人
- int fid = new BLL.T_Sys_Accessories().Add(model_T_Sys_Accessories);
- #endregion
- if (fid > 0)
- {//返回附件的ID
- model_T_Sys_Accessories.F_FileId = fid;//修改为返回对象以便查看图片
- return Success("文件日志都成功", model_T_Sys_Accessories);
- }
- else
- return Success("文件成功");
- }
- catch (Exception ex)
- {
- return Error(ex.Message);
- }
- }
- #endregion
- }
- }
|