示例#1
0
        /// <summary>
        /// 手机读取订单用户操作
        /// </summary>
        /// <param name="orderID">订单ID</param>
        /// <param name="checkStatus">订单状态</param>
        /// <param name="payKey">支付方式关键字</param>
        /// <returns></returns>
        public static string ReadOrderUserOperate2(int orderID, int orderStatus, string payKey)
        {
            string    result = string.Empty;
            OrderInfo order  = OrderBLL.Read(orderID);

            if (order.IsDelete == (int)BoolType.False)
            {
                switch (orderStatus)
                {
                case (int)OrderStatus.WaitPay:
                    result = "<a href=\"javascript:orderOperate(" + orderID + "," + (int)OrderOperate.Cancle + ")\">取消</a>";
                    if (payKey == "WxPay")
                    {
                        if (RequestHelper.UserAgent() && RequestHelper.IsMicroMessenger())
                        {
                            result += " <a href=\"/Plugins/Pay/WxPay/Pay.aspx?order_id=" + orderID.ToString() + "\" class=\"red\" style=\"background-color:#da251a;color:#fff;\">付款</a>";
                        }
                        else
                        {
                            result += " <a href=\"/mobile/finish.html?ID=" + orderID.ToString() + "\" class=\"red\" style=\"background-color:#da251a;color:#fff;\">付款</a>";
                        }
                    }
                    else
                    {
                        if (PayPlugins.ReadPayPlugins(payKey).IsOnline == (int)BoolType.True)
                        {
                            result += " <a href=\"/Plugins/Pay/" + payKey + "/Pay.aspx?order_id=" + orderID.ToString() + "\" class=\"red\" style=\"background-color:#da251a;color:#fff;\">付款</a>";
                        }
                    }
                    break;

                case (int)OrderStatus.WaitCheck:
                    if (PayPlugins.ReadPayPlugins(payKey).IsOnline != (int)BoolType.True)
                    {
                        result = "<a href=\"javascript:orderOperate(" + orderID + "," + (int)OrderOperate.Cancle + ")\" >取消</a>";
                    }
                    break;

                case (int)OrderStatus.NoEffect:
                case (int)OrderStatus.Shipping:
                    break;

                case (int)OrderStatus.HasShipping:
                    result  = "<a href=\"/mobile/User/ShippingList.html?OrderID=" + orderID + "\" class=\"red\">查看物流</a>";
                    result += "<a href=\"javascript:orderOperate(" + orderID + "," + (int)OrderStatus.HasShipping + ")\">确定收货</a>";
                    break;

                case (int)OrderStatus.ReceiveShipping:
                    result = "<a href=\"/Mobile/user/CommentOrderProduct-O" + orderID + ".html\" >评论</a>";
                    break;

                case (int)OrderStatus.HasReturn:
                    break;

                default:
                    break;
                }
            }
            return(result);
        }
示例#2
0
        public static string ReadOrderUserOperate3(int orderID, int orderStatus, string payKey)
        {
            string    result = string.Empty;
            OrderInfo order  = OrderBLL.Read(orderID);

            if (order.IsDelete == (int)BoolType.False)
            {
                switch (orderStatus)
                {
                case (int)OrderStatus.WaitPay:
                    result = "<a href=\"javascript:orderOperate(" + orderID + "," + (int)OrderOperate.Cancle + ")\">取消</a>";
                    if (payKey == "WxPay")
                    {
                        result += " <a href=\"/Plugins/Pay/WxPay/Pay.aspx?order_id=" + orderID.ToString() + "\" target=\"_blank\"  style=\"display:inline-block;background-color:#da251a;padding:0px 3px;color:#fff;\">付款</a>";
                    }
                    else
                    {
                        if (PayPlugins.ReadPayPlugins(payKey).IsOnline == (int)BoolType.True)
                        {
                            result += " <a href=\"/Plugins/Pay/" + payKey + "/Pay.aspx?order_id=" + orderID.ToString() + "\" target=\"_blank\" style=\"display:inline-block;background-color:#da251a;padding:0px 3px;color:#fff;\">付款</a>";
                        }
                    }
                    break;

                case (int)OrderStatus.WaitCheck:
                    if (PayPlugins.ReadPayPlugins(payKey).IsOnline != (int)BoolType.True)
                    {
                        result = "<a href=\"javascript:orderOperate(" + orderID + "," + (int)OrderOperate.Cancle + ")\" >取消</a>";
                    }
                    break;

                case (int)OrderStatus.NoEffect:
                case (int)OrderStatus.Shipping:
                    break;

                case (int)OrderStatus.HasShipping:
                    result = "<a href=\"javascript:orderOperate(" + orderID + "," + (int)OrderStatus.HasShipping + ")\">确定收货</a>";
                    break;

                case (int)OrderStatus.ReceiveShipping:
                    result = "<a href=\"/Mobile/User/CommentOrderProduct-O" + orderID + ".html\" target\"_blank\">评论</a>";
                    break;

                case (int)OrderStatus.HasReturn:
                    break;

                default:
                    break;
                }
            }
            return(result);
        }
