Ejemplo n.º 1
0
        public OrderItemInfo Infos(int key)
        {
            var result = new OrderItemInfo();
            var entity = GetEntityByKeyNotNull(key);

            this.ProcessEntity(() =>
            {
                result.ItemsCanBeAddedToShipmentCount = entity.GetItemsCanBeAddedToShipmentCount();
                result.ShipmentItemsCount             = entity.GetShipmentItemsCount();
                result.DispatchedItemsCount           = entity.GetDispatchedItemsCount();
                result.NotDispatchedItemsCount        = entity.GetNotDispatchedItemsCount();
                result.DeliveredItemsCount            = entity.GetDeliveredItemsCount();
                result.NotDeliveredItemsCount         = entity.GetNotDeliveredItemsCount();
            });

            return(result);
        }
Ejemplo n.º 2
0
        public IList <OrderItemInfo> GetList(int pageIndex, int pageSize, out int totalRecords, string sqlWhere, params SqlParameter[] cmdParms)
        {
            string cmdText = @"select count(*) from OrderItem ";

            if (!string.IsNullOrEmpty(sqlWhere))
            {
                cmdText += " where 1=1 " + sqlWhere;
            }
            totalRecords = (int)SqlHelper.ExecuteScalar(SqlHelper.SqlProviderConnString, CommandType.Text, cmdText, cmdParms);

            int startIndex = (pageIndex - 1) * pageSize + 1;
            int endIndex   = pageIndex * pageSize;

            cmdText = @"select * from(select row_number() over(order by LastUpdatedDate desc) as RowNumber,
			          OrderId,LineNum,ProductId,Price,Quantity
					  from OrderItem "                    ;
            if (!string.IsNullOrEmpty(sqlWhere))
            {
                cmdText += "where 1=1 " + sqlWhere;
            }
            cmdText += ")as objTable where RowNumber between " + startIndex + " and " + endIndex + " ";

            IList <OrderItemInfo> list = new List <OrderItemInfo>();

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.SqlProviderConnString, CommandType.Text, cmdText, cmdParms))
            {
                if (reader != null && reader.HasRows)
                {
                    while (reader.Read())
                    {
                        OrderItemInfo model = new OrderItemInfo();
                        model.OrderId   = reader.GetGuid(1);
                        model.LineNum   = reader.GetString(2);
                        model.ProductId = reader.GetGuid(3);
                        model.Price     = reader.GetDecimal(4);
                        model.Quantity  = reader.GetInt32(5);

                        list.Add(model);
                    }
                }
            }

            return(list);
        }
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            View view          = inflater.Inflate(Resource.Layout.certificates, container, false);
            var  TitleTextView = view.FindViewById <TextView>(Resource.Id.TitleTextView);

            TitleTextView.Text       = "CONTPAQI® 500 TIMBRES - PAQUETE(PDTIM500)";
            CertificatesRecyclerView = view.FindViewById <RecyclerView>(Resource.Id.CertificatesRecyclerView);
            var closeImageView = view.FindViewById <ImageView>(Resource.Id.closeImageView);

            closeImageView.Click += delegate
            {
                // this.FragmentManager.BeginTransaction().Remove(this).Commit();
                activity.OnBackPressed();
            };



            detail             = new OrderItemInfo();
            detail.ProductName = "";
            detail.Sku         = "";
            detail.Quantity    = 3;
            detail.UnitPrice   = 0;
            detail.Total       = 3333;

            var item = new OrderItemLicenseInfo();

            item.Serie          = "29DC0B941FD0D173";
            item.Lote           = "190313-01-0001";
            item.UrlCertificate = "Certificado";
            detail.Licenses.Add(item);

            GridLayoutManager manager = new GridLayoutManager(this.Context, 1);

            CertificatesRecyclerView.SetLayoutManager(manager);

            CertificateAdapter mAdapterCertificates = new CertificateAdapter(detail);

            mAdapterCertificates.ItemClick += MAdapter_ItemClick;
            CertificatesRecyclerView.SetAdapter(mAdapterCertificates);

            return(view);
        }
Ejemplo n.º 4
0
        public void AddComment(ProductCommentInfo model)
        {
            OrderItemInfo orderItemInfo = (
                from a in context.OrderItemInfo
                where a.Id == model.SubOrderId && a.OrderInfo.UserId == model.UserId
                select a).FirstOrDefault();

            if (orderItemInfo == null)
            {
                throw new HimallException("不能对此产品进行评价!");
            }
            model.ShopId    = orderItemInfo.ShopId;
            model.ProductId = orderItemInfo.ProductId;
            model.ShopName  = (
                from a in context.ShopInfo
                where a.Id == orderItemInfo.ShopId
                select a.ShopName).FirstOrDefault();
            context.ProductCommentInfo.Add(model);
            context.SaveChanges();
        }
Ejemplo n.º 5
0
        public int Insert(OrderItemInfo model)
        {
            string cmdText = @"insert into OrderItem (LineNum,ProductId,Price,Quantity)
			                 values
							 (@LineNum,@ProductId,@Price,@Quantity)
			                 "            ;

            SqlParameter[] parms =
            {
                new SqlParameter("@LineNum",   SqlDbType.Char,              12),
                new SqlParameter("@ProductId", SqlDbType.UniqueIdentifier),
                new SqlParameter("@Price",     SqlDbType.Decimal),
                new SqlParameter("@Quantity",  SqlDbType.Int)
            };
            parms[0].Value = model.LineNum;
            parms[1].Value = model.ProductId;
            parms[2].Value = model.Price;
            parms[3].Value = model.Quantity;

            return(SqlHelper.ExecuteNonQuery(SqlHelper.SqlProviderConnString, CommandType.Text, cmdText, parms));
        }
Ejemplo n.º 6
0
        public int Update(OrderItemInfo model)
        {
            string cmdText = @"update OrderItem set LineNum = @LineNum,ProductId = @ProductId,Price = @Price,Quantity = @Quantity 
			                 where OrderId = @OrderId"            ;

            SqlParameter[] parms =
            {
                new SqlParameter("@OrderId",   SqlDbType.UniqueIdentifier),
                new SqlParameter("@LineNum",   SqlDbType.Char, 12),
                new SqlParameter("@ProductId", SqlDbType.UniqueIdentifier),
                new SqlParameter("@Price",     SqlDbType.Decimal),
                new SqlParameter("@Quantity",  SqlDbType.Int)
            };
            parms[0].Value = model.OrderId;
            parms[1].Value = model.LineNum;
            parms[2].Value = model.ProductId;
            parms[3].Value = model.Price;
            parms[4].Value = model.Quantity;

            return(SqlHelper.ExecuteNonQuery(SqlHelper.SqlProviderConnString, CommandType.Text, cmdText, parms));
        }
Ejemplo n.º 7
0
        public OrderItemInfo GetOrderItemInfo(int orderId)
        {
            OrderItemInfo info = new OrderItemInfo();

            if (!this.IsNull)
            {
                info.ProductName = this.ProductName;
                if (this.isPresent)
                {
                    info.ProductId = this.Id;
                }
                else
                {
                    info.ProductId = this.ProductId;
                }
                info.TableName        = this.TableName;
                info.Unit             = this.Unit;
                info.Amount           = this.Amount;
                info.PriceMarket      = this.PriceMarket;
                info.Price            = this.Price;
                info.TruePrice        = this.Price;
                info.ServiceTerm      = this.ServiceTerm;
                info.ServiceTermUnit  = this.ServiceTermUnit;
                info.Remark           = this.Remark;
                info.BeginDate        = this.BeginDate;
                info.PresentExp       = this.PresentExp;
                info.PresentMoney     = this.PresentMoney;
                info.PresentPoint     = this.PresentPoint;
                info.ProductKind      = this.ProductKind;
                info.SubTotal         = this.SubTotal;
                info.SaleType         = this.SaleType;
                info.OrderId          = orderId;
                info.Property         = this.Property;
                info.ProductCharacter = this.ProductCharacter;
                info.Weight           = this.TotalWeight;
            }
            return(info);
        }
