Beispiel #1
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         IntegralParameterView view = new IntegralParameterView
         {
             IsSignIn            = this.radEnableGongNeng.Checked,
             IsDrop              = this.radEnableXiaJia.Checked,
             AvailabilityRatio   = decimal.Parse(this.txtKeYong.Text) / 100,
             SignIntegral        = int.Parse(this.txtSheZhi.Text),
             ConsumptionIntegral = int.Parse(this.txtXiaoFei.Text),
             Multiple            = decimal.Parse(this.txtJianLi.Text),
             MostBuckle          = int.Parse(txtMostBuckle.Text),
             SpecifiedDate       = this.selZhouQi.SelectedIndex != 7 ? (DateTime?)null : DateTime.Parse(txtZhiDing.Text),
             RangeReset          = (Common.Enums.IntegralRangeTime) this.selZhouQi.SelectedIndex
         };
         IntegralServer.UpdateIntegralParameter(view);
         NewMethod();
         ShowMessage("保存成功");
     }
     catch (Exception ex)
     {
         ShowExceptionMessage(ex, "保存");
     }
 }
Beispiel #2
0
        private static void FirstInsertIntegral(Guid companyId, IReposity reposity)
        {
            IntegralParameterView prameter = reposity.GetIntegralParameter();

            if (prameter.IsSignIn)
            {
                IntegralInfo integral = new IntegralInfo
                {
                    CompnayId   = companyId,
                    AccessTime  = DateTime.Now,
                    Integral    = prameter.SignIntegral,
                    IntegralWay = IntegralWay.SignIn,
                    Remark      = "登录奖励"
                };
                reposity.InsertIntegralInfo(integral);
                IntegralCount counts = reposity.GetIntegralCount(companyId);
                IntegralCount count  = new IntegralCount
                {
                    CompnayId = companyId,
                    Integral  = prameter.SignIntegral
                };
                if (counts == null)
                {
                    count.Integral = prameter.SignIntegral;
                    reposity.InsertIntegralCount(count);
                }
                else
                {
                    reposity.UpdateIntegralCount(count);
                }
            }
        }
Beispiel #3
0
 public static void UpdateIntegralParameter(IntegralParameterView view)
 {
     using (var cmd = Factory.CreateCommand())
     {
         var reposity = Factory.CreateIntegralReposity(cmd);
         reposity.UpdateIntegralParameter(view);
     }
 }
Beispiel #4
0
        private static void NotSignIn(string username, DateTime?lastTime, DateTime logonTime, Guid companyId, IReposity reposity)
        {
            IntegralParameterView parameter = reposity.GetIntegralParameter();

            if (lastTime != null && lastTime.Value.Date != logonTime.AddDays(-1).Date)
            {
                IntegralCount counts = reposity.GetIntegralCount(companyId);
                if (parameter.IsDrop)
                {
                    if (counts == null)
                    {
                        var count = new IntegralCount
                        {
                            CompnayId = companyId,
                            Integral  = 0
                        };
                        reposity.InsertIntegralCount(count);
                    }
                    else
                    {
                        TimeSpan            day  = logonTime.AddDays(-1).Date - lastTime.Value.Date;
                        IntegralConsumption view = new IntegralConsumption
                        {
                            CompnayId           = companyId,
                            AccountName         = username,
                            AccountNo           = "",
                            AccountPhone        = "",
                            DeliveryAddress     = "",
                            CommodityCount      = 0,
                            CommodityId         = Guid.Empty,
                            CommodityName       = "",
                            ConsumptionIntegral = parameter.SignIntegral,
                            Exchange            = ExchangeState.Processing,
                            ExchangeTiem        = lastTime.Value.Date,
                            ExpressCompany      = "",
                            ExpressDelivery     = "",
                            Reason = "",
                            Remark = "未登录减少积分",
                            Way    = IntegralWay.NotSignIn
                        };
                        int days = parameter.SignIntegral * day.Days < counts.IntegralSurplus ? day.Days : (int)Math.Ceiling(Convert.ToDouble(counts.IntegralSurplus) / Convert.ToDouble(parameter.SignIntegral));
                        reposity.InsertIntegralConsumption(view, days, parameter.SignIntegral, counts.IntegralSurplus);
                        var count = new IntegralCount
                        {
                            CompnayId = companyId,
                            Integral  = -(parameter.SignIntegral * day.Days >= counts.IntegralSurplus ? counts.IntegralSurplus : parameter.SignIntegral * day.Days)
                        };
                        reposity.UpdateIntegralCount(count);
                    }
                }
            }
        }
