Пример #1
0
        void rptContents_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                var cardCashLogInfo = new CardCashLogInfo(e.Item.DataItem);
                var cardSnInfo      = DataProviderWx.CardSnDao.GetCardSnInfo(cardCashLogInfo.CardSnId);
                var userInfo        = BaiRongDataProvider.UserDao.GetUserInfoByUserName(cardCashLogInfo.UserName);

                var ltlItemIndex    = e.Item.FindControl("ltlItemIndex") as Literal;
                var ltlSn           = e.Item.FindControl("ltlSN") as Literal;
                var ltlUserName     = e.Item.FindControl("ltlUserName") as Literal;
                var ltlMobile       = e.Item.FindControl("ltlMobile") as Literal;
                var ltlType         = e.Item.FindControl("ltlType") as Literal;
                var ltlAmount       = e.Item.FindControl("ltlAmount") as Literal;
                var ltlBeforeAmount = e.Item.FindControl("ltlBeforeAmount") as Literal;
                var ltlAfterAmount  = e.Item.FindControl("ltlAfterAmount") as Literal;
                var ltlAddDate      = e.Item.FindControl("ltlAddDate") as Literal;
                var ltlOperator     = e.Item.FindControl("ltlOperator") as Literal;

                ltlItemIndex.Text = (e.Item.ItemIndex + 1).ToString();
                ltlType.Text      = EConsumeTypeUtils.GetText(EConsumeTypeUtils.GetEnumType(cardCashLogInfo.ConsumeType));
                ltlAmount.Text    = cardCashLogInfo.Amount.ToString();
                if (EConsumeTypeUtils.GetEnumType(cardCashLogInfo.ConsumeType) == EConsumeType.Cash)
                {
                    ltlBeforeAmount.Text = cardCashLogInfo.CurAmount.ToString();
                }
                else
                {
                    ltlBeforeAmount.Text = (cardCashLogInfo.CurAmount + cardCashLogInfo.Amount).ToString();
                }
                ltlAfterAmount.Text = cardCashLogInfo.CurAmount.ToString();
                ltlUserName.Text    = userInfo != null ? userInfo.UserName : string.Empty;
                ltlMobile.Text      = userInfo != null ? userInfo.Mobile : string.Empty;
                ltlSn.Text          = cardSnInfo != null ? cardSnInfo.Sn : string.Empty;
                ltlAddDate.Text     = DateUtils.GetDateAndTimeString(cardCashLogInfo.AddDate);
                ltlOperator.Text    = cardCashLogInfo.Operator;
            }
        }
Пример #2
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (IsPostBack && IsValid)
            {
                UserInfo   userInfo   = null;
                CardSnInfo cardSnInfo = null;

                if (_cardSnid > 0)
                {
                    cardSnInfo = DataProviderWx.CardSnDao.GetCardSnInfo(_cardSnid);
                }
                else
                {
                    if (DdlKeyWordType.SelectedValue == "cardSN")
                    {
                        cardSnInfo = DataProviderWx.CardSnDao.GetCardSnInfo(PublishmentSystemId, TranslateUtils.ToInt(DdlCard.SelectedValue), TbKeyWord.Text, string.Empty);
                    }
                    else if (DdlKeyWordType.SelectedValue == "mobile")
                    {
                        var userId = BaiRongDataProvider.UserDao.GetUserIdByEmailOrMobile(string.Empty, TbKeyWord.Text);
                        userInfo = BaiRongDataProvider.UserDao.GetUserInfo(userId);
                        if (userInfo != null)
                        {
                            cardSnInfo = DataProviderWx.CardSnDao.GetCardSnInfo(PublishmentSystemId, TranslateUtils.ToInt(DdlCard.SelectedValue), string.Empty, userInfo.UserName);
                        }
                    }
                }

                if (cardSnInfo == null)
                {
                    FailMessage("会员卡不存在");
                    return;
                }

                var consumeType = EConsumeTypeUtils.GetEnumType(DdlConsumeType.SelectedValue);

                if (consumeType == EConsumeType.CardAmount)
                {
                    var amount = DataProviderWx.CardSnDao.GetAmount(cardSnInfo.Id, cardSnInfo.UserName);
                    if (amount < TranslateUtils.ToDecimal(TbConsumeAmount.Text))
                    {
                        FailMessage("会员卡余额不足");
                        return;
                    }
                }

                var cardCashLogInfo = new CardCashLogInfo();
                cardCashLogInfo.PublishmentSystemId = PublishmentSystemId;
                cardCashLogInfo.UserName            = cardSnInfo.UserName;
                cardCashLogInfo.CardId    = cardSnInfo.CardId;
                cardCashLogInfo.CardSnId  = cardSnInfo.Id;
                cardCashLogInfo.Amount    = TranslateUtils.ToDecimal(TbConsumeAmount.Text);
                cardCashLogInfo.CurAmount = cardSnInfo.Amount;
                if (consumeType == EConsumeType.CardAmount)
                {
                    cardCashLogInfo.CurAmount = cardSnInfo.Amount - TranslateUtils.ToInt(TbConsumeAmount.Text);
                }

                cardCashLogInfo.CashType    = ECashTypeUtils.GetValue(ECashType.Consume);
                cardCashLogInfo.ConsumeType = DdlConsumeType.SelectedValue;
                cardCashLogInfo.Operator    = DdlOperator.SelectedValue;
                cardCashLogInfo.AddDate     = DateTime.Now;

                try
                {
                    DataProviderWx.CardCashLogDao.Insert(cardCashLogInfo);

                    if (consumeType == EConsumeType.CardAmount)
                    {
                        DataProviderWx.CardSnDao.Consume(cardSnInfo.Id, cardSnInfo.UserName, TranslateUtils.ToDecimal(TbConsumeAmount.Text));

                        if (PublishmentSystemInfo.Additional.WxCardIsClaimCardCredits)
                        {
                            var amount        = TranslateUtils.ToDecimal(TbConsumeAmount.Text);
                            var consumeAmount = PublishmentSystemInfo.Additional.WxCardConsumeAmount;
                            var giveCredits   = PublishmentSystemInfo.Additional.WxCardGiveCredits;

                            //var userCreditsLogInfo = new UserCreditsLogInfo();
                            //userCreditsLogInfo.UserName = cardSNInfo.UserName;
                            //userCreditsLogInfo.ProductId = AppManager.WeiXin.AppID;
                            //userCreditsLogInfo.Num = (int)Math.Round(amount * (giveCredits / consumeAmount), 0);
                            //userCreditsLogInfo.AddDate = DateTime.Now;
                            //userCreditsLogInfo.IsIncreased = true;
                            //userCreditsLogInfo.Action = "消费送积分";

                            //BaiRongDataProvider.UserCreditsLogDao.Insert(userCreditsLogInfo);
                            //BaiRongDataProvider.UserDao.AddCredits(cardSNInfo.UserName, (int)Math.Round(amount * (giveCredits / consumeAmount), 0));
                        }
                    }
                    TbConsumeAmount.Text = string.Empty;

                    SuccessMessage("操作成功!");

                    //PageUtils.CloseModalPage(Page);
                }
                catch (Exception ex)
                {
                    FailMessage(ex, "操作失败!");
                }
            }
        }