Ejemplo n.º 8
0
        public string PlaceOrder(string productPriceId)
        {
            if (string.IsNullOrWhiteSpace(productPriceId))
            {
                throw new APIException("OrderItemId parameter cannot be empty");
            }

            OrderItemInfo oi = new OrderItemInfo()
            {
                ProductPriceId = productPriceId
            };

            var basket = Order.GetMemberBasket();

            basket.RemoveAllItems();
            basket.AddItem(oi);

            if (basket.TotalPrice == 0)
            {
                throw new APIException("Order total price must be bigger than zero");
            }

            var reseller = Provider.CurrentMember.GetAdminResellerMember();

            if (reseller == null)
            {
                throw new APIException("Reseller undefined! (This Member's ClientId should have an AdminMemberId)");
            }

            if (reseller.CreditBalance < basket.TotalPrice)
            {
                throw new APIException("Insufficient credits");
            }

            var order = CreateOrderFromBasket("");

            return(order.Items[0].Id);
        }
    /// <summary>
    /// Checks if order contains e-product or membership product. If so generates a confirmation message.
    /// </summary>
    private string GetConfirmationMessage()
    {
        // Get order items for this order
        DataSet orderItems = OrderItemInfoProvider.GetOrderItems(Order.OrderID);

        foreach (DataRow orderItemRow in orderItems.Tables[0].Rows)
        {
            // Get order item
            var item = new OrderItemInfo(orderItemRow);

            if (item.OrderItemSKU != null)
            {
                switch (item.OrderItemSKU.SKUProductType)
                {
                    // If order item represents membership
                    case SKUProductTypeEnum.Membership:
                        showMembershipWarning = true;
                        break;

                    // If order item represents e-product
                    case SKUProductTypeEnum.EProduct:
                        showEproductWarning = true;
                        break;
                }
            }
        }

        // If one of the rollback warnings should be shown
        if (showEproductWarning || showMembershipWarning)
        {
            // Set standard warning message
            string paidUncheckWarning = GetString("order_edit_billing.orderispaiduncheckwarning");

            // Add memberships rollback warning message if required
            if (showMembershipWarning)
            {
                paidUncheckWarning += "\\n\\n- " + GetString("order_edit_billing.orderispaiduncheckwarningmemberships");
            }

            // Add e-products rollback warning message if required
            if (showEproductWarning)
            {
                paidUncheckWarning += "\\n\\n- " + GetString("order_edit_billing.orderispaiduncheckwarningeproducts");
            }

            return paidUncheckWarning;
        }

        return "";
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        string errorMessage = null;

        // Get order item SKU file
        OrderItemSKUFileInfo oiskufi = OrderItemSKUFileInfoProvider.GetOrderItemSKUFileInfo(token);

        if (oiskufi != null)
        {
            // Get parent order item
            OrderItemInfo oii = OrderItemInfoProvider.GetOrderItemInfo(oiskufi.OrderItemID);

            if (oii != null)
            {
                // If download is not expired
                if ((oii.OrderItemValidTo.CompareTo(DateTimeHelper.ZERO_TIME) == 0) || (oii.OrderItemValidTo.CompareTo(DateTime.Now) > 0))
                {
                    // Get SKU file
                    SKUFileInfo skufi = SKUFileInfoProvider.GetSKUFileInfo(oiskufi.FileID);

                    if (skufi != null)
                    {
                        // Decide how to process the file based on file type
                        switch (skufi.FileType.ToLowerCSafe())
                        {
                        case "metafile":
                            // Set parameters to current context
                            Context.Items["fileguid"]    = skufi.FileMetaFileGUID;
                            Context.Items["disposition"] = "attachment";

                            // Perform server side redirect to download
                            Response.Clear();
                            Server.Transfer(URLHelper.ResolveUrl("~/CMSPages/GetMetaFile.aspx"));
                            Response.End();
                            return;
                        }
                    }
                }
                else
                {
                    // Set error message
                    errorMessage = ResHelper.GetString("getproductfile.expirederror");
                }
            }
        }

        // If error message not set
        if (String.IsNullOrEmpty(errorMessage))
        {
            // Set default error message
            errorMessage = ResHelper.GetString("getproductfile.existerror");
        }

        // Set error message to current context
        Context.Items["title"] = ResHelper.GetString("getproductfile.error");
        Context.Items["text"]  = errorMessage;

        // Perform server side redirect to error page
        Response.Clear();
        Server.Transfer(URLHelper.ResolveUrl("~/CMSMessages/Error.aspx"));
        Response.End();
    }
        /// <summary>
        /// 获取申请售后的信息
        /// </summary>
        /// <param name="id">订单ID</param>
        /// <param name="itemId">子订单ID</param>
        /// <returns></returns>
        public object GetOrderRefundModel(long id, long?itemId = null, long?refundId = null)
        {
            CheckUserLogin();
            try
            {
                dynamic d         = new System.Dynamic.ExpandoObject();
                var     ordser    = ServiceProvider.Instance <IOrderService> .Create;
                var     refundser = ServiceProvider.Instance <IRefundService> .Create;

                var order = ordser.GetOrder(id, CurrentUser.Id);
                if (order == null)
                {
                    throw new Himall.Core.HimallException("该订单已删除或不属于该用户");
                }
                if ((int)order.OrderStatus < 2)
                {
                    throw new Himall.Core.HimallException("错误的售后申请,订单状态有误");
                }
                if (itemId == null && order.OrderStatus != OrderInfo.OrderOperateStatus.WaitDelivery && order.OrderStatus != OrderInfo.OrderOperateStatus.WaitSelfPickUp)
                {
                    throw new Himall.Core.HimallException("错误的订单退款申请,订单状态有误");
                }
                //计算可退金额 预留
                ordser.CalculateOrderItemRefund(id);

                OrderRefundModel refundModel = new OrderRefundModel();
                OrderItemInfo    item        = new OrderItemInfo();
                refundModel.MaxRGDNumber    = 0;
                refundModel.MaxRefundAmount = order.OrderEnabledRefundAmount;
                if (itemId == null)
                {
                    item = order.OrderItemInfo.FirstOrDefault();
                }
                else
                {
                    item = order.OrderItemInfo.Where(a => a.Id == itemId).FirstOrDefault();
                    refundModel.MaxRGDNumber    = item.Quantity - item.ReturnQuantity;
                    refundModel.MaxRefundAmount = (decimal)(item.EnabledRefundAmount - item.RefundPrice);
                }

                bool isCanApply = false;

                if (order.OrderStatus == OrderInfo.OrderOperateStatus.WaitDelivery)
                {
                    isCanApply = refundser.CanApplyRefund(id, item.Id);
                }
                else
                {
                    isCanApply = refundser.CanApplyRefund(id, item.Id, false);
                }

                if (!refundId.HasValue)
                {
                    if (!isCanApply)
                    {
                        throw new Himall.Core.HimallException("您已申请过售后,不可重复申请");
                    }
                    d.ContactPerson    = CurrentUser.RealName;
                    d.ContactCellPhone = CurrentUser.CellPhone;
                    d.OrderItemId      = itemId;
                    d.RefundType       = 0;
                    d.IsRefundOrder    = false;
                    if (!itemId.HasValue)
                    {
                        d.IsRefundOrder = true;
                        d.RefundType    = 1;
                    }
                    var reasonlist = refundser.GetRefundReasons();
                    d.Id               = order.Id;
                    d.MaxRGDNumber     = refundModel.MaxRGDNumber;
                    d.MaxRefundAmount  = refundModel.MaxRefundAmount;
                    d.OrderStatus      = order.OrderStatus.ToDescription();
                    d.OrderStatusValue = (int)order.OrderStatus;
                    d.BackOut          = false;
                    d.RefundReasons    = reasonlist;
                    if (order.CanBackOut())
                    {
                        d.BackOut = true;
                    }
                }
                else
                {
                    var refunddata = refundser.GetOrderRefund(refundId.Value, CurrentUser.Id);
                    if (refunddata == null)
                    {
                        throw new Himall.Core.HimallException("错误的售后数据");
                    }
                    if (refunddata.SellerAuditStatus != OrderRefundInfo.OrderRefundAuditStatus.UnAudit)
                    {
                        throw new Himall.Core.HimallException("错误的售后状态,不可激活");
                    }
                    d.ContactPerson    = refunddata.ContactPerson;
                    d.ContactCellPhone = refunddata.ContactCellPhone;
                    d.OrderItemId      = refunddata.OrderItemId;
                    d.IsRefundOrder    = (refunddata.RefundMode == OrderRefundInfo.OrderRefundMode.OrderRefund);
                    d.RefundType       = (refunddata.RefundMode == OrderRefundInfo.OrderRefundMode.OrderRefund ? 1 : 0);
                    var reasonlist = refundser.GetRefundReasons();
                    d.RefundReasons    = reasonlist; //理由List
                    d.Id               = id;
                    d.MaxRGDNumber     = refundModel.MaxRGDNumber;
                    d.MaxRefundAmount  = refundModel.MaxRefundAmount;
                    d.OrderStatus      = order.OrderStatus.ToDescription();
                    d.OrderStatusValue = (int)order.OrderStatus;
                    d.BackOut          = false;
                    if (order.CanBackOut())
                    {
                        d.BackOut = true;
                    }
                }

                if (!d.IsRefundOrder && item.EnabledRefundAmount.HasValue)
                {
                    d.RefundGoodsPrice = item.EnabledRefundAmount.Value / item.Quantity;
                }
                return(Json(new { Success = true, RefundMode = d }));
            }
            catch (HimallException himallex)
            {
                return(Json(new { Success = false, Msg = himallex.Message }));
            }
            catch (Exception ex)
            {
                return(Json(new { Success = false, Msg = "系统异常:" + ex.Message }));
            }
        }
Ejemplo n.º 12
0
        // GET: Web/OrderRefund
        /// <summary>
        /// 退款申请
        /// </summary>
        /// <param name="id"></param>
        /// <param name="itemId"></param>
        /// <returns></returns>
        public ActionResult RefundApply(long orderid, long?itemId, long?refundid)
        {
            Mall.Web.Areas.Web.Models.RefundApplyModel model = new Mall.Web.Areas.Web.Models.RefundApplyModel();
            model.RefundMode  = null;
            model.OrderItemId = null;
            var                ordser       = ServiceApplication.Create <IOrderService>();
            var                order        = ordser.GetOrder(orderid, CurrentUser.Id);
            string             errormsg     = "";
            string             jumpurl      = "/" + ViewBag.AreaName + "/Member/Center";
            bool               isok         = true;
            VirtualProductInfo vProductInfo = null;

            if (isok)
            {
                if (order == null)
                {
                    isok     = false;
                    errormsg = "该订单已删除或不属于该用户";
                    return(Redirect(jumpurl));

                    throw new Mall.Core.MallException("该订单已删除或不属于该用户");
                }
            }

            if (isok)
            {
                if (order.OrderType != OrderInfo.OrderTypes.Virtual && (int)order.OrderStatus < 2)
                {
                    isok     = false;
                    errormsg = "错误的售后申请,订单状态有误";
                    return(Redirect(jumpurl));

                    throw new Mall.Core.MallException("错误的售后申请,订单状态有误");
                }
                if (order.OrderType == OrderInfo.OrderTypes.Virtual)
                {
                    //如果为虚拟商品,则要判断该商品是否允许退款,且该订单中是否至少有一个待核销的核销码
                    var orderItemInfo = OrderApplication.GetOrderItemsByOrderId(order.Id).FirstOrDefault();
                    if (orderItemInfo != null)
                    {
                        itemId = orderItemInfo.Id;
                        var virtualProductInfo = ProductManagerApplication.GetVirtualProductInfoByProductId(orderItemInfo.ProductId);
                        if (virtualProductInfo != null)
                        {
                            if (virtualProductInfo.SupportRefundType == 3)
                            {
                                isok     = false;
                                errormsg = "该商品不支持退款";
                                return(Redirect(jumpurl));

                                throw new Mall.Core.MallException("该商品不支持退款");
                            }
                            if (virtualProductInfo.SupportRefundType == 1 && DateTime.Now > virtualProductInfo.EndDate.Value)
                            {
                                throw new Mall.Core.MallException("该商品不支持过期退款");
                            }
                            var orderVerificationCodes = OrderApplication.GetOrderVerificationCodeInfosByOrderIds(new List <long>()
                            {
                                order.Id
                            });
                            long num = orderVerificationCodes.Where(a => a.Status == OrderInfo.VerificationCodeStatus.WaitVerification).Count();
                            if (num == 0)
                            {
                                isok     = false;
                                errormsg = "该商品没有可退的核销码";
                                return(Redirect(jumpurl));

                                throw new Mall.Core.MallException("该商品没有可退的核销码");
                            }
                            vProductInfo = virtualProductInfo;
                        }
                    }
                }
            }

            if (isok)
            {
                if (order.OrderType != OrderInfo.OrderTypes.Virtual)
                {
                    if (itemId == null && order.OrderStatus != Entities.OrderInfo.OrderOperateStatus.WaitDelivery && order.OrderStatus != Entities.OrderInfo.OrderOperateStatus.WaitSelfPickUp)
                    {
                        isok     = false;
                        errormsg = "错误的订单退款申请,订单状态有误";
                        return(Redirect(jumpurl));

                        throw new Mall.Core.MallException("错误的订单退款申请,订单状态有误");
                    }
                }
            }

            if (isok)
            {
                if (order.OrderType != OrderInfo.OrderTypes.Virtual)
                {
                    //售后时间限制
                    if (_iOrderService.IsRefundTimeOut(orderid))
                    {
                        isok     = false;
                        errormsg = "订单已超过售后期";
                        return(Redirect(jumpurl));

                        throw new Mall.Core.MallException("订单已超过售后期");
                    }
                }
            }

            if (isok)
            {
                //计算可退金额 预留
                ordser.CalculateOrderItemRefund(orderid);

                var item = new OrderItemInfo();
                model.MaxRefundGoodsNumber = 0;
                model.MaxRefundAmount      = order.OrderEnabledRefundAmount;
                if (itemId == null)
                {
                    model.OrderItems = _iOrderService.GetOrderItemsByOrderId(order.Id);
                }
                else
                {
                    item = _iOrderService.GetOrderItem(itemId.Value);
                    model.OrderItems.Add(item);
                    model.MaxRefundGoodsNumber = item.Quantity - item.ReturnQuantity;
                    model.MaxRefundAmount      = item.EnabledRefundAmount - item.RefundPrice;
                }
                if (!model.MaxRefundAmount.HasValue)
                {
                    model.MaxRefundAmount = 0;
                }
                if (order.OrderType == OrderInfo.OrderTypes.Virtual)
                {
                    var count = OrderApplication.GetOrderVerificationCodeInfosByOrderIds(new List <long>()
                    {
                        order.Id
                    }).Where(a => a.Status != OrderInfo.VerificationCodeStatus.WaitVerification).ToList().Count;
                    if (item.EnabledRefundAmount.HasValue)
                    {
                        decimal price = item.EnabledRefundAmount.Value / item.Quantity;
                        model.MaxRefundAmount = item.EnabledRefundAmount.Value - Math.Round(count * price, 2, MidpointRounding.AwayFromZero);
                    }
                }
                bool isCanApply = false;
                var  refundser  = _iRefundService;
                Entities.OrderRefundInfo refunddata;

                if (order.OrderStatus == Entities.OrderInfo.OrderOperateStatus.WaitDelivery)
                {
                    isCanApply = refundser.CanApplyRefund(orderid, item.Id);
                }
                else
                {
                    isCanApply = refundser.CanApplyRefund(orderid, item.Id, false);
                }
                if (!refundid.HasValue)
                {
                    if (!isCanApply)
                    {
                        isok     = false;
                        errormsg = "您已申请过售后,不可重复申请";
                        return(Redirect(jumpurl));

                        throw new Mall.Core.MallException("您已申请过售后,不可重复申请");
                    }

                    //model.ContactPerson = CurrentUser.RealName;
                    //model.ContactCellPhone = CurrentUser.CellPhone;
                    // model.ContactCellPhone = order.CellPhone;

                    model.ContactPerson    = string.IsNullOrEmpty(order.ShipTo) ? CurrentUser.RealName : order.ShipTo;
                    model.ContactCellPhone = string.IsNullOrEmpty(order.CellPhone) ? CurrentUser.CellPhone : order.CellPhone;

                    model.OrderItemId = itemId;
                    if (!model.OrderItemId.HasValue)
                    {
                        model.IsOrderAllRefund = true;
                        model.RefundMode       = Entities.OrderRefundInfo.OrderRefundMode.OrderRefund;
                    }
                }
                else
                {
                    refunddata = refundser.GetOrderRefund(refundid.Value, CurrentUser.Id);
                    if (refunddata == null)
                    {
                        isok     = false;
                        errormsg = "错误的售后数据";
                        return(Redirect(jumpurl));

                        throw new Mall.Core.MallException("错误的售后数据");
                    }
                    if (isok)
                    {
                        if (order.OrderType != OrderInfo.OrderTypes.Virtual)
                        {
                            if (refunddata.SellerAuditStatus != Entities.OrderRefundInfo.OrderRefundAuditStatus.UnAudit)
                            {
                                isok     = false;
                                errormsg = "错误的售后状态,不可激活";
                                return(Redirect(jumpurl));

                                throw new Mall.Core.MallException("错误的售后状态,不可激活");
                            }
                        }
                    }
                    if (isok)
                    {
                        model.ContactPerson     = refunddata.ContactPerson;
                        model.ContactCellPhone  = refunddata.ContactCellPhone;
                        model.OrderItemId       = refunddata.OrderItemId;
                        model.IsOrderAllRefund  = (refunddata.RefundMode == Entities.OrderRefundInfo.OrderRefundMode.OrderRefund);
                        model.RefundMode        = refunddata.RefundMode;
                        model.RefundReasonValue = refunddata.Reason;
                        model.RefundWayValue    = refunddata.RefundPayType;
                        model.CertPic1          = refunddata.CertPic1;
                        model.CertPic2          = refunddata.CertPic2;
                        model.CertPic3          = refunddata.CertPic3;
                    }
                }
                if (!model.IsOrderAllRefund && item.EnabledRefundAmount.HasValue)
                {
                    model.RefundGoodsPrice = item.EnabledRefundAmount.Value / item.Quantity;
                }

                if (isok)
                {
                    model.OrderInfo = order;
                    model.OrderId   = orderid;
                    model.RefundId  = refundid;

                    var reasons = refundser.GetRefundReasons();
                    foreach (var _ir in reasons)
                    {
                        _ir.AfterSalesText = _ir.AfterSalesText.Trim();
                    }
                    List <SelectListItem> reasel = new List <SelectListItem>();
                    SelectListItem        _tmpsel;
                    _tmpsel = new SelectListItem {
                        Text = "选择售后理由", Value = ""
                    };
                    //reasel.Add(_tmpsel);
                    foreach (var _i in reasons)
                    {
                        _tmpsel = new SelectListItem {
                            Text = _i.AfterSalesText, Value = _i.AfterSalesText
                        };
                        if (!string.IsNullOrWhiteSpace(model.RefundReasonValue))
                        {
                            if (_i.AfterSalesText == model.RefundReasonValue)
                            {
                                _tmpsel.Selected = true;
                            }
                        }
                        reasel.Add(_tmpsel);
                    }
                    model.RefundReasons = reasel;

                    List <SelectListItem> list = new List <SelectListItem> {
                        new SelectListItem {
                            Text  = OrderRefundInfo.OrderRefundPayType.BackCapital.ToDescription(),
                            Value = ((int)OrderRefundInfo.OrderRefundPayType.BackCapital).ToString()
                        }
                    };
                    if (order.CanBackOut())
                    {
                        _tmpsel = new SelectListItem
                        {
                            Text  = OrderRefundInfo.OrderRefundPayType.BackOut.ToDescription(),
                            Value = ((int)OrderRefundInfo.OrderRefundPayType.BackOut).ToString()
                        };
                        //if (model.RefundWayValue.HasValue)
                        //{
                        //    if (_tmpsel.Value == model.RefundWayValue.ToString())
                        //    {
                        //        _tmpsel.Selected = true;
                        //    }
                        //}
                        _tmpsel.Selected = true;  //若订单支付方式为支付宝、微信支付则退款方式默认选中“退款原路返回”
                        list.Add(_tmpsel);
                        model.BackOut = 1;
                    }
                    model.RefundWay = list;
                }
                if (order.DeliveryType == DeliveryType.SelfTake)
                {
                    var shopBranch = ShopBranchApplication.GetShopBranchById(order.ShopBranchId);
                    model.ReturnGoodsAddress  = RegionApplication.GetFullName(shopBranch.AddressId);
                    model.ReturnGoodsAddress += " " + shopBranch.AddressDetail;
                    model.ReturnGoodsAddress += " " + shopBranch.ContactPhone;
                }
            }
            ViewBag.errormsg = errormsg;
            #region 虚拟订单退款
            ViewBag.orderVerificationCode = OrderApplication.GetOrderVerificationCodeInfosByOrderIds(new List <long>()
            {
                order.Id
            }).Where(a => a.Status == OrderInfo.VerificationCodeStatus.WaitVerification).ToList();
            #endregion
            ViewBag.IsVirtual          = order.OrderType == OrderInfo.OrderTypes.Virtual ? 1 : 0;
            ViewBag.VirtualProductInfo = vProductInfo;
            return(View(model));
        }
