예제 #1
0
        public static bool PointChageCoupon(int couponId, int needPoint, int currentPoint)
        {
            Member        user  = HiContext.Current.User as Member;
            UserPointInfo point = new UserPointInfo {
                OrderId   = string.Empty,
                UserId    = user.UserId,
                TradeDate = DateTime.Now,
                TradeType = UserPointTradeType.ChangeCoupon,
                Increased = null,
                Reduced   = new int?(needPoint),
                Points    = currentPoint - needPoint
            };

            if ((point.Points >= 0) && TradeProvider.Instance().AddMemberPoint(point))
            {
                CouponItemInfo couponItem = new CouponItemInfo {
                    CouponId     = couponId,
                    UserId       = new int?(user.UserId),
                    UserName     = user.Username,
                    EmailAddress = user.Email,
                    ClaimCode    = Guid.NewGuid().ToString().Replace("-", "").Substring(0, 15),
                    GenerateTime = DateTime.Now
                };
                Users.ClearUserCache(user);
                if (TradeProvider.Instance().SendClaimCodes(couponItem))
                {
                    return(true);
                }
            }
            return(false);
        }
예제 #2
0
        public static bool ConfirmOrderFinish(OrderInfo order)
        {
            bool flag = false;

            if (order.CheckAction(OrderActions.BUYER_CONFIRM_GOODS))
            {
                flag = TradeProvider.Instance().ConfirmOrderFinish(order);
            }
            return(flag);
        }
예제 #3
0
        public static bool PointChageCoupon(int couponId, int needPoint, int currentPoint)
        {
            Member        member        = HiContext.Current.User as Member;
            UserPointInfo userPointInfo = new UserPointInfo();

            userPointInfo.OrderId   = string.Empty;
            userPointInfo.UserId    = member.UserId;
            userPointInfo.TradeDate = DateTime.Now;
            userPointInfo.TradeType = UserPointTradeType.ChangeCoupon;
            userPointInfo.Increased = null;
            userPointInfo.Reduced   = new int?(needPoint);
            userPointInfo.Points    = currentPoint - needPoint;
            bool result;

            if (userPointInfo.Points < 0)
            {
                result = false;
            }
            else
            {
                if (TradeProvider.Instance().AddMemberPoint(userPointInfo))
                {
                    CouponItemInfo couponItemInfo = new CouponItemInfo();
                    couponItemInfo.CouponId     = couponId;
                    couponItemInfo.UserId       = new int?(member.UserId);
                    couponItemInfo.UserName     = member.Username;
                    couponItemInfo.EmailAddress = member.Email;
                    couponItemInfo.ClaimCode    = Guid.NewGuid().ToString().Replace("-", "").Substring(0, 15);
                    couponItemInfo.GenerateTime = DateTime.Now;
                    Users.ClearUserCache(member);
                    if (TradeProvider.Instance().SendClaimCodes(couponItemInfo))
                    {
                        result = true;
                        return(result);
                    }
                }
                result = false;
            }
            return(result);
        }
예제 #4
0
 public static GroupBuyInfo GetGroupBuy(int groupBuyId)
 {
     return(TradeProvider.Instance().GetGroupBuy(groupBuyId));
 }
예제 #5
0
 public static CountDownInfo GetCountDownBuy(int CountDownId)
 {
     return(TradeProvider.Instance().CountDownBuy(CountDownId));
 }
예제 #6
0
 public static DataTable GetChangeCoupons()
 {
     return(TradeProvider.Instance().GetChangeCoupons());
 }
예제 #7
0
 public static bool ApplyForReplace(string orderId, string remark)
 {
     return(TradeProvider.Instance().ApplyForReplace(orderId, remark));
 }
예제 #8
0
 public static DbQueryResult GetUserPoints(int pageIndex)
 {
     return(TradeProvider.Instance().GetUserPoints(pageIndex));
 }
예제 #9
0
 public static DataTable GetUserCoupons(int userId)
 {
     return(TradeProvider.Instance().GetUserCoupons(userId));
 }
예제 #10
0
 public static PaymentModeInfo GetPaymentMode(int modeId)
 {
     return(TradeProvider.Instance().GetPaymentMode(modeId));
 }
예제 #11
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 {
                    OrderId   = order.OrderId,
                    UserId    = member.UserId,
                    TradeDate = DateTime.Now,
                    TradeType = UserPointTradeType.Bounty,
                    Increased = new int?(order.Points),
                    Points    = order.Points + 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 {
                                UserId    = member2.UserId,
                                UserName  = member2.Username,
                                TradeDate = DateTime.Now,
                                TradeType = TradeTypes.ReferralDeduct,
                                Income    = new decimal?((order.GetTotal() * referralDeduct) / 100M),
                                Balance   = num2,
                                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);
        }
예제 #12
0
 public static bool SetGroupBuyEndUntreated(int groupBuyId)
 {
     return(TradeProvider.Instance().SetGroupBuyEndUntreated(groupBuyId));
 }
예제 #13
0
 public static bool SaveDebitNote(DebitNote note)
 {
     return(TradeProvider.Instance().SaveDebitNote(note));
 }
예제 #14
0
 public static DbQueryResult GetReplaceApplys(ReplaceApplyQuery query, int userId)
 {
     return(TradeProvider.Instance().GetReplaceApplys(query, userId));
 }
예제 #15
0
 public static decimal GetRefundMoney(OrderInfo order, out decimal refundMoney)
 {
     return(TradeProvider.Instance().GetRefundMoney(order, out refundMoney));
 }
예제 #16
0
 public static bool CanReplace(string orderId)
 {
     return(TradeProvider.Instance().CanReplace(orderId));
 }
