Ejemplo n.º 1
0
        /// <summary>
        /// 关闭到期未付款的订单(还原库存、优惠券,现金券)
        /// </summary>
        /// <param name="closeOrderDays"></param>
        private void AutoCloseOrders(int closeOrderDays)
        {
            List <string> orderIdList      = new List <string>();
            DbCommand     sqlStringCommand = this.database.GetSqlStringCommand("SELECT OrderId FROM dbo.Ecshop_Orders  WHERE OrderStatus=1 AND OrderDate <= @OrderDate;");

            this.database.AddInParameter(sqlStringCommand, "OrderDate", DbType.DateTime, DateTime.Now.AddHours(-closeOrderDays));

            IDataReader dataReader = this.database.ExecuteReader(sqlStringCommand);

            while (dataReader.Read())
            {
                if (dataReader["OrderId"] == null || string.IsNullOrEmpty(dataReader["OrderId"].ToString()))
                {
                    continue;
                }

                orderIdList.Add(dataReader["OrderId"].ToString());
            }

            foreach (string orderId in orderIdList)
            {
                bool result = TradeHelper.CloseOrder(orderId, CloseOrderType.Auto);
                if (!result)
                {
                    ErrorLog.Write("【到期未付款】系统未能关闭订单:" + orderId);
                }
            }
        }