Beispiel #5
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         IntegralParameterView paraemter = IntegralServer.GetIntegralParameter();
         IntegralCount         counts    = IntegralServer.GetIntegralByAccountIdZong(CurrentCompany.CompanyId);
         if (counts == null)
         {
             throw new Exception("积分不够,暂不能兑换该短信!");
         }
         if (counts.IntegralAvailable < int.Parse(hidjf.Value))
         {
             throw new Exception("积分不够,暂不能兑换该短信!");
         }
         var consumtion = new IntegralConsumption
         {
             CompnayId        = CurrentCompany.CompanyId,
             CompanyShortName = CurrentCompany.AbbreviateName,
             AccountName      = CurrentUser.Name,
             AccountNo        = CurrentUser.UserName,
             AccountPhone     = "",
             DeliveryAddress  = "",
             CommodityCount   = int.Parse(hidsmsNumber.Value),
             CommodityId      = Guid.Empty,
             CommodityName    = hidName.Value,
             Exchange         = ExchangeState.Success,
             ExchangeTiem     = DateTime.Now,
             ExpressCompany   = "",
             ExpressDelivery  = "",
             Reason           = "",
             Remark           = "积分兑换商品",
             Way = IntegralWay.ExchangeSms,
             ConsumptionIntegral = int.Parse(hidjf.Value)
         };
         IntegralServer.InsertIntegralConsumption(consumtion);
         IntegralServer.UpdateIntegralCountByConsumption(0 - consumtion.ConsumptionIntegral, CurrentUser.Owner);
         var acc = from item in AccountService.Query(CurrentCompany.CompanyId)
                   where item.Type == Common.Enums.AccountType.Payment
                   select new { No = item.No };
         SMSOrderService.ExChangeSms(CurrentCompany.CompanyId, int.Parse(hidjf.Value), int.Parse(hidsmsNumber.Value), int.Parse(hidjfNum.Value), acc.First().No);
         hidShow.Value = "0";
     }
     catch (Exception ex)
     {
         ShowExceptionMessage(ex, "兑换短信套餐");
         hidShow.Value = "1";
     }
     if (hidShow.Value == "0")
     {
         RegisterScript("alert('兑换短信成功。');window.location.href='./SMSBuy.aspx';", true);
     }
 }
Beispiel #6
0
 /// <summary>
 /// 用户有效的总积分,总剩余积分
 /// </summary>
 /// <param name="companyId"></param>
 /// <returns></returns>
 public static Domain.IntegralCount GetIntegralByAccountIdZong(Guid companyId)
 {
     using (var cmd = Factory.CreateCommand())
     {
         var                   reposity = Factory.CreateIntegralReposity(cmd);
         IntegralCount         count    = reposity.GetIntegralCount(companyId);
         IntegralParameterView view     = reposity.GetIntegralParameter();
         if (count == null)
         {
             count = new IntegralCount();
         }
         count.IntegralAvailable = count.IntegralSurplus + count.IntegralNotDeduct < 0 ? (count.IntegralSurplus + count.IntegralNotDeduct) : (int)Math.Floor((count.IntegralSurplus + count.IntegralNotDeduct) * view.AvailabilityRatio);
         count.IntegralAvailable = count.IntegralCounts - count.IntegralAvailable > view.MostBuckle ? count.IntegralCounts - view.MostBuckle : count.IntegralAvailable;
         return(count);
     }
 }
Beispiel #7
0
        private void NewMethod()
        {
            IntegralParameterView view = IntegralServer.GetIntegralParameter();

            if (view != null)
            {
                radEnableGongNeng.Checked  = view.IsSignIn;
                radDisableGongNeng.Checked = !view.IsSignIn;
                radEnableXiaJia.Checked    = view.IsDrop;
                radDisableXiaJia.Checked   = !view.IsDrop;
                txtKeYong.Text             = (view.AvailabilityRatio * 100).TrimInvaidZero();
                txtSheZhi.Text             = view.SignIntegral + "";
                txtXiaoFei.Text            = view.ConsumptionIntegral + "";
                txtMostBuckle.Text         = view.MostBuckle + "";
                txtJianLi.Text             = view.Multiple.TrimInvaidZero();
                selZhouQi.SelectedIndex    = (int)view.RangeReset;
                txtZhiDing.Text            = view.SpecifiedDate == null?DateTime.Today.AddYears(1).ToString("yyyy-MM-dd") : view.SpecifiedDate.Value.ToString("yyyy-MM-dd");

                txtZhiDing.Style.Add(HtmlTextWriterStyle.Display, view.SpecifiedDate != null ? "" : "none");
            }
        }
