No Description

WxLoginController.cs 113KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445
  1. using CallCenter.Utility;
  2. using CallCenterApi.DB;
  3. using CallCenterApi.Interface.App_Start;
  4. using CallCenterApi.Interface.Controllers.Base;
  5. using CallCenterApi.Interface.Controllers.workorder;
  6. using CallCenterApi.Interface.Models.Enum;
  7. using CallCenterAPI.WechatSDK;
  8. using CallCenterAPI.WechatSDK.Models;
  9. using System;
  10. using System.Collections.Generic;
  11. using System.Data;
  12. using System.IO;
  13. using System.Linq;
  14. using System.Web;
  15. using System.Web.Mvc;
  16. namespace CallCenterApi.Interface.Controllers.weixin
  17. {
  18. public class WxLoginController : BaseController
  19. {
  20. private readonly BLL.T_Sys_UserAccount userAccountBLL = new BLL.T_Sys_UserAccount();
  21. private readonly BLL.T_Sys_RoleInfo roleBLL = new BLL.T_Sys_RoleInfo();
  22. private readonly BLL.T_Cus_CustomerBaseNew customerBaseBLL = new BLL.T_Cus_CustomerBaseNew();
  23. private readonly BLL.T_Cus_CustomerFinance finbll = new BLL.T_Cus_CustomerFinance();
  24. private readonly BLL.T_Wo_WorkOrder woBLL = new BLL.T_Wo_WorkOrder();
  25. //private readonly BLL.T_Cus_RegionCategory bllCus = new T_Cus_RegionCategory();
  26. ///// <summary>
  27. ///// 绑定微信号
  28. ///// </summary>
  29. ///// <param name="wxLoginDto"></param>
  30. ///// <returns></returns>
  31. //public ActionResult Login(WxLoginDto wxLoginDto)
  32. //{
  33. // var res = Redirect("获取微信openId", wxLoginDto.RedirectUrl);
  34. // var temp = WxHelper.GetOpenId(wxLoginDto);
  35. // if (string.IsNullOrWhiteSpace(temp.OpenId))
  36. // return res;
  37. // //openId => 用户
  38. // //如果不存在,跳转至登录页面
  39. // res = Redirect("绑定微信号", "");
  40. // return res;
  41. //}
  42. /// <summary>
  43. /// 绑定微信号 - 员工和业主分开登陆
  44. /// </summary>
  45. /// <param name="login"></param>
  46. /// <returns></returns>
  47. public ActionResult Login(WxLoginDto login)
  48. {
  49. #region 把其他OpenId更新为空
  50. var userAccount = userAccountBLL.GetModelByOpenid(login.OpenId);
  51. if (userAccount != null)
  52. {
  53. userAccount.F_WxOpenId = "";
  54. userAccountBLL.Update(userAccount);
  55. }
  56. var modelcustomer = customerBaseBLL.GetModelList(" F_WxOpenId='" + login.OpenId + "'").FirstOrDefault(); //customerBaseBLL.GetModelByOpenid(login.OpenId);
  57. if (modelcustomer != null)
  58. {
  59. modelcustomer.F_WxOpenId = "";
  60. customerBaseBLL.Update(modelcustomer);
  61. }
  62. #endregion
  63. if (login.UserType == 1)
  64. {
  65. Dictionary<string, string> paras = new Dictionary<string, string>();
  66. string sql = " select * from T_Sys_UserAccount (NOLOCK) where F_UserCode=@F_UserCode and F_PassWord=@F_PassWord and F_DeleteFlag = 0 ";
  67. paras.Add("@F_UserCode", login.UserCode);
  68. paras.Add("@F_PassWord", login.Password);
  69. var dt = DbHelperSQL.Query(sql, paras).Tables[0];
  70. if (dt != null && dt.Rows.Count > 0)
  71. {
  72. //var user = userAccountBLL.GetModel(login.UserCode); //20180926 次方法查询有漏洞
  73. var user = userAccountBLL.DataTableToList(dt).ToList().FirstOrDefault();
  74. user.F_WxOpenId = login.OpenId;
  75. int UserType = 0;string rolecode = "";
  76. //部门
  77. Model.T_Sys_Department modelDep = new BLL.T_Sys_Department().GetModel(user.F_DeptId);
  78. if (modelDep == null)
  79. return Error("获取失败!");
  80. #region 读取角色code
  81. var rolemodel = roleBLL.GetModel(user.F_RoleId);
  82. if (rolemodel != null)
  83. rolecode = rolemodel.F_RoleCode;
  84. #endregion
  85. #region 部门角色
  86. //部门角色(-1管理员,1接待部,2案场经理、项目负责人,3销售部总经理、物业部总经理、工程总经理、设计总经理,4区域客服,5业主(客户档案))
  87. if (user.F_RoleId == 17 || user.F_RoleId == 57)
  88. {
  89. //-1管理员
  90. UserType = -1;
  91. }
  92. else
  93. {
  94. UserType = 0;
  95. #region
  96. ////部门操作权限:1接待部,2办理人员,3区域客服,4监管
  97. //if (modelDep.F_Type == 1)
  98. //{
  99. // //1--接待部
  100. // UserType = 1;
  101. //}
  102. //else if (modelDep.F_Type == 2)
  103. //{
  104. // //2--办理人员
  105. // UserType = 2;
  106. //}
  107. //else if (modelDep.F_Type == 3)
  108. //{
  109. // //3--区域客服
  110. // UserType = 3;
  111. //}
  112. //else if (modelDep.F_Type == 4)
  113. //{
  114. // //4--监管
  115. // UserType = 4;
  116. //}
  117. //else
  118. //{
  119. // UserType = 0;
  120. //}
  121. #endregion
  122. }
  123. #endregion
  124. var obj = new
  125. {
  126. openid = login.OpenId,
  127. usercode = login.UserCode,
  128. usertype = UserType,
  129. rolecode=rolecode,
  130. };
  131. if (userAccountBLL.Update(user))
  132. return Success("绑定成功", obj);
  133. else
  134. return Error("绑定失败");
  135. }
  136. return Error("账号或密码错误,请重新登录");
  137. }
  138. //else if (login.UserType == 5)
  139. //{
  140. // //客户档案登录 - 用戶信息不存在时,登录客户档案业主账号
  141. // Dictionary<string, string> paras_Customer = new Dictionary<string, string>();
  142. // // F_RelationShipClassID IN (1,2) 用户类型:0来电用户; 1准业主; 2不是准业主或是亲戚朋友
  143. // //首次密码默认为身份证后6位信息
  144. // //F_CustomerClassID >= 0 为业主或租户,且F_RelationShipClassID = 0为会员账号 2、登录最早的信息
  145. // 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 ";
  146. // paras_Customer.Add("@F_UserCode", login.UserCode);
  147. // paras_Customer.Add("@F_PassWord", login.Password);
  148. // var dt_Customer = DbHelperSQL.Query(sql_Customer, paras_Customer).Tables[0];
  149. // if (dt_Customer != null && dt_Customer.Rows.Count > 0)
  150. // {
  151. // //var customer = customerBaseBLL.GetModel(login.UserCode); //20180926 次方法查询有漏洞
  152. // var customer = customerBaseBLL.DataTableToList(dt_Customer).ToList().FirstOrDefault();
  153. // customer.F_WxOpenId = login.OpenId;
  154. // #region 新加 - 登录后同时获取用户账号,openid,和角色
  155. // //5--业主(客户档案会员)
  156. // //int UserType = 5;
  157. // var obj = new
  158. // {
  159. // openid = login.OpenId,
  160. // usercode = login.UserCode,
  161. // companyname = customer.F_CompanyName,
  162. // //companyaddress=customer.F_CompanyAddress,
  163. // };
  164. // #endregion
  165. // if (customerBaseBLL.Update(customer))
  166. // return Success("绑定成功!", obj);
  167. // else
  168. // return Error("绑定失败!");
  169. // }
  170. // return Error("账号或密码错误或者没有注册,请重新登录");
  171. //}
  172. return Error("绑定失败");
  173. }
  174. /// <summary>
  175. /// 绑定微信号 - 员工和业主统一登陆 - 不用
  176. /// </summary>
  177. /// <param name="login"></param>
  178. /// <returns></returns>
  179. [WechatActionFilter]
  180. public ActionResult Login2(WxLoginDto login)
  181. {
  182. Dictionary<string, string> paras = new Dictionary<string, string>();
  183. string sql = " select * from T_Sys_UserAccount (NOLOCK) where F_UserCode=@F_UserCode and F_PassWord=@F_PassWord and F_DeleteFlag = 0 ";
  184. paras.Add("@F_UserCode", login.UserCode);
  185. paras.Add("@F_PassWord", login.Password);
  186. var dt = DbHelperSQL.Query(sql, paras).Tables[0];
  187. #region 把其他OpenId更新为空
  188. var userAccount = userAccountBLL.GetModelByOpenid(login.OpenId);
  189. if (userAccount != null)
  190. {
  191. userAccount.F_WxOpenId = "";
  192. userAccountBLL.Update(userAccount);
  193. }
  194. var modelcustomer = customerBaseBLL.GetModelList(" F_WxOpenId='" + login.OpenId + "'").FirstOrDefault();//.GetModelByOpenid(login.OpenId);
  195. if (modelcustomer != null)
  196. {
  197. modelcustomer.F_WxOpenId = "";
  198. customerBaseBLL.Update(modelcustomer);
  199. }
  200. #endregion
  201. if (dt != null && dt.Rows.Count > 0)
  202. {
  203. var user = userAccountBLL.GetModel(login.UserCode);
  204. user.F_WxOpenId = login.OpenId;
  205. //int UserType = 0;
  206. //部门
  207. Model.T_Sys_Department modelDep = new BLL.T_Sys_Department().GetModel(user.F_DeptId);
  208. if (modelDep == null)
  209. return Error("获取失败!");
  210. #region 部门角色
  211. ////部门角色(-1管理员,1接待部,2案场经理、项目负责人,3销售部总经理、物业部总经理、工程总经理、设计总经理,4区域客服,5业主(客户档案))
  212. //if (user.F_RoleId == 17)
  213. //{
  214. // //-1管理员
  215. // UserType = -1;
  216. //}
  217. //else
  218. //{
  219. // //部门操作权限:1接待部,2办理人员,3区域客服,4监管
  220. // if (modelDep.F_Type == 1)
  221. // {
  222. // //1--接待部
  223. // UserType = 1;
  224. // }
  225. // else if (modelDep.F_Type == 2)
  226. // {
  227. // //2--办理人员
  228. // UserType = 2;
  229. // }
  230. // else if (modelDep.F_Type == 3)
  231. // {
  232. // //3--区域客服
  233. // UserType = 3;
  234. // }
  235. // else if (modelDep.F_Type == 4)
  236. // {
  237. // //4--监管
  238. // UserType = 4;
  239. // }
  240. // else
  241. // {
  242. // UserType = 0;
  243. // }
  244. //}
  245. #endregion
  246. var obj = new
  247. {
  248. openid = login.OpenId,
  249. usercode = login.UserCode,
  250. //usertype = UserType
  251. };
  252. if (userAccountBLL.Update(user))
  253. {
  254. return Success("绑定成功", obj);
  255. }
  256. else
  257. {
  258. return Error("绑定失败");
  259. }
  260. }
  261. else
  262. {
  263. //客户档案登录 - 用戶信息不存在时,登录客户档案业主账号
  264. Dictionary<string, string> paras_Customer = new Dictionary<string, string>();
  265. // F_RelationShipClassID IN (1,2) 用户类型:0来电用户; 1准业主; 2不是准业主或是亲戚朋友
  266. //首次密码默认为身份证后6位信息
  267. //F_CustomerClassID >= 0 为业主或租户,且F_RelationShipClassID = 0为会员账号 2、登录最早的信息
  268. string sql_Customer = " select * from dbo.T_Cus_CustomerBaseNew (NOLOCK) where F_CustomerCode=@F_UserCode and F_PassWord=@F_PassWord and F_DeleteFlag = 0 ";
  269. paras_Customer.Add("@F_UserCode", login.UserCode);
  270. paras_Customer.Add("@F_PassWord", login.Password);
  271. var dt_Customer = DbHelperSQL.Query(sql_Customer, paras_Customer).Tables[0];
  272. if (dt_Customer != null && dt_Customer.Rows.Count > 0)
  273. {
  274. var customer = customerBaseBLL.GetModelList(" F_CustomerCode='" + login.UserCode + "'").FirstOrDefault(); //customerBaseBLL.GetModel(login.UserCode);
  275. customer.F_WxOpenId = login.OpenId;
  276. #region 新加 - 登录后同时获取用户账号,openid,和角色
  277. //5--业主(客户档案会员)
  278. //int UserType = 5;
  279. var obj = new
  280. {
  281. openid = login.OpenId,
  282. usercode = login.UserCode,
  283. //usertype = UserType
  284. };
  285. #endregion
  286. if (customerBaseBLL.Update(customer))
  287. {
  288. return Success("绑定成功!", obj);
  289. }
  290. else
  291. {
  292. return Error("绑定失败!");
  293. }
  294. }
  295. else
  296. {
  297. return Error("账号或密码错误,请重新登录");
  298. }
  299. //return Error("账号或密码错误,请重新登录");
  300. }
  301. }
  302. /// <summary>
  303. /// 获取微信openid
  304. /// </summary>
  305. /// <param name="login"></param>
  306. /// <returns></returns>
  307. public ActionResult GetOpenId(WxLoginDto wld)
  308. {
  309. wld.RedirectUrl = RequestString.GetUrlReferrer();
  310. if (string.IsNullOrEmpty(wld.OpenId))
  311. {
  312. var temp = WxHelper.GetOpenId(wld);
  313. if (string.IsNullOrWhiteSpace(temp.OpenId))
  314. {
  315. return Redirect("请求", temp.RedirectUrl);
  316. }
  317. wld.OpenId = temp.OpenId;
  318. #region 获取是否绑定用户表
  319. //获取是否绑定用户表
  320. var usertemp = new BLL.T_Sys_UserAccount().GetModelByOpenid(wld.OpenId);
  321. if (usertemp != null)
  322. {
  323. //部门
  324. Model.T_Sys_Department modelDep = new BLL.T_Sys_Department().GetModel(usertemp.F_DeptId);
  325. if (modelDep == null)
  326. return Error("获取失败!");
  327. wld.UserCode = usertemp.F_UserCode;
  328. #region 读取角色code
  329. var rolemodel = roleBLL.GetModel(usertemp.F_RoleId);
  330. if (rolemodel != null)
  331. wld.RoleCode = rolemodel.F_RoleCode;
  332. #endregion
  333. #region 部门角色
  334. if (usertemp.F_RoleId == 17)
  335. {
  336. //-1管理员
  337. wld.UserType = -1;
  338. }
  339. else
  340. {
  341. wld.UserType = 0;
  342. #region
  343. ////部门操作权限:1接待部,2办理人员,3区域客服,4监管
  344. //if (modelDep.F_Type == 1)
  345. //{
  346. // //1--接待部
  347. // wld.UserType = 1;
  348. //}
  349. //else if (modelDep.F_Type == 2)
  350. //{
  351. // //2--办理人员
  352. // wld.UserType = 2;
  353. //}
  354. //else if (modelDep.F_Type == 3)
  355. //{
  356. // //3--区域客服
  357. // wld.UserType = 3;
  358. //}
  359. //else if (modelDep.F_Type == 4)
  360. //{
  361. // //4--监管
  362. // wld.UserType = 4;
  363. //}
  364. //else
  365. //{
  366. // wld.UserType = 0;
  367. //}
  368. #endregion
  369. }
  370. #endregion
  371. }
  372. else
  373. {
  374. var customertemp = customerBaseBLL.GetModelByOpenid(wld.OpenId);
  375. if (customertemp != null)
  376. {
  377. wld.UserCode = customertemp.F_CustomerCode;
  378. //5--业主(客户档案会员)
  379. wld.UserType = 5;
  380. }
  381. else
  382. {
  383. wld.UserCode = "";
  384. }
  385. //wld.UserCode = "";
  386. }
  387. #endregion
  388. }
  389. var model = new BLL.T_Sys_Users().GetModel(wld.OpenId);
  390. if (model == null)
  391. {
  392. model = new Model.T_Sys_Users();
  393. model.F_OpenId = wld.OpenId;
  394. model.F_Type = 1;
  395. model.F_CreateTime = DateTime.Now;
  396. new BLL.T_Sys_Users().Add(model);
  397. }
  398. var newobj = new
  399. {
  400. openid = wld.OpenId,
  401. usercode = wld.UserCode,
  402. usertype = wld.UserType,
  403. rolecode = wld.RoleCode,
  404. };
  405. return Success("成功", newobj);
  406. }
  407. /// <summary>
  408. /// 修改密码
  409. /// </summary>
  410. /// <returns></returns>
  411. [WechatActionFilter]
  412. public ActionResult UpdatePassWord()
  413. {
  414. string stropenid = HttpUtility.UrlDecode(RequestString.GetFormString("openid"));
  415. //5--业主(客户档案会员)
  416. int usertype = RequestString.GetInt("usertype", 0);
  417. //原密码
  418. string oldpwd = RequestString.GetFormString("oldpwd").Trim();
  419. string pwd = RequestString.GetFormString("pwd").Trim();
  420. string repeatpwd = RequestString.GetFormString("repeatpwd").Trim();
  421. if (usertype == 0)
  422. return Error("无权修改密码");
  423. if (string.IsNullOrWhiteSpace(oldpwd))
  424. return Error("请输入原密码");
  425. if (string.IsNullOrWhiteSpace(pwd))
  426. return Error("请输入新密码");
  427. if (string.IsNullOrWhiteSpace(repeatpwd))
  428. return Error("请再次输入新密码");
  429. if (!pwd.Equals(repeatpwd))
  430. return Error("两个新密码不同,请重新输入");
  431. var model = new Model.T_Sys_UserAccount();
  432. var modelCus = new Model.T_Cus_CustomerBaseNew();
  433. //坐席表
  434. if (usertype < 5)
  435. {
  436. model = userAccountBLL.GetModelByOpenid(stropenid);
  437. if (model != null)
  438. {
  439. if (!model.F_Password.Equals(oldpwd)) return Error("原密码不正确");
  440. model.F_Password = pwd;
  441. if (userAccountBLL.Update(model))
  442. return Success("重置密码成功");
  443. }
  444. return Error("重置密码失败");
  445. }
  446. //客户档案表
  447. modelCus = customerBaseBLL.GetModelList(" F_WxOpenId='" + stropenid + "'").FirstOrDefault();//customerBaseBLL.GetModelByOpenid(stropenid);
  448. if (modelCus != null)
  449. {
  450. if (!modelCus.F_WxPassword.Equals(oldpwd)) return Error("原密码不正确");
  451. modelCus.F_WxPassword = pwd;
  452. if (customerBaseBLL.Update(modelCus))
  453. return Success("重置密码成功");
  454. }
  455. return Error("重置密码失败");
  456. }
  457. #region
  458. //workorder.WoBillController blcon = new WoBillController();
  459. ///// <summary>
  460. ///// 获取所有业务
  461. ///// </summary>
  462. ///// <returns></returns>
  463. //[WechatActionFilter]
  464. //public ActionResult GetBusList()
  465. //{
  466. // var list = blcon.GetBusAllList();
  467. // return Success("获取信息列表成功", list);
  468. //}
  469. ///// <summary>
  470. ///// 获取业务内容
  471. ///// </summary>
  472. ///// <returns></returns>
  473. //[WechatActionFilter]
  474. //public ActionResult GetBusInfo()
  475. //{
  476. // string strbusid = HttpUtility.UrlDecode(RequestString.GetQueryString("busid"));
  477. // if (string.IsNullOrEmpty(strbusid))
  478. // return Error("参数错误");
  479. // var model = blcon.GetBusInfo(strbusid);
  480. // if (model != null)
  481. // return Success("获取信息成功", model);
  482. // else
  483. // return Error("获取信息失败");
  484. //}
  485. ///// <summary>
  486. ///// 获取开票列表
  487. ///// </summary>
  488. ///// <returns></returns>
  489. //[WechatActionFilter]
  490. //public ActionResult GetBillList()
  491. //{
  492. // DataTable dt = new DataTable();
  493. // string stropenid = HttpUtility.UrlDecode(RequestString.GetQueryString("openid"));
  494. // string strbtime = HttpUtility.UrlDecode(RequestString.GetQueryString("btime"));
  495. // string stretime = HttpUtility.UrlDecode(RequestString.GetQueryString("etime"));
  496. // string strpageindex = RequestString.GetQueryString("pageindex");
  497. // int pageindex = 1;
  498. // string strpagesize = RequestString.GetQueryString("pagesize");
  499. // int pagesize = 10;
  500. // if (strpageindex.Trim() != "")
  501. // {
  502. // pageindex = Convert.ToInt32(strpageindex);
  503. // }
  504. // if (strpagesize.Trim() != "")
  505. // {
  506. // pagesize = Convert.ToInt32(strpagesize);
  507. // }
  508. // var obj=blcon.GetLists(stropenid, strbtime, stretime, pageindex, pagesize);
  509. // return Content(obj.ToJson());
  510. //}
  511. ///// <summary>
  512. ///// 获取开票详情
  513. ///// </summary>
  514. ///// <returns></returns>
  515. //[WechatActionFilter]
  516. //public ActionResult GetBillInfo()
  517. //{
  518. // string strbillid = HttpUtility.UrlDecode(RequestString.GetQueryString("billid"));
  519. // if (string.IsNullOrEmpty(strbillid))
  520. // return Error("参数错误");
  521. // var model = blcon.GetBillInfo(strbillid);
  522. // if (model != null)
  523. // return Success("获取信息成功", model);
  524. // else
  525. // return Error("获取信息失败");
  526. //}
  527. ///// <summary>
  528. ///// 开票
  529. ///// </summary>
  530. ///// <returns></returns>
  531. //[WechatActionFilter]
  532. //public ActionResult AddBill()
  533. //{
  534. // string billtype = RequestString.GetFormString("billtype");//发票类型
  535. // string cusname = RequestString.GetFormString("cusname");//客户名称
  536. // string taxidnum = RequestString.GetFormString("taxidnum");//纳税人识别号
  537. // string address = RequestString.GetFormString("address");//地址
  538. // string phone = RequestString.GetFormString("phone");//电话
  539. // string bank = RequestString.GetFormString("bank");//开户行
  540. // string bankaccount = RequestString.GetFormString("bankaccount");//开户行账号
  541. // string proname = RequestString.GetFormString("proname");//项目名称
  542. // string models = RequestString.GetFormString("models");//型号
  543. // string unit = RequestString.GetFormString("unit");//单位
  544. // string amount = RequestString.GetFormString("amount");//数量
  545. // string unitprice = RequestString.GetFormString("unitprice");//单价
  546. // string sumprice = RequestString.GetFormString("sumprice");//金额
  547. // string taxrate = RequestString.GetFormString("taxrate");//税率
  548. // string taxamount = RequestString.GetFormString("taxamount");//税额
  549. // string billingMethod = RequestString.GetFormString("billingmethod");//开票方式:快递/自取
  550. // string billingTime = RequestString.GetFormString("billingtime");//开票时间
  551. // string remark = RequestString.GetFormString("remark");//备注
  552. // string stropenid = HttpUtility.UrlDecode(RequestString.GetFormString("openid"));
  553. // Model.T_Wo_Bill dModel = new Model.T_Wo_Bill();
  554. // #region 保存基本信息
  555. // dModel.F_BillType = billtype;
  556. // dModel.F_CusName = cusname;
  557. // dModel.F_TaxIDNum = taxidnum;
  558. // dModel.F_Address = address;
  559. // dModel.F_Phone = phone;
  560. // dModel.F_Bank = bank;
  561. // dModel.F_BankAccount = bankaccount;
  562. // dModel.F_ProName = proname;
  563. // dModel.F_Models = models;
  564. // dModel.F_Unit = unit;
  565. // dModel.F_Amount = amount;
  566. // dModel.F_UnitPrice = unitprice;
  567. // dModel.F_SumPrice = sumprice;
  568. // dModel.F_TaxRate = taxrate;
  569. // dModel.F_TaxAmount = taxamount;
  570. // dModel.F_BillingMethod = billingMethod;
  571. // dModel.F_BillingTime = billingTime;
  572. // dModel.F_Remark = remark;
  573. // dModel.F_Openid = stropenid;
  574. // dModel.F_CreateOn = DateTime.Now;
  575. // dModel.F_State = 0;
  576. // #endregion
  577. // var res=blcon.addbills(dModel);
  578. // if (res)
  579. // return Success("保存成功");
  580. // else
  581. // return Error("保存失败");
  582. //}
  583. #endregion
  584. #region 获取公司详情
  585. ////获取公司信息
  586. //[WechatActionFilter]
  587. //public ActionResult GetInfo()
  588. //{
  589. // string stropenid = HttpUtility.UrlDecode(RequestString.GetQueryString("openid"));
  590. // if (string.IsNullOrEmpty(stropenid))
  591. // return Error("参数错误!");
  592. // var model=customerBaseBLL.GetModelByOpenid(stropenid);
  593. // if (model != null)
  594. // {
  595. // var sqlwo = " IsDel=0 and State <>2 "; var sqlno = " F_isDel=0 ";
  596. // var nowUser = userAccountBLL.GetModelByOpenid(stropenid);
  597. // var nowCus = customerBaseBLL.GetModelByOpenid(stropenid);
  598. // if (nowUser != null)
  599. // {
  600. // workorder.WorkOrderController wo = new workorder.WorkOrderController();
  601. // sqlwo += " and State =1 and WorkOrderID in ( '" + wo.GetDWCWorkOrderID(nowUser.F_UserCode) + "') ";
  602. // sqlno += " and (ISNULL(F_UserId,'') = '' or ISNULL(F_UserId,'') like '%," + nowUser.F_UserId + ",%')";
  603. // }
  604. // else if (nowCus != null)
  605. // {
  606. // sqlwo += " and ( CustomerID=" + model.F_CustomerId + " or County like '%" + model.F_CompanyName + "%' )";
  607. // 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)";
  608. // }
  609. // var ordercount = woBLL.GetRecordCount(sqlwo);
  610. // var noticecount = new BLL.T_Msg_NoticeInfo().GetRecordCount(sqlno);
  611. // var obj = new
  612. // {
  613. // model.F_CompanyName,//公司名称
  614. // model.F_CompanyLogo,//logo
  615. // model.F_CustomerCode,//编号
  616. // model.F_CycleStart,//服务周期-开始时间
  617. // model.F_CycleEnd,//服务周期-结束时间
  618. // model.F_ChargeType,//收费类型:1月度,2季度,3年度
  619. // model.F_Charges,//收费
  620. // model.F_TaxNumber,//公司税号
  621. // model.F_CompanyAddress,//公司地址
  622. // ordercount,//待处理工单数量
  623. // noticecount,//未读公告数量
  624. // };
  625. // return Success("获取成功", obj);
  626. // }
  627. // return Error("获取失败");
  628. //}
  629. ////获取财税信息
  630. ////[WechatActionFilter]
  631. //public ActionResult GetFinc()
  632. //{
  633. // string stropenid = HttpUtility.UrlDecode(RequestString.GetQueryString("openid"));
  634. // var model = customerBaseBLL.GetModelByOpenid(stropenid);
  635. // if (model != null)
  636. // {
  637. // var finmodel = finbll.GetModelList(" F_CustomerId=" + model.F_CustomerId).FirstOrDefault();
  638. // if (finmodel != null)
  639. // {
  640. // var obj = new
  641. // {
  642. // model.F_CompanyName,//公司名称
  643. // model.F_CompanyLogo,//logo
  644. // model.F_CustomerCode,//编号
  645. // finmodel.F_CusFinId,
  646. // finmodel.F_CustomerId,
  647. // finmodel.F_MonthState,
  648. // finmodel.F_AnnualIncome,
  649. // finmodel.F_AnnualProfit,
  650. // finmodel.F_AnnualCost,
  651. // finmodel.F_AnnualPersonCount,
  652. // finmodel.F_AnnualWages,
  653. // finmodel.F_QuarterlyCost,
  654. // finmodel.F_QuarterlyPersonCount,
  655. // finmodel.F_QuarterlyWages,
  656. // finmodel.F_QuarterlyIncome,
  657. // finmodel.F_QPVAT,
  658. // finmodel.F_QPSurtax,
  659. // finmodel.F_QPTaxes,
  660. // finmodel.F_QPConTax,
  661. // finmodel.F_QPPerinTax,
  662. // finmodel.F_QPStampTax,
  663. // finmodel.F_QPOtherTax
  664. // };
  665. // return Success("获取成功", obj);
  666. // }
  667. // }
  668. // return Error("获取失败");
  669. //}
  670. #endregion
  671. #region 工单
  672. /// <summary>
  673. /// 工单列表
  674. /// </summary>
  675. [WechatActionFilter]
  676. public ActionResult GetWoList()
  677. {
  678. workorder.WorkOrderController wo = new workorder.WorkOrderController();
  679. var config = new BLL.T_Sys_SystemConfig().GetModelList(" F_ParamCode='TimeLimitDays' ").FirstOrDefault();
  680. int days = config != null ? Convert.ToInt32(config.F_ParamValue) : 60; //默认60天
  681. DataTable dt = new DataTable();
  682. int recordCount = 0;
  683. string stropenid = HttpUtility.UrlDecode(RequestString.GetQueryString("openid"));
  684. //客户姓名,电话,工单号
  685. string keyword = HttpUtility.UrlDecode(RequestString.GetQueryString("keyword"));
  686. //工单状态
  687. int states = RequestString.GetInt("states", -1);
  688. string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
  689. string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
  690. string strpageindex = RequestString.GetQueryString("page");
  691. int pageindex = 1;
  692. string strpagesize = RequestString.GetQueryString("pagesize");
  693. int pagesize = 10;
  694. #region sql 语句相关处理
  695. string sql = " ";
  696. //获取坐席表信息
  697. var ua = userAccountBLL.GetModelList(" F_WxOpenId='" + stropenid + "'").FirstOrDefault();
  698. //获取客户档案(业主)表信息
  699. var modelCustomer = customerBaseBLL.GetModelList(" F_WxOpenId='" + stropenid.Trim() + "'").FirstOrDefault();
  700. if (!string.IsNullOrEmpty(sql))
  701. {
  702. sql += " and IsDel=0 ";
  703. //客户姓名,电话,房间号,工单号,接待描述
  704. if (!string.IsNullOrEmpty(keyword))
  705. {
  706. sql += " and (CustomerTel like '%" + keyword + "%' or Customer like '%" + keyword + "%' or WorkOrderID like '%" + keyword + "%' or Detail like '%" + keyword + "%' or County like '%" + keyword + "%' ) ";
  707. }
  708. if (states >= 0)
  709. {
  710. #region 权限限制
  711. if (ua != null)
  712. {
  713. string uwhere = " ";
  714. switch (states)
  715. {
  716. case 0://待指派的
  717. //sql += " and State ='0' and CreateUser= '" + ua.F_UserCode + "' ";
  718. //3区域客服可以看到区域待指派工单
  719. if (ua.F_RoleId != 17)
  720. {
  721. uwhere += " and CreateUser='" + ua.F_UserCode + "' ";
  722. }
  723. sql += " and State =0 " + uwhere;
  724. break;
  725. case 1://待接单的
  726. sql += " and State =" + (int)EnumWorkOrderState.assign + " and T_Wo_WorkOrder.ID in ( " + wo.GetDJDWorkOrderID(ua.F_UserCode) + ") ";
  727. break;
  728. case 2://待完成的(待处理)
  729. 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) + ") ";
  730. break;
  731. case 3://已完成的
  732. sql += " and State =" + (int)EnumWorkOrderState.finish + " and LastDealUser = '" + ua.F_UserCode + "' ";
  733. break;
  734. case 4://我参与的
  735. sql += " and (CreateUser= '" + ua.F_UserCode + "' or T_Wo_WorkOrder.ID in ( " + wo.GetCYWorkOrderID(ua.F_UserCode) + ")) ";
  736. break;
  737. case 5://超期工单 - 设置两个月的处理时效,两个月内未解决的工单都直接汇总到这里
  738. sql += $" and DATEADD(DAY,{days},CreateTime) < GETDATE() AND State < " + (int)EnumWorkOrderState.finish + " ";
  739. break;
  740. }
  741. }
  742. else if (modelCustomer != null)
  743. {
  744. sql += " and ( CustomerID=" + modelCustomer.F_CustomerId + " or County like '%"+modelCustomer.F_CompanyName+"%' )";
  745. }
  746. else
  747. {
  748. sql = "";
  749. }
  750. #endregion
  751. }
  752. if (strstarttime.Trim() != "" && strstarttime != "undefined")
  753. {
  754. sql += " and datediff(day,CreateTime,'" + strstarttime + "')<=0 ";
  755. }
  756. if (strendtime.Trim() != "" && strendtime != "undefined")
  757. {
  758. sql += " and datediff(day,CreateTime,'" + strendtime + "')>=0 ";
  759. }
  760. #endregion
  761. if (strpageindex.Trim() != "")
  762. {
  763. pageindex = Convert.ToInt32(strpageindex);
  764. }
  765. if (strpagesize.Trim() != "")
  766. {
  767. pagesize = Convert.ToInt32(strpagesize);
  768. }
  769. 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";
  770. dt = BLL.PagerBLL.GetListPager(
  771. "T_Wo_WorkOrder (NOLOCK)",
  772. "WorkOrderID",
  773. cols,
  774. sql,
  775. "ORDER BY CreateTime DESC,State asc",
  776. pagesize,
  777. pageindex,
  778. true,
  779. out recordCount);
  780. }
  781. var obj = new
  782. {
  783. state = "success",
  784. message = "成功",
  785. rows = dt,
  786. total = recordCount
  787. };
  788. return Content(obj.ToJson());
  789. }
  790. /// <summary>
  791. /// 工单详情
  792. /// </summary>
  793. [WechatActionFilter]
  794. public ActionResult GetWoInfo()
  795. {
  796. string strworkorderid = HttpUtility.UrlDecode(RequestString.GetQueryString("workorderid"));
  797. string stropenid = HttpUtility.UrlDecode(RequestString.GetQueryString("openid"));
  798. if (string.IsNullOrEmpty(strworkorderid))
  799. return Error("参数错误");
  800. if (string.IsNullOrEmpty(stropenid))
  801. return Error("参数错误!");
  802. 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 "
  803. + " from T_Wo_WorkOrder where T_Wo_WorkOrder.ID ='" + strworkorderid + "' ";
  804. var dt = DbHelperSQL.Query(sql).Tables[0];
  805. if (dt.Rows.Count > 0)
  806. {
  807. var config = new BLL.T_Sys_SystemConfig().GetModelList(" F_ParamCode='PlayPath' ").FirstOrDefault();
  808. var configfj = new BLL.T_Sys_SystemConfig().GetModelList(" F_ParamCode='FileUrlPath' ").FirstOrDefault();
  809. if (configfj != null)
  810. {
  811. dt = BindFileData(dt, configfj.F_ParamValue);
  812. }
  813. string gcsql = "select *,dbo.GetUserName(F_NextUser) as F_NextUserName, dbo.GetDeptName(F_NextDept) as F_NextDeptName,dbo.GetUserName(F_CreateUser) as F_CreateUserName "
  814. + "from T_Wo_WorkOrderItem_New where F_WoID ='" + strworkorderid + "'";
  815. var gcdt = DbHelperSQL.Query(gcsql).Tables[0];
  816. dt.Columns.Add("FilePath", typeof(string));
  817. if (configfj != null || config != null)
  818. {
  819. foreach (DataRow bldr in dt.Rows)
  820. {
  821. if (bldr["CallID"] != null && config != null)
  822. {
  823. bldr["FilePath"] = GetCallPath(bldr["CallID"].ToString(), config.F_ParamValue);
  824. }
  825. }
  826. }
  827. var obj = new
  828. {
  829. data = dt,
  830. item = gcdt
  831. };
  832. return Success("查询成功", obj);
  833. }
  834. return Error("查询失败");
  835. }
  836. #region 在用工单操作
  837. /// <summary>
  838. /// 处理工单
  839. /// </summary>
  840. /// <returns></returns>
  841. [WechatActionFilter]
  842. public ActionResult DealWorkOrder(long orderid, string cont, int isover = 0)
  843. {
  844. string stropenid = HttpUtility.UrlDecode(RequestString.GetFormString("openid"));
  845. if (!string.IsNullOrEmpty(stropenid))
  846. {
  847. Model.T_Sys_UserAccount ua = userAccountBLL.GetModelByOpenid(stropenid);
  848. if (ua != null)
  849. {
  850. Model.T_Wo_WorkOrder model = woBLL.GetModel(orderid);
  851. if (model != null)
  852. {
  853. bool res = new workorder.WorkOrderController().DealWO(ua, model, cont, isover);
  854. if (res)
  855. return Success("处理成功");
  856. else
  857. return Error("操作失败");
  858. }
  859. else
  860. return Error("工单不存在");
  861. }
  862. else
  863. return Error("无操作权限");
  864. }
  865. else
  866. return Error("参数错误");
  867. }
  868. /// <summary>
  869. /// 接单 - 确认工单
  870. /// </summary>
  871. /// <returns></returns>
  872. [WechatActionFilter]
  873. public ActionResult SureWorkOrder(long orderid)
  874. {
  875. string stropenid = HttpUtility.UrlDecode(RequestString.GetFormString("openid"));
  876. if (!string.IsNullOrEmpty(stropenid))
  877. {
  878. var ua = userAccountBLL.GetModelByOpenid(stropenid);
  879. if (ua != null)
  880. {
  881. Model.T_Wo_WorkOrder model = woBLL.GetModel(orderid);
  882. if (model != null)
  883. {
  884. bool res = new workorder.WorkOrderController().SureWO(ua, model);
  885. if (res)
  886. return Success("接单成功");
  887. else
  888. return Error("操作失败");
  889. }
  890. else
  891. return Error("工单不存在");
  892. }
  893. else
  894. return Error("无操作权限");
  895. }
  896. else
  897. return Error("参数错误");
  898. }
  899. /// <summary>
  900. /// 指派/转派工单
  901. /// </summary>
  902. /// <returns></returns>
  903. [WechatActionFilter]
  904. public ActionResult AssignWorkOrder(long orderid, string cont, int clbm = 0, int clid = 0)
  905. {
  906. string stropenid = HttpUtility.UrlDecode(RequestString.GetFormString("openid"));
  907. if (!string.IsNullOrEmpty(stropenid))
  908. {
  909. var ua = userAccountBLL.GetModelByOpenid(stropenid);
  910. if (ua != null)
  911. {
  912. if (clbm != 0 && clid == 0)
  913. return Error("请选择接收人");
  914. Model.T_Wo_WorkOrder model = woBLL.GetModel(orderid);
  915. if (model != null)
  916. {
  917. var res = new workorder.WorkOrderController().AssignWO(ua, model, cont, clbm, clid);
  918. if (res)
  919. return Success("转派成功");
  920. else
  921. return Error("转派失败!");
  922. }
  923. else
  924. return Error("工单不存在!");
  925. }
  926. }
  927. return Error("无操作权限!");
  928. }
  929. /// <summary>
  930. /// 退回工单
  931. /// </summary>
  932. /// <param name="input"></param>
  933. /// <returns></returns>
  934. [WechatActionFilter]
  935. public ActionResult BackWorkOrder(long orderid, string cont,int type=0)
  936. {//办理人员和监管可以退回工单
  937. string stropenid = HttpUtility.UrlDecode(RequestString.GetFormString("openid"));
  938. if (!string.IsNullOrEmpty(stropenid))
  939. {
  940. var ua = userAccountBLL.GetModelByOpenid(stropenid);
  941. if (ua != null)
  942. {
  943. Model.T_Wo_WorkOrder model = woBLL.GetModel(orderid);
  944. //验证信息
  945. if (model != null)
  946. {
  947. var res = new workorder.WorkOrderController().BackWO(ua, model, cont, type);
  948. if (res)
  949. return Success("处理成功");
  950. else
  951. return Error("处理失败!");
  952. }
  953. return Error("工单不存在");
  954. }
  955. }
  956. return Error("无操作权限");
  957. }
  958. /// <summary>
  959. /// 催办工单
  960. /// </summary>
  961. /// <returns></returns>
  962. [WechatActionFilter]
  963. public ActionResult AddWorkOrderRemind(long orderid, string cont)
  964. {
  965. string stropenid = HttpUtility.UrlDecode(RequestString.GetFormString("openid"));
  966. if (!string.IsNullOrEmpty(stropenid))
  967. {
  968. var ua = userAccountBLL.GetModelByOpenid(stropenid);
  969. if (ua != null)
  970. {
  971. Model.T_Wo_WorkOrder model = woBLL.GetModel(orderid);
  972. if (model != null)
  973. {
  974. var res = new workorder.WorkOrderController().RemindWO(ua, model, cont);
  975. if (res)
  976. Success("催办成功!");
  977. else
  978. Success("操作失败!");
  979. }
  980. return Error("工单不存在!");
  981. }
  982. }
  983. return Error("无操作权限!");
  984. }
  985. #endregion
  986. #endregion
  987. #region 公告通知
  988. /// <summary>
  989. /// 获取公告列表
  990. /// </summary>
  991. /// <returns></returns>
  992. //[WechatActionFilter]
  993. public ActionResult GetNoticeList()
  994. {
  995. DataTable dt = new DataTable(); int recordCount = 0;
  996. string stropenid = HttpUtility.UrlDecode(RequestString.GetQueryString("openid"));
  997. string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
  998. string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
  999. string strpageindex = RequestString.GetQueryString("page");
  1000. int pageindex = 1;
  1001. string strpagesize = RequestString.GetQueryString("pagesize");
  1002. int pagesize = 10;
  1003. #region sql 语句相关处理
  1004. string sql = " and F_isDel=0 ";
  1005. //获取坐席表信息
  1006. var ua = userAccountBLL.GetModelByOpenid(stropenid);
  1007. //获取客户档案(业主)表信息
  1008. var modelCustomer = customerBaseBLL.GetModelByOpenid(stropenid);
  1009. if (ua != null)
  1010. {
  1011. sql += " and (ISNULL(F_UserId,'') = '' or ISNULL(F_UserId,'') like '%," + ua.F_UserId + ",%')";
  1012. }
  1013. else if (modelCustomer != null) {
  1014. sql += " and F_isCus=1";
  1015. }
  1016. if (strstarttime.Trim() != "" && strstarttime != "undefined")
  1017. {
  1018. sql += " and datediff(day,F_CreateOn,'" + strstarttime + "')<=0 ";
  1019. }
  1020. if (strendtime.Trim() != "" && strendtime != "undefined")
  1021. {
  1022. sql += " and datediff(day,F_CreateOn,'" + strendtime + "')>=0 ";
  1023. }
  1024. #endregion
  1025. if (strpageindex.Trim() != "")
  1026. {
  1027. pageindex = Convert.ToInt32(strpageindex);
  1028. }
  1029. if (strpagesize.Trim() != "")
  1030. {
  1031. pagesize = Convert.ToInt32(strpagesize);
  1032. }
  1033. dt = BLL.PagerBLL.GetListPager(
  1034. "T_Msg_NoticeInfo",
  1035. "F_NoticeId",
  1036. "*",
  1037. sql,
  1038. "ORDER BY F_NoticeId desc",
  1039. pagesize,
  1040. pageindex,
  1041. true,
  1042. out recordCount);
  1043. List<Model.T_Msg_NoticeInfo> msgList = new BLL.T_Msg_NoticeInfo().DataTableToList(dt);
  1044. List<Model.T_Sys_UserAccount> userList = new BLL.T_Sys_UserAccount().GetModelList("");
  1045. var obj = new
  1046. {
  1047. rows = msgList.Select(m =>
  1048. {
  1049. Model.T_Sys_UserAccount usermodel = userList.Where(u => u.F_UserId == m.F_CreateBy.Value).FirstOrDefault();
  1050. var uname = "";
  1051. if (usermodel != null)
  1052. uname = usermodel.F_UserName;
  1053. return new
  1054. {
  1055. F_NoticeId = m.F_NoticeId,
  1056. F_Title = m.F_Title,
  1057. F_Content = m.F_Content,
  1058. F_isCus = m.F_isCus,
  1059. F_CreateOn = m.F_CreateOn,
  1060. F_CreateBy = m.F_CreateBy,
  1061. F_CreateByName = uname
  1062. };
  1063. }),
  1064. total = recordCount
  1065. };
  1066. return Content(obj.ToJson());
  1067. }
  1068. /// <summary>
  1069. /// 获取公告详情
  1070. /// </summary>
  1071. /// <returns></returns>
  1072. //[WechatActionFilter]
  1073. public ActionResult GetNoticeInfo()
  1074. {
  1075. string strnoticeid = HttpUtility.UrlDecode(RequestString.GetQueryString("noticeid"));
  1076. string stropenid = HttpUtility.UrlDecode(RequestString.GetQueryString("openid"));
  1077. if (string.IsNullOrEmpty(strnoticeid))
  1078. return Error("参数错误");
  1079. if (string.IsNullOrEmpty(stropenid))
  1080. return Error("参数错误!");
  1081. var dModel = new BLL.T_Msg_NoticeInfo().GetModel(int.Parse(strnoticeid.Trim()));
  1082. Model.T_Sys_UserAccount userModel = new Model.T_Sys_UserAccount();
  1083. if (dModel != null)
  1084. {
  1085. if (dModel.F_CreateBy != null)
  1086. userModel = userAccountBLL.GetModel(dModel.F_CreateBy.Value);
  1087. var uname = "";
  1088. if (userModel != null)
  1089. uname = userModel.F_UserName;
  1090. #region 标记为已读
  1091. var nowUser = userAccountBLL.GetModelByOpenid(stropenid);
  1092. var nowCus = customerBaseBLL.GetModelByOpenid(stropenid);
  1093. var usercode = "";
  1094. if (nowUser != null)
  1095. {
  1096. usercode = nowUser.F_UserCode;
  1097. var msglist = new BLL.T_Msg_List().GetModelList(" State=0 and ToUser='" + usercode + "' and Type=5 and ToID=" + dModel.F_NoticeId);
  1098. foreach (var item in msglist)
  1099. {
  1100. item.State = 1;
  1101. item.ReadDate = DateTime.Now;
  1102. new BLL.T_Msg_List().Update(item);
  1103. }
  1104. }
  1105. else if (nowCus != null)
  1106. {
  1107. usercode = nowCus.F_CustomerCode;
  1108. Model.T_Msg_List msg = new Model.T_Msg_List();
  1109. msg.Type = (int)Model.MSGType.cusnotice;
  1110. msg.ToUser = usercode;
  1111. msg.ToID = dModel.F_NoticeId;
  1112. msg.Detail = "客户" + usercode + "查看了公告《" + dModel.F_Title + "》";
  1113. msg.State = 1;
  1114. msg.IsDel = 0;
  1115. msg.CreateDate = DateTime.Now;
  1116. msg.ReadDate = DateTime.Now;
  1117. new BLL.T_Msg_List().Add(msg);
  1118. }
  1119. #endregion
  1120. var obj = new
  1121. {
  1122. F_NoticeId = dModel.F_NoticeId,
  1123. F_Title = dModel.F_Title,
  1124. F_Content = dModel.F_Content,
  1125. F_isCus = dModel.F_isCus,
  1126. F_CreateOn = dModel.F_CreateOn,
  1127. F_CreateBy = dModel.F_CreateBy,
  1128. F_CreateByName = uname,
  1129. F_UserId = dModel.F_UserId,
  1130. F_RoleId = dModel.F_RoleId,
  1131. };
  1132. return Success("获取公告详情成功", dModel);
  1133. }
  1134. else
  1135. return Error("获取公告详情失败");
  1136. }
  1137. #endregion
  1138. #region 微信工单
  1139. ///// <summary>
  1140. ///// 获取工单列表
  1141. ///// </summary>
  1142. ///// <returns></returns>
  1143. //[WechatActionFilter]
  1144. //public ActionResult GetList()
  1145. //{
  1146. // workorder.WorkOrderController wo = new workorder.WorkOrderController();
  1147. // var config = new BLL.T_Sys_SystemConfig().GetModelList(" F_ParamCode='TimeLimitDays' ").FirstOrDefault();
  1148. // int days = config != null ? Convert.ToInt32(config.F_ParamValue) : 60; //默认60天
  1149. // DataTable dt = new DataTable();
  1150. // int recordCount = 0;
  1151. // string stropenid = HttpUtility.UrlDecode(RequestString.GetQueryString("openid"));
  1152. // //客户姓名,电话,房间号,工单号
  1153. // string keyword = HttpUtility.UrlDecode(RequestString.GetQueryString("keyword"));
  1154. // //工单状态(ltype:)
  1155. // string strltype = HttpUtility.UrlDecode(RequestString.GetQueryString("ltype"));
  1156. // //工单状态
  1157. // int states = RequestString.GetInt("states", -1);
  1158. // //工单来源
  1159. // int strtype = RequestString.GetInt("type", 0);
  1160. // //工单类型
  1161. // int strtypeclass = RequestString.GetInt("typeclass", 0);
  1162. // //工单起止时间
  1163. // string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
  1164. // string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
  1165. // //来电单位
  1166. // string lddep = HttpUtility.UrlDecode(RequestString.GetQueryString("lddep"));
  1167. // //20180329 来电弹屏工单记录根据反馈单位获取列表 可以看到同一坐席组的所有人的工单记录
  1168. // string fkdep = HttpUtility.UrlDecode(RequestString.GetQueryString("fkdep"));
  1169. // int isldtp = RequestString.GetQueryInt("isldtp", 0);
  1170. // //微信列表(0未审核微信列表,1已审核微信列表)
  1171. // int isaudit = RequestString.GetInt("isaudit", -1);
  1172. // string strpageindex = RequestString.GetQueryString("page");
  1173. // int pageindex = 1;
  1174. // string strpagesize = RequestString.GetQueryString("pagesize");
  1175. // int pagesize = 10;
  1176. // #region sql 语句相关处理
  1177. // string sql = " ";
  1178. // //获取坐席表信息
  1179. // var ua = userAccountBLL.GetModelList(" F_WxOpenId='" + stropenid + "'").FirstOrDefault();
  1180. // //获取客户档案(业主)表信息
  1181. // var modelCustomer = customerBaseBLL.GetModelList(" F_WxOpenId='" + stropenid.Trim() + "'").FirstOrDefault();
  1182. // #region 权限限制
  1183. // string mobile = "", roomno = "";
  1184. // int customerid = 0, areaid = 0, proid = 0, buildingid = 0;
  1185. // if (ua != null)
  1186. // {
  1187. // int deptid = ua.F_DeptId; //部门id
  1188. // string deptCode = ua.F_DeptCode; //部门code
  1189. // int userRegionId = ua.RegionId; //项目id
  1190. // //部门信息
  1191. // var modelDep = new BLL.T_Sys_Department().GetModel(deptid);
  1192. // int depType = 0, depRegion = 0;
  1193. // if (modelDep != null)
  1194. // {
  1195. // depType = modelDep.F_Type ?? 0; //部门操作权限:1接待部,2办理人员,3区域客服,4监管
  1196. // depRegion = modelDep.F_Header ?? 0; //部门权限范围:9全部,1区域,2项目,3期
  1197. // }
  1198. // if (ua.F_RoleId != 17)
  1199. // {
  1200. // if (depType == 2)
  1201. // {
  1202. // if (depRegion == 1)
  1203. // {
  1204. // // 查看该区域工单
  1205. // //sql += $" and IsUserSend = (SELECT TOP 1 F_ParentId FROM dbo.T_Cus_RegionCategory WHERE F_RegionId = {userRegionId}) ";
  1206. // sql += $" and IsUserSend = {userRegionId} ";
  1207. // }
  1208. // else if (depRegion == 2)
  1209. // {
  1210. // // 查看该项目工单
  1211. // sql += $" and IsAdminSend = {userRegionId} ";
  1212. // }
  1213. // }
  1214. // else if (depType == 3)
  1215. // {
  1216. // if (depRegion == 1)
  1217. // {
  1218. // // 查看该区域工单
  1219. // //sql += $" and IsUserSend = (SELECT TOP 1 F_ParentId FROM dbo.T_Cus_RegionCategory WHERE F_RegionId = {userRegionId}) ";
  1220. // sql += $" and IsUserSend = {userRegionId} ";
  1221. // }
  1222. // }
  1223. // else if (depType == 4)
  1224. // {
  1225. // if (depRegion == 2)
  1226. // {
  1227. // // 查看该项目工单
  1228. // sql += $" and IsAdminSend = {userRegionId} ";
  1229. // }
  1230. // else if (depRegion == 9)
  1231. // {
  1232. // // 查看该部门工单(包括一级,二级)
  1233. // string deptCodeNew = String.Empty;
  1234. // int deptCodeIndex = 0; //变量声明
  1235. // string deptCodeN = deptCode.TrimEnd('|'); //去掉最后一个|
  1236. // deptCodeIndex = deptCodeN.LastIndexOf("|"); //获得|的索引
  1237. // deptCodeNew = deptCodeN.Substring(0, deptCodeIndex + 1); //获得目标字符串(//去掉最后一个|后面的字符串)
  1238. // //============== 部门权限条件 - 部门 ================
  1239. // string arrUser = " select F_UserCode from T_Sys_UserAccount where F_DeptCode LIKE '" + deptCodeNew + "%' ";
  1240. // sql += $" and WorkOrderID in (SELECT DISTINCT WorkOrderID FROM dbo.T_Wo_WorkOrderItem WHERE ToUser IN ({arrUser})) ";
  1241. // }
  1242. // }
  1243. // }
  1244. // string uwhere = " ";
  1245. // switch (strltype)
  1246. // {
  1247. // case "0"://待指派的
  1248. // //sql += " and State ='0' and CreateUser= '" + ua.F_UserCode + "' ";
  1249. // if (ua.F_RoleId != 17 && depType != 1 && depType != 3)
  1250. // {
  1251. // uwhere += " and CreateUser='" + ua.F_UserCode + "' ";
  1252. // }
  1253. // sql += " and State ='0' " + uwhere;
  1254. // break;
  1255. // case "1"://待接单的
  1256. // sql += " and State ='1' and WorkOrderID in ( '" + wo.GetDJDWorkOrderID(ua.F_UserCode) + "') ";
  1257. // break;
  1258. // case "2"://待完成的
  1259. // sql += " and State ='1' and WorkOrderID in ( '" + wo.GetDWCWorkOrderID(ua.F_UserCode) + "') ";
  1260. // break;
  1261. // case "3"://已完成的
  1262. // sql += " and State ='2' and LastDealUser = '" + ua.F_UserCode + "' ";
  1263. // break;
  1264. // case "4"://我参与的
  1265. // sql += " and (CreateUser= '" + ua.F_UserCode + "' or WorkOrderID in ( '" + wo.GetCYWorkOrderID(ua.F_UserCode) + "')) ";
  1266. // break;
  1267. // case "5"://超期工单 - 设置两个月的处理时效,两个月内未解决的工单都直接汇总到这里
  1268. // sql += $" and DATEADD(DAY,{days},CreateTime) < GETDATE() AND State < 2 ";
  1269. // break;
  1270. // }
  1271. // }
  1272. // else if (modelCustomer != null)
  1273. // {
  1274. // #region 根据openid获取所有工单号
  1275. // //var wxuser = new BLL.T_Sys_Users().GetModelList(" F_OpenId='" + stropenid.Trim() + "' and F_Type=1 ").FirstOrDefault();
  1276. // //if (wxuser != null)
  1277. // //{
  1278. // // sql += " and id in (select distinct F_WorkOrderID from T_WO_UserWorkOrder where F_UserId='" + wxuser.F_Id + "') ";
  1279. // //}
  1280. // #endregion
  1281. // // ============== 项目权限 - 项目 ============== 不通过项目查询,因为客户可能有多个项目的房产
  1282. // // ============== 电话,区域,项目,楼号,房间号权限条件 - 电话 ================
  1283. // //通过相关电话,区域,项目,楼号,房间号(CustomerTel,IsUserSend,IsAdminSend,IsTimeOut,Address)查询该用户查看的工单
  1284. // //mobile = modelCustomer.F_LegalTel;
  1285. // customerid = modelCustomer.F_CustomerId;
  1286. // //int CustomerClassID = modelCustomer.F_CustomerClassID ?? 0;
  1287. // ////F_Layer区域id F_CategoryId所购项目id F_CustomerType楼号 F_BusinessLicenseID房间号
  1288. // //areaid = modelCustomer.F_Layer ?? 0;
  1289. // //proid = modelCustomer.F_CategoryId ?? 0;
  1290. // //buildingid = modelCustomer.F_CustomerType ?? 0;
  1291. // //roomno = modelCustomer.F_BusinessLicenseID;
  1292. // ////查询业主和相关的亲属租户名下工单
  1293. // //sql += $" and CustomerTel IN (SELECT DISTINCT F_Mobile FROM dbo.T_Cus_CustomerBase WHERE F_CustomerClassID = {customerid} OR F_CustomerId = {customerid}) ";
  1294. // //if (CustomerClassID == 0)
  1295. // //{
  1296. // // //业主查看房屋所有工单
  1297. // // sql += $" and CustomerID IN (SELECT DISTINCT F_CustomerId FROM dbo.T_Cus_CustomerBase WHERE F_CustomerClassID = {customerid} OR F_CustomerId = {customerid}) ";
  1298. // //}
  1299. // //else
  1300. // //{
  1301. // // //租户只可查看自己工单
  1302. // // sql += $" and CustomerID = {customerid} ";
  1303. // //}
  1304. // ////查询相关房间号下工单
  1305. // //if (areaid > 0 && proid > 0 && buildingid > 0 && !string.IsNullOrEmpty(roomno))
  1306. // //{
  1307. // // sql += $" and F_Layer = {areaid} and F_CategoryId = {proid} and F_CustomerType = {buildingid} and F_BusinessLicenseID = '{roomno}' ";
  1308. // //}
  1309. // }
  1310. // else
  1311. // {
  1312. // sql = "";
  1313. // }
  1314. // #endregion
  1315. // if (!string.IsNullOrEmpty(sql))
  1316. // {
  1317. // sql += " and IsDel=0 ";
  1318. // //客户姓名,电话,房间号,工单号,接待描述
  1319. // if (!string.IsNullOrEmpty(keyword))
  1320. // {
  1321. // sql += " and (CustomerTel like '%" + keyword + "%' or Customer like '%" + keyword + "%' or Address like '%" + keyword + "%' or WorkOrderID like '%" + keyword + "%' or Detail like '%" + keyword + "%' ) ";
  1322. // }
  1323. // if (isaudit >= 0)
  1324. // {
  1325. // sql += " and IsAudit = " + isaudit + " "; // ANd Type = (SELECT F_DictionaryValueId FROM dbo.T_Sys_DictionaryValue (NOLOCK) WHERE F_DictionaryFlag = 'GDLY' AND F_Name = '微信')
  1326. // }
  1327. // if (states >= 0)
  1328. // sql += " and State = " + states + " ";
  1329. // if (strtype > 0)
  1330. // {
  1331. // sql += " and Type = " + strtype + " ";
  1332. // }
  1333. // if (strtypeclass > 0)
  1334. // {
  1335. // sql += " and TypeClass = " + strtypeclass + " ";
  1336. // }
  1337. // if (lddep.Trim() != "" && lddep != "undefined")
  1338. // {
  1339. // sql += " and Address = '" + lddep.Trim() + "' ";
  1340. // }
  1341. // if (fkdep.Trim() != "" && fkdep != "undefined")
  1342. // {
  1343. // sql += " and Source = '" + fkdep.Trim() + "' ";
  1344. // }
  1345. // if (strstarttime.Trim() != "" && strstarttime != "undefined")
  1346. // {
  1347. // sql += " and datediff(day,CreateTime,'" + strstarttime + "')<=0 ";
  1348. // }
  1349. // if (strendtime.Trim() != "" && strendtime != "undefined")
  1350. // {
  1351. // sql += " and datediff(day,CreateTime,'" + strendtime + "')>=0 ";
  1352. // }
  1353. // #endregion
  1354. // if (strpageindex.Trim() != "")
  1355. // {
  1356. // pageindex = Convert.ToInt32(strpageindex);
  1357. // }
  1358. // if (strpagesize.Trim() != "")
  1359. // {
  1360. // pagesize = Convert.ToInt32(strpagesize);
  1361. // }
  1362. // 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";
  1363. // dt = BLL.PagerBLL.GetListPager(
  1364. // "T_Wo_WorkOrder (NOLOCK)",
  1365. // "WorkOrderID",
  1366. // cols,
  1367. // sql,
  1368. // "ORDER BY CreateTime DESC",
  1369. // pagesize,
  1370. // pageindex,
  1371. // true,
  1372. // out recordCount);
  1373. // }
  1374. // var obj = new
  1375. // {
  1376. // state = "success",
  1377. // message = "成功",
  1378. // rows = dt,
  1379. // total = recordCount
  1380. // };
  1381. // return Content(obj.ToJson());
  1382. //}
  1383. ///// <summary>
  1384. ///// 获取可催办工单列表
  1385. ///// </summary>
  1386. ///// <returns></returns>
  1387. //[WechatActionFilter]
  1388. //public ActionResult GetNotDoneWorkList()
  1389. //{
  1390. // workorder.WorkOrderController wo = new workorder.WorkOrderController();
  1391. // DataTable dt = new DataTable();
  1392. // int recordCount = 0;
  1393. // string stropenid = HttpUtility.UrlDecode(RequestString.GetQueryString("openid"));
  1394. // //客户姓名,电话,房间号,工单号
  1395. // string keyword = HttpUtility.UrlDecode(RequestString.GetQueryString("keyword"));
  1396. // //工单状态
  1397. // string strltype = HttpUtility.UrlDecode(RequestString.GetQueryString("ltype"));
  1398. // //工单状态
  1399. // int states = RequestString.GetInt("states", -1);
  1400. // //工单来源
  1401. // int strtype = RequestString.GetInt("type", 0);
  1402. // //工单类型
  1403. // int strtypeclass = RequestString.GetInt("typeclass", 0);
  1404. // //工单起止时间
  1405. // string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
  1406. // string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
  1407. // //区域id
  1408. // int areaid = RequestString.GetInt("areaid", 0);
  1409. // //项目id
  1410. // int regionid = RequestString.GetInt("regionid", 0);
  1411. // //期id
  1412. // int buldingid = RequestString.GetInt("buldingid", 0);
  1413. // string uid = HttpUtility.UrlDecode(RequestString.GetQueryString("userid") == "" ? "0" : HttpUtility.UrlDecode(RequestString.GetQueryString("userid")));
  1414. // string strpageindex = RequestString.GetQueryString("page");
  1415. // int pageindex = 1;
  1416. // string strpagesize = RequestString.GetQueryString("pagesize");
  1417. // int pagesize = 10;
  1418. // string sql = " and isdel=0 and State != 2 ";
  1419. // //获取坐席表信息
  1420. // var ua = userAccountBLL.GetModelList(" F_WxOpenId='" + stropenid + "'").FirstOrDefault();
  1421. // //获取客户档案(业主)表信息
  1422. // var modelCustomer = customerBaseBLL.GetModelList(" F_WxOpenId='" + stropenid.Trim() + "'").FirstOrDefault();
  1423. // if (ua != null)
  1424. // {
  1425. // #region 权限限制
  1426. // int deptid = ua.F_DeptId; //部门id
  1427. // string deptCode = ua.F_DeptCode; //部门code
  1428. // int userRegionId = ua.RegionId; //项目id
  1429. // //部门信息
  1430. // var modelDep = new BLL.T_Sys_Department().GetModel(deptid);
  1431. // int depType = 0, depRegion = 0;
  1432. // if (modelDep != null)
  1433. // {
  1434. // depType = modelDep.F_Type ?? 0; //部门操作权限:1接待部,2办理人员,3区域客服,4监管
  1435. // depRegion = modelDep.F_Header ?? 0; //部门权限范围:9全部,1区域,2项目,3期
  1436. // }
  1437. // if (ua.F_RoleId != 17)
  1438. // {
  1439. // if (depType == 2)
  1440. // {
  1441. // if (depRegion == 1)
  1442. // {
  1443. // // 查看该区域工单
  1444. // //sql += $" and IsUserSend = (SELECT TOP 1 F_ParentId FROM dbo.T_Cus_RegionCategory WHERE F_RegionId = {userRegionId}) ";
  1445. // sql += $" and IsUserSend = {userRegionId} ";
  1446. // }
  1447. // else if (depRegion == 2)
  1448. // {
  1449. // // 查看该项目工单
  1450. // sql += $" and IsAdminSend = {userRegionId} ";
  1451. // }
  1452. // }
  1453. // else if (depType == 3)
  1454. // {
  1455. // if (depRegion == 1)
  1456. // {
  1457. // // 查看该区域工单
  1458. // //sql += $" and IsUserSend = (SELECT TOP 1 F_ParentId FROM dbo.T_Cus_RegionCategory WHERE F_RegionId = {userRegionId}) ";
  1459. // sql += $" and IsUserSend = {userRegionId} ";
  1460. // }
  1461. // }
  1462. // else if (depType == 4)
  1463. // {
  1464. // if (depRegion == 2)
  1465. // {
  1466. // // 查看该项目工单
  1467. // sql += $" and IsAdminSend = {userRegionId} ";
  1468. // }
  1469. // else if (depRegion == 9)
  1470. // {
  1471. // // 查看该部门工单(包括一级,二级)
  1472. // string deptCodeNew = String.Empty;
  1473. // int deptCodeIndex = 0; //变量声明
  1474. // string deptCodeN = deptCode.TrimEnd('|'); //去掉最后一个|
  1475. // deptCodeIndex = deptCodeN.LastIndexOf("|"); //获得|的索引
  1476. // deptCodeNew = deptCodeN.Substring(0, deptCodeIndex + 1); //获得目标字符串(//去掉最后一个|后面的字符串)
  1477. // //============== 部门权限条件 - 部门 ================
  1478. // string arrUser = " select F_UserCode from T_Sys_UserAccount where F_DeptCode LIKE '" + deptCodeNew + "%' ";
  1479. // sql += $" and WorkOrderID in (SELECT DISTINCT WorkOrderID FROM dbo.T_Wo_WorkOrderItem WHERE ToUser IN ({arrUser})) ";
  1480. // }
  1481. // }
  1482. // }
  1483. // #endregion
  1484. // //客户姓名,电话,房间号,工单号
  1485. // if (!string.IsNullOrEmpty(keyword))
  1486. // {
  1487. // sql += " and (CustomerTel like '%" + keyword + "%' or Customer like '%" + keyword + "%' or Address like '%" + keyword + "%' or WorkOrderID like '%" + keyword + "%' ) ";
  1488. // }
  1489. // if (states >= 0)
  1490. // sql += " and State = " + states + " ";
  1491. // if (areaid > 0)
  1492. // sql += " and IsUserSend = " + areaid + " ";
  1493. // if (regionid > 0)
  1494. // sql += " and IsAdminSend = " + regionid + " ";
  1495. // if (buldingid > 0)
  1496. // sql += " and IsTimeOut = " + buldingid + " ";
  1497. // //坐席工号
  1498. // if (uid.Trim() != "" && uid != "0")
  1499. // {
  1500. // sql += " and CreateUser = '" + uid + "' ";
  1501. // }
  1502. // if (strtype > 0)
  1503. // {
  1504. // sql += " and Type = " + strtype + " ";
  1505. // }
  1506. // if (strtypeclass > 0)
  1507. // {
  1508. // sql += " and TypeClass = " + strtype + " ";
  1509. // }
  1510. // if (strstarttime.Trim() != "" && strstarttime != "undefined")
  1511. // {
  1512. // sql += " and datediff(day,CreateTime,'" + strstarttime + "')<=0 ";
  1513. // }
  1514. // if (strendtime.Trim() != "" && strendtime != "undefined")
  1515. // {
  1516. // sql += " and datediff(day,CreateTime,'" + strendtime + "')>=0 ";
  1517. // }
  1518. // if (strpageindex.Trim() != "")
  1519. // {
  1520. // pageindex = Convert.ToInt32(strpageindex);
  1521. // }
  1522. // if (strpagesize.Trim() != "")
  1523. // {
  1524. // pagesize = Convert.ToInt32(strpagesize);
  1525. // }
  1526. // dt = BLL.PagerBLL.GetListPager(
  1527. // "T_Wo_WorkOrder",
  1528. // "T_Wo_WorkOrder.ID",
  1529. // "*,(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",
  1530. // sql,
  1531. // "ORDER BY T_Wo_WorkOrder.ID desc",
  1532. // pagesize,
  1533. // pageindex,
  1534. // true,
  1535. // out recordCount);
  1536. // dt.Columns.Add("CBCount", typeof(int));
  1537. // foreach (DataRow dr in dt.Rows)
  1538. // {
  1539. // 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];
  1540. // dr["CBCount"] = list.Rows.Count;
  1541. // }
  1542. // }
  1543. // var obj = new
  1544. // {
  1545. // state = "success",
  1546. // message = "成功",
  1547. // rows = dt,
  1548. // total = recordCount
  1549. // };
  1550. // return Content(obj.ToJson());
  1551. //}
  1552. ///// <summary>
  1553. ///// 新增工单
  1554. ///// </summary>
  1555. ///// <returns></returns>
  1556. //[WechatActionFilter]
  1557. //public ActionResult AddWorkOrder()
  1558. //{
  1559. // DataTable dt = new DataTable();
  1560. // //工单来源
  1561. // int gdly = RequestString.GetFormInt("gdly", 0);
  1562. // //工单类型
  1563. // int gdlx = RequestString.GetFormInt("gdlx", 0);
  1564. // //客户id
  1565. // int customerid = RequestString.GetFormInt("customerid", 0);
  1566. // //客户姓名
  1567. // string callCustomer = RequestString.GetFormString("callCustomer");
  1568. // //联系电话
  1569. // string tel = RequestString.GetFormString("tel");
  1570. // //处理部门
  1571. // string fkdep = RequestString.GetFormString("fkdep");
  1572. // //客服类类型
  1573. // string kfdepid = RequestString.GetFormString("kfdepid");
  1574. // //受理人 - 审核人工号
  1575. // string auditusercode = RequestString.GetFormString("auditusercode");
  1576. // //工单状态
  1577. // int gdzt = RequestString.GetFormInt("gdzt", 0);
  1578. // //接待描述 - 反馈内容
  1579. // string fkcont = RequestString.GetFormString("fkcont");
  1580. // string callid = HttpUtility.UrlDecode(RequestString.GetFormString("callid"));
  1581. // string files = RequestString.GetFormString("files");
  1582. // //咨询类工单指派部门
  1583. // int clbm = RequestString.GetFormInt("clbm", 0);
  1584. // //备注
  1585. // string note = RequestString.GetFormString("note");
  1586. // #region 添加验证判断
  1587. // if (string.IsNullOrEmpty(callCustomer))
  1588. // return Error("姓名不能为空!");
  1589. // if (string.IsNullOrEmpty(tel))
  1590. // return Error("电话不能为空!");
  1591. // #endregion
  1592. // string workOrder = DateTime.Now.ToString("yyyyMMddHHmmssfff"); //工单编号
  1593. // string stropenid = HttpUtility.UrlDecode(RequestString.GetFormString("openid"));
  1594. // var wxuser = new BLL.T_Sys_Users().GetModelList(" F_OpenId='" + stropenid.Trim() + "' and F_Type=1 ").FirstOrDefault();
  1595. // var model = userAccountBLL.GetModelByOpenid(stropenid);
  1596. // var modelCustomer = customerBaseBLL.GetModelList(" F_WxOpenId='" + stropenid.Trim() + "'").FirstOrDefault(); //customerBaseBLL.GetModelByOpenid(stropenid);
  1597. // string usercode = "";
  1598. // if (model != null)
  1599. // {
  1600. // usercode = model.F_UserCode;
  1601. // }
  1602. // else if (modelCustomer != null)
  1603. // {
  1604. // usercode = modelCustomer.F_CustomerCode;
  1605. // customerid = modelCustomer.F_CustomerId;
  1606. // }
  1607. // workorder.WorkOrderController wo = new workorder.WorkOrderController();
  1608. // string workorderid = wo.AddWXWorkOrder(workOrder, gdly, gdlx, customerid, callCustomer, tel, fkdep, kfdepid, auditusercode, fkcont, files, gdzt, note, usercode,-1);
  1609. // if (string.IsNullOrEmpty(workorderid))
  1610. // {
  1611. // return Error("新增失败");
  1612. // }
  1613. // else
  1614. // {
  1615. // #region 咨询类工单指派至部门
  1616. // //工单类型(107咨询,108投诉)
  1617. // if (gdlx == 107)
  1618. // {
  1619. // //需要审核后,再处理
  1620. // //bool b = wo.DealWXWorkOrder(workOrder, 0, 0, clbm, 0, "", fkcont, stropenid);
  1621. // }
  1622. // #endregion
  1623. // //暂时排除客户档案用户(F_UserId无法区分是住户添加 还是管理员添加) - 后期完善
  1624. // if (wxuser != null)
  1625. // {
  1626. // Model.T_WO_UserWorkOrder tbu = new Model.T_WO_UserWorkOrder();
  1627. // tbu.F_UserId = wxuser.F_Id;
  1628. // tbu.F_WorkOrderId = workorderid;
  1629. // new BLL.T_WO_UserWorkOrder().Add(tbu);
  1630. // }
  1631. // return Success("新增成功", workorderid);
  1632. // }
  1633. //}
  1634. ///// <summary>
  1635. ///// 修改工单
  1636. ///// </summary>
  1637. ///// <returns></returns>
  1638. //[WechatActionFilter]
  1639. //public ActionResult UpdateWorkOrder()
  1640. //{
  1641. // DataTable dt = new DataTable();
  1642. // //工单id
  1643. // string workorderid = RequestString.GetFormString("orderid");
  1644. // //工单来源
  1645. // int gdly = RequestString.GetFormInt("gdly", 0);
  1646. // //工单类型
  1647. // int gdlx = RequestString.GetFormInt("gdlx", 0);
  1648. // //客户id
  1649. // int customerid = RequestString.GetFormInt("customerid", 0);
  1650. // //客户姓名
  1651. // string callCustomer = RequestString.GetFormString("callCustomer");
  1652. // //联系电话
  1653. // string tel = RequestString.GetFormString("tel");
  1654. // //处理部门
  1655. // string fkdep = RequestString.GetFormString("fkdep");
  1656. // //客服类类型
  1657. // string kfdepid = RequestString.GetFormString("kfdepid");
  1658. // //受理人 - 审核人工号
  1659. // string auditusercode = RequestString.GetFormString("auditusercode");
  1660. // //接待描述 - 反馈内容
  1661. // string fkcont = RequestString.GetFormString("fkcont");
  1662. // string files = RequestString.GetFormString("files");
  1663. // //备注
  1664. // string note = RequestString.GetFormString("note");
  1665. // string stropenid = HttpUtility.UrlDecode(RequestString.GetFormString("openid"));
  1666. // //var wxuser = new BLL.T_Sys_Users().GetModelList(" F_OpenId='" + stropenid.Trim() + "' and F_Type=1 ").FirstOrDefault();
  1667. // if (!string.IsNullOrEmpty(stropenid))
  1668. // {
  1669. // var ua = new BLL.T_Sys_UserAccount().GetModelList(" F_WxOpenId='" + stropenid + "'").FirstOrDefault();
  1670. // if (ua != null)
  1671. // {
  1672. // WorkOrderController wo = new WorkOrderController();
  1673. // if (!string.IsNullOrEmpty(workorderid))
  1674. // {
  1675. // var models = new BLL.T_Wo_WorkOrder().GetModelList(" WorkOrderID='" + workorderid + "'");
  1676. // if (models.Count > 0)
  1677. // {
  1678. // var model = models.FirstOrDefault();
  1679. // string detail = model.Detail;
  1680. // model.Type = gdly; //工单来源
  1681. // model.TypeClass = gdlx; //投诉类型 -工单类型
  1682. // model.Customer = callCustomer; //客户姓名
  1683. // model.CustomerTel = tel; //联系电话
  1684. // //model.CustomerID = customerid; //用户档案Id
  1685. // model.Source = fkdep; //处理部门 反馈单位
  1686. // model.CreateUserID = kfdepid; //客服类类型
  1687. // model.AuditUser = auditusercode; //受理人 - 审核人工号
  1688. // //model.CreateUser = ua.F_UserCode; //接待人(工号)
  1689. // //model.State = 0; //工单状态
  1690. // //反馈内容
  1691. // var detailutf8 = System.Web.HttpUtility.UrlDecode(fkcont, System.Text.Encoding.UTF8);
  1692. // model.Detail = detailutf8;
  1693. // if (new BLL.T_Wo_WorkOrder().Update(model))
  1694. // {
  1695. // //添加工单修改操作日志
  1696. // wo.WriteWorkOrderLog(workorderid, detail, detailutf8, ua.F_UserCode, 0, "", 1, "修改工单(微信端)");
  1697. // return Success("修改成功!");
  1698. // }
  1699. // }
  1700. // }
  1701. // }
  1702. // }
  1703. // return Error("修改失败!");
  1704. //}
  1705. ///// <summary>
  1706. ///// 处理工单
  1707. ///// </summary>
  1708. ///// <returns></returns>
  1709. //[WechatActionFilter]
  1710. //public ActionResult DealWorkOrder()
  1711. //{
  1712. // DataTable dt = new DataTable();
  1713. // string orderid = RequestString.GetFormString("orderid");
  1714. // int isend = RequestString.GetInt("isend", 0); //0转派
  1715. // int ltype = RequestString.GetInt("ltype", 0); //处理方式 1结束 0转派
  1716. // int clbm = RequestString.GetInt("clbm", 0); //部门id
  1717. // int clid = RequestString.GetInt("clid", 0); //用户接收人id
  1718. // string cont = RequestString.GetFormString("cont"); //处理内容
  1719. // string detail = RequestString.GetFormString("detail");
  1720. // string stropenid = HttpUtility.UrlDecode(RequestString.GetFormString("openid"));
  1721. // workorder.WorkOrderController wo = new workorder.WorkOrderController();
  1722. // bool res = wo.DealWXWorkOrder(orderid, isend, ltype, clbm, clid, cont, detail, stropenid);
  1723. // if (res)
  1724. // {
  1725. // return Success("操作成功");
  1726. // }
  1727. // else
  1728. // {
  1729. // return Error("操作失败");
  1730. // }
  1731. //}
  1732. ///// <summary>
  1733. ///// 接单 - 确认工单
  1734. ///// </summary>
  1735. ///// <returns></returns>
  1736. //[WechatActionFilter]
  1737. //public ActionResult SureWorkOrder()
  1738. //{
  1739. // string stropenid = HttpUtility.UrlDecode(RequestString.GetFormString("openid"));
  1740. // string orderid = RequestString.GetFormString("orderid");
  1741. // if (!string.IsNullOrEmpty(stropenid))
  1742. // {
  1743. // var ua = new BLL.T_Sys_UserAccount().GetModelList(" F_WxOpenId='" + stropenid + "'").FirstOrDefault();
  1744. // if (ua != null)
  1745. // {
  1746. // Model.T_Wo_WorkOrder model = new BLL.T_Wo_WorkOrder().GetModelList(" WorkOrderID='" + orderid + "'").FirstOrDefault();
  1747. // if (model != null)
  1748. // {
  1749. // Model.T_Wo_WorkOrderItem item = new BLL.T_Wo_WorkOrderItem().GetModelList(" WorkOrderID='" + orderid + "' and isdel=0 and Type=1 ").OrderByDescending(p => p.CreateTime).FirstOrDefault();
  1750. // if (item != null && item.State == 0 && ("," + item.ToUser + ",").Contains("," + ua.F_UserCode + ","))
  1751. // {
  1752. // item.SureUser = ua.F_UserCode;
  1753. // item.State = 1;
  1754. // item.SureTime = DateTime.Now;
  1755. // if (new BLL.T_Wo_WorkOrderItem().Update(item))
  1756. // {
  1757. // return Success("接单成功!");
  1758. // }
  1759. // }
  1760. // return Error("操作失败,工单还没有派单!");
  1761. // }
  1762. // }
  1763. // return Error("操作失败");
  1764. // }
  1765. // return Error("参数错误");
  1766. //}
  1767. ///// <summary>
  1768. ///// 催办工单(管理员,业主)
  1769. ///// </summary>
  1770. ///// <returns></returns>
  1771. //[WechatActionFilter]
  1772. //public ActionResult RemindWorkOrder()
  1773. //{
  1774. // string stropenid = HttpUtility.UrlDecode(RequestString.GetFormString("openid"));
  1775. // if (!string.IsNullOrEmpty(stropenid))
  1776. // {
  1777. // var ua = new BLL.T_Sys_UserAccount().GetModelList(" F_WxOpenId='" + stropenid + "'").FirstOrDefault();
  1778. // string usercode = string.Empty;
  1779. // string username = string.Empty;
  1780. // if (ua != null)
  1781. // {
  1782. // usercode = ua.F_UserCode;
  1783. // username = ua.F_UserName;
  1784. // }
  1785. // else
  1786. // {
  1787. // //获取客户档案(业主)表信息
  1788. // var modelCustomer = customerBaseBLL.GetModelList(" F_WxOpenId='" + stropenid.Trim() + "'").FirstOrDefault();
  1789. // if (modelCustomer != null)
  1790. // {
  1791. // usercode = modelCustomer.F_CustomerCode;
  1792. // username = modelCustomer.F_CompanyName;
  1793. // }
  1794. // }
  1795. // if (string.IsNullOrEmpty(usercode))
  1796. // return Error("参数错误!");
  1797. // string orderid = RequestString.GetFormString("orderid");
  1798. // string cont = RequestString.GetFormString("cont");
  1799. // string callid = RequestString.GetFormString("callid");
  1800. // Model.T_Wo_WorkOrder model = new BLL.T_Wo_WorkOrder().GetModelList(" WorkOrderID='" + orderid + "'").FirstOrDefault();
  1801. // if (model != null)
  1802. // {
  1803. // 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();
  1804. // Model.T_Wo_WorkOrderItem item = new Model.T_Wo_WorkOrderItem();
  1805. // if (itemlast != null)
  1806. // {
  1807. // item.ToDept = itemlast.ToDept;
  1808. // item.ToUser = itemlast.ToUser;
  1809. // }
  1810. // else
  1811. // {
  1812. // var cu = new BLL.T_Sys_UserAccount().GetModel(model.CreateUser);
  1813. // if (cu != null)
  1814. // {
  1815. // item.ToDept = cu.F_DeptId;
  1816. // item.ToUser = cu.F_UserCode;
  1817. // }
  1818. // else {
  1819. // var modelCus = customerBaseBLL.GetModelList(" F_CustomerCode='" + model.CreateUser + "'").FirstOrDefault(); //customerBaseBLL.GetModel(model.CreateUser);
  1820. // if (modelCus != null)
  1821. // {
  1822. // item.ToDept = 0;
  1823. // item.ToUser = modelCus.F_LegalTel;
  1824. // }
  1825. // }
  1826. // }
  1827. // item.WorkOrderID = orderid;
  1828. // item.Type = 2;
  1829. // item.Detail = cont;
  1830. // item.CallID = callid;
  1831. // item.State = 0;
  1832. // item.IsDel = 0;
  1833. // item.IsLast = 0;
  1834. // item.IsStart = 0;
  1835. // item.IsTimeOut = 0;
  1836. // item.CreateUser = usercode; // ua.F_UserCode;
  1837. // item.CreateTime = DateTime.Now;
  1838. // long itemid = new BLL.T_Wo_WorkOrderItem().Add(item);
  1839. // if (itemid > 0 && !string.IsNullOrEmpty(item.ToUser))
  1840. // {
  1841. // foreach (string ur in item.ToUser.Split(','))
  1842. // {
  1843. // Model.T_Msg_List msg = new Model.T_Msg_List();
  1844. // msg.Type = 1;
  1845. // msg.ToUser = ur;
  1846. // msg.ToID = Int32.Parse(itemid.ToString());
  1847. // msg.Detail = username + "向你催办了工单,单号:" + model.WorkOrderID;
  1848. // msg.State = 0;
  1849. // msg.IsDel = 0;
  1850. // msg.CreateUser = usercode;
  1851. // msg.CreateDate = DateTime.Now;
  1852. // new BLL.T_Msg_List().Add(msg);
  1853. // }
  1854. // return Success("催办成功!");
  1855. // }
  1856. // }
  1857. // }
  1858. // return Error("参数错误");
  1859. //}
  1860. ///// <summary>
  1861. ///// 退回工单
  1862. ///// </summary>
  1863. ///// <param name="input"></param>
  1864. ///// <returns></returns>
  1865. //[WechatActionFilter]
  1866. //public ActionResult BackWorkOrder()
  1867. //{
  1868. // string stropenid = HttpUtility.UrlDecode(RequestString.GetFormString("openid"));
  1869. // if (!string.IsNullOrEmpty(stropenid))
  1870. // {
  1871. // var ua = new BLL.T_Sys_UserAccount().GetModelList(" F_WxOpenId='" + stropenid + "'").FirstOrDefault();
  1872. // if (ua != null)
  1873. // {
  1874. // string orderid = RequestString.GetFormString("orderid");
  1875. // var model = new BLL.T_Wo_WorkOrder().GetModelList(" WorkOrderID='" + orderid + "'").FirstOrDefault();
  1876. // //验证信息
  1877. // if (model == null)
  1878. // {
  1879. // return Error("工单不存在");
  1880. // }
  1881. // model.State = 0;
  1882. // if (new BLL.T_Wo_WorkOrder().Update(model))
  1883. // {
  1884. // 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();
  1885. // if (modelItem != null)
  1886. // {
  1887. // modelItem.State = 6;
  1888. // new BLL.T_Wo_WorkOrderItem().Update(modelItem);
  1889. // }
  1890. // return Success("操作成功");
  1891. // }
  1892. // return Error("操作失败");
  1893. // }
  1894. // }
  1895. // return Error("操作失败");
  1896. //}
  1897. ///// <summary>
  1898. ///// 评论工单(管理人员,业主)
  1899. ///// </summary>
  1900. ///// <returns></returns>
  1901. //[WechatActionFilter]
  1902. //public ActionResult CommentWorkOrder()
  1903. //{
  1904. // string stropenid = HttpUtility.UrlDecode(RequestString.GetFormString("openid"));
  1905. // if (!string.IsNullOrEmpty(stropenid))
  1906. // {
  1907. // var ua = new BLL.T_Sys_UserAccount().GetModelList(" F_WxOpenId='" + stropenid + "'").FirstOrDefault();
  1908. // string usercode = string.Empty;
  1909. // string username = string.Empty;
  1910. // if (ua != null)
  1911. // {
  1912. // usercode = ua.F_UserCode;
  1913. // username = ua.F_UserName;
  1914. // }
  1915. // else
  1916. // {
  1917. // //获取客户档案(业主)表信息
  1918. // var modelCustomer = customerBaseBLL.GetModelList(" F_WxOpenId='" + stropenid.Trim() + "'").FirstOrDefault();
  1919. // if (modelCustomer != null)
  1920. // {
  1921. // usercode = modelCustomer.F_CustomerCode;
  1922. // username = modelCustomer.F_CompanyName;
  1923. // }
  1924. // }
  1925. // if (string.IsNullOrEmpty(usercode))
  1926. // return Error("参数错误!");
  1927. // string orderid = RequestString.GetFormString("orderid");
  1928. // string cont = RequestString.GetFormString("cont");
  1929. // string file = RequestString.GetFormString("file");
  1930. // Model.T_Wo_WorkOrder model = new BLL.T_Wo_WorkOrder().GetModelList(" WorkOrderID='" + orderid + "'").FirstOrDefault();
  1931. // if (model != null)
  1932. // {
  1933. // Model.T_Wo_WorkOrderItem item = new Model.T_Wo_WorkOrderItem();
  1934. // item.WorkOrderID = orderid;
  1935. // item.Type = 3; //评论
  1936. // item.Detail = cont;
  1937. // item.Files = file;
  1938. // item.State = 0;
  1939. // item.IsDel = 0;
  1940. // item.IsStart = 0;
  1941. // item.IsTimeOut = 0;
  1942. // item.IsLast = 0;
  1943. // item.CreateUser = usercode;
  1944. // item.CreateTime = DateTime.Now;
  1945. // if (new BLL.T_Wo_WorkOrderItem().Add(item) > 0)
  1946. // {
  1947. // return Success("评论成功!");
  1948. // }
  1949. // }
  1950. // }
  1951. // return Error("操作失败");
  1952. //}
  1953. ///// <summary>
  1954. ///// 刪除工单
  1955. ///// </summary>
  1956. ///// <returns></returns>
  1957. //[WechatActionFilter]
  1958. //public ActionResult DelWorkOrder(string[] ids)
  1959. //{
  1960. // string stropenid = HttpUtility.UrlDecode(RequestString.GetFormString("openid"));
  1961. // if (!string.IsNullOrEmpty(stropenid))
  1962. // {
  1963. // var ua = new BLL.T_Sys_UserAccount().GetModelList(" F_WxOpenId='" + stropenid + "'").FirstOrDefault();
  1964. // if (ua != null)
  1965. // {
  1966. // if (ids != null && ids.Length > 0)
  1967. // {
  1968. // string idd = " ";
  1969. // foreach (string str in ids)
  1970. // {
  1971. // idd += str + ",";
  1972. // }
  1973. // string sql = "update T_Wo_WorkOrder set IsDel=1,DelUser='" + ua.F_UserCode + "',DelTime=getdate() where ID in (" + idd.TrimEnd(',') + ")";
  1974. // if (!string.IsNullOrEmpty(idd.Trim()))
  1975. // {
  1976. // if (DbHelperSQL.ExecuteSql(sql) > 0)
  1977. // {
  1978. // return Success("删除成功");
  1979. // }
  1980. // }
  1981. // else
  1982. // {
  1983. // return Error("请选择记录");
  1984. // }
  1985. // }
  1986. // else
  1987. // {
  1988. // return Error("获取参数失败");
  1989. // }
  1990. // }
  1991. // }
  1992. // return Error("操作失败");
  1993. //}
  1994. ///// <summary>
  1995. ///// 获取工单详情
  1996. ///// </summary>
  1997. ///// <returns></returns>
  1998. //[WechatActionFilter]
  1999. //public ActionResult GetWorkOrder()
  2000. //{
  2001. // string strworkorderid = HttpUtility.UrlDecode(RequestString.GetQueryString("workorderid"));
  2002. // string stropenid = HttpUtility.UrlDecode(RequestString.GetQueryString("openid"));
  2003. // if (string.IsNullOrEmpty(strworkorderid))
  2004. // return Error("参数错误");
  2005. // if (string.IsNullOrEmpty(stropenid))
  2006. // return Error("参数错误!");
  2007. // #region pc端工单也可以查看,所以注释(注释功能只能查看自己创建的工单)
  2008. // //var wxuser = new BLL.T_Sys_Users().GetModelList(" F_OpenId='" + stropenid.Trim() + "' and F_Type=1 ").FirstOrDefault();
  2009. // //if (wxuser != null)
  2010. // //{
  2011. // // var tbu = new BLL.T_WO_UserWorkOrder().GetList(" F_UserId='" + wxuser.F_Id + "' and F_WorkOrderId=" + strworkorderid + " ").Tables[0];
  2012. // // if (tbu.Rows.Count > 0)
  2013. // // {
  2014. // // }
  2015. // //}
  2016. // #endregion
  2017. // 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 "
  2018. // + " from T_Wo_WorkOrder where WorkOrderID ='" + strworkorderid + "' ";
  2019. // var dt = DbHelperSQL.Query(sql).Tables[0];
  2020. // if (dt.Rows.Count > 0)
  2021. // {
  2022. // var config = new BLL.T_Sys_SystemConfig().GetModelList(" F_ParamCode='PlayPath' ").FirstOrDefault();
  2023. // var configfj = new BLL.T_Sys_SystemConfig().GetModelList(" F_ParamCode='FileUrlPath' ").FirstOrDefault();
  2024. // if (configfj != null)
  2025. // {
  2026. // dt = BindFileData(dt, configfj.F_ParamValue);
  2027. // }
  2028. // string gcsql = "select *,dbo.GetUserName(CreateUser) as UserName "
  2029. // + "from T_Wo_WorkOrderItem where IsDel=0 and WorkOrderID ='" + dt.Rows[0]["WorkOrderId"] + "'";
  2030. // var gcdt = DbHelperSQL.Query(gcsql).Tables[0];
  2031. // dt.Columns.Add("FilePath", typeof(string));
  2032. // if (configfj != null || config != null)
  2033. // {
  2034. // foreach (DataRow bldr in dt.Rows)
  2035. // {
  2036. // if (bldr["CallID"] != null && config != null)
  2037. // {
  2038. // bldr["FilePath"] = GetCallPath(bldr["CallID"].ToString(), config.F_ParamValue);
  2039. // }
  2040. // }
  2041. // }
  2042. // var obj = new
  2043. // {
  2044. // data = dt,
  2045. // item = gcdt
  2046. // };
  2047. // return Success("查询成功", obj);
  2048. // }
  2049. // return Error("查询失败");
  2050. //}
  2051. ///// <summary>
  2052. ///// 获取工单明细列表
  2053. ///// </summary>
  2054. ///// <returns></returns>
  2055. //[WechatActionFilter]
  2056. //public ActionResult GetItemList()
  2057. //{
  2058. // string sql = " and IsDel=0 ";
  2059. // DataTable dt = new DataTable();
  2060. // string strid = HttpUtility.UrlDecode(RequestString.GetQueryString("workorderid"));
  2061. // string strtype = HttpUtility.UrlDecode(RequestString.GetQueryString("type"));
  2062. // string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
  2063. // string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
  2064. // string strpageindex = RequestString.GetQueryString("page");
  2065. // int pageindex = 1;
  2066. // string strpagesize = RequestString.GetQueryString("pagesize");
  2067. // int pagesize = 10;
  2068. // if (strid.Trim() != "" && strid != "undefined")
  2069. // {
  2070. // sql += " and WorkOrderID = '" + strid.Trim() + "' ";
  2071. // }
  2072. // if (strtype.Trim() != "" && strtype != "undefined")
  2073. // {
  2074. // sql += " and Type = '" + strtype.Trim() + "' ";
  2075. // }
  2076. // if (strstarttime.Trim() != "" && strstarttime != "undefined")
  2077. // {
  2078. // sql += " and datediff(day,CreateTime,'" + strstarttime + "')<=0 ";
  2079. // }
  2080. // if (strendtime.Trim() != "" && strendtime != "undefined")
  2081. // {
  2082. // sql += " and datediff(day,CreateTime,'" + strendtime + "')>=0 ";
  2083. // }
  2084. // if (strpageindex.Trim() != "")
  2085. // {
  2086. // pageindex = Convert.ToInt32(strpageindex);
  2087. // }
  2088. // if (strpagesize.Trim() != "")
  2089. // {
  2090. // pagesize = Convert.ToInt32(strpagesize);
  2091. // }
  2092. // int recordCount = 0;
  2093. // dt = BLL.PagerBLL.GetListPager(
  2094. // "T_Wo_WorkOrderItem",
  2095. // "T_Wo_WorkOrderItem.ID",
  2096. // "*,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",
  2097. // sql,
  2098. // "ORDER BY T_Wo_WorkOrderItem.ID desc",
  2099. // pagesize,
  2100. // pageindex,
  2101. // true,
  2102. // out recordCount);
  2103. // var obj = new
  2104. // {
  2105. // state = "success",
  2106. // message = "成功",
  2107. // rows = dt,
  2108. // total = recordCount
  2109. // };
  2110. // return Content(obj.ToJson());
  2111. //}
  2112. ///// <summary>
  2113. ///// 获取工作动态列表 - 工单明细动态列表 - 管理员功能
  2114. ///// </summary>
  2115. ///// <returns></returns>
  2116. //[WechatActionFilter]
  2117. //public ActionResult GetWorkOrderItemList()
  2118. //{
  2119. // DataTable dt = new DataTable();
  2120. // string stropenid = HttpUtility.UrlDecode(RequestString.GetQueryString("openid"));
  2121. // //string stropenid = "oXF5e1mWpX5DajW5_yjNLPKb8ThE";
  2122. // //获取客户档案(业主)表信息
  2123. // var model = userAccountBLL.GetModelList(" F_WxOpenId='" + stropenid + "'").FirstOrDefault();
  2124. // string sql = " and IsDel=0 ";
  2125. // string daytype = HttpUtility.UrlDecode(RequestString.GetQueryString("daytype"));
  2126. // string strpageindex = RequestString.GetQueryString("page");
  2127. // int pageindex = 1;
  2128. // string strpagesize = RequestString.GetQueryString("pagesize");
  2129. // int pagesize = 10;
  2130. // #region 权限限制
  2131. // //if (model != null) {
  2132. // // var sqlUser = "";
  2133. // // //部门信息
  2134. // // var modelDep = new BLL.T_Sys_Department().GetModel(model.F_DeptId);
  2135. // // int depType = 0, depRegion = 0;
  2136. // // if (modelDep != null)
  2137. // // {
  2138. // // depType = modelDep.F_Type ?? 0; //部门操作权限:1接待部,2办理人员,3区域客服,4监管
  2139. // // depRegion = modelDep.F_Header ?? 0; //部门权限范围:9全部,1区域,2项目,3期
  2140. // // }
  2141. // // //根据部门查询工单(可查看当前部门工单)
  2142. // // string deptCode = model.F_DeptCode; //部门code
  2143. // // int userRegionId = model.RegionId; //项目id
  2144. // // ////接待部(坐席)可以看到所有的工单
  2145. // // //if (model.F_RoleId != 17 && depType != 1)
  2146. // // //{
  2147. // // // //if (depType == 2 || depType == 3)
  2148. // // // //{
  2149. // // // // // ============== 项目权限 - 项目 ==============
  2150. // // // // sqlUser += $" and IsAdminSend = {userRegionId} ";
  2151. // // // //}
  2152. // // // //else if (depType == 4)
  2153. // // // //{
  2154. // // // // // 查看该部门工单(包括一级,二级)
  2155. // // // // string deptCodeNew = String.Empty;
  2156. // // // // int deptCodeIndex = 0; //变量声明
  2157. // // // // string deptCodeN = deptCode.TrimEnd('|'); //去掉最后一个|
  2158. // // // // deptCodeIndex = deptCodeN.LastIndexOf("|"); //获得|的索引
  2159. // // // // deptCodeNew = deptCodeN.Substring(0, deptCodeIndex + 1); //获得目标字符串(//去掉最后一个|后面的字符串)
  2160. // // // // // ============== 部门权限条件 - 部门 ================
  2161. // // // // string arrUser = " select F_UserCode from T_Sys_UserAccount where F_DeptCode LIKE '" + deptCodeNew + "%' ";
  2162. // // // // sql += $" and ToUser IN ({arrUser}) and WorkOrderID IN (SELECT WorkOrderID FROM dbo.T_Wo_WorkOrder WHERE 1=1 {sqlUser} ) ";
  2163. // // // //}
  2164. // // //}
  2165. // //}
  2166. // #endregion
  2167. // switch (daytype)
  2168. // {
  2169. // case "today":
  2170. // sql += " and DateDiff(dd,CreateTime,getdate())=0 ";
  2171. // break;
  2172. // case "yesterday":
  2173. // sql += " and DateDiff(dd,CreateTime,getdate())=1 ";
  2174. // break;
  2175. // case "month":
  2176. // sql += " and DateDiff(mm,CreateTime,getdate())=0 ";
  2177. // break;
  2178. // default:
  2179. // break;
  2180. // }
  2181. // if (strpageindex.Trim() != "")
  2182. // {
  2183. // pageindex = Convert.ToInt32(strpageindex);
  2184. // }
  2185. // if (strpagesize.Trim() != "")
  2186. // {
  2187. // pagesize = Convert.ToInt32(strpagesize);
  2188. // }
  2189. // int recordCount = 0;
  2190. // dt = BLL.PagerBLL.GetListPager(
  2191. // "T_Wo_WorkOrderItem",
  2192. // "T_Wo_WorkOrderItem.ID",
  2193. // "*,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",
  2194. // sql,
  2195. // "ORDER BY T_Wo_WorkOrderItem.ID desc",
  2196. // pagesize,
  2197. // pageindex,
  2198. // true,
  2199. // out recordCount);
  2200. // var obj = new
  2201. // {
  2202. // state = "success",
  2203. // message = "成功",
  2204. // rows = dt,
  2205. // total = recordCount
  2206. // };
  2207. // return Content(obj.ToJson());
  2208. //}
  2209. #endregion
  2210. #region 附件和语音文件
  2211. /// <summary>
  2212. /// 获取留言路径
  2213. /// </summary>
  2214. /// <param name="lid">留言id</param>
  2215. /// <param name="prefix">前缀</param>
  2216. /// <returns></returns>
  2217. public string GetLeavePath(string lid, string prefix)
  2218. {
  2219. string path = string.Empty;
  2220. var liuyan = new BLL.T_Call_LeaveRecord().GetModelList(" F_Id='" + lid + "' ").FirstOrDefault();
  2221. if (liuyan != null)
  2222. {
  2223. if (!string.IsNullOrEmpty(liuyan.F_RecFileUrl))
  2224. {
  2225. path = prefix + liuyan.F_RecFileUrl;
  2226. }
  2227. }
  2228. return path;
  2229. }
  2230. /// <summary>
  2231. /// 获取通话录音路径
  2232. /// </summary>
  2233. /// <param name="cid">通话id</param>
  2234. /// <param name="prefix">前缀</param>
  2235. /// <returns></returns>
  2236. public string GetCallPath(string cid, string prefix)
  2237. {
  2238. string path = string.Empty;
  2239. var luyin = new BLL.T_Call_CallRecords().GetModelList(" callid='" + cid + "' ").FirstOrDefault();
  2240. if (luyin != null)
  2241. {
  2242. if (!string.IsNullOrEmpty(luyin.FilePath))
  2243. {
  2244. var ym = prefix;
  2245. ym = ym.Substring(0, ym.Length - 1);
  2246. path = ym + luyin.FilePath.Substring(luyin.FilePath.IndexOf(':') + 1).Replace('\\', '/');
  2247. }
  2248. }
  2249. return path;
  2250. }
  2251. /// <summary>
  2252. /// 获取附件数据
  2253. /// </summary>
  2254. /// <param name="ids">附件id,多个用英文逗号,隔开</param>
  2255. /// <param name="prefix">前缀</param>
  2256. /// <returns></returns>
  2257. public DataTable GetFileData(string ids, string prefix)
  2258. {
  2259. DataTable dt = DbHelperSQL.Query("select * from T_Sys_Accessories where F_FileId in (" + ids + ")").Tables[0];
  2260. foreach (DataRow dr in dt.Rows)
  2261. {
  2262. dr["F_FileUrl"] = prefix + dr["F_FileUrl"].ToString();
  2263. }
  2264. return dt;
  2265. }
  2266. /// <summary>
  2267. /// 绑定附件信息
  2268. /// </summary>
  2269. /// <param name="dt"></param>
  2270. /// <param name="prefix"></param>
  2271. /// <returns></returns>
  2272. public DataTable BindFileData(DataTable dt, string prefix)
  2273. {
  2274. dt.Columns.Add("File", typeof(object));
  2275. foreach (DataRow dr in dt.Rows)
  2276. {
  2277. if (dr["Files"] != null && dr["Files"].ToString() != "")
  2278. {
  2279. dr["File"] = GetFileData(dr["Files"].ToString(), prefix);
  2280. }
  2281. }
  2282. return dt;
  2283. }
  2284. #endregion
  2285. #region 上传附件
  2286. /// <summary>
  2287. /// 上传附件
  2288. /// </summary>
  2289. /// <returns></returns>
  2290. public ActionResult UpLoadProcess(string id, string name, string type, string lastModifiedDate, int size, HttpPostedFileBase file)
  2291. {
  2292. try
  2293. {
  2294. string stropenid = HttpUtility.UrlDecode(RequestString.GetFormString("openid"));
  2295. string filePathName = string.Empty;
  2296. string path = "/Upload/Files/" + DateTime.Now.ToString("yyyy/MM/dd") + "/";
  2297. string localPath = Server.MapPath(Path.Combine(HttpRuntime.AppDomainAppPath, path));
  2298. if (Request.Files.Count == 0)
  2299. {
  2300. return Error("保存失败");
  2301. }
  2302. string ex = Path.GetExtension(file.FileName);
  2303. filePathName = DateTime.Now.ToString("yyyyMMddHHmmssfff") + "_" + Guid.NewGuid().ToString("N") + ex;
  2304. if (!System.IO.Directory.Exists(localPath))
  2305. {
  2306. System.IO.Directory.CreateDirectory(localPath);
  2307. }
  2308. file.SaveAs(Path.Combine(localPath, filePathName));
  2309. #region 添加日志
  2310. Model.T_Sys_Accessories model_T_Sys_Accessories = new Model.T_Sys_Accessories();
  2311. model_T_Sys_Accessories.F_AddTime = DateTime.Now;//上传时间
  2312. model_T_Sys_Accessories.F_FileName = filePathName;//附件名称
  2313. model_T_Sys_Accessories.F_FileType = type;//附件类型
  2314. model_T_Sys_Accessories.F_FileUrl = path + filePathName;//附件地址
  2315. model_T_Sys_Accessories.F_Size = size;
  2316. model_T_Sys_Accessories.F_UserCode = stropenid;//上传人
  2317. int fid = new BLL.T_Sys_Accessories().Add(model_T_Sys_Accessories);
  2318. #endregion
  2319. if (fid > 0)
  2320. {//返回附件的ID
  2321. model_T_Sys_Accessories.F_FileId = fid;//修改为返回对象以便查看图片
  2322. return Success("文件日志都成功", model_T_Sys_Accessories);
  2323. }
  2324. else
  2325. return Success("文件成功");
  2326. }
  2327. catch (Exception ex)
  2328. {
  2329. return Error(ex.Message);
  2330. }
  2331. }
  2332. #endregion
  2333. }
  2334. }