Beispiel #1
0
 static void UpdateUserAccount(OrderInfo order)
 {
     int userId = order.UserId;
     if (userId == 0x44c)
     {
         userId = 0;
     }
     IUser user = Users.GetUser(userId, false);
     if ((user != null) && (user.UserRole == UserRole.Member))
     {
         Member member = user as Member;
         UserPointInfo point = new UserPointInfo();
         point.OrderId = order.OrderId;
         point.UserId = member.UserId;
         point.TradeDate = DateTime.Now;
         point.TradeType = UserPointTradeType.Bounty;
         point.Increased = new int?(order.GetTotalPoints());
         point.Points = order.GetTotalPoints() + member.Points;
         if ((point.Points > 0x7fffffff) || (point.Points < 0))
         {
             point.Points = 0x7fffffff;
         }
         SalesProvider.Instance().AddMemberPoint(point);
         int referralDeduct = HiContext.Current.SiteSettings.ReferralDeduct;
         if (((referralDeduct > 0) && member.ReferralUserId.HasValue) && (member.ReferralUserId.Value > 0))
         {
             IUser user2 = Users.GetUser(member.ReferralUserId.Value, false);
             if ((user2 != null) && (user2.UserRole == UserRole.Member))
             {
                 Member member2 = user2 as Member;
                 if ((member.ParentUserId == member2.ParentUserId) && member2.IsOpenBalance)
                 {
                     decimal num3 = member2.Balance + ((order.GetTotal() * referralDeduct) / 100M);
                     BalanceDetailInfo balanceDetail = new BalanceDetailInfo();
                     balanceDetail.UserId = member2.UserId;
                     balanceDetail.UserName = member2.Username;
                     balanceDetail.TradeDate = DateTime.Now;
                     balanceDetail.TradeType = TradeTypes.ReferralDeduct;
                     balanceDetail.Income = new decimal?((order.GetTotal() * referralDeduct) / 100M);
                     balanceDetail.Balance = num3;
                     balanceDetail.Remark = string.Format("提成来自'{0}'的订单{1}", order.Username, order.OrderId);
                     MemberProvider.Instance().InsertBalanceDetail(balanceDetail);
                 }
             }
         }
         SalesProvider.Instance().UpdateUserAccount(order.GetTotal(), order.UserId);
         int historyPoint = SalesProvider.Instance().GetHistoryPoint(member.UserId);
         SalesProvider.Instance().ChangeMemberGrade(member.UserId, member.GradeId, historyPoint);
         Users.ClearUserCache(user);
     }
 }