Beispiel #8
0
        //public DataTransferObject.Integral.IntegralInfoView GetIntegralByAccountId(Guid CompnayId, Common.Enums.IntegralWay? way)
        //{
        //    IntegralInfoView result = null;
        //    string sql = @"SELECT TOP 1 [ID] ,[CompnayId]  ,[Integral]  ,[IntegralWay] ,[AccessTime]   ,[Remark]  FROM  [dbo].[T_IntegralInfo] WHERE CompnayId=@CompnayId ";
        //    using (var dbOperator = new DbOperator(Provider, ConnectionString))
        //    {
        //        AddParameter("CompnayId", CompnayId);
        //        if (way != null)
        //        {
        //            sql += " AND IntegralWay = @IntegralWay";
        //            AddParameter("IntegralWay", (byte)way);
        //        }
        //        sql += " ORDER BY AccessTime DESC";
        //        using (var reader = ExecuteReader(sql))
        //        {
        //            if (reader.Read())
        //            {
        //                result = new IntegralInfoView();
        //                result.CompnayId = reader.GetGuid(0);
        //                result.Integral = reader.GetInt32(1);
        //                result.IntegralWay = (Common.Enums.IntegralWay)reader.GetByte(2);
        //                result.AccessTime = reader.GetDateTime(3);
        //                result.Remark = reader.GetString(4);
        //            }
        //        }
        //    }
        //    return result;
        //}
        public DataTransferObject.Integral.IntegralParameterView GetIntegralParameter()
        {
            IntegralParameterView result = null;
            string sql = @"SELECT [IsSignIn] ,[SignIntegral],[IsDrop],[ConsumptionIntegral],[AvailabilityRatio],[RangeReset],Multiple,SpecifiedDate,MostBuckle FROM  [dbo].[T_IntegralParameter] ";

            using (var reader = ExecuteReader(sql))
            {
                if (reader.Read())
                {
                    result                     = new IntegralParameterView();
                    result.IsSignIn            = reader.GetBoolean(0);
                    result.SignIntegral        = reader.GetInt32(1);
                    result.IsDrop              = reader.GetBoolean(2);
                    result.ConsumptionIntegral = reader.GetInt32(3);
                    result.AvailabilityRatio   = reader.GetDecimal(4);
                    result.RangeReset          = (ChinaPay.B3B.Common.Enums.IntegralRangeTime)reader.GetByte(5);
                    result.Multiple            = reader.GetDecimal(6);
                    result.SpecifiedDate       = reader.GetValue(7) == DBNull.Value ? (Nullable <DateTime>)null : reader.GetDateTime(7);
                    result.MostBuckle          = reader.GetInt32(8);
                }
            }
            return(result);
        }
Beispiel #9
0
 /// <summary>
 /// 增加用户购买机票的积分或减少用户退票的积分
 /// </summary>
 /// <param name="IsChinaPay">是否是国付通支付</param>
 /// <param name="IsBuy">是否是购买机票/退票,true买票,false退票</param>
 private static void InsertIntergralByMoney(string username, Guid companyId, string companyShortName, decimal money, bool IsChinaPay, string orderId, bool IsBuy)
 {
     using (var cmd = Factory.CreateCommand())
     {
         var reposity = Factory.CreateIntegralReposity(cmd);
         IntegralParameterView prameter = reposity.GetIntegralParameter();
         IntegralCount         counts   = reposity.GetIntegralCount(companyId);
         IntegralCount         count    = new IntegralCount
         {
             CompnayId = companyId,
             Integral  = prameter.SignIntegral
         };
         if (IsBuy)
         {
             IntegralInfo integral = new IntegralInfo
             {
                 CompnayId   = companyId,
                 AccessTime  = DateTime.Now,
                 IntegralWay = IntegralWay.Buy,
                 Remark      = orderId,
                 Integral    = IsChinaPay ? (int)(Math.Floor(money * ((decimal)prameter.ConsumptionIntegral / 100)) * prameter.Multiple) : (int)Math.Floor(money * ((decimal)prameter.ConsumptionIntegral / 100))
             };
             count.Integral = integral.Integral;
             if (count.Integral != 0)
             {
                 reposity.InsertIntegralInfo(integral);
             }
         }
         else
         {
             IntegralConsumption consumtion = new IntegralConsumption
             {
                 CompnayId        = companyId,
                 AccountName      = username,
                 CompanyShortName = companyShortName,
                 AccountNo        = "",
                 AccountPhone     = "",
                 DeliveryAddress  = "",
                 CommodityCount   = 0,
                 CommodityId      = Guid.Empty,
                 CommodityName    = "",
                 Exchange         = ExchangeState.Processing,
                 ExchangeTiem     = DateTime.Now,
                 ExpressCompany   = "",
                 ExpressDelivery  = "",
                 Reason           = "",
                 Remark           = orderId,
                 Way = IntegralWay.TuiPiao
             };
             consumtion.ConsumptionIntegral = IsChinaPay ? (int)(Math.Floor(money * ((decimal)prameter.ConsumptionIntegral / 100)) * prameter.Multiple) : (int)Math.Floor(money * ((decimal)prameter.ConsumptionIntegral / 100));
             count.Integral = 0 - consumtion.ConsumptionIntegral;
             if (count.Integral != 0)
             {
                 reposity.InsertIntegralConsumption(consumtion);
             }
         }
         if (count.Integral == 0)
         {
             return;
         }
         count.IsNotDeduct = true;
         if (counts == null)
         {
             reposity.InsertIntegralCount(count);
         }
         else
         {
             reposity.UpdateIntegralCount(count);
         }
     }
 }
