コード例 #1
0
 private PurchaseOrderInfo GetPurchaseOrderInfo()
 {
     PurchaseOrderInfo info = new PurchaseOrderInfo();
     Distributor user = Users.GetUser(HiContext.Current.User.UserId) as Distributor;
     string orderId = GeneratePurchaseOrderId();
     info.PurchaseOrderId = orderId;
     IList<PurchaseShoppingCartItemInfo> purchaseShoppingCartItemInfos = SubsiteSalesHelper.GetPurchaseShoppingCartItemInfos();
     int totalWeight = 0;
     if (purchaseShoppingCartItemInfos.Count >= 1)
     {
         PurchaseOrderItemInfo item = null;
         foreach (PurchaseShoppingCartItemInfo info2 in purchaseShoppingCartItemInfos)
         {
             item = new PurchaseOrderItemInfo();
             item.PurchaseOrderId = orderId;
             item.SkuId = info2.SkuId;
             item.ThumbnailsUrl = info2.ThumbnailsUrl;
             item.SKUContent = info2.SKUContent;
             item.SKU = info2.SKU;
             item.Quantity = info2.Quantity;
             item.ProductId = info2.ProductId;
             item.ItemWeight = info2.ItemWeight;
             item.ItemCostPrice = info2.CostPrice;
             item.ItemPurchasePrice = info2.ItemPurchasePrice;
             item.ItemListPrice = info2.ItemListPrice;
             item.ItemDescription = info2.ItemDescription;
             item.ItemHomeSiteDescription = info2.ItemDescription;
             totalWeight += info2.ItemWeight * info2.Quantity;
             info.PurchaseOrderItems.Add(item);
         }
         ShippingModeInfo shippingMode = SubsiteSalesHelper.GetShippingMode(radioShippingMode.SelectedValue.Value, true);
         info.ShipTo = txtShipTo.Text.Trim();
         if (rsddlRegion.GetSelectedRegionId().HasValue)
         {
             info.RegionId = rsddlRegion.GetSelectedRegionId().Value;
         }
         info.Address = Globals.HtmlEncode(txtAddress.Value.Trim());
         info.TelPhone = txtTel.Text.Trim();
         info.ZipCode = txtZipcode.Text.Trim();
         info.CellPhone = txtMobile.Text.Trim();
         info.OrderId = null;
         info.RealShippingModeId = radioShippingMode.SelectedValue.Value;
         info.RealModeName = shippingMode.Name;
         info.ShippingModeId = radioShippingMode.SelectedValue.Value;
         info.ModeName = shippingMode.Name;
         info.AdjustedFreight = SubsiteSalesHelper.CalcFreight(info.RegionId, totalWeight, shippingMode);
         info.Freight = info.AdjustedFreight;
         info.ShippingRegion = rsddlRegion.SelectedRegions;
         info.Remark = Globals.HtmlEncode(txtRemark.Text.Trim());
         info.PurchaseStatus = OrderStatus.WaitBuyerPay;
         info.DistributorId = user.UserId;
         info.Distributorname = user.Username;
         info.DistributorEmail = user.Email;
         info.DistributorRealName = user.RealName;
         info.DistributorQQ = user.QQ;
         info.DistributorWangwang = user.Wangwang;
         info.DistributorMSN = user.MSN;
         info.RefundStatus = RefundStatus.None;
         info.Weight = totalWeight;
         info.ExpressCompanyAbb = shippingMode.ExpressCompanyAbb;
         info.ExpressCompanyName = shippingMode.ExpressCompanyName;
     }
     return info;
 }
