Пример #1
0
        public static bool UpdateCalculationCommission(OrderInfo order, string wid)
        {
            DistributorsInfo userIdDistributors = GetUserIdDistributors(order.ReferralUserId);
            SiteSettings     masterSettings     = SettingsManager.GetMasterSettings(false, wid);
            bool             flag = false;

            if (userIdDistributors != null)
            {
                if (!masterSettings.EnableCommission)
                {
                    if (userIdDistributors.ReferralStatus == 0)
                    {
                        flag = setCommission(order, userIdDistributors);
                    }
                }
                else
                {
                    if (userIdDistributors.ReferralStatus == 0)
                    {
                        flag = setCommission(order, userIdDistributors);
                    }
                    if (!string.IsNullOrEmpty(userIdDistributors.ReferralPath))
                    {
                        ArrayList commTatalList  = new ArrayList();
                        decimal   num            = 0M;
                        ArrayList userIdList     = new ArrayList();
                        string    referralUserId = order.ReferralUserId.ToString();
                        string    orderId        = order.OrderId;
                        ArrayList orderTotalList = new ArrayList();
                        decimal   num2           = 0M;
                        ArrayList gradeIdList    = new ArrayList();
                        string[]  strArray       = userIdDistributors.ReferralPath.Split(new char[] { '|' });
                        if (strArray.Length == 1)
                        {
                            DistributorsInfo info2 = GetUserIdDistributors(int.Parse(strArray[0]));
                            if (info2.ReferralStatus == 0)
                            {
                                foreach (LineItemInfo info3 in order.LineItems.Values)
                                {
                                    if (info3.OrderItemsStatus.ToString() == OrderStatus.SellerAlreadySent.ToString())
                                    {
                                        num  += info3.SecondItemsCommission;
                                        num2 += info3.GetSubTotal();
                                    }
                                }
                                commTatalList.Add(num);
                                orderTotalList.Add(num2);
                                userIdList.Add(info2.UserId);
                            }
                        }
                        if (strArray.Length == 2)
                        {
                            DistributorsInfo info4 = GetUserIdDistributors(int.Parse(strArray[0]));
                            if (info4.ReferralStatus == 0)
                            {
                                foreach (LineItemInfo info5 in order.LineItems.Values)
                                {
                                    if (info5.OrderItemsStatus.ToString() == OrderStatus.SellerAlreadySent.ToString())
                                    {
                                        num  += info5.ThirdItemsCommission;
                                        num2 += info5.GetSubTotal();
                                    }
                                }
                                commTatalList.Add(num);
                                orderTotalList.Add(num2);
                                userIdList.Add(info4.UserId);
                            }
                            DistributorsInfo info6 = GetUserIdDistributors(int.Parse(strArray[1]));
                            num  = 0M;
                            num2 = 0M;
                            if (info6.ReferralStatus == 0)
                            {
                                foreach (LineItemInfo info7 in order.LineItems.Values)
                                {
                                    if (info7.OrderItemsStatus.ToString() == OrderStatus.SellerAlreadySent.ToString())
                                    {
                                        num  += info7.SecondItemsCommission;
                                        num2 += info7.GetSubTotal();
                                    }
                                }
                                commTatalList.Add(num);
                                orderTotalList.Add(num2);
                                userIdList.Add(info6.UserId);
                            }
                        }
                        flag = new DistributorsDao().UpdateTwoCalculationCommission(userIdList, referralUserId, orderId, orderTotalList, commTatalList);
                        for (int i = 0; i < userIdList.Count; i++)
                        {
                            int notDescDistributorGrades = GetNotDescDistributorGrades(userIdList[i].ToString());
                            gradeIdList.Add(notDescDistributorGrades);
                        }
                        flag = new DistributorsDao().UpdateGradeId(gradeIdList, userIdList);
                    }
                }
                RemoveDistributorCache(userIdDistributors.UserId);
            }
            OrderRedPagerBrower.CreateOrderRedPager(order.OrderId, order.GetTotal(), order.UserId);
            int id = Globals.IsNumeric(order.ActivitiesId) ? Globals.ToNum(order.ActivitiesId) : 0;

            if (id > 0)
            {
                ActivityDetailInfo activityDetailInfo = new Hidistro.SqlDal.VShop.ActivityDao().GetActivityDetailInfo(id);
                if (activityDetailInfo != null)
                {
                    int couponId = activityDetailInfo.CouponId;
                    int integral = activityDetailInfo.Integral;
                    if ((couponId > 0) && (ShoppingProcessor.GetCoupon(couponId.ToString()) != null))
                    {
                        new CouponDao().SendCouponToMember(couponId, order.UserId);
                    }
                    if (integral > 0)
                    {
                        new OrderDao().AddMemberPointNumber(integral, order, null);
                    }
                }
            }
            MemberProcessor.UpdateUserAccount(order, wid);
            return(flag);
        }