Ejemplo n.º 13
0
        // GET: Web/OrderRefund
        /// <summary>
        /// 退款申请
        /// </summary>
        /// <param name="id"></param>
        /// <param name="itemId"></param>
        /// <returns></returns>
        public ActionResult RefundApply(long orderid, long?itemId, long?refundid)
        {
            Himall.Web.Areas.Web.Models.RefundApplyModel model = new Himall.Web.Areas.Web.Models.RefundApplyModel();
            model.RefundMode  = null;
            model.OrderItemId = null;
            var    ordser   = ServiceHelper.Create <IOrderService>();
            var    order    = ordser.GetOrder(orderid, CurrentUser.Id);
            string errormsg = "";
            string jumpurl  = "/" + ViewBag.AreaName + "/Member/Center";
            bool   isok     = true;

            if (isok)
            {
                if (order == null)
                {
                    isok     = false;
                    errormsg = "该预约单已删除或不属于该用户";
                    return(Redirect(jumpurl));

                    throw new Himall.Core.HimallException("该预约单已删除或不属于该用户");
                }
            }

            if (isok)
            {
                if ((int)order.OrderStatus < 2)
                {
                    isok     = false;
                    errormsg = "错误的售后申请,预约单状态有误";
                    return(Redirect(jumpurl));

                    throw new Himall.Core.HimallException("错误的售后申请,预约单状态有误");
                }
            }

            if (isok)
            {
                if (itemId == null && order.OrderStatus != OrderInfo.OrderOperateStatus.WaitDelivery && order.OrderStatus != OrderInfo.OrderOperateStatus.WaitSelfPickUp)
                {
                    isok     = false;
                    errormsg = "错误的预约单退款申请,预约单状态有误";
                    return(Redirect(jumpurl));

                    throw new Himall.Core.HimallException("错误的预约单退款申请,预约单状态有误");
                }
            }

            if (isok)
            {
                //售后时间限制
                if (_iOrderService.IsRefundTimeOut(orderid))
                {
                    isok     = false;
                    errormsg = "预约单已超过售后期";
                    return(Redirect(jumpurl));

                    throw new Himall.Core.HimallException("预约单已超过售后期");
                }
            }

            if (isok)
            {
                //计算可退金额 预留
                ordser.CalculateOrderItemRefund(orderid);

                OrderItemInfo item = new OrderItemInfo();
                model.MaxRefundGoodsNumber = 0;
                model.MaxRefundAmount      = order.OrderEnabledRefundAmount;
                if (itemId == null)
                {
                    model.OrderItems = order.OrderItemInfo.ToList();
                }
                else
                {
                    item = order.OrderItemInfo.Where(a => a.Id == itemId).FirstOrDefault();
                    model.OrderItems.Add(item);
                    model.MaxRefundGoodsNumber = item.Quantity - item.ReturnQuantity;
                    model.MaxRefundAmount      = item.EnabledRefundAmount - item.RefundPrice;
                }
                if (!model.MaxRefundAmount.HasValue)
                {
                    model.MaxRefundAmount = 0;
                }
                bool            isCanApply = false;
                var             refundser  = _iRefundService;
                OrderRefundInfo refunddata;

                if (order.OrderStatus == OrderInfo.OrderOperateStatus.WaitDelivery)
                {
                    isCanApply = refundser.CanApplyRefund(orderid, item.Id);
                }
                else
                {
                    isCanApply = refundser.CanApplyRefund(orderid, item.Id, false);
                }
                if (!refundid.HasValue)
                {
                    if (!isCanApply)
                    {
                        isok     = false;
                        errormsg = "您已申请过售后,不可重复申请";
                        return(Redirect(jumpurl));

                        throw new Himall.Core.HimallException("您已申请过售后,不可重复申请");
                    }

                    model.ContactPerson    = CurrentUser.RealName;
                    model.ContactCellPhone = CurrentUser.CellPhone;
                    model.OrderItemId      = itemId;
                    if (!model.OrderItemId.HasValue)
                    {
                        model.IsOrderAllRefund = true;
                        model.RefundMode       = OrderRefundInfo.OrderRefundMode.OrderRefund;
                    }
                }
                else
                {
                    refunddata = refundser.GetOrderRefund(refundid.Value, CurrentUser.Id);
                    if (refunddata == null)
                    {
                        isok     = false;
                        errormsg = "错误的售后数据";
                        return(Redirect(jumpurl));

                        throw new Himall.Core.HimallException("错误的售后数据");
                    }
                    if (isok)
                    {
                        if (refunddata.SellerAuditStatus != OrderRefundInfo.OrderRefundAuditStatus.UnAudit)
                        {
                            isok     = false;
                            errormsg = "错误的售后状态,不可激活";
                            return(Redirect(jumpurl));

                            throw new Himall.Core.HimallException("错误的售后状态,不可激活");
                        }
                    }
                    if (isok)
                    {
                        model.ContactPerson     = refunddata.ContactPerson;
                        model.ContactCellPhone  = refunddata.ContactCellPhone;
                        model.OrderItemId       = refunddata.OrderItemId;
                        model.IsOrderAllRefund  = (refunddata.RefundMode == OrderRefundInfo.OrderRefundMode.OrderRefund);
                        model.RefundMode        = refunddata.RefundMode;
                        model.RefundReasonValue = refunddata.Reason;
                        model.RefundWayValue    = refunddata.RefundPayType;
                        model.CertPic1          = refunddata.CertPic1;
                        model.CertPic2          = refunddata.CertPic2;
                        model.CertPic3          = refunddata.CertPic3;
                    }
                }
                if (!model.IsOrderAllRefund && item.EnabledRefundAmount.HasValue)
                {
                    model.RefundGoodsPrice = item.EnabledRefundAmount.Value / item.Quantity;
                }

                if (isok)
                {
                    model.OrderInfo = order;
                    model.OrderId   = orderid;
                    model.RefundId  = refundid;

                    var reasons = refundser.GetRefundReasons();
                    foreach (var _ir in reasons)
                    {
                        _ir.AfterSalesText = _ir.AfterSalesText.Trim();
                    }
                    List <SelectListItem> reasel = new List <SelectListItem>();
                    SelectListItem        _tmpsel;
                    _tmpsel = new SelectListItem {
                        Text = "选择售后原因", Value = ""
                    };
                    reasel.Add(_tmpsel);
                    foreach (var _i in reasons)
                    {
                        _tmpsel = new SelectListItem {
                            Text = _i.AfterSalesText, Value = _i.AfterSalesText
                        };
                        if (!string.IsNullOrWhiteSpace(model.RefundReasonValue))
                        {
                            if (_i.AfterSalesText == model.RefundReasonValue)
                            {
                                _tmpsel.Selected = true;
                            }
                        }
                        reasel.Add(_tmpsel);
                    }
                    model.RefundReasons = reasel;

                    List <SelectListItem> list = new List <SelectListItem> {
                        new SelectListItem {
                            Text  = OrderRefundInfo.OrderRefundPayType.BackCapital.ToDescription(),
                            Value = ((int)OrderRefundInfo.OrderRefundPayType.BackCapital).ToString()
                        }
                    };
                    if (order.CanBackOut())
                    {
                        _tmpsel = new SelectListItem
                        {
                            Text  = OrderRefundInfo.OrderRefundPayType.BackOut.ToDescription(),
                            Value = ((int)OrderRefundInfo.OrderRefundPayType.BackOut).ToString()
                        };
                        //if (model.RefundWayValue.HasValue)
                        //{
                        //    if (_tmpsel.Value == model.RefundWayValue.ToString())
                        //    {
                        //        _tmpsel.Selected = true;
                        //    }
                        //}
                        _tmpsel.Selected = true;  //若预约单支付方式为支付宝、微信支付则退款方式默认选中“退款原路返回”
                        list.Add(_tmpsel);
                        model.BackOut = 1;
                    }
                    model.RefundWay = list;
                }
            }
            ViewBag.errormsg = errormsg;
            return(View(model));
        }
