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 info2 = ExpressHelper.FindNode(company_name); if (info2 == null) { return(OpenApiErrorMessage.ShowErrorMsg(OpenApiErrorCode.Company_not_Exists, "company_name")); } orderInfo.ExpressCompanyAbb = info2.Kuaidi100Code; orderInfo.ExpressCompanyName = info2.Name; orderInfo.ShipOrderNumber = out_sid; if (!OrderHelper.SendGoods(orderInfo)) { return(OpenApiErrorMessage.ShowErrorMsg(OpenApiErrorCode.Trade_Status_Send, "send good")); } Express.SubscribeExpress100(orderInfo.ExpressCompanyAbb, out_sid); SendNoteInfo note = new SendNoteInfo { NoteId = Globals.GetGenerateId(), OrderId = orderInfo.OrderId, Operator = orderInfo.UserId.ToString(), Remark = "接口发货成功" }; OrderHelper.SaveSendNote(note); 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.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 })), "").SendGoods(orderInfo.GatewayOrderId, orderInfo.RealModeName, orderInfo.ShipOrderNumber, "EXPRESS"); } } if (orderInfo.Gateway == "hishop.plugins.payment.weixinrequest") { PayClient client; SiteSettings masterSettings = SettingsManager.GetMasterSettings(false); if (masterSettings.EnableSP) { client = new PayClient(masterSettings.Main_AppId, masterSettings.WeixinAppSecret, masterSettings.Main_Mch_ID, masterSettings.Main_PayKey, true, masterSettings.WeixinAppId, masterSettings.WeixinPartnerID); } else { client = new PayClient(masterSettings.WeixinAppId, masterSettings.WeixinAppSecret, masterSettings.WeixinPartnerID, masterSettings.WeixinPartnerKey, false, "", ""); } DeliverInfo deliver = new DeliverInfo { TransId = orderInfo.GatewayOrderId, OutTradeNo = orderInfo.OrderId, OpenId = MemberHelper.GetMember(orderInfo.UserId).OpenId }; client.DeliverNotify(deliver); } } 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); } } } }
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); } } } }
protected void Page_Load(object sender, System.EventArgs e) { string text = base.Request.QueryString.Get("orderId"); if (string.IsNullOrEmpty(text)) { return; } OrderInfo orderInfo = OrderHelper.GetOrderInfo(text); OrderHelper.SetOrderPayStatus(orderInfo.OrderId, 1); if (orderInfo == null) { return; } PackageInfo packageInfo = new PackageInfo(); packageInfo.Body = orderInfo.OrderId; packageInfo.NotifyUrl = string.Format("http://{0}/pay/wx_Pay.aspx", base.Request.Url.Host); packageInfo.OutTradeNo = orderInfo.OrderId; packageInfo.TotalFee = (int)(orderInfo.GetTotal() * 100m); if (packageInfo.TotalFee < 1m) { packageInfo.TotalFee = 1m; } string openId = ""; SiteSettings masterSettings = SettingsManager.GetMasterSettings(false); if (HiContext.Current.User != null) { openId = HiContext.Current.User.OpenId; } //openId = "oUBLTvixVJV6q0FtN7kpKW7f9Ur8"; if (string.IsNullOrEmpty(openId)) { string code = Request.QueryString["code"]; if (string.IsNullOrEmpty(code)) { string text2 = string.Format( "https://open.weixin.qq.com/connect/oauth2/authorize?appid={0}&redirect_uri={1}&response_type=code&scope=snsapi_base&state=123#wechat_redirect", masterSettings.WeixinAppId, Globals.UrlEncode(Request.Url.ToString())); this.Page.Response.Redirect(text2); } else { Ecdev.Weixin.MP.Domain.Token token = Ecdev.Weixin.MP.Api.TokenApi.GetToken(masterSettings.WeixinAppId, masterSettings.WeixinAppSecret, code, "authorization_code"); openId = token.openid; } } if (string.IsNullOrEmpty(openId)) { Response.Write("<script>alert('无法获取登录信息,建议退出并重新登录或注册新帐号。');location.href = '/Vshop/logout.aspx';</script>"); Response.End(); } packageInfo.OpenId = openId; PayClient payClient = new PayClient(masterSettings.WeixinAppId, masterSettings.WeixinAppSecret, masterSettings.WeixinPartnerID, masterSettings.WeixinPartnerKey, masterSettings.WeixinPaySignKey); PayRequestInfo req = null; int loop = 0; do { req = payClient.BuildPayRequest(packageInfo); if (!req.package.Equals("prepay_id=FAIL")) { break; } loop++; System.Threading.Thread.Sleep(500); } while (loop < 5); this.pay_json = this.ConvertPayJson(req); ErrorLog.Write("开始请求支付:" + this.pay_json); }
protected void Page_Load(object sender, System.EventArgs e) { string text = base.Request.QueryString.Get("orderId"); if (string.IsNullOrEmpty(text)) { return; } System.Collections.Generic.List <OrderInfo> orderMarkingOrderInfo = ShoppingProcessor.GetOrderMarkingOrderInfo(text, true); if (orderMarkingOrderInfo.Count == 0) { return; } decimal d = 0m; foreach (OrderInfo current in orderMarkingOrderInfo) { if (current.BargainDetialId > 0) { string text2 = BargainHelper.IsCanBuyByBarginDetailId(current.BargainDetialId); if (text2 != "1") { current.OrderStatus = OrderStatus.Closed; current.CloseReason = text2; OrderHelper.UpdateOrder(current); base.Response.Write("<script>alert('" + text2 + ",订单自动关闭!');location.href='/Vshop/MemberOrders.aspx'</script>"); base.Response.End(); return; } } else { foreach (LineItemInfo current2 in current.LineItems.Values) { if (!ProductHelper.GetProductHasSku(current2.SkuId, current2.Quantity)) { current.OrderStatus = OrderStatus.Closed; current.CloseReason = "库存不足"; OrderHelper.UpdateOrder(current); base.Response.Write("<script>alert('库存不足,订单自动关闭!');location.href='/Vshop/MemberOrders.aspx'</script>"); base.Response.End(); return; } } } //支付金额等于牛奶配送金额 d += current.GetMilkCashPayMoney(); //d += current.GetCashPayMoney(); } PackageInfo packageInfo = new PackageInfo(); packageInfo.Body = text; packageInfo.NotifyUrl = string.Format("http://{0}/pay/wx_Pay.aspx", base.Request.Url.Host); packageInfo.OutTradeNo = text; packageInfo.TotalFee = (int)(d * 100m); if (packageInfo.TotalFee < 1m) { packageInfo.TotalFee = 1m; } string openId = ""; MemberInfo currentMember = MemberProcessor.GetCurrentMember(); if (currentMember != null) { openId = currentMember.OpenId; } packageInfo.OpenId = openId; SiteSettings masterSettings = SettingsManager.GetMasterSettings(true); 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, "", ""); } if (payClient.checkSetParams(out this.CheckValue)) { if (!payClient.checkPackage(packageInfo, out this.CheckValue)) { return; } PayRequestInfo payRequestInfo = payClient.BuildPayRequest(packageInfo); this.pay_json = this.ConvertPayJson(payRequestInfo); if (!payRequestInfo.package.ToLower().StartsWith("prepay_id=wx")) { this.CheckValue = payRequestInfo.package; } System.Data.DataTable shareActivity = ShareActHelper.GetShareActivity(); int num = 0; decimal d2 = 0m; if (shareActivity.Rows.Count > 0) { for (int i = 0; i < shareActivity.Rows.Count; i++) { if (d != 0m && d >= decimal.Parse(shareActivity.Rows[shareActivity.Rows.Count - 1]["MeetValue"].ToString())) { num = int.Parse(shareActivity.Rows[shareActivity.Rows.Count - 1]["Id"].ToString()); d2 = decimal.Parse(shareActivity.Rows[shareActivity.Rows.Count - 1]["MeetValue"].ToString()); break; } if (d != 0m && d <= decimal.Parse(shareActivity.Rows[0]["MeetValue"].ToString())) { num = int.Parse(shareActivity.Rows[0]["Id"].ToString()); d2 = decimal.Parse(shareActivity.Rows[0]["MeetValue"].ToString()); break; } if (d != 0m && d >= decimal.Parse(shareActivity.Rows[i]["MeetValue"].ToString())) { num = int.Parse(shareActivity.Rows[i]["Id"].ToString()); d2 = decimal.Parse(shareActivity.Rows[i]["MeetValue"].ToString()); } } if (d >= d2) { this.shareid = num; } } return; } }
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 btnSubmit_Click(object sender, System.EventArgs e) { SiteSettings masterSettings = SettingsManager.GetMasterSettings(false); for (int i = 0; i < this.Orders.Rows.Count; i++) { OrderInfo orderInfo = OrderHelper.GetOrderInfo(this.Orders.Rows[i]["OrderId"].ToString()); if (orderInfo != null) { ManagerInfo currentManager = ManagerHelper.GetCurrentManager();//获取目前的管理员信息 if (orderInfo.GroupBuyId > 0 && orderInfo.GroupBuyStatus != GroupBuyStatus.Success) { this.ShowMsg("当前订单为团购订单,团购活动还未成功结束,所以不能发货", false); } else { if (!orderInfo.CheckAction(OrderActions.SELLER_SEND_GOODS)) { this.ShowMsg("当前订单状态没有付款或不是等待发货的订单,所以不能发货", false); } else { orderInfo.RealShippingModeId = 1;//固定为1,为第一种快递方式(店家初始化时自己配置的第一种方式是什么这里就是什么) orderInfo.RealModeName = "快速收银"; orderInfo.ShipOrderNumber = ""; if (OrderHelper.SendGoods(orderInfo)) { SendNoteInfo info5 = new SendNoteInfo(); info5.NoteId = Globals.GetGenerateId(); info5.OrderId = orderInfo.OrderId; info5.Operator = currentManager.UserName; info5.Remark = "后台" + info5.Operator + "发货成功"; OrderHelper.SaveSendNote(info5); MemberInfo member = MemberHelper.GetMember(orderInfo.UserId); Messenger.OrderShipping(orderInfo, member); 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.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 })), "").SendGoods(orderInfo.GatewayOrderId, orderInfo.RealModeName, orderInfo.ShipOrderNumber, "EXPRESS"); } } if (orderInfo.Gateway == "hishop.plugins.payment.weixinrequest") { //SiteSettings masterSettings = SettingsManager.GetMasterSettings(false); PayClient client = new PayClient(masterSettings.WeixinAppId, masterSettings.WeixinAppSecret, masterSettings.WeixinPartnerID, masterSettings.WeixinPartnerKey, masterSettings.WeixinPaySignKey); DeliverInfo deliver = new DeliverInfo { TransId = orderInfo.GatewayOrderId, OutTradeNo = orderInfo.OrderId, OpenId = MemberHelper.GetMember(orderInfo.UserId).OpenId }; client.DeliverNotify(deliver); } } orderInfo.OnDeliver(); //this.ShowMsg("发货成功", true); //发送成功后,确认收货 bool flag = false; orderInfo = ShoppingProcessor.GetOrderInfo(this.Orders.Rows[i]["OrderId"].ToString()); Dictionary <string, LineItemInfo> lineItems = orderInfo.LineItems; LineItemInfo lineItemInfo = new LineItemInfo(); foreach (KeyValuePair <string, LineItemInfo> lineItem in lineItems) { lineItemInfo = lineItem.Value; if (lineItemInfo.OrderItemsStatus != OrderStatus.ApplyForRefund && lineItemInfo.OrderItemsStatus != OrderStatus.ApplyForReturns) { continue; } flag = true; } if (flag) { Response.Write("<script>alert('订单中商品有退货(款)不允许完成');</script>"); return; } if (orderInfo == null || !MemberProcessor.ConfirmOrderFinish(orderInfo)) { Response.Write("<script>alert('订单当前状态不允许完成');</script>"); return; } DistributorsBrower.UpdateCalculationCommission(orderInfo);//增加佣金记录、更新分销商的有效推广佣金和订单总额 MemberInfo currentMember = MemberProcessor.GetMember(orderInfo.UserId); int num = 0; if (masterSettings.IsRequestDistributor && !string.IsNullOrEmpty(masterSettings.FinishedOrderMoney.ToString()) && currentMember.Expenditure >= masterSettings.FinishedOrderMoney) { num = 1; } foreach (LineItemInfo value in orderInfo.LineItems.Values) { if (value.OrderItemsStatus.ToString() != OrderStatus.SellerAlreadySent.ToString()) { continue; } ShoppingProcessor.UpdateOrderGoodStatu(orderInfo.OrderId, value.SkuId, 5); } DistributorsInfo distributorsInfo = new DistributorsInfo(); distributorsInfo = DistributorsBrower.GetUserIdDistributors(orderInfo.UserId); if (distributorsInfo != null && distributorsInfo.UserId > 0) { num = 0; } this.Orders.Clear(); dlstOrders.DataSource = this.Orders; dlstOrders.DataBind(); this.ShowMsg("收银成功", true); } else { this.ShowMsg("发货失败", false); } } } } } }
/// <summary> /// 订单退款 /// </summary> /// <param name="order"></param> /// <returns></returns> protected string OrderRefund(DataRow order) { try { ErrorLog.Write("进入退款中:" + order["PaymentType"].ToString()); #region 微信退款 if (order["PaymentType"].ToString().IndexOf("微信") >= 0)//微信退款 { ErrorLog.Write("【微信退款】开始:" + order["OrderId"].ToString()); PackageInfo packageInfo = new PackageInfo(); SiteSettings masterSettings = SettingsManager.GetMasterSettings(false); PayClient payClient = new PayClient(masterSettings.WeixinAppId, masterSettings.WeixinAppSecret, masterSettings.WeixinPartnerID, masterSettings.WeixinPartnerKey, masterSettings.WeixinPaySignKey); packageInfo.OutTradeNo = order["OrderId"].ToString(); packageInfo.OutRefundNo = order["OrderId"].ToString();//退款ID默认为订单号 decimal totle = 0; decimal.TryParse(order["OrderTotal"].ToString(), out totle); packageInfo.RefundFee = (decimal)Math.Round(totle, 2) * 100; packageInfo.TotalFee = (decimal)Math.Round(totle, 2) * 100; ErrorLog.Write("【微信退款】退款参数:" + Newtonsoft.Json.JsonConvert.SerializeObject(packageInfo)); string ret = string.Empty; int type = 1; if (order["SourceOrder"].ToString() == "11" || order["SourceOrder"].ToString() == "12") { type = 2; } ret = Refund.Run(order["GatewayOrderId"].ToString(), order["OrderId"].ToString(), packageInfo.TotalFee.ToString(), packageInfo.RefundFee.ToString(), type); //ret = payClient.RequestRefund(packageInfo); ErrorLog.Write("【微信退款】" + order["OrderId"].ToString() + "退款结果:" + ret); if (string.IsNullOrEmpty(ret) || ret.ToUpper().IndexOf("SUCCESS") >= 0) //退款成功 { Action ac = new Action(() => { TradeHelper.RefundOrder(order["OrderId"].ToString());//恢复库存及现金卷 TradeHelper.RefundOrder_Split(order["OrderId"].ToString(), order["SourceOrderId"].ToString()); TradeHelper.RefundSuccess(order["OrderId"].ToString(), 1); }); ac.BeginInvoke(null, ac); return("退款成功!"); } return("微信退款失败,请重试或联系客服退款!"); } #endregion #region 支付宝退款 if (order["PaymentType"].ToString().IndexOf("支付宝") >= 0)//支付宝退款 { //退款批次号 string batch_no = order["OrderId"].ToString(); //必填,每进行一次即时到账批量退款,都需要提供一个批次号,必须保证唯一性 //退款请求时间 string refund_date = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"); //必填,格式为:yyyy-MM-dd hh:mm:ss //退款总笔数 string batch_num = "1"; //必填,即参数detail_data的值中,“#”字符出现的数量加1,最大支持1000笔(即“#”字符出现的最大数量999个) //单笔数据集 decimal totle = 0; decimal.TryParse(order["OrderTotal"].ToString(), out totle); string detail_data = order["GatewayOrderId"] + "^" + totle + "^协商退款"; //必填,格式详见“4.3 单笔数据集参数说明” //////////////////////////////////////////////////////////////////////////////////////////////// Config.Key = "vec1v8gshy4mo8lz735boyupyuhotjct"; //把请求参数打包成数组 SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>(); sParaTemp.Add("partner", "2088121134306407"); sParaTemp.Add("_input_charset", "utf-8"); sParaTemp.Add("service", "refund_fastpay_by_platform_nopwd"); sParaTemp.Add("batch_no", batch_no); sParaTemp.Add("refund_date", refund_date); sParaTemp.Add("batch_num", batch_num); sParaTemp.Add("detail_data", detail_data); ErrorLog.Write("【支付宝退款】退款参数:" + Newtonsoft.Json.JsonConvert.SerializeObject(sParaTemp)); //建立请求 string sHtmlText = Submit.BuildRequest(sParaTemp); ErrorLog.Write("【支付宝退款】" + order["OrderId"].ToString() + ";海美生活订单退款:" + sHtmlText); XmlDocument xmlDoc = new XmlDocument(); try { xmlDoc.LoadXml(sHtmlText); string strXmlResponse = xmlDoc.SelectSingleNode("/alipay/is_success").InnerText; if (strXmlResponse.ToLower() == "t")//退款成功 { Action ac = new Action(() => { //if (string.IsNullOrEmpty(order.SourceOrderId.ToString()))//非拆单 //{ TradeHelper.RefundOrder(order["OrderId"].ToString().ToString());//恢复库存及现金卷 //} //else //{ TradeHelper.RefundOrder_Split(order["OrderId"].ToString(), order["SourceOrderId"].ToString()); //} TradeHelper.RefundSuccess(order["OrderId"].ToString(), 1); }); ac.BeginInvoke(null, ac); //Action ac = new Action(() => //{ // if (string.IsNullOrEmpty(order["SourceOrderId"].ToString()))//非拆单 // { // TradeHelper.RefundOrder(order["OrderId"].ToString());//恢复库存及现金卷 // } // else // { // TradeHelper.RefundOrder_Split(order["OrderId"].ToString(), order["SourceOrderId"].ToString()); // } // TradeHelper.RefundSuccess(order["OrderId"].ToString(), 1); //}); //ac.BeginInvoke(null, ac); return("Ok"); } } catch (Exception exp) { ErrorLog.Write("【支付宝退款】" + exp.Message, exp); } } #endregion ErrorLog.Write("【支付宝退款】" + order["OrderId"].ToString() + "退款异常,请重试或联系客服退款!"); return("退款异常,请重试或联系客服退款!"); } catch (Exception ee) { ErrorLog.Write("【退款异常】" + Newtonsoft.Json.JsonConvert.SerializeObject(order), ee); return("退款执行异常"); } }
private void btnSendGoods_Click(object sender, EventArgs e) { if (this.grdOrderGoods.Rows.Count <= 0) { this.ShowMsg("没有要进行发货的订单。", false); } else { DropdownColumn column = (DropdownColumn)this.grdOrderGoods.Columns[4]; ListItemCollection selectedItems = column.SelectedItems; DropdownColumn column2 = (DropdownColumn)this.grdOrderGoods.Columns[5]; ListItemCollection items2 = column2.SelectedItems; int num = 0; for (int i = 0; i < selectedItems.Count; i++) { string orderId = (string)this.grdOrderGoods.DataKeys[this.grdOrderGoods.Rows[i].RowIndex].Value; TextBox box = (TextBox)this.grdOrderGoods.Rows[i].FindControl("txtShippOrderNumber"); ListItem item = selectedItems[i]; ListItem item2 = items2[i]; int result = 0; int.TryParse(item.Value, out result); if ((!string.IsNullOrEmpty(box.Text.Trim()) && !string.IsNullOrEmpty(item.Value)) && ((int.Parse(item.Value) > 0) && !string.IsNullOrEmpty(item2.Value))) { OrderInfo orderInfo = OrderHelper.GetOrderInfo(orderId); if ((((orderInfo.GroupBuyId <= 0) || (orderInfo.GroupBuyStatus == GroupBuyStatus.Success)) && (((orderInfo.OrderStatus == OrderStatus.WaitBuyerPay) && (orderInfo.Gateway == "hishop.plugins.payment.podrequest")) || (orderInfo.OrderStatus == OrderStatus.BuyerAlreadyPaid))) && (((result > 0) && !string.IsNullOrEmpty(box.Text.Trim())) && (box.Text.Trim().Length <= 20))) { ShippingModeInfo shippingMode = SalesHelper.GetShippingMode(result, true); orderInfo.RealShippingModeId = shippingMode.ModeId; orderInfo.RealModeName = shippingMode.Name; orderInfo.ExpressCompanyAbb = item2.Value; orderInfo.ExpressCompanyName = item2.Text; orderInfo.ShipOrderNumber = box.Text; if (OrderHelper.SendGoods(orderInfo)) { SendNoteInfo info3 = new SendNoteInfo(); info3.NoteId = Globals.GetGenerateId() + num; info3.OrderId = orderId; info3.Operator = ManagerHelper.GetCurrentManager().UserName; info3.Remark = "后台" + info3.Operator + "发货成功"; OrderHelper.SaveSendNote(info3); 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.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 })), "").SendGoods(orderInfo.GatewayOrderId, orderInfo.RealModeName, orderInfo.ShipOrderNumber, "EXPRESS"); } } if (orderInfo.Gateway == "hishop.plugins.payment.weixinrequest") { SiteSettings masterSettings = SettingsManager.GetMasterSettings(false); PayClient client = new PayClient(masterSettings.WeixinAppId, masterSettings.WeixinAppSecret, masterSettings.WeixinPartnerID, masterSettings.WeixinPartnerKey, masterSettings.WeixinPaySignKey); DeliverInfo deliver = new DeliverInfo { TransId = orderInfo.GatewayOrderId, OutTradeNo = orderInfo.OrderId, OpenId = MemberHelper.GetMember(orderInfo.UserId).OpenId }; client.DeliverNotify(deliver); } } orderInfo.OnDeliver(); num++; } } } } if (num == 0) { this.ShowMsg("批量发货失败!", false); } else if (num > 0) { this.BindData(); this.ShowMsg(string.Format("批量发货成功!发货数量{0}个", num), true); } } }
protected void Page_Load(object sender, EventArgs e) { string str = base.Request.QueryString.Get("orderId"); if (!string.IsNullOrEmpty(str)) { List <OrderInfo> orderMarkingOrderInfo = ShoppingProcessor.GetOrderMarkingOrderInfo(str); if (orderMarkingOrderInfo.Count != 0) { decimal num = 0M; foreach (OrderInfo info in orderMarkingOrderInfo) { num += info.GetTotal(); } PackageInfo package = new PackageInfo { Body = str, NotifyUrl = string.Format("http://{0}/pay/wx_Pay.aspx", base.Request.Url.Host), OutTradeNo = str, TotalFee = (int)(num * 100M) }; if (package.TotalFee < 1M) { package.TotalFee = 1M; } string openId = ""; MemberInfo currentMember = MemberProcessor.GetCurrentMember(); if (currentMember != null) { openId = currentMember.OpenId; } package.OpenId = openId; wid = currentMember.wid; //SiteSettings masterSettings = SettingsManager.GetMasterSettings(false); Chenduo.Model.sf_website website = new Chenduo.BLL.sf_website().GetModelByWid(wid); //PayRequestInfo req = new PayClient(masterSettings.WeixinAppId, masterSettings.WeixinAppSecret, masterSettings.WeixinPartnerID, masterSettings.WeixinPartnerKey, masterSettings.WeixinPaySignKey).BuildPayRequest(package); PayRequestInfo req = new PayClient(wid, website.appid, website.appsecret, website.weixin_pay_account, website.account_pay_key, "").BuildPayRequest(package); this.pay_json = this.ConvertPayJson(req); DataTable shareActivity = ShareActHelper.GetShareActivity(); int num2 = 0; decimal num3 = 0M; if (shareActivity.Rows.Count > 0) { for (int i = 0; i < shareActivity.Rows.Count; i++) { if ((num != 0M) && (num >= decimal.Parse(shareActivity.Rows[shareActivity.Rows.Count - 1]["MeetValue"].ToString()))) { num2 = int.Parse(shareActivity.Rows[shareActivity.Rows.Count - 1]["Id"].ToString()); num3 = decimal.Parse(shareActivity.Rows[shareActivity.Rows.Count - 1]["MeetValue"].ToString()); break; } if ((num != 0M) && (num <= decimal.Parse(shareActivity.Rows[0]["MeetValue"].ToString()))) { num2 = int.Parse(shareActivity.Rows[0]["Id"].ToString()); num3 = decimal.Parse(shareActivity.Rows[0]["MeetValue"].ToString()); break; } if ((num != 0M) && (num >= decimal.Parse(shareActivity.Rows[i]["MeetValue"].ToString()))) { num2 = int.Parse(shareActivity.Rows[i]["Id"].ToString()); num3 = decimal.Parse(shareActivity.Rows[i]["MeetValue"].ToString()); } } if (num >= num3) { this.shareid = num2; } } } } }
protected void Page_Load(object sender, EventArgs e) { OrderInfo orderInfo = null; decimal d = default(decimal); string text = base.Request.QueryString.Get("orderId"); int num = base.Request.QueryString.Get("isrecharge").ToInt(0); if (!string.IsNullOrEmpty(text)) { if (num == 1) { InpourRequestInfo inpourBlance = MemberProcessor.GetInpourBlance(text); if (inpourBlance != null) { d = inpourBlance.InpourBlance; goto IL_0134; } } else { orderInfo = OrderHelper.GetOrderInfo(text); if (orderInfo != null) { if (orderInfo.PreSaleId > 0) { if (!orderInfo.DepositDate.HasValue && orderInfo.OrderStatus == OrderStatus.WaitBuyerPay) { d = orderInfo.Deposit - orderInfo.BalanceAmount; } else if (orderInfo.DepositDate.HasValue && orderInfo.OrderStatus == OrderStatus.WaitBuyerPay) { d = orderInfo.FinalPayment; } } else { d = orderInfo.GetTotal(true); } this.isFightGroup = ((orderInfo.FightGroupId > 0) ? "true" : "false"); goto IL_0134; } } } return; IL_0134: SiteSettings siteSettings = HiContext.Current.SiteSettings; string appWxAppId = siteSettings.AppWxAppId; string appWxAppSecret = siteSettings.AppWxAppSecret; string appWxMchId = siteSettings.AppWxMchId; string appWxPartnerKey = siteSettings.AppWxPartnerKey; string appWX_Main_MchID = siteSettings.AppWX_Main_MchID; string appWX_Main_AppId = siteSettings.AppWX_Main_AppId; if (siteSettings.OpenAppWxPay && !string.IsNullOrEmpty(siteSettings.AppWxAppId) && !string.IsNullOrEmpty(siteSettings.AppWxMchId) && !string.IsNullOrEmpty(siteSettings.AppWxPartnerKey)) { try { PackageInfo packageInfo = new PackageInfo(); if (num == 1) { packageInfo.Attach = "1"; } else { packageInfo.Attach = ""; } packageInfo.Body = text; packageInfo.NotifyUrl = Globals.GetProtocal(HttpContext.Current) + "://" + $"{base.Request.Url.Host}/pay/app_wxPay"; if (num == 1) { packageInfo.OutTradeNo = text; } else if (orderInfo.PreSaleId > 0 && !orderInfo.DepositDate.HasValue && orderInfo.OrderStatus == OrderStatus.WaitBuyerPay) { packageInfo.OutTradeNo = text + new Random().Next(10000, 99999).ToString(); } else { packageInfo.OutTradeNo = text + orderInfo.PayRandCode; } packageInfo.TotalFee = (int)(d * 100m); if (packageInfo.TotalFee < decimal.One) { packageInfo.TotalFee = decimal.One; } string text3 = packageInfo.OpenId = ""; PayClient payClient = null; payClient = ((string.IsNullOrEmpty(appWX_Main_AppId) || string.IsNullOrEmpty(appWX_Main_MchID)) ? new PayClient(appWxAppId, appWxAppSecret, appWxMchId, appWxPartnerKey, "", "", "", "") : new PayClient(appWX_Main_AppId, appWxAppSecret, appWX_Main_MchID, appWxPartnerKey, "", appWxMchId, appWxAppId, "")); PayRequestInfo req = payClient.BuildAppPayRequest(packageInfo); this.pay_json = Globals.UrlEncode(this.ConvertPayJson(siteSettings.AppWxAppId, siteSettings.AppWxMchId, req)); } catch (Exception ex) { Globals.WriteExceptionLog(ex, null, "APPWxPay"); this.pay_json = "config_error"; } } else { this.pay_json = "config_error"; } }
protected void Page_Load(object sender, EventArgs e) { OrderInfo orderInfo = null; PackageInfo packageInfo = new PackageInfo(); SiteSettings masterSettings = SettingsManager.GetMasterSettings(); bool flag = this.Page.Request["IsOffline"].ToBool(); string a = this.Page.Request["from"].ToNullString().ToLower(); string text = this.Page.Request.QueryString.Get("orderId"); string empty = string.Empty; string empty2 = string.Empty; string userAgent = base.Request.UserAgent; if (userAgent.ToLower().IndexOf("micromessenger") > -1) { this.isWeiXin = true; } if (a == "appstore") { this.isOfflineOrder = "true"; if (string.IsNullOrEmpty(text)) { this.Page.Response.Write("<h2 style=\"color:red;width:100%; text-align:center;\">错误的订单号,不能进行支付!<h2>"); this.Page.Response.End(); } empty = text; decimal d = default(decimal); StoreCollectionInfo storeCollectionInfo = null; if (flag) { this.isOfflineOrder = "true"; storeCollectionInfo = StoresHelper.GetStoreCollectionInfo(text); if (storeCollectionInfo == null) { this.Page.Response.Write("<h2 style=\"color:red;width:100%; text-align:center;\">订单状态错误,不能进行支付!<h2>"); this.Page.Response.End(); } if (storeCollectionInfo.Status != 0) { this.Page.Response.Write("<h2 style=\"color:red;width:100%; text-align:center;\">订单状态错误,不能进行支付!<h2>"); this.Page.Response.End(); } d = storeCollectionInfo.PayAmount; } else { orderInfo = ShoppingProcessor.GetOrderInfo(text); if (orderInfo == null) { this.Page.Response.Write("<h2 style=\"color:red;width:100%; text-align:center;\">订单状态错误,不能进行支付!<h2>"); this.Page.Response.End(); } if (orderInfo.OrderStatus != OrderStatus.WaitBuyerPay) { this.Page.Response.Write("<h2 style=\"color:red;width:100%; text-align:center;\">订单状态错误,不能进行支付!<h2>"); this.Page.Response.End(); } this.IsServiceOrder = ((orderInfo.OrderType == OrderType.ServiceOrder) ? "true" : "false"); if (orderInfo.PreSaleId > 0) { if (!orderInfo.DepositDate.HasValue && orderInfo.OrderStatus == OrderStatus.WaitBuyerPay) { empty = orderInfo.OrderId; d = orderInfo.Deposit - orderInfo.BalanceAmount; } if (orderInfo.DepositDate.HasValue && orderInfo.OrderStatus == OrderStatus.WaitBuyerPay) { if (orderInfo.PayRandCode.ToInt(0) == 0) { int num = orderInfo.PayRandCode.ToInt(0); num = ((num >= 100) ? (num + 1) : 100); orderInfo.PayRandCode = num.ToString(); OrderHelper.UpdateOrderPaymentTypeOfAPI(orderInfo); } empty = orderInfo.PayOrderId; d = orderInfo.FinalPayment; } } else { empty = orderInfo.PayOrderId; d = orderInfo.GetTotal(true); } } packageInfo.Body = text; packageInfo.NotifyUrl = Globals.GetProtocal(HttpContext.Current) + "://" + $"{this.Page.Request.Url.Host}/pay/AppStore_wxPay"; packageInfo.OutTradeNo = empty; packageInfo.TotalFee = (int)(d * 100m); if (orderInfo != null) { packageInfo.OutTradeNo = orderInfo.PayOrderId; packageInfo.Attach = empty2; } else { packageInfo.OutTradeNo = empty; packageInfo.Attach = empty2; } if (packageInfo.TotalFee < decimal.One) { packageInfo.TotalFee = decimal.One; } } else { if (string.IsNullOrEmpty(text)) { this.Page.Response.Write("<h2 style=\"color:red;width:100%; text-align:center;\">订单状态错误,不能进行支付!<h2>"); this.Page.Response.End(); } orderInfo = OrderHelper.GetOrderInfo(text); if (orderInfo == null) { this.Page.Response.Write("<h2 style=\"color:red;width:100%; text-align:center;\">订单状态错误,不能进行支付!<h2>"); this.Page.Response.End(); } if (orderInfo.OrderStatus != OrderStatus.WaitBuyerPay) { this.Page.Response.Write("<h2 style=\"color:red;width:100%; text-align:center;\">订单状态错误,不能进行支付!<h2>"); this.Page.Response.End(); } this.IsServiceOrder = ((orderInfo.OrderType == OrderType.ServiceOrder) ? "true" : "false"); empty = text; this.isFightGroup = ((orderInfo.FightGroupId > 0) ? "true" : "false"); decimal d2 = default(decimal); if (orderInfo.PreSaleId > 0) { if (!orderInfo.DepositDate.HasValue && orderInfo.OrderStatus == OrderStatus.WaitBuyerPay) { empty = orderInfo.OrderId; d2 = ((orderInfo.Deposit - orderInfo.BalanceAmount > decimal.Zero) ? (orderInfo.Deposit - orderInfo.BalanceAmount) : decimal.Zero); } if (orderInfo.DepositDate.HasValue && orderInfo.OrderStatus == OrderStatus.WaitBuyerPay) { if (orderInfo.PayRandCode.ToInt(0) == 0) { int num2 = orderInfo.PayRandCode.ToInt(0); num2 = ((num2 >= 100) ? (num2 + 1) : 100); orderInfo.PayRandCode = num2.ToString(); OrderHelper.UpdateOrderPaymentTypeOfAPI(orderInfo); } empty = orderInfo.PayOrderId; d2 = ((orderInfo.FinalPayment > decimal.Zero) ? orderInfo.FinalPayment : decimal.Zero); } } else { empty = orderInfo.OrderId; d2 = orderInfo.GetTotal(true); } packageInfo.Body = orderInfo.OrderId + orderInfo.PayRandCode; packageInfo.NotifyUrl = Globals.GetProtocal(HttpContext.Current) + "://" + $"{this.Page.Request.Url.Host}/pay/wx_Pay"; if (orderInfo.OrderType != OrderType.ServiceOrder && orderInfo.OrderSource == OrderSource.Applet) { packageInfo.NotifyUrl = Globals.GetProtocal(HttpContext.Current) + "://" + $"{this.Page.Request.Url.Host}/pay/O2OApplet_Pay"; } packageInfo.OutTradeNo = orderInfo.PayOrderId; packageInfo.Attach = empty2; packageInfo.TotalFee = (int)(d2 * 100m); if (packageInfo.TotalFee < decimal.One) { packageInfo.TotalFee = decimal.One; } } string text2 = masterSettings.WeixinAppId; string appSecret = masterSettings.WeixinAppSecret; string text3 = masterSettings.WeixinPartnerID; string text4 = masterSettings.WeixinPartnerKey; string text5 = masterSettings.Main_Mch_ID; string text6 = masterSettings.Main_AppId; if (a != "appstore") { if (orderInfo.OrderType == OrderType.ServiceOrder && orderInfo.OrderSource != OrderSource.WeiXin) { text2 = masterSettings.O2OAppletAppId; appSecret = masterSettings.O2OAppletAppSecrect; text3 = masterSettings.O2OAppletMchId; text4 = masterSettings.O2OAppletKey; text5 = ""; text6 = ""; } else if (orderInfo.OrderSource == OrderSource.Applet) { text2 = masterSettings.WxAppletAppId; appSecret = masterSettings.WxAppletAppSecrect; text3 = masterSettings.WxApplectMchId; text4 = masterSettings.WxApplectKey; text5 = ""; text6 = ""; } } string text7 = ""; MemberInfo user = HiContext.Current.User; if (user.UserId > 0 && a != "appstore") { MemberOpenIdInfo memberOpenIdInfo = null; if (orderInfo.OrderType == OrderType.ServiceOrder && orderInfo.OrderSource != OrderSource.WeiXin) { memberOpenIdInfo = user.MemberOpenIds.FirstOrDefault((MemberOpenIdInfo item) => item.OpenIdType.ToLower() == "hishop.plugins.openid.o2owxapplet"); if (memberOpenIdInfo != null) { text7 = memberOpenIdInfo.OpenId; } } else if (orderInfo.OrderSource == OrderSource.Applet) { memberOpenIdInfo = user.MemberOpenIds.FirstOrDefault((MemberOpenIdInfo item) => item.OpenIdType.ToLower() == "hishop.plugins.openid.wxapplet"); if (memberOpenIdInfo != null) { text7 = memberOpenIdInfo.OpenId; } } else { memberOpenIdInfo = user.MemberOpenIds.FirstOrDefault((MemberOpenIdInfo item) => item.OpenIdType.ToLower() == "hishop.plugins.openid.weixin"); if (memberOpenIdInfo != null && user.IsDefaultDevice) { text7 = memberOpenIdInfo.OpenId; } } } if (string.IsNullOrEmpty(text7)) { PayConfig payConfig = new PayConfig(); payConfig.AppId = text2; payConfig.Key = text4; payConfig.MchID = text3; payConfig.AppSecret = appSecret; JsApiPay jsApiPay = new JsApiPay(); try { NameValueCollection openidAndAccessToken = JsApiPay.GetOpenidAndAccessToken(this.Page, payConfig.AppId, payConfig.AppSecret, false); if (openidAndAccessToken.HasKeys()) { text7 = openidAndAccessToken["openId"]; } } catch (Exception ex) { if (!(ex is ThreadAbortException)) { IDictionary <string, string> dictionary = new Dictionary <string, string>(); dictionary.Add("AppId", payConfig.AppId); dictionary.Add("Key", payConfig.Key); dictionary.Add("MchID", payConfig.MchID); dictionary.Add("AppSecret", payConfig.AppSecret); dictionary.Add("Exception", ex.Message); dictionary.Add("StackTrace", ex.StackTrace); dictionary.Add("TargetSite", ex.TargetSite.ToString()); Globals.WriteLog(dictionary, "获取用户OpenId失败", "", "", "GetOpenId"); } } } if (!string.IsNullOrEmpty(text6) && !string.IsNullOrEmpty(text5)) { packageInfo.sub_openid = text7; } else { packageInfo.OpenId = text7; } PayClient payClient = null; payClient = ((string.IsNullOrEmpty(text6) || string.IsNullOrEmpty(text5)) ? new PayClient(text2, appSecret, text3, text4, "", "", "", "") : new PayClient(text6, appSecret, text5, text4, "", text3, text2, "")); PayRequestInfo req = payClient.BuildPayRequest(packageInfo); this.pay_json = this.ConvertPayJson(req); this.pay_uri = this.ConvertPayUri(req); if (!this.isWeiXin) { base.Response.Redirect(this.pay_uri); } }
private void btnSendGoods_Click(object sender, System.EventArgs e) { OrderInfo orderInfo = OrderHelper.GetOrderInfo(this.orderId); if (orderInfo != null) { ManagerInfo currentManager = ManagerHelper.GetCurrentManager(); if (currentManager != null) { if (orderInfo.GroupBuyId > 0 && orderInfo.GroupBuyStatus != GroupBuyStatus.Success) { this.ShowMsg("当前订单为团购订单,团购活动还未成功结束,所以不能发货", false); } else { if (!orderInfo.CheckAction(OrderActions.SELLER_SEND_GOODS)) { this.ShowMsg("当前订单状态没有付款或不是等待发货的订单,所以不能发货", false); } else { if (!this.radioShippingMode.SelectedValue.HasValue) { this.ShowMsg("请选择配送方式", false); } else { //if (CustomConfigHelper.Instance.BrandShow == false) //{ //if (string.IsNullOrEmpty(this.txtShipOrderNumber.Text.Trim()) || this.txtShipOrderNumber.Text.Trim().Length > 20) //{ // this.ShowMsg("运单号码不能为空,在1至20个字符之间", false); //} //} //else //{ if (string.IsNullOrEmpty(this.expressRadioButtonList.SelectedValue)) { this.ShowMsg("请选择物流公司", false); } else { ShippingModeInfo shippingMode = SalesHelper.GetShippingMode(this.radioShippingMode.SelectedValue.Value, true); orderInfo.RealShippingModeId = this.radioShippingMode.SelectedValue.Value; orderInfo.RealModeName = shippingMode.Name; ExpressCompanyInfo info4 = ExpressHelper.FindNode(this.expressRadioButtonList.SelectedValue); if (info4 != null) { orderInfo.ExpressCompanyAbb = info4.Kuaidi100Code; orderInfo.ExpressCompanyName = info4.Name; } orderInfo.ShipOrderNumber = this.txtShipOrderNumber.Text; if (OrderHelper.SendGoods(orderInfo)) { SendNoteInfo info5 = new SendNoteInfo(); info5.NoteId = Globals.GetGenerateId(); info5.OrderId = this.orderId; info5.Operator = currentManager.UserName; info5.Remark = "后台" + info5.Operator + "发货成功"; OrderHelper.SaveSendNote(info5); MemberInfo member = MemberHelper.GetMember(orderInfo.UserId); Messenger.OrderShipping(orderInfo, member); 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.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 })), "").SendGoods(orderInfo.GatewayOrderId, orderInfo.RealModeName, orderInfo.ShipOrderNumber, "EXPRESS"); } } if (orderInfo.Gateway == "hishop.plugins.payment.weixinrequest") { SiteSettings masterSettings = SettingsManager.GetMasterSettings(false); PayClient client = new PayClient(masterSettings.WeixinAppId, masterSettings.WeixinAppSecret, masterSettings.WeixinPartnerID, masterSettings.WeixinPartnerKey, masterSettings.WeixinPaySignKey); DeliverInfo deliver = new DeliverInfo { TransId = orderInfo.GatewayOrderId, OutTradeNo = orderInfo.OrderId, OpenId = MemberHelper.GetMember(orderInfo.UserId).OpenId }; client.DeliverNotify(deliver); } } orderInfo.OnDeliver(); if (CustomConfigHelper.Instance.IsSanzuo) //三作咖啡特殊需求:发货时,打印小票(配送票) { //this.ShowMsgAndReUrl("发货成功", true,"ManageOrders.aspx"); CloseWindowAndRedirect(); } else if (CustomConfigHelper.Instance.IsProLa) //pro辣特殊需求,发货时增加消息推送 { WriteLog("进入"); SiteSettings masterSettings = SettingsManager.GetMasterSettings(false); TemplateMessage templateMessage = new TemplateMessage(); templateMessage.Url = Request.Url.Host + "/vshop/MemberOrders.aspx?status=3"; //单击URL templateMessage.TemplateId = "pPCCurFLdpgnI0ZWpr5eFJQ5bxS7xboaEW2ScBoOY4U"; //Globals.GetMasterSettings(true).WX_Template_01;// "b1_ARggaBzbc5owqmwrZ15QPj9Ksfs0p5i64C6MzXKw";//消息模板ID templateMessage.Touser = member.OpenId; //用户OPENID string productsDes = ""; int c = 0; foreach (LineItemInfo info in orderInfo.LineItems.Values) { if (c > 3) { break; } productsDes += info.ItemDescription + ","; c++; } productsDes = productsDes.TrimEnd(',') + "等菜品"; TemplateMessage.MessagePart[] messateParts = new TemplateMessage.MessagePart[] { new TemplateMessage.MessagePart { Name = "first", Value = "亲,您的菜品已备好,配送在途!" }, new TemplateMessage.MessagePart { Name = "keyword1", Value = "订单" + orderInfo.OrderId + "开始配送" }, new TemplateMessage.MessagePart { Name = "keyword2", Value = productsDes }, new TemplateMessage.MessagePart { Name = "remark", Color = "#FF0000", Value = "预计到达时间:" + txtArriveTime.Text /*orderInfo.ShipToDate*/ } }; templateMessage.Data = messateParts; TemplateApi.SendMessage(TokenApi.GetToken_Message(masterSettings.WeixinAppId, masterSettings.WeixinAppSecret), templateMessage); this.ShowMsg("发货成功", true); } else { this.ShowMsg("发货成功", true); } } else { this.ShowMsg("发货失败", false); } } //} } } } } } }
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); } } } }
private void btnSendGoods_Click(object sender, EventArgs e) { OrderInfo orderInfo = OrderHelper.GetOrderInfo(this.orderId); if (orderInfo != null) { ManagerInfo currentManager = ManagerHelper.GetCurrentManager(); if (currentManager != null) { if ((orderInfo.GroupBuyId > 0) && (orderInfo.GroupBuyStatus != GroupBuyStatus.Success)) { this.ShowMsg("当前订单为团购订单,团购活动还未成功结束,所以不能发货", false); } else if (!orderInfo.CheckAction(OrderActions.SELLER_SEND_GOODS)) { this.ShowMsg("当前订单状态没有付款或不是等待发货的订单,所以不能发货", false); } else if (!this.radioShippingMode.SelectedValue.HasValue) { this.ShowMsg("请选择配送方式", false); } else if (string.IsNullOrEmpty(this.txtShipOrderNumber.Text.Trim()) || (this.txtShipOrderNumber.Text.Trim().Length > 20)) { this.ShowMsg("运单号码不能为空,在1至20个字符之间", false); } else if (string.IsNullOrEmpty(this.expressRadioButtonList.SelectedValue)) { this.ShowMsg("请选择物流公司", false); } else { ShippingModeInfo shippingMode = SalesHelper.GetShippingMode(this.radioShippingMode.SelectedValue.Value, true); orderInfo.RealShippingModeId = this.radioShippingMode.SelectedValue.Value; orderInfo.RealModeName = shippingMode.Name; ExpressCompanyInfo info4 = ExpressHelper.FindNode(this.expressRadioButtonList.SelectedValue); if (info4 != null) { orderInfo.ExpressCompanyAbb = info4.Kuaidi100Code; orderInfo.ExpressCompanyName = info4.Name; } orderInfo.ShipOrderNumber = this.txtShipOrderNumber.Text; if (OrderHelper.SendGoods(orderInfo)) { SendNoteInfo info5 = new SendNoteInfo(); info5.NoteId = Globals.GetGenerateId(); info5.OrderId = this.orderId; info5.Operator = currentManager.UserName; info5.Remark = "后台" + info5.Operator + "发货成功"; OrderHelper.SaveSendNote(info5); MemberInfo member = MemberHelper.GetMember(orderInfo.UserId); Messenger.OrderShipping(orderInfo, member); 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.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 })), "").SendGoods(orderInfo.GatewayOrderId, orderInfo.RealModeName, orderInfo.ShipOrderNumber, "EXPRESS"); } } if (orderInfo.Gateway == "hishop.plugins.payment.weixinrequest") { SiteSettings masterSettings = SettingsManager.GetMasterSettings(false); PayClient client = new PayClient(masterSettings.WeixinAppId, masterSettings.WeixinAppSecret, masterSettings.WeixinPartnerID, masterSettings.WeixinPartnerKey, masterSettings.WeixinPaySignKey); DeliverInfo deliver = new DeliverInfo { TransId = orderInfo.GatewayOrderId, OutTradeNo = orderInfo.OrderId, OpenId = MemberHelper.GetMember(orderInfo.UserId).OpenId }; client.DeliverNotify(deliver); } } orderInfo.OnDeliver(); this.ShowMsg("发货成功", true); } else { this.ShowMsg("发货失败", false); } } } } }
protected void Page_Load(object sender, System.EventArgs e) { string text = base.Request.QueryString.Get("orderId"); if (string.IsNullOrEmpty(text)) { this.pay_json = "{\"msg\":\"订单参数错误!\"}"; return; } OneyuanTaoParticipantInfo addParticipant = OneyuanTaoHelp.GetAddParticipant(0, text, ""); if (addParticipant == null) { this.pay_json = "{\"msg\":\"订单不存在了!\"}"; return; } OneyuanTaoInfo oneyuanTaoInfoById = OneyuanTaoHelp.GetOneyuanTaoInfoById(addParticipant.ActivityId); if (oneyuanTaoInfoById == null) { this.pay_json = "{\"msg\":\"活动已取消,禁止参与!\"}"; return; } OneTaoState oneTaoState = OneyuanTaoHelp.getOneTaoState(oneyuanTaoInfoById); if (oneTaoState != OneTaoState.进行中) { this.pay_json = "{\"msg\":\"您来晚了,活动已结束!\"}"; return; } if (oneTaoState != OneTaoState.进行中) { this.pay_json = "{\"msg\":\"您来晚了,活动已结束!\"}"; return; } if (oneyuanTaoInfoById.ReachType == 1 && oneyuanTaoInfoById.FinishedNum + addParticipant.BuyNum > oneyuanTaoInfoById.ReachNum) { this.pay_json = "{\"msg\":\"活动已满员,您来晚了!\"}"; return; } decimal totalPrice = addParticipant.TotalPrice; PackageInfo packageInfo = new PackageInfo(); packageInfo.Body = Globals.SubStr(oneyuanTaoInfoById.ProductTitle, 36, "...") + "。活动编号:" + addParticipant.ActivityId; packageInfo.NotifyUrl = string.Format("http://{0}/pay/wx_Pay.aspx", base.Request.Url.Host); packageInfo.OutTradeNo = text; packageInfo.TotalFee = (int)(totalPrice * 100m); if (packageInfo.TotalFee < 1m) { packageInfo.TotalFee = 1m; } string openId = ""; MemberInfo currentMember = MemberProcessor.GetCurrentMember(); if (currentMember != null) { openId = currentMember.OpenId; } else { this.pay_json = "{\"msg\":\"用户OPENID不存在,无法支付!\"}"; } packageInfo.OpenId = openId; SiteSettings masterSettings = SettingsManager.GetMasterSettings(true); 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, "", ""); } if (!payClient.checkSetParams(out this.CheckValue)) { return; } if (!payClient.checkPackage(packageInfo, out this.CheckValue)) { return; } PayRequestInfo payRequestInfo = payClient.BuildPayRequest(packageInfo); this.pay_json = this.ConvertPayJson(payRequestInfo); if (!payRequestInfo.package.ToLower().StartsWith("prepay_id=wx")) { this.CheckValue = payRequestInfo.package; } }
protected void Page_Load(object sender, EventArgs e) { string str2; string str3; JArray array; string str4; if (Globals.RequestQueryStr("type") == "saveorders") { this.type = "saveorders"; } string str = Globals.RequestFormStr("posttype"); this.orderIds = Globals.RequestQueryStr("OrderId").Trim(new char[] { ',' }); if (string.IsNullOrEmpty(this.ReUrl)) { this.ReUrl = "manageorder.aspx"; } switch (str) { case "saveorders": str2 = Globals.RequestFormStr("data"); base.Response.ContentType = "application/json"; str3 = "{\"type\":\"0\",\"tips\":\"指定物流失败!\"}"; array = (JArray)JsonConvert.DeserializeObject(str2); str4 = string.Empty; if (array != null) { if (array.Count > 1) { str4 = "批量"; } bool flag = true; foreach (JObject obj2 in array) { if (!this.CheckOrderCompany(obj2["orderid"].ToString(), obj2["companycode"].ToString(), obj2["compname"].ToString(), obj2["shipordernumber"].ToString())) { flag = false; } } if (flag) { foreach (JObject obj3 in array) { OrderHelper.UpdateOrderCompany(obj3["orderid"].ToString(), obj3["companycode"].ToString(), obj3["compname"].ToString(), obj3["shipordernumber"].ToString()); } str3 = "{\"type\":\"1\",\"tips\":\"" + str4 + "指定物流成功!\"}"; } else { str3 = "{\"type\":\"0\",\"tips\":\"" + str4 + "指定物流失败,请检测数据的正确性!\"}"; } } base.Response.Write(str3); base.Response.End(); return; case "saveoneorders": str2 = Globals.RequestFormStr("data"); base.Response.ContentType = "application/json"; str3 = "{\"type\":\"0\",\"tips\":\"指定物流失败!\"}"; array = (JArray)JsonConvert.DeserializeObject(str2); str4 = string.Empty; if (array != null) { bool flag2 = true; string shipNumber = "1111111111"; foreach (JObject obj4 in array) { if (!this.CheckOrderCompany(obj4["orderid"].ToString(), obj4["companycode"].ToString(), obj4["compname"].ToString(), shipNumber)) { flag2 = false; } } if (flag2) { foreach (JObject obj5 in array) { OrderHelper.UpdateOrderCompany(obj5["orderid"].ToString(), obj5["companycode"].ToString(), obj5["compname"].ToString(), ""); } str3 = "{\"type\":\"1\",\"tips\":\"" + str4 + "指定物流成功!\"}"; } else { str3 = "{\"type\":\"0\",\"tips\":\"" + str4 + "指定物流失败,请检测数据的正确性!\"}"; } } base.Response.Write(str3); base.Response.End(); return; case "sendorders": str2 = Globals.RequestFormStr("data"); base.Response.ContentType = "application/json"; str3 = "{\"type\":\"0\",\"tips\":\"发货失败!\"}"; array = (JArray)JsonConvert.DeserializeObject(str2); str4 = string.Empty; if (array != null) { if (array.Count > 1) { str4 = "批量"; } bool flag3 = true; foreach (JObject obj6 in array) { if (!this.CheckOrderCompany(obj6["orderid"].ToString(), obj6["companycode"].ToString(), obj6["compname"].ToString(), obj6["shipordernumber"].ToString())) { flag3 = false; } } if (flag3) { int num = 0; foreach (JObject obj7 in array) { OrderInfo orderInfo = OrderHelper.GetOrderInfo(obj7["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(obj7["shipordernumber"].ToString().Trim()) && (obj7["shipordernumber"].ToString().Trim().Length <= 30))) { orderInfo.ExpressCompanyAbb = obj7["companycode"].ToString(); orderInfo.ExpressCompanyName = obj7["compname"].ToString(); orderInfo.ShipOrderNumber = obj7["shipordernumber"].ToString(); if (OrderHelper.SendGoods(orderInfo)) { SendNoteInfo info2 = new SendNoteInfo(); Express.SubscribeExpress100(obj7["companycode"].ToString(), obj7["shipordernumber"].ToString()); info2 = new SendNoteInfo { NoteId = Globals.GetGenerateId() + num, OrderId = obj7["orderid"].ToString(), Operator = ManagerHelper.GetCurrentManager().UserName, Remark = "后台" + info2.Operator + "发货成功" }; OrderHelper.SaveSendNote(info2); 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.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 })), "").SendGoods(orderInfo.GatewayOrderId, orderInfo.RealModeName, orderInfo.ShipOrderNumber, "EXPRESS"); } } if (orderInfo.Gateway == "hishop.plugins.payment.weixinrequest") { PayClient client; SiteSettings masterSettings = SettingsManager.GetMasterSettings(false); if (masterSettings.EnableSP) { client = new PayClient(masterSettings.Main_AppId, masterSettings.WeixinAppSecret, masterSettings.Main_Mch_ID, masterSettings.Main_PayKey, true, masterSettings.WeixinAppId, masterSettings.WeixinPartnerID); } else { client = new PayClient(masterSettings.WeixinAppId, masterSettings.WeixinAppSecret, masterSettings.WeixinPartnerID, masterSettings.WeixinPartnerKey, false, "", ""); } DeliverInfo deliver = new DeliverInfo { TransId = orderInfo.GatewayOrderId, OutTradeNo = orderInfo.OrderId, OpenId = MemberHelper.GetMember(orderInfo.UserId).OpenId }; client.DeliverNotify(deliver); } } orderInfo.OnDeliver(); num++; } } } if (num == 0) { str3 = "{\"type\":\"0\",\"tips\":\"" + str4 + "发货失败!\"}"; } else { str3 = "{\"type\":\"1\",\"tips\":\"" + num + "个订单发货成功!\"}"; } } else { str3 = "{\"type\":\"0\",\"tips\":\"" + str4 + "发货失败,请检测数据的正确性!\"}"; } } base.Response.Write(str3); base.Response.End(); return; case "getcompany": { base.Response.ContentType = "application/json"; str2 = "[{\"type\":\"0\",\"data\":[]}]"; IList <ExpressCompanyInfo> allExpress = ExpressHelper.GetAllExpress(); int num2 = 0; StringBuilder builder = new StringBuilder(); foreach (ExpressCompanyInfo info5 in allExpress) { if (num2 == 0) { builder.Append("{\"code\":\"" + String2Json(info5.Kuaidi100Code) + "\",\"name\":\"" + String2Json(info5.Name) + "\"}"); } else { builder.Append(",{\"code\":\"" + String2Json(info5.Kuaidi100Code) + "\",\"name\":\"" + String2Json(info5.Name) + "\"}"); } num2++; } if (!string.IsNullOrEmpty(builder.ToString())) { str2 = "[{\"type\":\"1\",\"data\":[" + builder.ToString() + "]}]"; } base.Response.Write(str2); base.Response.End(); return; } case "updateExpress": { str2 = Globals.RequestFormStr("data"); base.Response.ContentType = "application/json"; str3 = "{\"type\":\"0\",\"tips\":\"修改失败!\"}"; array = (JArray)JsonConvert.DeserializeObject(str2); bool flag4 = true; foreach (JObject obj8 in array) { if (!this.CheckOrderCompany(obj8["orderid"].ToString(), obj8["companycode"].ToString(), obj8["compname"].ToString(), obj8["shipordernumber"].ToString())) { flag4 = false; } } if (flag4) { bool flag5 = false; foreach (JObject obj9 in array) { OrderInfo order = OrderHelper.GetOrderInfo(obj9["orderid"].ToString()); order.ExpressCompanyAbb = obj9["companycode"].ToString(); order.ExpressCompanyName = obj9["compname"].ToString(); order.ShipOrderNumber = obj9["shipordernumber"].ToString(); flag5 = OrderHelper.UpdateOrder(order); if (flag5) { Express.SubscribeExpress100(obj9["companycode"].ToString(), obj9["shipordernumber"].ToString()); } } if (flag5) { str3 = "{\"type\":\"1\",\"tips\":\"修改成功!\"}"; } } else { str3 = "{\"type\":\"0\",\"tips\":\"数据验证失败!\"}"; } base.Response.Write(str3); base.Response.End(); return; } } if (string.IsNullOrEmpty(this.orderIds)) { base.GotoResourceNotFound(); } else { string[] strArray = this.orderIds.Split(new char[] { ',' }); bool flag6 = true; foreach (string str6 in strArray) { if (!Globals.IsOrdersID(str6)) { flag6 = false; break; } } if (flag6) { DataSet ordersByOrderIDList = OrderHelper.GetOrdersByOrderIDList(this.orderIds); this.rptItemList.DataSource = ordersByOrderIDList; this.rptItemList.DataBind(); this.litOrdersCount.Text = ordersByOrderIDList.Tables[0].Rows.Count.ToString(); } else { base.Response.Write("非法参数请求!"); base.Response.End(); } } }
protected void Page_Load(object sender, EventArgs e) { NameValueCollection headers = base.Request.Headers; string text = ""; if (headers.AllKeys.Contains("Forwarded")) { text = headers["Forwarded"].ToNullString(); } OrderInfo orderInfo = null; PackageInfo packageInfo = new PackageInfo(); SiteSettings masterSettings = SettingsManager.GetMasterSettings(); bool flag = this.Page.Request["IsOffline"].ToBool(); string a = this.Page.Request["from"].ToNullString().ToLower(); string text2 = this.Page.Request.QueryString.Get("orderId"); string empty = string.Empty; string empty2 = string.Empty; decimal d; if (a == "appstore") { this.isOfflineOrder = "true"; if (string.IsNullOrEmpty(text2)) { this.litError.Text = "错误的订单号,不能进行支付!"; return; } empty = text2; d = default(decimal); StoreCollectionInfo storeCollectionInfo = null; if (flag) { this.isOfflineOrder = "true"; storeCollectionInfo = StoresHelper.GetStoreCollectionInfo(text2); if (storeCollectionInfo == null) { this.litError.Text = "订单状态错误,不能进行支付!"; } else if (storeCollectionInfo.Status == 0) { d = storeCollectionInfo.PayAmount; goto IL_0309; } return; } orderInfo = ShoppingProcessor.GetOrderInfo(text2); if (orderInfo == null) { this.litError.Text = "错误的订单信息,不能进行支付!"; return; } if (orderInfo.OrderStatus != OrderStatus.WaitBuyerPay) { if (orderInfo.OrderSource == OrderSource.Alioh) { base.Response.Redirect("/AliOH/MemberOrderDetails?OrderId=" + orderInfo.OrderId); } else { base.Response.Redirect("/WapShop/MemberOrderDetails?OrderId=" + orderInfo.OrderId); } return; } this.IsServiceOrder = ((orderInfo.OrderType == OrderType.ServiceOrder) ? "true" : "false"); if (orderInfo.PreSaleId > 0) { if (!orderInfo.DepositDate.HasValue && orderInfo.OrderStatus == OrderStatus.WaitBuyerPay) { empty = orderInfo.OrderId; d = orderInfo.Deposit - orderInfo.BalanceAmount; } if (orderInfo.DepositDate.HasValue && orderInfo.OrderStatus == OrderStatus.WaitBuyerPay) { if (orderInfo.PayRandCode.ToInt(0) == 0) { int num = orderInfo.PayRandCode.ToInt(0); num = ((num >= 100) ? (num + 1) : 100); orderInfo.PayRandCode = num.ToString(); OrderHelper.UpdateOrderPaymentTypeOfAPI(orderInfo); } empty = orderInfo.PayOrderId; d = orderInfo.FinalPayment; } } else { empty = orderInfo.PayOrderId; d = orderInfo.GetTotal(true); } goto IL_0309; } if (string.IsNullOrEmpty(text2)) { this.litError.Text = "订单状态错误,不能进行支付!"; return; } orderInfo = OrderHelper.GetOrderInfo(text2); if (orderInfo == null) { this.litError.Text = "订单状态错误,不能进行支付!"; return; } if (orderInfo.OrderStatus != OrderStatus.WaitBuyerPay) { if (orderInfo.OrderSource == OrderSource.Alioh) { base.Response.Redirect("/AliOH/MemberOrderDetails?OrderId=" + orderInfo.OrderId); } else { base.Response.Redirect("/WapShop/MemberOrderDetails?OrderId=" + orderInfo.OrderId); } return; } empty = text2; this.isFightGroup = ((orderInfo.FightGroupId > 0) ? "true" : "false"); decimal d2 = default(decimal); if (orderInfo.PreSaleId > 0) { if (!orderInfo.DepositDate.HasValue && orderInfo.OrderStatus == OrderStatus.WaitBuyerPay) { empty = orderInfo.OrderId; d2 = ((orderInfo.Deposit - orderInfo.BalanceAmount > decimal.Zero) ? (orderInfo.Deposit - orderInfo.BalanceAmount) : decimal.Zero); } if (orderInfo.DepositDate.HasValue && orderInfo.OrderStatus == OrderStatus.WaitBuyerPay) { if (orderInfo.PayRandCode.ToInt(0) == 0) { int num2 = orderInfo.PayRandCode.ToInt(0); num2 = ((num2 >= 100) ? (num2 + 1) : 100); orderInfo.PayRandCode = num2.ToString(); OrderHelper.UpdateOrderPaymentTypeOfAPI(orderInfo); } empty = orderInfo.PayOrderId; d2 = ((orderInfo.FinalPayment > decimal.Zero) ? orderInfo.FinalPayment : decimal.Zero); } } else { empty = orderInfo.PayOrderId; d2 = orderInfo.GetTotal(true); } packageInfo.Body = orderInfo.OrderId; packageInfo.NotifyUrl = Globals.GetProtocal(HttpContext.Current) + "://" + $"{this.Page.Request.Url.Host}/pay/wx_Pay"; if (orderInfo.OrderType != OrderType.ServiceOrder && orderInfo.OrderSource == OrderSource.Applet) { packageInfo.NotifyUrl = Globals.GetProtocal(HttpContext.Current) + "://" + $"{this.Page.Request.Url.Host}/pay/O2OApplet_Pay"; } packageInfo.OutTradeNo = empty; packageInfo.Attach = empty2; packageInfo.TotalFee = (int)(d2 * 100m); if (packageInfo.TotalFee < decimal.One) { packageInfo.TotalFee = decimal.One; } goto IL_06db; IL_06db: packageInfo.SpbillCreateIp = ((string.IsNullOrEmpty(text) || !Globals.IsIpAddress(text)) ? Globals.GetIPAddress(HttpContext.Current) : text); string text3 = masterSettings.WeixinAppId; string appSecret = masterSettings.WeixinAppSecret; string text4 = masterSettings.WeixinPartnerID; string partnerKey = masterSettings.WeixinPartnerKey; string text5 = masterSettings.Main_Mch_ID; string text6 = masterSettings.Main_AppId; if (orderInfo.OrderType == OrderType.ServiceOrder) { text3 = masterSettings.O2OAppletAppId; appSecret = masterSettings.O2OAppletAppSecrect; text4 = masterSettings.O2OAppletMchId; partnerKey = masterSettings.O2OAppletKey; text5 = ""; text6 = ""; } else if (orderInfo.OrderSource == OrderSource.Applet) { text3 = masterSettings.WxAppletAppId; appSecret = masterSettings.WxAppletAppSecrect; text4 = masterSettings.WxApplectMchId; partnerKey = masterSettings.WxApplectKey; text5 = ""; text6 = ""; } string text7 = ""; if (!string.IsNullOrEmpty(text6) && !string.IsNullOrEmpty(text5)) { packageInfo.sub_openid = text7; } else { packageInfo.OpenId = text7; } PayClient payClient = null; payClient = ((string.IsNullOrEmpty(text6) || string.IsNullOrEmpty(text5)) ? new PayClient(text3, appSecret, text4, partnerKey, "", "", "", "") : new PayClient(text6, appSecret, text5, partnerKey, "", text4, text3, "")); Globals.AppendLog(JsonHelper.GetJson(packageInfo), "", "", "H5PaySubmit"); PayRequestInfo payRequestInfo = payClient.BuildH5PayRequest(packageInfo); this.pay_uri = payRequestInfo.mweb_url; return; IL_0309: packageInfo.Body = text2; packageInfo.NotifyUrl = Globals.GetProtocal(HttpContext.Current) + "://" + $"{this.Page.Request.Url.Host}/pay/AppStore_wxPay"; packageInfo.OutTradeNo = empty; packageInfo.TotalFee = (int)(d * 100m); if (orderInfo != null) { packageInfo.OutTradeNo = orderInfo.PayOrderId; packageInfo.Attach = empty2; } else { packageInfo.OutTradeNo = empty; packageInfo.Attach = empty2; } if (packageInfo.TotalFee < decimal.One) { packageInfo.TotalFee = decimal.One; } goto IL_06db; }
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 btnAcceptRefund_Click(object sender, System.EventArgs e) { ManagerHelper.CheckPrivilege(Privilege.OrderRefundApplyAccept); decimal refundTotal = 0m; if (string.IsNullOrEmpty(this.hidRefundTotal.Value)) { this.ShowMsg("退款金额不能为空", false); return; } if (!decimal.TryParse(this.hidRefundTotal.Value, out refundTotal)) { this.ShowMsg("退款金额只能为数字", false); return; } string username = HiContext.Current.User.Username; OrderInfo orderInfo = OrderHelper.GetOrderInfo(this.hidOrderId.Value); if (refundTotal > orderInfo.GetTotal()) { this.ShowMsg("退款金额不能大于订单金额", false); return; } bool isReturn = false; if (this.radBtnList.SelectedValue == "1") { isReturn = true; } if (OrderHelper.CheckRefund(orderInfo, username, this.hidAdminRemark.Value, int.Parse(this.hidRefundType.Value), refundTotal, true, isReturn)) { this.BindRefund(); decimal amount = orderInfo.GetTotal(); if (orderInfo.GroupBuyId > 0 && orderInfo.GroupBuyStatus != GroupBuyStatus.Failed) { amount = orderInfo.GetTotal() - orderInfo.NeedPrice; } //调用微信接口退款 bool isAutoRefund = this.hidIsAutoRefund.Value == "1"; if (1 == 2) { SiteSettings masterSettings = SettingsManager.GetMasterSettings(false); PackageInfo packageInfo = new PackageInfo(); PayClient payClient = new PayClient(masterSettings.WeixinAppId, masterSettings.WeixinAppSecret, masterSettings.WeixinPartnerID, masterSettings.WeixinPartnerKey, masterSettings.WeixinPaySignKey); RefundInfo refundinfo = OrderHelper.GetRefundByOrderId(orderInfo.OrderId); packageInfo.TransactionId = orderInfo.GatewayOrderId; packageInfo.OutTradeNo = orderInfo.OrderId; packageInfo.OutRefundNo = refundinfo.RefundId.ToString(); packageInfo.RefundFee = (int)refundTotal * 100m; packageInfo.TotalFee = (int)orderInfo.GetTotal() * 100m; string ret = string.Empty; try { ret = payClient.RequestRefund(packageInfo); } catch (Exception ex) { ErrorLog.Write("申请退款失败:" + ex.ToString()); } ErrorLog.Write(ret); } Member user = Users.GetUser(orderInfo.UserId) as Member; //是否退券 radBtnList Messenger.OrderRefund(user, orderInfo, amount); this.ShowMsg("成功的确认了订单退款", true); } }
protected void Page_Load(object sender, EventArgs e) { string str = base.Request.QueryString.Get("orderId"); if (!string.IsNullOrEmpty(str)) { List <OrderInfo> orderMarkingOrderInfo = ShoppingProcessor.GetOrderMarkingOrderInfo(str, true); if (orderMarkingOrderInfo.Count != 0) { PayClient client; decimal num = 0M; if (orderMarkingOrderInfo[0].UserId != 0) { foreach (OrderInfo info in orderMarkingOrderInfo) { if (info.BargainDetialId > 0) { string str2 = BargainHelper.IsCanBuyByBarginDetailId(info.BargainDetialId); if (str2 != "1") { info.OrderStatus = OrderStatus.Closed; info.CloseReason = str2; OrderHelper.UpdateOrder(info); base.Response.Write("<script>alert('" + str2 + ",订单自动关闭!');location.href='/Vshop/MemberOrders.aspx'</script>"); base.Response.End(); return; } } else { foreach (LineItemInfo info2 in info.LineItems.Values) { if (!ProductHelper.GetProductHasSku(info2.SkuId, info2.Quantity)) { info.OrderStatus = OrderStatus.Closed; info.CloseReason = "库存不足"; OrderHelper.UpdateOrder(info); base.Response.Write("<script>alert('库存不足,订单自动关闭!');location.href='/Vshop/MemberOrders.aspx'</script>"); base.Response.End(); return; } } } num += info.GetCashPayMoney(); } } else { num = orderMarkingOrderInfo[0].Amount; } PackageInfo package = new PackageInfo { Body = str, NotifyUrl = string.Format("http://{0}/pay/wx_Pay.aspx", base.Request.Url.Host), OutTradeNo = str, TotalFee = (int)(num * 100M) }; if (package.TotalFee < 1M) { package.TotalFee = 1M; } string openId = ""; MemberInfo currentMember = MemberProcessor.GetCurrentMember(); if (currentMember != null) { openId = currentMember.OpenId; } package.OpenId = openId; SiteSettings masterSettings = SettingsManager.GetMasterSettings(true); if (masterSettings.EnableSP) { client = new PayClient(masterSettings.Main_AppId, masterSettings.WeixinAppSecret, masterSettings.Main_Mch_ID, masterSettings.Main_PayKey, true, masterSettings.WeixinAppId, masterSettings.WeixinPartnerID); } else { client = new PayClient(masterSettings.WeixinAppId, masterSettings.WeixinAppSecret, masterSettings.WeixinPartnerID, masterSettings.WeixinPartnerKey, false, "", ""); } if (client.checkSetParams(out this.CheckValue) && client.checkPackage(package, out this.CheckValue)) { PayRequestInfo req = client.BuildPayRequest(package); this.pay_json = this.ConvertPayJson(req); if (!req.package.ToLower().StartsWith("prepay_id=wx")) { this.CheckValue = req.package; } DataTable shareActivity = ShareActHelper.GetShareActivity(); int num2 = 0; decimal num3 = 0M; if (shareActivity.Rows.Count > 0) { for (int i = 0; i < shareActivity.Rows.Count; i++) { if ((num != 0M) && (num >= decimal.Parse(shareActivity.Rows[shareActivity.Rows.Count - 1]["MeetValue"].ToString()))) { num2 = int.Parse(shareActivity.Rows[shareActivity.Rows.Count - 1]["Id"].ToString()); num3 = decimal.Parse(shareActivity.Rows[shareActivity.Rows.Count - 1]["MeetValue"].ToString()); break; } if ((num != 0M) && (num <= decimal.Parse(shareActivity.Rows[0]["MeetValue"].ToString()))) { num2 = int.Parse(shareActivity.Rows[0]["Id"].ToString()); num3 = decimal.Parse(shareActivity.Rows[0]["MeetValue"].ToString()); break; } if ((num != 0M) && (num >= decimal.Parse(shareActivity.Rows[i]["MeetValue"].ToString()))) { num2 = int.Parse(shareActivity.Rows[i]["Id"].ToString()); num3 = decimal.Parse(shareActivity.Rows[i]["MeetValue"].ToString()); } } if (num >= num3) { this.shareid = num2; } } } } } }
/// <summary> /// 发红包回调 /// </summary> /// <returns></returns> public async Task <Tuple <bool, string, string> > CallbackRedEnvelopAsync() { try { // 领取记录增加到数据库中。 using (var dbHelper = DbHelper.CreateDbHelper()) { // 获取user var user = await FetchUserByUserIdByCacheAsync(_oaRedEnvelopeBuilderModel.UserId); // 添加到明细表 var result = await DalOARedEnvelopeDetail.InsertOARedEnvelopeDetailAsync(dbHelper, new OARedEnvelopeDetailModel { GetMoney = _oaRedEnvelopeBuilderModel.Money, OfficialAccountType = _oaRedEnvelopeBuilderModel.OfficialAccountType, OpenId = _oaRedEnvelopeBuilderModel.OpenId, UserId = _oaRedEnvelopeBuilderModel.UserId, ReferrerUserId = _oaRedEnvelopeBuilderModel.ReferrerUserId, NickName = _oaRedEnvelopeBuilderModel.WXNickName, WXHeadImgUrl = _oaRedEnvelopeBuilderModel.WXHeadPicUrl, GetDate = _oaRedEnvelopeBuilderModel.RequestTime.Date, }); if (result > 0) { // 设置数据库插入成功 _oaRedEnvelopeBuilderModel.DbDetailGet(result); using (var configClient = new Service.Config.ConfigClient()) { // 判断开关是否打开 var payServiceFlag = configClient.GetOrSetRuntimeSwitch("OAEnvelopeUsePayService")?.Result?.Value ?? false; if (payServiceFlag) { // 调用PAY 实际给用户发钱 using (var payClient = new PayClient()) { var payResult = await payClient.Wx_SendRedBagAsync(new WxSendRedBagRequest { ActName = "关注公众号领红包", Channel = "关注公众号领红包", // 这边 *100 是因为 支付系统是不支持小数的 Money = (int)(_oaRedEnvelopeBuilderModel.Money * 100), OpenId = _oaRedEnvelopeBuilderModel.OpenId, Remark = "关注公众号领红包奖励" }); payResult.ThrowIfException(); if (!payResult.Success || !payResult.Result) { // 判断异常类型 --- 发送提醒 Logger.Warn( $"OARedEnvelopeUserReceiveManager -> CallbackRedEnvelopAsync -> Wx_SendRedBagAsync -> false -> {JsonConvert.SerializeObject(_oaRedEnvelopeBuilderModel)} {payResult.ErrorMessage} {payResult.ErrorCode} "); return(Tuple.Create(false, "-10", "")); } } } } } // 写日志 Logger.Info( $"OARedEnvelopeUserReceiveManager -> CallbackRedEnvelopAsync -> finish -> {JsonConvert.SerializeObject(_oaRedEnvelopeBuilderModel)}"); // 实时统计 await _oaRedEnvelopeCacheManager.StatisticsDoingAsync(1, _oaRedEnvelopeBuilderModel.Money); } return(await Task.FromResult(Tuple.Create(true, string.Empty, string.Empty))); } catch (Exception e) { Logger.Error( $"OARedEnvelopeUserReceiveManager -> CallbackRedEnvelopAsync -> {JsonConvert.SerializeObject(_oaRedEnvelopeBuilderModel)}", e.InnerException ?? e); throw; } }
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(); }
protected void Page_Load(object sender, EventArgs e) { string str = base.Request.QueryString.Get("orderId"); if (string.IsNullOrEmpty(str)) { this.pay_json = "{\"msg\":\"订单参数错误!\"}"; } else { OneyuanTaoParticipantInfo info = OneyuanTaoHelp.GetAddParticipant(0, str, ""); if (info == null) { this.pay_json = "{\"msg\":\"订单不存在了!\"}"; } else { OneyuanTaoInfo oneyuanTaoInfoById = OneyuanTaoHelp.GetOneyuanTaoInfoById(info.ActivityId); if (oneyuanTaoInfoById == null) { this.pay_json = "{\"msg\":\"活动已取消,禁止参与!\"}"; } else { OneTaoState state = OneyuanTaoHelp.getOneTaoState(oneyuanTaoInfoById); if (state != OneTaoState.进行中) { this.pay_json = "{\"msg\":\"您来晚了,活动已结束!\"}"; } else if (state != OneTaoState.进行中) { this.pay_json = "{\"msg\":\"您来晚了,活动已结束!\"}"; } else if ((oneyuanTaoInfoById.ReachType == 1) && ((oneyuanTaoInfoById.FinishedNum + info.BuyNum) > oneyuanTaoInfoById.ReachNum)) { this.pay_json = "{\"msg\":\"活动已满员,您来晚了!\"}"; } else { PayClient client; decimal totalPrice = info.TotalPrice; PackageInfo package = new PackageInfo { Body = "一元夺宝。当前活动编号:" + info.ActivityId, NotifyUrl = string.Format("http://{0}/pay/wx_Pay.aspx", base.Request.Url.Host), OutTradeNo = str, TotalFee = (int)(totalPrice * 100M) }; if (package.TotalFee < 1M) { package.TotalFee = 1M; } string openId = ""; MemberInfo currentMember = MemberProcessor.GetCurrentMember(); if (currentMember != null) { openId = currentMember.OpenId; } else { this.pay_json = "{\"msg\":\"用户OPENID不存在,无法支付!\"}"; } package.OpenId = openId; SiteSettings masterSettings = SettingsManager.GetMasterSettings(true); if (masterSettings.EnableSP) { client = new PayClient(masterSettings.Main_AppId, masterSettings.WeixinAppSecret, masterSettings.Main_Mch_ID, masterSettings.Main_PayKey, true, masterSettings.WeixinAppId, masterSettings.WeixinPartnerID); } else { client = new PayClient(masterSettings.WeixinAppId, masterSettings.WeixinAppSecret, masterSettings.WeixinPartnerID, masterSettings.WeixinPartnerKey, false, "", ""); } if (client.checkSetParams(out this.CheckValue) && client.checkPackage(package, out this.CheckValue)) { PayRequestInfo req = client.BuildPayRequest(package); this.pay_json = this.ConvertPayJson(req); if (!req.package.ToLower().StartsWith("prepay_id=wx")) { this.CheckValue = req.package; } } } } } } }