Esempio n. 1
0
        public static bool AddOrderGift(OrderInfo order, GiftInfo gift, int quantity, int promotype)
        {
            bool flag;

            using (DbConnection connection = DatabaseFactory.CreateDatabase().CreateConnection())
            {
                connection.Open();
                DbTransaction dbTran = connection.BeginTransaction();
                try
                {
                    if (!SubsiteSalesProvider.Instance().AddOrderGift(order.OrderId, gift, quantity, promotype, dbTran))
                    {
                        dbTran.Rollback();
                        return(false);
                    }
                    bool flag2 = false;
                    foreach (OrderGiftInfo info in order.Gifts)
                    {
                        if (info.GiftId == gift.GiftId)
                        {
                            flag2          = true;
                            info.Quantity += quantity;
                        }
                    }
                    if (!flag2)
                    {
                        OrderGiftInfo item = new OrderGiftInfo();
                        item.GiftId        = gift.GiftId;
                        item.OrderId       = order.OrderId;
                        item.GiftName      = gift.Name;
                        item.Quantity      = quantity;
                        item.CostPrice     = gift.PurchasePrice;
                        item.ThumbnailsUrl = gift.ThumbnailUrl40;
                        item.PromoteType   = promotype;
                        order.Gifts.Add(item);
                    }
                    if (!SubsiteSalesProvider.Instance().UpdateOrderAmount(order, dbTran))
                    {
                        dbTran.Rollback();
                        return(false);
                    }
                    dbTran.Commit();
                    flag = true;
                }
                catch
                {
                    dbTran.Rollback();
                    flag = false;
                }
                finally
                {
                    connection.Close();
                }
            }
            return(flag);
        }
Esempio n. 2
0
        public static bool DeleteOrderGift(OrderInfo order, int giftId)
        {
            ManagerHelper.CheckPrivilege(Privilege.EditOrders);
            Database database = DatabaseFactory.CreateDatabase();
            bool     result;

            using (System.Data.Common.DbConnection dbConnection = database.CreateConnection())
            {
                dbConnection.Open();
                System.Data.Common.DbTransaction dbTransaction = dbConnection.BeginTransaction();
                try
                {
                    SalesProvider salesProvider = SalesProvider.Instance();
                    OrderGiftInfo orderGift     = salesProvider.GetOrderGift(giftId, order.OrderId);
                    order.Gifts.Remove(orderGift);
                    if (!salesProvider.DeleteOrderGift(order.OrderId, orderGift.GiftId, dbTransaction))
                    {
                        dbTransaction.Rollback();
                        result = false;
                    }
                    else
                    {
                        if (!salesProvider.UpdateOrderAmount(order, dbTransaction))
                        {
                            dbTransaction.Rollback();
                            result = false;
                        }
                        else
                        {
                            dbTransaction.Commit();
                            EventLogs.WriteOperationLog(Privilege.EditOrders, string.Format(CultureInfo.InvariantCulture, "删除了订单号为\"{0}\"的订单礼品", new object[]
                            {
                                order.OrderId
                            }));
                            result = true;
                        }
                    }
                }
                catch
                {
                    dbTransaction.Rollback();
                    result = false;
                }
                finally
                {
                    dbConnection.Close();
                }
            }
            return(result);
        }
Esempio n. 3
0
 private void rptPointGifts_ItemDataBound(object sender, RepeaterItemEventArgs e)
 {
     if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
     {
         OrderGiftInfo orderGiftInfo = e.Item.DataItem as OrderGiftInfo;
         HtmlAnchor    htmlAnchor    = e.Item.FindControl("hylinkGiftName") as HtmlAnchor;
         Literal       literal       = e.Item.FindControl("ltlPoints") as Literal;
         Literal       literal2      = e.Item.FindControl("ltlGiftCount") as Literal;
         HtmlAnchor    htmlAnchor2   = e.Item.FindControl("hyDetailLink") as HtmlAnchor;
         string        hRef          = (orderGiftInfo.NeedPoint == 1) ? ("ServiceMemberOrderDetails.aspx?OrderId=" + orderGiftInfo.OrderId) : ("MemberOrderDetails.aspx?OrderId=" + orderGiftInfo.OrderId);
         htmlAnchor.InnerText = orderGiftInfo.GiftName;
         htmlAnchor.HRef      = hRef;
         literal2.Text        = orderGiftInfo.Quantity.ToNullString();
         htmlAnchor2.HRef     = hRef;
     }
 }
Esempio n. 4
0
        public OrderGiftInfo GetOrderGift(int giftId, string orderId)
        {
            OrderGiftInfo result           = null;
            DbCommand     sqlStringCommand = this.database.GetSqlStringCommand("SELECT * FROM Ecshop_OrderGifts WHERE OrderId=@OrderId AND GiftId=@GiftId");

            this.database.AddInParameter(sqlStringCommand, "OrderId", DbType.String, orderId);
            this.database.AddInParameter(sqlStringCommand, "GiftId", DbType.Int32, giftId);
            using (IDataReader dataReader = this.database.ExecuteReader(sqlStringCommand))
            {
                if (dataReader.Read())
                {
                    result = DataMapper.PopulateOrderGift(dataReader);
                }
            }
            return(result);
        }
Esempio n. 5
0
        public bool AddOrderGift(string orderId, OrderGiftInfo gift, int quantity, DbTransaction dbTran)
        {
            DbCommand sqlStringCommand = this.database.GetSqlStringCommand("select * from Ecshop_OrderGifts where OrderId=@OrderId AND GiftId=@GiftId");

            this.database.AddInParameter(sqlStringCommand, "OrderId", DbType.String, orderId);
            this.database.AddInParameter(sqlStringCommand, "GiftId", DbType.Int32, gift.GiftId);
            bool result;

            using (IDataReader dataReader = this.database.ExecuteReader(sqlStringCommand))
            {
                if (dataReader.Read())
                {
                    DbCommand sqlStringCommand2 = this.database.GetSqlStringCommand("update Ecshop_OrderGifts set Quantity=@Quantity where OrderId=@OrderId AND GiftId=@GiftId");
                    this.database.AddInParameter(sqlStringCommand2, "OrderId", DbType.String, orderId);
                    this.database.AddInParameter(sqlStringCommand2, "GiftId", DbType.Int32, gift.GiftId);
                    this.database.AddInParameter(sqlStringCommand2, "Quantity", DbType.Int32, (int)dataReader["Quantity"] + quantity);
                    if (dbTran != null)
                    {
                        result = (this.database.ExecuteNonQuery(sqlStringCommand2, dbTran) == 1);
                    }
                    else
                    {
                        result = (this.database.ExecuteNonQuery(sqlStringCommand2) == 1);
                    }
                }
                else
                {
                    DbCommand sqlStringCommand3 = this.database.GetSqlStringCommand("INSERT INTO Ecshop_OrderGifts(OrderId,GiftId,GiftName,CostPrice,ThumbnailsUrl,Quantity,PromoType) VALUES(@OrderId,@GiftId,@GiftName,@CostPrice,@ThumbnailsUrl,@Quantity,@PromoType)");
                    this.database.AddInParameter(sqlStringCommand3, "OrderId", DbType.String, orderId);
                    this.database.AddInParameter(sqlStringCommand3, "GiftId", DbType.Int32, gift.GiftId);
                    this.database.AddInParameter(sqlStringCommand3, "GiftName", DbType.String, gift.GiftName);
                    this.database.AddInParameter(sqlStringCommand3, "CostPrice", DbType.Currency, gift.CostPrice);
                    this.database.AddInParameter(sqlStringCommand3, "ThumbnailsUrl", DbType.String, gift.ThumbnailsUrl);
                    this.database.AddInParameter(sqlStringCommand3, "Quantity", DbType.Int32, gift.Quantity);
                    this.database.AddInParameter(sqlStringCommand3, "PromoType", DbType.Int16, gift.PromoteType);
                    if (dbTran != null)
                    {
                        result = (this.database.ExecuteNonQuery(sqlStringCommand3, dbTran) == 1);
                    }
                    else
                    {
                        result = (this.database.ExecuteNonQuery(sqlStringCommand3) == 1);
                    }
                }
            }
            return(result);
        }