Ejemplo n.º 14
0
    /// <summary>
    /// Creates order item. Called when the "Create item" button is pressed.
    /// </summary>
    private bool CreateOrderItem()
    {
        // Prepare the parameters
        string where = "CustomerLastName LIKE N'My New Registered%'";
        string whereProduct = "SKUName LIKE N'MyNewProduct%'";
        CustomerInfo customer = null;
        OrderInfo order = null;
        SKUInfo product = null;

        // Get the product
        DataSet products = SKUInfoProvider.GetSKUs(whereProduct, null);
        if (!DataHelper.DataSourceIsEmpty(products))
        {
            // Create object from DataRow
            product = new SKUInfo(products.Tables[0].Rows[0]);
        }

        // Get the customer
        DataSet customers = CustomerInfoProvider.GetCustomers(where, null);
        if (!DataHelper.DataSourceIsEmpty(customers))
        {
            // Create object from DataRow
            customer = new CustomerInfo(customers.Tables[0].Rows[0]);
        }

        if (customer != null)
        {
            string whereOrder = "OrderCustomerID = " + customer.CustomerID;

            // Get the order
            DataSet orders = OrderInfoProvider.GetOrders(whereOrder, null);
            if (!DataHelper.DataSourceIsEmpty(orders))
            {
                // Create object from DataRow
                order = new OrderInfo(orders.Tables[0].Rows[0]);
            }

            if ((order != null) && (product != null))
            {
                // Create new order item object
                OrderItemInfo newItem = new OrderItemInfo();

                // Set the properties
                newItem.OrderItemSKUName = "MyNewProduct";
                newItem.OrderItemOrderID = order.OrderID;
                newItem.OrderItemSKUID = product.SKUID;
                newItem.OrderItemUnitPrice = 200;
                newItem.OrderItemUnitCount = 1;

                // Create the order item
                OrderItemInfoProvider.SetOrderItemInfo(newItem);

                return true;
            }
        }

        return false;
    }
Ejemplo n.º 15
0
 public OrderInfo AddToOrder(OrderItemInfo orderItem)
 {
     return(Call <OrderInfo, OrderItemInfo>(orderItem, MethodBase.GetCurrentMethod().Name));
 }
Ejemplo n.º 16
0
 /// <summary>
 /// 添加数据到数据库
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int Insert(OrderItemInfo model)
 {
     return(dal.Insert(model));
 }
Ejemplo n.º 17
0
        public void SellerDealRefund(long id, OrderRefundInfo.OrderRefundAuditStatus auditStatus, string sellerRemark, string sellerName)
        {
            OrderRefundInfo now = context.OrderRefundInfo.FindById <OrderRefundInfo>(id);

            if (now.SellerAuditStatus != OrderRefundInfo.OrderRefundAuditStatus.WaitAudit)
            {
                throw new HimallException("只有待审核状态的退款/退货才能进行处理");
            }
            if (now.RefundMode == OrderRefundInfo.OrderRefundMode.OrderRefund)
            {
                if (auditStatus == OrderRefundInfo.OrderRefundAuditStatus.WaitDelivery)
                {
                    auditStatus = OrderRefundInfo.OrderRefundAuditStatus.Audited;
                    Instance <IOrderService> .Create.AgreeToRefundBySeller(now.OrderId);
                }
            }
            else if (!now.IsReturn && auditStatus == OrderRefundInfo.OrderRefundAuditStatus.WaitDelivery)
            {
                auditStatus = OrderRefundInfo.OrderRefundAuditStatus.Audited;
            }
            if (auditStatus == OrderRefundInfo.OrderRefundAuditStatus.UnAudit)
            {
                if (now.RefundMode != OrderRefundInfo.OrderRefundMode.OrderRefund)
                {
                    OrderItemInfo num = context.OrderItemInfo.FindById <OrderItemInfo>(now.OrderItemId);
                    if (num != null)
                    {
                        num.ReturnQuantity = 0;
                        num.RefundPrice    = new decimal(0);
                    }
                }
                else
                {
                    OrderInfo orderInfo = context.OrderInfo.Include("OrderItemInfo").FirstOrDefault((OrderInfo d) => d.Id == now.OrderId);
                    if (orderInfo != null)
                    {
                        foreach (OrderItemInfo orderItemInfo in orderInfo.OrderItemInfo)
                        {
                            orderItemInfo.ReturnQuantity = 0;
                            orderItemInfo.RefundPrice    = new decimal(0);
                        }
                    }
                }
            }
            if (auditStatus != OrderRefundInfo.OrderRefundAuditStatus.WaitDelivery || now.IsReturn)
            {
                now.SellerAuditStatus = auditStatus;
            }
            else
            {
                now.SellerAuditStatus = OrderRefundInfo.OrderRefundAuditStatus.Audited;
            }
            now.SellerAuditDate = DateTime.Now;
            now.SellerRemark    = sellerRemark;
            if (auditStatus == OrderRefundInfo.OrderRefundAuditStatus.Audited)
            {
                now.ManagerConfirmDate = DateTime.Now;
            }
            OrderOperationLogInfo orderOperationLogInfo = new OrderOperationLogInfo()
            {
                Operator       = sellerName,
                OrderId        = now.OrderId,
                OperateDate    = DateTime.Now,
                OperateContent = "商家处理退款退货申请"
            };

            context.OrderOperationLogInfo.Add(orderOperationLogInfo);
            context.SaveChanges();
        }
Ejemplo n.º 18
0
        public void AddOrderRefund(OrderRefundInfo info)
        {
            bool flag = false;

            if (info.RefundMode == OrderRefundInfo.OrderRefundMode.OrderRefund)
            {
                flag = true;
            }
            bool flag1 = false;

            flag1 = (!flag ? CanApplyRefund(info.OrderId, info.OrderItemId, new bool?(false)) : CanApplyRefund(info.OrderId, info.OrderItemId, new bool?(true)));
            if (!flag1)
            {
                throw new HimallException("您己申请过售后,不可重复申请");
            }
            if (!flag)
            {
                if (info.ReturnQuantity <= 0)
                {
                    info.RefundMode = OrderRefundInfo.OrderRefundMode.OrderItemRefund;
                }
                else
                {
                    info.RefundMode = OrderRefundInfo.OrderRefundMode.ReturnGoodsRefund;
                }
            }
            info.SellerAuditDate      = DateTime.Now;
            info.SellerAuditStatus    = OrderRefundInfo.OrderRefundAuditStatus.WaitAudit;
            info.ManagerConfirmDate   = DateTime.Now;
            info.ManagerConfirmStatus = OrderRefundInfo.OrderRefundConfirmStatus.UnConfirm;
            if (flag)
            {
                info.OrderItemId = context.OrderItemInfo.FirstOrDefault((OrderItemInfo d) => d.OrderId == info.OrderId).Id;
            }
            List <OrderItemInfo> orderItemInfos = new List <OrderItemInfo>();

            if (flag)
            {
                orderItemInfos = (
                    from d in context.OrderItemInfo
                    where d.OrderId == info.OrderId
                    select d).ToList();
                foreach (OrderItemInfo orderItemInfo in orderItemInfos)
                {
                    orderItemInfo.ReturnQuantity = orderItemInfo.Quantity;
                    if (!orderItemInfo.EnabledRefundAmount.HasValue)
                    {
                        orderItemInfo.EnabledRefundAmount = new decimal?(new decimal(0));
                    }
                    orderItemInfo.RefundPrice = orderItemInfo.EnabledRefundAmount.Value;
                }
                info.ReturnQuantity = (int)orderItemInfos.Sum <OrderItemInfo>((OrderItemInfo d) => d.Quantity);
            }
            else
            {
                OrderItemInfo returnQuantity = context.OrderItemInfo.FirstOrDefault((OrderItemInfo d) => d.Id == info.OrderItemId);
                if (returnQuantity.Quantity - returnQuantity.ReturnQuantity < info.ReturnQuantity || (returnQuantity.RealTotalPrice - returnQuantity.RefundPrice) < info.Amount)
                {
                    throw new HimallException("退货和退款数量不能超过订单的实际数量和金额!");
                }
                returnQuantity.ReturnQuantity = info.ReturnQuantity;
                returnQuantity.RefundPrice    = info.Amount;
            }
            context.OrderRefundInfo.Add(info);
            context.SaveChanges();
        }