示例#3
0
        /// <summary>
        /// 逻辑删除
        /// </summary>
        /// <param name="ids"></param>
        public static void DeleteLogically(string ids)
        {
            string[] delArr = ids.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            if (delArr.Length > 0)
            {
                foreach (string did in delArr)
                {
                    int id = 0;
                    if (int.TryParse(did, out id))
                    {
                        bool canDel = true;
                        if (OrderDetailBLL.ReadListByProductId(id).Count > 0)
                        {
                            foreach (OrderDetailInfo myOD in OrderDetailBLL.ReadListByProductId(id))
                            {
                                OrderInfo tempOrder = OrderBLL.Read(myOD.OrderId, 0);
                                if (tempOrder.IsDelete == 0)
                                {
                                    canDel = false;
                                    break;
                                }
                            }
                            if (!canDel)
                            {
                                ScriptHelper.Alert("该产品存在相关订单,不能删除。");
                            }
                            else
                            {
                                var product = Read(id);

                                if (product.Id > 0)
                                {
                                    dal.DeleteLogically(id);
                                    CacheHelper.Remove("ProductClass");
                                }
                            }
                        }
                        else
                        {
                            var product = Read(id);

                            if (product.Id > 0)
                            {
                                dal.DeleteLogically(id);
                                CacheHelper.Remove("ProductClass");
                            }
                        }
                    }
                }
            }
        }
示例#4
0
        /// <summary>
        /// 彻底删除
        /// </summary>
        /// <param name="id"></param>
        public static void Delete(int id)
        {
            bool canDel = true;

            if (OrderDetailBLL.ReadListByProductId(id).Count > 0)
            {
                foreach (OrderDetailInfo myOD in OrderDetailBLL.ReadListByProductId(id))
                {
                    OrderInfo tempOrder = OrderBLL.Read(myOD.OrderId, 0);
                    if (tempOrder.IsDelete == 0)
                    {
                        canDel = false;
                        break;
                    }
                }
                if (!canDel)
                {
                    ScriptHelper.Alert("该产品存在相关订单,不能删除。");
                }
                else
                {
                    var product = Read(id);

                    if (product.Id > 0)
                    {
                        UploadBLL.DeleteUploadByRecordID(TableID, id.ToString());
                        dal.Delete(id);
                        ProductPhotoBLL.DeleteList(id, 0);

                        int[] classIds = Array.ConvertAll <string, int>(product.ClassId.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries), k => Convert.ToInt32(k));
                        ProductClassBLL.ChangeProductCount(classIds, ChangeAction.Minus);
                        CacheHelper.Remove("ProductClass");
                    }
                }
            }
            else
            {
                var product = Read(id);

                if (product.Id > 0)
                {
                    UploadBLL.DeleteUploadByRecordID(TableID, id.ToString());
                    dal.Delete(id);
                    ProductPhotoBLL.DeleteList(id, 0);

                    int[] classIds = Array.ConvertAll <string, int>(product.ClassId.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries), k => Convert.ToInt32(k));
                    ProductClassBLL.ChangeProductCount(classIds, ChangeAction.Minus);
                    CacheHelper.Remove("ProductClass");
                }
            }
        }
