public ApiErrorCode SendOrders(OrderInfo order, ShippingModeInfo shippingmode, string out_id, ExpressCompanyInfo express) { if (order.GroupBuyId > 0 && order.GroupBuyStatus != GroupBuyStatus.Success) { return(ApiErrorCode.Group_Error); } if (!order.CheckAction(OrderActions.SELLER_SEND_GOODS)) { return(ApiErrorCode.NoPay_Error); } if (shippingmode.ModeId <= 0) { return(ApiErrorCode.NoShippingMode); } if (string.IsNullOrEmpty(out_id) || out_id.Length > 20) { return(ApiErrorCode.ShipingOrderNumber_Error); } order.RealShippingModeId = shippingmode.ModeId; order.RealModeName = shippingmode.Name; order.ExpressCompanyName = express.Name; order.ExpressCompanyAbb = express.Kuaidi100Code; order.ShipOrderNumber = out_id; if (OrderHelper.SendAPIGoods(order)) { if (!string.IsNullOrEmpty(order.GatewayOrderId) && order.GatewayOrderId.Trim().Length > 0) { PaymentModeInfo paymentMode = SalesHelper.GetPaymentMode(order.PaymentTypeId); if (paymentMode != null) { PaymentRequest paymentRequest = PaymentRequest.CreateInstance(paymentMode.Gateway, HiCryptographer.Decrypt(paymentMode.Settings), order.OrderId, order.GetTotal(), "订单发货", "订单号-" + order.OrderId, order.EmailAddress, order.OrderDate, Globals.FullPath(Globals.GetSiteUrls().Home), Globals.FullPath(Globals.GetSiteUrls().UrlData.FormatUrl("PaymentReturn_url", new object[] { paymentMode.Gateway })), Globals.FullPath(Globals.GetSiteUrls().UrlData.FormatUrl("PaymentNotify_url", new object[] { paymentMode.Gateway })), ""); paymentRequest.SendGoods(order.GatewayOrderId, order.RealModeName, order.ShipOrderNumber, "EXPRESS"); } } int num = order.UserId; if (num == 1100) { num = 0; } Hidistro.Membership.Core.IUser user = Hidistro.Membership.Context.Users.GetUser(num); Messenger.OrderShipping(order, user); order.OnDeliver(); return(ApiErrorCode.Success); } return(ApiErrorCode.Unknown_Error); }
/// <summary> /// 支付接口发货通知 /// </summary> /// <param name="orderInfo"></param> private void PaySendGoodsNotice(OrderInfo orderInfo) { try { if (orderInfo.Gateway == "Ecdev.plugins.payment.weixinrequest") { SiteSettings masterSettings = SettingsManager.GetMasterSettings(false); PayClient payClient = new PayClient(masterSettings.WeixinAppId, masterSettings.WeixinAppSecret, masterSettings.WeixinPartnerID, masterSettings.WeixinPartnerKey, masterSettings.WeixinPaySignKey); payClient.DeliverNotify(new DeliverInfo { TransId = orderInfo.GatewayOrderId, OutTradeNo = orderInfo.OrderId, OpenId = MemberHelper.GetMember(orderInfo.UserId).OpenId }); } else { if (!string.IsNullOrEmpty(orderInfo.GatewayOrderId) && orderInfo.GatewayOrderId.Trim().Length > 0) { PaymentModeInfo paymentMode = SalesHelper.GetPaymentMode(orderInfo.Gateway); if (paymentMode != null && !string.IsNullOrEmpty(paymentMode.Settings) && paymentMode.Settings != "1hSUSkKQ/ENo0JDZah8KKQweixin") { PaymentRequest paymentRequest = PaymentRequest.CreateInstance(paymentMode.Gateway, HiCryptographer.Decrypt(paymentMode.Settings), orderInfo.OrderId, orderInfo.GetTotal(), "订单发货", "订单号-" + orderInfo.OrderId, orderInfo.EmailAddress, orderInfo.OrderDate, Globals.FullPath(Globals.GetSiteUrls().Home), Globals.FullPath(Globals.GetSiteUrls().UrlData.FormatUrl("PaymentReturn_url", new object[] { paymentMode.Gateway })), Globals.FullPath(Globals.GetSiteUrls().UrlData.FormatUrl("PaymentNotify_url", new object[] { paymentMode.Gateway })), ""); paymentRequest.SendGoods(orderInfo.GatewayOrderId, orderInfo.RealModeName, orderInfo.ShipOrderNumber, "EXPRESS"); } } } } catch (Exception ex) { ErrorLog.Write(string.Format("WMS发货回传通知支付接口出错,订单id{0},支付接口{1},错误信息{2}", orderInfo.OrderId, orderInfo.Gateway, ex.ToString())); } }
private string sendGoods(HttpContext context) { string text = context.Request["OrderNO"].Trim(); string text2 = context.Request["SndStyle"].Trim(); string text3 = context.Request["BillID"].Trim(); IDictionary <string, string> dictionary = new Dictionary <string, string>(); dictionary.Add("OrderId", text); dictionary.Add("SndStyle", text2); dictionary.Add("BillID", text3); dictionary.Add("ErrorMsg", ""); if (text.IndexOf(',') > 0) { return("<?xml version='1.0' encoding='utf-8'?><Rsp><Result>0</Result><Cause><![CDATA[{不支持合并发货,请选择单个订单}]]></Cause></Rsp>"); } OrderInfo orderInfo = OrderHelper.GetOrderInfo(text); if (orderInfo == null) { return("<?xml version='1.0' encoding='utf-8'?><Rsp><Result>0</Result><Cause><![CDATA[{未找到此订单}]]></Cause></Rsp>"); } if (orderInfo.OrderStatus == OrderStatus.WaitBuyerPay && OrderHelper.NeedUpdateStockWhenSendGoods(orderInfo) && !OrderHelper.CheckStock(orderInfo)) { return("<?xml version='1.0' encoding='utf-8'?><Rsp><Result>0</Result><Cause><![CDATA[{订单有商品库存不足,请补充库存后发货!}]]></Cause></Rsp>"); } if (orderInfo.GroupBuyId > 0 && orderInfo.GroupBuyStatus != GroupBuyStatus.Success) { return("<?xml version='1.0' encoding='utf-8'?><Rsp><Result>0</Result><Cause><![CDATA[{当前订单为团购订单,团购活动还未成功结束,所以不能发货!}]]></Cause></Rsp>"); } if (!orderInfo.CheckAction(OrderActions.SELLER_SEND_GOODS)) { return("<?xml version='1.0' encoding='utf-8'?><Rsp><Result>0</Result><Cause><![CDATA[{当前订单状态没有付款或不是等待发货的订单,所以不能发货!}]]></Cause></Rsp>"); } if (string.IsNullOrEmpty(text3.Trim()) || text3.Trim().Length > 20) { return("<?xml version='1.0' encoding='utf-8'?><Rsp><Result>0</Result><Cause><![CDATA[{运单号码不能为空,在1至20个字符之间!}]]></Cause></Rsp>"); } ExpressCompanyInfo expressCompanyInfo = ExpressHelper.FindNodeLikeName(text2); if (expressCompanyInfo != null) { orderInfo.ExpressCompanyAbb = expressCompanyInfo.Kuaidi100Code; orderInfo.ExpressCompanyName = expressCompanyInfo.Name; } else { orderInfo.ExpressCompanyAbb = ""; orderInfo.ExpressCompanyName = text2; } orderInfo.ShipOrderNumber = text3; if (!string.IsNullOrEmpty(orderInfo.OuterOrderId) && orderInfo.OuterOrderId.StartsWith("jd_") && (expressCompanyInfo == null || string.IsNullOrWhiteSpace(expressCompanyInfo.JDCode))) { return("<?xml version='1.0' encoding='utf-8'?><Rsp><Result>0</Result><Cause><![CDATA[{此订单是京东订单,所选物流公司不被京东支持!}]]></Cause></Rsp>"); } if (OrderHelper.SendAPIGoods(orderInfo, true)) { string text4 = ""; if (orderInfo.Gateway == "hishop.plugins.payment.weixinrequest") { try { SiteSettings masterSettings = SettingsManager.GetMasterSettings(); PayClient payClient = new PayClient(masterSettings.WeixinAppId, masterSettings.WeixinAppSecret, masterSettings.WeixinPartnerID, masterSettings.WeixinPartnerKey, masterSettings.WeixinPaySignKey, "", "", ""); DeliverInfo deliverInfo = new DeliverInfo(); deliverInfo.TransId = orderInfo.GatewayOrderId; deliverInfo.OutTradeNo = orderInfo.OrderId; MemberOpenIdInfo memberOpenIdInfo = Users.GetUser(orderInfo.UserId).MemberOpenIds.FirstOrDefault((MemberOpenIdInfo item) => item.OpenIdType.ToLower() == "hishop.plugins.openid.weixin"); if (memberOpenIdInfo != null) { deliverInfo.OpenId = memberOpenIdInfo.OpenId; } payClient.DeliverNotify(deliverInfo); } catch (Exception ex) { dictionary["ErrrorMsg"] = "同步微信支付发货状态失败"; Globals.WriteExceptionLog(ex, dictionary, "APISendGoods"); } } else { if (!string.IsNullOrEmpty(orderInfo.GatewayOrderId) && orderInfo.GatewayOrderId.Trim().Length > 0) { try { PaymentModeInfo paymentMode = SalesHelper.GetPaymentMode(orderInfo.Gateway); if (paymentMode != null && !string.IsNullOrEmpty(paymentMode.Settings)) { string hIGW = paymentMode.Gateway.Replace(".", "_"); PaymentRequest paymentRequest = PaymentRequest.CreateInstance(paymentMode.Gateway, HiCryptographer.Decrypt(paymentMode.Settings), orderInfo.PayOrderId, orderInfo.GetTotal(false), "订单发货", "订单号-" + orderInfo.PayOrderId, orderInfo.EmailAddress, orderInfo.OrderDate, Globals.FullPath(""), Globals.FullPath(RouteConfig.GetRouteUrl(HttpContext.Current, "PaymentReturn_url", new { HIGW = hIGW })), Globals.FullPath(RouteConfig.GetRouteUrl(HttpContext.Current, "PaymentNotify_url", new { HIGW = hIGW })), ""); paymentRequest.SendGoods(orderInfo.GatewayOrderId, orderInfo.RealModeName, orderInfo.ShipOrderNumber, "EXPRESS"); } } catch (Exception ex2) { dictionary["ErrrorMsg"] = "同步支付接口发货状态失败"; Globals.WriteExceptionLog(ex2, dictionary, "APISendGoods"); } } if (!string.IsNullOrEmpty(orderInfo.OuterOrderId)) { if (orderInfo.OuterOrderId.StartsWith("tb_")) { string text5 = orderInfo.OuterOrderId.Replace("tb_", ""); try { string requestUriString = $"http://order2.kuaidiangtong.com/UpdateShipping.ashx?tid={text5}&companycode={expressCompanyInfo.TaobaoCode}&outsid={orderInfo.ShipOrderNumber}&Host={HiContext.Current.SiteUrl}"; WebRequest webRequest = WebRequest.Create(requestUriString); webRequest.GetResponse(); } catch (Exception ex3) { dictionary["ErrrorMsg"] = "同步淘宝发货状态失败"; Globals.WriteExceptionLog(ex3, dictionary, "APISendGoods"); } } else if (orderInfo.OuterOrderId.StartsWith("jd_")) { string text5 = orderInfo.OuterOrderId.Replace("jd_", ""); try { SiteSettings masterSettings2 = SettingsManager.GetMasterSettings(); JDHelper.JDOrderOutStorage(masterSettings2.JDAppKey, masterSettings2.JDAppSecret, masterSettings2.JDAccessToken, expressCompanyInfo.JDCode, orderInfo.ShipOrderNumber, text5); } catch (Exception ex4) { dictionary["ErrrorMsg"] = "同步京东发货失败"; Globals.WriteExceptionLog(ex4, dictionary, "APISendGoods"); text4 = $"同步京东发货失败,京东订单号:{text5},{ex4.Message}\r\n"; } } } } MemberInfo user = Users.GetUser(orderInfo.UserId); Messenger.OrderShipping(orderInfo, user); orderInfo.OnDeliver(); return("<?xml version='1.0' encoding='utf-8'?><Rsp><Result>1</Result><Cause></Cause></Rsp>"); } return("<?xml version='1.0' encoding='utf-8'?><Rsp><Result>0</Result><Cause><![CDATA[{发货失败,可能是商品库存不足,订单中有商品正在退货、换货状态!}]]></Cause></Rsp>"); }
protected void Page_Load(object sender, System.EventArgs e) { if (Globals.RequestQueryStr("type") == "saveorders") { this.type = "saveorders"; } string text = Globals.RequestFormStr("posttype"); this.orderIds = Globals.RequestQueryStr("OrderId").Trim(new char[] { ',' }); if (string.IsNullOrEmpty(this.ReUrl)) { this.ReUrl = "manageorder.aspx"; } string a; if ((a = text) != null) { if (a == "saveorders") { string text2 = Globals.RequestFormStr("data"); base.Response.ContentType = "application/json"; string s = "{\"type\":\"0\",\"tips\":\"指定物流失败!\"}"; JArray jArray = (JArray)JsonConvert.DeserializeObject(text2); string text3 = string.Empty; if (jArray != null) { if (jArray.Count > 1) { text3 = "批量"; } bool flag = true; using (System.Collections.Generic.IEnumerator <JToken> enumerator = jArray.GetEnumerator()) { while (enumerator.MoveNext()) { JObject jObject = (JObject)enumerator.Current; if (!this.CheckOrderCompany(jObject["orderid"].ToString(), jObject["companycode"].ToString(), jObject["compname"].ToString(), jObject["shipordernumber"].ToString())) { flag = false; } } } if (flag) { using (System.Collections.Generic.IEnumerator <JToken> enumerator2 = jArray.GetEnumerator()) { while (enumerator2.MoveNext()) { JObject jObject2 = (JObject)enumerator2.Current; OrderHelper.UpdateOrderCompany(jObject2["orderid"].ToString(), jObject2["companycode"].ToString(), jObject2["compname"].ToString(), jObject2["shipordernumber"].ToString()); } } s = "{\"type\":\"1\",\"tips\":\"" + text3 + "指定物流成功!\"}"; } else { s = "{\"type\":\"0\",\"tips\":\"" + text3 + "指定物流失败,请检测数据的正确性!\"}"; } } base.Response.Write(s); base.Response.End(); return; } if (a == "saveoneorders") { string text2 = Globals.RequestFormStr("data"); base.Response.ContentType = "application/json"; string s = "{\"type\":\"0\",\"tips\":\"指定物流失败!\"}"; JArray jArray = (JArray)JsonConvert.DeserializeObject(text2); string text3 = string.Empty; if (jArray != null) { bool flag2 = true; string shipNumber = "1111111111"; using (System.Collections.Generic.IEnumerator <JToken> enumerator3 = jArray.GetEnumerator()) { while (enumerator3.MoveNext()) { JObject jObject3 = (JObject)enumerator3.Current; if (!this.CheckOrderCompany(jObject3["orderid"].ToString(), jObject3["companycode"].ToString(), jObject3["compname"].ToString(), shipNumber)) { flag2 = false; } } } if (flag2) { using (System.Collections.Generic.IEnumerator <JToken> enumerator4 = jArray.GetEnumerator()) { while (enumerator4.MoveNext()) { JObject jObject4 = (JObject)enumerator4.Current; OrderHelper.UpdateOrderCompany(jObject4["orderid"].ToString(), jObject4["companycode"].ToString(), jObject4["compname"].ToString(), ""); } } s = "{\"type\":\"1\",\"tips\":\"" + text3 + "指定物流成功!\"}"; } else { s = "{\"type\":\"0\",\"tips\":\"" + text3 + "指定物流失败,请检测数据的正确性!\"}"; } } base.Response.Write(s); base.Response.End(); return; } if (a == "sendorders") { string text2 = Globals.RequestFormStr("data"); base.Response.ContentType = "application/json"; string s = "{\"type\":\"0\",\"tips\":\"发货失败!\"}"; JArray jArray = (JArray)JsonConvert.DeserializeObject(text2); string text3 = string.Empty; if (jArray != null) { if (jArray.Count > 1) { text3 = "批量"; } bool flag3 = true; using (System.Collections.Generic.IEnumerator <JToken> enumerator5 = jArray.GetEnumerator()) { while (enumerator5.MoveNext()) { JObject jObject5 = (JObject)enumerator5.Current; if (!this.CheckOrderCompany(jObject5["orderid"].ToString(), jObject5["companycode"].ToString(), jObject5["compname"].ToString(), jObject5["shipordernumber"].ToString())) { flag3 = false; } } } if (flag3) { int num = 0; using (System.Collections.Generic.IEnumerator <JToken> enumerator6 = jArray.GetEnumerator()) { while (enumerator6.MoveNext()) { JObject jObject6 = (JObject)enumerator6.Current; OrderInfo orderInfo = OrderHelper.GetOrderInfo(jObject6["orderid"].ToString()); if ((orderInfo.GroupBuyId <= 0 || orderInfo.GroupBuyStatus == GroupBuyStatus.Success) && ((orderInfo.OrderStatus == OrderStatus.WaitBuyerPay && orderInfo.Gateway == "hishop.plugins.payment.podrequest") || orderInfo.OrderStatus == OrderStatus.BuyerAlreadyPaid) && !string.IsNullOrEmpty(jObject6["shipordernumber"].ToString().Trim()) && jObject6["shipordernumber"].ToString().Trim().Length <= 30) { orderInfo.ExpressCompanyAbb = jObject6["companycode"].ToString(); orderInfo.ExpressCompanyName = jObject6["compname"].ToString(); orderInfo.ShipOrderNumber = jObject6["shipordernumber"].ToString(); if (OrderHelper.SendGoods(orderInfo)) { Express.SubscribeExpress100(jObject6["companycode"].ToString(), jObject6["shipordernumber"].ToString()); SendNoteInfo sendNoteInfo = new SendNoteInfo(); sendNoteInfo.NoteId = Globals.GetGenerateId() + num; sendNoteInfo.OrderId = jObject6["orderid"].ToString(); sendNoteInfo.Operator = ManagerHelper.GetCurrentManager().UserName; sendNoteInfo.Remark = "后台" + sendNoteInfo.Operator + "发货成功"; OrderHelper.SaveSendNote(sendNoteInfo); if (!string.IsNullOrEmpty(orderInfo.GatewayOrderId) && orderInfo.GatewayOrderId.Trim().Length > 0) { if (orderInfo.Gateway == "hishop.plugins.payment.ws_wappay.wswappayrequest") { PaymentModeInfo paymentMode = SalesHelper.GetPaymentMode(orderInfo.PaymentTypeId); if (paymentMode != null) { PaymentRequest paymentRequest = PaymentRequest.CreateInstance(paymentMode.Gateway, HiCryptographer.Decrypt(paymentMode.Settings), orderInfo.OrderId, orderInfo.GetTotal(), "订单发货", "订单号-" + orderInfo.OrderId, orderInfo.EmailAddress, orderInfo.OrderDate, Globals.FullPath(Globals.GetSiteUrls().Home), Globals.FullPath(Globals.GetSiteUrls().UrlData.FormatUrl("PaymentReturn_url", new object[] { paymentMode.Gateway })), Globals.FullPath(Globals.GetSiteUrls().UrlData.FormatUrl("PaymentNotify_url", new object[] { paymentMode.Gateway })), ""); paymentRequest.SendGoods(orderInfo.GatewayOrderId, orderInfo.RealModeName, orderInfo.ShipOrderNumber, "EXPRESS"); } } if (orderInfo.Gateway == "hishop.plugins.payment.weixinrequest") { SiteSettings masterSettings = SettingsManager.GetMasterSettings(false); PayClient payClient; if (masterSettings.EnableSP) { payClient = new PayClient(masterSettings.Main_AppId, masterSettings.WeixinAppSecret, masterSettings.Main_Mch_ID, masterSettings.Main_PayKey, true, masterSettings.WeixinAppId, masterSettings.WeixinPartnerID); } else { payClient = new PayClient(masterSettings.WeixinAppId, masterSettings.WeixinAppSecret, masterSettings.WeixinPartnerID, masterSettings.WeixinPartnerKey, false, "", ""); } payClient.DeliverNotify(new DeliverInfo { TransId = orderInfo.GatewayOrderId, OutTradeNo = orderInfo.OrderId, OpenId = MemberHelper.GetMember(orderInfo.UserId).OpenId }); } } orderInfo.OnDeliver(); num++; } } } } if (num == 0) { s = "{\"type\":\"0\",\"tips\":\"" + text3 + "发货失败!\"}"; } else { s = string.Concat(new object[] { "{\"type\":\"1\",\"tips\":\"", text3, "发货成功!发货数量", num, "个\"}" }); } } else { s = "{\"type\":\"0\",\"tips\":\"" + text3 + "发货失败,请检测数据的正确性!\"}"; } } base.Response.Write(s); base.Response.End(); return; } if (a == "getcompany") { base.Response.ContentType = "application/json"; string text2 = "[{\"type\":\"0\",\"data\":[]}]"; System.Collections.Generic.IList <ExpressCompanyInfo> allExpress = ExpressHelper.GetAllExpress(); int num2 = 0; System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder(); foreach (ExpressCompanyInfo current in allExpress) { if (num2 == 0) { stringBuilder.Append(string.Concat(new string[] { "{\"code\":\"", SendOrderGoods.String2Json(current.Kuaidi100Code), "\",\"name\":\"", SendOrderGoods.String2Json(current.Name), "\"}" })); } else { stringBuilder.Append(string.Concat(new string[] { ",{\"code\":\"", SendOrderGoods.String2Json(current.Kuaidi100Code), "\",\"name\":\"", SendOrderGoods.String2Json(current.Name), "\"}" })); } num2++; } if (!string.IsNullOrEmpty(stringBuilder.ToString())) { text2 = "[{\"type\":\"1\",\"data\":[" + stringBuilder.ToString() + "]}]"; } base.Response.Write(text2); base.Response.End(); return; } } if (string.IsNullOrEmpty(this.orderIds)) { base.GotoResourceNotFound(); return; } string[] array = this.orderIds.Split(new char[] { ',' }); bool flag4 = true; string[] array2 = array; for (int i = 0; i < array2.Length; i++) { string lstr = array2[i]; if (!Globals.IsOrdersID(lstr)) { flag4 = false; break; } } if (flag4) { System.Data.DataSet ordersByOrderIDList = OrderHelper.GetOrdersByOrderIDList(this.orderIds); this.rptItemList.DataSource = ordersByOrderIDList; this.rptItemList.DataBind(); this.litOrdersCount.Text = ordersByOrderIDList.Tables[0].Rows.Count.ToString(); return; } base.Response.Write("非法参数请求!"); base.Response.End(); }
private void btnSendGoods_Click(object sender, EventArgs e) { int num = this.txtSendGoodType.Value.ToInt(0); if (this.grdOrderGoods.Items.Count <= 0) { this.ShowMsg("没有要进行发货的订单。", false); } else { int num2 = 0; for (int i = 0; i < this.grdOrderGoods.Items.Count; i++) { HiddenField hiddenField = (HiddenField)this.grdOrderGoods.Items[i].FindControl("txtDeliveryNo"); string text = hiddenField.Value.ToNullString(); if (num != 2 || !(text == "")) { HiddenField hiddenField2 = (HiddenField)this.grdOrderGoods.Items[i].FindControl("hidorderId"); string value = hiddenField2.Value; TextBox textBox = (TextBox)this.grdOrderGoods.Items[i].FindControl("txtShippOrderNumber"); ExpressDropDownList expressDropDownList = this.grdOrderGoods.Items[i].FindControl("expressList1") as ExpressDropDownList; OrderInfo orderInfo = OrderHelper.GetOrderInfo(value); if ((orderInfo.GroupBuyId <= 0 || orderInfo.GroupBuyStatus == GroupBuyStatus.Success) && ((orderInfo.OrderStatus == OrderStatus.WaitBuyerPay && orderInfo.Gateway == "hishop.plugins.payment.podrequest") || orderInfo.OrderStatus == OrderStatus.BuyerAlreadyPaid)) { ExpressCompanyInfo expressCompanyInfo = null; switch (num) { case 1: if (!string.IsNullOrEmpty(expressDropDownList.SelectedValue)) { expressCompanyInfo = ExpressHelper.FindNode(expressDropDownList.SelectedValue); } if (expressCompanyInfo != null) { orderInfo.ExpressCompanyName = expressCompanyInfo.Name; orderInfo.ExpressCompanyAbb = expressCompanyInfo.Kuaidi100Code; orderInfo.ShipOrderNumber = textBox.Text; } break; case 2: orderInfo.ExpressCompanyName = "同城物流配送"; orderInfo.ExpressCompanyAbb = ""; orderInfo.ShipOrderNumber = ""; orderInfo.DadaStatus = DadaStatus.WaitOrder; break; default: orderInfo.ExpressCompanyName = ""; orderInfo.ExpressCompanyAbb = ""; orderInfo.ShipOrderNumber = ""; break; } OrderStatus orderStatus = orderInfo.OrderStatus; if (OrderHelper.SendGoods(orderInfo)) { if (expressCompanyInfo != null && !string.IsNullOrEmpty(orderInfo.ExpressCompanyAbb) && orderInfo.ExpressCompanyAbb.ToUpper() == "HTKY") { ExpressHelper.GetDataByKuaidi100(orderInfo.ExpressCompanyAbb, orderInfo.ShipOrderNumber); } if (orderStatus == OrderStatus.WaitBuyerPay) { OrderHelper.ChangeStoreStockAndWriteLog(orderInfo); } if (orderInfo.Gateway.ToLower() == "hishop.plugins.payment.podrequest") { OrderHelper.SetOrderIsStoreCollect(orderInfo.OrderId); ProductStatisticsHelper.UpdateOrderSaleStatistics(orderInfo); TransactionAnalysisHelper.AnalysisOrderTranData(orderInfo); } if (!string.IsNullOrEmpty(orderInfo.GatewayOrderId) && orderInfo.GatewayOrderId.Trim().Length > 0) { PaymentModeInfo paymentMode = SalesHelper.GetPaymentMode(orderInfo.Gateway); if (paymentMode != null) { string hIGW = paymentMode.Gateway.Replace(".", "_"); PaymentRequest paymentRequest = PaymentRequest.CreateInstance(paymentMode.Gateway, HiCryptographer.TryDecypt(paymentMode.Settings), orderInfo.OrderId, orderInfo.GetTotal(false), "订单发货", "订单号-" + orderInfo.OrderId, orderInfo.EmailAddress, orderInfo.OrderDate, Globals.FullPath(""), Globals.FullPath(base.GetRouteUrl("PaymentReturn_url", new { HIGW = hIGW })), Globals.FullPath(base.GetRouteUrl("PaymentNotify_url", new { HIGW = hIGW })), ""); paymentRequest.SendGoods(orderInfo.GatewayOrderId, orderInfo.RealModeName, orderInfo.ShipOrderNumber, "EXPRESS"); } } if (orderInfo.ExpressCompanyName == "同城物流配送" && !string.IsNullOrEmpty(text)) { SiteSettings masterSettings = SettingsManager.GetMasterSettings(); DadaHelper.addAfterQuery(masterSettings.DadaSourceID, text); } if (!string.IsNullOrEmpty(orderInfo.OuterOrderId) && expressCompanyInfo != null) { if (orderInfo.OuterOrderId.StartsWith("tb_")) { string text2 = orderInfo.OuterOrderId.Replace("tb_", ""); try { string requestUriString = $"http://order2.kuaidiangtong.com/UpdateShipping.ashx?tid={text2}&companycode={expressCompanyInfo.TaobaoCode}&outsid={orderInfo.ShipOrderNumber}&Host={HiContext.Current.SiteUrl}"; WebRequest webRequest = WebRequest.Create(requestUriString); webRequest.GetResponse(); } catch { } } else if (orderInfo.OuterOrderId.StartsWith("jd_")) { string text2 = orderInfo.OuterOrderId.Replace("jd_", ""); } } MemberInfo user = Users.GetUser(orderInfo.UserId); Messenger.OrderShipping(orderInfo, user); orderInfo.OnDeliver(); num2++; } } } } if (num2 == 0) { this.ShowMsg("批量发货失败,商品库存不足或者有商品正在退货,换货中的订单不能发货!", false); } else if (num2 > 0) { this.BindData(); this.ShowMsg($"批量发货成功!发货数量{num2}个,商品库存不足或者有商品正在退货,换货中的订单不能发货!", true); } } }
private void btnSendGoods_Click(object sender, System.EventArgs e) { OrderInfo orderInfo = OrderHelper.GetOrderInfo(this.orderId); if (orderInfo == null) { return; } if (orderInfo.GroupBuyId > 0 && orderInfo.GroupBuyStatus != GroupBuyStatus.Success) { this.ShowMsg("当前订单为团购订单,团购活动还未成功结束,所以不能发货", false); return; } if (!orderInfo.CheckAction(OrderActions.SELLER_SEND_GOODS)) { this.ShowMsg("当前订单状态没有付款或不是等待发货的订单,所以不能发货", false); return; } if (!this.radioShippingMode.SelectedValue.HasValue) { this.ShowMsg("请选择配送方式", false); return; } if (string.IsNullOrEmpty(this.txtShipOrderNumber.Text.Trim()) || this.txtShipOrderNumber.Text.Trim().Length > 20) { this.ShowMsg("运单号码不能为空,在1至20个字符之间", false); return; } if (string.IsNullOrEmpty(this.expressRadioButtonList.SelectedValue)) { this.ShowMsg("请选择物流公司", false); return; } ShippingModeInfo shippingMode = SalesHelper.GetShippingMode(this.radioShippingMode.SelectedValue.Value, true); orderInfo.RealShippingModeId = this.radioShippingMode.SelectedValue.Value; orderInfo.RealModeName = shippingMode.Name; orderInfo.ShippingModeId = this.radioShippingMode.SelectedValue.Value; orderInfo.ModeName = shippingMode.Name; ExpressCompanyInfo expressCompanyInfo = ExpressHelper.FindNode(this.expressRadioButtonList.SelectedValue); if (expressCompanyInfo != null) { orderInfo.ExpressCompanyAbb = expressCompanyInfo.Kuaidi100Code; orderInfo.ExpressCompanyName = expressCompanyInfo.Name; } orderInfo.ShipOrderNumber = this.txtShipOrderNumber.Text; orderInfo.ShippingDate = DateTime.Now; if (OrderHelper.SendGoods(orderInfo)) { SendNoteInfo sendNoteInfo = new SendNoteInfo(); sendNoteInfo.NoteId = Globals.GetGenerateId(); sendNoteInfo.OrderId = this.orderId; sendNoteInfo.Operator = HiContext.Current.User.Username; sendNoteInfo.Remark = "后台" + sendNoteInfo.Operator + "发货成功"; OrderHelper.SaveSendNote(sendNoteInfo); if (orderInfo.Gateway == "Ecdev.plugins.payment.weixinrequest") { SiteSettings masterSettings = SettingsManager.GetMasterSettings(false); PayClient payClient = new PayClient(masterSettings.WeixinAppId, masterSettings.WeixinAppSecret, masterSettings.WeixinPartnerID, masterSettings.WeixinPartnerKey, masterSettings.WeixinPaySignKey); payClient.DeliverNotify(new DeliverInfo { TransId = orderInfo.GatewayOrderId, OutTradeNo = orderInfo.OrderId, OpenId = MemberHelper.GetMember(orderInfo.UserId).OpenId }); } else { if (!string.IsNullOrEmpty(orderInfo.GatewayOrderId) && orderInfo.GatewayOrderId.Trim().Length > 0) { PaymentModeInfo paymentMode = SalesHelper.GetPaymentMode(orderInfo.Gateway); if (paymentMode != null && !string.IsNullOrEmpty(paymentMode.Settings) && paymentMode.Settings != "1hSUSkKQ/ENo0JDZah8KKQweixin") { PaymentRequest paymentRequest = PaymentRequest.CreateInstance(paymentMode.Gateway, HiCryptographer.Decrypt(paymentMode.Settings), orderInfo.OrderId, orderInfo.GetTotal(), "订单发货", "订单号-" + orderInfo.OrderId, orderInfo.EmailAddress, orderInfo.OrderDate, Globals.FullPath(Globals.GetSiteUrls().Home), Globals.FullPath(Globals.GetSiteUrls().UrlData.FormatUrl("PaymentReturn_url", new object[] { paymentMode.Gateway })), Globals.FullPath(Globals.GetSiteUrls().UrlData.FormatUrl("PaymentNotify_url", new object[] { paymentMode.Gateway })), ""); paymentRequest.SendGoods(orderInfo.GatewayOrderId, orderInfo.RealModeName, orderInfo.ShipOrderNumber, "EXPRESS"); } } if (!string.IsNullOrEmpty(orderInfo.TaobaoOrderId)) { try { string requestUriString = string.Format("http://vip.ecdev.cn/UpdateShipping.ashx?tid={0}&companycode={1}&outsid={2}&Host={3}", new object[] { orderInfo.TaobaoOrderId, expressCompanyInfo.TaobaoCode, orderInfo.ShipOrderNumber, HiContext.Current.SiteUrl }); System.Net.WebRequest webRequest = System.Net.WebRequest.Create(requestUriString); webRequest.GetResponse(); } catch { } } } int num = orderInfo.UserId; if (num == 1100) { num = 0; } IUser user = Users.GetUser(num); Messenger.OrderShipping(orderInfo, user); orderInfo.OnDeliver(); //this.ShowMsg("发货成功", true); this.CloseWindow(); return; } this.ShowMsg("发货失败", false); }
protected void btnBatchSend_Click(object sender, System.EventArgs e)//新增上传excel来发货 { this.btnBatchSend.Enabled = false; HttpPostedFile file = this.excelFile.PostedFile; if (file.ContentLength == 0) { this.btnBatchSend.Enabled = true; this.ShowMsg("请选择文件!", false); return; } string expandName = file.FileName.Substring(file.FileName.LastIndexOf('.') + 1); int excelType = 0; if (expandName == "xls") { excelType = 1; } else if (expandName == "xlsx") { excelType = 2; } else { this.btnBatchSend.Enabled = true; this.ShowMsg("请上传excel文件!", false); return; } ExcelHelper excelHelper = new ExcelHelper(file.InputStream); DataTable dtExcel = excelHelper.ExcelToDataTable("", true, excelType); if (dtExcel == null || dtExcel.Columns.Count < 4) { this.btnBatchSend.Enabled = true; this.ShowMsg("excel表格列数错误!", false); return; } if (!(dtExcel.Columns[0].ToString() == "订单编号" && dtExcel.Columns[1].ToString() == "发货时间" && dtExcel.Columns[2].ToString() == "快递公司" && dtExcel.Columns[3].ToString() == "快递单号")) { this.btnBatchSend.Enabled = true; this.ShowMsg("excel表格列名称错误!", false); return; } List <string> orderIds = new List <string>(); List <string> expressCompanyName = new List <string>(); List <string> ShipOrderNumber = new List <string>(); List <DateTime> deliveryTimes = new List <DateTime>(); Dictionary <string, string> deliverFailOrders = new Dictionary <string, string>(); List <deliverFailOrderInfo> listdeliverFailOrderInfo = new List <deliverFailOrderInfo>(); int num = 0; #region 整理发货单数据 if (dtExcel != null) { int count = dtExcel.Rows.Count; for (int i = 0; i < count; i++) { string tmpOrderId = string.Empty; string tmpexpressCompanyName = string.Empty; string tmpkuaidi100Code = string.Empty; DateTime tmpdeliveryTime = DateTime.Now; tmpOrderId = dtExcel.Rows[i][0].ToString(); DateTime.TryParse(dtExcel.Rows[i][1].ToString(), out tmpdeliveryTime); tmpexpressCompanyName = dtExcel.Rows[i][2].ToString(); tmpkuaidi100Code = dtExcel.Rows[i][3].ToString(); string[] singleLineOrderIds = tmpOrderId.Split(',');//单行可能多个订单号 for (int j = 0; j < singleLineOrderIds.Length; j++) { tmpOrderId = singleLineOrderIds[j]; if (string.IsNullOrEmpty(tmpOrderId)) { continue; } orderIds.Add(tmpOrderId); deliveryTimes.Add(tmpdeliveryTime); expressCompanyName.Add(tmpexpressCompanyName); ShipOrderNumber.Add(tmpkuaidi100Code); } } } #endregion #region 发货业务逻辑处理 for (int i = 0; i < orderIds.Count; i++) { deliverFailOrderInfo failOrderInfo = null; if (string.IsNullOrEmpty(orderIds[i]) && string.IsNullOrEmpty(expressCompanyName[i]) && string.IsNullOrEmpty(ShipOrderNumber[i])) { if (!deliverFailOrders.ContainsKey(orderIds[i])) { failOrderInfo = new deliverFailOrderInfo(); failOrderInfo.OrderId = orderIds[i]; failOrderInfo.FailInfo = "订单号、快递公司或快递单号不能为空"; failOrderInfo.ExpressCompanyCode = ShipOrderNumber[i]; failOrderInfo.ExpressCompanyName = expressCompanyName[i]; listdeliverFailOrderInfo.Add(failOrderInfo); deliverFailOrders.Add(orderIds[i], "订单号、快递公司或快递单号不能为空"); continue; } } OrderInfo orderInfo = OrderHelper.GetOrderInfo(orderIds[i]); if (orderInfo == null) { if (!deliverFailOrders.ContainsKey(orderIds[i])) { failOrderInfo = new deliverFailOrderInfo(); failOrderInfo.OrderId = orderIds[i]; failOrderInfo.FailInfo = "不存在该订单"; failOrderInfo.ExpressCompanyCode = ShipOrderNumber[i]; failOrderInfo.ExpressCompanyName = expressCompanyName[i]; listdeliverFailOrderInfo.Add(failOrderInfo); deliverFailOrders.Add(orderIds[i], "不存在该订单"); } continue; } if ((orderInfo.GroupBuyId <= 0 || orderInfo.GroupBuyStatus == GroupBuyStatus.Success) && ((orderInfo.OrderStatus == OrderStatus.WaitBuyerPay && orderInfo.Gateway == "hishop.plugins.payment.podrequest") || orderInfo.OrderStatus == OrderStatus.BuyerAlreadyPaid)) { string exCompanyName = expressCompanyName[i]; ShippingModeInfo shippingModeByCompany = SalesHelper.GetShippingModeByCompany(exCompanyName); if (shippingModeByCompany != null) { if (shippingModeByCompany.ModeId > 0) { orderInfo.RealModeName = shippingModeByCompany.Name; orderInfo.RealShippingModeId = shippingModeByCompany.ModeId; } else { orderInfo.RealShippingModeId = 2;//配送方式 orderInfo.RealModeName = "圆通"; } } else { orderInfo.RealShippingModeId = 2;//配送方式 orderInfo.RealModeName = "圆通"; } ExpressCompanyInfo expressCompanyInfo = ExpressHelper.FindNode(expressCompanyName[i]);//物流公司 if (expressCompanyInfo == null) { if (!deliverFailOrders.ContainsKey(orderIds[i])) { failOrderInfo = new deliverFailOrderInfo(); failOrderInfo.OrderId = orderIds[i]; failOrderInfo.FailInfo = "不存在物流公司"; failOrderInfo.ExpressCompanyCode = ShipOrderNumber[i]; failOrderInfo.ExpressCompanyName = expressCompanyName[i]; listdeliverFailOrderInfo.Add(failOrderInfo); deliverFailOrders.Add(orderIds[i], "不存在物流公司"); } continue; } orderInfo.ExpressCompanyName = expressCompanyInfo.Name; orderInfo.ExpressCompanyAbb = expressCompanyInfo.Kuaidi100Code; orderInfo.ShipOrderNumber = ShipOrderNumber[i]; orderInfo.ShippingDate = deliveryTimes[i]; //todo 发货时间 if (OrderHelper.SendGoods(orderInfo)) { SendNoteInfo sendNoteInfo = new SendNoteInfo(); sendNoteInfo.NoteId = Globals.GetGenerateId() + num; sendNoteInfo.OrderId = orderIds[i]; sendNoteInfo.Operator = HiContext.Current.User.Username; sendNoteInfo.Remark = "后台" + sendNoteInfo.Operator + "发货成功"; OrderHelper.SaveSendNote(sendNoteInfo); if (!string.IsNullOrEmpty(orderInfo.GatewayOrderId) && orderInfo.GatewayOrderId.Trim().Length > 0) { PaymentModeInfo paymentMode = SalesHelper.GetPaymentMode(orderInfo.Gateway); if (paymentMode != null && !string.IsNullOrEmpty(paymentMode.Settings) && paymentMode.Settings != "1hSUSkKQ/ENo0JDZah8KKQweixin") { PaymentRequest paymentRequest = PaymentRequest.CreateInstance(paymentMode.Gateway, HiCryptographer.Decrypt(paymentMode.Settings), orderInfo.OrderId, orderInfo.GetTotal(), "订单发货", "订单号-" + orderInfo.OrderId, orderInfo.EmailAddress, orderInfo.OrderDate, Globals.FullPath(Globals.GetSiteUrls().Home), Globals.FullPath(Globals.GetSiteUrls().UrlData.FormatUrl("PaymentReturn_url", new object[] { paymentMode.Gateway })), Globals.FullPath(Globals.GetSiteUrls().UrlData.FormatUrl("PaymentNotify_url", new object[] { paymentMode.Gateway })), ""); if (paymentRequest != null) { paymentRequest.SendGoods(orderInfo.GatewayOrderId, orderInfo.RealModeName, orderInfo.ShipOrderNumber, "EXPRESS"); } } } if (!string.IsNullOrEmpty(orderInfo.TaobaoOrderId)) { try { string requestUriString = string.Format("http://order2.ecdev.cn/UpdateShipping.ashx?tid={0}&companycode={1}&outsid={2}&Host={3}", new object[] { orderInfo.TaobaoOrderId, expressCompanyInfo.TaobaoCode, orderInfo.ShipOrderNumber, HiContext.Current.SiteUrl }); System.Net.WebRequest webRequest = System.Net.WebRequest.Create(requestUriString); webRequest.GetResponse(); } catch { } } int num3 = orderInfo.UserId; if (num3 == 1100) { num3 = 0; } IUser user = Users.GetUser(num3); Messenger.OrderShipping(orderInfo, user); orderInfo.OnDeliver(); num++; } else { if (!deliverFailOrders.ContainsKey(orderIds[i])) { failOrderInfo = new deliverFailOrderInfo(); failOrderInfo.OrderId = orderIds[i]; failOrderInfo.FailInfo = "发货失败"; failOrderInfo.ExpressCompanyCode = ShipOrderNumber[i]; failOrderInfo.ExpressCompanyName = expressCompanyName[i]; listdeliverFailOrderInfo.Add(failOrderInfo); deliverFailOrders.Add(orderIds[i], "发货失败"); } } } else { if (!deliverFailOrders.ContainsKey(orderIds[i])) { failOrderInfo = new deliverFailOrderInfo(); failOrderInfo.OrderId = orderIds[i]; failOrderInfo.FailInfo = "该订单不满足发货条件"; failOrderInfo.ExpressCompanyCode = ShipOrderNumber[i]; failOrderInfo.ExpressCompanyName = expressCompanyName[i]; listdeliverFailOrderInfo.Add(failOrderInfo); deliverFailOrders.Add(orderIds[i], "该订单不满足发货条件"); } } } #endregion #region 失败订单抛出 if (deliverFailOrders.Count > 0) { System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder(); stringBuilder.AppendLine("<html><head><meta http-equiv=Content-Type content=\"text/html; charset=gb2312\"></head><body>"); stringBuilder.AppendLine("<table cellspacing=\"0\" cellpadding=\"5\" rules=\"all\" border=\"1\">"); stringBuilder.AppendLine("<caption style='text-align:center;'>发货未成功订单列表</caption>"); stringBuilder.AppendLine("<tr style=\"font-weight: bold; white-space: nowrap;\">"); stringBuilder.AppendLine("<td>订单号</td>"); stringBuilder.AppendLine("<td>物流公司</td>"); stringBuilder.AppendLine("<td>物流单号</td>"); stringBuilder.AppendLine("<td>错误信息</td>"); stringBuilder.AppendLine("</tr>"); foreach (deliverFailOrderInfo failOrderInfo in listdeliverFailOrderInfo) { stringBuilder.AppendLine("<tr>"); stringBuilder.AppendLine(string.Format("<td style=\"vnd.ms-excel.numberformat:@\">{0}</td>", failOrderInfo.OrderId)); stringBuilder.AppendLine(string.Format("<td style=\"vnd.ms-excel.numberformat:@\">{0}</td>", failOrderInfo.ExpressCompanyName)); stringBuilder.AppendLine(string.Format("<td style=\"vnd.ms-excel.numberformat:@\">{0}</td>", failOrderInfo.ExpressCompanyCode)); stringBuilder.AppendLine(string.Format("<td style=\"vnd.ms-excel.numberformat:@\">{0}</td>", failOrderInfo.FailInfo)); stringBuilder.AppendLine("</tr>"); } stringBuilder.AppendLine("</table>"); stringBuilder.AppendLine("</body></html>"); base.Response.Clear(); base.Response.Buffer = false; base.Response.Charset = "GB2312"; base.Response.AppendHeader("Content-Disposition", "attachment;filename=发货未成功订单_" + System.DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls"); base.Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312"); base.Response.ContentType = "application/ms-excel"; this.EnableViewState = false; base.Response.Write(stringBuilder.ToString()); } #endregion this.btnBatchSend.Enabled = true; this.ShowMsg("操作完成!", true); //base.Response.End(); }
protected void dlstOrders_ItemCommand(object sender, System.Web.UI.WebControls.DataListCommandEventArgs e) { OrderInfo orderInfo = OrderHelper.GetOrderInfo(e.CommandArgument.ToString()); if (orderInfo != null) { if (e.CommandName == "CONFIRM_PAY" && orderInfo.CheckAction(OrderActions.SELLER_CONFIRM_PAY)) { int num = 0; int num2 = 0; int num3 = 0; if (orderInfo.CountDownBuyId > 0) { CountDownInfo countDownBuy = TradeHelper.GetCountDownBuy(orderInfo.CountDownBuyId); if (countDownBuy == null || countDownBuy.EndDate < System.DateTime.Now) { this.ShowMsg("当前的订单为限时抢购订单,此活动已结束,所以不能支付", false); return; } } if (orderInfo.GroupBuyId > 0) { GroupBuyInfo groupBuy = PromoteHelper.GetGroupBuy(orderInfo.GroupBuyId); if (groupBuy != null) { if (groupBuy.Status == GroupBuyStatus.UnderWay) { num2 = PromoteHelper.GetOrderCount(orderInfo.GroupBuyId); num = groupBuy.MaxCount; num3 = orderInfo.GetGroupBuyOerderNumber(); if (num < num2 + num3) { this.ShowMsg("当前的订单为团购订单,订购数量已超过订购总数,所以不能支付", false); return; } goto IL_E2; } } this.ShowMsg("当前的订单为团购订单,此团购活动已结束,所以不能支付", false); return; } IL_E2: if (OrderHelper.ConfirmPay(orderInfo)) { DebitNote debitNote = new DebitNote(); debitNote.NoteId = Globals.GetGenerateId(); debitNote.OrderId = e.CommandArgument.ToString(); debitNote.Operator = Hidistro.Membership.Context.HiContext.Current.User.Username; debitNote.Remark = "后台" + debitNote.Operator + "收款成功"; OrderHelper.SaveDebitNote(debitNote); if (orderInfo.GroupBuyId > 0 && num == num2 + num3) { PromoteHelper.SetGroupBuyEndUntreated(orderInfo.GroupBuyId); } this.BindOrders(); int num4 = orderInfo.UserId; if (num4 == 1100) { num4 = 0; } Hidistro.Membership.Core.IUser user = Hidistro.Membership.Context.Users.GetUser(num4); Messenger.OrderPayment(user, orderInfo.OrderId, orderInfo.GetTotal()); orderInfo.OnPayment(); this.Page.ClientScript.RegisterClientScriptBlock(base.GetType(), "sucess", string.Format("<script language=\"javascript\" >alert('确认收款成功');window.location.href=\"{0}\"</script>", System.Web.HttpContext.Current.Request.RawUrl)); return; } this.ShowMsg("确认订单收款失败", false); return; } else { if (e.CommandName == "FINISH_TRADE" && orderInfo.CheckAction(OrderActions.SELLER_FINISH_TRADE)) { if (OrderHelper.ConfirmOrderFinish(orderInfo)) { this.BindOrders(); this.ShowMsg("成功的完成了该订单", true); return; } this.ShowMsg("完成订单失败", false); return; } else { if (e.CommandName == "Match_Order") { if (orderInfo == null) { return; } if (orderInfo.GroupBuyId > 0 && orderInfo.GroupBuyStatus != GroupBuyStatus.Success) { this.ShowMsg("当前订单为团购订单,团购活动还未成功结束,所以不能发货", false); return; } if (!orderInfo.CheckAction(OrderActions.SELLER_SEND_GOODS)) { this.ShowMsg("当前订单状态没有付款或不是等待发货的订单,所以不能发货", false); return; } if (Methods.Supplier_OrderIsFenPei(e.CommandArgument.ToString())) { this.ShowMsg("生成成功", true); return; } string text = Methods.Supplier_OrderItemSupplierUpdate(orderInfo); if (text != "true") { this.ShowMsg(text, false); return; } orderInfo.RealShippingModeId = 0; orderInfo.RealModeName = "配送方式(已实际发货单为准)"; orderInfo.ShipOrderNumber = string.Format("{0}", string.Format(" <a style=\"color:red;cursor:pointer;\" target=\"_blank\" onclick=\"{0}\">物流详细</a>", "showWindow_ShipInfoPage('" + orderInfo.OrderId + "')")); if (OrderHelper.SendGoods(orderInfo)) { Methods.Supplier_OrderItemsSupplierFenPeiOverUpdate(orderInfo.OrderId); if (!string.IsNullOrEmpty(orderInfo.GatewayOrderId) && orderInfo.GatewayOrderId.Trim().Length > 0) { PaymentModeInfo paymentMode = SalesHelper.GetPaymentMode(orderInfo.PaymentTypeId); if (paymentMode != null) { PaymentRequest paymentRequest = PaymentRequest.CreateInstance(paymentMode.Gateway, HiCryptographer.Decrypt(paymentMode.Settings), orderInfo.OrderId, orderInfo.GetTotal(), "订单发货", "订单号-" + orderInfo.OrderId, orderInfo.EmailAddress, orderInfo.OrderDate, Globals.FullPath(Globals.GetSiteUrls().Home), Globals.FullPath(Globals.GetSiteUrls().UrlData.FormatUrl("PaymentReturn_url", new object[] { paymentMode.Gateway })), Globals.FullPath(Globals.GetSiteUrls().UrlData.FormatUrl("PaymentNotify_url", new object[] { paymentMode.Gateway })), ""); paymentRequest.SendGoods(orderInfo.GatewayOrderId, orderInfo.RealModeName, orderInfo.ShipOrderNumber, "EXPRESS"); } } int num5 = orderInfo.UserId; if (num5 == 1100) { num5 = 0; } Hidistro.Membership.Core.IUser user2 = Hidistro.Membership.Context.Users.GetUser(num5); Messenger.OrderShipping(orderInfo, user2); orderInfo.OnDeliver(); this.ShowMsg("生成成功", true); this.BindOrders(); return; } this.ShowMsg("发货失败", false); this.ShowMsg("生成成功", true); } } } } }
private void btnSendGoods_Click(object sender, System.EventArgs e) { OrderInfo orderInfo = OrderHelper.GetOrderInfo(this.orderId); if (orderInfo == null) { return; } if (orderInfo.GroupBuyId > 0 && orderInfo.GroupBuyStatus != GroupBuyStatus.Success) { this.ShowMsg("当前订单为团购订单,团购活动还未成功结束,所以不能发货", false); return; } if (!orderInfo.CheckAction(OrderActions.SELLER_SEND_GOODS)) { this.ShowMsg("当前订单状态没有付款或不是等待发货的订单,所以不能发货", false); return; } if (!this.radioShippingMode.SelectedValue.HasValue) { this.ShowMsg("请选择配送方式", false); return; } if (string.IsNullOrEmpty(this.txtShipOrderNumber.Text.Trim()) || this.txtShipOrderNumber.Text.Trim().Length > 20) { this.ShowMsg("运单号码不能为空,在1至20个字符之间", false); return; } if (string.IsNullOrEmpty(this.expressRadioButtonList.SelectedValue)) { this.ShowMsg("请选择物流公司", false); return; } ShippingModeInfo shippingMode = SalesHelper.GetShippingMode(this.radioShippingMode.SelectedValue.Value, true); orderInfo.RealShippingModeId = this.radioShippingMode.SelectedValue.Value; orderInfo.RealModeName = shippingMode.Name; ExpressCompanyInfo expressCompanyInfo = ExpressHelper.FindNode(this.expressRadioButtonList.SelectedValue); if (expressCompanyInfo != null) { orderInfo.ExpressCompanyAbb = expressCompanyInfo.Kuaidi100Code; orderInfo.ExpressCompanyName = expressCompanyInfo.Name; } orderInfo.ShipOrderNumber = this.txtShipOrderNumber.Text; if (OrderHelper.SendGoods(orderInfo)) { SendNote sendNote = new SendNote(); sendNote.NoteId = Globals.GetGenerateId(); sendNote.OrderId = this.orderId; sendNote.Operator = Hidistro.Membership.Context.HiContext.Current.User.Username; sendNote.Remark = "后台" + sendNote.Operator + "发货成功"; OrderHelper.SaveSendNote(sendNote); if (!string.IsNullOrEmpty(orderInfo.GatewayOrderId) && orderInfo.GatewayOrderId.Trim().Length > 0) { PaymentModeInfo paymentMode = SalesHelper.GetPaymentMode(orderInfo.PaymentTypeId); if (paymentMode != null) { PaymentRequest paymentRequest = PaymentRequest.CreateInstance(paymentMode.Gateway, HiCryptographer.Decrypt(paymentMode.Settings), orderInfo.OrderId, orderInfo.GetTotal(), "订单发货", "订单号-" + orderInfo.OrderId, orderInfo.EmailAddress, orderInfo.OrderDate, Globals.FullPath(Globals.GetSiteUrls().Home), Globals.FullPath(Globals.GetSiteUrls().UrlData.FormatUrl("PaymentReturn_url", new object[] { paymentMode.Gateway })), Globals.FullPath(Globals.GetSiteUrls().UrlData.FormatUrl("PaymentNotify_url", new object[] { paymentMode.Gateway })), ""); paymentRequest.SendGoods(orderInfo.GatewayOrderId, orderInfo.RealModeName, orderInfo.ShipOrderNumber, "EXPRESS"); } } int num = orderInfo.UserId; if (num == 1100) { num = 0; } Hidistro.Membership.Core.IUser user = Hidistro.Membership.Context.Users.GetUser(num); Messenger.OrderShipping(orderInfo, user); orderInfo.OnDeliver(); this.ShowMsg("发货成功", true); return; } this.ShowMsg("发货失败", false); }
private void btnSendGoods_Click(object sender, EventArgs e) { OrderInfo orderInfo = OrderHelper.GetOrderInfo(this.orderId); if (orderInfo != null) { if (orderInfo.OrderStatus == OrderStatus.WaitBuyerPay && OrderHelper.NeedUpdateStockWhenSendGoods(orderInfo) && !OrderHelper.CheckStock(orderInfo)) { this.ShowMsg("订单有商品库存不足,请补充库存后发货!", false); } else if (orderInfo.GroupBuyId > 0 && orderInfo.GroupBuyStatus != GroupBuyStatus.Success) { this.ShowMsg("当前订单为团购订单,团购活动还未成功结束,所以不能发货", false); } else if (!orderInfo.CheckAction(OrderActions.SELLER_SEND_GOODS)) { this.ShowMsg("当前订单状态没有付款或不是等待发货的订单,所以不能发货", false); } else { ExpressCompanyInfo expressCompanyInfo = null; if (!string.IsNullOrEmpty(this.expressRadioButtonList.SelectedValue)) { expressCompanyInfo = ExpressHelper.FindNode(this.expressRadioButtonList.SelectedValue); if (expressCompanyInfo != null) { orderInfo.ExpressCompanyAbb = expressCompanyInfo.Kuaidi100Code; orderInfo.ExpressCompanyName = expressCompanyInfo.Name; } orderInfo.ShipOrderNumber = this.txtShipOrderNumber.Text; if (!string.IsNullOrEmpty(orderInfo.OuterOrderId) && orderInfo.OuterOrderId.StartsWith("jd_") && string.IsNullOrWhiteSpace(expressCompanyInfo.JDCode)) { this.ShowMsg("此订单是京东订单,所选物流公司不被京东支持", false); return; } } if (OrderHelper.SendGoods(orderInfo)) { if (!string.IsNullOrEmpty(orderInfo.ExpressCompanyAbb) && orderInfo.ExpressCompanyAbb.ToUpper() == "HTKY") { ExpressHelper.GetDataByKuaidi100(orderInfo.ExpressCompanyAbb, orderInfo.ShipOrderNumber); } string text = ""; if (orderInfo.Gateway == "hishop.plugins.payment.weixinrequest") { SiteSettings masterSettings = SettingsManager.GetMasterSettings(); PayClient payClient = new PayClient(masterSettings.WeixinAppId, masterSettings.WeixinAppSecret, masterSettings.WeixinPartnerID, masterSettings.WeixinPartnerKey, masterSettings.WeixinPaySignKey, "", "", ""); DeliverInfo deliverInfo = new DeliverInfo(); deliverInfo.TransId = orderInfo.GatewayOrderId; deliverInfo.OutTradeNo = orderInfo.OrderId; MemberOpenIdInfo memberOpenIdInfo = Users.GetUser(orderInfo.UserId).MemberOpenIds.FirstOrDefault((MemberOpenIdInfo item) => item.OpenIdType.ToLower() == "hishop.plugins.openid.weixin"); if (memberOpenIdInfo != null) { deliverInfo.OpenId = memberOpenIdInfo.OpenId; } payClient.DeliverNotify(deliverInfo); } else { if (!string.IsNullOrEmpty(orderInfo.GatewayOrderId) && orderInfo.GatewayOrderId.Trim().Length > 0) { try { PaymentModeInfo paymentMode = SalesHelper.GetPaymentMode(orderInfo.Gateway); if (paymentMode != null && !string.IsNullOrEmpty(paymentMode.Settings)) { string hIGW = paymentMode.Gateway.Replace(".", "_"); PaymentRequest paymentRequest = PaymentRequest.CreateInstance(paymentMode.Gateway, HiCryptographer.Decrypt(paymentMode.Settings), orderInfo.OrderId, orderInfo.GetTotal(false), "订单发货", "订单号-" + orderInfo.OrderId, orderInfo.EmailAddress, orderInfo.OrderDate, Globals.FullPath(""), Globals.FullPath(base.GetRouteUrl("PaymentReturn_url", new { HIGW = hIGW })), Globals.FullPath(base.GetRouteUrl("PaymentNotify_url", new { HIGW = hIGW })), ""); paymentRequest.SendGoods(orderInfo.GatewayOrderId, orderInfo.RealModeName, orderInfo.ShipOrderNumber, "EXPRESS"); } } catch (Exception) { } } if (!string.IsNullOrEmpty(orderInfo.OuterOrderId) && expressCompanyInfo != null) { if (orderInfo.OuterOrderId.StartsWith("tb_")) { string text2 = orderInfo.OuterOrderId.Replace("tb_", ""); try { string requestUriString = $"http://order2.kuaidiangtong.com/UpdateShipping.ashx?tid={text2}&companycode={expressCompanyInfo.TaobaoCode}&outsid={orderInfo.ShipOrderNumber}&Host={HiContext.Current.SiteUrl}"; WebRequest webRequest = WebRequest.Create(requestUriString); webRequest.GetResponse(); } catch { } } else if (orderInfo.OuterOrderId.StartsWith("jd_") && expressCompanyInfo != null) { string text2 = orderInfo.OuterOrderId.Replace("jd_", ""); try { SiteSettings masterSettings2 = SettingsManager.GetMasterSettings(); JDHelper.JDOrderOutStorage(masterSettings2.JDAppKey, masterSettings2.JDAppSecret, masterSettings2.JDAccessToken, expressCompanyInfo.JDCode, orderInfo.ShipOrderNumber, text2); } catch (Exception ex2) { text = $"\r\n同步京东发货失败,京东订单号:{text2},{ex2.Message}\r\n"; } } } } MemberInfo user = Users.GetUser(orderInfo.UserId); Messenger.OrderShipping(orderInfo, user); orderInfo.OnDeliver(); if (string.IsNullOrWhiteSpace(text)) { this.ShowMsg("发货成功", true); this.CloseWindow("../sales/manageorder.aspx"); } else { this.ShowMsg($"发货成功{text}", true); } } else { this.ShowMsg("发货失败,可能是商品库存不足,订单中有商品正在退货、换货状态", false); } } } }
public ApiErrorCode SendOrders(OrderInfo order, ShippingModeInfo shippingmode, string out_id, ExpressCompanyInfo express) { if (order.GroupBuyId > 0 && order.GroupBuyStatus != GroupBuyStatus.Success) { return(ApiErrorCode.Group_Error); } if (!order.CheckAction(OrderActions.SELLER_SEND_GOODS)) { return(ApiErrorCode.NoPay_Error); } if (shippingmode.ModeId <= 0) { return(ApiErrorCode.NoShippingMode); } if (string.IsNullOrEmpty(out_id) || out_id.Length > 20) { return(ApiErrorCode.ShipingOrderNumber_Error); } order.RealShippingModeId = shippingmode.ModeId; order.RealModeName = shippingmode.Name; order.ExpressCompanyName = express.Name; order.ExpressCompanyAbb = express.Kuaidi100Code; order.ShipOrderNumber = out_id; if (OrderHelper.SendAPIGoods(order)) { if (!string.IsNullOrEmpty(order.GatewayOrderId)) { PaymentModeInfo paymentMode = SalesHelper.GetPaymentMode(order.PaymentTypeId); if (paymentMode != null) { PaymentRequest paymentRequest = PaymentRequest.CreateInstance(paymentMode.Gateway, HiCryptographer.Decrypt(paymentMode.Settings), order.OrderId, order.GetTotal(), "订单发货", "订单号-" + order.OrderId, order.EmailAddress, order.OrderDate, Globals.FullPath(Globals.GetSiteUrls().Home), Globals.FullPath(Globals.GetSiteUrls().UrlData.FormatUrl("PaymentReturn_url", new object[] { paymentMode.Gateway })), Globals.FullPath(Globals.GetSiteUrls().UrlData.FormatUrl("PaymentNotify_url", new object[] { paymentMode.Gateway })), ""); paymentRequest.SendGoods(order.GatewayOrderId, order.RealModeName, order.ShipOrderNumber, "EXPRESS"); } } if (!string.IsNullOrEmpty(order.TaobaoOrderId)) { try { string requestUriString = string.Format("http://vip.ecdev.cn/UpdateShipping.ashx?tid={0}&companycode={1}&outsid={2}", order.TaobaoOrderId, express.TaobaoCode, order.ShipOrderNumber); System.Net.WebRequest webRequest = System.Net.WebRequest.Create(requestUriString); webRequest.GetResponse(); } catch { } } int num = order.UserId; if (num == 1100) { num = 0; } IUser user = Users.GetUser(num); Messenger.OrderShipping(order, user); order.OnDeliver(); return(ApiErrorCode.Success); } return(ApiErrorCode.Unknown_Error); }
private void btnSendGoods_Click(object sender, EventArgs e) { if (this.grdOrderGoods.Items.Count <= 0) { this.ShowMsg("没有要进行发货的订单。", false); } else { StringBuilder stringBuilder = new StringBuilder(); SiteSettings masterSettings = SettingsManager.GetMasterSettings(); int num = 0; for (int i = 0; i < this.grdOrderGoods.Items.Count; i++) { HiddenField hiddenField = (HiddenField)this.grdOrderGoods.Items[i].FindControl("hidorderId"); string value = hiddenField.Value; TextBox textBox = (TextBox)this.grdOrderGoods.Items[i].FindControl("txtShippOrderNumber"); ExpressDropDownList expressDropDownList = this.grdOrderGoods.Items[i].FindControl("expressList1") as ExpressDropDownList; OrderInfo orderInfo = OrderHelper.GetOrderInfo(value); if ((orderInfo.GroupBuyId <= 0 || orderInfo.GroupBuyStatus == GroupBuyStatus.Success) && ((orderInfo.OrderStatus == OrderStatus.WaitBuyerPay && orderInfo.Gateway == "hishop.plugins.payment.podrequest") || orderInfo.OrderStatus == OrderStatus.BuyerAlreadyPaid)) { ExpressCompanyInfo expressCompanyInfo = null; if (!string.IsNullOrEmpty(expressDropDownList.SelectedValue)) { expressCompanyInfo = ExpressHelper.FindNode(expressDropDownList.SelectedValue); } if (expressCompanyInfo != null) { if (!string.IsNullOrEmpty(orderInfo.OuterOrderId) && orderInfo.OuterOrderId.StartsWith("jd_") && string.IsNullOrWhiteSpace(expressCompanyInfo.JDCode)) { continue; } orderInfo.ExpressCompanyName = expressCompanyInfo.Name; orderInfo.ExpressCompanyAbb = expressCompanyInfo.Kuaidi100Code; orderInfo.ShipOrderNumber = textBox.Text; } if (OrderHelper.SendGoods(orderInfo) && expressCompanyInfo != null && !string.IsNullOrEmpty(orderInfo.ExpressCompanyAbb) && orderInfo.ExpressCompanyAbb.ToUpper() == "HTKY") { ExpressHelper.GetDataByKuaidi100(orderInfo.ExpressCompanyAbb, orderInfo.ShipOrderNumber); } if (!string.IsNullOrEmpty(orderInfo.GatewayOrderId) && orderInfo.GatewayOrderId.Trim().Length > 0) { PaymentModeInfo paymentMode = SalesHelper.GetPaymentMode(orderInfo.Gateway); if (paymentMode != null) { string hIGW = paymentMode.Gateway.Replace(".", "_"); PaymentRequest paymentRequest = PaymentRequest.CreateInstance(paymentMode.Gateway, HiCryptographer.Decrypt(paymentMode.Settings), orderInfo.PayOrderId, orderInfo.GetTotal(false), "订单发货", "订单号-" + orderInfo.PayOrderId, orderInfo.EmailAddress, orderInfo.OrderDate, Globals.FullPath(""), Globals.FullPath(base.GetRouteUrl("PaymentReturn_url", new { HIGW = hIGW })), Globals.FullPath(base.GetRouteUrl("PaymentNotify_url", new { HIGW = hIGW })), ""); paymentRequest.SendGoods(orderInfo.GatewayOrderId, orderInfo.RealModeName, orderInfo.ShipOrderNumber, "EXPRESS"); } } if (!string.IsNullOrEmpty(orderInfo.OuterOrderId) && expressCompanyInfo != null) { if (orderInfo.OuterOrderId.StartsWith("tb_")) { string text = orderInfo.OuterOrderId.Replace("tb_", ""); try { string requestUriString = $"http://order2.kuaidiangtong.com/UpdateShipping.ashx?tid={text}&companycode={expressCompanyInfo.TaobaoCode}&outsid={orderInfo.ShipOrderNumber}&Host={HiContext.Current.SiteUrl}"; WebRequest webRequest = WebRequest.Create(requestUriString); webRequest.GetResponse(); } catch { } } else if (orderInfo.OuterOrderId.StartsWith("jd_") && expressCompanyInfo != null) { string text = orderInfo.OuterOrderId.Replace("jd_", ""); try { JDHelper.JDOrderOutStorage(masterSettings.JDAppKey, masterSettings.JDAppSecret, masterSettings.JDAccessToken, expressCompanyInfo.JDCode, orderInfo.ShipOrderNumber, text); } catch (Exception ex) { stringBuilder.Append($"订单:{orderInfo.OrderId}同步京东发货失败,京东订单号:{text},{ex.Message}\r\n"); } } } int num2 = orderInfo.UserId; if (num2 == 1100) { num2 = 0; } MemberInfo user = Users.GetUser(num2); Messenger.OrderShipping(orderInfo, user); orderInfo.OnDeliver(); num++; } } if (num == 0) { this.ShowMsg("批量发货失败,您填写的信息不完整!", false); } else if (num > 0) { this.ShowMsgCloseWindow(string.Format("批量发货成功!发货数量{0}个!{1}", num, (stringBuilder.Length > 0) ? stringBuilder.ToString() : ""), true); } } }
private void btnSendGoods_Click(object sender, System.EventArgs e) { OrderInfo orderInfo = OrderHelper.GetOrderInfo(this.orderId); if (orderInfo == null) { return; } if (orderInfo.GroupBuyId > 0 && orderInfo.GroupBuyStatus != GroupBuyStatus.Success) { this.ShowMsg("当前订单为团购订单,团购活动还未成功结束,所以不能发货", false); return; } if (!orderInfo.CheckAction(OrderActions.SELLER_SEND_GOODS)) { this.ShowMsg("当前订单状态没有付款或不是等待发货的订单,所以不能发货", false); return; } if (Methods.Supplier_OrderIsFenPei(this.orderId)) { this.ShowMsg("生成成功", true); return; } string text = Methods.Supplier_OrderItemSupplierUpdate(orderInfo); if (text != "true") { this.ShowMsg(text, false); return; } orderInfo.RealShippingModeId = 0; orderInfo.RealModeName = "配送方式(已实际发货单为准)"; orderInfo.ShipOrderNumber = string.Format("{0}", string.Format(" <a style=\"color:red;cursor:pointer;\" target=\"_blank\" onclick=\"{0}\">物流详细</a>", "showWindow_ShipInfoPage('" + orderInfo.OrderId + "')")); if (OrderHelper.SendGoods(orderInfo)) { Methods.Supplier_OrderItemsSupplierFenPeiOverUpdate(orderInfo.OrderId); if (!string.IsNullOrEmpty(orderInfo.GatewayOrderId) && orderInfo.GatewayOrderId.Trim().Length > 0) { PaymentModeInfo paymentMode = SalesHelper.GetPaymentMode(orderInfo.PaymentTypeId); if (paymentMode != null) { PaymentRequest paymentRequest = PaymentRequest.CreateInstance(paymentMode.Gateway, HiCryptographer.Decrypt(paymentMode.Settings), orderInfo.OrderId, orderInfo.GetTotal(), "订单发货", "订单号-" + orderInfo.OrderId, orderInfo.EmailAddress, orderInfo.OrderDate, Globals.FullPath(Globals.GetSiteUrls().Home), Globals.FullPath(Globals.GetSiteUrls().UrlData.FormatUrl("PaymentReturn_url", new object[] { paymentMode.Gateway })), Globals.FullPath(Globals.GetSiteUrls().UrlData.FormatUrl("PaymentNotify_url", new object[] { paymentMode.Gateway })), ""); paymentRequest.SendGoods(orderInfo.GatewayOrderId, orderInfo.RealModeName, "物流单(已实际发货单为准,可在下单网站查看)", "EXPRESS"); } } int num = orderInfo.UserId; if (num == 1100) { num = 0; } Hidistro.Membership.Core.IUser user = Hidistro.Membership.Context.Users.GetUser(num); Messenger.OrderShipping(orderInfo, user); orderInfo.OnDeliver(); this.CloseWindow(); return; } this.ShowMsg("发货失败", false); }
private void btnSendGoods_Click(object sender, System.EventArgs e) { if (this.txtShipOrderNumber.Text.IndexOf("showWindow_ShipInfoPage") != -1) { OrderInfo orderInfo = SubsiteSalesHelper.GetOrderInfo(this.orderId); if (orderInfo == null) { return; } if (orderInfo.GroupBuyId > 0 && orderInfo.GroupBuyStatus != GroupBuyStatus.Success) { this.ShowMsg("当前订单为团购订单,团购活动还未成功结束,所以不能发货", false); return; } if (orderInfo.OrderStatus != OrderStatus.BuyerAlreadyPaid) { this.ShowMsg("当前订单状态没有付款或不是等待发货的订单,所以不能发货", false); return; } orderInfo.RealShippingModeId = 0; orderInfo.RealModeName = "配送方式(已实际发货单为准)"; orderInfo.ShipOrderNumber = this.txtShipOrderNumber.Text; if (SubsiteSalesHelper.SendGoods(orderInfo)) { if (!string.IsNullOrEmpty(orderInfo.GatewayOrderId) && orderInfo.GatewayOrderId.Trim().Length > 0) { PaymentModeInfo paymentMode = SubsiteSalesHelper.GetPaymentMode(orderInfo.PaymentTypeId); if (paymentMode != null) { PaymentRequest paymentRequest = PaymentRequest.CreateInstance(paymentMode.Gateway, HiCryptographer.Decrypt(paymentMode.Settings), orderInfo.OrderId, orderInfo.GetTotal(), "订单发货", "订单号-" + orderInfo.OrderId, orderInfo.EmailAddress, orderInfo.OrderDate, Globals.FullPath(Globals.GetSiteUrls().Home), Globals.FullPath(Globals.GetSiteUrls().UrlData.FormatUrl("PaymentReturn_url", new object[] { paymentMode.Gateway })), Globals.FullPath(Globals.GetSiteUrls().UrlData.FormatUrl("PaymentNotify_url", new object[] { paymentMode.Gateway })), ""); paymentRequest.SendGoods(orderInfo.GatewayOrderId, orderInfo.RealModeName, orderInfo.ShipOrderNumber, "EXPRESS"); } } int num = orderInfo.UserId; if (num == 1100) { num = 0; } Hidistro.Membership.Core.IUser user = Hidistro.Membership.Context.Users.GetUser(num); Messenger.OrderShipping(orderInfo, user); orderInfo.OnDeliver(); this.ShowMsg("发货成功", true); return; } this.ShowMsg("发货失败", false); return; } else { if (string.IsNullOrEmpty(this.txtShipOrderNumber.Text.Trim()) || this.txtShipOrderNumber.Text.Trim().Length > 20) { this.ShowMsg("运单号码不能为空,在1至20个字符之间", false); return; } OrderInfo orderInfo2 = SubsiteSalesHelper.GetOrderInfo(this.orderId); if (orderInfo2 == null) { return; } if (orderInfo2.GroupBuyId > 0 && orderInfo2.GroupBuyStatus != GroupBuyStatus.Success) { this.ShowMsg("当前订单为团购订单,团购活动还未成功结束,所以不能发货", false); return; } if (orderInfo2.OrderStatus != OrderStatus.BuyerAlreadyPaid) { this.ShowMsg("当前订单状态没有付款或不是等待发货的订单,所以不能发货", false); return; } if (!this.radioShippingMode.SelectedValue.HasValue) { this.ShowMsg("请选择配送方式", false); return; } if (string.IsNullOrEmpty(this.expressRadioButtonList.SelectedValue)) { this.ShowMsg("请选择物流公司", false); return; } ShippingModeInfo shippingMode = SubsiteSalesHelper.GetShippingMode(this.radioShippingMode.SelectedValue.Value, true); orderInfo2.RealShippingModeId = this.radioShippingMode.SelectedValue.Value; orderInfo2.RealModeName = shippingMode.Name; ExpressCompanyInfo expressCompanyInfo = ExpressHelper.FindNode(this.expressRadioButtonList.SelectedValue); if (expressCompanyInfo != null) { orderInfo2.ExpressCompanyAbb = expressCompanyInfo.Kuaidi100Code; orderInfo2.ExpressCompanyName = expressCompanyInfo.Name; } orderInfo2.ShipOrderNumber = this.txtShipOrderNumber.Text; if (SubsiteSalesHelper.SendGoods(orderInfo2)) { if (!string.IsNullOrEmpty(orderInfo2.GatewayOrderId) && orderInfo2.GatewayOrderId.Trim().Length > 0) { PaymentModeInfo paymentMode2 = SubsiteSalesHelper.GetPaymentMode(orderInfo2.PaymentTypeId); if (paymentMode2 != null) { PaymentRequest paymentRequest2 = PaymentRequest.CreateInstance(paymentMode2.Gateway, HiCryptographer.Decrypt(paymentMode2.Settings), orderInfo2.OrderId, orderInfo2.GetTotal(), "订单发货", "订单号-" + orderInfo2.OrderId, orderInfo2.EmailAddress, orderInfo2.OrderDate, Globals.FullPath(Globals.GetSiteUrls().Home), Globals.FullPath(Globals.GetSiteUrls().UrlData.FormatUrl("PaymentReturn_url", new object[] { paymentMode2.Gateway })), Globals.FullPath(Globals.GetSiteUrls().UrlData.FormatUrl("PaymentNotify_url", new object[] { paymentMode2.Gateway })), ""); paymentRequest2.SendGoods(orderInfo2.GatewayOrderId, orderInfo2.RealModeName, orderInfo2.ShipOrderNumber, "EXPRESS"); } } int num2 = orderInfo2.UserId; if (num2 == 1100) { num2 = 0; } Hidistro.Membership.Core.IUser user2 = Hidistro.Membership.Context.Users.GetUser(num2); Messenger.OrderShipping(orderInfo2, user2); orderInfo2.OnDeliver(); this.ShowMsg("发货成功", true); return; } this.ShowMsg("发货失败", false); return; } }
private void btnSendGoods_Click(object sender, System.EventArgs e) { if (this.grdOrderGoods.Rows.Count <= 0) { this.ShowMsg("没有要进行发货的订单。", false); return; } DropdownColumn dropdownColumn = (DropdownColumn)this.grdOrderGoods.Columns[4]; System.Web.UI.WebControls.ListItemCollection selectedItems = dropdownColumn.SelectedItems; DropdownColumn dropdownColumn2 = (DropdownColumn)this.grdOrderGoods.Columns[5]; System.Web.UI.WebControls.ListItemCollection selectedItems2 = dropdownColumn2.SelectedItems; int num = 0; for (int i = 0; i < selectedItems.Count; i++) { string orderId = (string)this.grdOrderGoods.DataKeys[this.grdOrderGoods.Rows[i].RowIndex].Value; System.Web.UI.WebControls.TextBox textBox = (System.Web.UI.WebControls.TextBox) this.grdOrderGoods.Rows[i].FindControl("txtShippOrderNumber"); System.Web.UI.WebControls.ListItem listItem = selectedItems[i]; System.Web.UI.WebControls.ListItem listItem2 = selectedItems2[i]; int num2 = 0; int.TryParse(listItem.Value, out num2); if (!string.IsNullOrEmpty(textBox.Text.Trim()) && !string.IsNullOrEmpty(listItem.Value) && int.Parse(listItem.Value) > 0 && !string.IsNullOrEmpty(listItem2.Value)) { OrderInfo orderInfo = OrderHelper.GetOrderInfo(orderId); if ((orderInfo.GroupBuyId <= 0 || orderInfo.GroupBuyStatus == GroupBuyStatus.Success) && ((orderInfo.OrderStatus == OrderStatus.WaitBuyerPay && orderInfo.Gateway == "Ecdev.plugins.payment.podrequest") || orderInfo.OrderStatus == OrderStatus.BuyerAlreadyPaid) && num2 > 0 && !string.IsNullOrEmpty(textBox.Text.Trim()) && textBox.Text.Trim().Length <= 20) { ShippingModeInfo shippingMode = SalesHelper.GetShippingMode(num2, true); orderInfo.RealShippingModeId = shippingMode.ModeId; orderInfo.RealModeName = shippingMode.Name; ExpressCompanyInfo expressCompanyInfo = ExpressHelper.FindNode(listItem2.Value); orderInfo.ExpressCompanyName = expressCompanyInfo.Name; orderInfo.ExpressCompanyAbb = expressCompanyInfo.Kuaidi100Code; orderInfo.ShipOrderNumber = textBox.Text; if (OrderHelper.SendGoods(orderInfo)) { SendNoteInfo sendNoteInfo = new SendNoteInfo(); sendNoteInfo.NoteId = Globals.GetGenerateId() + num; sendNoteInfo.OrderId = orderId; sendNoteInfo.Operator = HiContext.Current.User.Username; sendNoteInfo.Remark = "后台" + sendNoteInfo.Operator + "发货成功"; OrderHelper.SaveSendNote(sendNoteInfo); if (!string.IsNullOrEmpty(orderInfo.GatewayOrderId) && orderInfo.GatewayOrderId.Trim().Length > 0) { PaymentModeInfo paymentMode = SalesHelper.GetPaymentMode(orderInfo.Gateway); if (paymentMode != null) { PaymentRequest paymentRequest = PaymentRequest.CreateInstance(paymentMode.Gateway, HiCryptographer.Decrypt(paymentMode.Settings), orderInfo.OrderId, orderInfo.GetTotal(), "订单发货", "订单号-" + orderInfo.OrderId, orderInfo.EmailAddress, orderInfo.OrderDate, Globals.FullPath(Globals.GetSiteUrls().Home), Globals.FullPath(Globals.GetSiteUrls().UrlData.FormatUrl("PaymentReturn_url", new object[] { paymentMode.Gateway })), Globals.FullPath(Globals.GetSiteUrls().UrlData.FormatUrl("PaymentNotify_url", new object[] { paymentMode.Gateway })), ""); paymentRequest.SendGoods(orderInfo.GatewayOrderId, orderInfo.RealModeName, orderInfo.ShipOrderNumber, "EXPRESS"); } } if (!string.IsNullOrEmpty(orderInfo.TaobaoOrderId)) { try { string requestUriString = string.Format("http://vip.ecdev.cn/UpdateShipping.ashx?tid={0}&companycode={1}&outsid={2}&Host={3}", new object[] { orderInfo.TaobaoOrderId, expressCompanyInfo.TaobaoCode, orderInfo.ShipOrderNumber, HiContext.Current.SiteUrl }); System.Net.WebRequest webRequest = System.Net.WebRequest.Create(requestUriString); webRequest.GetResponse(); } catch { } } int num3 = orderInfo.UserId; if (num3 == 1100) { num3 = 0; } IUser user = Users.GetUser(num3); Messenger.OrderShipping(orderInfo, user); orderInfo.OnDeliver(); num++; } } } } if (num == 0) { this.ShowMsg("批量发货失败!", false); return; } if (num > 0) { this.BindData(); this.ShowMsg(string.Format("批量发货成功!发货数量{0}个", num), true); } }
private void btnSendGoods_Click(object sender, System.EventArgs e) { if (this.grdOrderGoods.Rows.Count <= 0) { this.ShowMsg("没有要进行发货的订单。", false); return; } DropdownColumn dropdownColumn = (DropdownColumn)this.grdOrderGoods.Columns[4]; System.Web.UI.WebControls.ListItemCollection selectedItems = dropdownColumn.SelectedItems; int num = 0; for (int i = 0; i < selectedItems.Count; i++) { string orderId = (string)this.grdOrderGoods.DataKeys[this.grdOrderGoods.Rows[i].RowIndex].Value; System.Web.UI.WebControls.TextBox textBox = (System.Web.UI.WebControls.TextBox) this.grdOrderGoods.Rows[i].FindControl("txtShippOrderNumber"); System.Web.UI.WebControls.ListItem listItem = selectedItems[i]; int num2 = 0; int.TryParse(listItem.Value, out num2); OrderInfo orderInfo = SubsiteSalesHelper.GetOrderInfo(orderId); if (orderInfo != null && (orderInfo.GroupBuyId <= 0 || orderInfo.GroupBuyStatus == GroupBuyStatus.Success) && orderInfo.OrderStatus == OrderStatus.BuyerAlreadyPaid && num2 > 0 && !string.IsNullOrEmpty(textBox.Text) && textBox.Text.Length <= 20) { ShippingModeInfo shippingMode = SubsiteSalesHelper.GetShippingMode(num2, true); orderInfo.RealShippingModeId = shippingMode.ModeId; orderInfo.RealModeName = shippingMode.Name; orderInfo.ShipOrderNumber = textBox.Text; if (SubsiteSalesHelper.SendGoods(orderInfo)) { if (!string.IsNullOrEmpty(orderInfo.GatewayOrderId) && orderInfo.GatewayOrderId.Trim().Length > 0) { PaymentModeInfo paymentMode = SubsiteSalesHelper.GetPaymentMode(orderInfo.PaymentTypeId); if (paymentMode != null) { PaymentRequest paymentRequest = PaymentRequest.CreateInstance(paymentMode.Gateway, HiCryptographer.Decrypt(paymentMode.Settings), orderInfo.OrderId, orderInfo.GetTotal(), "订单发货", "订单号-" + orderInfo.OrderId, orderInfo.EmailAddress, orderInfo.OrderDate, Globals.FullPath(Globals.GetSiteUrls().Home), Globals.FullPath(Globals.GetSiteUrls().UrlData.FormatUrl("PaymentReturn_url", new object[] { paymentMode.Gateway })), Globals.FullPath(Globals.GetSiteUrls().UrlData.FormatUrl("PaymentNotify_url", new object[] { paymentMode.Gateway })), ""); paymentRequest.SendGoods(orderInfo.GatewayOrderId, orderInfo.RealModeName, orderInfo.ShipOrderNumber, "EXPRESS"); } } int num3 = orderInfo.UserId; if (num3 == 1100) { num3 = 0; } Hidistro.Membership.Core.IUser user = Hidistro.Membership.Context.Users.GetUser(num3); Messenger.OrderShipping(orderInfo, user); orderInfo.OnDeliver(); } num++; } } if (num == 0) { this.ShowMsg("批量发货失败!,发货数量0个", false); return; } if (num > 0) { this.BindData(); this.ShowMsg(string.Format("批量发货成功!,发货数量{0}个", num), true); } }
private void btnSendGoods_Click(object sender, EventArgs e) { string text = this.txtDeliveryNo.Value.ToNullString(); OrderInfo orderInfo = OrderHelper.GetOrderInfo(this.orderId); int num = this.txtSendGoodType.Value.ToInt(0); if (orderInfo != null) { if (orderInfo.OrderStatus == OrderStatus.WaitBuyerPay && !OrderHelper.CheckStock(orderInfo)) { this.ShowMsg("订单有商品库存不足,请补充库存后发货!", false); } else if (orderInfo.GroupBuyId > 0 && orderInfo.GroupBuyStatus != GroupBuyStatus.Success) { this.ShowMsg("当前订单为团购订单,团购活动还未成功结束,所以不能发货", false); } else if (!orderInfo.CheckAction(OrderActions.SELLER_SEND_GOODS) || orderInfo.ItemStatus != 0) { this.ShowMsg("当前订单状态没有付款、不是等待发货的订单,或者订单中有商品正在进行退款操作,所以不能发货", false); } else if (num == 1 && (string.IsNullOrEmpty(this.txtShipOrderNumber.Text.Trim()) || this.txtShipOrderNumber.Text.Trim().Length > 20)) { this.ShowMsg("运单号码不能为空,在1至20个字符之间", false); } else if (num == 1 && string.IsNullOrEmpty(this.expressRadioButtonList.SelectedValue)) { this.ShowMsg("请选择物流公司", false); } else if (num == 2 && text == "") { this.ShowMsg("使用同城物流发货需要正确的物流编号", false); } else { string text2 = ""; ExpressCompanyInfo expressCompanyInfo = null; switch (num) { case 1: if (string.IsNullOrEmpty(this.expressRadioButtonList.SelectedValue)) { break; } expressCompanyInfo = ExpressHelper.FindNode(this.expressRadioButtonList.SelectedValue); if (expressCompanyInfo != null) { orderInfo.ExpressCompanyAbb = expressCompanyInfo.Kuaidi100Code; orderInfo.ExpressCompanyName = expressCompanyInfo.Name; } orderInfo.ShipOrderNumber = this.txtShipOrderNumber.Text; if (string.IsNullOrEmpty(orderInfo.OuterOrderId)) { break; } if (!orderInfo.OuterOrderId.StartsWith("jd_") || !string.IsNullOrWhiteSpace(expressCompanyInfo.JDCode)) { break; } this.ShowMsg("此订单是京东订单,所选物流公司不被京东支持", false); return; case 0: orderInfo.ExpressCompanyName = ""; orderInfo.ExpressCompanyAbb = ""; orderInfo.ShipOrderNumber = ""; break; default: orderInfo.ExpressCompanyName = "同城物流配送"; orderInfo.ExpressCompanyAbb = ""; orderInfo.ShipOrderNumber = ""; orderInfo.DadaStatus = DadaStatus.WaitOrder; break; } OrderStatus orderStatus = orderInfo.OrderStatus; if (OrderHelper.SendGoods(orderInfo)) { if (!string.IsNullOrEmpty(orderInfo.ExpressCompanyAbb) && orderInfo.ExpressCompanyAbb.ToUpper() == "HTKY") { ExpressHelper.GetDataByKuaidi100(orderInfo.ExpressCompanyAbb, orderInfo.ShipOrderNumber); } if (orderInfo.Gateway.ToNullString().ToLower() == "hishop.plugins.payment.podrequest") { ProductStatisticsHelper.UpdateOrderSaleStatistics(orderInfo); TransactionAnalysisHelper.AnalysisOrderTranData(orderInfo); } if (orderStatus == OrderStatus.WaitBuyerPay) { OrderHelper.ChangeStoreStockAndWriteLog(orderInfo); } if (orderInfo.Gateway == "hishop.plugins.payment.weixinrequest") { SiteSettings masterSettings = SettingsManager.GetMasterSettings(); PayClient payClient = new PayClient(masterSettings.WeixinAppId, masterSettings.WeixinAppSecret, masterSettings.WeixinPartnerID, masterSettings.WeixinPartnerKey, masterSettings.WeixinPaySignKey, "", "", ""); DeliverInfo deliverInfo = new DeliverInfo(); deliverInfo.TransId = orderInfo.GatewayOrderId; deliverInfo.OutTradeNo = orderInfo.PayOrderId; deliverInfo.OpenId = Users.GetUser(orderInfo.UserId).MemberOpenIds.FirstOrDefault((MemberOpenIdInfo item) => item.OpenIdType.ToLower() == "hishop.plugins.openid.weixin").OpenId; payClient.DeliverNotify(deliverInfo); } else { if (!string.IsNullOrEmpty(orderInfo.GatewayOrderId) && orderInfo.GatewayOrderId.Trim().Length > 0) { try { PaymentModeInfo paymentMode = SalesHelper.GetPaymentMode(orderInfo.Gateway); if (paymentMode != null && !string.IsNullOrEmpty(paymentMode.Settings)) { string hIGW = paymentMode.Gateway.Replace(".", "_"); PaymentRequest paymentRequest = PaymentRequest.CreateInstance(paymentMode.Gateway, HiCryptographer.TryDecypt(paymentMode.Settings), orderInfo.PayOrderId, orderInfo.GetTotal(false), "订单发货", "订单号-" + orderInfo.PayOrderId, orderInfo.EmailAddress, orderInfo.OrderDate, Globals.FullPath(""), Globals.FullPath(base.GetRouteUrl("PaymentReturn_url", new { HIGW = hIGW })), Globals.FullPath(base.GetRouteUrl("PaymentNotify_url", new { HIGW = hIGW })), ""); paymentRequest.SendGoods(orderInfo.GatewayOrderId, orderInfo.RealModeName, orderInfo.ShipOrderNumber, "EXPRESS"); } } catch (Exception) { } } if (!string.IsNullOrEmpty(orderInfo.OuterOrderId) && expressCompanyInfo != null) { if (orderInfo.OuterOrderId.StartsWith("tb_")) { string text3 = orderInfo.OuterOrderId.Replace("tb_", ""); try { string requestUriString = $"http://order2.kuaidiangtong.com/UpdateShipping.ashx?tid={text3}&companycode={expressCompanyInfo.TaobaoCode}&outsid={orderInfo.ShipOrderNumber}&Host={HiContext.Current.SiteUrl}"; WebRequest webRequest = WebRequest.Create(requestUriString); webRequest.GetResponse(); } catch { } } else if (orderInfo.OuterOrderId.StartsWith("jd_") && expressCompanyInfo != null) { string text3 = orderInfo.OuterOrderId.Replace("jd_", ""); try { SiteSettings masterSettings2 = SettingsManager.GetMasterSettings(); JDHelper.JDOrderOutStorage(masterSettings2.JDAppKey, masterSettings2.JDAppSecret, masterSettings2.JDAccessToken, expressCompanyInfo.JDCode, orderInfo.ShipOrderNumber, text3); } catch (Exception ex2) { text2 = $"\r\n同步京东发货失败,京东订单号:{text3},{ex2.Message}\r\n"; } } } } if (orderInfo.ExpressCompanyName == "同城物流配送" && !string.IsNullOrEmpty(text)) { SiteSettings masterSettings3 = SettingsManager.GetMasterSettings(); DadaHelper.addAfterQuery(masterSettings3.DadaSourceID, text); } int userId = orderInfo.UserId; MemberInfo user = Users.GetUser(orderInfo.UserId); Messenger.OrderShipping(orderInfo, user); orderInfo.OnDeliver(); if (orderInfo.Gateway.ToLower() == "hishop.plugins.payment.podrequest") { OrderHelper.SetOrderIsStoreCollect(orderInfo.OrderId); } if (string.IsNullOrWhiteSpace(text2)) { this.ShowMsg("发货成功", true); } else { this.ShowMsg($"发货成功{text2}", true); } } else { this.ShowMsg("发货失败,可能是商品库存不足,订单中有商品正在退货、换货状态", false); } } } }
public string SendLogistic(string tid, string company_name, string out_sid) { OrderInfo orderInfo = OrderHelper.GetOrderInfo(tid); if (orderInfo == null || string.IsNullOrEmpty(orderInfo.OrderId)) { return(OpenApiErrorMessage.ShowErrorMsg(OpenApiErrorCode.Trade_not_Exists, "tid")); } if (orderInfo.GroupBuyId > 0 && orderInfo.GroupBuyStatus != GroupBuyStatus.Success) { return(OpenApiErrorMessage.ShowErrorMsg(OpenApiErrorCode.Trade_Status_Send, "group order")); } if (!orderInfo.CheckAction(OrderActions.SELLER_SEND_GOODS)) { return(OpenApiErrorMessage.ShowErrorMsg(OpenApiErrorCode.Trade_Status_Send, "orderstatue")); } if (string.IsNullOrEmpty(out_sid)) { return(OpenApiErrorMessage.ShowErrorMsg(OpenApiErrorCode.Missing_Required_Arguments, "out_sid")); } ExpressCompanyInfo expressCompanyInfo = ExpressHelper.FindNode(company_name); if (expressCompanyInfo == null) { return(OpenApiErrorMessage.ShowErrorMsg(OpenApiErrorCode.Company_not_Exists, "company_name")); } orderInfo.ExpressCompanyAbb = expressCompanyInfo.Kuaidi100Code; orderInfo.ExpressCompanyName = expressCompanyInfo.Name; orderInfo.ShipOrderNumber = out_sid; if (!OrderHelper.SendGoods(orderInfo)) { return(OpenApiErrorMessage.ShowErrorMsg(OpenApiErrorCode.Trade_Status_Send, "send good")); } Express.SubscribeExpress100(orderInfo.ExpressCompanyAbb, out_sid); OrderHelper.SaveSendNote(new SendNoteInfo { NoteId = Globals.GetGenerateId(), OrderId = orderInfo.OrderId, Operator = orderInfo.UserId.ToString(), Remark = "接口发货成功" }); if (!string.IsNullOrEmpty(orderInfo.GatewayOrderId) && orderInfo.GatewayOrderId.Trim().Length > 0) { if (orderInfo.Gateway == "hishop.plugins.payment.ws_wappay.wswappayrequest") { PaymentModeInfo paymentMode = SalesHelper.GetPaymentMode(orderInfo.PaymentTypeId); if (paymentMode != null) { PaymentRequest paymentRequest = PaymentRequest.CreateInstance(paymentMode.Gateway, HiCryptographer.Decrypt(paymentMode.Settings), orderInfo.OrderId, orderInfo.GetTotal(), "订单发货", "订单号-" + orderInfo.OrderId, orderInfo.EmailAddress, orderInfo.OrderDate, Globals.FullPath(Globals.GetSiteUrls().Home), Globals.FullPath(Globals.GetSiteUrls().UrlData.FormatUrl("PaymentReturn_url", new object[] { paymentMode.Gateway })), Globals.FullPath(Globals.GetSiteUrls().UrlData.FormatUrl("PaymentNotify_url", new object[] { paymentMode.Gateway })), ""); paymentRequest.SendGoods(orderInfo.GatewayOrderId, orderInfo.RealModeName, orderInfo.ShipOrderNumber, "EXPRESS"); } } if (orderInfo.Gateway == "hishop.plugins.payment.weixinrequest") { SiteSettings masterSettings = SettingsManager.GetMasterSettings(false); PayClient payClient; if (masterSettings.EnableSP) { payClient = new PayClient(masterSettings.Main_AppId, masterSettings.WeixinAppSecret, masterSettings.Main_Mch_ID, masterSettings.Main_PayKey, true, masterSettings.WeixinAppId, masterSettings.WeixinPartnerID); } else { payClient = new PayClient(masterSettings.WeixinAppId, masterSettings.WeixinAppSecret, masterSettings.WeixinPartnerID, masterSettings.WeixinPartnerKey, false, "", ""); } payClient.DeliverNotify(new DeliverInfo { TransId = orderInfo.GatewayOrderId, OutTradeNo = orderInfo.OrderId, OpenId = MemberHelper.GetMember(orderInfo.UserId).OpenId }); } } orderInfo.OnDeliver(); string format = "{{\"logistics_send_response\":{{\"shipping\":{{\"is_success\":{0}}}}}}}"; return(string.Format(format, "true")); }
private void btnSendGoods_Click(object sender, EventArgs e) { OrderInfo orderInfo = OrderHelper.GetOrderInfo(this.orderId); int num = this.radio_sendGoodType.SelectedValue.ToInt(0); string text = this.txtDeliveryNo.Value.ToNullString(); if (orderInfo != null) { if (orderInfo.OrderStatus == OrderStatus.WaitBuyerPay && OrderHelper.NeedUpdateStockWhenSendGoods(orderInfo) && !OrderHelper.CheckStock(orderInfo)) { this.ShowMsg("订单有商品库存不足,请补充库存后发货!", false); } else if (orderInfo.GroupBuyId > 0 && orderInfo.GroupBuyStatus != GroupBuyStatus.Success) { this.ShowMsg("当前订单为团购订单,团购活动还未成功结束,所以不能发货", false); } else if (!orderInfo.CheckAction(OrderActions.SELLER_SEND_GOODS)) { this.ShowMsg("当前订单状态没有付款或不是等待发货的订单,所以不能发货", false); } else if (num == 2 && text == "") { this.ShowMsg("使用同城物流发货需要正确的物流编号", false); } else { ExpressCompanyInfo expressCompanyInfo = null; if (num == 1 && !string.IsNullOrEmpty(this.expressRadioButtonList.SelectedValue)) { expressCompanyInfo = ExpressHelper.FindNode(this.expressRadioButtonList.SelectedValue); if (expressCompanyInfo != null) { orderInfo.ExpressCompanyAbb = expressCompanyInfo.Kuaidi100Code; orderInfo.ExpressCompanyName = expressCompanyInfo.Name; } orderInfo.ShipOrderNumber = this.txtShipOrderNumber.Text; if (!string.IsNullOrEmpty(orderInfo.OuterOrderId) && !string.IsNullOrEmpty(orderInfo.ShipOrderNumber) && orderInfo.OuterOrderId.StartsWith("jd_") && string.IsNullOrWhiteSpace(expressCompanyInfo.JDCode)) { this.ShowMsg("此订单是京东订单,所选物流公司不被京东支持", false); return; } } else if (num == 2) { orderInfo.ExpressCompanyName = "同城物流配送"; orderInfo.ExpressCompanyAbb = ""; orderInfo.ShipOrderNumber = ""; orderInfo.DadaStatus = DadaStatus.WaitOrder; if (orderInfo.ExpressCompanyName == "同城物流配送" && !string.IsNullOrEmpty(text)) { SiteSettings masterSettings = SettingsManager.GetMasterSettings(); DadaHelper.addAfterQuery(masterSettings.DadaSourceID, text); } } if (OrderHelper.SendGoods(orderInfo)) { if (!string.IsNullOrEmpty(orderInfo.ExpressCompanyAbb) && orderInfo.ExpressCompanyAbb.ToUpper() == "HTKY") { ExpressHelper.GetDataByKuaidi100(orderInfo.ExpressCompanyAbb, orderInfo.ShipOrderNumber); } if (orderInfo.Gateway.ToNullString().ToLower() == "hishop.plugins.payment.podrequest") { ProductStatisticsHelper.UpdateOrderSaleStatistics(orderInfo); TransactionAnalysisHelper.AnalysisOrderTranData(orderInfo); } string text2 = ""; if (orderInfo.Gateway == "hishop.plugins.payment.weixinrequest") { SiteSettings masterSettings2 = SettingsManager.GetMasterSettings(); PayClient payClient = new PayClient(masterSettings2.WeixinAppId, masterSettings2.WeixinAppSecret, masterSettings2.WeixinPartnerID, masterSettings2.WeixinPartnerKey, masterSettings2.WeixinPaySignKey, "", "", ""); DeliverInfo deliverInfo = new DeliverInfo(); deliverInfo.TransId = orderInfo.GatewayOrderId; deliverInfo.OutTradeNo = orderInfo.OrderId; MemberOpenIdInfo memberOpenIdInfo = Users.GetUser(orderInfo.UserId).MemberOpenIds.FirstOrDefault((MemberOpenIdInfo item) => item.OpenIdType.ToLower() == "hishop.plugins.openid.weixin"); if (memberOpenIdInfo != null) { deliverInfo.OpenId = memberOpenIdInfo.OpenId; } payClient.DeliverNotify(deliverInfo); } else { if (!string.IsNullOrEmpty(orderInfo.GatewayOrderId) && orderInfo.GatewayOrderId.Trim().Length > 0) { try { PaymentModeInfo paymentMode = SalesHelper.GetPaymentMode(orderInfo.Gateway); if (paymentMode != null && !string.IsNullOrEmpty(paymentMode.Settings)) { string hIGW = paymentMode.Gateway.Replace(".", "_"); PaymentRequest paymentRequest = PaymentRequest.CreateInstance(paymentMode.Gateway, HiCryptographer.Decrypt(paymentMode.Settings), orderInfo.OrderId, orderInfo.GetTotal(false), "订单发货", "订单号-" + orderInfo.OrderId, orderInfo.EmailAddress, orderInfo.OrderDate, Globals.FullPath(""), Globals.FullPath(base.GetRouteUrl("PaymentReturn_url", new { HIGW = hIGW })), Globals.FullPath(base.GetRouteUrl("PaymentNotify_url", new { HIGW = hIGW })), ""); paymentRequest.SendGoods(orderInfo.GatewayOrderId, orderInfo.RealModeName, orderInfo.ShipOrderNumber, "EXPRESS"); } } catch (Exception) { } } if (!string.IsNullOrEmpty(orderInfo.OuterOrderId)) { if (orderInfo.OuterOrderId.StartsWith("tb_")) { string text3 = orderInfo.OuterOrderId.Replace("tb_", ""); try { if (expressCompanyInfo != null) { string requestUriString = $"http://order2.kuaidiangtong.com/UpdateShipping.ashx?tid={text3}&companycode={expressCompanyInfo.TaobaoCode}&outsid={orderInfo.ShipOrderNumber}&Host={HiContext.Current.SiteUrl}"; WebRequest webRequest = WebRequest.Create(requestUriString); webRequest.GetResponse(); } } catch { } } else if (orderInfo.OuterOrderId.StartsWith("jd_") && expressCompanyInfo != null) { string text3 = orderInfo.OuterOrderId.Replace("jd_", ""); try { SiteSettings masterSettings3 = SettingsManager.GetMasterSettings(); JDHelper.JDOrderOutStorage(masterSettings3.JDAppKey, masterSettings3.JDAppSecret, masterSettings3.JDAccessToken, expressCompanyInfo.JDCode, orderInfo.ShipOrderNumber, text3); } catch (Exception ex2) { text2 = $"同步京东发货失败,京东订单号:{text3},{ex2.Message}\r\n"; } } } } MemberInfo user = Users.GetUser(orderInfo.UserId); Messenger.OrderShipping(orderInfo, user); orderInfo.OnDeliver(); if (string.IsNullOrWhiteSpace(text2)) { this.ShowMsg("发货成功", true); StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < base.Request.QueryString.Count && base.Request.QueryString.Keys[i] != null; i++) { string text4 = base.Request.QueryString.Keys[i].ToLower(); string text5 = base.Request.QueryString[text4]; if (!(text4 == "orderid") && !string.IsNullOrEmpty(text5)) { text4 = ((text4 == "searchorderid") ? "orderid" : text4); stringBuilder.Append("&" + text4 + "=" + text5); } } if (string.IsNullOrWhiteSpace(base.JsCallBack)) { base.CloseWindowGo("../sales/manageorder.aspx?1=1" + stringBuilder.ToString()); } else { base.CloseWindow(null); } } else { this.ShowMsg($"发货成功\r\n{text2}", true); } } else { this.ShowMsg("发货失败,可能是商品库存不足,订单中有商品正在退货、换货状态", false); } } } }