三元财务API

WxLoginController.cs 101KB

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