示例#5
0
        /// <summary>
        /// 逻辑删除--isdelete 置为1
        /// </summary>
        /// <param name="id"></param>
        public static void DeleteLogically(int id)
        {
            bool canDel = true;

            if (OrderDetailBLL.ReadListByProductId(id).Count > 0)
            {
                foreach (OrderDetailInfo myOD in OrderDetailBLL.ReadListByProductId(id))
                {
                    OrderInfo tempOrder = OrderBLL.Read(myOD.OrderId, 0);
                    if (tempOrder.IsDelete == 0)
                    {
                        canDel = false;
                        break;
                    }
                }
                if (!canDel)
                {
                    ScriptHelper.Alert("该产品存在相关订单,不能删除。");
                }
                else
                {
                    var product = Read(id);

                    if (product.Id > 0)
                    {
                        dal.DeleteLogically(id);

                        CacheHelper.Remove("ProductClass");
                    }
                }
            }
            else
            {
                var product = Read(id);

                if (product.Id > 0)
                {
                    dal.DeleteLogically(id);
                }
            }
        }
示例#6
0
        /// <summary>
        /// 读取订单用户操作
        /// </summary>
        /// <param name="orderId">订单ID</param>
        /// <param name="checkStatus">订单状态</param>
        /// <param name="payKey">支付方式关键字</param>
        /// <returns></returns>
        public static string ReadOrderUserOperate(int orderId, int orderStatus, string payKey, int userId)
        {
            string    result = string.Empty;
            OrderInfo order  = OrderBLL.Read(orderId);

            if (order.IsDelete == (int)BoolType.False)
            {
                switch (orderStatus)
                {
                case (int)OrderStatus.WaitPay:
                    if (payKey == "WxPay")
                    {
                        if (RequestHelper.UserAgent() && RequestHelper.IsMicroMessenger())
                        {
                            result += " <a href=\"/Plugins/Pay/WxPay/Pay.aspx?order_id=" + orderId.ToString() + "\" target=\"_blank\" class=\"red\">付款</a>";
                        }
                        else
                        {
                            result += " <a href=\"/finish.html?ID=" + orderId.ToString() + "\" class=\"red\" target=\"_blank\">付款</a>";
                        }
                    }
                    else
                    {
                        if (PayPlugins.ReadPayPlugins(payKey).IsOnline == (int)BoolType.True)
                        {
                            result = " <a href=\"/Plugins/Pay/" + payKey + "/Pay.aspx?order_id=" + orderId.ToString() + "\" target=\"_blank\" class=\"red\">付款</a>";
                        }
                    }
                    result += "<a href=\"javascript:orderOperate(" + orderId + "," + (int)OrderOperate.Cancle + ")\" class=\"red\">取消</a>";
                    break;

                case (int)OrderStatus.WaitCheck:
                    if (PayPlugins.ReadPayPlugins(payKey).IsOnline != (int)BoolType.True)
                    {
                        result = "<a href=\"javascript:orderOperate(" + orderId + "," + (int)OrderOperate.Cancle + ")\"  class=\"red\">取消</a>";
                    }
                    break;

                case (int)OrderStatus.NoEffect:
                case (int)OrderStatus.Shipping:
                    break;

                case (int)OrderStatus.HasShipping:
                    result  = "<a href=\"/User/ShippingList.html?OrderID=" + orderId + "\" class=\"red\">查看物流</a>";
                    result += "   <a href=\"javascript:orderOperate(" + orderId + "," + (int)OrderOperate.Received + ")\" class=\"red\">确定收货</a>";
                    break;

                case (int)OrderStatus.ReceiveShipping:
                    //if (!ProductCommentBLL.HasCommented(orderId, userId))
                    //{
                    //    result = "<a href=\"/user/userproductcommentadd.html?orderid=" + orderId + "\" title=\"订单评价\" class=\"a1\">评价</a>";
                    //}
                    break;

                case (int)OrderStatus.HasReturn:
                    break;

                default:
                    break;
                }
            }
            return(result);
        }