Esempio n. 6
0
        public static bool DeleteOrderGift(OrderInfo order, int giftId)
        {
            bool flag;

            ManagerHelper.CheckPrivilege(Privilege.EditOrders);
            using (DbConnection connection = DatabaseFactory.CreateDatabase().CreateConnection())
            {
                connection.Open();
                DbTransaction dbTran = connection.BeginTransaction();
                try
                {
                    SalesProvider provider  = SalesProvider.Instance();
                    OrderGiftInfo orderGift = provider.GetOrderGift(giftId, order.OrderId);
                    order.Gifts.Remove(orderGift);
                    if (!provider.DeleteOrderGift(order.OrderId, orderGift.GiftId, dbTran))
                    {
                        dbTran.Rollback();
                        return(false);
                    }
                    if (!provider.UpdateOrderAmount(order, dbTran))
                    {
                        dbTran.Rollback();
                        return(false);
                    }
                    dbTran.Commit();
                    EventLogs.WriteOperationLog(Privilege.EditOrders, string.Format(CultureInfo.InvariantCulture, "删除了订单号为\"{0}\"的订单礼品", new object[] { order.OrderId }));
                    flag = true;
                }
                catch
                {
                    dbTran.Rollback();
                    flag = false;
                }
                finally
                {
                    connection.Close();
                }
            }
            return(flag);
        }
Esempio n. 7
0
        public bool AddOrderGift(string orderId, OrderGiftInfo gift, int quantity, DbTransaction dbTran)
        {
            //先查是否存在订单
            DbCommand sqlStringCommand = this.database.GetSqlStringCommand("select * from Hishop_OrderGifts where OrderId=@OrderId AND GiftId=@GiftId");

            this.database.AddInParameter(sqlStringCommand, "OrderId", DbType.String, orderId);
            this.database.AddInParameter(sqlStringCommand, "GiftId", DbType.Int32, gift.GiftId);
            using (IDataReader reader = this.database.ExecuteReader(sqlStringCommand))
            {
                //若存在,则update
                if (reader.Read())
                {
                    DbCommand command2 = this.database.GetSqlStringCommand("update Hishop_OrderGifts set Quantity=@Quantity where OrderId=@OrderId AND GiftId=@GiftId");
                    this.database.AddInParameter(command2, "OrderId", DbType.String, orderId);
                    this.database.AddInParameter(command2, "GiftId", DbType.Int32, gift.GiftId);
                    this.database.AddInParameter(command2, "Quantity", DbType.Int32, ((int)reader["Quantity"]) + quantity);
                    if (dbTran != null)
                    {
                        return(this.database.ExecuteNonQuery(command2, dbTran) == 1);
                    }
                    return(this.database.ExecuteNonQuery(command2) == 1);
                }
                //否则insert
                DbCommand command = this.database.GetSqlStringCommand("INSERT INTO Hishop_OrderGifts(OrderId,GiftId,GiftName,CostPrice,costPoint,ThumbnailsUrl,Quantity,PromoType) VALUES(@OrderId,@GiftId,@GiftName,@CostPrice,@costPoint,@ThumbnailsUrl,@Quantity,@PromoType)");
                this.database.AddInParameter(command, "OrderId", DbType.String, orderId);
                this.database.AddInParameter(command, "GiftId", DbType.Int32, gift.GiftId);
                this.database.AddInParameter(command, "GiftName", DbType.String, gift.GiftName);
                this.database.AddInParameter(command, "CostPrice", DbType.Currency, gift.CostPrice);
                this.database.AddInParameter(command, "costPoint", DbType.Currency, gift.costPoint);
                this.database.AddInParameter(command, "ThumbnailsUrl", DbType.String, gift.ThumbnailsUrl);
                this.database.AddInParameter(command, "Quantity", DbType.Int32, gift.Quantity);
                this.database.AddInParameter(command, "PromoType", DbType.Int16, gift.PromoteType);
                if (dbTran != null)
                {
                    return(this.database.ExecuteNonQuery(command, dbTran) == 1);
                }
                return(this.database.ExecuteNonQuery(command) == 1);
            }
        }
Esempio n. 8
0
        public static bool AddOrderGift(OrderInfo order, GiftInfo giftinfo, int quantity)
        {
            bool flag;

            ManagerHelper.CheckPrivilege(Privilege.EditOrders);
            using (DbConnection connection = DatabaseFactory.CreateDatabase().CreateConnection())
            {
                connection.Open();
                DbTransaction dbTran = connection.BeginTransaction();
                try
                {
                    SalesProvider provider = SalesProvider.Instance();
                    OrderGiftInfo item     = new OrderGiftInfo();
                    item.OrderId  = order.OrderId;
                    item.Quantity = quantity;
                    item.GiftName = giftinfo.Name;
                    decimal costPrice = item.CostPrice;
                    item.CostPrice     = Convert.ToDecimal(giftinfo.CostPrice);
                    item.GiftId        = giftinfo.GiftId;
                    item.ThumbnailsUrl = giftinfo.ThumbnailUrl40;
                    bool flag2 = false;
                    foreach (OrderGiftInfo info2 in order.Gifts)
                    {
                        if (giftinfo.GiftId == info2.GiftId)
                        {
                            flag2          = true;
                            info2.Quantity = quantity;
                            break;
                        }
                    }
                    if (!flag2)
                    {
                        order.Gifts.Add(item);
                    }
                    if (!provider.AddOrderGift(order.OrderId, item, quantity, dbTran))
                    {
                        dbTran.Rollback();
                        return(false);
                    }
                    if (!provider.UpdateOrderAmount(order, dbTran))
                    {
                        dbTran.Rollback();
                        return(false);
                    }
                    dbTran.Commit();
                    flag = true;
                }
                catch
                {
                    dbTran.Rollback();
                    flag = false;
                }
                finally
                {
                    connection.Close();
                }
            }
            if (flag)
            {
                EventLogs.WriteOperationLog(Privilege.EditOrders, string.Format(CultureInfo.InvariantCulture, "成功的为订单号为\"{0}\"的订单添加了礼品", new object[] { order.OrderId }));
            }
            return(flag);
        }
