示例#1
0
        public void Insert(int? AdsMemberID,int? CompanyAdsID,decimal? AdsPoint,DateTime? AdsDate,decimal? OrderSum,int? CompanyID,int? PaymentID)
        {
            SysMemberAd item = new SysMemberAd();

            item.AdsMemberID = AdsMemberID;

            item.CompanyAdsID = CompanyAdsID;

            item.AdsPoint = AdsPoint;

            item.AdsDate = AdsDate;

            item.OrderSum = OrderSum;

            item.CompanyID = CompanyID;

            item.PaymentID = PaymentID;

            item.Save(UserName);
        }
示例#2
0
 public static bool ClickCompanyAds(SysMember user, int adsID, string answer, out string message)
 {
     SysCompanyAd item = SysCompanyAd.FetchByID(adsID);
     SysCompany company = SysCompany.FetchByID(item.AdsCompanyID);
     decimal userLastOrderSum = UserBLL.GetUserLastMonthOrderSum(user.Id);
     if (!CheckCompanyAdsCanClick(user, item, company, userLastOrderSum, out message))
         goto lbl_end;
     if (!string.IsNullOrEmpty(item.AdsQuestion) && item.AdsRightAnswer.HasValue &&
         Utilities.ToInt(answer) != item.AdsRightAnswer.Value)
     {
         message = "你的互动答题答案不正确!";
         goto lbl_end;
     }
     decimal point = CompanyAdsBLL.GetCompanyAdPoint(userLastOrderSum, item.AdsID);
     if (CompanyBLL.IsMaxPointLevel(company.Id, point))
     {
         message = "此广告主累计赠送的积分已经超过500,须进行积分结算后才能继续操作系统";
         goto lbl_end;
     }
     SysMemberAd ad = new SysMemberAd
     {
         AdsDate = DateTime.Now,
         AdsMemberID = user.Id,
         AdsPoint = point,
         CompanyID = item.AdsCompanyID,
         CompanyAdsID = item.AdsID,
         OrderSum = userLastOrderSum,
         PaymentID = 0
     };
     TransactionScope ts = new TransactionScope( );
     SharedDbConnectionScope ss = new SharedDbConnectionScope( );
     try
     {
         ad.Save( );
         item.AdsClicked = Utilities.ToInt(item.AdsClicked) + 1;
         item.AdsPointSum = Utilities.ToDecimal(item.AdsPointSum) + point;
         item.Save( );
         if (ad.AdsPoint.HasValue && ad.AdsPoint.Value > 0)
         {
             var p = new Payment
             {
                 PaymentDate = DateTime.Now,
                 PaymentCode = string.Empty,
                 PaymentCompanyID = item.AdsCompanyID,
                 PaymentEmail = string.Empty,
                 PaymentMemberID = user.Id,
                 PaymentMemo = string.Format("浏览【{0}】投放的广告,获得{1:0.00}个积分", company.CompanyName, ad.AdsPoint),
                 PaymentOrderID = ad.AdsID,
                 PaymentStatus = 1,
                 PaymentSum = ad.AdsPoint.Value,
                 PaymentType = (int)PaymentType.AdvsGive
             };
             p.Save( );
             ad.PaymentID = p.Id;
             ad.Save( );
             OrderBLL.UpdateBalance( );
         }
         ts.Complete( );
         message = string.Format("成功抢得{0}个积分", ad.AdsPoint);
         return true;
     }
     catch (Exception ex)
     {
         message = "抢积分失败:" + ex.Message;
         Logging.Log("CompanyAdsBLL->ClickCompanyAds", ex, true);
     }
     finally
     {
         ss.Dispose( );
         ts.Dispose( );
     }
     lbl_end:
     return false;
 }