Ejemplo n.º 19
0
        /// <summary>
        /// 退款申请
        /// </summary>
        /// <param name="id"></param>
        /// <param name="itemId"></param>
        /// <returns></returns>
        public ActionResult RefundApply(long orderid, long?itemId, long?refundid)
        {
            RefundApplyModel model = new RefundApplyModel();

            model.RefundMode  = null;
            model.OrderItemId = null;
            var order = _iOrderService.GetOrder(orderid, CurrentUser.Id);

            if (order == null)
            {
                throw new Himall.Core.HimallException("该预约单已删除或不属于该用户");
            }
            if ((int)order.OrderStatus < 2)
            {
                throw new Himall.Core.HimallException("错误的售后申请,预约单状态有误");
            }
            if (itemId == null && order.OrderStatus != OrderInfo.OrderOperateStatus.WaitDelivery && order.OrderStatus != OrderInfo.OrderOperateStatus.WaitSelfPickUp)
            {
                throw new Himall.Core.HimallException("错误的预约单退款申请,预约单状态有误");
            }
            //售后时间限制
            if (_iOrderService.IsRefundTimeOut(orderid))
            {
                throw new Himall.Core.HimallException("预约单已超过售后期");
            }


            //计算可退金额 预留
            _iOrderService.CalculateOrderItemRefund(orderid);

            OrderItemInfo item = new OrderItemInfo();

            model.MaxRefundGoodsNumber = 0;
            model.MaxRefundAmount      = order.OrderEnabledRefundAmount;
            if (itemId == null)
            {
                model.OrderItems = order.OrderItemInfo.ToList();
                if (model.OrderItems.Count == 1)
                {
                    item = model.OrderItems.FirstOrDefault();
                }
            }
            else
            {
                item = order.OrderItemInfo.Where(a => a.Id == itemId).FirstOrDefault();
                model.OrderItems.Add(item);
                model.MaxRefundGoodsNumber = item.Quantity - item.ReturnQuantity;
                model.MaxRefundAmount      = item.EnabledRefundAmount - item.RefundPrice;
            }
            foreach (var orderItem in model.OrderItems)
            {
                ProductTypeInfo typeInfo = _iTypeService.GetTypeByProductId(orderItem.ProductId);
                orderItem.ColorAlias   = (typeInfo == null || string.IsNullOrEmpty(typeInfo.ColorAlias)) ? SpecificationType.Color.ToDescription() : typeInfo.ColorAlias;
                orderItem.SizeAlias    = (typeInfo == null || string.IsNullOrEmpty(typeInfo.SizeAlias)) ? SpecificationType.Size.ToDescription() : typeInfo.SizeAlias;
                orderItem.VersionAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.VersionAlias)) ? SpecificationType.Version.ToDescription() : typeInfo.VersionAlias;
            }
            if (!model.MaxRefundAmount.HasValue)
            {
                model.MaxRefundAmount = 0;
            }
            bool            isCanApply = false;
            var             refundser  = _iRefundService;
            OrderRefundInfo refunddata;

            if (order.OrderStatus == OrderInfo.OrderOperateStatus.WaitDelivery)
            {
                isCanApply = refundser.CanApplyRefund(orderid, item.Id);
            }
            else
            {
                isCanApply = refundser.CanApplyRefund(orderid, item.Id, false);
            }
            if (!refundid.HasValue)
            {
                if (!isCanApply)
                {
                    var orderRefunds = OrderApplication.GetOrderRefunds(new long[] { item.Id });
                    if (orderRefunds.Count == 1)
                    {
                        Response.Redirect("/OrderRefund/Detail/" + orderRefunds[0].Id);
                    }

                    throw new Himall.Core.HimallException("您已申请过售后,不可重复申请");
                }

                model.ContactPerson    = CurrentUser.RealName;
                model.ContactCellPhone = CurrentUser.CellPhone;
                model.OrderItemId      = itemId;
                if (!model.OrderItemId.HasValue)
                {
                    model.IsOrderAllRefund = true;
                    model.RefundMode       = OrderRefundInfo.OrderRefundMode.OrderRefund;
                }
            }
            else
            {
                refunddata = refundser.GetOrderRefund(refundid.Value, CurrentUser.Id);
                if (refunddata == null)
                {
                    throw new Himall.Core.HimallException("错误的售后数据");
                }
                if (refunddata.SellerAuditStatus != OrderRefundInfo.OrderRefundAuditStatus.UnAudit)
                {
                    throw new Himall.Core.HimallException("错误的售后状态,不可激活");
                }
                model.ContactPerson      = refunddata.ContactPerson;
                model.ContactCellPhone   = refunddata.ContactCellPhone;
                model.OrderItemId        = refunddata.OrderItemId;
                model.IsOrderAllRefund   = (refunddata.RefundMode == OrderRefundInfo.OrderRefundMode.OrderRefund);
                model.RefundMode         = refunddata.RefundMode;
                model.RefundReasonValue  = refunddata.Reason;
                model.RefundReasonDetail = refunddata.ReasonDetail;
                model.RefundWayValue     = refunddata.RefundPayType;
                model.CertPic1           = refunddata.CertPic1;
                model.CertPic2           = refunddata.CertPic2;
                model.CertPic3           = refunddata.CertPic3;
            }
            if (!model.IsOrderAllRefund && item.EnabledRefundAmount.HasValue)
            {
                model.RefundGoodsPrice = item.EnabledRefundAmount.Value / item.Quantity;
            }
            model.OrderInfo = order;
            model.OrderId   = orderid;
            model.RefundId  = refundid;

            var reasons = refundser.GetRefundReasons();

            foreach (var _ir in reasons)
            {
                _ir.AfterSalesText = _ir.AfterSalesText.Trim();
            }
            List <SelectListItem> reasel = new List <SelectListItem>();
            SelectListItem        _tmpsel;

            _tmpsel = new SelectListItem {
                Text = "选择售后原因", Value = ""
            };
            reasel.Add(_tmpsel);
            foreach (var _i in reasons)
            {
                _tmpsel = new SelectListItem {
                    Text = _i.AfterSalesText, Value = _i.AfterSalesText
                };
                if (!string.IsNullOrWhiteSpace(model.RefundReasonValue))
                {
                    if (_i.AfterSalesText == model.RefundReasonValue)
                    {
                        _tmpsel.Selected = true;
                    }
                }
                reasel.Add(_tmpsel);
            }
            model.RefundReasons = reasel;

            List <SelectListItem> list = new List <SelectListItem> {
                new SelectListItem {
                    Text  = OrderRefundInfo.OrderRefundPayType.BackCapital.ToDescription(),
                    Value = ((int)OrderRefundInfo.OrderRefundPayType.BackCapital).ToString()
                }
            };

            if (order.CanBackOut())
            {
                _tmpsel = new SelectListItem
                {
                    Text  = OrderRefundInfo.OrderRefundPayType.BackOut.ToDescription(),
                    Value = ((int)OrderRefundInfo.OrderRefundPayType.BackOut).ToString()
                };
                //if (model.RefundWayValue.HasValue)
                //{
                //    if (_tmpsel.Value == model.RefundWayValue.ToString())
                //    {
                //        _tmpsel.Selected = true;
                //    }
                //}
                _tmpsel.Selected = true;  //若预约单支付方式为支付宝、微信支付则退款方式默认选中“退款原路返回”
                list.Add(_tmpsel);
            }
            model.RefundWay = list;

            if (order.DeliveryType == CommonModel.Enum.DeliveryType.SelfTake)
            {
                var shopBranch = ShopBranchApplication.GetShopBranchById(order.ShopBranchId.Value);
                model.ReturnGoodsAddress  = RegionApplication.GetFullName(shopBranch.AddressId);
                model.ReturnGoodsAddress += " " + shopBranch.AddressDetail;
                model.ReturnGoodsAddress += " " + shopBranch.ContactPhone;
            }

            return(View(model));
        }
Ejemplo n.º 20
0
 public static bool Update(OrderItemInfo entity)
 {
     return(entity != null && BizBase.dbo.UpdateModel <OrderItemInfo>(entity));
 }
Ejemplo n.º 21
0
 public bool Update(OrderItemInfo orderItemInfo)
 {
     return(DBHelper.ExecuteProc("PR_Shop_OrderItem_Update", GetParms(orderItemInfo)));
 }
Ejemplo n.º 22
0
 public CertificateAdapter(OrderItemInfo detail)
 {
     this.detail = detail;
 }
Ejemplo n.º 23
0
        public ActionResult RefundApply(long id, long?itemId)
        {
            decimal?      nullable1;
            IOrderService orderService = ServiceHelper.Create <IOrderService>();
            OrderInfo     order        = orderService.GetOrder(id, base.CurrentUser.Id);

            if (order == null)
            {
                throw new HimallException("该订单已删除或不属于该用户");
            }
            if (order.OrderStatus < OrderInfo.OrderOperateStatus.WaitDelivery)
            {
                throw new HimallException("错误的售后申请,订单状态有误");
            }
            if (!itemId.HasValue && order.OrderStatus != OrderInfo.OrderOperateStatus.WaitDelivery)
            {
                throw new HimallException("错误的订单退款申请,订单状态有误");
            }
            orderService.CalculateOrderItemRefund(id, false);
            OrderItemInfo orderItemInfo = new OrderItemInfo();

            ViewBag.MaxRGDNumber    = 0;
            ViewBag.MaxRefundAmount = order.OrderEnabledRefundAmount;
            if (itemId.HasValue)
            {
                orderItemInfo = order.OrderItemInfo.Where((OrderItemInfo a) => {
                    long num      = a.Id;
                    long?nullable = itemId;
                    if (num != nullable.GetValueOrDefault())
                    {
                        return(false);
                    }
                    return(nullable.HasValue);
                }).FirstOrDefault();
                ViewBag.MaxRGDNumber = orderItemInfo.Quantity - orderItemInfo.ReturnQuantity;
                dynamic viewBag             = base.ViewBag;
                decimal?enabledRefundAmount = orderItemInfo.EnabledRefundAmount;
                decimal refundPrice         = orderItemInfo.RefundPrice;
                if (enabledRefundAmount.HasValue)
                {
                    nullable1 = new decimal?(enabledRefundAmount.GetValueOrDefault() - refundPrice);
                }
                else
                {
                    nullable1 = null;
                }
                //viewBag.MaxRefundAmount = nullable1;
            }
            else
            {
                orderItemInfo = order.OrderItemInfo.FirstOrDefault();
            }
            bool           flag          = false;
            IRefundService refundService = ServiceHelper.Create <IRefundService>();

            flag = (order.OrderStatus != OrderInfo.OrderOperateStatus.WaitDelivery ? refundService.CanApplyRefund(id, orderItemInfo.Id, new bool?(false)) : refundService.CanApplyRefund(id, orderItemInfo.Id, null));
            if (!flag)
            {
                throw new HimallException("您己申请过售后,不可重复申请");
            }
            ViewBag.UserName    = base.CurrentUser.RealName;
            ViewBag.Phone       = base.CurrentUser.CellPhone;
            ViewBag.OrderInfo   = order;
            ViewBag.OrderItemId = itemId;
            ViewBag.RefundWay   = "";
            List <SelectListItem> selectListItems = new List <SelectListItem>();
            SelectListItem        selectListItem  = new SelectListItem()
            {
                Text  = OrderRefundInfo.OrderRefundPayType.BackCapital.ToDescription(),
                Value = 3.ToString()
            };

            selectListItems.Add(selectListItem);
            List <SelectListItem> selectListItems1 = selectListItems;

            if (!string.IsNullOrWhiteSpace(order.PaymentTypeGateway) && order.PaymentTypeGateway.ToLower().Contains("weixin"))
            {
                SelectListItem selectListItem1 = new SelectListItem()
                {
                    Text  = OrderRefundInfo.OrderRefundPayType.BackOut.ToDescription(),
                    Value = 1.ToString()
                };
                selectListItems1.Add(selectListItem1);
            }
            ViewBag.RefundWay = selectListItems1;
            return(View(orderItemInfo));
        }
Ejemplo n.º 24
0
    protected void LoadData()
    {
        OrderInfo oi = OrderInfoProvider.GetOrderInfo(orderId);

        EditedObject = oi;

        if (oi != null)
        {
            // Check order site ID
            CheckOrderSiteID(oi.OrderSiteID);

            customerId = oi.OrderCustomerID;

            string paymentResultValue = oi.OrderPaymentResult.GetFormattedPaymentResultString();

            if (paymentResultValue.Trim() == String.Empty)
            {
                paymentResultValue = GetString("general.na");
            }

            lblPaymentResultValue.Text = paymentResultValue;

            drpPayment.ShippingOptionID = oi.OrderShippingOptionID;
            drpPayment.AddNoneRecord    = true;

            // If no shipping option selected
            if (drpPayment.ShippingOptionID == 0)
            {
                drpPayment.DisplayOnlyAllowedIfNoShipping = true;
            }

            addressElem.CustomerID = customerId;

            if (!URLHelper.IsPostback())
            {
                drpPayment.PaymentID   = oi.OrderPaymentOptionID;
                drpCurrency.CurrencyID = oi.OrderCurrencyID;
                addressElem.AddressID  = oi.OrderBillingAddressID;
                chkOrderIsPaid.Checked = oi.OrderIsPaid;
            }

            // Get order items for this order
            DataSet orderItems = OrderItemInfoProvider.GetOrderItems(orderId);

            foreach (DataRow orderItem in orderItems.Tables[0].Rows)
            {
                // Get order item
                OrderItemInfo oii = new OrderItemInfo(orderItem);

                if ((oii != null) && (oii.OrderItemSKU != null))
                {
                    switch (oii.OrderItemSKU.SKUProductType)
                    {
                    // If order item represents membership
                    case SKUProductTypeEnum.Membership:
                        showMembershipWarning = true;
                        break;

                    // If order item represents e-product
                    case SKUProductTypeEnum.EProduct:
                        showEproductWarning = true;
                        break;
                    }
                }
            }
        }
    }