Esempio n. 9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string orderIds = base.Request["orderIds"].Trim(',');

            if (!string.IsNullOrEmpty(base.Request["orderIds"]))
            {
                foreach (OrderInfo printDatum in this.GetPrintData(orderIds))
                {
                    HtmlGenericControl htmlGenericControl = new HtmlGenericControl("div");
                    htmlGenericControl.Attributes["class"] = "order1 print";
                    StringBuilder stringBuilder = new StringBuilder("");
                    stringBuilder.AppendFormat("<div class=\"info\"><div class=\"prime-info\" style=\"margin-right: 20px;\"><p><span><h3>{0}</h3></span></p></div><ul class=\"sub-info\"><li><span>手机号码: </span>{3}</li><li><span>生成时间: </span>{1}</li><li><span>订单编号: </span>{2}</li></ul><br class=\"clear\" /></div>", printDatum.ShipTo.ToNullString(), printDatum.OrderDate.ToString("yyyy-MM-dd HH:mm"), printDatum.OrderId, printDatum.CellPhone);
                    stringBuilder.Append("<table><col class=\"col-0\" /><col class=\"col-1\" /><col class=\"col-2\" /><col class=\"col-3\" /><col class=\"col-4\" /><col class=\"col-5\" /><thead><tr><th>货号</th><th>商品名称</th><th>规格</th><th>数量</th><th nowrap=\"nowrap\">单价</th><th>总价</th></tr></thead><tbody>");
                    Dictionary <string, LineItemInfo> lineItems = printDatum.LineItems;
                    if (lineItems != null)
                    {
                        foreach (string key in lineItems.Keys)
                        {
                            LineItemInfo lineItemInfo = lineItems[key];
                            if (lineItemInfo.Status != LineItemStatus.Refunded && lineItemInfo.Status != LineItemStatus.Returned)
                            {
                                stringBuilder.AppendFormat("<tr><td nowrap=\"nowrap\">{0}</td>", lineItemInfo.SKU);
                                stringBuilder.AppendFormat("<td>{0}</td>", lineItemInfo.ItemDescription);
                                stringBuilder.AppendFormat("<td>{0}</td>", lineItemInfo.SKUContent);
                                stringBuilder.AppendFormat("<td nowrap=\"nowrap\">{0}</td>", lineItemInfo.ShipmentQuantity);
                                stringBuilder.AppendFormat("<td nowrap=\"nowrap\">{0}</td>", Math.Round(lineItemInfo.ItemListPrice, 2));
                                stringBuilder.AppendFormat("<td nowrap=\"nowrap\">{0}</td></tr>", Math.Round(lineItemInfo.GetSubTotal(), 2));
                            }
                        }
                    }
                    stringBuilder.Append("</tbody></table>");
                    string value = "";
                    IList <OrderGiftInfo> gifts = printDatum.Gifts;
                    if (gifts != null && gifts.Count > 0)
                    {
                        OrderGiftInfo orderGiftInfo = gifts[0];
                        stringBuilder.Append("<p style=\"text-align:left;\"><b>&nbsp;</b></p>");
                        stringBuilder.Append("<table><col class=\"col-0\" /><col class=\"col-1\" /><col class=\"col-2\" /><col class=\"col-3\" /><thead><tr><th>礼品名称</th><th>成本价</th><th>数量</th><th>类型</th></tr></thead><tbody>");
                        foreach (OrderGiftInfo gift in printDatum.Gifts)
                        {
                            stringBuilder.AppendFormat("<tr><td nowrap=\"nowrap\">{0}</td>", gift.GiftName);
                            stringBuilder.AppendFormat("<td>{0}</td>", gift.CostPrice.F2ToString("f2"));
                            stringBuilder.AppendFormat("<td>{0}</td>", gift.Quantity);
                            stringBuilder.AppendFormat("<td nowrap=\"nowrap\">{0}</td>", (gift.PromoteType == 5) ? "商品促销" : ((gift.PromoteType == 15) ? "订单促销" : "积分兑换"));
                        }
                        stringBuilder.Append("</tbody></table>");
                    }
                    stringBuilder.AppendFormat("<ul class=\"price\"><li><span>收货地址: </span>{0}</li><li><span>送货上门时间: </span>{1}</li></ul>", printDatum.ShippingRegion + printDatum.Address, printDatum.ShipToDate);
                    stringBuilder.AppendFormat("<br class=\"clear\" /><ul class=\"price\"><li><span>商品总价: </span>{0}</li><li><span>运费: </span>{1}</li>", Math.Round(printDatum.GetAmount(false), 2), Math.Round(printDatum.AdjustedFreight, 2));
                    decimal reducedPromotionAmount = printDatum.ReducedPromotionAmount;
                    if (reducedPromotionAmount > decimal.Zero)
                    {
                        stringBuilder.AppendFormat("<li><span>优惠金额:</span>{0}</li>", Math.Round(reducedPromotionAmount, 2));
                    }
                    if (!string.IsNullOrEmpty(printDatum.CouponCode))
                    {
                        decimal couponValue = printDatum.CouponValue;
                        if (couponValue > decimal.Zero)
                        {
                            stringBuilder.AppendFormat("<li><span>优惠券:</span>{0}</li>", Math.Round(couponValue, 2));
                        }
                    }
                    decimal adjustedDiscount = printDatum.AdjustedDiscount;
                    if (adjustedDiscount > decimal.Zero)
                    {
                        stringBuilder.AppendFormat("<li><span>管理员手工加价:</span>{0}</li>", Math.Round(adjustedDiscount, 2));
                    }
                    else
                    {
                        stringBuilder.AppendFormat("<li><span>管理员手工减价:</span>{0}</li>", Math.Round(-adjustedDiscount, 2));
                    }
                    stringBuilder.Append(value);
                    stringBuilder.AppendFormat("<li><span>实付金额:</span>{0}</li>", Math.Round(printDatum.GetTotal(false), 2));
                    stringBuilder.AppendFormat("<li><span>支付方式:</span>{0}</li></ul>", printDatum.PaymentType);
                    stringBuilder.AppendFormat("<br class=\"clear\" /><ul class=\"price\"><li><span>备注: </span>{0}</li></ul><br class=\"clear\" /><br><br>", printDatum.Remark);
                    htmlGenericControl.InnerHtml = stringBuilder.ToString();
                    this.divContent.Controls.AddAt(0, htmlGenericControl);
                }
            }
        }
Esempio n. 10
0
 public abstract bool AddOrderGift(string orderId, OrderGiftInfo gift, int quantity, DbTransaction dbTran);
Esempio n. 11
0
        public static OrderInfo ConvertShoppingCartToOrder(ShoppingCartInfo shoppingCart, bool isGroupBuy, bool isCountDown, bool isSignBuy)
        {
            if ((shoppingCart.LineItems.Count == 0) && (shoppingCart.LineGifts.Count == 0))
            {
                return(null);
            }
            OrderInfo info = new OrderInfo();

            info.Points                      = shoppingCart.GetPoint();
            info.ReducedPromotionId          = shoppingCart.ReducedPromotionId;
            info.ReducedPromotionName        = shoppingCart.ReducedPromotionName;
            info.ReducedPromotionAmount      = shoppingCart.ReducedPromotionAmount;
            info.IsReduced                   = shoppingCart.IsReduced;
            info.SentTimesPointPromotionId   = shoppingCart.SentTimesPointPromotionId;
            info.SentTimesPointPromotionName = shoppingCart.SentTimesPointPromotionName;
            info.IsSendTimesPoint            = shoppingCart.IsSendTimesPoint;
            info.TimesPoint                  = shoppingCart.TimesPoint;
            info.FreightFreePromotionId      = shoppingCart.FreightFreePromotionId;
            info.FreightFreePromotionName    = shoppingCart.FreightFreePromotionName;
            info.IsFreightFree               = shoppingCart.IsFreightFree;
            string str = string.Empty;

            if (shoppingCart.LineItems.Values.Count > 0)
            {
                foreach (ShoppingCartItemInfo info2 in shoppingCart.LineItems.Values)
                {
                    str = str + string.Format("'{0}',", info2.SkuId);
                }
            }
            Dictionary <string, decimal> costPriceForItems = new Dictionary <string, decimal>();

            if (!string.IsNullOrEmpty(str))
            {
                str = str.Substring(0, str.Length - 1);
                costPriceForItems = ShoppingProvider.Instance().GetCostPriceForItems(str);
            }
            if (shoppingCart.LineItems.Values.Count > 0)
            {
                foreach (ShoppingCartItemInfo info2 in shoppingCart.LineItems.Values)
                {
                    decimal costPrice = 0M;
                    if ((isGroupBuy || isCountDown) || isSignBuy)
                    {
                        costPrice = ShoppingProvider.Instance().GetCostPrice(info2.SkuId);
                    }
                    else if (costPriceForItems.ContainsKey(info2.SkuId))
                    {
                        costPrice = costPriceForItems[info2.SkuId];
                    }
                    LineItemInfo info3 = new LineItemInfo();
                    info3.SkuId             = info2.SkuId;
                    info3.ProductId         = info2.ProductId;
                    info3.SKU               = info2.SKU;
                    info3.Quantity          = info2.Quantity;
                    info3.ShipmentQuantity  = info2.ShippQuantity;
                    info3.ItemCostPrice     = costPrice;
                    info3.ItemListPrice     = info2.MemberPrice;
                    info3.ItemAdjustedPrice = info2.AdjustedPrice;
                    info3.ItemDescription   = info2.Name;
                    info3.ThumbnailsUrl     = info2.ThumbnailUrl40;
                    info3.ItemWeight        = info2.Weight;
                    info3.SKUContent        = info2.SkuContent;
                    info3.PromotionId       = info2.PromotionId;
                    info3.PromotionName     = info2.PromotionName;
                    info.LineItems.Add(info3.SkuId, info3);
                }
            }
            info.Tax          = 0.00M;
            info.InvoiceTitle = "";
            if (shoppingCart.LineGifts.Count > 0)
            {
                foreach (ShoppingCartGiftInfo info4 in shoppingCart.LineGifts)
                {
                    OrderGiftInfo item = new OrderGiftInfo();
                    item.GiftId        = info4.GiftId;
                    item.GiftName      = info4.Name;
                    item.Quantity      = info4.Quantity;
                    item.ThumbnailsUrl = info4.ThumbnailUrl40;
                    item.PromoteType   = info4.PromoType;
                    if (HiContext.Current.SiteSettings.IsDistributorSettings)
                    {
                        item.CostPrice = info4.PurchasePrice;
                    }
                    else
                    {
                        item.CostPrice = info4.CostPrice;
                    }
                    info.Gifts.Add(item);
                }
            }
            return(info);
        }
