| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445 |
- using CallCenter.Utility;
- using CallCenterApi.DB;
- using CallCenterApi.Interface.App_Start;
- using CallCenterApi.Interface.Controllers.Base;
- using CallCenterApi.Interface.Controllers.workorder;
- using CallCenterApi.Interface.Models.Enum;
- 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_Sys_RoleInfo roleBLL = new BLL.T_Sys_RoleInfo();
- 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_Wo_WorkOrder woBLL = new BLL.T_Wo_WorkOrder();
- //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;string rolecode = "";
- //部门
- Model.T_Sys_Department modelDep = new BLL.T_Sys_Department().GetModel(user.F_DeptId);
- if (modelDep == null)
- return Error("获取失败!");
- #region 读取角色code
- var rolemodel = roleBLL.GetModel(user.F_RoleId);
- if (rolemodel != null)
- rolecode = rolemodel.F_RoleCode;
- #endregion
- #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,
- rolecode=rolecode,
- };
- 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 读取角色code
- var rolemodel = roleBLL.GetModel(usertemp.F_RoleId);
- if (rolemodel != null)
- wld.RoleCode = rolemodel.F_RoleCode;
- #endregion
- #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,
- rolecode = wld.RoleCode,
- };
- 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"));
- // if (string.IsNullOrEmpty(stropenid))
- // return Error("参数错误!");
- // var model=customerBaseBLL.GetModelByOpenid(stropenid);
- // if (model != null)
- // {
- // var sqlwo = " IsDel=0 and State <>2 "; var sqlno = " F_isDel=0 ";
- // var nowUser = userAccountBLL.GetModelByOpenid(stropenid);
- // var nowCus = customerBaseBLL.GetModelByOpenid(stropenid);
- // if (nowUser != null)
- // {
- // workorder.WorkOrderController wo = new workorder.WorkOrderController();
- // sqlwo += " and State =1 and WorkOrderID in ( '" + wo.GetDWCWorkOrderID(nowUser.F_UserCode) + "') ";
- // sqlno += " and (ISNULL(F_UserId,'') = '' or ISNULL(F_UserId,'') like '%," + nowUser.F_UserId + ",%')";
- // }
- // else if (nowCus != null)
- // {
- // sqlwo += " and ( CustomerID=" + model.F_CustomerId + " or County like '%" + model.F_CompanyName + "%' )";
- // sqlno += " and F_isCus=1 and F_NoticeId not in (select toid from T_Msg_List where Type=6 and ToUser='"+nowCus.F_CustomerCode+ "' and state=1 and IsDel=0)";
- // }
- // var ordercount = woBLL.GetRecordCount(sqlwo);
- // var noticecount = new BLL.T_Msg_NoticeInfo().GetRecordCount(sqlno);
- // 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,//公司地址
- // ordercount,//待处理工单数量
- // noticecount,//未读公告数量
- // };
- // 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 + "%' or County 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 =" + (int)EnumWorkOrderState.assign + " and T_Wo_WorkOrder.ID in ( " + wo.GetDJDWorkOrderID(ua.F_UserCode) + ") ";
- break;
- case 2://待完成的(待处理)
- sql += " and State in(" + (int)EnumWorkOrderState.dealing + "," + (int)EnumWorkOrderState.receive + "," + (int)EnumWorkOrderState.reback + "," + (int)EnumWorkOrderState.abreback + ") and T_Wo_WorkOrder.ID in ( " + wo.GetDWCWorkOrderID(ua.F_UserCode) + ") ";
- break;
- case 3://已完成的
- sql += " and State =" + (int)EnumWorkOrderState.finish + " and LastDealUser = '" + ua.F_UserCode + "' ";
- break;
- case 4://我参与的
- sql += " and (CreateUser= '" + ua.F_UserCode + "' or T_Wo_WorkOrder.ID in ( " + wo.GetCYWorkOrderID(ua.F_UserCode) + ")) ";
- break;
- case 5://超期工单 - 设置两个月的处理时效,两个月内未解决的工单都直接汇总到这里
- sql += $" and DATEADD(DAY,{days},CreateTime) < GETDATE() AND State < " + (int)EnumWorkOrderState.finish + " ";
- break;
- }
- }
- else if (modelCustomer != null)
- {
- sql += " and ( CustomerID=" + modelCustomer.F_CustomerId + " or County like '%"+modelCustomer.F_CompanyName+"%' )";
- }
- 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 T_Wo_WorkOrder.ID ='" + 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(F_NextUser) as F_NextUserName, dbo.GetDeptName(F_NextDept) as F_NextDeptName,dbo.GetUserName(F_CreateUser) as F_CreateUserName "
- + "from T_Wo_WorkOrderItem_New where F_WoID ='" + strworkorderid + "'";
- 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("查询失败");
- }
- #region 在用工单操作
- /// <summary>
- /// 处理工单
- /// </summary>
- /// <returns></returns>
- [WechatActionFilter]
- public ActionResult DealWorkOrder(long orderid, string cont, int isover = 0)
- {
- string stropenid = HttpUtility.UrlDecode(RequestString.GetFormString("openid"));
- if (!string.IsNullOrEmpty(stropenid))
- {
- Model.T_Sys_UserAccount ua = userAccountBLL.GetModelByOpenid(stropenid);
- if (ua != null)
- {
- Model.T_Wo_WorkOrder model = woBLL.GetModel(orderid);
- if (model != null)
- {
- bool res = new workorder.WorkOrderController().DealWO(ua, model, cont, isover);
- if (res)
- return Success("处理成功");
- else
- return Error("操作失败");
- }
- else
- return Error("工单不存在");
- }
- else
- return Error("无操作权限");
- }
- else
- return Error("参数错误");
- }
- /// <summary>
- /// 接单 - 确认工单
- /// </summary>
- /// <returns></returns>
- [WechatActionFilter]
- public ActionResult SureWorkOrder(long orderid)
- {
- string stropenid = HttpUtility.UrlDecode(RequestString.GetFormString("openid"));
- if (!string.IsNullOrEmpty(stropenid))
- {
- var ua = userAccountBLL.GetModelByOpenid(stropenid);
- if (ua != null)
- {
- Model.T_Wo_WorkOrder model = woBLL.GetModel(orderid);
- if (model != null)
- {
- bool res = new workorder.WorkOrderController().SureWO(ua, model);
- if (res)
- return Success("接单成功");
- else
- return Error("操作失败");
- }
- else
- return Error("工单不存在");
- }
- else
- return Error("无操作权限");
- }
- else
- return Error("参数错误");
- }
- /// <summary>
- /// 指派/转派工单
- /// </summary>
- /// <returns></returns>
- [WechatActionFilter]
- public ActionResult AssignWorkOrder(long orderid, string cont, int clbm = 0, int clid = 0)
- {
- string stropenid = HttpUtility.UrlDecode(RequestString.GetFormString("openid"));
- if (!string.IsNullOrEmpty(stropenid))
- {
- var ua = userAccountBLL.GetModelByOpenid(stropenid);
- if (ua != null)
- {
- if (clbm != 0 && clid == 0)
- return Error("请选择接收人");
- Model.T_Wo_WorkOrder model = woBLL.GetModel(orderid);
- if (model != null)
- {
- var res = new workorder.WorkOrderController().AssignWO(ua, model, cont, clbm, clid);
- if (res)
- return Success("转派成功");
- else
- return Error("转派失败!");
- }
- else
- return Error("工单不存在!");
- }
- }
- return Error("无操作权限!");
- }
- /// <summary>
- /// 退回工单
- /// </summary>
- /// <param name="input"></param>
- /// <returns></returns>
- [WechatActionFilter]
- public ActionResult BackWorkOrder(long orderid, string cont,int type=0)
- {//办理人员和监管可以退回工单
- string stropenid = HttpUtility.UrlDecode(RequestString.GetFormString("openid"));
- if (!string.IsNullOrEmpty(stropenid))
- {
- var ua = userAccountBLL.GetModelByOpenid(stropenid);
- if (ua != null)
- {
- Model.T_Wo_WorkOrder model = woBLL.GetModel(orderid);
- //验证信息
- if (model != null)
- {
- var res = new workorder.WorkOrderController().BackWO(ua, model, cont, type);
- if (res)
- return Success("处理成功");
- else
- return Error("处理失败!");
- }
- return Error("工单不存在");
- }
- }
- return Error("无操作权限");
- }
- /// <summary>
- /// 催办工单
- /// </summary>
- /// <returns></returns>
- [WechatActionFilter]
- public ActionResult AddWorkOrderRemind(long orderid, string cont)
- {
- string stropenid = HttpUtility.UrlDecode(RequestString.GetFormString("openid"));
- if (!string.IsNullOrEmpty(stropenid))
- {
- var ua = userAccountBLL.GetModelByOpenid(stropenid);
- if (ua != null)
- {
- Model.T_Wo_WorkOrder model = woBLL.GetModel(orderid);
- if (model != null)
- {
- var res = new workorder.WorkOrderController().RemindWO(ua, model, cont);
- if (res)
- Success("催办成功!");
- else
- Success("操作失败!");
- }
- return Error("工单不存在!");
- }
- }
- return Error("无操作权限!");
- }
- #endregion
- #endregion
- #region 公告通知
- /// <summary>
- /// 获取公告列表
- /// </summary>
- /// <returns></returns>
- //[WechatActionFilter]
- public ActionResult GetNoticeList()
- {
- DataTable dt = new DataTable(); int recordCount = 0;
- string stropenid = HttpUtility.UrlDecode(RequestString.GetQueryString("openid"));
- 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 = " and F_isDel=0 ";
- //获取坐席表信息
- var ua = userAccountBLL.GetModelByOpenid(stropenid);
- //获取客户档案(业主)表信息
- var modelCustomer = customerBaseBLL.GetModelByOpenid(stropenid);
- if (ua != null)
- {
- sql += " and (ISNULL(F_UserId,'') = '' or ISNULL(F_UserId,'') like '%," + ua.F_UserId + ",%')";
- }
- else if (modelCustomer != null) {
- sql += " and F_isCus=1";
- }
- if (strstarttime.Trim() != "" && strstarttime != "undefined")
- {
- sql += " and datediff(day,F_CreateOn,'" + strstarttime + "')<=0 ";
- }
- if (strendtime.Trim() != "" && strendtime != "undefined")
- {
- sql += " and datediff(day,F_CreateOn,'" + strendtime + "')>=0 ";
- }
- #endregion
- if (strpageindex.Trim() != "")
- {
- pageindex = Convert.ToInt32(strpageindex);
- }
- if (strpagesize.Trim() != "")
- {
- pagesize = Convert.ToInt32(strpagesize);
- }
- dt = BLL.PagerBLL.GetListPager(
- "T_Msg_NoticeInfo",
- "F_NoticeId",
- "*",
- sql,
- "ORDER BY F_NoticeId desc",
- pagesize,
- pageindex,
- true,
- out recordCount);
- List<Model.T_Msg_NoticeInfo> msgList = new BLL.T_Msg_NoticeInfo().DataTableToList(dt);
- List<Model.T_Sys_UserAccount> userList = new BLL.T_Sys_UserAccount().GetModelList("");
- var obj = new
- {
- rows = msgList.Select(m =>
- {
- Model.T_Sys_UserAccount usermodel = userList.Where(u => u.F_UserId == m.F_CreateBy.Value).FirstOrDefault();
- var uname = "";
- if (usermodel != null)
- uname = usermodel.F_UserName;
- return new
- {
- F_NoticeId = m.F_NoticeId,
- F_Title = m.F_Title,
- F_Content = m.F_Content,
- F_isCus = m.F_isCus,
- F_CreateOn = m.F_CreateOn,
- F_CreateBy = m.F_CreateBy,
- F_CreateByName = uname
- };
- }),
- total = recordCount
- };
- return Content(obj.ToJson());
- }
- /// <summary>
- /// 获取公告详情
- /// </summary>
- /// <returns></returns>
- //[WechatActionFilter]
- public ActionResult GetNoticeInfo()
- {
- string strnoticeid = HttpUtility.UrlDecode(RequestString.GetQueryString("noticeid"));
- string stropenid = HttpUtility.UrlDecode(RequestString.GetQueryString("openid"));
- if (string.IsNullOrEmpty(strnoticeid))
- return Error("参数错误");
- if (string.IsNullOrEmpty(stropenid))
- return Error("参数错误!");
- var dModel = new BLL.T_Msg_NoticeInfo().GetModel(int.Parse(strnoticeid.Trim()));
- Model.T_Sys_UserAccount userModel = new Model.T_Sys_UserAccount();
- if (dModel != null)
- {
- if (dModel.F_CreateBy != null)
- userModel = userAccountBLL.GetModel(dModel.F_CreateBy.Value);
- var uname = "";
- if (userModel != null)
- uname = userModel.F_UserName;
- #region 标记为已读
- var nowUser = userAccountBLL.GetModelByOpenid(stropenid);
- var nowCus = customerBaseBLL.GetModelByOpenid(stropenid);
- var usercode = "";
- if (nowUser != null)
- {
- usercode = nowUser.F_UserCode;
- var msglist = new BLL.T_Msg_List().GetModelList(" State=0 and ToUser='" + usercode + "' and Type=5 and ToID=" + dModel.F_NoticeId);
- foreach (var item in msglist)
- {
- item.State = 1;
- item.ReadDate = DateTime.Now;
- new BLL.T_Msg_List().Update(item);
- }
- }
- else if (nowCus != null)
- {
- usercode = nowCus.F_CustomerCode;
- Model.T_Msg_List msg = new Model.T_Msg_List();
- msg.Type = (int)Model.MSGType.cusnotice;
- msg.ToUser = usercode;
- msg.ToID = dModel.F_NoticeId;
- msg.Detail = "客户" + usercode + "查看了公告《" + dModel.F_Title + "》";
- msg.State = 1;
- msg.IsDel = 0;
- msg.CreateDate = DateTime.Now;
- msg.ReadDate = DateTime.Now;
- new BLL.T_Msg_List().Add(msg);
- }
- #endregion
- var obj = new
- {
- F_NoticeId = dModel.F_NoticeId,
- F_Title = dModel.F_Title,
- F_Content = dModel.F_Content,
- F_isCus = dModel.F_isCus,
- F_CreateOn = dModel.F_CreateOn,
- F_CreateBy = dModel.F_CreateBy,
- F_CreateByName = uname,
- F_UserId = dModel.F_UserId,
- F_RoleId = dModel.F_RoleId,
- };
- return Success("获取公告详情成功", dModel);
- }
- else
- 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
- }
- }
|