Ejemplo n.º 25
0
        /*采购商退货*/
        public JsonResult InsertTH(long OrderNo, string Reson, string Amont, string Introduce, string images, string Attitude)
        {
            Result res = new Result();

            try
            {
                OrderInfo order = ServiceHelper.Create <IOrderService>().GetOrder(Convert.ToInt64(OrderNo));

                TH   thq  = ServiceHelper.Create <ITHService>().GetTHByOrderNum(OrderNo);
                long TKid = 0;
                if (thq == null)
                {
                    OrderInfo     oinfo   = ServiceHelper.Create <IOrderService>().GetOrder(OrderNo);
                    OrderItemInfo oiiinfo = ServiceHelper.Create <IOrderService>().GetOrderItemInfo(OrderNo);
                    if (oiiinfo == null || oinfo == null)
                    {
                        res.success = false;
                    }
                    ChemCloud.Service.Order.Business.OrderBO _orderBO = new ChemCloud.Service.Order.Business.OrderBO();
                    TH  th       = new TH();
                    var newmoney = oinfo.OrderTotalAmount - (oinfo.Freight + oinfo.Insurancefee + oinfo.Transactionfee + oinfo.Counterfee);
                    th.TH_Number           = _orderBO.GenerateOrderNumber();
                    th.TH_OrderNum         = OrderNo;
                    th.TH_Time             = DateTime.Now;
                    th.TH_UserId           = base.CurrentUser.Id;
                    th.TH_UserName         = base.CurrentUser.UserName;
                    th.TH_UserType         = base.CurrentUser.UserType;
                    th.TH_ProductName      = oiiinfo.ProductName;
                    th.TH_ProductCount     = int.Parse(oiiinfo.Quantity.ToString());
                    th.TH_ProductMoney     = newmoney;
                    th.TH_ProductMoneyReal = newmoney;
                    th.TH_ProductMoneyType = int.Parse(ConfigurationManager.AppSettings["CoinType"]);
                    ManagerInfo    minfo  = ServiceHelper.Create <IManagerService>().GetManagerInfoByShopId(oinfo.ShopId);
                    UserMemberInfo uminfo = ServiceHelper.Create <IMemberService>().GetMemberByName(minfo.UserName);
                    th.TH_ToUserId   = uminfo.Id;
                    th.TH_ToUserName = oinfo.ShopName;
                    th.TH_ToUserType = uminfo.UserType;
                    th.TH_Status     = 1;
                    th.TH_Reason     = Reson;

                    TKid = ServiceHelper.Create <ITHService>().AddTH(th);
                    if (TKid != 0)
                    {
                        oinfo.OrderStatus = ChemCloud.Model.OrderInfo.OrderOperateStatus.THing;
                        /*订单状态为 退货中*/
                        ServiceHelper.Create <IOrderService>().UpdateOrderStatu(OrderNo, 8);
                        /*2.添加退货日志*/
                        THMessageInfo tkm = new THMessageInfo()
                        {
                            MessageContent  = Introduce,
                            MessageDate     = DateTime.Now,
                            MessageAttitude = Convert.ToInt32(Attitude),
                            ReturnName      = base.CurrentUser.RealName,
                            UserId          = base.CurrentUser.Id,
                            THId            = TKid
                        };
                        long thmid = ServiceHelper.Create <ITHService>().InsertTHMessage(tkm);

                        /*3、退货凭证*/
                        string[]           imgs = images.Split(',');
                        List <THImageInfo> tkis = new List <THImageInfo>();
                        foreach (string item in imgs)
                        {
                            if (string.IsNullOrWhiteSpace(item))
                            {
                                continue;
                            }
                            THImageInfo tki = new THImageInfo()
                            {
                                THImage     = item,
                                THMessageId = thmid
                            };
                            tkis.Add(tki);
                        }
                        ServiceHelper.Create <ITHService>().InsertTHImage(tkis);

                        res.success = true;
                        res.msg     = "操作成功!";
                    }
                    else
                    {
                        res.success = false;
                        res.msg     = "操作失败!";
                    }
                }
                else
                {
                    TKid = thq.Id;

                    if (thq.TH_Status == 3)
                    {
                        /*更改退货订单为 退货申请中1  */
                        ServiceHelper.Create <ITHService>().UpdateTHStatus(thq.TH_OrderNum, 1);
                        /*订单状态为 退货中*/
                        ServiceHelper.Create <IOrderService>().UpdateOrderStatu(OrderNo, 8);
                    }

                    /*2.添加退货日志*/
                    THMessageInfo tkm = new THMessageInfo()
                    {
                        MessageContent  = Introduce,
                        MessageDate     = DateTime.Now,
                        MessageAttitude = Convert.ToInt32(Attitude),
                        ReturnName      = base.CurrentUser.RealName,
                        UserId          = base.CurrentUser.Id,
                        THId            = TKid
                    };
                    long thmid = ServiceHelper.Create <ITHService>().InsertTHMessage(tkm);

                    /*3、退货凭证*/
                    string[]           imgs = images.Split(',');
                    List <THImageInfo> tkis = new List <THImageInfo>();
                    foreach (string item in imgs)
                    {
                        if (string.IsNullOrWhiteSpace(item))
                        {
                            continue;
                        }
                        THImageInfo tki = new THImageInfo()
                        {
                            THImage     = item,
                            THMessageId = thmid
                        };
                        tkis.Add(tki);
                    }
                    ServiceHelper.Create <ITHService>().InsertTHImage(tkis);

                    res.success = true;
                    res.msg     = "操作成功!";
                }
            }
            catch (Exception)
            {
                res.success = false;
                res.msg     = "操作失败!";
            }
            return(Json(res));
        }
Ejemplo n.º 26
0
 /// <summary>
 /// 修改数据
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int Update(OrderItemInfo model)
 {
     return(dal.Update(model));
 }
Ejemplo n.º 27
0
        /// <summary>
        /// 下单
        /// </summary>
        /// <param name="model"></param>
        public void SubmitOrder(MargainBill margainbill)
        {
            try
            {
                //订单号
                ChemCloud.Service.Order.Business.OrderBO _orderBO = new ChemCloud.Service.Order.Business.OrderBO();
                long orderid = _orderBO.GenerateOrderNumber();

                //收货信息
                ShippingAddressService _ShippingAddressService = new ShippingAddressService();
                ShippingAddressInfo    addressinfo             = _ShippingAddressService.GetUserShippingAddress(long.Parse(margainbill.RegionId.ToString()));

                //供应商
                ShopService _ShopService = new ShopService();
                string      shopname     = _ShopService.GetShopName(margainbill.ShopId);

                //会员
                MemberService _MemberService = new MemberService();
                string        username       = _MemberService.GetMember(margainbill.MemberId) == null ? "" : (_MemberService.GetMember(margainbill.MemberId).UserName == null ? "" : _MemberService.GetMember(margainbill.MemberId).UserName);

                using (TransactionScope transactionScope = new TransactionScope())
                {
                    OrderInfo orderInfo = new OrderInfo();
                    orderInfo.Id        = orderid;                          //订单号
                    orderInfo.ShopId    = margainbill.ShopId;               //供应商编号ChemCloud_Shops
                    orderInfo.ShopName  = shopname;
                    orderInfo.UserId    = margainbill.MemberId;             //采购商ChemCloud_Members
                    orderInfo.UserName  = username;
                    orderInfo.OrderDate = DateTime.Now;                     //订单日期

                    orderInfo.ExpressCompanyName = margainbill.DeliverType; //物流配送方式
                    orderInfo.Freight            = margainbill.DeliverCost; //运费
                    //orderInfo.ShippingDate = margainbill.DeliverDate; //发货日期

                    orderInfo.PaymentTypeName = margainbill.PayMode;        //支付方式

                    orderInfo.ProductTotalAmount = margainbill.TotalAmount; //产品金额
                    orderInfo.CoinType           = margainbill.CoinType;    //货币种类

                    orderInfo.ShipTo         = addressinfo.ShipTo;          //收货人
                    orderInfo.TopRegionId    = addressinfo.RegionId;        //RegionId
                    orderInfo.RegionId       = addressinfo.RegionId;        //RegionId
                    orderInfo.RegionFullName = addressinfo.RegionFullName;  //省市区街道
                    orderInfo.Address        = addressinfo.Address;
                    orderInfo.CellPhone      = addressinfo.Phone;

                    orderInfo.OrderStatus        = OrderInfo.OrderOperateStatus.WaitPay;//订单
                    orderInfo.IsPrinted          = false;
                    orderInfo.RefundTotalAmount  = new decimal(0);
                    orderInfo.CommisTotalAmount  = new decimal(0);
                    orderInfo.RefundCommisAmount = new decimal(0);
                    orderInfo.Platform           = PlatformType.PC;

                    if (margainbill.InvoiceType == 0)
                    {
                        orderInfo.InvoiceType = InvoiceType.None;
                    }
                    else if (margainbill.InvoiceType == 1)
                    {
                        orderInfo.InvoiceType = InvoiceType.VATInvoice;
                    }
                    else if (margainbill.InvoiceType == 2)
                    {
                        orderInfo.InvoiceType = InvoiceType.OrdinaryInvoices;
                    }
                    orderInfo.InvoiceTitle   = margainbill.InvoiceTitle;
                    orderInfo.InvoiceContext = margainbill.InvoiceContext;

                    orderInfo.DiscountAmount   = new decimal(0);
                    orderInfo.ActiveType       = OrderInfo.ActiveTypes.None;
                    orderInfo.IntegralDiscount = new decimal(0);

                    orderInfo.IsInsurance    = margainbill.IsInsurance; //保险费
                    orderInfo.Insurancefee   = margainbill.Insurancefee;
                    orderInfo.Transactionfee = 0;                       //交易费
                    orderInfo.Counterfee     = 0;                       //手续费

                    context.OrderInfo.Add(orderInfo);
                    context.SaveChanges();

                    MargainBillDetail billdetail    = margainbill._MargainBillDetail.LastOrDefault();
                    OrderItemInfo     orderInfoitem = new OrderItemInfo();
                    orderInfoitem.OrderId        = orderid;
                    orderInfoitem.ShopId         = margainbill.ShopId;
                    orderInfoitem.ProductId      = billdetail.ProductId;
                    orderInfoitem.ProductName    = billdetail.ProductName;
                    orderInfoitem.Quantity       = billdetail.Num;
                    orderInfoitem.SalePrice      = billdetail.PurchasePrice;
                    orderInfoitem.PackingUnit    = billdetail.PackingUnit;
                    orderInfoitem.Purity         = billdetail.Purity;
                    orderInfoitem.SpecLevel      = billdetail.SpecLevel;
                    orderInfoitem.ReturnQuantity = long.Parse("1");
                    orderInfoitem.CostPrice      = 0;

                    orderInfoitem.DiscountAmount = 0;
                    orderInfoitem.RealTotalPrice = 0;
                    orderInfoitem.RefundPrice    = 0;
                    orderInfoitem.CommisRate     = 0;
                    orderInfoitem.IsLimitBuy     = false;

                    context.OrderItemInfo.Add(orderInfoitem);
                    context.SaveChanges();

                    //下单成功 更改状态
                    margainbill.BillStatus = EnumBillStatus.BargainSucceed;
                    context.SaveChanges();

                    transactionScope.Complete();
                }
            }
            catch (Exception)
            {
            }
        }
Ejemplo n.º 28
0
    protected void LoadData()
    {
        OrderInfo oi = OrderInfoProvider.GetOrderInfo(this.orderId);
        EditedObject = oi;

        if (oi != null)
        {
            customerId = oi.OrderCustomerID;

            string paymentResultValue = oi.OrderPaymentResult.GetFormattedPaymentResultString();

            if (paymentResultValue.Trim() == String.Empty)
            {
                paymentResultValue = GetString("general.na");
            }

            lblPaymentResultValue.Text = paymentResultValue;

            this.drpPayment.ShippingOptionID = oi.OrderShippingOptionID;
            this.drpPayment.AddNoneRecord = true;

            // If no shipping option selected
            if (this.drpPayment.ShippingOptionID == 0)
            {
                this.drpPayment.DisplayOnlyAllowedIfNoShipping = true;
            }

            addressElem.CustomerID = customerId;

            if (!URLHelper.IsPostback())
            {
                drpPayment.PaymentID = oi.OrderPaymentOptionID;
                drpCurrency.CurrencyID = oi.OrderCurrencyID;
                addressElem.AddressID = oi.OrderBillingAddressID;
                chkOrderIsPaid.Checked = oi.OrderIsPaid;
            }

            // Get order items for this order
            DataSet orderItems = OrderItemInfoProvider.GetOrderItems(this.orderId);

            foreach (DataRow orderItem in orderItems.Tables[0].Rows)
            {
                // Get order item
                OrderItemInfo oii = new OrderItemInfo(orderItem);

                if ((oii != null) && (oii.OrderItemSKU != null))
                {
                    switch (oii.OrderItemSKU.SKUProductType)
                    {
                        // If order item represents membership
                        case SKUProductTypeEnum.Membership:
                            this.showMembershipWarning = true;
                            break;

                        // If order item represents e-product
                        case SKUProductTypeEnum.EProduct:
                            this.showEproductWarning = true;
                            break;
                    }
                }
            }
        }
    }
