mem_orderController.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data.SqlClient;
  4. using System.Linq;
  5. using System.Threading.Tasks;
  6. using CoreEntity.DAL;
  7. using CoreEntity.Entity;
  8. using CoreEntity.ESEntity;
  9. using JCSoft.WX.Framework.Api;
  10. using Microsoft.AspNetCore.Mvc;
  11. using Microsoft.Extensions.Caching.Memory;
  12. using Newtonsoft.Json;
  13. using PublicLibrary.Model;
  14. using SupplierWeb.Commonss;
  15. namespace SupplierWeb.Controllers
  16. {
  17. [Route("web/mem_order")]
  18. public class mem_OrderController : BaseController
  19. {
  20. public mem_OrderController(IMemoryCache cache, IApiClient client) : base(cache, client)
  21. {
  22. }
  23. public IActionResult Index()
  24. {
  25. return View();
  26. }
  27. /// <summary>
  28. /// 会员中心列表
  29. /// </summary>
  30. /// <param name="data"></param>
  31. /// <param name="filters"></param>
  32. /// <returns></returns>
  33. [HttpPost]
  34. [Route("OrderByCode")]
  35. public ActionResult OrderByCode([FromBody]dynamic data, QueryFilter[] filters)
  36. {
  37. int start = 0;
  38. string OrdersCode = "";
  39. if (data != null)
  40. {
  41. OrdersCode = data.query[0];
  42. data = new { query = "select * from mem_order where OrdersCode = '"+ OrdersCode + "'" };
  43. }
  44. //将参数转换成JSON数据
  45. var json = JsonConvert.SerializeObject(data);
  46. //通过传来的SQL语句,转换成DSL语句
  47. string sql = Util.ElasticQuery("_sql/translate?format=json", "POST", json);
  48. string from = "\"from\":" + start + ",";
  49. sql = sql.Insert(1, from);
  50. //通过转换的DSL语句,获取数据
  51. var str = Util.ElasticQuery("mem_order/_search?format=json", "POST", sql);
  52. //JSON转Root对象
  53. //Root stobj = FromJSON<Root>(str);
  54. Root<_source> stobj = EsCommon.FromJSON<Root<_source>>(str);
  55. //将Root对象中的子对象取出来
  56. List<_source> _source = new List<_source>();
  57. IList<Mem_Terminaldoc> terms = TerminalDAL.getTerms();
  58. IList<Mem_Payplatform> payterms = PayPlatFormDAL.getPayTerms();
  59. IList<Mem_DataDictory> SourcePlatForms = Mem_DataDictoryDAL.getDatas(" and parentid= '783' ");
  60. Dictionary<string, string> temsMap = new Dictionary<string, string>(terms.Count);
  61. Dictionary<string, string> payTermsMap = new Dictionary<string, string>(payterms.Count);
  62. Dictionary<string, string> sourcePlatFormsMap = new Dictionary<string, string>(SourcePlatForms.Count);
  63. foreach (var term in terms)
  64. {
  65. var label = term.TerminalName;
  66. var value = term.TerminalCode.ToString();
  67. temsMap.Add(value, label);
  68. }
  69. foreach (var term in payterms)
  70. {
  71. var label = term.PayPlatFormName;
  72. var value = term.PayPlatFormCode;
  73. payTermsMap.Add(value, label);
  74. }
  75. foreach (var term in SourcePlatForms)
  76. {
  77. var label = term.Text;
  78. var value = term.Value;
  79. sourcePlatFormsMap.Add(value, label);
  80. }
  81. //给filed额外的属性赋值
  82. stobj.hits.hits.ForEach(x =>
  83. {
  84. x._source._id = x._id;
  85. x.fields.OriginType[0] = x.fields.OriginType[0] != 0 ?
  86. temsMap[x.fields.OriginType[0].ToString()] : "";
  87. x.fields.InitSum[0] = x.fields.InitSum[0] > 0 ?
  88. x.fields.InitSum[0] / 100 : 0;
  89. x.fields.OrderStatus[0] = x.fields.OrderStatus[0].ToString();
  90. x.fields.PaymentType[0] = x.fields.PaymentType[0] != 0 ?
  91. payTermsMap[x.fields.PaymentType[0].ToString()] : "";
  92. x.fields.SourcePlatforms[0] = x.fields.SourcePlatforms[0] != 0 ?
  93. sourcePlatFormsMap[x.fields.SourcePlatforms[0].ToString()] : "";
  94. x.fields.Sum[0] = x.fields.Sum[0] > 0 ?
  95. x.fields.Sum[0] / 100 : 0;
  96. });
  97. //_source = stobj.hits.hits.Select(x => x._source).ToList();
  98. _source = stobj.hits.hits.Select(x => x.entity()).ToList();
  99. foreach (var item in _source)
  100. {
  101. string[] phones = new string[1];
  102. phones[0] = item.MemPhone;
  103. var phones1 = CommonDAL.getPhoneDecrypt(phones);
  104. string phoneStars = phones1[0];
  105. if (phoneStars != null && phoneStars.Length > 8)
  106. {
  107. string replaced = phoneStars.Substring(3, 4);
  108. phoneStars = phoneStars.Replace(replaced, "****");
  109. }
  110. item.MemPhone = phoneStars;
  111. }
  112. var jsonData = JsonConvert.SerializeObject(_source);
  113. return Json(
  114. new
  115. {
  116. items = JsonConvert.DeserializeObject(jsonData),
  117. success = true
  118. });
  119. }
  120. ///// <summary>
  121. ///// JSON转对象
  122. ///// </summary>
  123. ///// <typeparam name="T"></typeparam>
  124. ///// <param name="input"></param>
  125. ///// <returns></returns>
  126. //public static T FromJSON<T>(string input)
  127. //{
  128. // try
  129. // {
  130. // return JsonConvert.DeserializeObject<T>(input);
  131. // }
  132. // catch (Exception ex)
  133. // {
  134. // string a = ex.Message;
  135. // return default(T);
  136. // }
  137. //}
  138. //#region
  139. //public class _shards
  140. //{
  141. // /// <summary>
  142. // ///
  143. // /// </summary>
  144. // public int total { get; set; }
  145. // /// <summary>
  146. // ///
  147. // /// </summary>
  148. // public int successful { get; set; }
  149. // /// <summary>
  150. // ///
  151. // /// </summary>
  152. // public int skipped { get; set; }
  153. // /// <summary>
  154. // ///
  155. // /// </summary>
  156. // public int failed { get; set; }
  157. //}
  158. //public class Total
  159. //{
  160. // /// <summary>
  161. // ///
  162. // /// </summary>
  163. // public int value { get; set; }
  164. // /// <summary>
  165. // ///
  166. // /// </summary>
  167. // public string relation { get; set; }
  168. //}
  169. public class _source
  170. {
  171. public string _id { get; set; }//id
  172. public string OriginType { get; set; }//下单平台终端
  173. public string InitSum { get; set; }//下单金额
  174. public string OrderStatus { get; set; }//订单状态
  175. public string PaymentType { get; set; }//支付方式
  176. public string SourcePlatforms { get; set; }//下单平台
  177. /// <summary>
  178. ///
  179. /// </summary>
  180. public DateTime? OrderTime { get; set; }
  181. /// <summary>
  182. ///
  183. /// </summary>
  184. public DateTime? InventoryAuditDate { get; set; }
  185. /// <summary>
  186. ///
  187. /// </summary>
  188. public DateTime? CreationDate { get; set; }
  189. /// <summary>
  190. ///
  191. /// </summary>
  192. public string AccountId { get; set; }
  193. /// <summary>
  194. ///
  195. /// </summary>
  196. public string Invoice { get; set; }
  197. /// <summary>
  198. ///
  199. /// </summary>
  200. public string VerificationCode { get; set; }
  201. /// <summary>
  202. ///
  203. /// </summary>
  204. public string RegionCode { get; set; }
  205. /// <summary>
  206. ///
  207. /// </summary>
  208. public string OrderNotes { get; set; }
  209. /// <summary>
  210. ///
  211. /// </summary>
  212. public string Sex { get; set; }
  213. /// <summary>
  214. ///
  215. /// </summary>
  216. public string CustomerDataId { get; set; }
  217. /// <summary>
  218. ///
  219. /// </summary>
  220. public string IsToERP { get; set; }
  221. /// <summary>
  222. ///
  223. /// </summary>
  224. public string SubProductLine { get; set; }
  225. /// <summary>
  226. /// 吉林省吉林市磐石市河南街牛心综合楼一单元601室
  227. /// </summary>
  228. public string ADeliveryAddress { get; set; }
  229. /// <summary>
  230. ///
  231. /// </summary>
  232. public DateTime? LastModified { get; set; }
  233. /// <summary>
  234. ///
  235. /// </summary>
  236. public string MemPhone { get; set; }
  237. /// <summary>
  238. /// 赵海霞
  239. /// </summary>
  240. public string Consignee { get; set; }
  241. /// <summary>
  242. ///
  243. /// </summary>
  244. public string ReceiverPhone { get; set; }
  245. /// <summary>
  246. ///
  247. /// </summary>
  248. public string LeverNumber { get; set; }
  249. /// <summary>
  250. ///
  251. /// </summary>
  252. public string AConsigneePhone1 { get; set; }
  253. /// <summary>
  254. ///
  255. /// </summary>
  256. public string DeliveryZipCode { get; set; }
  257. /// <summary>
  258. ///
  259. /// </summary>
  260. public string Height { get; set; }
  261. /// <summary>
  262. ///
  263. /// </summary>
  264. public string AConsigneePhone2 { get; set; }
  265. /// <summary>
  266. ///
  267. /// </summary>
  268. public string CustomerName { get; set; }
  269. /// <summary>
  270. ///
  271. /// </summary>
  272. public string ProductLine { get; set; }
  273. /// <summary>
  274. ///
  275. /// </summary>
  276. public string BusinessId { get; set; }
  277. /// <summary>
  278. ///
  279. /// </summary>
  280. public string InvoiceContent { get; set; }
  281. /// <summary>
  282. ///
  283. /// </summary>
  284. public string ConfirmId { get; set; }
  285. /// <summary>
  286. ///
  287. /// </summary>
  288. public string CashCouponCode { get; set; }
  289. /// <summary>
  290. ///
  291. /// </summary>
  292. public string ShippingNo { get; set; }
  293. /// <summary>
  294. ///
  295. /// </summary>
  296. public string DiseaseClassCode { get; set; }
  297. /// <summary>
  298. ///
  299. /// </summary>
  300. public string AuditorId { get; set; }
  301. /// <summary>
  302. ///
  303. /// </summary>
  304. public string ReceivingTime { get; set; }
  305. /// <summary>
  306. ///
  307. /// </summary>
  308. public string CustomerCode { get; set; }
  309. /// <summary>
  310. ///
  311. /// </summary>
  312. public string SyncStatus { get; set; }
  313. /// <summary>
  314. ///
  315. /// </summary>
  316. public string InvoiceNo { get; set; }
  317. /// <summary>
  318. ///
  319. /// </summary>
  320. public string DeptId { get; set; }
  321. /// <summary>
  322. ///
  323. /// </summary>
  324. public string Weight { get; set; }
  325. /// <summary>
  326. ///
  327. /// </summary>
  328. public DateTime? ShippingTime { get; set; }
  329. /// <summary>
  330. ///
  331. /// </summary>
  332. public DateTime? AllocationTime { get; set; }
  333. /// <summary>
  334. ///
  335. /// </summary>
  336. public string OtherNote { get; set; }
  337. /// <summary>
  338. ///
  339. /// </summary>
  340. public string OrderProcessDate { get; set; }
  341. /// <summary>
  342. ///
  343. /// </summary>
  344. public string MerchantNote { get; set; }
  345. /// <summary>
  346. ///
  347. /// </summary>
  348. public string OperateID { get; set; }
  349. /// <summary>
  350. ///
  351. /// </summary>
  352. public string DeptCode { get; set; }
  353. /// <summary>
  354. ///
  355. /// </summary>
  356. public string OrdersCode { get; set; }
  357. /// <summary>
  358. ///
  359. /// </summary>
  360. public string BuyUserId { get; set; }
  361. /// <summary>
  362. ///
  363. /// </summary>
  364. public string AccountName { get; set; }
  365. }
  366. public class Fields
  367. {
  368. /// <summary>
  369. ///
  370. /// </summary>
  371. public List<string> IsPayByCard { get; set; }
  372. /// <summary>
  373. ///
  374. /// </summary>
  375. public List<int> IntegralValue { get; set; }
  376. /// <summary>
  377. ///
  378. /// </summary>
  379. public List<string> IsDrug { get; set; }
  380. /// <summary>
  381. ///
  382. /// </summary>
  383. public List<int> HealthPrice { get; set; }
  384. /// <summary>
  385. ///
  386. /// </summary>
  387. public List<int> WarehouseCode { get; set; }
  388. /// <summary>
  389. ///
  390. /// </summary>
  391. public List<string> IsNeedReceipt { get; set; }
  392. /// <summary>
  393. ///
  394. /// </summary>
  395. public List<string> AllocationFlag { get; set; }
  396. /// <summary>
  397. ///
  398. /// </summary>
  399. public List<int> TransportCosts { get; set; }
  400. /// <summary>
  401. ///
  402. /// </summary>
  403. public List<string> BonusDate { get; set; }
  404. /// <summary>
  405. ///
  406. /// </summary>
  407. public List<int> DeliveryType { get; set; }
  408. /// <summary>
  409. ///
  410. /// </summary>
  411. public List<int> InitSum { get; set; }
  412. /// <summary>
  413. ///
  414. /// </summary>
  415. public List<int> OriginType { get; set; }
  416. /// <summary>
  417. ///
  418. /// </summary>
  419. public List<int> CouponValue { get; set; }
  420. /// <summary>
  421. ///
  422. /// </summary>
  423. public List<int> Discountprice { get; set; }
  424. /// <summary>
  425. ///
  426. /// </summary>
  427. public List<string> IsEmailmark { get; set; }
  428. /// <summary>
  429. ///
  430. /// </summary>
  431. public List<int> Sum { get; set; }
  432. /// <summary>
  433. ///
  434. /// </summary>
  435. public List<int> OrdersType { get; set; }
  436. /// <summary>
  437. ///
  438. /// </summary>
  439. public List<int> DeviceType { get; set; }
  440. /// <summary>
  441. ///
  442. /// </summary>
  443. public List<int> AdvanceSum { get; set; }
  444. /// <summary>
  445. ///
  446. /// </summary>
  447. public List<int> InvoiceSum { get; set; }
  448. /// <summary>
  449. ///
  450. /// </summary>
  451. public List<string> IsRxDrug { get; set; }
  452. /// <summary>
  453. ///
  454. /// </summary>
  455. public List<string> Ispayment { get; set; }
  456. /// <summary>
  457. ///
  458. /// </summary>
  459. public List<int> ProductCost { get; set; }
  460. /// <summary>
  461. ///
  462. /// </summary>
  463. public List<string> IsNewOrder { get; set; }
  464. /// <summary>
  465. ///
  466. /// </summary>
  467. public List<string> IsDealWith { get; set; }
  468. /// <summary>
  469. ///
  470. /// </summary>
  471. public List<int> ErrorCount { get; set; }
  472. /// <summary>
  473. ///
  474. /// </summary>
  475. public List<int> MemKey { get; set; }
  476. /// <summary>
  477. ///
  478. /// </summary>
  479. public List<string> IsReturn { get; set; }
  480. /// <summary>
  481. ///
  482. /// </summary>
  483. public List<string> IsReward { get; set; }
  484. /// <summary>
  485. ///
  486. /// </summary>
  487. public List<int> HuaWuOriginType { get; set; }
  488. /// <summary>
  489. ///
  490. /// </summary>
  491. public List<int> OrderStatus { get; set; }
  492. /// <summary>
  493. ///
  494. /// </summary>
  495. public List<int> AgainOrderCount { get; set; }
  496. /// <summary>
  497. ///
  498. /// </summary>
  499. public List<string> IsO2O { get; set; }
  500. /// <summary>
  501. ///
  502. /// </summary>
  503. public List<string> IsAutomaticSigned { get; set; }
  504. /// <summary>
  505. ///
  506. /// </summary>
  507. public List<int> PaymentType { get; set; }
  508. /// <summary>
  509. ///
  510. /// </summary>
  511. public List<string> PreferentialRate { get; set; }
  512. /// <summary>
  513. ///
  514. /// </summary>
  515. public List<string> Age { get; set; }
  516. /// <summary>
  517. ///
  518. /// </summary>
  519. public List<int> InvoiceContentType { get; set; }
  520. /// <summary>
  521. ///
  522. /// </summary>
  523. public List<int> OrdersIntegral { get; set; }
  524. /// <summary>
  525. ///
  526. /// </summary>
  527. public List<int> ConfimLevel { get; set; }
  528. /// <summary>
  529. ///
  530. /// </summary>
  531. public List<int> ConsigneeType { get; set; }
  532. /// <summary>
  533. ///
  534. /// </summary>
  535. public List<int> AdvancePayType { get; set; }
  536. /// <summary>
  537. ///
  538. /// </summary>
  539. public List<int> CouponCode { get; set; }
  540. /// <summary>
  541. ///
  542. /// </summary>
  543. public List<int> CashCouponValue { get; set; }
  544. /// <summary>
  545. ///
  546. /// </summary>
  547. public List<int> Reducing { get; set; }
  548. /// <summary>
  549. ///
  550. /// </summary>
  551. public List<string> IsVisible { get; set; }
  552. /// <summary>
  553. ///
  554. /// </summary>
  555. public List<int> SourcePlatforms { get; set; }
  556. }
  557. //public class HitsItem
  558. //{
  559. // /// <summary>
  560. // ///
  561. // /// </summary>
  562. // public string _index { get; set; }
  563. // /// <summary>
  564. // ///
  565. // /// </summary>
  566. // public string _type { get; set; }
  567. // /// <summary>
  568. // ///
  569. // /// </summary>
  570. // public string _id { get; set; }
  571. // /// <summary>
  572. // ///
  573. // /// </summary>
  574. // public string _score { get; set; }
  575. // /// <summary>
  576. // ///
  577. // /// </summary>
  578. // public string _routing { get; set; }
  579. // /// <summary>
  580. // ///
  581. // /// </summary>
  582. // public _source _source { get; set; }
  583. // /// <summary>
  584. // ///
  585. // /// </summary>
  586. // public Fields fields { get; set; }
  587. // /// <summary>
  588. // ///
  589. // /// </summary>
  590. // public List<int> sort { get; set; }
  591. //}
  592. //public class Hits
  593. //{
  594. // /// <summary>
  595. // ///
  596. // /// </summary>
  597. // public Total total { get; set; }
  598. // /// <summary>
  599. // ///
  600. // /// </summary>
  601. // public string max_score { get; set; }
  602. // /// <summary>
  603. // ///
  604. // /// </summary>
  605. // public List<HitsItem> hits { get; set; }
  606. //}
  607. //public class Root
  608. //{
  609. // /// <summary>
  610. // ///
  611. // /// </summary>
  612. // public int took { get; set; }
  613. // /// <summary>
  614. // ///
  615. // /// </summary>
  616. // public string timed_out { get; set; }
  617. // /// <summary>
  618. // ///
  619. // /// </summary>
  620. // public _shards _shards { get; set; }
  621. // /// <summary>
  622. // ///
  623. // /// </summary>
  624. // public Hits hits { get; set; }
  625. //}
  626. //#endregion
  627. }
  628. }