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); } } }
public void ExportToExcle(object sender, EventArgs e) { string text = "ProductReport.xls"; int num = this.hidLastConsumeTime.Value.ToInt(0); if (!Enum.IsDefined(typeof(EnumConsumeTime), num)) { num = 1; } DateTime dateTime = default(DateTime); DateTime dateTime2; if (!DateTime.TryParse(this.hidStartDate.Value, out dateTime)) { dateTime2 = DateTime.Now; dateTime = dateTime2.AddDays(-1.0); } DateTime dateTime3 = default(DateTime); if (!DateTime.TryParse(this.hidEndDate.Value, out dateTime3)) { dateTime2 = DateTime.Now; dateTime3 = dateTime2.AddDays(-1.0); } EnumConsumeTime lastConsumeTime; switch (num) { case 8: if (dateTime3 < dateTime) { this.ShowMsg("错误的时间范围", false); return; } lastConsumeTime = EnumConsumeTime.custom; text = "ProductReport" + dateTime.ToString("yyyyMMdd") + "-" + dateTime3.ToString("yyyyMMdd") + ".xls"; break; case 4: { dateTime2 = DateTime.Now; dateTime2 = dateTime2.Date; dateTime3 = dateTime2.AddDays(-1.0); dateTime = dateTime3.AddDays(-30.0); lastConsumeTime = EnumConsumeTime.inOneMonth; string[] obj2 = new string[5] { "ProductReport", dateTime.ToString("yyyyMMdd"), "-", null, null }; dateTime2 = dateTime3.AddDays(-1.0); obj2[3] = dateTime2.ToString("yyyyMMdd"); obj2[4] = ".xls"; text = string.Concat(obj2); break; } case 2: { dateTime2 = DateTime.Now; dateTime2 = dateTime2.Date; dateTime3 = dateTime2.AddDays(-1.0); dateTime = dateTime3.AddDays(-7.0); lastConsumeTime = EnumConsumeTime.inOneWeek; string[] obj = new string[5] { "ProductReport", dateTime.ToString("yyyyMMdd"), "-", null, null }; dateTime2 = dateTime3.AddDays(-1.0); obj[3] = dateTime2.ToString("yyyyMMdd"); obj[4] = ".xls"; text = string.Concat(obj); break; } default: dateTime2 = DateTime.Now; dateTime2 = dateTime2.Date; dateTime3 = dateTime2.AddDays(-1.0); dateTime2 = DateTime.Now; dateTime2 = dateTime2.Date; dateTime3 = dateTime2.AddDays(-1.0); lastConsumeTime = EnumConsumeTime.yesterday; text = "ProductReport" + dateTime.ToString("yyyyMMdd") + ".xls"; break; } ProductStatisticsQuery productStatisticsQuery = new ProductStatisticsQuery(); productStatisticsQuery.CustomConsumeEndTime = dateTime3; productStatisticsQuery.CustomConsumeStartTime = dateTime; productStatisticsQuery.LastConsumeTime = lastConsumeTime; string a = this.hidOrderby.Value.ToNullString().ToLower(); string text2 = this.hidOrderAction.Value.ToNullString().ToLower(); if (text2 != "pv" && text2 != "uv" && text2 != "paymentnum" && text2 != "salequantity" && text2 != "saleamount" && text2 != "productconversionrate") { text2 = "pv"; } productStatisticsQuery.SortBy = text2; productStatisticsQuery.SortOrder = SortAction.Desc; if (a == "asc") { productStatisticsQuery.SortOrder = SortAction.Asc; } IList <ProductStatisticsInfo> productStatisticsDataNoPage = ProductStatisticsHelper.GetProductStatisticsDataNoPage(productStatisticsQuery); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("<table cellspacing=\"0\" cellpadding=\"5\" rules=\"all\" border=\"1\">"); 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("<td>单品转化率</td>"); stringBuilder.AppendLine("<td>销售数量</td>"); stringBuilder.AppendLine("<td>销售金额</td>"); stringBuilder.AppendLine("</tr>"); foreach (ProductStatisticsInfo item in productStatisticsDataNoPage) { stringBuilder.AppendLine("<tr>"); stringBuilder.AppendLine("<td>" + item.ProductName + "</td>"); stringBuilder.AppendLine("<td style=\"vnd.ms-excel.numberformat:@\">" + item.PV + "</td>"); stringBuilder.AppendLine("<td style=\"vnd.ms-excel.numberformat:@\">" + item.UV + "</td>"); stringBuilder.AppendLine("<td style=\"vnd.ms-excel.numberformat:@\">" + item.PaymentNum + "</td>"); stringBuilder.AppendLine("<td style=\"vnd.ms-excel.numberformat:@\">" + item.ProductConversionRate.F2ToString("f2") + "%</td>"); stringBuilder.AppendLine("<td style=\"vnd.ms-excel.numberformat:@\">" + item.SaleQuantity + "</td>"); stringBuilder.AppendLine("<td style=\"vnd.ms-excel.numberformat:@\">" + item.SaleAmount.F2ToString("f2") + "</td>"); stringBuilder.AppendLine("</tr>"); } stringBuilder.AppendLine("</table>"); this.Page.Response.Clear(); this.Page.Response.Buffer = false; this.Page.Response.Charset = "UTF-8"; this.Page.Response.AppendHeader("Content-Disposition", ("attachment;filename=" + text) ?? ""); this.Page.Response.ContentEncoding = Encoding.GetEncoding("UTF-8"); this.Page.Response.ContentType = "application/ms-excel"; this.Page.EnableViewState = false; this.Page.Response.Write(stringBuilder.ToString()); this.Page.Response.End(); }
private void btnupdatepost_Click(object sender, EventArgs e) { string value = this.txt_expressCompanyName.Value; this.order.ShipOrderNumber = this.txtpost.Text.Trim(); this.order.ExpressCompanyName = value; string arg = ""; ExpressCompanyInfo expressCompanyInfo = null; if (!"".Equals(value)) { expressCompanyInfo = ExpressHelper.FindNode(value); if (expressCompanyInfo != null) { this.order.ExpressCompanyAbb = expressCompanyInfo.Kuaidi100Code; this.order.ExpressCompanyName = expressCompanyInfo.Name; } if (!string.IsNullOrEmpty(this.order.OuterOrderId) && !string.IsNullOrEmpty(this.order.ShipOrderNumber) && this.order.OuterOrderId.StartsWith("jd_") && string.IsNullOrWhiteSpace(expressCompanyInfo.JDCode)) { this.ShowMsg("此订单是京东订单,所选物流公司不被京东支持", false); return; } if (this.order.ExpressCompanyAbb != null && this.order.ExpressCompanyAbb.ToUpper() == "HTKY") { ExpressHelper.GetDataByKuaidi100(this.order.ExpressCompanyAbb, this.order.ShipOrderNumber); } if (this.order.Gateway != null && this.order.Gateway.ToLower() == "hishop.plugins.payment.podrequest") { ProductStatisticsHelper.UpdateOrderSaleStatistics(this.order); TransactionAnalysisHelper.AnalysisOrderTranData(this.order); } if (!string.IsNullOrEmpty(this.order.OuterOrderId)) { if (this.order.OuterOrderId.StartsWith("tb_")) { string text = this.order.OuterOrderId.Replace("tb_", ""); try { if (expressCompanyInfo != null) { string requestUriString = $"http://order2.kuaidiangtong.com/UpdateShipping.ashx?tid={text}&companycode={expressCompanyInfo.TaobaoCode}&outsid={this.order.ShipOrderNumber}&Host={HiContext.Current.SiteUrl}"; WebRequest webRequest = WebRequest.Create(requestUriString); webRequest.GetResponse(); } } catch { } } else if (this.order.OuterOrderId.StartsWith("jd_")) { string text = this.order.OuterOrderId.Replace("jd_", ""); try { SiteSettings masterSettings = SettingsManager.GetMasterSettings(); JDHelper.JDOrderOutStorage(masterSettings.JDAppKey, masterSettings.JDAppSecret, masterSettings.JDAccessToken, expressCompanyInfo.JDCode, this.order.ShipOrderNumber, text); } catch (Exception ex) { arg = $"\r\n同步京东发货失败,京东订单号:{text},{ex.Message}\r\n"; } } } } string expresssCompanyAbb = string.IsNullOrEmpty(this.order.ExpressCompanyAbb) ? "" : this.order.ExpressCompanyAbb; OrderHelper.SetOrderShipNumber(this.order.OrderId, expresssCompanyAbb, this.order.ExpressCompanyName, this.order.ShipOrderNumber); this.ShowMsg($"修改发货单号成功{arg}", true); this.LoadControl(); }
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); } } } }
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)) { if (expressCompanyInfo != null && !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 (!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.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 (!string.IsNullOrEmpty(orderInfo.OuterOrderId)) { if (orderInfo.OuterOrderId.StartsWith("tb_")) { string text = orderInfo.OuterOrderId.Replace("tb_", ""); try { if (expressCompanyInfo != null) { 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, 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); } } } }