SupplyMobileController.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572
  1. using JCSoft.WX.Framework.Api;
  2. using Microsoft.AspNetCore.Mvc;
  3. using Microsoft.AspNetCore.Http;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Threading.Tasks;
  8. using Common.Wechat;
  9. using Common;
  10. using System.Data;
  11. using ZcPeng.PublicLibrary;
  12. using CoreEntity.Entity;
  13. using Common.Model;
  14. using Newtonsoft.Json.Converters;
  15. using Newtonsoft.Json;
  16. using CoreEntity.DAL;
  17. using System.Data.SqlClient;
  18. using System.Reflection;
  19. using SupplierWeb.Codes.Auth;
  20. using Microsoft.Extensions.Caching.Memory;
  21. using CoreEntity.BAL;
  22. namespace SupplierWeb.Controllers
  23. {
  24. [Route("web/supplymobile")]
  25. public class SupplyMobileController : BaseController
  26. {
  27. public SupplyMobileController(IMemoryCache cache, IApiClient client) : base(cache, client)
  28. {
  29. }
  30. ////绑定手机号
  31. [HttpGet, Route("bindphone")]
  32. public ActionResult BindPhone()
  33. {
  34. WechatHelper.ReGetOpenId(HttpContext);
  35. string WxOpenId = HttpContext.Session.GetString("openid");
  36. #region 获取user
  37. if (WxOpenId != null&& !WxOpenId.Equals(""))
  38. {
  39. string commandTextUser = "Select accountName,accountPassword,AccountPhone,Id,RoleId From "
  40. + Config.TablePrefix + "Account join contactDoc on FocusMicNo = WxOpenId Where WxOpenId=@WxOpenId and Beactive = 'Y'";
  41. string resultUser;
  42. DataTable dt = new DataTable();
  43. List<List<Object>> parametersUser = new List<List<Object>>();
  44. parametersUser.Add(new List<Object>() { "WxOpenId", WxOpenId });
  45. DataAccess.GetValues(commandTextUser, ref dt, DataAccess.ToParameters(parametersUser).ToArray(), out resultUser);
  46. IList<Account> users = new List<Account>();
  47. //openId已存在不能添加
  48. if (dt != null && dt.Rows.Count>0)
  49. {
  50. users = ModelConvertHelper<Account>.ConvertToModel(dt);
  51. Account user = users.ToArray()[0];
  52. ViewData["WxOpenId"] = user.WxOpenId;
  53. ViewData["AccountName"] = user.AccountName;
  54. ViewData["AccountPassword"] = user.AccountPassWord;
  55. ViewData["Id"] = user.Id;
  56. return View("hasbindphone");
  57. }
  58. return View();
  59. }
  60. else
  61. {
  62. return new EmptyResult();
  63. }
  64. #endregion
  65. }
  66. ////绑定手机号
  67. [HttpPost, Route("bindphone")]
  68. public ActionResult BindPhonePost(string AccountPhone, string AccountName, string AccountPassword, string nonce)
  69. {
  70. WechatHelper.ReGetOpenId(HttpContext);
  71. string WxOpenId = HttpContext.Session.GetString("openid");
  72. if (WxOpenId != null && WxOpenId != "")
  73. {
  74. #region 绑定手机号
  75. string commandTextAccount = "Select AccountName,AccountPassword,AccountPhone,Id,RoleId From "
  76. + Config.TablePrefix + "Account Where AccountName=@AccountName and AccountPassword=@AccountPassword";
  77. string resultAccount;
  78. DataTable dtAccount = new DataTable();
  79. List<List<Object>> parametersAccount = new List<List<Object>>();
  80. parametersAccount.Add(new List<Object>() { "AccountName", AccountName });
  81. parametersAccount.Add(new List<Object>() { "AccountPassword", AccountPassword });
  82. DataAccess.GetValues(commandTextAccount, ref dtAccount, DataAccess.ToParameters(parametersAccount).ToArray(), out resultAccount);
  83. IList<Account> Accounts = new List<Account>();
  84. //账户密码错误
  85. if (dtAccount == null || dtAccount.Rows.Count == 0)
  86. {
  87. ViewData["msg"] = "账户名或密码错误";
  88. return View("bindphoneError");
  89. }
  90. else
  91. {
  92. int roleId = (int)dtAccount.Rows[0]["RoleId"];
  93. if(roleId != 3) {
  94. ViewData["msg"] = "供应商账户才能绑定";
  95. return View("bindphoneError");
  96. }
  97. }
  98. string commandTextUser = "Select accountName,AccountPassword,AccountPhone,Id From "
  99. + Config.TablePrefix + "Account join contactDoc on FocusMicNo = WxOpenId Where WxOpenId=@WxOpenId and Beactive = 'Y'";
  100. string resultUser;
  101. DataTable dt = new DataTable();
  102. List<List<Object>> parametersUser = new List<List<Object>>();
  103. parametersUser.Add(new List<Object>() { "WxOpenId", WxOpenId });
  104. DataAccess.GetValues(commandTextUser, ref dt, DataAccess.ToParameters(parametersUser).ToArray(), out resultUser);
  105. IList<Account> users = new List<Account>();
  106. //openId已存在不能添加
  107. if (dt != null && dt.Rows.Count > 0)
  108. {
  109. users = ModelConvertHelper<Account>.ConvertToModel(dt);
  110. Account user = users.ToArray()[0];
  111. ViewData["WxOpenId"] = user.WxOpenId;
  112. ViewData["AccountName"] = user.AccountName;
  113. ViewData["AccountPassword"] = user.AccountPassWord;
  114. return View("hasbindphone");
  115. }
  116. #endregion
  117. List<DataAccessCommand> list = new List<DataAccessCommand>(2);
  118. #region 绑定openid 到account
  119. string commandTextAcc = "Update " + Config.TablePrefix + "Account set WxOpenId = @WxOpenId " +
  120. " Where AccountPhone=@AccountPhone ";
  121. //string resultAcc;
  122. List<List<Object>> parameters = new List<List<Object>>();
  123. parameters.Add(new List<Object>() { "WxOpenId", WxOpenId });
  124. parameters.Add(new List<Object>() { "AccountPhone", AccountPhone });
  125. //int successAcc = DataAccess.ExecuteCommand(commandTextAcc, DataAccess.ToParameters(parameters), out resultAcc);
  126. list.Add(new DataAccessCommand(commandTextAcc, DataAccess.ToParameters(parameters),CommandType.Text ,true));
  127. #endregion
  128. #region 绑定openid 到coantacdoc
  129. string commandText = "Update contactDoc set FocusMicNo = @WxOpenId " +
  130. " Where exists ( select 1 from " + Config.TablePrefix + "Account where Id = UserId and AccountPhone=@AccountPhone and Beactive = 'Y') ";
  131. string result;
  132. //int success = DataAccess.ExecuteCommand(commandText, DataAccess.ToParameters(parameters), out result);
  133. list.Add(new DataAccessCommand(commandText, DataAccess.ToParameters(parameters), CommandType.Text, true));
  134. #endregion
  135. bool success = DataAccess.ExecuteBatchCommands(list,out result);
  136. if (success) {
  137. ViewData["WxOpenId"] = WxOpenId;
  138. ViewData["AccountName"] = AccountName;
  139. ViewData["AccountPassword"] = AccountPassword;
  140. return View("hasbindphone");
  141. }
  142. else
  143. ViewData["result"] = result;
  144. return View("bindphoneNeedWx");
  145. }
  146. else
  147. return View("bindphoneNeedWx");
  148. }
  149. ////采购品种列表
  150. [HttpGet, Route("listdata")]
  151. public ActionResult listData(string RecordId)
  152. {
  153. WechatHelper.ReGetOpenId(HttpContext, "?RecordId=" + RecordId);
  154. string WxOpenId = HttpContext.Session.GetString("openid");
  155. //var WxOpenId = "oCzgS1fzaxA3nGpu5pnldkSar1pA";
  156. //var WxOpenId = "oCzgS1RSy_nTGVkxgpluAdOUtKsw";
  157. //var WxOpenId = "oCzgS1XfcqvJkiKozn-oWUgSDoZQ";
  158. if (WxOpenId != null && WxOpenId != "")
  159. {
  160. string commandTextUser = "Select * From "
  161. + Config.TablePrefix + "Account join contactDoc on FocusMicNo = WxOpenId Where WxOpenId=@WxOpenId and Beactive = 'Y'";
  162. string resultUser;
  163. DataTable dt = new DataTable();
  164. List<List<Object>> parametersUser = new List<List<Object>>();
  165. parametersUser.Add(new List<Object>() { "WxOpenId", WxOpenId });
  166. DataAccess.GetValues(commandTextUser, ref dt, DataAccess.ToParameters(parametersUser).ToArray(), out resultUser);
  167. IList<Account> users = new List<Account>();
  168. List<Dictionary<String, Object>> data = new List<Dictionary<String, Object>>(0);
  169. if (dt.Rows.Count > 0) {
  170. users = ModelConvertHelper<Account>.ConvertToModel(dt);
  171. Account user = users.ToArray()[0];
  172. ViewData["WxOpenId"] = WxOpenId;
  173. ViewData["AccountName"] = user.AccountName;
  174. ViewData["AccountPassword"] = user.AccountPassWord;
  175. int UserId = user.Id;
  176. Token token = SupplierWeb.Codes.Auth.Token.genAndSaveToken(users, _cache, out var roleName);
  177. ViewData["staffId"] = token.StaffId;
  178. #region 获取Goods
  179. DataTable dtAccount = new DataTable();
  180. string commandTextAccount = "Select A.*," +
  181. "E.Unit,F.WmsMeas From " +
  182. Config.TablePrefix + "PushFeedback A " +
  183. " left join PGPrice E on E.EntId = A.EntId and E.GoodsId = A.GoodsId " +
  184. " left join GoodsAttr F on F.EntId = A.EntId and F.GoodsId = A.GoodsId " +
  185. "Where A.PushRecordId=@RecordId " +
  186. " and A.PushAccountId = " + UserId;
  187. string resultAccount;
  188. List<List<Object>> parametersAccount = new List<List<Object>>();
  189. parametersAccount.Add(new List<Object>() { "RecordId", RecordId });
  190. DataAccess.GetValues(commandTextAccount, ref dtAccount, DataAccess.ToParameters(parametersAccount).ToArray(), out resultAccount);
  191. IList<PushFeedback> Accounts = new List<PushFeedback>();
  192. if (dtAccount != null && dtAccount.Rows.Count > 0)
  193. {
  194. Accounts = ModelConvertHelper<PushFeedback>.ConvertToModel(dtAccount);
  195. }
  196. #endregion
  197. foreach (PushFeedback pfb in Accounts)
  198. {
  199. Dictionary<string,object> maps= ToMap(pfb);
  200. maps["PurchaseTotalNum"] = decimal.ToInt64(pfb.PurchaseTotalNum);
  201. data.Add(maps);
  202. }
  203. }
  204. else
  205. {
  206. return Redirect("/web/supplymobile/bindphone");
  207. }
  208. ViewData["data"] = data;
  209. return View();
  210. }
  211. else
  212. {
  213. return new EmptyResult();
  214. }
  215. }
  216. /// <summary>
  217. ///
  218. /// 将对象属性转换为key-value对
  219. /// </summary>
  220. /// <param name="o"></param>
  221. /// <returns></returns>
  222. public static Dictionary<String, Object> ToMap(Object o)
  223. {
  224. Dictionary<String, Object> map = new Dictionary<string, object>();
  225. Type t = o.GetType();
  226. PropertyInfo[] pi = t.GetProperties(BindingFlags.Public | BindingFlags.Instance);
  227. foreach (PropertyInfo p in pi)
  228. {
  229. MethodInfo mi = p.GetGetMethod();
  230. if (mi != null && mi.IsPublic && !map.ContainsKey(p.Name))
  231. {
  232. map.Add(p.Name, mi.Invoke(o, new Object[] { }));
  233. }
  234. }
  235. return map;
  236. }
  237. ////查询已提交的采购单-web版
  238. [HttpGet,Route("purchaseorder")]
  239. public ActionResult PurchaseOrder(string echostr, string signature, string timestamp, string nonce)
  240. {
  241. #region 获取Openid
  242. //WechatHelper.ReGetOpenId(HttpContext);
  243. #endregion
  244. return View();
  245. }
  246. ////确认订单
  247. [HttpGet, Route("confirmorder")]
  248. public ActionResult confirmorder(string RecordId)
  249. {
  250. WechatHelper.ReGetOpenId(HttpContext, "?RecordId=" + RecordId);
  251. string WxOpenId = HttpContext.Session.GetString("openid");
  252. //string WxOpenId = "oCzgS1fzaxA3nGpu5pnldkSar1pA";
  253. //string WxOpenId = "oCzgS1fzaxA3nGpu5pnldkSar1pA";
  254. if (WxOpenId != null && WxOpenId != "")
  255. {
  256. //string commandTextUser = "Select accountName,AccountPassword,AccountPhone,Id From "
  257. //+ Config.TablePrefix + "Account join contactDoc on FocusMicNo = WxOpenId Where WxOpenId=@WxOpenId and Beactive = 'Y'";
  258. string commandTextUser = "Select * From "
  259. + Config.TablePrefix + "Account Where WxOpenId=@WxOpenId " +
  260. " and Id in (select userid from contactDoc where Beactive = 'Y' and FocusMicNo=@WxOpenId) ";
  261. string resultUser;
  262. DataTable dt = new DataTable();
  263. List<List<Object>> parametersUser = new List<List<Object>>();
  264. parametersUser.Add(new List<Object>() { "WxOpenId", WxOpenId });
  265. DataAccess.GetValues(commandTextUser, ref dt, DataAccess.ToParameters(parametersUser).ToArray(), out resultUser);
  266. IList<Account> users = new List<Account>();
  267. Dictionary<string, object> mapsrd = new Dictionary<String, Object>();
  268. List<Dictionary<String, Object>> data = new List<Dictionary<String, Object>>(0);
  269. if (dt.Rows.Count > 0)
  270. {
  271. users = ModelConvertHelper<Account>.ConvertToModel(dt);
  272. Account user = users.ToArray()[0];
  273. ViewData["WxOpenId"] = WxOpenId;
  274. ViewData["AccountName"] = user.AccountName;
  275. ViewData["AccountPassword"] = user.AccountPassWord;
  276. Token token = SupplierWeb.Codes.Auth.Token.genAndSaveToken(users, _cache, out var roleName);
  277. ViewData["staffId"] = token.StaffId;
  278. int UserId = user.Id;
  279. #region 获取Goods
  280. DataTable dtAccount = new DataTable();
  281. string commandTextAccount = "Select A.* From " +
  282. Config.TablePrefix + "PushFeedback A " +
  283. "Where A.PushRecordId=@RecordId " +
  284. " and A.PushAccountId = " + UserId;
  285. string resultAccount;
  286. List<List<Object>> parametersAccount = new List<List<Object>>();
  287. parametersAccount.Add(new List<Object>() { "RecordId", RecordId });
  288. DataAccess.GetValues(commandTextAccount, ref dtAccount, DataAccess.ToParameters(parametersAccount).ToArray(), out resultAccount);
  289. IList<PushFeedback> Accounts = new List<PushFeedback>();
  290. if (dtAccount != null && dtAccount.Rows.Count > 0)
  291. {
  292. Accounts = ModelConvertHelper<PushFeedback>.ConvertToModel(dtAccount);
  293. }
  294. #endregion
  295. foreach (PushFeedback pfb in Accounts)
  296. {
  297. Dictionary<string, object> maps = ToMap(pfb);
  298. maps["StoreGapNum"] = decimal.ToInt64(pfb.StoreGapNum);
  299. maps["PurchaseTotalNum"] = decimal.ToInt64(pfb.PurchaseTotalNum);
  300. maps["GoodsName"] = pfb.GoodsName.Replace("/", "_");
  301. maps["GoodsSpec"] = pfb.GoodsSpec.Replace("/", "_");
  302. data.Add(maps);
  303. }
  304. DataTable dtAccount2 = new DataTable();
  305. string commandTextAccount2 = "Select A.* From " +
  306. Config.TablePrefix + "PushRecord A " +
  307. "Where A.Id=@RecordId " +
  308. " and A.PushAccountId = " + UserId;
  309. string resultAccount2;
  310. List<List<Object>> parametersAccount2 = new List<List<Object>>();
  311. parametersAccount2.Add(new List<Object>() { "RecordId", RecordId });
  312. DataAccess.GetValues(commandTextAccount2, ref dtAccount2, DataAccess.ToParameters(parametersAccount2).ToArray(), out resultAccount2);
  313. IList<PushRecord> Accounts2 = new List<PushRecord>();
  314. if (dtAccount2 != null && dtAccount2.Rows.Count > 0)
  315. {
  316. Accounts2 = ModelConvertHelper<PushRecord>.ConvertToModel(dtAccount2);
  317. var prd = Accounts2[0];
  318. prd.Id = Guid.Parse(RecordId);
  319. mapsrd = ToMap(prd);
  320. mapsrd["pfbs"] = data;
  321. }
  322. }
  323. else
  324. {
  325. return Redirect("/web/supplymobile/bindphone");
  326. }
  327. IsoDateTimeConverter timejson = new IsoDateTimeConverter
  328. {
  329. DateTimeFormat = "yyyy'-'MM'-'dd' 'HH':'mm':'ss"
  330. };
  331. //var jsonData = JsonConvert.SerializeObject(mapsrd, timejson);
  332. ViewData["data"] = data;
  333. ViewData["rddata"] = mapsrd;
  334. return View();
  335. }
  336. else
  337. {
  338. return new EmptyResult();
  339. }
  340. }
  341. [HttpPost, Route("mt")]
  342. public JsonResult mt(string RecordId)
  343. {
  344. string UserId = getStaff("userid");
  345. string RoleId = getStaff("roleid");
  346. //判断参数是否合法
  347. if (string.IsNullOrEmpty(UserId))
  348. {
  349. return Json(new
  350. {
  351. items = new string[] { },
  352. sum = new { },
  353. totalCount = 0
  354. });
  355. }
  356. Dictionary<string, object> mapsrd = new Dictionary<String, Object>();
  357. List<Dictionary<String, Object>> data = new List<Dictionary<String, Object>>(0);
  358. #region
  359. DataTable dtAccount = new DataTable();
  360. string commandTextAccount = "Select A.* From " +
  361. Config.TablePrefix + "PushFeedback A " +
  362. "Where A.PushRecordId=@RecordId " +
  363. " and A.PushAccountId = " + UserId;
  364. string resultAccount;
  365. List<List<Object>> parametersAccount = new List<List<Object>>();
  366. parametersAccount.Add(new List<Object>() { "RecordId", RecordId });
  367. DataAccess.GetValues(commandTextAccount, ref dtAccount, DataAccess.ToParameters(parametersAccount).ToArray(), out resultAccount);
  368. IList<PushFeedback> Accounts = new List<PushFeedback>();
  369. if (dtAccount != null && dtAccount.Rows.Count > 0)
  370. {
  371. Accounts = ModelConvertHelper<PushFeedback>.ConvertToModel(dtAccount);
  372. }
  373. foreach (PushFeedback pfb in Accounts)
  374. {
  375. Dictionary<string, object> maps = ToMap(pfb);
  376. maps["StoreGapNum"] = decimal.ToInt64(pfb.StoreGapNum);
  377. maps["PurchaseTotalNum"] = decimal.ToInt64(pfb.PurchaseTotalNum);
  378. data.Add(maps);
  379. }
  380. DataTable dtAccount2 = new DataTable();
  381. string commandTextAccount2 = "Select A.* From " +
  382. Config.TablePrefix + "PushRecord A " +
  383. "Where A.Id=@RecordId " +
  384. " and A.PushAccountId = " + UserId;
  385. string resultAccount2;
  386. List<List<Object>> parametersAccount2 = new List<List<Object>>();
  387. parametersAccount2.Add(new List<Object>() { "RecordId", RecordId });
  388. DataAccess.GetValues(commandTextAccount2, ref dtAccount2, DataAccess.ToParameters(parametersAccount2).ToArray(), out resultAccount2);
  389. IList<PushRecord> Accounts2 = new List<PushRecord>();
  390. if (dtAccount2 != null && dtAccount2.Rows.Count > 0)
  391. {
  392. Accounts2 = ModelConvertHelper<PushRecord>.ConvertToModel(dtAccount2);
  393. var prd = Accounts2[0];
  394. prd.Id = Guid.Parse(RecordId);
  395. mapsrd = ToMap(prd);
  396. mapsrd["pfbs"] = data;
  397. }
  398. #endregion
  399. return Json(mapsrd);
  400. }
  401. [HttpGet, Route("listorder")]
  402. public ActionResult ListOrder(int OrderBillNo,string TypeId = null,string picUrl=null )
  403. {
  404. WechatHelper.ReGetOpenId(HttpContext, "?OrderBillNo=" + OrderBillNo);
  405. string WxOpenId = HttpContext.Session.GetString("openid");
  406. //var WxOpenId = "oCzgS1fzaxA3nGpu5pnldkSar1pA";
  407. if (WxOpenId != null && WxOpenId != "")
  408. {
  409. string commandTextUser = "Select accountName,AccountPassword,AccountPhone,Id From "
  410. + Config.TablePrefix + "Account join contactDoc on FocusMicNo = WxOpenId Where WxOpenId=@WxOpenId and Beactive = 'Y'";
  411. string resultUser;
  412. DataTable dt = new DataTable();
  413. List<List<Object>> parametersUser = new List<List<Object>>();
  414. parametersUser.Add(new List<Object>() { "WxOpenId", WxOpenId });
  415. DataAccess.GetValues(commandTextUser, ref dt, DataAccess.ToParameters(parametersUser).ToArray(), out resultUser);
  416. IList<Account> users = new List<Account>();
  417. List<Dictionary<String, Object>> data = new List<Dictionary<String, Object>>(0);
  418. if (dt.Rows.Count > 0)
  419. {
  420. users = ModelConvertHelper<Account>.ConvertToModel(dt);
  421. Account user = users.ToArray()[0];
  422. ViewData["WxOpenId"] = WxOpenId;
  423. ViewData["AccountName"] = user.AccountName;
  424. ViewData["AccountPassword"] = user.AccountPassWord;
  425. int UserId = user.Id;
  426. if(TypeId != null && TypeId.Equals(PushBAL.OPaidTypeId)) {
  427. var Orderdts = PushPaidBackMsgDAL.GetPaidBackMsgDT(OrderBillNo);
  428. Dictionary<string, object> maps = new Dictionary<string, object>();
  429. List <Dictionary<String, Object>> dataDT = new List<Dictionary<String, Object>>(0);
  430. foreach (PurOrderDTEx orderDT in Orderdts)
  431. {
  432. Dictionary<string, object> mapOrderDT = ToMap(orderDT);
  433. dataDT.Add(mapOrderDT);
  434. }
  435. maps["Orderdts"] = dataDT;
  436. data.Add(maps);
  437. }
  438. else {
  439. #region 获取Goods
  440. DataTable dtAccount = new DataTable();
  441. string commandTextAccount = "Select A.* From " +
  442. "PurOrderMT A " +
  443. "Where A.BillNo=@OrderBillNo ";
  444. string resultAccount;
  445. List<List<Object>> parametersAccount = new List<List<Object>>(1);
  446. parametersAccount.Add(new List<Object>() { "OrderBillNo", OrderBillNo });
  447. DataAccess.GetValues(commandTextAccount, ref dtAccount, DataAccess.ToParameters(parametersAccount).ToArray(), out resultAccount);
  448. IList<PurOrderMTEx> Accounts = new List<PurOrderMTEx>();
  449. if (dtAccount != null && dtAccount.Rows.Count > 0)
  450. {
  451. Accounts = ModelConvertHelper<PurOrderMTEx>.ConvertToModel(dtAccount);
  452. }
  453. #endregion
  454. foreach (PurOrderMTEx pfb in Accounts)
  455. {
  456. var sql1 = "select A.*,B.AccountRealName as Contact,C.GoodsName,C.GoodsSpec,C.GoodsCode,C.Manufacturer" +
  457. ",D.ApprovalNo,E.BusinessName from PurOrderDT A " +
  458. " left join PurOrderMT A1 on A1.BillNo = A.BillNo " +
  459. " left join sup_Account B on B.PurStaffId = A1.SaleManId " +
  460. " left join GoodsDoc C on C.EntId = A.EntId and C.GoodsId = A.GoodsId " +
  461. " left join GoodsAttr D on D.GoodsId = C.GoodsId and D.EntId = C.EntId " +
  462. " left join BusinessDoc E on E.BusinessId = A1.SuppliersId and E.EntId = A1.EntId " +
  463. " where A.BillNo = @BillNo ";
  464. List<SqlParameter> param1 = new List<SqlParameter>(1);
  465. param1.Add(new SqlParameter("BillNo", pfb.BillNo));
  466. pfb.Orderdts = DataAccess.GetValues<PurOrderDTEx>(sql1, param1, out var msg);
  467. Dictionary<string, object> maps = ToMap(pfb);
  468. List<Dictionary<String, Object>> dataDT = new List<Dictionary<String, Object>>(0);
  469. foreach (PurOrderDTEx orderDT in pfb.Orderdts)
  470. {
  471. Dictionary<string, object> mapOrderDT = ToMap(orderDT);
  472. dataDT.Add(mapOrderDT);
  473. }
  474. maps["Orderdts"] = dataDT;
  475. data.Add(maps);
  476. }
  477. }
  478. }
  479. else
  480. {
  481. return Redirect("/web/supplymobile/bindphone");
  482. }
  483. ViewData["data"] = data;
  484. if (TypeId == null)
  485. return View();
  486. else {
  487. ViewData["picUrl"] = picUrl;
  488. return View("listPaid");
  489. }
  490. }
  491. else
  492. {
  493. return new EmptyResult();
  494. }
  495. }
  496. }
  497. }