示例#7
0
        /// <summary>
        /// 退款到账户余额及各支付渠道
        /// </summary>
        /// <param name="orderRefund"></param>
        public static void RefundToAnyPay(OrderRefundInfo orderRefund)
        {
            if (orderRefund.Status != (int)OrderRefundStatus.Returning)
            {
                return;
            }

            if (RefundOnline)
            {
                if (PayPlugins.ReadPayPlugins(orderRefund.RefundPayKey).IsOnline == 1 && (OrderBLL.Read(orderRefund.OrderId).AliPayTradeNo.Trim() != string.Empty || OrderBLL.Read(orderRefund.OrderId).WxPayTradeNo.Trim() != string.Empty))//只有在线付款才走线上流程,并且存在支付交易号(支付宝微信任意一个)
                {
                    //退款到各支付渠道
                    //如需退余额,将在第三方支付退款成功后操作
                    //这样做的好处在于保障了余额能够被准确退还。不会出现退了余额,但支付宝或微信因为人为或意外的原因没退成功的情况。
                    if (orderRefund.RefundMoney > 0)
                    {
                        //HttpContext.Current.Response.Redirect(string.Format("/Plugins/Pay/{0}/Refund.aspx?order_refund_id={1}", orderRefund.RefundPayKey, orderRefund.Id));
                        HttpContext.Current.Response.Redirect(string.Format("/Plugins/Pay/{0}/Refund.aspx?order_refund_id={1}&returnurl={2}", orderRefund.RefundPayKey, orderRefund.Id, RefundRedirectUrl));
                    }
                    else
                    {
                        //只需退款到余额
                        //在这里写自己的逻辑
                        if (orderRefund.RefundBalance > 0)
                        {
                            //HttpContext.Current.Response.Redirect(string.Format("/Admin/OrderRefundToBalance.aspx?order_refund_id={0}", orderRefund.Id));
                            HttpContext.Current.Response.Redirect(string.Format("/Admin/OrderRefundToBalance.aspx?order_refund_id={0}&returnurl={1}", orderRefund.Id, RefundRedirectUrl));
                        }
                    }
                }
                else//线下退款则直接更改状态,所以线下退款只能管理员自己审核。
                {
                    orderRefund.Remark   = "退款完成";
                    orderRefund.Status   = (int)OrderRefundStatus.HasReturn;
                    orderRefund.TmRefund = DateTime.Now;
                    OrderRefundBLL.Update(orderRefund);

                    OrderRefundActionBLL.Add(new OrderRefundActionInfo
                    {
                        OrderRefundId = orderRefund.Id,
                        Status        = 1,
                        Tm            = DateTime.Now,
                        UserType      = 2,
                        UserId        = Cookies.Admin.GetAdminID(false),
                        UserName      = Cookies.Admin.GetAdminName(false),
                        Remark        = orderRefund.Remark
                    });
                    #region 发送订单退款成功通知
                    int       isSendNotice  = ShopConfig.ReadConfigInfo().RefundOrder;
                    int       isSendEmail   = ShopConfig.ReadConfigInfo().RefundOrderEmail;
                    int       isSendMessage = ShopConfig.ReadConfigInfo().RefundOrderMsg;
                    string    key           = "RefundOrder";
                    OrderInfo order         = OrderBLL.Read(orderRefund.OrderId);
                    if (isSendNotice == (int)BoolType.True && key != string.Empty)
                    {
                        if (isSendEmail == (int)BoolType.True)
                        {//发邮件
                            try
                            {
                                EmailContentInfo    emailContent    = EmailContentHelper.ReadSystemEmailContent(key);
                                EmailSendRecordInfo emailSendRecord = new EmailSendRecordInfo();
                                emailSendRecord.Title     = emailContent.EmailTitle;
                                emailSendRecord.Content   = emailContent.EmailContent.Replace("$UserName$", order.UserName).Replace("$OrderNumber$", order.OrderNumber).Replace("$PayName$", order.PayName).Replace("$ShippingName$", ShippingBLL.Read(order.ShippingId).Name).Replace("$ShippingNumber$", order.ShippingNumber).Replace("$ShippingDate$", order.ShippingDate.ToString("yyyy-MM-dd"));
                                emailSendRecord.IsSystem  = (int)BoolType.True;
                                emailSendRecord.EmailList = order.Email;
                                emailSendRecord.IsStatisticsOpendEmail = (int)BoolType.False;
                                emailSendRecord.SendStatus             = (int)SendStatus.No;
                                emailSendRecord.AddDate  = RequestHelper.DateNow;
                                emailSendRecord.SendDate = RequestHelper.DateNow;
                                emailSendRecord.ID       = EmailSendRecordBLL.AddEmailSendRecord(emailSendRecord);
                                EmailSendRecordBLL.SendEmail(emailSendRecord);
                                //result = "通知邮件已发送。";
                            }
                            catch
                            {
                                //result = "未发送通知邮件。";
                            }
                        }
                        if (isSendMessage == (int)BoolType.True)
                        {//发短信
                         //result += "未发送通知短信。";
                        }
                    }
                    #endregion
                    if (string.IsNullOrEmpty(RefundRedirectUrl))
                    {
                        HttpContext.Current.Response.Redirect(string.Format("/Admin/OrderRefundAdd.aspx?id={0}", orderRefund.Id));
                    }
                    else
                    {
                        HttpContext.Current.Response.Redirect(RefundRedirectUrl);
                    }
                }
            }
            else
            {
                //处理订单、商品的退款状态,线下退款
                //在这里写自己的逻辑
                HttpContext.Current.Response.Redirect(string.Format("/Admin/OrderRefundToBalance.aspx?order_refund_id={0}&returnurl={1}", orderRefund.Id, RefundRedirectUrl));
            }
        }
