Exemple #1
0
        public static bool UpdateCalculationCommission(OrderInfo order)
        {
            new MemberDao().SetOrderDate(order.UserId, 2);
            DistributorsInfo userIdDistributors = DistributorsBrower.GetUserIdDistributors(order.ReferralUserId);
            SiteSettings     masterSettings     = SettingsManager.GetMasterSettings(false);
            bool             result             = false;

            if (userIdDistributors != null)
            {
                result = DistributorsBrower.setCommission(order, userIdDistributors);
                if (!string.IsNullOrEmpty(order.ReferralPath))
                {
                    ArrayList arrayList      = new ArrayList();
                    decimal   num            = 0m;
                    ArrayList arrayList2     = new ArrayList();
                    string    referralUserId = order.ReferralUserId.ToString();
                    string    orderId        = order.OrderId;
                    ArrayList arrayList3     = new ArrayList();
                    decimal   d          = 0m;
                    ArrayList arrayList4 = new ArrayList();
                    string[]  array      = order.ReferralPath.Split(new char[]
                    {
                        '|'
                    });
                    if (array.Length == 1)
                    {
                        DistributorsInfo userIdDistributors2 = DistributorsBrower.GetUserIdDistributors(int.Parse(array[0]));
                        if (userIdDistributors2 != null)
                        {
                            foreach (LineItemInfo current in order.LineItems.Values)
                            {
                                if (current.OrderItemsStatus.ToString() == OrderStatus.SellerAlreadySent.ToString())
                                {
                                    num += current.SecondItemsCommission;
                                    d   += current.GetSubTotal();
                                }
                            }
                            arrayList.Add(num);
                            arrayList3.Add(d + order.AdjustedFreight);
                            arrayList2.Add(userIdDistributors2.UserId);
                            try
                            {
                                if (order != null && num > 0m)
                                {
                                    string userOpenIdByUserId    = MemberProcessor.GetUserOpenIdByUserId(userIdDistributors2.UserId);
                                    string aliUserOpenIdByUserId = MemberProcessor.GetAliUserOpenIdByUserId(userIdDistributors2.UserId);
                                    Messenger.SendWeiXinMsg_OrderGetCommission(order, userOpenIdByUserId, aliUserOpenIdByUserId, num);
                                }
                            }
                            catch (Exception var_16_1FA)
                            {
                            }
                            int notDescDistributorGrades = DistributorsBrower.GetNotDescDistributorGrades(userIdDistributors2.UserId.ToString());
                            if (userIdDistributors2.DistriGradeId != notDescDistributorGrades)
                            {
                                DistributorsBrower.DistributorGradeChange(userIdDistributors2, order.OrderId, notDescDistributorGrades);
                            }
                        }
                    }
                    if (array.Length == 2)
                    {
                        DistributorsInfo userIdDistributors3 = DistributorsBrower.GetUserIdDistributors(int.Parse(array[0]));
                        foreach (LineItemInfo current in order.LineItems.Values)
                        {
                            if (current.OrderItemsStatus.ToString() == OrderStatus.SellerAlreadySent.ToString())
                            {
                                num += current.ThirdItemsCommission;
                                d   += current.GetSubTotal();
                            }
                        }
                        arrayList.Add(num);
                        arrayList3.Add(d + order.AdjustedFreight);
                        arrayList2.Add(userIdDistributors3.UserId);
                        try
                        {
                            if (order != null && num > 0m)
                            {
                                string userOpenIdByUserId    = MemberProcessor.GetUserOpenIdByUserId(userIdDistributors3.UserId);
                                string aliUserOpenIdByUserId = MemberProcessor.GetAliUserOpenIdByUserId(userIdDistributors3.UserId);
                                Messenger.SendWeiXinMsg_OrderGetCommission(order, userOpenIdByUserId, aliUserOpenIdByUserId, num);
                            }
                        }
                        catch (Exception var_16_1FA)
                        {
                        }
                        int notDescDistributorGrades = DistributorsBrower.GetNotDescDistributorGrades(userIdDistributors3.UserId.ToString());
                        if (userIdDistributors3.DistriGradeId != notDescDistributorGrades)
                        {
                            DistributorsBrower.DistributorGradeChange(userIdDistributors3, order.OrderId, notDescDistributorGrades);
                        }
                        DistributorsInfo userIdDistributors4 = DistributorsBrower.GetUserIdDistributors(int.Parse(array[1]));
                        num = 0m;
                        d   = 0m;
                        foreach (LineItemInfo current in order.LineItems.Values)
                        {
                            if (current.OrderItemsStatus.ToString() == OrderStatus.SellerAlreadySent.ToString())
                            {
                                num += current.SecondItemsCommission;
                                d   += current.GetSubTotal();
                            }
                        }
                        arrayList.Add(num);
                        arrayList3.Add(d + order.AdjustedFreight);
                        arrayList2.Add(userIdDistributors4.UserId);
                        try
                        {
                            if (order != null && num > 0m)
                            {
                                string userOpenIdByUserId    = MemberProcessor.GetUserOpenIdByUserId(userIdDistributors4.UserId);
                                string aliUserOpenIdByUserId = MemberProcessor.GetAliUserOpenIdByUserId(userIdDistributors4.UserId);
                                Messenger.SendWeiXinMsg_OrderGetCommission(order, userOpenIdByUserId, aliUserOpenIdByUserId, num);
                            }
                        }
                        catch (Exception var_16_1FA)
                        {
                        }
                        int notDescDistributorGrades2 = DistributorsBrower.GetNotDescDistributorGrades(userIdDistributors4.UserId.ToString());
                        if (userIdDistributors4.DistriGradeId != notDescDistributorGrades2)
                        {
                            DistributorsBrower.DistributorGradeChange(userIdDistributors4, order.OrderId, notDescDistributorGrades2);
                        }
                    }
                    result = new DistributorsDao().UpdateTwoCalculationCommission(arrayList2, referralUserId, orderId, arrayList3, arrayList);
                    for (int i = 0; i < arrayList2.Count; i++)
                    {
                        int notDescDistributorGrades3 = DistributorsBrower.GetNotDescDistributorGrades(arrayList2[i].ToString());
                        arrayList4.Add(notDescDistributorGrades3);
                    }
                    result = new DistributorsDao().UpdateGradeId(arrayList4, arrayList2);
                }
                DistributorsBrower.RemoveDistributorCache(userIdDistributors.UserId);
            }
            OrderRedPagerBrower.CreateOrderRedPager(order.OrderId, order.GetTotal(), order.UserId);
            int num2 = Globals.IsNumeric(order.ActivitiesId) ? Globals.ToNum(order.ActivitiesId) : 0;

            if (num2 > 0)
            {
                Hidistro.SqlDal.VShop.ActivityDao activityDao = new Hidistro.SqlDal.VShop.ActivityDao();
                ActivityDetailInfo activityDetailInfo         = activityDao.GetActivityDetailInfo(num2);
                if (activityDetailInfo != null)
                {
                    int couponId = activityDetailInfo.CouponId;
                    int integral = activityDetailInfo.Integral;
                    if (couponId > 0)
                    {
                        CouponInfo coupon = ShoppingProcessor.GetCoupon(couponId.ToString());
                        if (coupon != null)
                        {
                            CouponDao        couponDao        = new CouponDao();
                            SendCouponResult sendCouponResult = couponDao.SendCouponToMember(couponId, order.UserId);
                            try
                            {
                                if (order != null)
                                {
                                    Messenger.SendWeiXinMsg_OrderGetCoupon(order);
                                }
                            }
                            catch (Exception var_16_1FA)
                            {
                            }
                        }
                    }
                    if (integral > 0)
                    {
                        new OrderDao().AddMemberPointNumber(integral, order, null);
                        try
                        {
                            if (order != null)
                            {
                                Messenger.SendWeiXinMsg_OrderGetPoint(order, integral);
                            }
                        }
                        catch (Exception var_16_1FA)
                        {
                        }
                    }
                }
            }
            MemberProcessor.UpdateUserAccount(order);
            try
            {
                string   text      = "";
                DateTime orderDate = order.OrderDate;
                DateTime?payDate   = order.PayDate;
                if (order.Gateway == "hishop.plugins.payment.podrequest")
                {
                    payDate = new DateTime?(orderDate);
                }
                if (payDate.HasValue && payDate.Value.ToString("yyyy-MM-dd") != DateTime.Now.ToString("yyyy-MM-dd"))
                {
                    bool flag = new ShopStatisticDao().StatisticsOrdersByRecDate(payDate.Value, UpdateAction.AllUpdate, 0, out text);
                }
            }
            catch
            {
            }
            return(result);
        }