Esempio n. 12
0
        public static bool AddOrderGift(OrderInfo order, GiftInfo giftinfo, int quantity, int promotype)
        {
            ManagerHelper.CheckPrivilege(Privilege.EditOrders);
            Database database = DatabaseFactory.CreateDatabase();
            bool     result;
            bool     flag2;

            using (System.Data.Common.DbConnection dbConnection = database.CreateConnection())
            {
                dbConnection.Open();
                System.Data.Common.DbTransaction dbTransaction = dbConnection.BeginTransaction();
                try
                {
                    SalesProvider salesProvider = SalesProvider.Instance();
                    OrderGiftInfo orderGiftInfo = new OrderGiftInfo();
                    orderGiftInfo.OrderId  = order.OrderId;
                    orderGiftInfo.Quantity = quantity;
                    orderGiftInfo.GiftName = giftinfo.Name;
                    decimal arg_5C_0 = orderGiftInfo.CostPrice;
                    orderGiftInfo.CostPrice     = Convert.ToDecimal(giftinfo.CostPrice);
                    orderGiftInfo.GiftId        = giftinfo.GiftId;
                    orderGiftInfo.ThumbnailsUrl = giftinfo.ThumbnailUrl40;
                    orderGiftInfo.PromoteType   = promotype;
                    bool flag = false;
                    foreach (OrderGiftInfo current in order.Gifts)
                    {
                        if (giftinfo.GiftId == current.GiftId)
                        {
                            flag                = true;
                            current.Quantity    = quantity;
                            current.PromoteType = promotype;
                            break;
                        }
                    }
                    if (!flag)
                    {
                        order.Gifts.Add(orderGiftInfo);
                    }
                    if (!salesProvider.AddOrderGift(order.OrderId, orderGiftInfo, quantity, dbTransaction))
                    {
                        dbTransaction.Rollback();
                        result = false;
                        return(result);
                    }
                    if (!salesProvider.UpdateOrderAmount(order, dbTransaction))
                    {
                        dbTransaction.Rollback();
                        result = false;
                        return(result);
                    }
                    dbTransaction.Commit();
                    flag2 = true;
                }
                catch
                {
                    dbTransaction.Rollback();
                    flag2 = false;
                }
                finally
                {
                    dbConnection.Close();
                }
            }
            if (flag2)
            {
                EventLogs.WriteOperationLog(Privilege.EditOrders, string.Format(CultureInfo.InvariantCulture, "成功的为订单号为\"{0}\"的订单添加了礼品", new object[]
                {
                    order.OrderId
                }));
            }
            result = flag2;
            return(result);
        }
Esempio n. 13
0
 public abstract bool AddOrderGift(string orderId, OrderGiftInfo gift, int quantity, System.Data.Common.DbTransaction dbTran);