Ejemplo n.º 2
0
        protected void listOrders_ItemCommand(object sender, GridViewCommandEventArgs e)
        {
            OrderInfo orderInfo = TradeHelper.GetOrderInfo(e.CommandArgument.ToString());

            if (orderInfo != null)
            {
                if ((e.CommandName == "FINISH_TRADE") && orderInfo.CheckAction(OrderActions.SELLER_FINISH_TRADE))
                {
                    if (TradeHelper.ConfirmOrderFinish(orderInfo))
                    {
                        this.BindOrders();
                        this.ShowMessage("成功的完成了该订单", true);
                    }
                    else
                    {
                        this.ShowMessage("完成订单失败", false);
                    }
                }
                if ((e.CommandName == "CLOSE_TRADE") && orderInfo.CheckAction(OrderActions.SELLER_CLOSE))
                {
                    if (TradeHelper.CloseOrder(orderInfo.OrderId))
                    {
                        this.BindOrders();
                        this.ShowMessage("成功的关闭了该订单", true);
                    }
                    else
                    {
                        this.ShowMessage("关闭订单失败", false);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        protected void listOrders_ItemCommand(object sender, RepeaterCommandEventArgs e)
        {
            OrderInfo orderInfo = TradeHelper.GetOrderInfo(e.CommandArgument.ToString());

            if (orderInfo != null)
            {
                if (e.CommandName == "FINISH_TRADE" && orderInfo.CheckAction(OrderActions.SELLER_FINISH_TRADE))
                {
                    if (TradeHelper.ConfirmOrderFinish(orderInfo))
                    {
                        this.BindOrders();
                        this.ShowMessage("成功的完成了该订单", true, "", 1);
                        if (orderInfo.LineItems.Count > 0)
                        {
                            SiteSettings masterSettings = SettingsManager.GetMasterSettings();
                            if (masterSettings != null && masterSettings.ProductCommentPoint > 0)
                            {
                                Panel panel = (Panel)this.FindControl("panl_productcommentTip");
                                if (panel != null)
                                {
                                    panel.Visible = true;
                                    HiddenField hiddenField = (HiddenField)this.FindControl("goCommentLink");
                                    if (hiddenField != null)
                                    {
                                        hiddenField.Value = $"/user/OrderReviews/{orderInfo.OrderId}";
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        this.ShowMessage("完成订单失败,订单状态错误或者订单商品有退款、退货或者换货正在进行中!", false, "", 1);
                    }
                }
                if (e.CommandName == "CLOSE_TRADE" && orderInfo.CheckAction(OrderActions.SELLER_CLOSE))
                {
                    if (TradeHelper.CloseOrder(orderInfo.OrderId, "会员主动关闭") && orderInfo.ItemStatus == OrderItemStatus.Nomarl)
                    {
                        if (orderInfo.ShippingModeId == -2 && orderInfo.IsConfirm)
                        {
                            OrderHelper.CloseDeportOrderReturnStock(orderInfo, "会员" + HiContext.Current.User.UserName + "关闭订单");
                        }
                        Messenger.OrderClosed(HiContext.Current.User, orderInfo, "用户自己关闭订单");
                        this.BindOrders();
                        this.ShowMessage("成功的关闭了该订单", true, "", 1);
                    }
                    else
                    {
                        this.ShowMessage("关闭订单失败。", false, "", 1);
                    }
                }
            }
        }
Ejemplo n.º 4
0
 private void lkbtnCloseOrder_Click(object sender, System.EventArgs e)
 {
     // 2015-08-19
     if (TradeHelper.CloseOrder(this.orderId))
     {
         this.ShowMessage("成功的关闭了该订单", true);
         OrderInfo orderInfo = TradeHelper.GetOrderInfo(this.orderId);
         this.BindOrderBase(orderInfo);
         return;
     }
     this.ShowMessage("关闭订单失败", false);
 }
Ejemplo n.º 5
0
 private void lkbtnCloseOrder_Click(object sender, EventArgs e)
 {
     if (TradeHelper.CloseOrder(this.orderId, "会员主动关闭"))
     {
         this.ShowMessage("成功的关闭了该订单", true, "", 1);
         OrderInfo orderInfo = TradeHelper.GetOrderInfo(this.orderId);
         this.BindOrderBase(orderInfo);
     }
     else
     {
         this.ShowMessage("关闭订单失败!", false, "", 1);
     }
 }
Ejemplo n.º 6
0
        public void Execute(XmlNode node)
        {
            try
            {
                Database  database         = DatabaseFactory.CreateDatabase();
                DbCommand sqlStringCommand = database.GetSqlStringCommand("SELECT o.OrderId, o.UserId, o.StoreId, o.FightGroupId, o.Gateway, o.GatewayOrderId,o.OrderStatus,o.BalanceAmount, o.OrderTotal,(SELECT SUM(Quantity) FROM Hishop_OrderItems WHERE OrderId = o.OrderId) AS Quantity,(SELECT Top 1 ItemDescription FROM Hishop_OrderItems WHERE OrderId = o.OrderId) as ItemDescription FROM Hishop_FightGroups fg INNER JOIN Hishop_Orders o ON fg.FightGroupId = o.FightGroupId AND fg.EndTime < getdate () AND fg.Status = @Status");
                database.AddInParameter(sqlStringCommand, "Status", DbType.Int32, 0);
                DataTable dataTable = null;
                using (IDataReader reader = database.ExecuteReader(sqlStringCommand))
                {
                    dataTable = DataHelper.ConverDataReaderToDataTable(reader);
                }
                if (dataTable != null && dataTable.Rows.Count > 0)
                {
                    foreach (DataRow row in dataTable.Rows)
                    {
                        int     refundType    = 3;
                        string  text          = row["Gateway"].ToNullString();
                        string  orderId       = row["OrderId"].ToNullString();
                        string  refundOrderId = row["GatewayOrderId"].ToNullString();
                        decimal refundAmount  = row["OrderTotal"].ToDecimal(0);
                        decimal d             = row["BalanceAmount"].ToDecimal(0);
                        if (d > decimal.Zero)
                        {
                            refundType = 1;
                        }
                        int value          = row["StoreId"].ToInt(0);
                        int num            = row["Quantity"].ToInt(0);
                        int fightGroupFail = row["FightGroupId"].ToInt(0);
                        int num2           = VShopHelper.SetFightGroupFail(fightGroupFail);
                        switch (row["OrderStatus"].ToInt(0))
                        {
                        case 1:
                            TradeHelper.CloseOrder(orderId, "火拼团订单成团时限内未付款");
                            break;

                        case 2:
                        {
                            if (text == "hishop.plugins.payment.advancerequest")
                            {
                                refundType = 1;
                            }
                            RefundInfo refundInfo = new RefundInfo();
                            refundInfo.OrderId       = orderId;
                            refundInfo.RefundReason  = "拼团失败,自动退款";
                            refundInfo.RefundGateWay = (string.IsNullOrEmpty(text) ? "" : text.ToLower().Replace(".payment.", ".refund."));
                            refundInfo.RefundType    = (RefundTypes)refundType;
                            refundInfo.RefundOrderId = refundOrderId;
                            refundInfo.StoreId       = value;
                            refundInfo.AdminRemark   = "拼团失败,自动退款";
                            refundInfo.ApplyForTime  = DateTime.Now;
                            refundInfo.UserRemark    = "";
                            refundInfo.RefundAmount  = refundAmount;
                            TradeHelper.ApplyForRefund(refundInfo);
                            MemberInfo user           = Users.GetUser((int)row["UserId"]);
                            string     productInfo    = row["ItemDescription"].ToString();
                            string     fightGroupInfo = string.Format("{0}人团{1}元", num2, ((decimal)row["OrderTotal"]).F2ToString("f2"));
                            Messenger.FightGroupOrderFail(user, productInfo, fightGroupInfo, orderId);
                            break;
                        }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Globals.WriteExceptionLog(ex, null, "FightGroupJob");
            }
        }
Ejemplo n.º 7
0
        protected void listOrders_ItemCommand(object sender, System.Web.UI.WebControls.RepeaterCommandEventArgs e)
        {
            string    orderId   = e.CommandArgument.ToString();
            OrderInfo orderInfo = TradeHelper.GetOrderInfo(orderId);

            if (orderInfo != null)
            {
                if (e.CommandName == "FINISH_TRADE" && orderInfo.CheckAction(OrderActions.SELLER_FINISH_TRADE))
                {
                    if (TradeHelper.ConfirmOrderFinish(orderInfo))
                    {
                        this.BindOrders();
                        this.ShowMessage("成功的完成了该订单", true);
                    }
                    else
                    {
                        this.ShowMessage("完成订单失败", false);
                    }
                }
                if (e.CommandName == "CLOSE_TRADE")
                {
                    if (orderInfo.CheckAction(OrderActions.SELLER_CLOSE))
                    {
                        if (TradeHelper.CloseOrder(orderInfo.OrderId, CloseOrderType.Manually))
                        {
                            Messenger.OrderClosed(HiContext.Current.User, orderInfo, "用户自己关闭订单");
                            this.BindOrders();
                            this.ShowMessage("成功的关闭了该订单", true);
                            return;
                        }
                        this.ShowMessage("关闭订单失败", false);
                    }
                    this.BindOrders();
                }
                if (e.CommandName == "CLOSE_Refund")//申请退款
                {
                    this.ReloadUserOrders(true);
                }
                //    string refundrest = string.Empty;
                //    OrderRefundTime = OrderRefundTime > 0 ? OrderRefundTime : 30;
                //    if (orderInfo.IsRefund == 2)
                //    {
                //        this.ShowMessage("您退款已申请成功,无需再提交!", true);
                //        return;
                //    }
                //    if (Convert.ToDateTime(orderInfo.PayDate) > DateTime.Now.AddMinutes(-OrderRefundTime) && orderInfo.IsRefund != 1 && (int)orderInfo.OrderStatus == 2)//可以取消
                //    {
                //        int type = string.IsNullOrEmpty(orderInfo.SourceOrderId) ? 1 : 2;
                //        orderId = type == 1 ? orderId : orderInfo.SourceOrderId;
                //        bool Rest = TradeHelper.ChangeRefundType(orderId, type);
                //        if (Rest)
                //        {
                //            this.Enabled = false;
                //            this.ShowMessage("退款申请成功", true);
                //            this.BindOrders();
                //        }
                //        else
                //        {
                //            this.ShowMessage("退款失败,", false);
                //        }
                //    }
                //    else
                //    {
                //        this.ShowMessage("您离付款时间已经超过" + OrderRefundTime + "分钟,不能自动退款!", false);
                //    }

                //}
            }

            //删除订单(逻辑删除,放到回收站)
            if (e.CommandName == "LogicDelete")
            {
                int result = TradeHelper.LogicDeleteOrder(orderId, (int)UserStatus.RecycleDelete);
                if (result > 0)
                {
                    this.BindOrders();
                    this.ShowMessage("删除订单成功", true);
                }
                else
                {
                    this.ShowMessage("删除订单失败", false);
                }
            }
        }
Ejemplo n.º 8
0
        protected void listOrders_ItemCommand(object sender, System.Web.UI.WebControls.RepeaterCommandEventArgs e)
        {
            string    orderId   = e.CommandArgument.ToString();
            OrderInfo orderInfo = TradeHelper.GetOrderInfo(orderId);

            if (orderInfo != null)
            {
                if (e.CommandName == "FINISH_TRADE" && orderInfo.CheckAction(OrderActions.SELLER_FINISH_TRADE))
                {
                    if (TradeHelper.ConfirmOrderFinish(orderInfo))
                    {
                        this.BindOrders();
                        this.ShowMessage("成功的完成了该订单", true);
                    }
                    else
                    {
                        this.ShowMessage("完成订单失败", false);
                    }
                }
                if (e.CommandName == "CLOSE_TRADE" && orderInfo.CheckAction(OrderActions.SELLER_CLOSE))
                {
                    // 2015-08-19
                    if (TradeHelper.CloseOrder(orderInfo.OrderId))
                    {
                        Messenger.OrderClosed(HiContext.Current.User, orderInfo, "用户自己关闭订单");
                        this.BindOrders();
                        this.ShowMessage("成功的关闭了该订单", true);
                        return;
                    }
                    this.ShowMessage("关闭订单失败", false);
                }
            }

            //回收站彻底删除订单
            if (e.CommandName == "completeDel")
            {
                int result = TradeHelper.LogicDeleteOrder(orderId, (int)UserStatus.CompleteDelete);
                if (result > 0)
                {
                    this.BindOrders();
                    this.ShowMessage("删除订单成功", true);
                }
                else
                {
                    this.ShowMessage("删除订单失败", false);
                }
            }

            if (e.CommandName == "RevertDel")
            {
                int result = TradeHelper.LogicDeleteOrder(orderId, (int)UserStatus.DefaultStatus);
                if (result > 0)
                {
                    this.BindOrders();
                    this.ShowMessage("还原订单成功", true);
                }
                else
                {
                    this.ShowMessage("还原订单失败", false);
                }
            }
        }