コード例 #2
0
ファイル: PurchaseOrderData.cs プロジェクト: davinx/himedi
 PurchaseOrderInfo ConvertOrderToPurchaseOrder(OrderInfo order)
 {
     if (order == null)
     {
         return null;
     }
     StringBuilder builder = new StringBuilder();
     string query = "";
     foreach (LineItemInfo info in order.LineItems.Values)
     {
         builder.AppendFormat("'" + info.SkuId + "',", new object[0]);
     }
     if (builder.Length > 0)
     {
         builder = builder.Remove(builder.Length - 1, 1);
         query = string.Format("SELECT S.SkuId, S.CostPrice, p.ProductName FROM Hishop_Products P JOIN Hishop_SKUs S ON P.ProductId = S.ProductId WHERE S.SkuId IN({0});", builder);
     }
     if (order.Gifts.Count > 0)
     {
         StringBuilder builder2 = new StringBuilder();
         foreach (OrderGiftInfo info2 in order.Gifts)
         {
             builder2.AppendFormat(info2.GiftId.ToString() + ",", new object[0]);
         }
         builder2.Remove(builder2.Length - 1, 1);
         query = query + string.Format(" SELECT GiftId, CostPrice FROM Hishop_Gifts WHERE GiftId IN({0});", builder2.ToString());
     }
     DbCommand sqlStringCommand = database.GetSqlStringCommand(query);
     Dictionary<string, PurchaseOrderItemInfo> dictionary = new Dictionary<string, PurchaseOrderItemInfo>();
     Dictionary<int, decimal> dictionary2 = new Dictionary<int, decimal>();
     using (IDataReader reader = database.ExecuteReader(sqlStringCommand))
     {
         if (order.LineItems.Values.Count > 0)
         {
             while (reader.Read())
             {
                 PurchaseOrderItemInfo info3 = new PurchaseOrderItemInfo();
                 if (reader["CostPrice"] != DBNull.Value)
                 {
                     info3.ItemCostPrice = (decimal)reader["CostPrice"];
                 }
                 info3.ItemHomeSiteDescription = (string)reader["ProductName"];
                 dictionary.Add((string)reader["SkuId"], info3);
             }
         }
         if (order.Gifts.Count > 0)
         {
             if (order.LineItems.Count > 0)
             {
                 reader.NextResult();
             }
             while (reader.Read())
             {
                 dictionary2.Add((int)reader["GiftId"], (DBNull.Value == reader["CostPrice"]) ? 0M : Convert.ToDecimal(reader["CostPrice"]));
             }
         }
     }
     IUser user = Users.GetUser(HiContext.Current.SiteSettings.UserId.Value, false);
     if ((user == null) || (user.UserRole != UserRole.Distributor))
     {
         return null;
     }
     Distributor distributor = user as Distributor;
     PurchaseOrderInfo info4 = new PurchaseOrderInfo();
     info4.PurchaseOrderId = "PO" + order.OrderId;
     info4.OrderId = order.OrderId;
     info4.Remark = order.Remark;
     info4.PurchaseStatus = OrderStatus.WaitBuyerPay;
     info4.DistributorId = distributor.UserId;
     info4.Distributorname = distributor.Username;
     info4.DistributorEmail = distributor.Email;
     info4.DistributorRealName = distributor.RealName;
     info4.DistributorQQ = distributor.QQ;
     info4.DistributorWangwang = distributor.Wangwang;
     info4.DistributorMSN = distributor.MSN;
     info4.ShippingRegion = order.ShippingRegion;
     info4.Address = order.Address;
     info4.ZipCode = order.ZipCode;
     info4.ShipTo = order.ShipTo;
     info4.TelPhone = order.TelPhone;
     info4.CellPhone = order.CellPhone;
     info4.ShippingModeId = order.ShippingModeId;
     info4.ModeName = order.ModeName;
     info4.RegionId = order.RegionId;
     info4.Freight = order.Freight;
     info4.AdjustedFreight = order.Freight;
     info4.ShipOrderNumber = order.ShipOrderNumber;
     info4.Weight = order.Weight;
     info4.RefundStatus = RefundStatus.None;
     info4.OrderTotal = order.GetTotal();
     info4.ExpressCompanyName = order.ExpressCompanyName;
     info4.ExpressCompanyAbb = order.ExpressCompanyAbb;
     foreach (LineItemInfo info5 in order.LineItems.Values)
     {
         PurchaseOrderItemInfo item = new PurchaseOrderItemInfo();
         item.PurchaseOrderId = info4.PurchaseOrderId;
         item.SkuId = info5.SkuId;
         item.ProductId = info5.ProductId;
         item.SKU = info5.SKU;
         item.Quantity = info5.ShipmentQuantity;
         foreach (KeyValuePair<string, PurchaseOrderItemInfo> pair in dictionary)
         {
             if (pair.Key == info5.SkuId)
             {
                 item.ItemCostPrice = pair.Value.ItemCostPrice;
                 item.ItemHomeSiteDescription = pair.Value.ItemHomeSiteDescription;
             }
         }
         item.ItemPurchasePrice = info5.ItemCostPrice;
         item.ItemListPrice = info5.ItemListPrice;
         item.ItemDescription = info5.ItemDescription;
         item.SKUContent = info5.SKUContent;
         item.ThumbnailsUrl = info5.ThumbnailsUrl;
         item.ItemWeight = info5.ItemWeight;
         if (string.IsNullOrEmpty(item.ItemHomeSiteDescription))
         {
             item.ItemHomeSiteDescription = item.ItemDescription;
         }
         info4.PurchaseOrderItems.Add(item);
     }
     foreach (OrderGiftInfo info7 in order.Gifts)
     {
         PurchaseOrderGiftInfo info8 = new PurchaseOrderGiftInfo();
         info8.PurchaseOrderId = info4.PurchaseOrderId;
         foreach (KeyValuePair<int, decimal> pair2 in dictionary2)
         {
             if (pair2.Key == info7.GiftId)
             {
                 info8.CostPrice = pair2.Value;
             }
         }
         info8.PurchasePrice = info7.CostPrice;
         info8.GiftId = info7.GiftId;
         info8.GiftName = info7.GiftName;
         info8.Quantity = info7.Quantity;
         info8.ThumbnailsUrl = info7.ThumbnailsUrl;
         info4.PurchaseOrderGifts.Add(info8);
     }
     foreach (OrderOptionInfo info9 in order.OrderOptions)
     {
         PurchaseOrderOptionInfo info10 = new PurchaseOrderOptionInfo();
         info10.PurchaseOrderId = info4.PurchaseOrderId;
         info10.LookupListId = info9.LookupListId;
         info10.LookupItemId = info9.LookupItemId;
         info10.ListDescription = info9.ListDescription;
         info10.ItemDescription = info9.ItemDescription;
         info10.AdjustedPrice = info9.AdjustedPrice;
         info10.CustomerTitle = info9.CustomerTitle;
         info10.CustomerDescription = info9.CustomerDescription;
         info4.PurchaseOrderOptions.Add(info10);
     }
     return info4;
 }