Beispiel #2
0
 bool CreatOrder(OrderInfo orderInfo, DbTransaction dbTran)
 {
     DbCommand storedProcCommand = this.database.GetStoredProcCommand("ss_distro_CreateOrder");
     this.database.AddInParameter(storedProcCommand, "OrderId", DbType.String, orderInfo.OrderId);
     this.database.AddInParameter(storedProcCommand, "OrderDate", DbType.DateTime, orderInfo.OrderDate);
     this.database.AddInParameter(storedProcCommand, "UserId", DbType.Int32, orderInfo.UserId);
     this.database.AddInParameter(storedProcCommand, "UserName", DbType.String, orderInfo.Username);
     this.database.AddInParameter(storedProcCommand, "Wangwang", DbType.String, orderInfo.Wangwang);
     this.database.AddInParameter(storedProcCommand, "RealName", DbType.String, orderInfo.RealName);
     this.database.AddInParameter(storedProcCommand, "EmailAddress", DbType.String, orderInfo.EmailAddress);
     this.database.AddInParameter(storedProcCommand, "Remark", DbType.String, orderInfo.Remark);
     this.database.AddInParameter(storedProcCommand, "AdjustedDiscount", DbType.Currency, orderInfo.AdjustedDiscount);
     this.database.AddInParameter(storedProcCommand, "OrderStatus", DbType.Int32, (int) orderInfo.OrderStatus);
     this.database.AddInParameter(storedProcCommand, "DistributorUserId", DbType.Int32, HiContext.Current.SiteSettings.UserId.Value);
     this.database.AddInParameter(storedProcCommand, "ShippingRegion", DbType.String, orderInfo.ShippingRegion);
     this.database.AddInParameter(storedProcCommand, "Address", DbType.String, orderInfo.Address);
     this.database.AddInParameter(storedProcCommand, "ZipCode", DbType.String, orderInfo.ZipCode);
     this.database.AddInParameter(storedProcCommand, "ShipTo", DbType.String, orderInfo.ShipTo);
     this.database.AddInParameter(storedProcCommand, "TelPhone", DbType.String, orderInfo.TelPhone);
     this.database.AddInParameter(storedProcCommand, "CellPhone", DbType.String, orderInfo.CellPhone);
     this.database.AddInParameter(storedProcCommand, "ShippingModeId", DbType.Int32, orderInfo.ShippingModeId);
     this.database.AddInParameter(storedProcCommand, "ModeName", DbType.String, orderInfo.ModeName);
     this.database.AddInParameter(storedProcCommand, "RegionId", DbType.Int32, orderInfo.RegionId);
     this.database.AddInParameter(storedProcCommand, "Freight", DbType.Currency, orderInfo.Freight);
     this.database.AddInParameter(storedProcCommand, "AdjustedFreight", DbType.Currency, orderInfo.AdjustedFreight);
     this.database.AddInParameter(storedProcCommand, "ShipOrderNumber", DbType.String, orderInfo.ShipOrderNumber);
     this.database.AddInParameter(storedProcCommand, "Weight", DbType.Int32, orderInfo.Weight);
     this.database.AddInParameter(storedProcCommand, "ExpressCompanyName", DbType.String, orderInfo.ExpressCompanyName);
     this.database.AddInParameter(storedProcCommand, "ExpressCompanyAbb", DbType.String, orderInfo.ExpressCompanyAbb);
     this.database.AddInParameter(storedProcCommand, "PaymentTypeId", DbType.Int32, orderInfo.PaymentTypeId);
     this.database.AddInParameter(storedProcCommand, "PaymentType", DbType.String, orderInfo.PaymentType);
     this.database.AddInParameter(storedProcCommand, "PayCharge", DbType.Currency, orderInfo.PayCharge);
     this.database.AddInParameter(storedProcCommand, "AdjustedPayCharge", DbType.Currency, orderInfo.AdjustedPayCharge);
     this.database.AddInParameter(storedProcCommand, "RefundStatus", DbType.Int32, (int) orderInfo.RefundStatus);
     this.database.AddInParameter(storedProcCommand, "OrderTotal", DbType.Currency, orderInfo.GetTotal());
     this.database.AddInParameter(storedProcCommand, "OrderPoint", DbType.Int32, orderInfo.GetTotalPoints());
     this.database.AddInParameter(storedProcCommand, "OrderCostPrice", DbType.Currency, orderInfo.GetCostPrice());
     this.database.AddInParameter(storedProcCommand, "OrderProfit", DbType.Currency, orderInfo.GetProfit());
     this.database.AddInParameter(storedProcCommand, "OptionPrice", DbType.Currency, orderInfo.GetOptionPrice());
     this.database.AddInParameter(storedProcCommand, "Amount", DbType.Currency, orderInfo.GetAmount());
     this.database.AddInParameter(storedProcCommand, "ActivityName", DbType.String, orderInfo.ActivityName);
     this.database.AddInParameter(storedProcCommand, "ActivityId", DbType.Int32, orderInfo.ActivityId);
     this.database.AddInParameter(storedProcCommand, "EightFree", DbType.Boolean, orderInfo.EightFree);
     this.database.AddInParameter(storedProcCommand, "ProcedureFeeFree", DbType.Boolean, orderInfo.ProcedureFeeFree);
     this.database.AddInParameter(storedProcCommand, "OrderOptionFree", DbType.Boolean, orderInfo.OrderOptionFree);
     this.database.AddInParameter(storedProcCommand, "DiscountName", DbType.String, orderInfo.DiscountName);
     this.database.AddInParameter(storedProcCommand, "DiscountId", DbType.Int32, orderInfo.DiscountId);
     this.database.AddInParameter(storedProcCommand, "DiscountValue", DbType.Currency, orderInfo.DiscountValue);
     this.database.AddInParameter(storedProcCommand, "DiscountValueType", DbType.Int32, (int) orderInfo.DiscountValueType);
     this.database.AddInParameter(storedProcCommand, "DiscountAmount", DbType.Currency, orderInfo.GetDiscountAmount());
     this.database.AddInParameter(storedProcCommand, "CouponName", DbType.String, orderInfo.CouponName);
     this.database.AddInParameter(storedProcCommand, "CouponCode", DbType.String, orderInfo.CouponCode);
     this.database.AddInParameter(storedProcCommand, "CouponAmount", DbType.Currency, orderInfo.CouponAmount);
     this.database.AddInParameter(storedProcCommand, "CouponValue", DbType.Currency, orderInfo.CouponValue);
     if (orderInfo.GroupBuyId > 0)
     {
         this.database.AddInParameter(storedProcCommand, "GroupBuyId", DbType.Int32, orderInfo.GroupBuyId);
         this.database.AddInParameter(storedProcCommand, "NeedPrice", DbType.Currency, orderInfo.NeedPrice);
         this.database.AddInParameter(storedProcCommand, "GroupBuyStatus", DbType.Int32, 1);
     }
     else
     {
         this.database.AddInParameter(storedProcCommand, "GroupBuyId", DbType.Int32, DBNull.Value);
         this.database.AddInParameter(storedProcCommand, "NeedPrice", DbType.Currency, DBNull.Value);
         this.database.AddInParameter(storedProcCommand, "GroupBuyStatus", DbType.Int32, DBNull.Value);
     }
     return (this.database.ExecuteNonQuery(storedProcCommand, dbTran) == 1);
 }