Ejemplo n.º 29
0
        /// <summary>
        /// 下单
        /// </summary>
        /// <param name="model"></param>
        public bool CartSubmitOrder(List <MargainBill> listbill)
        {
            bool result = false;

            try
            {
                foreach (MargainBill margainbill in listbill)
                {
                    //订单号
                    ChemCloud.Service.Order.Business.OrderBO _orderBO = new ChemCloud.Service.Order.Business.OrderBO();
                    long orderid = _orderBO.GenerateOrderNumber();

                    //收货信息
                    ShippingAddressService _ShippingAddressService = new ShippingAddressService();
                    ShippingAddressInfo    addressinfo             = _ShippingAddressService.GetUserShippingAddress(long.Parse(margainbill.RegionId.ToString()));

                    //供应商
                    ShopService _ShopService = new ShopService();
                    string      shopname     = _ShopService.GetShopName(margainbill.ShopId);

                    //会员
                    MemberService _MemberService = new MemberService();
                    string        username       = _MemberService.GetMember(margainbill.MemberId) == null ? "" : (_MemberService.GetMember(margainbill.MemberId).UserName == null ? "" : _MemberService.GetMember(margainbill.MemberId).UserName);

                    using (TransactionScope transactionScope = new TransactionScope())
                    {
                        OrderInfo orderInfo = new OrderInfo();
                        orderInfo.Id        = orderid;                          //订单号
                        orderInfo.ShopId    = margainbill.ShopId;               //供应商编号ChemCloud_Shops
                        orderInfo.ShopName  = shopname;
                        orderInfo.UserId    = margainbill.MemberId;             //采购商ChemCloud_Members
                        orderInfo.UserName  = username;
                        orderInfo.OrderDate = DateTime.Now;                     //订单日期

                        orderInfo.ExpressCompanyName = margainbill.DeliverType; //物流配送方式

                        orderInfo.Freight = margainbill.DeliverCost;            //运费
                        //orderInfo.ShippingDate = margainbill.DeliverDate; //发货日期
                        //orderInfo.ShippingDate = null; //发货日期  尚未支付
                        orderInfo.PaymentTypeName = margainbill.PayMode;           //支付方式

                        orderInfo.ProductTotalAmount = margainbill.TotalAmount;    //产品金额
                        orderInfo.CoinType           = margainbill.CoinType;       //货币种类

                        orderInfo.ShipTo             = addressinfo.ShipTo;         //收货人
                        orderInfo.TopRegionId        = addressinfo.RegionId;       //RegionId
                        orderInfo.RegionId           = addressinfo.RegionId;       //RegionId
                        orderInfo.RegionFullName     = addressinfo.RegionFullName; //省市区街道
                        orderInfo.Address            = addressinfo.Address;
                        orderInfo.CellPhone          = addressinfo.Phone;
                        orderInfo.OrderStatus        = OrderInfo.OrderOperateStatus.WaitPay;//订单
                        orderInfo.IsPrinted          = false;
                        orderInfo.RefundTotalAmount  = new decimal(0);
                        orderInfo.CommisTotalAmount  = new decimal(0);
                        orderInfo.RefundCommisAmount = new decimal(0);
                        orderInfo.Platform           = PlatformType.PC;

                        /*发票信息*/
                        if (margainbill.InvoiceType == 0)
                        {
                            orderInfo.InvoiceType = InvoiceType.None;
                        }
                        else if (margainbill.InvoiceType == 1)
                        {
                            orderInfo.InvoiceType = InvoiceType.VATInvoice;
                        }
                        else if (margainbill.InvoiceType == 2)
                        {
                            orderInfo.InvoiceType = InvoiceType.OrdinaryInvoices;
                        }
                        else if (margainbill.InvoiceType == 3)
                        {
                            orderInfo.InvoiceType = InvoiceType.SpecialTicket;
                        }
                        orderInfo.InvoiceTitle   = margainbill.InvoiceTitle;   //名称
                        orderInfo.InvoiceContext = margainbill.InvoiceContext; //纳税人识别号
                        orderInfo.SellerPhone    = margainbill.SellerPhone;    //电话
                        orderInfo.SellerRemark   = margainbill.SellerRemark;   //开户行及账号
                        orderInfo.SellerAddress  = margainbill.SellerAddress;  //地址
                        /*发票信息*/

                        orderInfo.DiscountAmount   = new decimal(0);
                        orderInfo.ActiveType       = OrderInfo.ActiveTypes.None;
                        orderInfo.IntegralDiscount = new decimal(0);

                        orderInfo.IsInsurance    = margainbill.IsInsurance; //保险费
                        orderInfo.Insurancefee   = margainbill.Insurancefee;
                        orderInfo.Transactionfee = 0;                       //交易费
                        orderInfo.Counterfee     = 0;                       //手续费

                        context.OrderInfo.Add(orderInfo);
                        context.SaveChanges();
                        MargainBillService _MargainBillService = new MargainBillService();
                        OrderItemInfo      orderInfoitem       = new OrderItemInfo();
                        foreach (MargainBillDetail billdetail in margainbill._MargainBillDetail)
                        {
                            orderInfoitem.OrderId        = orderid;
                            orderInfoitem.ShopId         = margainbill.ShopId;
                            orderInfoitem.ProductId      = billdetail.ProductId;
                            orderInfoitem.ProductName    = billdetail.ProductName;
                            orderInfoitem.Quantity       = billdetail.Num;
                            orderInfoitem.SalePrice      = billdetail.PurchasePrice;
                            orderInfoitem.PackingUnit    = billdetail.PackingUnit;
                            orderInfoitem.SpecLevel      = billdetail.SpecLevel;
                            orderInfoitem.Purity         = billdetail.Purity;
                            orderInfoitem.ReturnQuantity = long.Parse("1");
                            orderInfoitem.CostPrice      = 0;
                            orderInfoitem.DiscountAmount = 0;
                            orderInfoitem.RealTotalPrice = 0;
                            orderInfoitem.RefundPrice    = 0;
                            orderInfoitem.CommisRate     = 0;
                            orderInfoitem.IsLimitBuy     = false;
                            context.OrderItemInfo.Add(orderInfoitem);
                            context.SaveChanges();
                            _MargainBillService.RemoveCartAfterOrder(orderInfo.UserId, billdetail.ProductId); //提交成功后,删除购物车内容
                        }
                        transactionScope.Complete();
                    }
                }
                result = true;
            }
            catch (Exception)
            {
                return(false);
            }

            return(result);
        }
Ejemplo n.º 30
0
    /// <summary>
    /// Gets and updates order item. Called when the "Get and update item" button is pressed.
    /// Expects the CreateOrderItem method to be run first.
    /// </summary>
    private bool GetAndUpdateOrderItem()
    {
        // Prepare the parameters
        string where = "CustomerLastName LIKE N'My New Registered%'";
        CustomerInfo customer = null;
        OrderInfo order = null;

        // Get the customer
        DataSet customers = CustomerInfoProvider.GetCustomers(where, null);
        if (!DataHelper.DataSourceIsEmpty(customers))
        {
            // Create object from DataRow
            customer = new CustomerInfo(customers.Tables[0].Rows[0]);
        }

        if (customer != null)
        {
            string whereOrder = "OrderCustomerID = " + customer.CustomerID;

            // Get the order
            DataSet orders = OrderInfoProvider.GetOrders(whereOrder, null);
            if (!DataHelper.DataSourceIsEmpty(orders))
            {
                // Create object from DataRow
                order = new OrderInfo(orders.Tables[0].Rows[0]);
            }

            if (order != null)
            {
                string whereOrderItem = "OrderItemOrderID = " + order.OrderID;

                // Get the order item
                DataSet orderItems = OrderItemInfoProvider.GetOrderItems(whereOrderItem, null, 0, null);
                if (!DataHelper.DataSourceIsEmpty(orderItems))
                {
                    // Create object from DataRow
                    OrderItemInfo orderItem = new OrderItemInfo(orderItems.Tables[0].Rows[0]);

                    // Update the property
                    orderItem.OrderItemSKUName = orderItem.OrderItemSKUName.ToLowerCSafe();

                    // Update the order item
                    OrderItemInfoProvider.SetOrderItemInfo(orderItem);

                    return true;
                }
            }
        }

        return false;
    }
Ejemplo n.º 31
0
        /// <summary>
        ///  平台退货详细页面
        /// </summary>
        /// <param name="orderNo"></param>
        /// <returns></returns>
        public ActionResult THDetail(long orderNo)
        {
            try
            {
                TH th = ServiceHelper.Create <ITHService>().GetTHByOrderNum(orderNo);
                if (th == null)
                {
                    decimal       newmoney = 0;
                    OrderInfo     oinfo    = ServiceHelper.Create <IOrderService>().GetOrder(orderNo);
                    OrderItemInfo oiiinfo  = ServiceHelper.Create <IOrderService>().GetOrderItemInfo(orderNo);
                    if (oiiinfo != null || oinfo != null)
                    {
                        newmoney = oinfo.OrderTotalAmount - (oinfo.Freight + oinfo.Insurancefee + oinfo.Transactionfee + oinfo.Counterfee);
                    }
                    ViewBag.TH_Reason       = "";
                    ViewBag.TH_ProductMoney = newmoney;
                    ViewBag.TH_Status       = 0;

                    th.TH_WLDH = "";
                    th.TH_WLGS = "";
                }
                else
                {
                    ViewBag.TH_Reason       = th.TH_Reason;
                    ViewBag.TH_ProductMoney = th.TH_ProductMoney;
                    ViewBag.TH_Status       = th.TH_Status;

                    List <THMessageModel> tkmms = new List <THMessageModel>();
                    List <THMessageInfo>  tks   = ServiceHelper.Create <ITHService>().getTHMessage(th.Id);
                    foreach (THMessageInfo item in tks)
                    {
                        THMessageModel tkmm = new THMessageModel()
                        {
                            MessageAttitude = item.MessageAttitude,
                            ReturnName      = item.ReturnName,
                            MessageDate     = item.MessageDate,
                            MessageContent  = item.MessageContent,
                            UserId          = item.UserId,
                            THId            = item.THId,
                            Id   = item.Id,
                            tkis = ServiceHelper.Create <ITHService>().getTHImage(item.Id)
                        };
                        tkmms.Add(tkmm);
                    }
                    ViewBag.tkmms = tkmms;
                }

                /*订单信息*/
                OrderInfo order = ServiceHelper.Create <IOrderService>().GetOrder(Convert.ToInt64(orderNo));
                if (order != null)
                {
                    ViewBag.OrderNo  = order.Id;
                    ViewBag.ShopName = order.ShopName;
                    ViewBag.yunfei   = order.Freight;
                    ViewBag.total    = order.ProductTotalAmount;
                    ViewBag.max      = order.Freight + order.ProductTotalAmount;
                    ViewBag.ShopId   = order.ShopId;
                    ViewBag.UserName = order.UserName;
                }
                else
                {
                    ViewBag.OrderNo  = "";
                    ViewBag.ShopName = "";
                    ViewBag.yunfei   = "";
                    ViewBag.total    = "";
                    ViewBag.max      = "";
                    ViewBag.ShopId   = "";
                }

                return(View(th));
            }
            catch (Exception)
            {
                return(View());
            }
        }
