Exemplo n.º 1
0
        private IDictionary <int, string> GetPrintElementIndexAndOrderValue(ShopInfo shop, OrderInfo order, IEnumerable <int> printElementIndexes)
        {
            if (order == null)
            {
                throw new NullReferenceException("订单为空");
            }
            Dictionary <int, string> nums          = new Dictionary <int, string>();
            RegionService            regionService = new RegionService();

            string[] strArrays = order.RegionFullName.Split(new char[] { ' ' });
            string   empty     = string.Empty;

            string[] strArrays1 = new string[0];
            if (shop.SenderRegionId.HasValue)
            {
                int?senderRegionId = shop.SenderRegionId;
                empty      = regionService.GetRegionFullName(senderRegionId.Value, " ");
                strArrays1 = empty.Split(new char[] { ' ' });
            }
            string str = string.Empty;

            foreach (int list in printElementIndexes.ToList())
            {
                string shipTo = string.Empty;
                switch (list)
                {
                case 1:
                {
                    shipTo = order.ShipTo;
                    break;
                }

                case 2:
                {
                    shipTo = order.Address;
                    break;
                }

                case 3:
                {
                    shipTo = order.CellPhone;
                    break;
                }

                case 4:
                {
                    shipTo = "";
                    break;
                }

                case 5:
                {
                    shipTo = strArrays[0];
                    break;
                }

                case 6:
                {
                    shipTo = strArrays.Length > 1 ? strArrays[1] : "";
                    break;
                }

                case 7:
                {
                    shipTo = strArrays.Length > 2 ? strArrays[2] : "";
                    break;
                }

                case 8:
                {
                    shipTo = shop.SenderName;
                    break;
                }

                case 9:
                {
                    shipTo = strArrays1.Length > 0 ? strArrays1[0] : "";
                    break;
                }

                case 10:
                {
                    shipTo = strArrays1.Length > 1 ? strArrays1[2] : "";
                    break;
                }

                case 11:
                {
                    shipTo = strArrays1.Length > 2 ? strArrays1[2] : "";
                    break;
                }

                case 12:
                {
                    shipTo = shop.SenderAddress;
                    break;
                }

                case 13:
                {
                    shipTo = "";
                    break;
                }

                case 14:
                {
                    shipTo = shop.SenderPhone;
                    break;
                }

                case 15:
                {
                    shipTo = order.Id.ToString();
                    break;
                }

                case 16:
                {
                    shipTo = order.OrderTotalAmount.ToString("F2");
                    break;
                }

                case 17:
                {
                    shipTo = string.Empty;
                    break;
                }

                case 18:
                {
                    shipTo = (string.IsNullOrWhiteSpace(order.UserRemark) ? "" : order.UserRemark.ToString());
                    break;
                }

                case 19:
                {
                    shipTo = string.Empty;
                    break;
                }

                case 20:
                {
                    shipTo = string.Empty;
                    break;
                }

                case 21:
                {
                    shipTo = shop.ShopName;
                    break;
                }

                case 22:
                {
                    shipTo = "√";
                    break;
                }

                default:
                {
                    goto case 20;
                }
                }
                nums.Add(list, shipTo);
            }
            return(nums);
        }
Exemplo n.º 2
0
        IDictionary <int, string> GetPrintElementIndexAndOrderValue(ShopInfo shop, OrderInfo order, IEnumerable <int> printElementIndexes)
        {
            if (order == null)
            {
                throw new NullReferenceException("订单为空");
            }

            var dic = new Dictionary <int, string>();


            RegionService regionService = new RegionService();

            string[] regionNames = order.RegionFullName.Split(' ');

            string sellerRegionFullName = string.Empty;

            string[] sellerRegionNames = new string[] { };

            if (shop.SenderRegionId.HasValue)
            {
                sellerRegionFullName = regionService.GetFullName(shop.SenderRegionId.Value);
                sellerRegionNames    = sellerRegionFullName.Split(' ');
            }

            string value;
            string fullRegionName = string.Empty;


            foreach (var index in printElementIndexes.ToList())
            {
                value = string.Empty;

                #region 获取对应值
                switch (index)
                {
                case 1:    //"收货人-姓名"
                    value = order.ShipTo;
                    break;

                case 2:    //"收货人-地址"
                    value = order.Address;
                    break;

                case 3:    //"收货人-电话"
                    value = order.CellPhone;
                    break;

                case 4:    //"收货人-邮编"
                    value = "";
                    break;

                case 5:    //"收货人-地区1级"
                    value = regionNames[0];
                    break;

                case 6:    //"收货人-地区2级"
                    value = regionNames.Length > 1 ? regionNames[1] : "";
                    break;

                case 7:    //"收货人-地区3级"
                    value = regionNames.Length > 2 ? regionNames[2] : "";
                    break;

                case 8:    //"发货人-姓名"
                    value = shop.SenderName;
                    break;

                case 9:    //"发货人-地区1级"
                    value = sellerRegionNames.Length > 0 ? sellerRegionNames[0] : "";
                    break;

                case 10:    // "发货人-地区2级"
                    value = sellerRegionNames.Length > 1 ? sellerRegionNames[1] : "";
                    break;

                case 11:    //"发货人-地区3级"
                    value = sellerRegionNames.Length > 2 ? sellerRegionNames[2] : "";
                    break;

                case 12:    //"发货人-地址"
                    value = shop.SenderAddress;
                    break;

                case 13:    //"发货人-邮编"
                    value = "";
                    break;

                case 14:    //"发货人-电话"
                    value = shop.SenderPhone;
                    break;

                case 15:    //"订单-订单号"
                    value = order.Id.ToString();
                    break;

                case 16:    //"订单-总金额"
                    value = order.OrderTotalAmount.ToString("F2");
                    break;

                case 17:    //"订单-物品总重量"
                    value = string.Empty;
                    break;

                case 18:    //"订单-备注"
                    value = string.IsNullOrWhiteSpace(order.UserRemark) ? "" : order.UserRemark.ToString();
                    break;

                case 19:    //"订单-详情"
                    value = string.Empty;
                    break;

                case 21:    //"网店名称"
                    value = shop.ShopName;
                    break;

                case 22:    //"对号-√"
                    value = "√";
                    break;

                default:
                    value = string.Empty;
                    break;
                }
                #endregion

                dic.Add(index, value);
            }
            return(dic);
        }