コード例 #3
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            if (ValidateCreateOrder())
            {
                string str = "";

                PurchaseOrderInfo purchaseOrderInfo = new PurchaseOrderInfo();

                Distributor user = Users.GetUser(HiContext.Current.User.UserId) as Distributor;

                purchaseOrderInfo.PurchaseOrderId = GeneratePurchaseOrderId();

                int totalWeight = 0;

                for (int i = 0; i < rpTaobaoOrder.Items.Count; i++)
                {
                    CheckBox box = (CheckBox)rpTaobaoOrder.Items[i].FindControl("chkTbOrder");

                    if (box.Checked)
                    {
                        str = str + tbOrders[i].orderId + ",";
                        Repeater repeater = (Repeater)rpTaobaoOrder.Items[i].FindControl("reOrderItems");
                        IList<tbOrderItem> items = tbOrders[i].items;
                        for (int j = 0; j < repeater.Items.Count; j++)
                        {
                            if (items[j].localSkuId.Trim() == "")
                            {
                                string msg = string.Format("在授权给分销商的商品中没有找到淘宝商品:{0}!请重新查找", items[j].title);
                                ShowMsg(msg, false);
                                return;
                            }
                            string localSkuId = items[j].localSkuId;
                            TextBox box2 = (TextBox)repeater.Items[j].FindControl("productNumber");
                            int num4 = Convert.ToInt32(box2.Text);
                            bool flag = false;
                            foreach (PurchaseOrderItemInfo info2 in purchaseOrderInfo.PurchaseOrderItems)
                            {
                                if (info2.SKU == localSkuId)
                                {
                                    flag = true;
                                    info2.Quantity += num4;
                                    totalWeight += info2.ItemWeight * num4;
                                }
                            }
                            if (!flag)
                            {
                                DataTable skuContentBySku = SubSiteProducthelper.GetSkuContentBySku(localSkuId);
                                PurchaseOrderItemInfo item = new PurchaseOrderItemInfo();
                                if (num4 > ((int)skuContentBySku.Rows[0]["Stock"]))
                                {
                                    ShowMsg("商品库存不够", false);
                                    return;
                                }
                                foreach (DataRow row in skuContentBySku.Rows)
                                {
                                    if (!(string.IsNullOrEmpty(row["AttributeName"].ToString()) || string.IsNullOrEmpty(row["ValueStr"].ToString())))
                                    {
                                        object sKUContent = item.SKUContent;
                                        item.SKUContent = string.Concat(new object[] { sKUContent, row["AttributeName"], ":", row["ValueStr"], "; " });
                                    }
                                }
                                item.PurchaseOrderId = purchaseOrderInfo.PurchaseOrderId;
                                item.SkuId = localSkuId;
                                item.ProductId = (int)skuContentBySku.Rows[0]["ProductId"];
                                if (skuContentBySku.Rows[0]["SKU"] != DBNull.Value)
                                {
                                    item.SKU = (string)skuContentBySku.Rows[0]["SKU"];
                                }
                                if (skuContentBySku.Rows[0]["Weight"] != DBNull.Value)
                                {
                                    item.ItemWeight = (int)skuContentBySku.Rows[0]["Weight"];
                                }
                                item.ItemPurchasePrice = (decimal)skuContentBySku.Rows[0]["PurchasePrice"];
                                item.Quantity = num4;
                                item.ItemListPrice = (decimal)skuContentBySku.Rows[0]["SalePrice"];
                                if (skuContentBySku.Rows[0]["CostPrice"] != DBNull.Value)
                                {
                                    item.ItemCostPrice = (decimal)skuContentBySku.Rows[0]["CostPrice"];
                                }
                                item.ItemDescription = (string)skuContentBySku.Rows[0]["ProductName"];
                                item.ItemHomeSiteDescription = (string)skuContentBySku.Rows[0]["ProductName"];
                                if (skuContentBySku.Rows[0]["ThumbnailUrl40"] != DBNull.Value)
                                {
                                    item.ThumbnailsUrl = (string)skuContentBySku.Rows[0]["ThumbnailUrl40"];
                                }
                                totalWeight += item.ItemWeight * num4;
                                purchaseOrderInfo.PurchaseOrderItems.Add(item);
                            }
                        }
                    }
                }
                if (str == "")
                {
                    ShowMsg("至少选择一个淘宝订单!!", false);
                }
                else
                {
                    ShippingModeInfo shippingMode = SubsiteSalesHelper.GetShippingMode(radioShippingMode.SelectedValue.Value, true);
                    purchaseOrderInfo.ShipTo = txtShipTo.Text.Trim();
                    if (rsddlRegion.GetSelectedRegionId().HasValue)
                    {
                        purchaseOrderInfo.RegionId = rsddlRegion.GetSelectedRegionId().Value;
                    }
                    purchaseOrderInfo.Address = txtAddress.Text.Trim();
                    purchaseOrderInfo.TelPhone = txtTel.Text.Trim();
                    purchaseOrderInfo.ZipCode = txtZipcode.Text.Trim();
                    purchaseOrderInfo.CellPhone = txtMobile.Text.Trim();
                    purchaseOrderInfo.OrderId = null;
                    purchaseOrderInfo.RealShippingModeId = radioShippingMode.SelectedValue.Value;
                    purchaseOrderInfo.RealModeName = shippingMode.Name;
                    purchaseOrderInfo.ShippingModeId = radioShippingMode.SelectedValue.Value;
                    purchaseOrderInfo.ModeName = shippingMode.Name;
                    purchaseOrderInfo.AdjustedFreight = SubsiteSalesHelper.CalcFreight(purchaseOrderInfo.RegionId, totalWeight, shippingMode);
                    purchaseOrderInfo.Freight = purchaseOrderInfo.AdjustedFreight;
                    purchaseOrderInfo.ShippingRegion = rsddlRegion.SelectedRegions;
                    purchaseOrderInfo.PurchaseStatus = OrderStatus.WaitBuyerPay;
                    purchaseOrderInfo.DistributorId = user.UserId;
                    purchaseOrderInfo.Distributorname = user.Username;
                    purchaseOrderInfo.DistributorEmail = user.Email;
                    purchaseOrderInfo.DistributorRealName = user.RealName;
                    purchaseOrderInfo.DistributorQQ = user.QQ;
                    purchaseOrderInfo.DistributorWangwang = user.Wangwang;
                    purchaseOrderInfo.DistributorMSN = user.MSN;
                    purchaseOrderInfo.RefundStatus = RefundStatus.None;
                    purchaseOrderInfo.Weight = totalWeight;
                    purchaseOrderInfo.Remark = null;
                    purchaseOrderInfo.TaobaoOrderId = str;
                    if (purchaseOrderInfo.PurchaseOrderItems.Count == 0)
                    {
                        ShowMsg("您暂时未选择您要添加的商品", false);
                    }
                    else if (SubsiteSalesHelper.CreatePurchaseOrder(purchaseOrderInfo))
                    {
                        SubsiteSalesHelper.ClearPurchaseShoppingCart();
                        ResponseCookies();
                        base.Response.Redirect(Globals.ApplicationPath + "/Shopadmin/purchaseOrder/Pay.aspx?PurchaseOrderId=" + purchaseOrderInfo.PurchaseOrderId);
                    }
                    else
                    {
                        ShowMsg("提交采购单失败", false);
                    }
                }
            }
        }
