示例#1
0
 /// <summary>
 /// 添加一条消费记录
 /// </summary>
 public static void InsertIntegralConsumption(IntegralConsumption view)
 {
     using (var cmd = Factory.CreateCommand())
     {
         var reposity = Factory.CreateIntegralReposity(cmd);
         reposity.InsertIntegralConsumption(view);
     }
 }
示例#2
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);
                    }
                }
            }
        }
示例#3
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);
     }
 }
示例#4
0
        public void InsertIntegralConsumption(IntegralConsumption view, int days, int integral, int integralSurplus)
        {
            int      integralCount = 0;
            DateTime tiem          = view.ExchangeTiem;
            string   sql           = "";

            for (var i = 0; i < days; i++)
            {
                integralCount           += integral;
                view.ConsumptionIntegral = integralCount > integralSurplus ? integralCount - integralSurplus : integral;
                view.ExchangeTiem        = tiem.AddDays(i + 1).Date;

                sql += @"INSERT INTO [dbo].[T_IntegralConsumption]
                           ([ID] ,[CompnayId] ,[CompanyShortName] ,[AccountNo],[AccountName],[AccountPhone],[DeliveryAddress],[ExpressCompany],[ExpressDelivery],[ConsumptionIntegral],[CommodityId],[CommodityName],[ExchangeTiem],[Exchange],[IntegralWay],[CommodityCount],[Remark],[Reason])
                            VALUES('" + Guid.NewGuid() + "','" + view.CompnayId + "','" + view.CompanyShortName + "','" + view.AccountNo + "','" + view.AccountName + "','" + view.AccountPhone + "','" + view.DeliveryAddress + "','" + view.ExpressCompany + "','" + view.ExpressDelivery + "','" + view.ConsumptionIntegral + "','" + view.CommodityId + "','" + view.CommodityName + "','" + view.ExchangeTiem + "'," + (byte)Common.Enums.ExchangeState.Processing + "," + (byte)Common.Enums.IntegralWay.NotSignIn + "," + view.CommodityCount + ",'" + view.Remark + "','" + view.Reason + "');";

                if (integralCount == integralSurplus)
                {
                    break;
                }
            }
            ExecuteNonQuery(sql);
        }
示例#5
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);
         }
     }
 }
示例#6
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);
         }
     }
 }