示例#8
0
        /// <summary>
        /// 对最终需要提交的退款服务单,做进一步的验证
        /// </summary>
        /// <param name="orderRefund"></param>
        /// <param name="needRefundMoney">本次服务单需退款的金额</param>
        /// <returns></returns>
        public static JWRefundMsg VerifySubmitOrderRefund(OrderRefundInfo orderRefund, decimal needRefundMoney)
        {
            var refundMsg = new JWRefundMsg {
                CanRefund = false
            };

            //退款金额必须大于0
            if (needRefundMoney <= 0)
            {
                refundMsg.ErrorCode = JWRefundErrorCode.REFUND_MONEY_MUST_GT0_ERROR;
                return(refundMsg);
            }

            var order = OrderBLL.Read(orderRefund.OrderId);

            OrderDetailInfo orderDetail = null;

            if (orderRefund.OrderDetailId > 0)
            {
                orderDetail = OrderDetailBLL.Read(orderRefund.OrderDetailId);
            }

            //验证该退款单能否被退款
            refundMsg = CanRefund(order, orderDetail, orderRefund.RefundCount, needRefundMoney);
            if (!refundMsg.CanRefund)
            {
                return(refundMsg);
            }

            orderRefund.OrderNumber   = order.OrderNumber;
            orderRefund.RefundPayKey  = order.PayKey;
            orderRefund.RefundPayName = order.PayName;
            orderRefund.OrderDetailId = orderDetail == null ? 0 : orderDetail.Id;
            orderRefund.OwnerId       = order.UserId;

            /*-----退款金额分配(余额与第三方支付金额) start----------------------------------------------------*/

            //已退余额金额
            var     orderRefundList  = OrderRefundBLL.ReadListValid(orderRefund.OrderId);
            decimal hasRefundBalance = orderRefundList.Sum(k => k.RefundBalance);

            //退商品
            if (orderRefund.OrderDetailId > 0)
            {
                //如果需要退款的金额不大于剩余未退的余额金额,则全部退到余额账户
                if (needRefundMoney <= (order.Balance - hasRefundBalance))
                {
                    orderRefund.RefundBalance = needRefundMoney;
                    orderRefund.RefundMoney   = 0;
                }
                else
                {
                    orderRefund.RefundBalance = (order.Balance - hasRefundBalance);
                    orderRefund.RefundMoney   = needRefundMoney - (order.Balance - hasRefundBalance);
                }
            }
            //退订单
            else
            {
                orderRefund.RefundBalance = (order.Balance - hasRefundBalance);
                orderRefund.RefundMoney   = needRefundMoney - (order.Balance - hasRefundBalance);
            }
            /*-----退款金额分配(余额与第三方支付金额) end------------------------------------------------------*/

            refundMsg.CanRefund = true;
            return(refundMsg);
        }