Пример #2
0
        /// <summary>
        /// jinhb,20150820,更新三级返佣金额,加入了无限代理佣金算法
        /// </summary>
        public static bool UpdateCalculationCommission(OrderInfo order)
        {
            DistributorsInfo userIdDistributors = GetUserIdDistributors(order.ReferralUserId);

            SiteSettings masterSettings = SettingsManager.GetMasterSettings(false);
            bool         flag           = false;

            if (userIdDistributors != null)
            {
                bool isAgent1 = (userIdDistributors.IsAgent == 1) ? true : false;
                bool isAgent2 = false;
                bool isAgent3 = false;
                if (!masterSettings.EnableCommission)                    //未启用三级返佣
                {
                    if (userIdDistributors.ReferralStatus == 0)          //状态正常
                    {
                        flag = setCommission(order, userIdDistributors); //设置分销商佣金(仅更新直接销售的分销商返佣)
                    }
                }
                else//启用了三级返佣
                {
                    if (userIdDistributors.ReferralStatus == 0)
                    {
                        flag = setCommission(order, userIdDistributors);//更新直接销售的分销商返佣
                    }
                    if (!string.IsNullOrEmpty(userIdDistributors.ReferralPath))
                    {
                        ArrayList commTatalList  = new ArrayList();
                        decimal   num            = 0M;
                        ArrayList userIdList     = new ArrayList();
                        string    referralUserId = order.ReferralUserId.ToString();
                        string    orderId        = order.OrderId;
                        ArrayList orderTotalList = new ArrayList();
                        decimal   num2           = 0M;
                        ArrayList gradeIdList    = new ArrayList();
                        string[]  strArray       = userIdDistributors.ReferralPath.Split(new char[] { '|' });
                        if (strArray.Length == 1)
                        {
                            #region  一级返佣
                            DistributorsInfo info2 = GetUserIdDistributors(int.Parse(strArray[0]));
                            isAgent2 = (info2.IsAgent == 1) ? true : false;
                            if (info2.ReferralStatus == 0)
                            {
                                foreach (LineItemInfo info3 in order.LineItems.Values)
                                {
                                    if (info3.OrderItemsStatus.ToString() == OrderStatus.SellerAlreadySent.ToString())
                                    {
                                        num  += info3.SecondItemsCommission;
                                        num2 += info3.GetSubTotal();
                                    }
                                }
                                commTatalList.Add(num);
                                orderTotalList.Add(num2);
                                userIdList.Add(info2.UserId);
                            }
                            #endregion  一级返佣
                        }
                        if (strArray.Length == 2)
                        {
                            #region  一级、上二级返佣
                            DistributorsInfo info4 = GetUserIdDistributors(int.Parse(strArray[0]));
                            isAgent3 = (info4.IsAgent == 1) ? true : false;
                            if (info4.ReferralStatus == 0)
                            {
                                foreach (LineItemInfo info3 in order.LineItems.Values)
                                {
                                    if (info3.OrderItemsStatus.ToString() == OrderStatus.SellerAlreadySent.ToString())
                                    {
                                        num  += info3.ThirdItemsCommission;
                                        num2 += info3.GetSubTotal();
                                    }
                                }
                                commTatalList.Add(num);
                                orderTotalList.Add(num2);
                                userIdList.Add(info4.UserId);
                            }
                            DistributorsInfo info5 = GetUserIdDistributors(int.Parse(strArray[1]));
                            isAgent2 = (info5.IsAgent == 1) ? true : false;
                            num      = 0M;
                            num2     = 0M;
                            if (info5.ReferralStatus == 0)
                            {
                                foreach (LineItemInfo info3 in order.LineItems.Values)
                                {
                                    if (info3.OrderItemsStatus.ToString() == OrderStatus.SellerAlreadySent.ToString())
                                    {
                                        num  += info3.SecondItemsCommission;
                                        num2 += info3.GetSubTotal();
                                    }
                                }
                                commTatalList.Add(num);
                                orderTotalList.Add(num2);
                                userIdList.Add(info5.UserId);
                            }
                            #endregion  一级、上二级返佣

                            //三级向上存在代理时进行设置
                            if (!string.IsNullOrEmpty(info4.AgentPath))
                            {
                                System.Data.DataView defaultViewAgent = DistributorGradeBrower.GetAllAgentGrade().DefaultView;      //当前系统中所有代理商等级
                                #region 设置无限代理返佣

                                string[] arrayAgentPath = info4.AgentPath.Split(new char[] { '|' });
                                foreach (string strAgentPat in arrayAgentPath)
                                {
                                    DistributorsInfo infoAgent = GetUserIdDistributors(int.Parse(strAgentPat));
                                    if (infoAgent.IsAgent != 1 || infoAgent.ReferralStatus == 1)
                                    {
                                        continue;
                                    }
                                    defaultViewAgent.RowFilter = " AgentGradeId=" + infoAgent.AgentGradeId;
                                    if (defaultViewAgent.Count == 0)
                                    {
                                        continue;
                                    }
                                    num  = 0M;
                                    num2 = 0M;
                                    foreach (LineItemInfo info in order.LineItems.Values)
                                    {
                                        if (info.OrderItemsStatus.ToString() == OrderStatus.SellerAlreadySent.ToString())
                                        {
                                            if (!SettingsManager.GetMasterSettings(false).EnableProfit)
                                            {
                                                num += decimal.Parse(defaultViewAgent[0]["FirstCommissionRise"].ToString()) / 100m * info.GetSubTotal();
                                            }
                                            else
                                            {
                                                num += decimal.Parse(defaultViewAgent[0]["FirstCommissionRise"].ToString()) / 100m * info.GetSubTotalProfit();
                                            }

                                            num2 += info.GetSubTotal();
                                        }
                                    }
                                    commTatalList.Add(num);
                                    orderTotalList.Add(num2);
                                    userIdList.Add(infoAgent.UserId);
                                }

                                #endregion 设置无限代理返佣
                            }
                        }

                        //点睛教育:收到佣金的同时,收到5/100的积分


                        flag = new DistributorsDao().UpdateTwoCalculationCommission(userIdList, referralUserId, orderId, orderTotalList, commTatalList);
                        for (int i = 0; i < userIdList.Count; i++)
                        {
                            int notDescDistributorGrades = GetNotDescDistributorGrades(userIdList[i].ToString());
                            gradeIdList.Add(notDescDistributorGrades);
                        }
                        flag = new DistributorsDao().UpdateGradeId(gradeIdList, userIdList);
                    }
                }
                RemoveDistributorCache(userIdDistributors.UserId);
            }


            //额外10%的比例给服务门店
            if (order.RedPagerID > 0)    //如果选中了门店
            {
                #region 迪蔓门店服务费10%
                ArrayList commTatalList  = new ArrayList();
                ArrayList userIdList     = new ArrayList();
                string    referralUserId = order.ReferralUserId.ToString();
                string    orderId        = order.OrderId;
                ArrayList orderTotalList = new ArrayList();
                decimal   num            = 0M;
                decimal   num2           = 0M;
                foreach (LineItemInfo info in order.LineItems.Values)
                {
                    if (info.OrderItemsStatus.ToString() == OrderStatus.SellerAlreadySent.ToString())
                    {
                        if (!SettingsManager.GetMasterSettings(false).EnableProfit)
                        {
                            num += decimal.Parse("10") / 100m * info.GetSubTotal();
                        }
                        else
                        {
                            num += decimal.Parse("10") / 100m * info.GetSubTotalProfit();
                        }

                        num2 += info.GetSubTotal();
                    }
                }
                commTatalList.Add(num);
                orderTotalList.Add(num2);
                userIdList.Add(order.RedPagerID);
                flag = new DistributorsDao().UpdateTwoCalculationCommission(userIdList, referralUserId, orderId, orderTotalList, commTatalList);
                #endregion
            }


            OrderRedPagerBrower.CreateOrderRedPager(order.OrderId, order.GetTotal(), order.UserId);
            return(flag);
        }