Esempio n. 14
0
        public static OrderInfo ConvertShoppingCartToOrder(ShoppingCartInfo shoppingCart, bool isGroupBuy, bool isCountDown, bool isSignBuy)
        {
            if ((shoppingCart.LineItems.Count == 0) && (shoppingCart.LineGifts.Count == 0))
            {
                return(null);
            }
            OrderInfo info = new OrderInfo();

            info.ActivityId        = shoppingCart.FeeFreeActivityId;
            info.ActivityName      = shoppingCart.FeeFreeName;
            info.OrderOptionFree   = shoppingCart.OrderOptionFree;
            info.ProcedureFeeFree  = shoppingCart.ProcedureFeeFree;
            info.EightFree         = shoppingCart.EightFree;
            info.DiscountId        = shoppingCart.DiscountActivityId;
            info.DiscountName      = shoppingCart.DiscountName;
            info.DiscountValue     = shoppingCart.DiscountValue;
            info.DiscountValueType = shoppingCart.DiscountValueType;
            //OrderInfo info = info6;

            string skuIds = string.Empty;

            if (shoppingCart.LineItems.Values.Count > 0)
            {
                foreach (ShoppingCartItemInfo item in shoppingCart.LineItems.Values)
                {
                    skuIds = skuIds + string.Format("'{0}',", item.SkuId);
                }
            }

            Dictionary <string, decimal> costPriceForItems = new Dictionary <string, decimal>();

            if (!string.IsNullOrEmpty(skuIds))
            {
                skuIds            = skuIds.Substring(0, skuIds.Length - 1);
                costPriceForItems = ShoppingProvider.Instance().GetCostPriceForItems(skuIds);
            }

            if (shoppingCart.LineItems.Values.Count > 0)
            {
                foreach (ShoppingCartItemInfo info2 in shoppingCart.LineItems.Values)
                {
                    decimal memberPrice = info2.MemberPrice;
                    decimal costPrice   = 0M;
                    if (((info2.WholesaleDiscountId > 0) && !string.IsNullOrEmpty(info2.WholesaleDiscountName)) && info2.DiscountRate.HasValue)
                    {
                        memberPrice = info2.MemberPrice * (info2.DiscountRate.Value / 100M);
                    }
                    if ((isGroupBuy || isCountDown) || isSignBuy)
                    {
                        costPrice = ShoppingProvider.Instance().GetCostPrice(info2.SkuId);
                    }
                    else if (costPriceForItems.ContainsKey(info2.SkuId))
                    {
                        costPrice = costPriceForItems[info2.SkuId];
                    }
                    LineItemInfo info3 = new LineItemInfo(info2.SkuId, info2.ProductId, info2.SKU, info2.Quantity, info2.Quantity + info2.GiveQuantity, costPrice, info2.MemberPrice, memberPrice, info2.Name, info2.ThumbnailUrl40, info2.Weight, info2.PurchaseGiftId, info2.PurchaseGiftName, info2.WholesaleDiscountId, info2.WholesaleDiscountName, info2.SkuContent);
                    info.LineItems.Add(info3.SkuId, info3);
                }
            }
            if (shoppingCart.LineGifts.Count > 0)
            {
                foreach (ShoppingCartGiftInfo info4 in shoppingCart.LineGifts)
                {
                    OrderGiftInfo item = new OrderGiftInfo();
                    item.GiftId        = info4.GiftId;
                    item.GiftName      = info4.Name;
                    item.Quantity      = info4.Quantity;
                    item.ThumbnailsUrl = info4.ThumbnailUrl40;
                    if (HiContext.Current.SiteSettings.IsDistributorSettings)
                    {
                        item.CostPrice = info4.PurchasePrice;
                    }
                    else
                    {
                        item.CostPrice = info4.CostPrice;
                    }
                    info.Gifts.Add(item);
                }
            }
            return(info);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string orderIds = base.Request["orderIds"].Trim(',');

            if (!string.IsNullOrEmpty(base.Request["orderIds"]))
            {
                foreach (OrderInfo printDatum in this.GetPrintData(orderIds))
                {
                    HtmlGenericControl htmlGenericControl = new HtmlGenericControl("div");
                    htmlGenericControl.Attributes["class"] = "order1 print";
                    StringBuilder stringBuilder = new StringBuilder("");
                    stringBuilder.AppendFormat("<div class=\"info\"><div class=\"prime-info\" style=\"margin-right: 20px;\"><p><span><h3>{0}</h3></span></p></div><ul class=\"sub-info\"><li><span>手机号码: </span>{3}</li><li><span>生成时间: </span>{1}</li><li><span>订单编号: </span>{2}</li></ul><br class=\"clear\" /></div>", printDatum.ShipTo.ToNullString(), printDatum.OrderDate.ToString("yyyy-MM-dd HH:mm"), printDatum.OrderId, printDatum.CellPhone);
                    stringBuilder.Append("<table><col class=\"col-0\" /><col class=\"col-1\" /><col class=\"col-2\" /><col class=\"col-3\" /><col class=\"col-4\" /><col class=\"col-5\" /><thead><tr><th>货号</th><th>商品名称</th><th>规格</th><th>数量</th><th nowrap=\"nowrap\">单价</th><th>总价</th></tr></thead><tbody>");
                    Dictionary <string, LineItemInfo> lineItems = printDatum.LineItems;
                    if (lineItems != null)
                    {
                        foreach (string key in lineItems.Keys)
                        {
                            LineItemInfo lineItemInfo = lineItems[key];
                            if (lineItemInfo.Status != LineItemStatus.Refunded && lineItemInfo.Status != LineItemStatus.Returned)
                            {
                                stringBuilder.AppendFormat("<tr><td nowrap=\"nowrap\">{0}</td>", lineItemInfo.SKU);
                                stringBuilder.AppendFormat("<td>{0}</td>", lineItemInfo.ItemDescription);
                                stringBuilder.AppendFormat("<td>{0}</td>", lineItemInfo.SKUContent);
                                stringBuilder.AppendFormat("<td nowrap=\"nowrap\">{0}</td>", lineItemInfo.ShipmentQuantity);
                                stringBuilder.AppendFormat("<td nowrap=\"nowrap\">{0}</td>", Math.Round(lineItemInfo.ItemListPrice, 2));
                                stringBuilder.AppendFormat("<td nowrap=\"nowrap\">{0}</td></tr>", Math.Round(lineItemInfo.GetSubTotal(), 2));
                            }
                        }
                    }
                    stringBuilder.Append("</tbody></table>");
                    string value = "";
                    IList <OrderGiftInfo> gifts = printDatum.Gifts;
                    if (gifts != null && gifts.Count > 0)
                    {
                        OrderGiftInfo orderGiftInfo = gifts[0];
                        stringBuilder.Append("<p style=\"text-align:left;\"><b>&nbsp;</b></p>");
                        stringBuilder.Append("<table><col class=\"col-0\" /><col class=\"col-1\" /><col class=\"col-2\" /><col class=\"col-3\" /><thead><tr><th>礼品名称</th><th>市场参考价</th><th>数量</th><th>类型</th></tr></thead><tbody>");
                        foreach (OrderGiftInfo gift in printDatum.Gifts)
                        {
                            stringBuilder.AppendFormat("<tr><td nowrap=\"nowrap\">{0}</td>", gift.GiftName);
                            stringBuilder.AppendFormat("<td>{0}</td>", gift.CostPrice.F2ToString("f2"));
                            stringBuilder.AppendFormat("<td>{0}</td>", gift.Quantity);
                            stringBuilder.AppendFormat("<td nowrap=\"nowrap\">{0}</td>", (gift.PromoteType == 5) ? "商品促销" : ((gift.PromoteType == 15) ? "订单促销" : "积分兑换"));
                        }
                        stringBuilder.Append("</tbody></table>");
                    }
                    stringBuilder.AppendFormat("<ul class=\"price\">");
                    if (!string.IsNullOrEmpty(printDatum.InvoiceTitle))
                    {
                        stringBuilder.AppendFormat("<li><span>发票抬头:</span>{0}</li>", printDatum.InvoiceTitle);
                        if (printDatum.InvoiceType == InvoiceType.Enterprise)
                        {
                            stringBuilder.AppendFormat("<li><span>企业纳税人识别号:</span>{0}</li>", printDatum.InvoiceTaxpayerNumber);
                        }
                    }
                    stringBuilder.AppendFormat("<li><span>收货地址: </span>{0}</li><li><span>送货上门时间: </span>{1}</li></ul>", printDatum.ShippingRegion + printDatum.Address, printDatum.ShipToDate);
                    stringBuilder.AppendFormat("<br class=\"clear\" /><ul class=\"price\"><li><span>商品总价: </span>{0}</li><li><span>运费: </span>{1}</li>", Math.Round(printDatum.GetAmount(false), 2), Math.Round(printDatum.AdjustedFreight, 2));
                    decimal reducedPromotionAmount = printDatum.ReducedPromotionAmount;
                    if (reducedPromotionAmount > decimal.Zero)
                    {
                        stringBuilder.AppendFormat("<li><span>优惠金额:</span>{0}</li>", Math.Round(reducedPromotionAmount, 2));
                    }
                    if (!string.IsNullOrEmpty(printDatum.CouponCode))
                    {
                        decimal couponValue = printDatum.CouponValue;
                        if (couponValue > decimal.Zero)
                        {
                            stringBuilder.AppendFormat("<li><span>优惠券:</span>{0}</li>", Math.Round(couponValue, 2));
                        }
                    }
                    decimal adjustedDiscount = printDatum.AdjustedDiscount;
                    if (adjustedDiscount > decimal.Zero)
                    {
                        stringBuilder.AppendFormat("<li><span>管理员手工加价:</span>{0}</li>", Math.Round(adjustedDiscount, 2));
                    }
                    else
                    {
                        stringBuilder.AppendFormat("<li><span>管理员手工减价:</span>{0}</li>", Math.Round(-adjustedDiscount, 2));
                    }
                    stringBuilder.Append(value);
                    stringBuilder.AppendFormat("<li><span>实付金额:</span>{0}</li>", Math.Round(printDatum.GetTotal(false), 2));
                    stringBuilder.AppendFormat("<li><span>支付方式:</span>{0}</li></ul>", printDatum.PaymentType);
                    if (HiContext.Current.SiteSettings.IsOpenCertification && printDatum.IsincludeCrossBorderGoods && printDatum.OrderStatus != OrderStatus.WaitBuyerPay)
                    {
                        StringBuilder stringBuilder2 = new StringBuilder();
                        if (!string.IsNullOrWhiteSpace(printDatum.IDNumber) || !string.IsNullOrWhiteSpace(printDatum.IDImage1) || !string.IsNullOrWhiteSpace(printDatum.IDImage2))
                        {
                            stringBuilder2.AppendFormat("<li><span class=\"txtright\"> 收货人:</span>{0}</li>", printDatum.ShipTo);
                        }
                        if (!string.IsNullOrWhiteSpace(printDatum.IDNumber))
                        {
                            stringBuilder2.AppendFormat("<li><span>身份证号:</span>{0}</li>", HiCryptographer.Decrypt(printDatum.IDNumber));
                        }
                        if (HiContext.Current.SiteSettings.CertificationModel == 2 && ((!string.IsNullOrWhiteSpace(printDatum.IDImage1) && this.IsImageUrlExists(printDatum.IDImage1)) || (!string.IsNullOrWhiteSpace(printDatum.IDImage2) && this.IsImageUrlExists(printDatum.IDImage2))))
                        {
                            stringBuilder2.AppendFormat("<li><span>身份证照:</span><div>");
                            if (!string.IsNullOrWhiteSpace(printDatum.IDImage1))
                            {
                                stringBuilder2.AppendFormat("<img src='{0}' runat ='server' alt='证件照正面' clientidmode='Static'/>", printDatum.IDImage1);
                            }
                            if (!string.IsNullOrWhiteSpace(printDatum.IDImage2))
                            {
                                stringBuilder2.AppendFormat("<img src='{0}' runat ='server' alt='证件照反面' clientidmode ='Static'/>", printDatum.IDImage2);
                            }
                            stringBuilder2.AppendFormat("{0}", stringBuilder2.ToString().Contains("img") ? "</div></li>" : "");
                        }
                        if (stringBuilder2.ToString() != string.Empty)
                        {
                            stringBuilder2.AppendFormat("</ul>");
                            stringBuilder2.Insert(0, "<br class=\"clear\" /><ul class=\"idInfo\">");
                            stringBuilder.Append(stringBuilder2.ToString());
                        }
                    }
                    stringBuilder.AppendFormat("<br class=\"clear\" /><ul class=\"price\"><li><span>备注: </span>{0}</li></ul><br class=\"clear\" /><br><br>", printDatum.Remark);
                    htmlGenericControl.InnerHtml = stringBuilder.ToString();
                    this.divContent.Controls.AddAt(0, htmlGenericControl);
                }
            }
        }