예제 #17
0
 public static int GetOrderCount(int groupBuyId)
 {
     return(TradeProvider.Instance().GetOrderCount(groupBuyId));
 }
예제 #18
0
 public static int AddClaimCodeToUser(string claimCode, int userId)
 {
     return(TradeProvider.Instance().AddClaimCodeToUser(claimCode, userId));
 }
예제 #19
0
 public static OrderInfo GetOrderInfo(string orderId)
 {
     return(TradeProvider.Instance().GetOrderInfo(orderId));
 }
예제 #20
0
 public static bool CloseOrder(string orderId)
 {
     return(TradeProvider.Instance().CloseOrder(orderId));
 }
예제 #21
0
 public static IList <PaymentModeInfo> GetPaymentModes()
 {
     return(TradeProvider.Instance().GetPaymentModes());
 }
예제 #22
0
 public static bool UpdateOrderPaymentType(OrderInfo order)
 {
     return(TradeProvider.Instance().UpdateOrderPaymentType(order));
 }
예제 #23
0
 public static DbQueryResult GetUserOrder(int userId, OrderQuery query)
 {
     return(TradeProvider.Instance().GetUserOrder(userId, query));
 }
예제 #24
0
 public static bool ExitCouponClaimCode(string claimCode)
 {
     return(TradeProvider.Instance().ExitCouponClaimCode(claimCode));
 }
예제 #25
0
        public static bool UserPayOrder(OrderInfo order, bool isBalancePayOrder)
        {
            bool flag = false;
            bool result;

            if (order.CheckAction(OrderActions.BUYER_PAY))
            {
                Database database = DatabaseFactory.CreateDatabase();
                using (System.Data.Common.DbConnection dbConnection = database.CreateConnection())
                {
                    dbConnection.Open();
                    System.Data.Common.DbTransaction dbTransaction = dbConnection.BeginTransaction();
                    try
                    {
                        if (!TradeProvider.Instance().UserPayOrder(order, isBalancePayOrder, dbTransaction))
                        {
                            dbTransaction.Rollback();
                            result = false;
                            return(result);
                        }
                        if (HiContext.Current.SiteSettings.IsDistributorSettings && order.GroupBuyId <= 0)
                        {
                            PurchaseOrderProvider purchaseOrderProvider = PurchaseOrderProvider.CreateInstance();
                            if (!purchaseOrderProvider.CreatePurchaseOrder(order, dbTransaction))
                            {
                                dbTransaction.Rollback();
                                result = false;
                                return(result);
                            }
                        }
                        flag = true;
                        dbTransaction.Commit();
                    }
                    catch
                    {
                        dbTransaction.Rollback();
                        result = false;
                        return(result);
                    }
                    finally
                    {
                        dbConnection.Close();
                    }
                }
                if (flag)
                {
                    if (!HiContext.Current.SiteSettings.IsDistributorSettings)
                    {
                        TradeProvider.Instance().UpdateStockPayOrder(order.OrderId);
                    }
                    TradeProvider.Instance().UpdateProductSaleCounts(order.LineItems);
                    if (order.UserId != 0 && order.UserId != 1100)
                    {
                        IUser user = Users.GetUser(order.UserId, false);
                        bool  arg_145_0;
                        if (user != null)
                        {
                            if (user.UserRole == UserRole.Member)
                            {
                                arg_145_0 = false;
                                goto IL_145;
                            }
                        }
                        arg_145_0 = (user == null || user.UserRole != UserRole.Underling);
IL_145:
                        if (!arg_145_0)
                        {
                            Member        member        = user as Member;
                            UserPointInfo userPointInfo = new UserPointInfo();
                            userPointInfo.OrderId   = order.OrderId;
                            userPointInfo.UserId    = member.UserId;
                            userPointInfo.TradeDate = DateTime.Now;
                            userPointInfo.TradeType = UserPointTradeType.Bounty;
                            userPointInfo.Increased = new int?(order.Points);
                            userPointInfo.Points    = order.Points + member.Points;
                            int arg_1B7_0 = userPointInfo.Points;
                            if (userPointInfo.Points < 0)
                            {
                                userPointInfo.Points = 2147483647;
                            }
                            TradeProvider.Instance().AddMemberPoint(userPointInfo);
                            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           balance           = member2.Balance + order.GetTotal() * referralDeduct / 100m;
                                        BalanceDetailInfo balanceDetailInfo = new BalanceDetailInfo();
                                        balanceDetailInfo.UserId    = member2.UserId;
                                        balanceDetailInfo.UserName  = member2.Username;
                                        balanceDetailInfo.TradeDate = DateTime.Now;
                                        balanceDetailInfo.TradeType = TradeTypes.ReferralDeduct;
                                        balanceDetailInfo.Income    = new decimal?(order.GetTotal() * referralDeduct / 100m);
                                        balanceDetailInfo.Balance   = balance;
                                        balanceDetailInfo.Remark    = string.Format("提成来自'{0}'的订单{1}", order.Username, order.OrderId);
                                        PersonalProvider.Instance().AddBalanceDetail(balanceDetailInfo);
                                    }
                                }
                            }
                            TradeProvider.Instance().UpdateUserAccount(order.GetTotal(), userPointInfo.Points, order.UserId);
                            int historyPoint = TradeProvider.Instance().GetHistoryPoint(member.UserId);
                            TradeProvider.Instance().ChangeMemberGrade(member.UserId, member.GradeId, historyPoint);
                            Users.ClearUserCache(user);
                        }
                    }
                }
            }
            result = flag;
            return(result);
        }
예제 #26
0
 public static bool ApplyForReturn(string orderId, string remark, int refundType)
 {
     return(TradeProvider.Instance().ApplyForReturn(orderId, remark, refundType));
 }