Exemple #1
0
 public string ConvertTrades(System.Data.DataSet dstrades)
 {
     System.Collections.Generic.List <trade_list_model> list = new System.Collections.Generic.List <trade_list_model>();
     foreach (System.Data.DataRow dataRow in dstrades.Tables[0].Rows)
     {
         trade_list_model      trade_list_model = new trade_list_model();
         System.Data.DataRow[] childRows        = dataRow.GetChildRows("OrderRelation");
         for (int i = 0; i < childRows.Length; i++)
         {
             System.Data.DataRow dataRow2         = childRows[i];
             string           sku_properties_name = Globals.HtmlEncode(dataRow2["SKUContent"].ToString());
             trade_itme_model item = new trade_itme_model
             {
                 sku_id = (string)dataRow2["SkuId"],
                 sku_properties_name = sku_properties_name,
                 num_id        = dataRow2["ProductId"].ToString(),
                 num           = (int)dataRow2["Quantity"],
                 title         = (string)dataRow2["ItemDescription"],
                 outer_sku_id  = (string)dataRow2["SKU"],
                 pic_path      = ((dataRow2["ThumbnailsUrl"] != System.DBNull.Value) ? ((string)dataRow2["ThumbnailsUrl"]) : ""),
                 price         = (decimal)dataRow2["ItemAdjustedPrice"],
                 refund_status = EnumDescription.GetEnumDescription((OrderStatus)System.Enum.Parse(typeof(OrderStatus), dataRow2["OrderItemsStatus"].ToString()), 1)
             };
             trade_list_model.orders.Add(item);
         }
         trade_list_model.tid = (string)dataRow["OrderId"];
         if (dataRow["Remark"] != System.DBNull.Value)
         {
             trade_list_model.buyer_memo = dataRow["Remark"].ToString();
         }
         if (dataRow["ManagerRemark"] != System.DBNull.Value)
         {
             trade_list_model.seller_memo = dataRow["ManagerRemark"].ToString();
         }
         if (dataRow["ManagerMark"] != System.DBNull.Value)
         {
             trade_list_model.seller_flag = dataRow["ManagerMark"].ToString();
         }
         trade_list_model.discount_fee = (decimal)dataRow["AdjustedDiscount"];
         trade_list_model.status       = EnumDescription.GetEnumDescription((OrderStatus)System.Enum.Parse(typeof(OrderStatus), dataRow["OrderStatus"].ToString()), 1);
         if (dataRow["Gateway"].ToString() == "hishop.plugins.payment.podrequest" && trade_list_model.status == EnumDescription.GetEnumDescription((OrderStatus)System.Enum.Parse(typeof(OrderStatus), System.Convert.ToInt16(OrderStatus.WaitBuyerPay).ToString()), 1))
         {
             trade_list_model.status = EnumDescription.GetEnumDescription((OrderStatus)System.Enum.Parse(typeof(OrderStatus), System.Convert.ToInt16(OrderStatus.BuyerAlreadyPaid).ToString()), 1);
         }
         if (dataRow["CloseReason"] != System.DBNull.Value)
         {
             trade_list_model.close_memo = (string)dataRow["CloseReason"];
         }
         trade_list_model.created = new System.DateTime?(System.DateTime.Parse(dataRow["OrderDate"].ToString()));
         if (dataRow["UpdateDate"] != System.DBNull.Value)
         {
             trade_list_model.modified = new System.DateTime?(System.DateTime.Parse(dataRow["UpdateDate"].ToString()));
         }
         if (dataRow["PayDate"] != System.DBNull.Value)
         {
             trade_list_model.pay_time = new System.DateTime?(System.DateTime.Parse(dataRow["PayDate"].ToString()));
         }
         if (dataRow["ShippingDate"] != System.DBNull.Value)
         {
             trade_list_model.consign_time = new System.DateTime?(System.DateTime.Parse(dataRow["ShippingDate"].ToString()));
         }
         if (dataRow["FinishDate"] != System.DBNull.Value)
         {
             trade_list_model.end_time = new System.DateTime?(System.DateTime.Parse(dataRow["FinishDate"].ToString()));
         }
         trade_list_model.buyer_uname = (string)dataRow["Username"];
         if (dataRow["EmailAddress"] != System.DBNull.Value)
         {
             trade_list_model.buyer_email = (string)dataRow["EmailAddress"];
         }
         if (dataRow["RealName"] != System.DBNull.Value)
         {
             trade_list_model.buyer_nick = (string)dataRow["RealName"];
         }
         if (dataRow["ShipTo"] != System.DBNull.Value)
         {
             trade_list_model.receiver_name = (string)dataRow["ShipTo"];
         }
         string fullRegion = RegionHelper.GetFullRegion(System.Convert.ToInt32(dataRow["RegionId"]), "-");
         if (!string.IsNullOrEmpty(fullRegion))
         {
             string[] array = fullRegion.Split(new char[]
             {
                 '-'
             });
             trade_list_model.receiver_state = array[0];
             if (array.Length >= 2)
             {
                 trade_list_model.receiver_city = array[1];
             }
             if (array.Length >= 3)
             {
                 trade_list_model.receiver_district = array[2];
             }
             else if (array.Length >= 2)
             {
                 trade_list_model.receiver_district = array[1];
             }
             if (array.Length >= 4)
             {
                 trade_list_model.receiver_town = array[3];
             }
         }
         trade_list_model.receiver_address = (string)dataRow["Address"];
         trade_list_model.receiver_mobile  = (string)dataRow["CellPhone"];
         trade_list_model.receiver_zip     = (string)dataRow["ZipCode"];
         trade_list_model.invoice_fee      = (decimal)dataRow["Tax"];
         trade_list_model.invoice_title    = (string)dataRow["InvoiceTitle"];
         trade_list_model.payment          = (decimal)dataRow["OrderTotal"];
         trade_list_model.storeId          = "0";
         list.Add(trade_list_model);
     }
     return(JsonConvert.SerializeObject(list));
 }
