Ejemplo n.º 1
0
        public static bool UserPayOrder(OrderInfo order)
        {
            OrderDao dao = new OrderDao();

            order.OrderStatus = OrderStatus.BuyerAlreadyPaid;
            order.PayDate     = new DateTime?(DateTime.Now);
            bool   flag = dao.UpdateOrder(order, null);
            string str  = "";

            Globals.Debuglog("调用付款:" + order.OrderId + ",成功否:" + flag.ToString() + ",order.UserId:" + order.UserId.ToString(), "_DebuglogPaymentTest.txt");
            if (flag)
            {
                if (order.UserId == 0)
                {
                    //更新保险订单状态
                    if (order.CouponCode != "")
                    {
                        InsuranceDao       daoid     = new InsuranceDao();
                        InsuranceOrderInfo insurance = daoid.GetModel(Convert.ToInt32(order.CouponCode));
                        insurance.InsuranceOrderStatu = 3;
                        daoid.Update(insurance);
                    }
                    try
                    {
                        Messenger.SendWeiXinMsg_OrderPay(order);
                    }
                    catch
                    {
                    }
                }
                else
                {
                    dao.UpdatePayOrderStock(order);
                    SettingsManager.GetMasterSettings(true);
                    MemberInfo member = GetMember(order.UserId, true);
                    if (VshopBrowser.IsPassAutoToDistributor(member, true))
                    {
                        DistributorsBrower.MemberAutoToDistributor(member);
                    }
                    new MemberDao().SetOrderDate(order.UserId, 1);
                    foreach (LineItemInfo info2 in order.LineItems.Values)
                    {
                        ProductDao dao2 = new ProductDao();
                        str = str + "'" + info2.SkuId + "',";
                        ProductInfo productDetails = dao2.GetProductDetails(info2.ProductId);
                        productDetails.SaleCounts     += info2.Quantity;
                        productDetails.ShowSaleCounts += info2.Quantity;
                        dao2.UpdateProduct(productDetails, null);
                    }
                    if (!string.IsNullOrEmpty(str))
                    {
                        dao.UpdateItemsStatus(order.OrderId, 2, str.Substring(0, str.Length - 1));
                    }
                    if (!string.IsNullOrEmpty(order.ActivitiesId))
                    {
                        new ActivitiesDao().UpdateActivitiesTakeEffect(order.ActivitiesId);
                    }
                    if (member == null)
                    {
                        return(flag);
                    }
                    Globals.Debuglog("发微信消息:" + order.OrderId + ",成功:" + flag.ToString() + ",order.UserId:" + order.UserId.ToString(), "_DebuglogPaymentTest.txt");
                    try
                    {
                        Messenger.SendWeiXinMsg_OrderPay(order);
                    }
                    catch
                    {
                    }
                }
            }
            return(flag);
        }
Ejemplo n.º 2
0
        public static bool UserPayOrder(OrderInfo order)
        {
            OrderDao dao = new OrderDao();

            order.OrderStatus = OrderStatus.BuyerAlreadyPaid;
            order.PayDate     = new DateTime?(DateTime.Now);
            bool   flag = dao.UpdateOrder(order, null);
            string str  = "";

            if (flag)
            {
                dao.UpdatePayOrderStock(order.OrderId);
                foreach (LineItemInfo info in order.LineItems.Values)
                {
                    ProductDao dao2 = new ProductDao();
                    str = str + "'" + info.SkuId + "',";
                    ProductInfo productDetails = dao2.GetProductDetails(info.ProductId);
                    productDetails.SaleCounts     += info.Quantity;
                    productDetails.ShowSaleCounts += info.Quantity;
                    dao2.UpdateProduct(productDetails, null);
                }
                if (!string.IsNullOrEmpty(str))
                {
                    dao.UpdateItemsStatus(order.OrderId, 2, str.Substring(0, str.Length - 1));
                }
                if (!string.IsNullOrEmpty(order.ActivitiesId))
                {
                    new ActivitiesDao().UpdateActivitiesTakeEffect(order.ActivitiesId);
                }
                MemberInfo member = GetMember(order.UserId);
                if (member == null)
                {
                    return(flag);
                }
                MemberDao       dao4  = new MemberDao();
                PointDetailInfo point = new PointDetailInfo {
                    OrderId   = order.OrderId,
                    UserId    = member.UserId,
                    TradeDate = DateTime.Now,
                    TradeType = PointTradeType.Bounty,
                    Increased = new int?(order.Points),
                    Points    = order.Points + member.Points
                };
                if ((point.Points > 0x7fffffff) || (point.Points < 0))
                {
                    point.Points = 0x7fffffff;
                }
                PointDetailDao dao5 = new PointDetailDao();
                dao5.AddPointDetail(point);
                member.Expenditure += order.GetTotal();
                member.OrderNumber++;
                dao4.Update(member);
                Messenger.OrderPayment(member, order.OrderId, order.GetTotal());
                int             historyPoint = dao5.GetHistoryPoint(member.UserId);
                MemberGradeInfo memberGrade  = GetMemberGrade(member.GradeId);
                //点睛教育需求:给代理商以及1级分销商加上佣金的20%的积分
                DistributorsBrower.UpdateDistributorPoints(order);
                if ((memberGrade != null) && (memberGrade.Points > historyPoint))
                {
                    return(flag);
                }
                List <MemberGradeInfo> memberGrades = new MemberGradeDao().GetMemberGrades() as List <MemberGradeInfo>;
                foreach (MemberGradeInfo info6 in from item in memberGrades
                         orderby item.Points descending
                         select item)
                {
                    if (member.GradeId == info6.GradeId)
                    {
                        return(flag);
                    }
                    if (info6.Points <= historyPoint)
                    {
                        member.GradeId = info6.GradeId;
                        dao4.Update(member);
                        return(flag);
                    }
                }
            }
            return(flag);
        }