Esempio n. 16
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            string orderIds = base.Request["orderIds"].Trim(new char[]
            {
                ','
            });

            if (string.IsNullOrEmpty(base.Request["orderIds"]))
            {
                return;
            }
            foreach (OrderInfo current in this.GetPrintData(orderIds))
            {
                System.Web.UI.HtmlControls.HtmlGenericControl htmlGenericControl = new System.Web.UI.HtmlControls.HtmlGenericControl("div");
                htmlGenericControl.Attributes["class"] = "order print";
                System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder("");
                stringBuilder.AppendFormat("<div class=\"info\"><div class=\"prime-info\" style=\"margin-right: 20px;\"><p><span><h3 style=\"font-weight: normal\">{0}</h3></span></p></div><ul class=\"sub-info\"><li><span>生成时间: </span>{1}</li><li><span>发货单号: </span>{2}</li></ul><br class=\"clear\" /></div>", current.ShipTo, current.OrderDate.ToString("yyyy-MM-dd HH:mm"), current.OrderId);
                stringBuilder.Append("<table><col class=\"col-0\" /><col class=\"col-1\" /><col class=\"col-2\" /><col class=\"col-3\" /><col class=\"col-4\" /><col class=\"col-5\" /><thead><tr><th>货号</th><th>商品名称</th><th>规格</th><th>数量</th><th style=\"display:none\">单价</th><th style=\"display:none\">总价</th></tr></thead><tbody>");
                System.Collections.Generic.Dictionary <string, LineItemInfo> lineItems = current.LineItems;
                if (lineItems != null)
                {
                    foreach (string current2 in lineItems.Keys)
                    {
                        LineItemInfo lineItemInfo = lineItems[current2];
                        stringBuilder.AppendFormat("<tr><td>{0}</td>", lineItemInfo.SKU);
                        stringBuilder.AppendFormat("<td>{0}</td>", lineItemInfo.ItemDescription);
                        stringBuilder.AppendFormat("<td>{0}</td>", lineItemInfo.SKUContent);
                        stringBuilder.AppendFormat("<td>{0}</td>", lineItemInfo.ShipmentQuantity);
                        stringBuilder.AppendFormat("<td style=\"display:none\">{0}</td>", System.Math.Round(lineItemInfo.ItemListPrice, 2));
                        stringBuilder.AppendFormat("<td style=\"display:none\">{0}</td></tr>", System.Math.Round(lineItemInfo.GetSubTotal(), 2));
                    }
                }
                string value = "";
                System.Collections.Generic.IList <OrderGiftInfo> gifts = current.Gifts;
                if (gifts != null && gifts.Count > 0)
                {
                    OrderGiftInfo orderGiftInfo = gifts[0];
                    value = string.Format("<li><span>赠送礼品:</span>{0},数量:{1}</li>", orderGiftInfo.GiftName, orderGiftInfo.Quantity);
                }
                stringBuilder.AppendFormat("</tbody></table><ul class=\"price\" style=\"display:none\"><li><span>商品总价: </span>{0}</li><li><span>运费: </span>{1}</li>", System.Math.Round(current.GetAmount(), 2), System.Math.Round(current.AdjustedFreight, 2));
                decimal reducedPromotionAmount = current.ReducedPromotionAmount;
                if (reducedPromotionAmount > 0m)
                {
                    stringBuilder.AppendFormat("<li style=\"display:none\"><span>优惠金额:</span>{0}</li>", System.Math.Round(reducedPromotionAmount, 2));
                }
                decimal payCharge = current.PayCharge;
                if (payCharge > 0m)
                {
                    stringBuilder.AppendFormat("<li style=\"display:none\"><span>支付手续费:</span>{0}</li>", System.Math.Round(payCharge, 2));
                }
                if (!string.IsNullOrEmpty(current.CouponCode))
                {
                    decimal couponValue = current.CouponValue;
                    if (couponValue > 0m)
                    {
                        stringBuilder.AppendFormat("<li style=\"display:none\"><span>优惠券:</span>{0}</li>", System.Math.Round(couponValue, 2));
                    }
                }
                decimal adjustedDiscount = current.AdjustedDiscount;
                if (adjustedDiscount > 0m)
                {
                    stringBuilder.AppendFormat("<li style=\"display:none\"><span>管理员手工打折:</span>{0}</li>", System.Math.Round(adjustedDiscount, 2));
                }
                stringBuilder.Append(value);
                stringBuilder.AppendFormat("<li style=\"display:none\"><span>实付金额:</span>{0}</li></ul><br class=\"clear\" /><br><br>", System.Math.Round(current.GetTotal(), 2));
                htmlGenericControl.InnerHtml = stringBuilder.ToString();
                this.divContent.Controls.AddAt(0, htmlGenericControl);
            }
        }
Esempio n. 17
0
        public static void BindDetailOrderItemsAndGifts(OrderInfo orderInfo, ShoppingCartInfo shoppingCart, int supplierId)
        {
            if (shoppingCart.LineItems.Count > 0)
            {
                foreach (ShoppingCartItemInfo item in from c in shoppingCart.LineItems
                         where c.SupplierId == supplierId
                         select c)
                {
                    LineItemInfo lineItemInfo = new LineItemInfo();
                    lineItemInfo.SkuId             = item.SkuId;
                    lineItemInfo.ProductId         = item.ProductId;
                    lineItemInfo.SKU               = item.SKU;
                    lineItemInfo.Quantity          = item.Quantity;
                    lineItemInfo.ShipmentQuantity  = item.ShippQuantity;
                    lineItemInfo.ItemCostPrice     = item.CostPrice;
                    lineItemInfo.ItemListPrice     = item.MemberPrice;
                    lineItemInfo.ItemAdjustedPrice = item.AdjustedPrice;
                    lineItemInfo.ItemDescription   = item.Name;
                    lineItemInfo.ThumbnailsUrl     = item.ThumbnailUrl180;
                    lineItemInfo.ItemWeight        = item.Weight;
                    lineItemInfo.SKUContent        = item.SkuContent;
                    lineItemInfo.PromotionId       = item.PromotionId;
                    lineItemInfo.PromotionName     = item.PromotionName;
                    orderInfo.LineItems.Add(lineItemInfo.SkuId, lineItemInfo);
                    if (HiContext.Current.UserId > 0)
                    {
                        PromotionInfo productPromotionInfo = ProductBrowser.GetProductPromotionInfo(item.ProductId);
                        if (productPromotionInfo != null && productPromotionInfo.PromoteType == PromoteType.SentGift && !string.IsNullOrEmpty(productPromotionInfo.GiftIds))
                        {
                            IList <GiftInfo> giftDetailsByGiftIds = ProductBrowser.GetGiftDetailsByGiftIds(productPromotionInfo.GiftIds);
                            foreach (GiftInfo item2 in giftDetailsByGiftIds)
                            {
                                OrderGiftInfo orderGiftInfo = new OrderGiftInfo();
                                orderGiftInfo.GiftId        = item2.GiftId;
                                orderGiftInfo.GiftName      = item2.Name;
                                orderGiftInfo.Quantity      = item.ShippQuantity;
                                orderGiftInfo.ThumbnailsUrl = item2.ThumbnailUrl180;
                                orderGiftInfo.PromoteType   = 5;
                                orderGiftInfo.CostPrice     = (item2.CostPrice.HasValue ? item2.CostPrice.Value : decimal.Zero);
                                orderGiftInfo.SkuId         = item.SkuId;
                                orderInfo.Gifts.Add(orderGiftInfo);
                            }
                            goto IL_027c;
                        }
                        continue;
                    }
                    goto IL_027c;
IL_027c:
                    if (item.IsCrossborder)
                    {
                        orderInfo.IsincludeCrossBorderGoods = true;
                    }
                }
            }
            if (supplierId == 0 && shoppingCart.LineGifts.Count > 0)
            {
                foreach (ShoppingCartGiftInfo lineGift in shoppingCart.LineGifts)
                {
                    OrderGiftInfo orderGiftInfo2 = new OrderGiftInfo();
                    orderGiftInfo2.GiftId        = lineGift.GiftId;
                    orderGiftInfo2.GiftName      = lineGift.Name;
                    orderGiftInfo2.Quantity      = lineGift.Quantity;
                    orderGiftInfo2.ThumbnailsUrl = lineGift.ThumbnailUrl180;
                    orderGiftInfo2.CostPrice     = lineGift.CostPrice;
                    orderGiftInfo2.PromoteType   = lineGift.PromoType;
                    orderGiftInfo2.NeedPoint     = lineGift.NeedPoint;
                    orderInfo.Gifts.Add(orderGiftInfo2);
                }
            }
        }