Exemple #2
0
        private string ConvertTrades(OrderInfo orderInfo)
        {
            trade_list_model trade_list_model = new trade_list_model();

            trade_list_model.tid           = orderInfo.OrderId;
            trade_list_model.buyer_memo    = orderInfo.Remark;
            trade_list_model.seller_memo   = orderInfo.ManagerRemark;
            trade_list_model.seller_flag   = (orderInfo.ManagerMark.HasValue ? System.Convert.ToInt16(orderInfo.ManagerMark).ToString() : "0");
            trade_list_model.discount_fee  = orderInfo.AdjustedDiscount;
            trade_list_model.status        = EnumDescription.GetEnumDescription(orderInfo.OrderStatus, 1);
            trade_list_model.close_memo    = orderInfo.CloseReason;
            trade_list_model.created       = new System.DateTime?(orderInfo.OrderDate);
            trade_list_model.modified      = new System.DateTime?(orderInfo.UpdateDate);
            trade_list_model.pay_time      = orderInfo.PayDate;
            trade_list_model.consign_time  = orderInfo.ShippingDate;
            trade_list_model.end_time      = orderInfo.FinishDate;
            trade_list_model.buyer_uname   = orderInfo.Username;
            trade_list_model.buyer_email   = orderInfo.EmailAddress;
            trade_list_model.buyer_nick    = orderInfo.RealName;
            trade_list_model.receiver_name = orderInfo.ShipTo;
            string fullRegion = RegionHelper.GetFullRegion(orderInfo.RegionId, "-");

            if (!string.IsNullOrEmpty(fullRegion))
            {
                string[] array = fullRegion.Split(new char[]
                {
                    '-'
                });
                trade_list_model.receiver_state = array[0];
                if (array.Length >= 2)
                {
                    trade_list_model.receiver_city = array[1];
                }
                if (array.Length >= 3)
                {
                    trade_list_model.receiver_district = array[2];
                }
                if (array.Length >= 4)
                {
                    trade_list_model.receiver_town = array[3];
                }
            }
            trade_list_model.receiver_address = orderInfo.Address;
            trade_list_model.receiver_mobile  = orderInfo.CellPhone;
            trade_list_model.receiver_zip     = orderInfo.ZipCode;
            trade_list_model.invoice_fee      = orderInfo.Tax;
            trade_list_model.invoice_title    = orderInfo.InvoiceTitle;
            trade_list_model.payment          = orderInfo.GetTotal();
            trade_list_model.storeId          = "0";
            foreach (LineItemInfo current in orderInfo.LineItems.Values)
            {
                string           sku_properties_name = Globals.HtmlEncode(current.SKUContent);
                trade_itme_model item = new trade_itme_model
                {
                    sku_id = current.SkuId,
                    sku_properties_name = sku_properties_name,
                    num_id        = current.ProductId.ToString(),
                    num           = current.Quantity,
                    title         = current.ItemDescription,
                    outer_sku_id  = current.SKU,
                    pic_path      = current.ThumbnailsUrl,
                    price         = decimal.Round(current.ItemAdjustedPrice, 2),
                    refund_status = EnumDescription.GetEnumDescription(current.OrderItemsStatus, 1)
                };
                trade_list_model.orders.Add(item);
            }
            return(JsonConvert.SerializeObject(trade_list_model));
        }