Пример #3
0
        /// <summary>
        /// jinhb,20150820,更新三级返佣金额,加入了无限代理佣金算法
        /// </summary>
        public static bool UpdateCalculationCommission(OrderInfo order)
        {
            DistributorsInfo userIdDistributors = GetUserIdDistributors(order.ReferralUserId);

            SiteSettings masterSettings = SettingsManager.GetMasterSettings(false);
            bool         flag           = false;

            if (userIdDistributors != null)
            {
                bool isAgent1 = (userIdDistributors.IsAgent == 1) ? true : false;
                bool isAgent2 = false;
                bool isAgent3 = false;
                if (!masterSettings.EnableCommission)                    //未启用三级返佣
                {
                    if (userIdDistributors.ReferralStatus == 0)          //状态正常
                    {
                        flag = setCommission(order, userIdDistributors); //设置分销商佣金(仅更新直接销售的分销商返佣)
                    }
                }
                else//启用了三级返佣
                {
                    if (userIdDistributors.ReferralStatus == 0)
                    {
                        flag = setCommission(order, userIdDistributors);//更新直接销售的分销商返佣
                    }
                    if (!string.IsNullOrEmpty(userIdDistributors.ReferralPath))
                    {
                        ArrayList commTatalList  = new ArrayList();
                        decimal   num            = 0M;
                        ArrayList userIdList     = new ArrayList();
                        string    referralUserId = order.ReferralUserId.ToString();
                        string    orderId        = order.OrderId;
                        ArrayList orderTotalList = new ArrayList();
                        decimal   num2           = 0M;
                        ArrayList gradeIdList    = new ArrayList();
                        string[]  strArray       = userIdDistributors.ReferralPath.Split(new char[] { '|' });
                        if (strArray.Length == 1)
                        {
                            #region  一级返佣
                            DistributorsInfo info2 = GetUserIdDistributors(int.Parse(strArray[0]));
                            isAgent2 = (info2.IsAgent == 1) ? true : false;
                            if (info2.ReferralStatus == 0)
                            {
                                foreach (LineItemInfo info3 in order.LineItems.Values)
                                {
                                    if (info3.OrderItemsStatus.ToString() == OrderStatus.SellerAlreadySent.ToString())
                                    {
                                        num  += info3.SecondItemsCommission;
                                        num2 += info3.GetSubTotal();
                                    }
                                }
                                commTatalList.Add(num);
                                orderTotalList.Add(num2);
                                userIdList.Add(info2.UserId);
                            }
                            #endregion  一级返佣
                        }
                        if (strArray.Length == 2)
                        {
                            #region  一级、上二级返佣
                            DistributorsInfo info4 = GetUserIdDistributors(int.Parse(strArray[0]));
                            isAgent3 = (info4.IsAgent == 1) ? true : false;
                            if (info4.ReferralStatus == 0)
                            {
                                foreach (LineItemInfo info3 in order.LineItems.Values)
                                {
                                    if (info3.OrderItemsStatus.ToString() == OrderStatus.SellerAlreadySent.ToString())
                                    {
                                        num  += info3.ThirdItemsCommission;
                                        num2 += info3.GetSubTotal();
                                    }
                                }
                                commTatalList.Add(num);
                                orderTotalList.Add(num2);
                                userIdList.Add(info4.UserId);
                            }
                            DistributorsInfo info5 = GetUserIdDistributors(int.Parse(strArray[1]));
                            isAgent2 = (info5.IsAgent == 1) ? true : false;
                            num      = 0M;
                            num2     = 0M;
                            if (info5.ReferralStatus == 0)
                            {
                                foreach (LineItemInfo info3 in order.LineItems.Values)
                                {
                                    if (info3.OrderItemsStatus.ToString() == OrderStatus.SellerAlreadySent.ToString())
                                    {
                                        num  += info3.SecondItemsCommission;
                                        num2 += info3.GetSubTotal();
                                    }
                                }
                                commTatalList.Add(num);
                                orderTotalList.Add(num2);
                                userIdList.Add(info5.UserId);
                            }
                            #endregion  一级、上二级返佣

                            //三级向上存在代理时进行设置
                            if (!string.IsNullOrEmpty(info4.AgentPath) && CustomConfigHelper.Instance.SelectServerAgent == false)
                            {
                                /*20160424,by 迪蔓。后期服务门店类时可通用
                                 * 1.消费者购买时可选择服务门店(天使,下拉框列表)
                                 * 1.1如果服务门店选择无,则按正常三级返佣(三级之外的不参与返佣,如无限级代理)
                                 * 1.2如果选择了服务门店,正常三级返佣不变(同1.1规则),额外10%的比例给服务门店(同时支持天使的返佣)
                                 * 1.3店铺订单,列表中额外查出服务订单
                                 */

                                System.Data.DataView defaultViewAgent = DistributorGradeBrower.GetAllAgentGrade().DefaultView;      //当前系统中所有代理商等级
                                #region 设置无限代理返佣

                                string[] arrayAgentPath = info4.AgentPath.Split(new char[] { '|' });
                                foreach (string strAgentPat in arrayAgentPath)
                                {
                                    DistributorsInfo infoAgent = GetUserIdDistributors(int.Parse(strAgentPat));
                                    if (infoAgent.IsAgent != 1 || infoAgent.ReferralStatus == 1)
                                    {
                                        continue;
                                    }
                                    defaultViewAgent.RowFilter = " AgentGradeId=" + infoAgent.AgentGradeId;
                                    if (defaultViewAgent.Count == 0)
                                    {
                                        continue;
                                    }
                                    num  = 0M;
                                    num2 = 0M;
                                    foreach (LineItemInfo info in order.LineItems.Values)
                                    {
                                        if (info.OrderItemsStatus.ToString() == OrderStatus.SellerAlreadySent.ToString())
                                        {
                                            if (!SettingsManager.GetMasterSettings(false).EnableProfit)
                                            {
                                                num += decimal.Parse(defaultViewAgent[0]["FirstCommissionRise"].ToString()) / 100m * info.GetSubTotal();
                                            }
                                            else
                                            {
                                                num += decimal.Parse(defaultViewAgent[0]["FirstCommissionRise"].ToString()) / 100m * info.GetSubTotalProfit();
                                            }

                                            num2 += info.GetSubTotal();
                                        }
                                    }
                                    commTatalList.Add(num);
                                    orderTotalList.Add(num2);
                                    userIdList.Add(infoAgent.UserId);

                                    //齐品汇的代理商特殊返佣算法,此处为代理商在三级分佣之外时的情况:实际返佣=商品售价-出货折扣-三级返佣
                                    if (CustomConfigHelper.Instance.IsQipinhui)
                                    {
                                        decimal num_new = 0m;
                                        foreach (LineItemInfo info in order.LineItems.Values)
                                        {
                                            if (info.OrderItemsStatus.ToString() == OrderStatus.SellerAlreadySent.ToString())
                                            {
                                                int    categoryId  = int.Parse(info.MainCategoryPath.TrimEnd('|')); //分类id
                                                string specialName = "";                                            //当前代理商的名字
                                                specialName = DistributorGradeBrower.GetAgentGradeInfo(infoAgent.AgentGradeId).AgentGradeName;

                                                //通过分类id和代理商名字获取特殊的分佣比例
                                                decimal currentRate     = Convert.ToDecimal(CatalogHelper.GetSpecialCategoryRent(categoryId, specialName));
                                                string  noCommOpenids   = CustomConfigHelper.Instance.NoCommOpenids != "" ? CustomConfigHelper.Instance.NoCommOpenids.ToLower() : "";      //先获取不参加返佣的4个openid
                                                decimal currentSubTotal = CatalogHelper.isSpecialRateExist(categoryId) ? info.GetSubTotal() * currentRate : info.GetSubTotalByCostPrice(); //根据当前分类id判断当前是用特殊比例计算还是使用成本价计算

                                                if (infoAgent.OpenId != null && noCommOpenids.IndexOf(infoAgent.OpenId.ToLower()) >= 0)
                                                {
                                                    num_new = 0;
                                                }
                                                else
                                                {
                                                    num_new = info.GetSubTotal() - currentSubTotal - (info.ItemsCommission + info.SecondItemsCommission + info.ThirdItemsCommission);
                                                }

                                                /*if (infoAgent.OpenId != null)
                                                 *  num_new = noCommOpenids.IndexOf(infoAgent.OpenId.ToLower()) >= 0 ? 0 : (info.GetSubTotal() - currentSubTotal - (info.ItemsCommission + info.SecondItemsCommission + info.ThirdItemsCommission));
                                                 * else
                                                 * {
                                                 *  num_new = info.GetSubTotal() - currentSubTotal - (info.ItemsCommission + info.SecondItemsCommission + info.ThirdItemsCommission);
                                                 * }
                                                 */
                                            }
                                        }


                                        commTatalList[commTatalList.Count - 1] = num_new;
                                        break;
                                    }
                                }

                                #endregion 设置无限代理返佣
                            }

                            #region 迪蔓,只返一次无限级
                            if (CustomConfigHelper.Instance.SelectServerAgent)
                            {
                                if (isAgent1 == false && isAgent2 == false && isAgent3 == false)
                                {
                                    //三级之外存在店铺时,向上找最近的代理商
                                    while (!string.IsNullOrEmpty(info4.ReferralPath))
                                    {
                                        string[] arrayReferralPath = info4.ReferralPath.Split(new char[] { '|' });
                                        info4 = GetUserIdDistributors(int.Parse(arrayReferralPath[arrayReferralPath.Length - 1]));
                                        if (info4.IsAgent == 1)
                                        {
                                            System.Data.DataView defaultViewAgent = DistributorGradeBrower.GetAllAgentGrade().DefaultView;  //当前系统中所有代理商等级
                                            defaultViewAgent.RowFilter = " AgentGradeId=" + info4.AgentGradeId;
                                            if (defaultViewAgent.Count == 0)
                                            {
                                                break;
                                            }
                                            num  = 0M;
                                            num2 = 0M;
                                            foreach (LineItemInfo info in order.LineItems.Values)
                                            {
                                                if (info.OrderItemsStatus.ToString() == OrderStatus.SellerAlreadySent.ToString())
                                                {
                                                    if (!SettingsManager.GetMasterSettings(false).EnableProfit)
                                                    {
                                                        num += decimal.Parse(defaultViewAgent[0]["FirstCommissionRise"].ToString()) / 100m * info.GetSubTotal();
                                                    }
                                                    else
                                                    {
                                                        num += decimal.Parse(defaultViewAgent[0]["FirstCommissionRise"].ToString()) / 100m * info.GetSubTotalProfit();
                                                    }

                                                    num2 += info.GetSubTotal();
                                                }
                                            }
                                            commTatalList.Add(num);
                                            orderTotalList.Add(num2);
                                            userIdList.Add(info4.UserId);//添加无限级代理商佣金
                                            break;
                                        }
                                    }
                                }
                            }
                            #endregion
                        }
                        #region 51跟单特殊处理,如果是分销商在自己店铺购买商品,三级佣金往上推一层(直接佣金为0推至第四级佣金)
                        if (CustomConfigHelper.Instance.Is51gendan && order.UserId == order.ReferralUserId)
                        {
                            commTatalList  = new ArrayList();
                            userIdList     = new ArrayList();
                            orderTotalList = new ArrayList();
                            num            = 0m; num2 = 0m;
                            //获取第四级分销商id
                            string[]         strArrayNew = userIdDistributors.ReferralPath.Split(new char[] { '|' });
                            DistributorsInfo user4       = new DistributorsInfo();
                            if (strArrayNew.Length == 2)
                            {
                                user4 = GetUserIdDistributors(GetUserIdDistributors(strArrayNew[0].ToInt()).ReferralUserId);//第四级的分销商为当前分销商的第三级的上一级分销商
                            }


                            //一级返佣为0
                            DistributorsInfo user1 = GetUserIdDistributors(order.ReferralUserId);
                            if (user1.ReferralStatus == 0)
                            {
                                foreach (LineItemInfo item1 in order.LineItems.Values)
                                {
                                    if (item1.OrderItemsStatus.ToString() == OrderStatus.SellerAlreadySent.ToString())
                                    {
                                        num  += 0;//一级不加返佣
                                        num2 += item1.GetSubTotal();
                                    }
                                }
                                commTatalList.Add(num); num    = 0m;
                                orderTotalList.Add(num2); num2 = 0m;
                                userIdList.Add(user1.UserId);
                            }
                            //一共有二级的返佣处理
                            if (strArrayNew.Length == 1)
                            {
                                DistributorsInfo user2 = GetUserIdDistributors(int.Parse(strArray[0]));
                                if (user2.ReferralStatus == 0)
                                {
                                    foreach (LineItemInfo item2 in order.LineItems.Values)
                                    {
                                        if (item2.OrderItemsStatus.ToString() == OrderStatus.SellerAlreadySent.ToString())
                                        {
                                            num  += item2.ItemsCommission;
                                            num2 += item2.GetSubTotal();
                                        }
                                    }
                                    commTatalList.Add(num);
                                    orderTotalList.Add(num2);
                                    userIdList.Add(user2.UserId);
                                }
                            }
                            //一共有三级的返佣处理
                            if (strArray.Length == 2)
                            {
                                DistributorsInfo user2 = GetUserIdDistributors(int.Parse(strArrayNew[0]));
                                if (user2.ReferralStatus == 0)
                                {
                                    foreach (LineItemInfo item2 in order.LineItems.Values)
                                    {
                                        if (item2.OrderItemsStatus.ToString() == OrderStatus.SellerAlreadySent.ToString())
                                        {
                                            num  += item2.SecondItemsCommission;
                                            num2 += item2.GetSubTotal();
                                        }
                                    }
                                    commTatalList.Add(num); num    = 0M;
                                    orderTotalList.Add(num2); num2 = 0M;
                                    userIdList.Add(user2.UserId);
                                }
                                DistributorsInfo user3 = GetUserIdDistributors(int.Parse(strArrayNew[1]));
                                if (user3.ReferralStatus == 0)
                                {
                                    foreach (LineItemInfo item3 in order.LineItems.Values)
                                    {
                                        if (item3.OrderItemsStatus.ToString() == OrderStatus.SellerAlreadySent.ToString())
                                        {
                                            num  += item3.ItemsCommission;
                                            num2 += item3.GetSubTotal();
                                        }
                                    }
                                    commTatalList.Add(num); num    = 0m;
                                    orderTotalList.Add(num2); num2 = 0m;
                                    userIdList.Add(user3.UserId);
                                }
                            }
                            //四级返佣
                            if (user4 != null && user4.ReferralStatus == 0)
                            {
                                foreach (LineItemInfo item4 in order.LineItems.Values)
                                {
                                    if (item4.OrderItemsStatus.ToString() == OrderStatus.SellerAlreadySent.ToString())
                                    {
                                        num  += item4.ThirdItemsCommission;
                                        num2 += item4.GetSubTotal();
                                    }
                                }
                                commTatalList.Add(num);
                                orderTotalList.Add(num2);
                                userIdList.Add(user4.UserId);
                            }
                        }
                        #endregion

                        flag = new DistributorsDao().UpdateTwoCalculationCommission(userIdList, referralUserId, orderId, orderTotalList, commTatalList);
                        for (int i = 0; i < userIdList.Count; i++)
                        {
                            int notDescDistributorGrades = GetNotDescDistributorGrades(userIdList[i].ToString());
                            gradeIdList.Add(notDescDistributorGrades);
                        }
                        flag = new DistributorsDao().UpdateGradeId(gradeIdList, userIdList);
                    }
                }
                RemoveDistributorCache(userIdDistributors.UserId);
            }


            //额外10%的比例给服务门店
            if (order.RedPagerID > 0)    //如果选中了门店
            {
                #region 迪蔓门店服务费10%
                ArrayList commTatalList  = new ArrayList();
                ArrayList userIdList     = new ArrayList();
                string    referralUserId = order.ReferralUserId.ToString();
                string    orderId        = order.OrderId;
                ArrayList orderTotalList = new ArrayList();
                decimal   num            = 0M;
                decimal   num2           = 0M;
                foreach (LineItemInfo info in order.LineItems.Values)
                {
                    if (info.OrderItemsStatus.ToString() == OrderStatus.SellerAlreadySent.ToString())
                    {
                        if (!SettingsManager.GetMasterSettings(false).EnableProfit)
                        {
                            num += decimal.Parse("10") / 100m * info.GetSubTotal();
                        }
                        else
                        {
                            num += decimal.Parse("10") / 100m * info.GetSubTotalProfit();
                        }

                        num2 += info.GetSubTotal();
                    }
                }
                commTatalList.Add(num);
                orderTotalList.Add(num2);
                userIdList.Add(order.RedPagerID);
                flag = new DistributorsDao().UpdateTwoCalculationCommission(userIdList, referralUserId, orderId, orderTotalList, commTatalList);
                #endregion
            }


            OrderRedPagerBrower.CreateOrderRedPager(order.OrderId, order.GetTotal(), order.UserId);
            return(flag);
        }