示例#9
0
        public static void Update(OrderRefundInfo entity)
        {
            dal.Update(entity);

            //服务工单审核不通过,或被取消。回滚在处理的退款的商品数量
            if (entity.Status == (int)OrderRefundStatus.Reject || entity.Status == (int)OrderRefundStatus.Cancel)
            {
                //退商品
                if (entity.OrderDetailId > 0)
                {
                    OrderDetailBLL.ChangeRefundCount(entity.OrderDetailId, entity.RefundCount, ChangeAction.Minus);
                }
                //退订单
                else
                {
                    var orderRefundList = ReadListValid(entity.OrderId);
                    foreach (var orderDetail in OrderDetailBLL.ReadList(entity.OrderId))
                    {
                        //逐一退商品
                        //如果前面有提交过该商品的退款服务单,则不能回滚这个商品的数量(orderDetail.RefundCount - refundCount)
                        int refundCount = orderRefundList.Where(k => k.OrderDetailId == orderDetail.Id).Sum(k => k.RefundCount);
                        OrderDetailBLL.ChangeRefundCount(orderDetail.Id, orderDetail.RefundCount - refundCount, ChangeAction.Minus);
                    }
                }
            }

            //退款完成,更新原订单(商品)的退款状态,库存回滚
            var order = OrderBLL.Read(entity.OrderId);

            if (entity.Status == (int)OrderRefundStatus.HasReturn)
            {
                //退单个商品
                if (entity.OrderDetailId > 0)
                {
                    //计算已退商品总数是否与订单商品总数相同,如相同则更改订单状态
                    var orderRefundList = ReadList(entity.OrderId);
                    orderRefundList = orderRefundList.Where(k => k.Status == (int)OrderRefundStatus.HasReturn).ToList();
                    var orderDetailList = OrderDetailBLL.ReadList(entity.OrderId);

                    if (orderRefundList.Sum(k => k.RefundCount) == orderDetailList.Sum(k => k.BuyCount))
                    {
                        UpdateOrderRefundStatus(order);
                    }

                    //库存回滚
                    var orderDetail = OrderDetailBLL.Read(entity.OrderDetailId);
                    ProductBLL.ChangeOrderCount(orderDetail.ProductId, -orderDetail.RefundCount);
                    if (!string.IsNullOrEmpty(orderDetail.StandardValueList))
                    {
                        ProductTypeStandardRecordBLL.ChangeOrderCount(orderDetail.ProductId, orderDetail.StandardValueList, orderDetail.RefundCount, ChangeAction.Minus);
                    }

                    if (order.OrderStatus >= (int)OrderStatus.HasShipping)
                    {
                        ProductBLL.ChangeSendCount(orderDetail.ProductId, -orderDetail.RefundCount);
                        if (!string.IsNullOrEmpty(orderDetail.StandardValueList))
                        {
                            ProductTypeStandardRecordBLL.ChangeSendCount(orderDetail.ProductId, orderDetail.StandardValueList, orderDetail.RefundCount, ChangeAction.Minus);
                        }
                    }
                }
                //退订单
                else
                {
                    UpdateOrderRefundStatus(order);

                    //库存回滚
                    var orderRefundList = ReadListValid(entity.OrderId);
                    foreach (var orderDetail in OrderDetailBLL.ReadList(entity.OrderId))
                    {
                        //逐一处理
                        //如果前面有提交过该商品的退款服务单,则不能回滚这个商品的数量
                        int refundCount = orderRefundList.Where(k => k.OrderDetailId == orderDetail.Id).Sum(k => k.RefundCount);
                        int buyCount    = orderDetail.BuyCount - refundCount;
                        if (buyCount > 0)
                        {
                            ProductBLL.ChangeOrderCount(orderDetail.ProductId, -buyCount);
                            if (!string.IsNullOrEmpty(orderDetail.StandardValueList))
                            {
                                ProductTypeStandardRecordBLL.ChangeOrderCount(orderDetail.ProductId, orderDetail.StandardValueList, buyCount, ChangeAction.Minus);
                            }

                            if (order.OrderStatus >= (int)OrderStatus.HasShipping)
                            {
                                ProductBLL.ChangeSendCount(orderDetail.ProductId, -buyCount);
                                if (!string.IsNullOrEmpty(orderDetail.StandardValueList))
                                {
                                    ProductTypeStandardRecordBLL.ChangeSendCount(orderDetail.ProductId, orderDetail.StandardValueList, buyCount, ChangeAction.Minus);
                                }
                            }
                        }
                    }
                }
            }
        }