Ejemplo n.º 1
0
        public static void DistributorGradeChange(DistributorsInfo distributor, string orderid, int newDistributorGradeid)
        {
            DistributorGradeInfo distributorGradeInfo = DistributorGradeBrower.GetDistributorGradeInfo(newDistributorGradeid);

            if (distributorGradeInfo != null && distributorGradeInfo.AddCommission > 0m)
            {
                try
                {
                    MemberInfo member = MemberProcessor.GetMember(distributor.UserId, true);
                    Messenger.SendWeiXinMsg_DistributorGradeChange(member, distributorGradeInfo.Name);
                }
                catch
                {
                }
                SiteSettings masterSettings = SettingsManager.GetMasterSettings(false);
                if (masterSettings.IsAddCommission == 1)
                {
                    try
                    {
                        DateTime t  = DateTime.Parse(masterSettings.AddCommissionStartTime);
                        DateTime t2 = DateTime.Parse(masterSettings.AddCommissionEndTime).AddDays(1.0);
                        if (DateTime.Now > t && DateTime.Now < t2)
                        {
                            decimal num = distributor.ReferralRequestBalance + distributor.ReferralBlance;
                            DistributorGradeCommissionInfo distributorGradeCommissionInfo = new DistributorGradeCommissionInfo();
                            distributorGradeCommissionInfo.UserId             = distributor.UserId;
                            distributorGradeCommissionInfo.Commission         = distributorGradeInfo.AddCommission;
                            distributorGradeCommissionInfo.PubTime            = DateTime.Now;
                            distributorGradeCommissionInfo.OperAdmin          = "system";
                            distributorGradeCommissionInfo.Memo               = "升级奖励";
                            distributorGradeCommissionInfo.OrderID            = orderid;
                            distributorGradeCommissionInfo.OldCommissionTotal = num;
                            if (!string.IsNullOrEmpty(distributorGradeCommissionInfo.OrderID))
                            {
                                distributorGradeCommissionInfo.ReferralUserId = new OrderDao().GetOrderReferralUserId(distributorGradeCommissionInfo.OrderID);
                            }
                            else
                            {
                                distributorGradeCommissionInfo.OrderID = "U" + DistributorsBrower.GenerateOrderId();
                            }
                            distributorGradeCommissionInfo.CommType = 3;
                            if (distributorGradeCommissionInfo.ReferralUserId == 0)
                            {
                                distributorGradeCommissionInfo.ReferralUserId = distributorGradeCommissionInfo.UserId;
                                distributorGradeCommissionInfo.CommType       = 4;
                            }
                            DistributorGradeCommissionBrower.AddCommission(distributorGradeCommissionInfo);
                            NoticeInfo noticeInfo = new NoticeInfo();
                            noticeInfo.Title = "恭喜分销商获得升级奖励佣金¥" + distributorGradeInfo.AddCommission.ToString("F2");
                            StringBuilder stringBuilder = new StringBuilder();
                            stringBuilder.Append(string.Concat(new string[]
                            {
                                "<p class='textlist'>恭喜<span style='color:#3D9BDF;'>",
                                distributor.StoreName,
                                "</span>自动升级为<span style='color:red;'>",
                                distributorGradeInfo.Name,
                                "</span>分销商",
                                (num > 0m) ? ("(累计获得佣金" + num.ToString("F2") + "元)") : "",
                                ",系统额外奖励佣金",
                                distributorGradeInfo.AddCommission.ToString("F2"),
                                "元!</p>"
                            }));
                            stringBuilder.Append(string.Concat(new string[]
                            {
                                "<p class='textlist'>自",
                                t.ToString("yyyy年MM月dd日"),
                                "至",
                                t2.ToString("yyyy年MM月dd日"),
                                ",分销商等级提升将获得系统奖励的额外佣金。</p>"
                            }));
                            stringBuilder.Append("<table class='table table-bordered' style='text-align: center;'><thead><tr class='firstRow'><th style='text-align:center;'>等级名称</th><th style='text-align:center;'>需要佣金</th><th style='text-align:center;'>奖励佣金</th></tr></thead><tbody>");
                            System.Data.DataTable allDistributorGrade = DistributorGradeBrower.GetAllDistributorGrade();
                            int count = allDistributorGrade.Rows.Count;
                            for (int i = 0; i < count; i++)
                            {
                                stringBuilder.Append(string.Concat(new string[]
                                {
                                    "<tr><td>",
                                    allDistributorGrade.Rows[i]["Name"].ToString(),
                                    "</td><td>¥",
                                    decimal.Parse(allDistributorGrade.Rows[i]["CommissionsLimit"].ToString()).ToString("F2"),
                                    "</td><td>¥",
                                    decimal.Parse(allDistributorGrade.Rows[i]["AddCommission"].ToString()).ToString("F2"),
                                    "</td></tr>"
                                }));
                            }
                            stringBuilder.Append("</tbody></table>");
                            noticeInfo.Memo     = stringBuilder.ToString();
                            noticeInfo.Author   = "system";
                            noticeInfo.AddTime  = DateTime.Now;
                            noticeInfo.IsPub    = 1;
                            noticeInfo.PubTime  = new DateTime?(DateTime.Now);
                            noticeInfo.SendType = 0;
                            noticeInfo.SendTo   = 0;
                            NoticeBrowser.SaveNotice(noticeInfo);
                        }
                    }
                    catch (Exception ex)
                    {
                        Globals.Debuglog("升级奖励异常" + ex.Message, "_Debuglog.txt");
                    }
                }
            }
        }