Пример #4
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);
        }
Пример #5
0
        public static bool UpdateCalculationCommission(OrderInfo order)
        {
            Exception exception;

            new MemberDao().SetOrderDate(order.UserId, 2);
            DistributorsInfo userIdDistributors = GetUserIdDistributors(order.ReferralUserId);
            SiteSettings     masterSettings     = SettingsManager.GetMasterSettings(false);
            bool             flag = false;

            if (userIdDistributors != null)
            {
                flag = setCommission(order, userIdDistributors);
                if (!string.IsNullOrEmpty(order.ReferralPath))
                {
                    string    userOpenIdByUserId;
                    string    aliUserOpenIdByUserId;
                    int       notDescDistributorGrades;
                    ArrayList commTatalList  = new ArrayList();
                    decimal   num            = 0M;
                    ArrayList userIdList     = new ArrayList();
                    string    referralUserId = order.ReferralUserId.ToString();
                    string    orderId        = order.OrderId;
                    ArrayList orderTotalList = new ArrayList();
                    decimal   num2           = 0M;
                    ArrayList gradeIdList    = new ArrayList();
                    string[]  strArray       = order.ReferralPath.Split(new char[] { '|' });
                    if (strArray.Length == 1)
                    {
                        DistributorsInfo distributor = GetUserIdDistributors(int.Parse(strArray[0]));
                        if (distributor != null)
                        {
                            foreach (LineItemInfo info3 in order.LineItems.Values)
                            {
                                if (info3.OrderItemsStatus.ToString() == OrderStatus.SellerAlreadySent.ToString())
                                {
                                    num  += info3.SecondItemsCommission;
                                    num2 += info3.GetSubTotal();
                                }
                            }
                            commTatalList.Add(num);
                            orderTotalList.Add(num2 + order.AdjustedFreight);
                            userIdList.Add(distributor.UserId);
                            try
                            {
                                if ((order != null) && (num > 0M))
                                {
                                    userOpenIdByUserId    = MemberProcessor.GetUserOpenIdByUserId(distributor.UserId);
                                    aliUserOpenIdByUserId = MemberProcessor.GetAliUserOpenIdByUserId(distributor.UserId);
                                    Messenger.SendWeiXinMsg_OrderGetCommission(order, userOpenIdByUserId, aliUserOpenIdByUserId, num);
                                }
                            }
                            catch (Exception exception1)
                            {
                                exception = exception1;
                            }
                            notDescDistributorGrades = GetNotDescDistributorGrades(distributor.UserId.ToString());
                            if (distributor.DistriGradeId != notDescDistributorGrades)
                            {
                                DistributorGradeChange(distributor, order.OrderId, notDescDistributorGrades);
                            }
                        }
                    }
                    if (strArray.Length == 2)
                    {
                        DistributorsInfo info4 = GetUserIdDistributors(int.Parse(strArray[0]));
                        foreach (LineItemInfo info3 in order.LineItems.Values)
                        {
                            if (info3.OrderItemsStatus.ToString() == OrderStatus.SellerAlreadySent.ToString())
                            {
                                num  += info3.ThirdItemsCommission;
                                num2 += info3.GetSubTotal();
                            }
                        }
                        commTatalList.Add(num);
                        orderTotalList.Add(num2 + order.AdjustedFreight);
                        userIdList.Add(info4.UserId);
                        try
                        {
                            if ((order != null) && (num > 0M))
                            {
                                userOpenIdByUserId    = MemberProcessor.GetUserOpenIdByUserId(info4.UserId);
                                aliUserOpenIdByUserId = MemberProcessor.GetAliUserOpenIdByUserId(info4.UserId);
                                Messenger.SendWeiXinMsg_OrderGetCommission(order, userOpenIdByUserId, aliUserOpenIdByUserId, num);
                            }
                        }
                        catch (Exception exception2)
                        {
                            exception = exception2;
                        }
                        notDescDistributorGrades = GetNotDescDistributorGrades(info4.UserId.ToString());
                        if (info4.DistriGradeId != notDescDistributorGrades)
                        {
                            DistributorGradeChange(info4, order.OrderId, notDescDistributorGrades);
                        }
                        DistributorsInfo info5 = GetUserIdDistributors(int.Parse(strArray[1]));
                        num  = 0M;
                        num2 = 0M;
                        foreach (LineItemInfo info3 in order.LineItems.Values)
                        {
                            if (info3.OrderItemsStatus.ToString() == OrderStatus.SellerAlreadySent.ToString())
                            {
                                num  += info3.SecondItemsCommission;
                                num2 += info3.GetSubTotal();
                            }
                        }
                        commTatalList.Add(num);
                        orderTotalList.Add(num2 + order.AdjustedFreight);
                        userIdList.Add(info5.UserId);
                        try
                        {
                            if ((order != null) && (num > 0M))
                            {
                                userOpenIdByUserId    = MemberProcessor.GetUserOpenIdByUserId(info5.UserId);
                                aliUserOpenIdByUserId = MemberProcessor.GetAliUserOpenIdByUserId(info5.UserId);
                                Messenger.SendWeiXinMsg_OrderGetCommission(order, userOpenIdByUserId, aliUserOpenIdByUserId, num);
                            }
                        }
                        catch (Exception exception3)
                        {
                            exception = exception3;
                        }
                        int newDistributorGradeid = GetNotDescDistributorGrades(info5.UserId.ToString());
                        if (info5.DistriGradeId != newDistributorGradeid)
                        {
                            DistributorGradeChange(info5, order.OrderId, newDistributorGradeid);
                        }
                    }
                    flag = new DistributorsDao().UpdateTwoCalculationCommission(userIdList, referralUserId, orderId, orderTotalList, commTatalList);
                    for (int i = 0; i < userIdList.Count; i++)
                    {
                        int num6 = GetNotDescDistributorGrades(userIdList[i].ToString());
                        gradeIdList.Add(num6);
                    }
                    flag = new DistributorsDao().UpdateGradeId(gradeIdList, userIdList);
                }
                RemoveDistributorCache(userIdDistributors.UserId);
            }
            OrderRedPagerBrower.CreateOrderRedPager(order.OrderId, order.GetTotal(), order.UserId);
            int id = Globals.IsNumeric(order.ActivitiesId) ? Globals.ToNum(order.ActivitiesId) : 0;

            if (id > 0)
            {
                ActivityDetailInfo activityDetailInfo = new Hidistro.SqlDal.VShop.ActivityDao().GetActivityDetailInfo(id);
                if (activityDetailInfo != null)
                {
                    OrderInfo info8;
                    int       couponId = activityDetailInfo.CouponId;
                    int       integral = activityDetailInfo.Integral;
                    if ((couponId > 0) && (ShoppingProcessor.GetCoupon(couponId.ToString()) != null))
                    {
                        SendCouponResult result = new CouponDao().SendCouponToMember(couponId, order.UserId);
                        try
                        {
                            info8 = order;
                            if (info8 != null)
                            {
                                Messenger.SendWeiXinMsg_OrderGetCoupon(info8);
                            }
                        }
                        catch (Exception exception4)
                        {
                            exception = exception4;
                        }
                    }
                    if (integral > 0)
                    {
                        new OrderDao().AddMemberPointNumber(integral, order, null);
                        try
                        {
                            info8 = order;
                            if (info8 != null)
                            {
                                Messenger.SendWeiXinMsg_OrderGetPoint(info8, integral);
                            }
                        }
                        catch (Exception exception5)
                        {
                            exception = exception5;
                        }
                    }
                }
            }
            MemberProcessor.UpdateUserAccount(order);
            try
            {
                string   retInfo   = "";
                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 flag2 = new ShopStatisticDao().StatisticsOrdersByRecDate(payDate.Value, UpdateAction.AllUpdate, 0, out retInfo);
                }
            }
            catch
            {
            }
            return(flag);
        }
        public static bool UpdateCalculationCommission(OrderInfo order)
        {
            new MemberDao().SetOrderDate(order.UserId, 2);
            DistributorsInfo userIdDistributors = GetUserIdDistributors(order.ReferralUserId);
            SiteSettings     masterSettings     = SettingsManager.GetMasterSettings(false);
            bool             flag = false;

            if (userIdDistributors != null)
            {
                flag = setCommission(order, userIdDistributors, masterSettings);
                if (!string.IsNullOrEmpty(order.ReferralPath))
                {
                    ArrayList commTatalList  = new ArrayList();
                    decimal   num            = 0M;
                    ArrayList userIdList     = new ArrayList();
                    string    referralUserId = order.ReferralUserId.ToString();
                    string    orderId        = order.OrderId;
                    ArrayList orderTotalList = new ArrayList();
                    decimal   num2           = 0M;
                    ArrayList gradeIdList    = new ArrayList();
                    string[]  strArray       = order.ReferralPath.Split(new char[] { '|' });
                    if (strArray.Length == 1)
                    {
                        DistributorsInfo distributor = GetUserIdDistributors(int.Parse(strArray[0]));
                        if (distributor != null)
                        {
                            foreach (LineItemInfo info3 in order.LineItems.Values)
                            {
                                if (info3.OrderItemsStatus.ToString() == OrderStatus.SellerAlreadySent.ToString())
                                {
                                    num  += Math.Round(info3.SecondItemsCommission, 2);
                                    num2 += info3.GetSubTotal();
                                }
                            }
                            commTatalList.Add(num);
                            orderTotalList.Add(num2);
                            userIdList.Add(distributor.UserId);
                            try
                            {
                                if ((order != null) && (num > 0M))
                                {
                                    string userOpenIdByUserId    = MemberProcessor.GetUserOpenIdByUserId(distributor.UserId);
                                    string aliUserOpenIdByUserId = MemberProcessor.GetAliUserOpenIdByUserId(distributor.UserId);
                                    Messenger.SendWeiXinMsg_OrderGetCommission(order, userOpenIdByUserId, aliUserOpenIdByUserId, num);
                                }
                            }
                            catch (Exception)
                            {
                            }
                            int notDescDistributorGrades = GetNotDescDistributorGrades(distributor.UserId.ToString());
                            if (distributor.DistriGradeId != notDescDistributorGrades)
                            {
                                DistributorGradeChange(distributor, order.OrderId, notDescDistributorGrades, true);
                            }
                        }
                    }
                    if (strArray.Length == 2)
                    {
                        DistributorsInfo info4 = GetUserIdDistributors(int.Parse(strArray[0]));
                        foreach (LineItemInfo info5 in order.LineItems.Values)
                        {
                            if (info5.OrderItemsStatus.ToString() == OrderStatus.SellerAlreadySent.ToString())
                            {
                                num  += Math.Round(info5.ThirdItemsCommission, 2);
                                num2 += info5.GetSubTotal();
                            }
                        }
                        commTatalList.Add(num);
                        orderTotalList.Add(num2);
                        userIdList.Add(info4.UserId);
                        try
                        {
                            if ((order != null) && (num > 0M))
                            {
                                string wxOpenId  = MemberProcessor.GetUserOpenIdByUserId(info4.UserId);
                                string aliOpneid = MemberProcessor.GetAliUserOpenIdByUserId(info4.UserId);
                                Messenger.SendWeiXinMsg_OrderGetCommission(order, wxOpenId, aliOpneid, num);
                            }
                        }
                        catch (Exception)
                        {
                        }
                        int newDistributorGradeid = GetNotDescDistributorGrades(info4.UserId.ToString());
                        if (info4.DistriGradeId != newDistributorGradeid)
                        {
                            DistributorGradeChange(info4, order.OrderId, newDistributorGradeid, true);
                        }
                        DistributorsInfo info6 = GetUserIdDistributors(int.Parse(strArray[1]));
                        num  = 0M;
                        num2 = 0M;
                        foreach (LineItemInfo info7 in order.LineItems.Values)
                        {
                            if (info7.OrderItemsStatus.ToString() == OrderStatus.SellerAlreadySent.ToString())
                            {
                                num  += Math.Round(info7.SecondItemsCommission, 2);
                                num2 += info7.GetSubTotal();
                            }
                        }
                        commTatalList.Add(num);
                        orderTotalList.Add(num2);
                        userIdList.Add(info6.UserId);
                        try
                        {
                            if ((order != null) && (num > 0M))
                            {
                                string str7 = MemberProcessor.GetUserOpenIdByUserId(info6.UserId);
                                string str8 = MemberProcessor.GetAliUserOpenIdByUserId(info6.UserId);
                                Messenger.SendWeiXinMsg_OrderGetCommission(order, str7, str8, num);
                            }
                        }
                        catch (Exception)
                        {
                        }
                        int num5 = GetNotDescDistributorGrades(info6.UserId.ToString());
                        if (info6.DistriGradeId != num5)
                        {
                            DistributorGradeChange(info6, order.OrderId, num5, true);
                        }
                    }
                    if (new DistributorsDao().UpdateTwoCalculationCommission(userIdList, referralUserId, orderId, orderTotalList, commTatalList))
                    {
                        for (int j = 0; j < userIdList.Count; j++)
                        {
                            CommissionAutoToBalance(Globals.ToNum(userIdList[j]), masterSettings, decimal.Parse(commTatalList[j].ToString()));
                        }
                    }
                    for (int i = 0; i < userIdList.Count; i++)
                    {
                        int num8 = GetNotDescDistributorGrades(userIdList[i].ToString());
                        gradeIdList.Add(num8);
                    }
                    flag = new DistributorsDao().UpdateGradeId(gradeIdList, userIdList);
                }
                RemoveDistributorCache(userIdDistributors.UserId);
            }
            OrderRedPagerBrower.CreateOrderRedPager(order.OrderId, order.GetTotal(), order.UserId);
            string[] strArray2 = !string.IsNullOrEmpty(order.ActivitiesId) ? order.ActivitiesId.Split(new char[] { ',' }) : null;
            if ((strArray2 != null) && (strArray2.Length > 0))
            {
                int pointNumber = 0;
                foreach (string str9 in strArray2)
                {
                    int id = Globals.IsNumeric(str9) ? Globals.ToNum(str9) : 0;
                    if (id > 0)
                    {
                        ActivityDetailInfo activityDetailInfo = new Hidistro.SqlDal.VShop.ActivityDao().GetActivityDetailInfo(id);
                        if (activityDetailInfo != null)
                        {
                            int couponId = activityDetailInfo.CouponId;
                            pointNumber += activityDetailInfo.Integral;
                            if ((couponId > 0) && (ShoppingProcessor.GetCoupon(couponId.ToString()) != null))
                            {
                                new CouponDao().SendCouponToMember(couponId, order.UserId);
                                try
                                {
                                    OrderInfo info10 = order;
                                    if (info10 != null)
                                    {
                                        Messenger.SendWeiXinMsg_OrderGetCoupon(info10);
                                    }
                                }
                                catch (Exception)
                                {
                                }
                            }
                        }
                    }
                }
                if (pointNumber > 0)
                {
                    new OrderDao().AddMemberPointNumber(pointNumber, order, null);
                    try
                    {
                        OrderInfo info11 = order;
                        if (info11 != null)
                        {
                            Messenger.SendWeiXinMsg_OrderGetPoint(info11, pointNumber);
                        }
                    }
                    catch (Exception)
                    {
                    }
                }
            }
            MemberProcessor.UpdateUserAccount(order);
            try
            {
                string   retInfo   = "";
                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")))
                {
                    new ShopStatisticDao().StatisticsOrdersByRecDate(payDate.Value, UpdateAction.AllUpdate, 0, out retInfo);
                }
            }
            catch
            {
            }
            return(flag);
        }