Ejemplo n.º 32
0
        public object AfterSalePreCheck(string openId, long OrderId, string SkuId = "", bool IsReturn = false)
        {
            CheckUserLogin();

            try
            {
                var result    = new OrderRefundAfterSalePreCheckModel(true);
                var ordser    = ServiceProvider.Instance <IOrderService> .Create;
                var refundser = ServiceProvider.Instance <IRefundService> .Create;
                //计算可退金额 预留
                ordser.CalculateOrderItemRefund(OrderId);
                var order = ordser.GetOrder(OrderId, CurrentUser.Id);
                if (order == null)
                {
                    throw new Himall.Core.HimallException("该订单已删除或不属于该用户");
                }
                if ((int)order.OrderStatus < 2)
                {
                    throw new Himall.Core.HimallException("错误的售后申请,订单状态有误");
                }
                result.CanBackReturn    = order.CanBackOut();
                result.CanReturnOnStore = result.CanBackReturn;
                result.CanToBalance     = true;
                if (order.OrderStatus == OrderInfo.OrderOperateStatus.WaitDelivery || order.OrderStatus == OrderInfo.OrderOperateStatus.WaitSelfPickUp)
                {
                    if (IsReturn)
                    {
                        throw new HimallException("订单状态不可以退货");
                    }
                    var _tmprefund = refundser.GetOrderRefundByOrderId(OrderId);
                    if (_tmprefund != null && _tmprefund.SellerAuditStatus != OrderRefundInfo.OrderRefundAuditStatus.UnAudit)
                    {
                        throw new HimallException("售后中,不可激活");
                    }
                    result.MaxRefundQuantity = 0;
                    result.oneReundAmount    = "0.00";
                    result.MaxRefundAmount   = order.OrderEnabledRefundAmount.ToString("f2");
                }
                else
                {
                    if (string.IsNullOrWhiteSpace(SkuId))
                    {
                        throw new Himall.Core.HimallException("错误的参数:SkuId");
                    }
                    OrderItemInfo _ordItem = order.OrderItemInfo.FirstOrDefault(d => d.SkuId == SkuId);
                    if (_ordItem != null)
                    {
                        var _tmprefund = refundser.GetOrderRefundList(OrderId).FirstOrDefault(d => d.OrderItemId == _ordItem.Id);
                        if (_tmprefund != null && _tmprefund.SellerAuditStatus != OrderRefundInfo.OrderRefundAuditStatus.UnAudit)
                        {
                            throw new HimallException("售后中,不可激活");
                        }
                    }
                    else
                    {
                        throw new Himall.Core.HimallException("错误的参数:SkuId");
                    }

                    result.MaxRefundQuantity = _ordItem.Quantity - _ordItem.ReturnQuantity;
                    result.oneReundAmount    = (_ordItem.EnabledRefundAmount.Value / _ordItem.Quantity).ToString("f2");
                    result.MaxRefundAmount   = (_ordItem.EnabledRefundAmount.Value - _ordItem.RefundPrice).ToString("f2");
                }
                var reasonlist = refundser.GetRefundReasons();
                result.RefundReasons = reasonlist;    //理由List
                return(Json(result));
            }
            catch (Exception ex)
            {
                return(Json(new BaseResultModel(false)
                {
                    Message = ex.Message
                }));
            }
        }
    /// <summary>
    /// Creates order item. Called when the "Create item" button is pressed.
    /// </summary>
    private bool CreateOrderItem()
    {
        // Get the data
        var product = SKUInfoProvider.GetSKUs()
                           .WhereStartsWith("SKUName", "MyNewProduct")
                           .FirstOrDefault();

        // Get the customer
        var customer = CustomerInfoProvider.GetCustomers()
                           .WhereStartsWith("CustomerLastName", "My New Registered")
                           .FirstOrDefault();

        if (customer != null)
        {
            // Get the order
            var order = OrderInfoProvider.GetOrders()
                            .WhereEquals("OrderCustomerID", customer.CustomerID)
                            .FirstOrDefault();

            if ((order != null) && (product != null))
            {
                // Create new order item object
                OrderItemInfo newItem = new OrderItemInfo
                                        {
                                            OrderItemSKUName = "MyNewProduct",
                                            OrderItemOrderID = order.OrderID,
                                            OrderItemSKUID = product.SKUID,
                                            OrderItemUnitPrice = 200,
                                            OrderItemUnitCount = 1
                                        };

                // Create the order item
                OrderItemInfoProvider.SetOrderItemInfo(newItem);

                return true;
            }
        }

        return false;
    }
Ejemplo n.º 34
0
        public JsonResult RefundApply(OrderRefundInfo info)
        {
            decimal?  nullable;
            OrderInfo order = ServiceHelper.Create <IOrderService>().GetOrder(info.OrderId, base.CurrentUser.Id);

            if (order == null)
            {
                throw new HimallException("该订单已删除或不属于该用户");
            }
            if (order.OrderStatus < OrderInfo.OrderOperateStatus.WaitDelivery)
            {
                throw new HimallException("错误的售后申请,订单状态有误");
            }
            if (order.OrderStatus == OrderInfo.OrderOperateStatus.WaitDelivery)
            {
                info.RefundMode     = OrderRefundInfo.OrderRefundMode.OrderRefund;
                info.ReturnQuantity = 0;
            }
            if (info.RefundType == 1)
            {
                info.ReturnQuantity = 0;
                info.IsReturn       = false;
            }
            if (info.ReturnQuantity < 0)
            {
                throw new HimallException("错误的退货数量");
            }
            OrderItemInfo orderItemInfo = order.OrderItemInfo.FirstOrDefault((OrderItemInfo a) => a.Id == info.OrderItemId);

            if (orderItemInfo == null && info.RefundMode != OrderRefundInfo.OrderRefundMode.OrderRefund)
            {
                throw new HimallException("该订单条目已删除或不属于该用户");
            }
            if (info.RefundMode != OrderRefundInfo.OrderRefundMode.OrderRefund)
            {
                decimal amount = info.Amount;
                decimal?enabledRefundAmount = orderItemInfo.EnabledRefundAmount;
                decimal refundPrice         = orderItemInfo.RefundPrice;
                if (enabledRefundAmount.HasValue)
                {
                    nullable = new decimal?(enabledRefundAmount.GetValueOrDefault() - refundPrice);
                }
                else
                {
                    nullable = null;
                }
                decimal?nullable1 = nullable;
                if ((amount <= nullable1.GetValueOrDefault() ? false : nullable1.HasValue))
                {
                    throw new HimallException("退款金额不能超过订单的可退金额");
                }
                if (info.ReturnQuantity > orderItemInfo.Quantity - orderItemInfo.ReturnQuantity)
                {
                    throw new HimallException("退货数量不可以超出可退数量");
                }
            }
            else
            {
                if (order.OrderStatus != OrderInfo.OrderOperateStatus.WaitDelivery)
                {
                    throw new HimallException("错误的订单退款申请,订单状态有误");
                }
                info.IsReturn       = false;
                info.ReturnQuantity = 0;
                if (info.Amount > order.OrderEnabledRefundAmount)
                {
                    throw new HimallException("退款金额不能超过订单的实际支付金额");
                }
            }
            info.IsReturn = false;
            if (info.ReturnQuantity > 0)
            {
                info.IsReturn = true;
            }
            if (info.RefundType == 2)
            {
                info.IsReturn = true;
            }
            if (info.IsReturn && info.ReturnQuantity < 1)
            {
                throw new HimallException("错误的退货数量");
            }
            if (info.Amount <= new decimal(0))
            {
                throw new HimallException("错误的退款金额");
            }
            info.ShopId    = order.ShopId;
            info.ShopName  = order.ShopName;
            info.UserId    = base.CurrentUser.Id;
            info.Applicant = base.CurrentUser.UserName;
            info.ApplyDate = DateTime.Now;
            info.Reason    = OrderRefundController.HTMLEncode(info.Reason.Replace("'", "‘").Replace("\"", "”"));
            ServiceHelper.Create <IRefundService>().AddOrderRefund(info);
            return(Json(new { success = true, msg = "提交成功", id = info.Id }));
        }
Ejemplo n.º 35
0
        //议价单转订单
        public void TransferOrder(long MargainBillId)
        {
            try
            {
                MargainBill margainbill = GetBillById(MargainBillId, 0);

                ChemCloud.Service.Order.Business.OrderBO _orderBO = new ChemCloud.Service.Order.Business.OrderBO();
                long orderid = _orderBO.GenerateOrderNumber();

                ShippingAddressService _ShippingAddressService = new ShippingAddressService();
                ShippingAddressInfo    addressinfo             = _ShippingAddressService.GetUserShippingAddress(long.Parse(margainbill.DeliverAddress));

                ShopService _ShopService = new ShopService();
                string      shopname     = _ShopService.GetShopName(margainbill.ShopId);

                MemberService _MemberService = new MemberService();
                string        username       = _MemberService.GetMember(margainbill.MemberId).UserName;

                using (TransactionScope transactionScope = new TransactionScope())
                {
                    OrderInfo orderInfo = new OrderInfo();
                    orderInfo.Id                 = orderid;                    //订单号
                    orderInfo.ShopId             = margainbill.ShopId;         //供应商编号ChemCloud_Shops
                    orderInfo.ShopName           = shopname;
                    orderInfo.UserId             = margainbill.MemberId;       //采购商ChemCloud_Members
                    orderInfo.UserName           = username;
                    orderInfo.OrderDate          = DateTime.Now;               //订单日期
                    orderInfo.Address            = margainbill.DeliverAddress; //收获地址 shippingaddress 编号
                    orderInfo.ExpressCompanyName = margainbill.DeliverType;
                    orderInfo.Freight            = margainbill.DeliverCost;
                    orderInfo.ShippingDate       = margainbill.DeliverDate;
                    orderInfo.PaymentTypeName    = margainbill.PayMode;
                    orderInfo.ProductTotalAmount = margainbill.TotalAmount;
                    orderInfo.CoinType           = margainbill.CoinType;
                    orderInfo.ShipTo             = addressinfo.ShipTo;//收货人
                    orderInfo.TopRegionId        = int.Parse("1");
                    orderInfo.RegionId           = addressinfo.RegionId;
                    orderInfo.RegionFullName     = addressinfo.RegionFullName;

                    orderInfo.OrderStatus        = OrderInfo.OrderOperateStatus.WaitPay;
                    orderInfo.IsPrinted          = false;
                    orderInfo.RefundTotalAmount  = new decimal(0);
                    orderInfo.CommisTotalAmount  = new decimal(0);
                    orderInfo.RefundCommisAmount = new decimal(0);
                    orderInfo.Platform           = PlatformType.PC;
                    orderInfo.InvoiceType        = InvoiceType.OrdinaryInvoices;
                    orderInfo.InvoiceTitle       = "InvoiceTitle";
                    orderInfo.InvoiceContext     = "InvoiceContext";
                    orderInfo.DiscountAmount     = new decimal(0);
                    orderInfo.ActiveType         = OrderInfo.ActiveTypes.None;
                    orderInfo.IntegralDiscount   = new decimal(0);

                    context.OrderInfo.Add(orderInfo);
                    context.SaveChanges();

                    MargainBillDetail billdetail    = margainbill._MargainBillDetail.LastOrDefault();
                    OrderItemInfo     orderInfoitem = new OrderItemInfo();
                    orderInfoitem.OrderId        = orderid;
                    orderInfoitem.ShopId         = margainbill.ShopId;
                    orderInfoitem.ProductId      = billdetail.ProductId;
                    orderInfoitem.ProductName    = billdetail.ProductName;
                    orderInfoitem.Quantity       = billdetail.Num;
                    orderInfoitem.SalePrice      = billdetail.PurchasePrice;
                    orderInfoitem.ReturnQuantity = long.Parse("1");
                    orderInfoitem.CostPrice      = 0;

                    orderInfoitem.DiscountAmount = 0;
                    orderInfoitem.RealTotalPrice = 0;
                    orderInfoitem.RefundPrice    = 0;
                    orderInfoitem.CommisRate     = 0;
                    orderInfoitem.IsLimitBuy     = false;

                    context.OrderItemInfo.Add(orderInfoitem);
                    context.SaveChanges();

                    //下单成功 更改状态
                    margainbill.BillStatus = EnumBillStatus.BargainSucceed;
                    context.SaveChanges();

                    transactionScope.Complete();
                }
            }
            catch (Exception)
            {
            }
        }