Esempio n. 18
0
        public static OrderInfo ConvertShoppingCartToOrder(ShoppingCartInfo shoppingCart, bool isGroupBuy, bool isCountDown, int storeId = 0)
        {
            if (shoppingCart.LineItems.Count == 0 && shoppingCart.LineGifts.Count == 0)
            {
                return(null);
            }
            OrderInfo orderInfo = new OrderInfo();

            if (HiContext.Current.ReferralUserId != HiContext.Current.UserId)
            {
                orderInfo.ReferralUserId = HiContext.Current.ReferralUserId;
            }
            if (HiContext.Current.UserId != 0)
            {
                orderInfo.Points = shoppingCart.GetPoint(HiContext.Current.SiteSettings.PointsRate);
            }
            else
            {
                orderInfo.Points = 0;
            }
            if (HiContext.Current.UserId > 0)
            {
                orderInfo.ReducedPromotionId     = shoppingCart.ReducedPromotionId;
                orderInfo.ReducedPromotionName   = shoppingCart.ReducedPromotionName;
                orderInfo.ReducedPromotionAmount = decimal.Parse(shoppingCart.ReducedPromotionAmount.F2ToString("f2"));
                orderInfo.IsReduced = shoppingCart.IsReduced;
                orderInfo.SentTimesPointPromotionId   = shoppingCart.SentTimesPointPromotionId;
                orderInfo.SentTimesPointPromotionName = shoppingCart.SentTimesPointPromotionName;
                orderInfo.IsSendTimesPoint            = shoppingCart.IsSendTimesPoint;
                orderInfo.TimesPoint = shoppingCart.TimesPoint;
            }
            orderInfo.FreightFreePromotionId   = shoppingCart.FreightFreePromotionId;
            orderInfo.FreightFreePromotionName = shoppingCart.FreightFreePromotionName;
            orderInfo.IsFreightFree            = shoppingCart.IsFreightFree;
            if (shoppingCart.LineItems.Count > 0)
            {
                foreach (ShoppingCartItemInfo lineItem in shoppingCart.LineItems)
                {
                    LineItemInfo lineItemInfo = new LineItemInfo();
                    lineItemInfo.SkuId             = lineItem.SkuId;
                    lineItemInfo.ProductId         = lineItem.ProductId;
                    lineItemInfo.SKU               = lineItem.SKU;
                    lineItemInfo.Quantity          = lineItem.Quantity;
                    lineItemInfo.ShipmentQuantity  = lineItem.ShippQuantity;
                    lineItemInfo.ItemCostPrice     = lineItem.CostPrice;
                    lineItemInfo.ItemListPrice     = lineItem.MemberPrice;
                    lineItemInfo.ItemAdjustedPrice = lineItem.AdjustedPrice;
                    lineItemInfo.ItemDescription   = lineItem.Name;
                    lineItemInfo.ThumbnailsUrl     = lineItem.ThumbnailUrl180;
                    lineItemInfo.ItemWeight        = lineItem.Weight;
                    lineItemInfo.SKUContent        = lineItem.SkuContent;
                    lineItemInfo.PromotionId       = lineItem.PromotionId;
                    lineItemInfo.PromotionName     = lineItem.PromotionName;
                    orderInfo.LineItems.Add(lineItemInfo.SkuId, lineItemInfo);
                }
            }
            orderInfo.IsincludeCrossBorderGoods = ((from i in shoppingCart.LineItems
                                                    where i.IsCrossborder
                                                    select i).Count() > 0);
            orderInfo.Tax          = 0.00m;
            orderInfo.InvoiceTitle = "";
            if (shoppingCart.LineGifts.Count > 0)
            {
                foreach (ShoppingCartGiftInfo lineGift in shoppingCart.LineGifts)
                {
                    if (lineGift.PromoType == 15 || (lineGift.PromoType == 0 && storeId <= 0))
                    {
                        OrderGiftInfo orderGiftInfo = new OrderGiftInfo();
                        orderGiftInfo.GiftId        = lineGift.GiftId;
                        orderGiftInfo.GiftName      = lineGift.Name;
                        orderGiftInfo.Quantity      = lineGift.Quantity;
                        orderGiftInfo.ThumbnailsUrl = lineGift.ThumbnailUrl180;
                        orderGiftInfo.CostPrice     = lineGift.CostPrice;
                        orderGiftInfo.PromoteType   = lineGift.PromoType;
                        orderGiftInfo.NeedPoint     = lineGift.NeedPoint;
                        orderInfo.Gifts.Add(orderGiftInfo);
                    }
                }
            }
            if (HiContext.Current.UserId > 0 && !isGroupBuy && !isCountDown && storeId <= 0)
            {
                foreach (ShoppingCartItemInfo lineItem2 in shoppingCart.LineItems)
                {
                    PromotionInfo productPromotionInfo = ProductBrowser.GetProductPromotionInfo(lineItem2.ProductId);
                    if (productPromotionInfo != null && productPromotionInfo.PromoteType == PromoteType.SentGift && !string.IsNullOrEmpty(productPromotionInfo.GiftIds))
                    {
                        IList <GiftInfo> giftDetailsByGiftIds = ProductBrowser.GetGiftDetailsByGiftIds(productPromotionInfo.GiftIds);
                        foreach (GiftInfo item in giftDetailsByGiftIds)
                        {
                            OrderGiftInfo orderGiftInfo2 = new OrderGiftInfo();
                            orderGiftInfo2.GiftId        = item.GiftId;
                            orderGiftInfo2.GiftName      = item.Name;
                            orderGiftInfo2.Quantity      = lineItem2.ShippQuantity;
                            orderGiftInfo2.ThumbnailsUrl = item.ThumbnailUrl180;
                            orderGiftInfo2.PromoteType   = 5;
                            orderGiftInfo2.CostPrice     = (item.CostPrice.HasValue ? item.CostPrice.Value : decimal.Zero);
                            orderGiftInfo2.SkuId         = lineItem2.SkuId;
                            orderInfo.Gifts.Add(orderGiftInfo2);
                        }
                    }
                }
            }
            return(orderInfo);
        }
Esempio n. 19
0
        public static OrderInfo ConvertShoppingCartToOrder(ShoppingCartInfo shoppingCart, bool isGroupBuy, bool isCountDown, bool isSignBuy)
        {
            OrderInfo result;

            if (shoppingCart.LineItems.Count == 0 && shoppingCart.LineGifts.Count == 0)
            {
                result = null;
            }
            else
            {
                OrderInfo orderInfo = new OrderInfo();
                orderInfo.Points                      = shoppingCart.GetPoint();
                orderInfo.ReducedPromotionId          = shoppingCart.ReducedPromotionId;
                orderInfo.ReducedPromotionName        = shoppingCart.ReducedPromotionName;
                orderInfo.ReducedPromotionAmount      = shoppingCart.ReducedPromotionAmount;
                orderInfo.IsReduced                   = shoppingCart.IsReduced;
                orderInfo.SentTimesPointPromotionId   = shoppingCart.SentTimesPointPromotionId;
                orderInfo.SentTimesPointPromotionName = shoppingCart.SentTimesPointPromotionName;
                orderInfo.IsSendTimesPoint            = shoppingCart.IsSendTimesPoint;
                orderInfo.TimesPoint                  = shoppingCart.TimesPoint;
                orderInfo.FreightFreePromotionId      = shoppingCart.FreightFreePromotionId;
                orderInfo.FreightFreePromotionName    = shoppingCart.FreightFreePromotionName;
                orderInfo.IsFreightFree               = shoppingCart.IsFreightFree;
                string text = string.Empty;
                if (shoppingCart.LineItems.Values.Count > 0)
                {
                    foreach (ShoppingCartItemInfo current in shoppingCart.LineItems.Values)
                    {
                        text += string.Format("'{0}',", current.SkuId);
                    }
                }
                Dictionary <string, decimal> dictionary = new Dictionary <string, decimal>();
                if (!string.IsNullOrEmpty(text))
                {
                    text       = text.Substring(0, text.Length - 1);
                    dictionary = ShoppingProvider.Instance().GetCostPriceForItems(text);
                }
                if (shoppingCart.LineItems.Values.Count > 0)
                {
                    foreach (ShoppingCartItemInfo current in shoppingCart.LineItems.Values)
                    {
                        decimal itemCostPrice = 0m;
                        if (isGroupBuy || isCountDown || isSignBuy)
                        {
                            itemCostPrice = ShoppingProvider.Instance().GetCostPrice(current.SkuId);
                        }
                        else
                        {
                            if (dictionary.ContainsKey(current.SkuId))
                            {
                                itemCostPrice = dictionary[current.SkuId];
                            }
                        }
                        LineItemInfo lineItemInfo = new LineItemInfo();
                        lineItemInfo.SkuId             = current.SkuId;
                        lineItemInfo.ProductId         = current.ProductId;
                        lineItemInfo.SKU               = current.SKU;
                        lineItemInfo.Quantity          = current.Quantity;
                        lineItemInfo.ShipmentQuantity  = current.ShippQuantity;
                        lineItemInfo.ItemCostPrice     = itemCostPrice;
                        lineItemInfo.ItemListPrice     = current.MemberPrice;
                        lineItemInfo.ItemAdjustedPrice = current.AdjustedPrice;
                        lineItemInfo.ItemDescription   = current.Name;
                        lineItemInfo.ThumbnailsUrl     = current.ThumbnailUrl40;
                        lineItemInfo.ItemWeight        = current.Weight;
                        lineItemInfo.SKUContent        = current.SkuContent;
                        lineItemInfo.PromotionId       = current.PromotionId;
                        lineItemInfo.PromotionName     = current.PromotionName;
                        orderInfo.LineItems.Add(lineItemInfo.SkuId, lineItemInfo);
                    }
                }
                orderInfo.Tax          = 0.00m;
                orderInfo.InvoiceTitle = "";
                if (shoppingCart.LineGifts.Count > 0)
                {
                    foreach (ShoppingCartGiftInfo current2 in shoppingCart.LineGifts)
                    {
                        OrderGiftInfo orderGiftInfo = new OrderGiftInfo();
                        orderGiftInfo.GiftId        = current2.GiftId;
                        orderGiftInfo.GiftName      = current2.Name;
                        orderGiftInfo.Quantity      = current2.Quantity;
                        orderGiftInfo.ThumbnailsUrl = current2.ThumbnailUrl40;
                        orderGiftInfo.PromoteType   = current2.PromoType;
                        if (HiContext.Current.SiteSettings.IsDistributorSettings)
                        {
                            orderGiftInfo.CostPrice = current2.PurchasePrice;
                        }
                        else
                        {
                            orderGiftInfo.CostPrice = current2.CostPrice;
                        }
                        orderInfo.Gifts.Add(orderGiftInfo);
                    }
                }
                result = orderInfo;
            }
            return(result);
        }
