123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660 |
- using System;
- using System.Collections.Generic;
- using System.Data.SqlClient;
- using System.Linq;
- using System.Threading.Tasks;
- using CoreEntity.DAL;
- using CoreEntity.Entity;
- using CoreEntity.ESEntity;
- using JCSoft.WX.Framework.Api;
- using Microsoft.AspNetCore.Mvc;
- using Microsoft.Extensions.Caching.Memory;
- using Newtonsoft.Json;
- using PublicLibrary.Model;
- using SupplierWeb.Commonss;
- namespace SupplierWeb.Controllers
- {
- [Route("web/mem_order")]
- public class mem_OrderController : BaseController
- {
- public mem_OrderController(IMemoryCache cache, IApiClient client) : base(cache, client)
- {
- }
- public IActionResult Index()
- {
- return View();
- }
- /// <summary>
- /// 会员中心列表
- /// </summary>
- /// <param name="data"></param>
- /// <param name="filters"></param>
- /// <returns></returns>
- [HttpPost]
- [Route("OrderByCode")]
- public ActionResult OrderByCode([FromBody]dynamic data, QueryFilter[] filters)
- {
- int start = 0;
- string OrdersCode = "";
- if (data != null)
- {
- OrdersCode = data.query[0];
- data = new { query = "select * from mem_order where OrdersCode = '"+ OrdersCode + "'" };
- }
- //将参数转换成JSON数据
- var json = JsonConvert.SerializeObject(data);
- //通过传来的SQL语句,转换成DSL语句
- string sql = Util.ElasticQuery("_sql/translate?format=json", "POST", json);
- string from = "\"from\":" + start + ",";
- sql = sql.Insert(1, from);
- //通过转换的DSL语句,获取数据
- var str = Util.ElasticQuery("mem_order/_search?format=json", "POST", sql);
- //JSON转Root对象
- //Root stobj = FromJSON<Root>(str);
- Root<_source> stobj = EsCommon.FromJSON<Root<_source>>(str);
- //将Root对象中的子对象取出来
- List<_source> _source = new List<_source>();
- IList<Mem_Terminaldoc> terms = TerminalDAL.getTerms();
- IList<Mem_Payplatform> payterms = PayPlatFormDAL.getPayTerms();
- IList<Mem_DataDictory> SourcePlatForms = Mem_DataDictoryDAL.getDatas(" and parentid= '783' ");
- Dictionary<string, string> temsMap = new Dictionary<string, string>(terms.Count);
- Dictionary<string, string> payTermsMap = new Dictionary<string, string>(payterms.Count);
- Dictionary<string, string> sourcePlatFormsMap = new Dictionary<string, string>(SourcePlatForms.Count);
- foreach (var term in terms)
- {
- var label = term.TerminalName;
- var value = term.TerminalCode.ToString();
- temsMap.Add(value, label);
- }
- foreach (var term in payterms)
- {
- var label = term.PayPlatFormName;
- var value = term.PayPlatFormCode;
- payTermsMap.Add(value, label);
- }
- foreach (var term in SourcePlatForms)
- {
- var label = term.Text;
- var value = term.Value;
- sourcePlatFormsMap.Add(value, label);
- }
- //给filed额外的属性赋值
- stobj.hits.hits.ForEach(x =>
- {
- x._source._id = x._id;
- x.fields.OriginType[0] = x.fields.OriginType[0] != 0 ?
- temsMap[x.fields.OriginType[0].ToString()] : "";
- x.fields.InitSum[0] = x.fields.InitSum[0] > 0 ?
- x.fields.InitSum[0] / 100 : 0;
- x.fields.OrderStatus[0] = x.fields.OrderStatus[0].ToString();
- x.fields.PaymentType[0] = x.fields.PaymentType[0] != 0 ?
- payTermsMap[x.fields.PaymentType[0].ToString()] : "";
- x.fields.SourcePlatforms[0] = x.fields.SourcePlatforms[0] != 0 ?
- sourcePlatFormsMap[x.fields.SourcePlatforms[0].ToString()] : "";
- x.fields.Sum[0] = x.fields.Sum[0] > 0 ?
- x.fields.Sum[0] / 100 : 0;
- });
- //_source = stobj.hits.hits.Select(x => x._source).ToList();
- _source = stobj.hits.hits.Select(x => x.entity()).ToList();
- foreach (var item in _source)
- {
- string[] phones = new string[1];
- phones[0] = item.MemPhone;
- var phones1 = CommonDAL.getPhoneDecrypt(phones);
- string phoneStars = phones1[0];
- if (phoneStars != null && phoneStars.Length > 8)
- {
- string replaced = phoneStars.Substring(3, 4);
- phoneStars = phoneStars.Replace(replaced, "****");
- }
- item.MemPhone = phoneStars;
- }
- var jsonData = JsonConvert.SerializeObject(_source);
- return Json(
- new
- {
- items = JsonConvert.DeserializeObject(jsonData),
- success = true
- });
- }
- ///// <summary>
- ///// JSON转对象
- ///// </summary>
- ///// <typeparam name="T"></typeparam>
- ///// <param name="input"></param>
- ///// <returns></returns>
- //public static T FromJSON<T>(string input)
- //{
- // try
- // {
- // return JsonConvert.DeserializeObject<T>(input);
- // }
- // catch (Exception ex)
- // {
- // string a = ex.Message;
- // return default(T);
- // }
- //}
- //#region
-
- //public class _shards
- //{
- // /// <summary>
- // ///
- // /// </summary>
- // public int total { get; set; }
- // /// <summary>
- // ///
- // /// </summary>
- // public int successful { get; set; }
- // /// <summary>
- // ///
- // /// </summary>
- // public int skipped { get; set; }
- // /// <summary>
- // ///
- // /// </summary>
- // public int failed { get; set; }
- //}
- //public class Total
- //{
- // /// <summary>
- // ///
- // /// </summary>
- // public int value { get; set; }
- // /// <summary>
- // ///
- // /// </summary>
- // public string relation { get; set; }
- //}
- public class _source
- {
- public string _id { get; set; }//id
- public string OriginType { get; set; }//下单平台终端
- public string InitSum { get; set; }//下单金额
- public string OrderStatus { get; set; }//订单状态
- public string PaymentType { get; set; }//支付方式
- public string SourcePlatforms { get; set; }//下单平台
- /// <summary>
- ///
- /// </summary>
- public DateTime? OrderTime { get; set; }
- /// <summary>
- ///
- /// </summary>
- public DateTime? InventoryAuditDate { get; set; }
- /// <summary>
- ///
- /// </summary>
- public DateTime? CreationDate { get; set; }
- /// <summary>
- ///
- /// </summary>
- public string AccountId { get; set; }
- /// <summary>
- ///
- /// </summary>
- public string Invoice { get; set; }
- /// <summary>
- ///
- /// </summary>
- public string VerificationCode { get; set; }
- /// <summary>
- ///
- /// </summary>
- public string RegionCode { get; set; }
- /// <summary>
- ///
- /// </summary>
- public string OrderNotes { get; set; }
- /// <summary>
- ///
- /// </summary>
- public string Sex { get; set; }
- /// <summary>
- ///
- /// </summary>
- public string CustomerDataId { get; set; }
- /// <summary>
- ///
- /// </summary>
- public string IsToERP { get; set; }
- /// <summary>
- ///
- /// </summary>
- public string SubProductLine { get; set; }
- /// <summary>
- /// 吉林省吉林市磐石市河南街牛心综合楼一单元601室
- /// </summary>
- public string ADeliveryAddress { get; set; }
- /// <summary>
- ///
- /// </summary>
- public DateTime? LastModified { get; set; }
- /// <summary>
- ///
- /// </summary>
- public string MemPhone { get; set; }
- /// <summary>
- /// 赵海霞
- /// </summary>
- public string Consignee { get; set; }
- /// <summary>
- ///
- /// </summary>
- public string ReceiverPhone { get; set; }
- /// <summary>
- ///
- /// </summary>
- public string LeverNumber { get; set; }
- /// <summary>
- ///
- /// </summary>
- public string AConsigneePhone1 { get; set; }
- /// <summary>
- ///
- /// </summary>
- public string DeliveryZipCode { get; set; }
- /// <summary>
- ///
- /// </summary>
- public string Height { get; set; }
- /// <summary>
- ///
- /// </summary>
- public string AConsigneePhone2 { get; set; }
- /// <summary>
- ///
- /// </summary>
- public string CustomerName { get; set; }
- /// <summary>
- ///
- /// </summary>
- public string ProductLine { get; set; }
- /// <summary>
- ///
- /// </summary>
- public string BusinessId { get; set; }
- /// <summary>
- ///
- /// </summary>
- public string InvoiceContent { get; set; }
- /// <summary>
- ///
- /// </summary>
- public string ConfirmId { get; set; }
- /// <summary>
- ///
- /// </summary>
- public string CashCouponCode { get; set; }
- /// <summary>
- ///
- /// </summary>
- public string ShippingNo { get; set; }
- /// <summary>
- ///
- /// </summary>
- public string DiseaseClassCode { get; set; }
- /// <summary>
- ///
- /// </summary>
- public string AuditorId { get; set; }
- /// <summary>
- ///
- /// </summary>
- public string ReceivingTime { get; set; }
- /// <summary>
- ///
- /// </summary>
- public string CustomerCode { get; set; }
- /// <summary>
- ///
- /// </summary>
- public string SyncStatus { get; set; }
- /// <summary>
- ///
- /// </summary>
- public string InvoiceNo { get; set; }
- /// <summary>
- ///
- /// </summary>
- public string DeptId { get; set; }
- /// <summary>
- ///
- /// </summary>
- public string Weight { get; set; }
- /// <summary>
- ///
- /// </summary>
- public DateTime? ShippingTime { get; set; }
- /// <summary>
- ///
- /// </summary>
- public DateTime? AllocationTime { get; set; }
- /// <summary>
- ///
- /// </summary>
- public string OtherNote { get; set; }
- /// <summary>
- ///
- /// </summary>
- public string OrderProcessDate { get; set; }
- /// <summary>
- ///
- /// </summary>
- public string MerchantNote { get; set; }
- /// <summary>
- ///
- /// </summary>
- public string OperateID { get; set; }
- /// <summary>
- ///
- /// </summary>
- public string DeptCode { get; set; }
- /// <summary>
- ///
- /// </summary>
- public string OrdersCode { get; set; }
- /// <summary>
- ///
- /// </summary>
- public string BuyUserId { get; set; }
- /// <summary>
- ///
- /// </summary>
- public string AccountName { get; set; }
- }
- public class Fields
- {
- /// <summary>
- ///
- /// </summary>
- public List<string> IsPayByCard { get; set; }
- /// <summary>
- ///
- /// </summary>
- public List<int> IntegralValue { get; set; }
- /// <summary>
- ///
- /// </summary>
- public List<string> IsDrug { get; set; }
- /// <summary>
- ///
- /// </summary>
- public List<int> HealthPrice { get; set; }
- /// <summary>
- ///
- /// </summary>
- public List<int> WarehouseCode { get; set; }
- /// <summary>
- ///
- /// </summary>
- public List<string> IsNeedReceipt { get; set; }
- /// <summary>
- ///
- /// </summary>
- public List<string> AllocationFlag { get; set; }
- /// <summary>
- ///
- /// </summary>
- public List<int> TransportCosts { get; set; }
- /// <summary>
- ///
- /// </summary>
- public List<string> BonusDate { get; set; }
- /// <summary>
- ///
- /// </summary>
- public List<int> DeliveryType { get; set; }
- /// <summary>
- ///
- /// </summary>
- public List<int> InitSum { get; set; }
- /// <summary>
- ///
- /// </summary>
- public List<int> OriginType { get; set; }
- /// <summary>
- ///
- /// </summary>
- public List<int> CouponValue { get; set; }
- /// <summary>
- ///
- /// </summary>
- public List<int> Discountprice { get; set; }
- /// <summary>
- ///
- /// </summary>
- public List<string> IsEmailmark { get; set; }
- /// <summary>
- ///
- /// </summary>
- public List<int> Sum { get; set; }
- /// <summary>
- ///
- /// </summary>
- public List<int> OrdersType { get; set; }
- /// <summary>
- ///
- /// </summary>
- public List<int> DeviceType { get; set; }
- /// <summary>
- ///
- /// </summary>
- public List<int> AdvanceSum { get; set; }
- /// <summary>
- ///
- /// </summary>
- public List<int> InvoiceSum { get; set; }
- /// <summary>
- ///
- /// </summary>
- public List<string> IsRxDrug { get; set; }
- /// <summary>
- ///
- /// </summary>
- public List<string> Ispayment { get; set; }
- /// <summary>
- ///
- /// </summary>
- public List<int> ProductCost { get; set; }
- /// <summary>
- ///
- /// </summary>
- public List<string> IsNewOrder { get; set; }
- /// <summary>
- ///
- /// </summary>
- public List<string> IsDealWith { get; set; }
- /// <summary>
- ///
- /// </summary>
- public List<int> ErrorCount { get; set; }
- /// <summary>
- ///
- /// </summary>
- public List<int> MemKey { get; set; }
- /// <summary>
- ///
- /// </summary>
- public List<string> IsReturn { get; set; }
- /// <summary>
- ///
- /// </summary>
- public List<string> IsReward { get; set; }
- /// <summary>
- ///
- /// </summary>
- public List<int> HuaWuOriginType { get; set; }
- /// <summary>
- ///
- /// </summary>
- public List<int> OrderStatus { get; set; }
- /// <summary>
- ///
- /// </summary>
- public List<int> AgainOrderCount { get; set; }
- /// <summary>
- ///
- /// </summary>
- public List<string> IsO2O { get; set; }
- /// <summary>
- ///
- /// </summary>
- public List<string> IsAutomaticSigned { get; set; }
- /// <summary>
- ///
- /// </summary>
- public List<int> PaymentType { get; set; }
- /// <summary>
- ///
- /// </summary>
- public List<string> PreferentialRate { get; set; }
- /// <summary>
- ///
- /// </summary>
- public List<string> Age { get; set; }
- /// <summary>
- ///
- /// </summary>
- public List<int> InvoiceContentType { get; set; }
- /// <summary>
- ///
- /// </summary>
- public List<int> OrdersIntegral { get; set; }
- /// <summary>
- ///
- /// </summary>
- public List<int> ConfimLevel { get; set; }
- /// <summary>
- ///
- /// </summary>
- public List<int> ConsigneeType { get; set; }
- /// <summary>
- ///
- /// </summary>
- public List<int> AdvancePayType { get; set; }
- /// <summary>
- ///
- /// </summary>
- public List<int> CouponCode { get; set; }
- /// <summary>
- ///
- /// </summary>
- public List<int> CashCouponValue { get; set; }
- /// <summary>
- ///
- /// </summary>
- public List<int> Reducing { get; set; }
- /// <summary>
- ///
- /// </summary>
- public List<string> IsVisible { get; set; }
- /// <summary>
- ///
- /// </summary>
- public List<int> SourcePlatforms { get; set; }
- }
- //public class HitsItem
- //{
- // /// <summary>
- // ///
- // /// </summary>
- // public string _index { get; set; }
- // /// <summary>
- // ///
- // /// </summary>
- // public string _type { get; set; }
- // /// <summary>
- // ///
- // /// </summary>
- // public string _id { get; set; }
- // /// <summary>
- // ///
- // /// </summary>
- // public string _score { get; set; }
- // /// <summary>
- // ///
- // /// </summary>
- // public string _routing { get; set; }
- // /// <summary>
- // ///
- // /// </summary>
- // public _source _source { get; set; }
- // /// <summary>
- // ///
- // /// </summary>
- // public Fields fields { get; set; }
- // /// <summary>
- // ///
- // /// </summary>
- // public List<int> sort { get; set; }
- //}
- //public class Hits
- //{
- // /// <summary>
- // ///
- // /// </summary>
- // public Total total { get; set; }
- // /// <summary>
- // ///
- // /// </summary>
- // public string max_score { get; set; }
- // /// <summary>
- // ///
- // /// </summary>
- // public List<HitsItem> hits { get; set; }
- //}
- //public class Root
- //{
- // /// <summary>
- // ///
- // /// </summary>
- // public int took { get; set; }
- // /// <summary>
- // ///
- // /// </summary>
- // public string timed_out { get; set; }
- // /// <summary>
- // ///
- // /// </summary>
- // public _shards _shards { get; set; }
- // /// <summary>
- // ///
- // /// </summary>
- // public Hits hits { get; set; }
- //}
- //#endregion
- }
- }
|