Beispiel #10
0
 /// <summary>
 /// 兑换商品
 /// </summary>
 public static void ExChangeCommodity(Guid id, int exChangeNum, CompanyDetailInfo compnay, EmployeeDetailInfo accountinfo, OEMCommodityState stata, string domainName, Guid?oemid)
 {
     using (var cmd = Factory.CreateCommand())
     {
         var           reposity      = Factory.CreateIntegralReposity(cmd);
         CommodityView commodityview = reposity.GetCommodity(id);
         if (commodityview.ValidityTime.Date < DateTime.Now.Date)
         {
             throw new Exception("该商品上架时间已经到期,不能兑换!");
         }
         if (!commodityview.State)
         {
             throw new Exception("该商品未启用,不能兑换!");
         }
         if (commodityview.SurplusNumber == 0)
         {
             throw new Exception("该商品已经兑换完毕,不能兑换!");
         }
         if (commodityview.SurplusNumber < exChangeNum)
         {
             throw new Exception("该商品库存不足,不能兑换!");
         }
         if (commodityview.NeedIntegral > 0)
         {
             IntegralParameterView paraemter = IntegralServer.GetIntegralParameter();
             IntegralCount         counts    = IntegralServer.GetIntegralByAccountIdZong(compnay.CompanyId);
             if (counts == null)
             {
                 throw new Exception("积分不够,暂不能兑换该商品!");
             }
             if (counts.IntegralAvailable < commodityview.NeedIntegral * exChangeNum)
             {
                 throw new Exception("积分不够,暂不能兑换该商品!");
             }
         }
         commodityview.SurplusNumber  = commodityview.SurplusNumber - exChangeNum;
         commodityview.ExchangeNumber = commodityview.ExchangeNumber + exChangeNum;
         cmd.BeginTransaction();
         try
         {
             reposity.Update(commodityview);
             var consumtion = new IntegralConsumption
             {
                 CompnayId        = compnay.CompanyId,
                 CompanyShortName = compnay.AbbreviateName,
                 AccountName      = accountinfo.Name,
                 AccountNo        = accountinfo.UserName,
                 AccountPhone     = compnay.ContactPhone,
                 DeliveryAddress  = commodityview.Type == CommodityType.Entity ? compnay.Address : "",
                 CommodityCount   = exChangeNum,
                 CommodityId      = commodityview.ID,
                 CommodityName    = commodityview.CommodityName,
                 Exchange         = commodityview.Type == CommodityType.Entity ? ExchangeState.Processing : ExchangeState.Success,
                 ExchangeTiem     = DateTime.Now,
                 ExpressCompany   = "",
                 ExpressDelivery  = "",
                 Reason           = "",
                 Remark           = commodityview.CommodityName,
                 Way = commodityview.Type == CommodityType.Entity ? IntegralWay.Exchange : IntegralWay.ExchangeSms,
                 ConsumptionIntegral = commodityview.NeedIntegral * exChangeNum,
                 OEMCommodityState   = commodityview.Type == CommodityType.SMS ? OEMCommodityState.Success : stata,
                 OEMName             = domainName,
                 OEMID = oemid
             };
             IntegralServer.InsertIntegralConsumption(consumtion);
             IntegralServer.UpdateIntegralCountByConsumption(0 - consumtion.ConsumptionIntegral, accountinfo.Owner);
             cmd.CommitTransaction();
         }
         catch (Exception)
         {
             cmd.RollbackTransaction();
             throw;
         }
         if (commodityview.Type == CommodityType.SMS)
         {
             var acc = from item in AccountService.Query(compnay.CompanyId)
                       where item.Type == Common.Enums.AccountType.Payment
                       select new { No = item.No };
             SMSOrderService.ExChangeSms(compnay.CompanyId, commodityview.NeedIntegral, exChangeNum, commodityview.ExchangSmsNumber, acc.First().No);
         }
     }
 }