Esempio n. 20
0
        public static OrderInfo ConvertShoppingCartToOrder(ShoppingCartInfo shoppingCart, bool isCountDown, bool isSignBuy, bool isAgent)
        {
            if (shoppingCart.LineItems.Count == 0 && shoppingCart.LineGifts.Count == 0)
            {
                return(null);
            }
            OrderInfo info = new OrderInfo
            {
                Points                      = shoppingCart.GetPoint(),
                ReducedPromotionId          = shoppingCart.ReducedPromotionId,
                ReducedPromotionName        = shoppingCart.ReducedPromotionName,
                ReducedPromotionAmount      = shoppingCart.ReducedPromotionAmount,
                IsReduced                   = shoppingCart.IsReduced,
                SentTimesPointPromotionId   = shoppingCart.SentTimesPointPromotionId,
                SentTimesPointPromotionName = shoppingCart.SentTimesPointPromotionName,
                IsSendTimesPoint            = shoppingCart.IsSendTimesPoint,
                TimesPoint                  = shoppingCart.TimesPoint,
                FreightFreePromotionId      = shoppingCart.FreightFreePromotionId,
                FreightFreePromotionName    = shoppingCart.FreightFreePromotionName,
                IsFreightFree               = shoppingCart.IsFreightFree
            };
            string str = string.Empty;

            if (shoppingCart.LineItems.Count > 0)
            {
                foreach (ShoppingCartItemInfo info2 in shoppingCart.LineItems)
                {
                    str = str + string.Format("'{0}',", info2.SkuId);
                }
            }
            if (shoppingCart.LineItems.Count > 0)
            {
                foreach (ShoppingCartItemInfo info2 in shoppingCart.LineItems)
                {
                    decimal      costprice = new SkuDao().GetSkuItem(info2.SkuId).CostPrice;
                    LineItemInfo info3     = new LineItemInfo
                    {
                        SkuId             = info2.SkuId,
                        ProductId         = info2.ProductId,
                        SKU               = info2.SKU,
                        Quantity          = info2.Quantity,
                        ShipmentQuantity  = info2.ShippQuantity,
                        ItemCostPrice     = costprice,
                        ItemListPrice     = isAgent ? costprice : info2.MemberPrice,
                        ItemAdjustedPrice = isAgent ? costprice : info2.AdjustedPrice,
                        ItemDescription   = info2.Name,
                        ThumbnailsUrl     = info2.ThumbnailUrl40,
                        ItemWeight        = info2.Weight,
                        SKUContent        = info2.SkuContent,
                        PromotionId       = info2.PromotionId,
                        PromotionName     = info2.PromotionName,
                        MainCategoryPath  = info2.MainCategoryPath,
                        GiveQuantity      = info2.GiveQuantity,
                        HalfPriceQuantity = info2.HalfPriceQuantity
                    };
                    info.LineItems.Add(info3.SkuId, info3);
                }
            }
            //如果有礼品在购物车内,增加礼品到订单
            if (shoppingCart.LineGifts.Count > 0)
            {
                foreach (ShoppingCartGiftInfo info4 in shoppingCart.LineGifts)
                {
                    OrderGiftInfo item = new OrderGiftInfo
                    {
                        GiftId        = info4.GiftId,
                        GiftName      = info4.Name,
                        Quantity      = info4.Quantity,
                        ThumbnailsUrl = info4.ThumbnailUrl100,
                        CostPrice     = info4.CostPrice,
                        costPoint     = info4.NeedPoint * info4.Quantity
                    };
                    info.Gifts.Add(item);
                }
            }
            //如果当前订单内商品数量为零的话,则订单状态为已付款
            if ((info.GetTotal() == 0M) && (info.LineItems.Count == 0))
            {
                info.OrderStatus = OrderStatus.BuyerAlreadyPaid;
            }
            info.Tax          = 0.00M;
            info.InvoiceTitle = "";
            return(info);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string orderIds = base.Request["orderIds"].Trim(new char[] { ',' });

            if (!string.IsNullOrEmpty(base.Request["orderIds"]))
            {
                foreach (OrderInfo info in this.GetPrintData(orderIds))
                {
                    HtmlGenericControl child = new HtmlGenericControl("div");
                    child.Attributes["class"] = "order print";
                    StringBuilder builder = new StringBuilder("");
                    builder.AppendFormat("<div class=\"info\"><div class=\"prime-info\" style=\"margin-right: 20px;\"><p><span><h3 style=\"font-weight: normal\">{0}</h3></span></p></div><ul class=\"sub-info\"><li><span>生成时间: </span>{1}</li><li><span>订单编号: </span>{2}</li></ul><br class=\"clear\" /></div>", info.ShipTo, info.OrderDate.ToString("yyyy-MM-dd HH:mm"), info.OrderId);
                    builder.Append("<table><col class=\"col-0\" /><col class=\"col-1\" /><col class=\"col-2\" /><col class=\"col-3\" /><col class=\"col-4\" /><col class=\"col-5\" /><thead><tr><th>货号</th><th>商品名称</th><th>规格</th><th>数量</th><th>单价</th><th>总价</th></tr></thead><tbody>");
                    Dictionary <string, LineItemInfo> lineItems = info.LineItems;
                    if (lineItems != null)
                    {
                        foreach (string str2 in lineItems.Keys)
                        {
                            LineItemInfo info2 = lineItems[str2];
                            builder.AppendFormat("<tr><td>{0}</td>", info2.SKU);
                            builder.AppendFormat("<td>{0}</td>", info2.ItemDescription);
                            builder.AppendFormat("<td>{0}</td>", info2.SKUContent);
                            builder.AppendFormat("<td>{0}</td>", info2.ShipmentQuantity);
                            builder.AppendFormat("<td>{0}</td>", Math.Round(info2.ItemListPrice, 2));
                            builder.AppendFormat("<td>{0}</td></tr>", Math.Round(info2.GetSubTotal(), 2));
                        }
                    }
                    string str3 = "";
                    IList <OrderGiftInfo> gifts = info.Gifts;
                    if ((gifts != null) && (gifts.Count > 0))
                    {
                        OrderGiftInfo info3 = gifts[0];
                        str3 = string.Format("<li><span>赠送礼品:</span>{0},数量:{1}</li>", info3.GiftName, info3.Quantity);
                    }
                    builder.AppendFormat("</tbody></table><ul class=\"price\"><li><span>商品总价: </span>{0}</li><li><span>运费: </span>{1}</li>", Math.Round(info.GetAmount(), 2), Math.Round(info.AdjustedFreight, 2));
                    decimal reducedPromotionAmount = info.ReducedPromotionAmount;
                    if (reducedPromotionAmount > 0M)
                    {
                        builder.AppendFormat("<li><span>优惠金额:</span>{0}</li>", Math.Round(reducedPromotionAmount, 2));
                    }
                    decimal payCharge = info.PayCharge;
                    if (payCharge > 0M)
                    {
                        builder.AppendFormat("<li><span>支付手续费:</span>{0}</li>", Math.Round(payCharge, 2));
                    }
                    if (!string.IsNullOrEmpty(info.CouponCode))
                    {
                        decimal couponValue = info.CouponValue;
                        if (couponValue > 0M)
                        {
                            builder.AppendFormat("<li><span>优惠券:</span>{0}</li>", Math.Round(couponValue, 2));
                        }
                    }
                    decimal adjustedDiscount = info.AdjustedDiscount;
                    if (adjustedDiscount > 0M)
                    {
                        builder.AppendFormat("<li><span>管理员手工打折:</span>{0}</li>", Math.Round(adjustedDiscount, 2));
                    }
                    builder.Append(str3);
                    builder.AppendFormat("<li><span>实付金额:</span>{0}</li></ul><br class=\"clear\" /><br><br>", Math.Round(info.GetTotal(), 2));
                    child.InnerHtml = builder.ToString();
                    this.divContent.Controls.AddAt(0, child);
                }
            }
        }