Exemplo n.º 1
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);
     }
 }
Exemplo n.º 2
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");
            }
        }
Exemplo n.º 3
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);
         }
     }
 }