Beispiel #3
0
 public override int ConfirmPay(OrderInfo order)
 {
     DbCommand sqlStringCommand = database.GetSqlStringCommand("UPDATE Hishop_Orders SET PayDate = @PayDate, OrderStatus = @OrderStatus ,OrderPoint=@OrderPoint WHERE OrderId = @OrderId");
     database.AddInParameter(sqlStringCommand, "OrderPoint", DbType.Int32, order.GetTotalPoints());
     database.AddInParameter(sqlStringCommand, "PayDate", DbType.DateTime, DateTime.Now);
     database.AddInParameter(sqlStringCommand, "OrderStatus", DbType.Int32, 2);
     database.AddInParameter(sqlStringCommand, "OrderId", DbType.String, order.OrderId);
     return database.ExecuteNonQuery(sqlStringCommand);
 }
Beispiel #4
0
 public override bool UpdateOrderAmount(OrderInfo order, DbTransaction dbTran)
 {
     DbCommand sqlStringCommand = database.GetSqlStringCommand("UPDATE Hishop_Orders SET OrderTotal = @OrderTotal, OrderProfit=@OrderProfit, AdjustedFreight = @AdjustedFreight, AdjustedPayCharge = @AdjustedPayCharge, AdjustedDiscount=@AdjustedDiscount, OrderPoint=@OrderPoint, Amount=@Amount,OrderCostPrice=@OrderCostPrice WHERE OrderId = @OrderId");
     database.AddInParameter(sqlStringCommand, "OrderTotal", DbType.Currency, order.GetTotal());
     database.AddInParameter(sqlStringCommand, "AdjustedFreight", DbType.Currency, order.AdjustedFreight);
     database.AddInParameter(sqlStringCommand, "AdjustedPayCharge", DbType.Currency, order.AdjustedPayCharge);
     database.AddInParameter(sqlStringCommand, "OrderCostPrice", DbType.Currency, order.GetCostPrice());
     database.AddInParameter(sqlStringCommand, "AdjustedDiscount", DbType.Currency, order.AdjustedDiscount);
     database.AddInParameter(sqlStringCommand, "OrderPoint", DbType.Int32, order.GetTotalPoints());
     database.AddInParameter(sqlStringCommand, "OrderProfit", DbType.Currency, order.GetProfit());
     database.AddInParameter(sqlStringCommand, "OrderId", DbType.String, order.OrderId);
     database.AddInParameter(sqlStringCommand, "Amount", DbType.Currency, order.GetAmount());
     if (dbTran != null)
     {
         return (database.ExecuteNonQuery(sqlStringCommand, dbTran) == 1);
     }
     return (database.ExecuteNonQuery(sqlStringCommand) == 1);
 }