コード例 #4
0
ファイル: DataMapper.cs プロジェクト: davinx/himedi
 public static PurchaseOrderItemInfo PopulatePurchaseOrderItem(IDataReader reader)
 {
     if (null == reader)
     {
         return null;
     }
     PurchaseOrderItemInfo info = new PurchaseOrderItemInfo();
     info.PurchaseOrderId = (string) reader["PurchaseOrderId"];
     info.SkuId = (string) reader["SkuId"];
     info.ProductId = (int) reader["ProductId"];
     if (DBNull.Value != reader["SKU"])
     {
         info.SKU = (string) reader["SKU"];
     }
     info.Quantity = (int) reader["Quantity"];
     info.ItemCostPrice = (decimal) reader["CostPrice"];
     info.ItemListPrice = (decimal) reader["ItemListPrice"];
     info.ItemPurchasePrice = (decimal) reader["ItemPurchasePrice"];
     info.ItemDescription = (string) reader["ItemDescription"];
     info.ItemHomeSiteDescription = (string) reader["ItemHomeSiteDescription"];
     if (reader["ThumbnailsUrl"] != DBNull.Value)
     {
         info.ThumbnailsUrl = (string) reader["ThumbnailsUrl"];
     }
     info.ItemWeight = (reader["Weight"] == DBNull.Value) ? 0 : ((int) reader["Weight"]);
     if (reader["SKUContent"] != DBNull.Value)
     {
         info.SKUContent = (string) reader["SKUContent"];
     }
     return info;
 }