Exemple #3
0
        /// <summary>
        /// 预约单信息转换
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        private trade_list_model OrderInfoMapChange(OrderInfo data)
        {
            #region 基础信息初始化
            var      UserInfo = _iMemberService.GetMemberByName(data.UserName);
            string   state, city, district, town;
            string[] adressArray = data.RegionFullName.Split(new string[] { " ", ",", "," }, StringSplitOptions.RemoveEmptyEntries);

            state    = adressArray[0];
            city     = adressArray[1];
            district = adressArray[2];
            if (adressArray.Length == 4)
            {
                town = adressArray[3];
            }
            else
            {
                town = string.Empty;
            }

            string status = string.Empty;
            switch (data.OrderStatus)
            {
            case OrderInfo.OrderOperateStatus.Close:
                status = "TRADE_CLOSED";
                break;

            case OrderInfo.OrderOperateStatus.Finish:
                status = "TRADE_FINISHED";
                break;

            case OrderInfo.OrderOperateStatus.WaitDelivery:
                status = "WAIT_SELLER_SEND_GOODS";
                //拼团预约单信息修正
                if (data.OrderType == OrderInfo.OrderTypes.FightGroup)
                {
                    var fgord = _iFightGroupService.GetOrder(data.Id);
                    if (fgord != null)
                    {
                        if (fgord.GetJoinStatus != FightGroupOrderJoinStatus.BuildSuccess)
                        {
                            //未拼团成功的预约单为待付款状态返回
                            status = "WAIT_BUYER_PAY";
                        }
                    }
                }
                break;

            case OrderInfo.OrderOperateStatus.WaitPay:
                status = "WAIT_BUYER_PAY";
                break;

            case OrderInfo.OrderOperateStatus.WaitReceiving:
                status = "WAIT_BUYER_CONFIRM_GOODS";
                break;

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

            trade_list_model result = new trade_list_model();
            result.tid               = data.Id.ToString();
            result.buyer_memo        = data.PayRemark;
            result.seller_memo       = data.SellerRemark;
            result.seller_flag       = "";
            result.discount_fee      = data.DiscountAmount;
            result.status            = status;
            result.close_memo        = data.CloseReason;
            result.created           = data.OrderDate;
            result.modified          = data.OrderDate;
            result.pay_time          = data.PayDate;
            result.consign_time      = data.ShippingDate;
            result.end_time          = data.FinishDate;
            result.buyer_uname       = data.UserName;
            result.buyer_email       = UserInfo.Email;
            result.buyer_nick        = UserInfo.Nick;
            result.buyer_area        = regionService.GetFullName(UserInfo.RegionId, "");
            result.receiver_name     = data.ShipTo;
            result.receiver_state    = state;
            result.receiver_city     = city;
            result.receiver_district = district;
            result.receiver_town     = town;
            result.receiver_address  = data.Address;
            result.receiver_zip      = ""; //无邮编
            result.receiver_mobile   = data.CellPhone;
            result.seller_id         = data.ShopId.ToString();
            result.seller_name       = data.ShopName;
            result.seller_mobile     = data.SellerPhone;
            result.invoice_fee       = data.Tax;
            result.invoice_title     = data.InvoiceTitle;
            result.payment           = data.ProductTotalAmount;
            result.storeId           = "0"; //无门店功能,云商城有
            result.orders            = new List <trade_itme_model>();

            #region 子预约单装配

            foreach (var orderitem in data.OrderItemInfo)
            {
                ProductTypeInfo  typeInfo     = _iTypeService.GetTypeByProductId(orderitem.ProductId);
                string           colorAlias   = (typeInfo == null || string.IsNullOrEmpty(typeInfo.ColorAlias)) ? SpecificationType.Color.ToDescription() : typeInfo.ColorAlias;
                string           sizeAlias    = (typeInfo == null || string.IsNullOrEmpty(typeInfo.SizeAlias)) ? SpecificationType.Size.ToDescription() : typeInfo.SizeAlias;
                string           versionAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.VersionAlias)) ? SpecificationType.Version.ToDescription() : typeInfo.VersionAlias;
                trade_itme_model tradesItem   = new trade_itme_model();
                tradesItem.sku_id = orderitem.SkuId;
                //tradesItem.num_id = orderitem.SKU;
                tradesItem.outer_sku_id = orderitem.SKU;
                tradesItem.title        = orderitem.ProductName;
                string skuFullName = "";
                if (!string.IsNullOrEmpty(orderitem.Color))
                {
                    skuFullName = colorAlias + ":" + orderitem.Color + ";";
                }
                //skuFullName = "颜色:" + orderitem.Color + ";";
                if (!string.IsNullOrEmpty(orderitem.Size))
                {
                    skuFullName = sizeAlias + ":" + orderitem.Size + ";";
                }
                //skuFullName = "尺码:" + orderitem.Size + ";";
                if (!string.IsNullOrEmpty(orderitem.Version))
                {
                    skuFullName = versionAlias + ":" + orderitem.Version + ";";
                }
                //skuFullName = "版本:" + orderitem.Version + ";";
                if (!string.IsNullOrEmpty(skuFullName))
                {
                    skuFullName = skuFullName.TrimEnd(';');
                }
                tradesItem.sku_properties_name = skuFullName;
                tradesItem.price    = orderitem.SalePrice;
                tradesItem.num      = (int)orderitem.Quantity;
                tradesItem.pic_path = OpenAPIHelper.HostUrl + orderitem.ThumbnailsUrl;

                tradesItem.refund_status = status;
                result.orders.Add(tradesItem);
            }
            #endregion

            return(result);
        }