/// <summary> /// 订单自动收货确认+自动完结 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void orderReceived(object sender, System.Timers.ElapsedEventArgs e) { string days = conf.OrderReceivedDays; int Days = 0; int.TryParse(days, out Days); if (Days > 0) { List <Lebi_Transport_Order> torders = B_Lebi_Transport_Order.GetList("Time_Add<'" + System.DateTime.Now.AddDays(0 - Days) + "' and Type_id_TransportOrderStatus=220", ""); foreach (Lebi_Transport_Order torder in torders) { torder.Type_id_TransportOrderStatus = 223; torder.Time_Received = System.DateTime.Now; B_Lebi_Transport_Order.Update(torder); EX_Area.UpdateShouHuoCount(torder); Log.Add("自动确认收货", "Order", torder.Order_id.ToString()); } } days = conf.OrderCompleteDays; Days = 0; int.TryParse(days, out Days); if (Days > 0) { List <Lebi_Order> orders = B_Lebi_Order.GetList("Time_Received<'" + System.DateTime.Now.AddDays(0 - Days) + "' and IsReceived_All=1 and IsCompleted=0", ""); foreach (Lebi_Order order in orders) { Order.Order_Completed(order); Log.Add("自动确认完成", "Order", order.id.ToString()); } } }
/// <summary> /// 返回快递100物流数据 /// </summary> /// <param name="to"></param> /// <returns></returns> public static KuaiDi100 GetKuaiDi100(Lebi_Transport_Order torder) { string json; KuaiDi100 log = new KuaiDi100(); BaseConfig conf = ShopCache.GetBaseConfig(); JavaScriptSerializer jss = new JavaScriptSerializer(); if (torder.Type_id_TransportOrderStatus == 223) { json = torder.Log; log = jss.Deserialize <KuaiDi100>(json); } else { try { string url = "http://www.kuaidi100.com/api?id=" + conf.KuaiDi100 + "&com=" + torder.Transport_Code + "&nu=" + torder.Code + "&show=0&muti=1"; json = HtmlEngine.CetHtml(url); log = jss.Deserialize <KuaiDi100>(json); switch (log.state) { case "1": torder.Type_id_TransportOrderStatus = 221; break; case "2": torder.Type_id_TransportOrderStatus = 222; break; case "3": torder.Type_id_TransportOrderStatus = 223; try { torder.Time_Received = Convert.ToDateTime(log.data.FirstOrDefault().time); } catch { torder.Time_Received = System.DateTime.Now; } break; case "4": torder.Type_id_TransportOrderStatus = 224; break; //default: // //torder.Type_id_TransportOrderStatus = 220; // break; } if (log.message != "ok") { //没有成功获取到json数据 url = "http://www.kuaidi100.com/applyurl?key=" + conf.KuaiDi100 + "&com=" + torder.Transport_Code + "&nu=" + torder.Code; string html = HtmlEngine.CetHtml(url); //html = HtmlEngine.CetHtml(html); torder.HtmlLog = html; } torder.Log = json; B_Lebi_Transport_Order.Update(torder); UpdateShouHuoCount(torder); } catch (Exception) { log = new KuaiDi100(); } } if (log == null) { log = new KuaiDi100(); } if (log.data == null) { log.data = new List <KuaiDi100.KuaiDi100data>(); } return(log); }