コード例 #5
0
        private PurchaseOrderInfo GetPurchaseOrder(Trade trade)
        {
            PurchaseOrderInfo info = new PurchaseOrderInfo();

            info.PurchaseOrderId = "MPO" + trade.Tid.ToString();
            info.TaobaoOrderId = trade.Tid.ToString();
            info.ShipTo = trade.ReceiverName;
            info.ShippingRegion = trade.ReceiverState + trade.ReceiverCity + trade.ReceiverDistrict;
            info.RegionId = RegionHelper.GetRegionIdByName(trade.ReceiverState, trade.ReceiverCity, trade.ReceiverDistrict);
            info.Address = trade.ReceiverAddress;
            info.TelPhone = trade.ReceiverPhone;
            info.ZipCode = trade.ReceiverZip;
            info.CellPhone = trade.ReceiverMobile;
            info.ShippingModeId = shippingMode.ModeId;
            info.ModeName = shippingMode.Name;
            info.RealShippingModeId = shippingMode.ModeId;
            info.RealModeName = shippingMode.Name;
            info.AdjustedDiscount = 0M;
            info.OrderTotal = decimal.Parse(trade.Payment);
            int totalWeight = 0;

            foreach (Order order in trade.Orders)
            {

                DataTable skuContent = SubSiteProducthelper.GetSkuContent(order.NumIid, order.OuterSkuId);

                if ((skuContent != null) && (skuContent.Rows.Count > 0))
                {
                    PurchaseOrderItemInfo item = new PurchaseOrderItemInfo();

                    foreach (DataRow row in skuContent.Rows)
                    {
                        if (!(string.IsNullOrEmpty(row["AttributeName"].ToString()) || string.IsNullOrEmpty(row["ValueStr"].ToString())))
                        {
                            object sKUContent = item.SKUContent;
                            item.SKUContent = string.Concat(new object[] { sKUContent, row["AttributeName"], ":", row["ValueStr"], "; " });
                        }
                    }
                    item.PurchaseOrderId = info.PurchaseOrderId;
                    item.SkuId = (string)skuContent.Rows[0]["SkuId"];
                    item.ProductId = (int)skuContent.Rows[0]["ProductId"];
                    if (skuContent.Rows[0]["SKU"] != DBNull.Value)
                    {
                        item.SKU = (string)skuContent.Rows[0]["SKU"];
                    }
                    if (skuContent.Rows[0]["Weight"] != DBNull.Value)
                    {
                        item.ItemWeight = (int)skuContent.Rows[0]["Weight"];
                    }
                    item.ItemPurchasePrice = (decimal)skuContent.Rows[0]["PurchasePrice"];
                    item.Quantity = int.Parse(order.Num.ToString());
                    item.ItemListPrice = (decimal)skuContent.Rows[0]["SalePrice"];
                    if (skuContent.Rows[0]["CostPrice"] != DBNull.Value)
                    {
                        item.ItemCostPrice = (decimal)skuContent.Rows[0]["CostPrice"];
                    }
                    item.ItemDescription = (string)skuContent.Rows[0]["ProductName"];
                    item.ItemHomeSiteDescription = (string)skuContent.Rows[0]["ProductName"];
                    if (skuContent.Rows[0]["ThumbnailUrl40"] != DBNull.Value)
                    {
                        item.ThumbnailsUrl = (string)skuContent.Rows[0]["ThumbnailUrl40"];
                    }
                    totalWeight += item.ItemWeight * item.Quantity;
                    info.PurchaseOrderItems.Add(item);
                }
            }
            if (info.PurchaseOrderItems.Count <= 0)
            {
                return null;
            }
            info.Weight = totalWeight;
            info.AdjustedFreight = SubsiteSalesHelper.CalcFreight(info.RegionId, totalWeight, shippingMode);
            info.Freight = info.AdjustedFreight;
            info.PurchaseStatus = OrderStatus.WaitBuyerPay;
            info.RefundStatus = RefundStatus.None;
            info.DistributorId = distributor.UserId;
            info.Distributorname = distributor.Username;
            info.DistributorEmail = distributor.Email;
            info.DistributorRealName = distributor.RealName;
            info.DistributorQQ = distributor.QQ;
            info.DistributorWangwang = distributor.Wangwang;
            info.DistributorMSN = distributor.MSN;
            return info;
        }