Beispiel #5
0
 public override int ConfirmPay(OrderInfo order, DbTransaction dbTran)
 {
     DbCommand sqlStringCommand = database.GetSqlStringCommand("UPDATE distro_Orders SET PayDate = @PayDate, OrderStatus = @OrderStatus,OrderPoint=@OrderPoint WHERE OrderId = @OrderId AND DistributorUserId=@DistributorUserId");
     database.AddInParameter(sqlStringCommand, "PayDate", DbType.DateTime, DateTime.Now);
     database.AddInParameter(sqlStringCommand, "OrderPoint", DbType.Int32, order.GetTotalPoints());
     database.AddInParameter(sqlStringCommand, "OrderStatus", DbType.Int32, 2);
     database.AddInParameter(sqlStringCommand, "OrderId", DbType.String, order.OrderId);
     database.AddInParameter(sqlStringCommand, "DistributorUserId", DbType.Int32, HiContext.Current.User.UserId);
     if (dbTran != null)
     {
         return database.ExecuteNonQuery(sqlStringCommand, dbTran);
     }
     return database.ExecuteNonQuery(sqlStringCommand);
 }
Beispiel #6
0
 public override bool UserPayOrder(OrderInfo order, bool isBalancePayOrder, DbTransaction dbTran)
 {
     StringBuilder builder = new StringBuilder();
     builder.AppendFormat("UPDATE Hishop_Orders SET OrderStatus = {0}, PayDate = '{1}', GatewayOrderId = @GatewayOrderId ,OrderPoint=@OrderPoint WHERE OrderId = '{2}';", 2, DateTime.Now, order.OrderId);
     if (isBalancePayOrder)
     {
         Member user = Users.GetUser(order.UserId, false) as Member;
         decimal num = user.Balance - order.GetTotal();
         if ((user.Balance - user.RequestBalance) < order.GetTotal())
         {
             return false;
         }
         builder.AppendFormat("INSERT INTO Hishop_BalanceDetails(UserId,UserName, TradeDate, TradeType, Expenses, Balance,Remark) VALUES({0},'{1}', '{2}', {3}, {4}, {5},'{6}');", new object[] { order.UserId, HiContext.Current.User.Username, DateTime.Now, 3, order.GetTotal(), num, string.Format("对订单{0}付款", order.OrderId) });
     }
     DbCommand sqlStringCommand = database.GetSqlStringCommand(builder.ToString());
     database.AddInParameter(sqlStringCommand, "GatewayOrderId", DbType.String, order.GatewayOrderId);
     database.AddInParameter(sqlStringCommand, "OrderPoint", DbType.Int32, order.GetTotalPoints());
     return (database.ExecuteNonQuery(sqlStringCommand, dbTran) >= 1);
 }
Beispiel #7
0
 private void BindTatolAmount(OrderInfo order)
 {
     decimal amount = order.GetAmount();
     lblAllPrice.Money = amount;
     lblWeight.Text = order.Weight.ToString(CultureInfo.InvariantCulture);
     litIntegral.Text = order.GetTotalPoints().ToString(CultureInfo.InvariantCulture);
     litTotal.Text = Globals.FormatMoney(order.GetTotal());
 }
Beispiel #8
0
 void BindOrderItems(OrderInfo order)
 {
     this.orderItems.DataSource = order.LineItems.Values;
     this.orderItems.DataBind();
     if (order.Gifts.Count > 0)
     {
         this.plOrderGift.Visible = true;
         this.grdOrderGift.DataSource = order.Gifts;
         this.grdOrderGift.DataBind();
     }
     this.lblCartMoney.Money = order.GetAmount();
     this.litWeight.Text = order.Weight.ToString();
     this.lblPayCharge.Money = order.AdjustedPayCharge;
     this.lblOptionPrice.Money = order.GetOptionPrice();
     this.lblFreight.Money = order.AdjustedFreight;
     this.lblAdjustedDiscount.Money = order.AdjustedDiscount;
     this.litCouponValue.Text = order.CouponName + " -" + Globals.FormatMoney(order.CouponValue);
     this.lblDiscount.Money = order.GetAmount() - order.GetDiscountedAmount();
     if (order.OrderStatus == OrderStatus.WaitBuyerPay)
     {
         this.litPoints.Text = order.GetTotalPoints().ToString(CultureInfo.InvariantCulture);
     }
     else
     {
         this.litPoints.Text = order.Points.ToString(CultureInfo.InvariantCulture);
     }
     this.litTotalPrice.Money = order.GetTotal();
 }
Beispiel #9
0
 public static bool UserPayOrder(OrderInfo order, bool isBalancePayOrder)
 {
     bool flag = false;
     if (order.CheckAction(OrderActions.BUYER_PAY))
     {
         using (DbConnection connection = DatabaseFactory.CreateDatabase().CreateConnection())
         {
             connection.Open();
             DbTransaction dbTran = connection.BeginTransaction();
             try
             {
                 if (!TradeProvider.Instance().UserPayOrder(order, isBalancePayOrder, dbTran))
                 {
                     dbTran.Rollback();
                     return false;
                 }
                 if ((HiContext.Current.SiteSettings.IsDistributorSettings && (order.GroupBuyId <= 0)) && !PurchaseOrderProvider.CreateInstance().CreatePurchaseOrder(order, dbTran))
                 {
                     dbTran.Rollback();
                     return false;
                 }
                 flag = true;
                 dbTran.Commit();
             }
             catch
             {
                 dbTran.Rollback();
                 return false;
             }
             finally
             {
                 connection.Close();
             }
         }
         if (!flag)
         {
             return flag;
         }
         if (!HiContext.Current.SiteSettings.IsDistributorSettings)
         {
             TradeProvider.Instance().UpdateStockPayOrder(order.OrderId);
         }
         TradeProvider.Instance().UpdateProductSaleCounts(order.LineItems);
         if ((order.UserId == 0) || (order.UserId == 0x44c))
         {
             return flag;
         }
         IUser user = Users.GetUser(order.UserId, false);
         if (((user == null) || (user.UserRole != UserRole.Member)) && ((user == null) || (user.UserRole != UserRole.Underling)))
         {
             return flag;
         }
         Member member = user as Member;
         UserPointInfo point = new UserPointInfo();
         point.OrderId = order.OrderId;
         point.UserId = member.UserId;
         point.TradeDate = DateTime.Now;
         point.TradeType = UserPointTradeType.Bounty;
         point.Increased = new int?(order.GetTotalPoints());
         point.Points = order.GetTotalPoints() + member.Points;
         if ((point.Points > 0x7fffffff) || (point.Points < 0))
         {
             point.Points = 0x7fffffff;
         }
         TradeProvider.Instance().AddMemberPoint(point);
         int referralDeduct = HiContext.Current.SiteSettings.ReferralDeduct;
         if (((referralDeduct > 0) && member.ReferralUserId.HasValue) && (member.ReferralUserId.Value > 0))
         {
             IUser user2 = Users.GetUser(member.ReferralUserId.Value, false);
             if ((user2 != null) && ((user2.UserRole == UserRole.Member) || (user2.UserRole == UserRole.Underling)))
             {
                 Member member2 = user2 as Member;
                 if ((member.ParentUserId == member2.ParentUserId) && member2.IsOpenBalance)
                 {
                     decimal num2 = member2.Balance + ((order.GetTotal() * referralDeduct) / 100M);
                     BalanceDetailInfo balanceDetails = new BalanceDetailInfo();
                     balanceDetails.UserId = member2.UserId;
                     balanceDetails.UserName = member2.Username;
                     balanceDetails.TradeDate = DateTime.Now;
                     balanceDetails.TradeType = TradeTypes.ReferralDeduct;
                     balanceDetails.Income = new decimal?((order.GetTotal() * referralDeduct) / 100M);
                     balanceDetails.Balance = num2;
                     balanceDetails.Remark = string.Format("提成来自'{0}'的订单{1}", order.Username, order.OrderId);
                     PersonalProvider.Instance().AddBalanceDetail(balanceDetails);
                 }
             }
         }
         TradeProvider.Instance().UpdateUserAccount(order.GetTotal(), point.Points, order.UserId);
         int historyPoint = TradeProvider.Instance().GetHistoryPoint(member.UserId);
         TradeProvider.Instance().ChangeMemberGrade(member.UserId, member.GradeId, historyPoint);
         Users.ClearUserCache(user);
     }
     return flag;
 }