Exemplo n.º 1
0
        private void MemberMainNew_Load(object sender, EventArgs e)
        {
            memberInfoUI      = new MemberInfoUI();
            memberInfoUI.Dock = DockStyle.Fill;
            this.navigationPage1.Controls.Add(memberInfoUI);

            memberConsume  = new ConsumeInfoUI();
            memberRecharge = new RechargeInfoUI();
            this.navigationPage2.Controls.Add(memberConsume);
            memberConsume.Dock = DockStyle.Fill;
            this.navigationPage3.Controls.Add(memberRecharge);
            memberRecharge.Dock = DockStyle.Fill;


            memberRechargeQuery      = new MemberRecharge();
            memberRechargeQuery.Dock = DockStyle.Fill;
            this.navigationPage4.Controls.Add(memberRechargeQuery);

            cardOperiation      = new CradOperiation();
            cardOperiation.Dock = DockStyle.Fill;
            this.navigationPage5.Controls.Add(cardOperiation);

            this.navigationPane1.SelectedPage = this.navigationPage1;
        }
Exemplo n.º 2
0
        public StoredValueCardRechargeResult StoredValueCardRecharge(int type, string cardNo, decimal amount)
        {
            var info = Pharos.Logic.ApiData.Pos.User.Salesclerk.GetMachineInfo(StoreId, MachineSN, CompanyId, DeviceSn);

            if (info == null)
            {
                throw new PosException("无法获取操作员信息!");
            }
            var cardState = "正常";

            if (amount > 0)
            {
                //判断最低充值
                var checkData = (from a in MembershipCardService.CurrentRepository.Entities
                                 where a.CardSN == cardNo && a.CompanyId == CompanyId
                                 join b in CardInfoService.CurrentRepository.Entities
                                 on a.CardTypeId equals b.CardTypeId
                                 select new
                {
                    a,
                    b.MinRecharge,
                    b.CardType
                }).FirstOrDefault();
                if (checkData == null)
                {
                    throw new PosException("无法找到对应卡类型信息!");
                }
                if (checkData.a.State != 1)
                {
                    switch (checkData.a.State)
                    {
                    case 0:
                        cardState = "未激活";
                        break;

                    case 2:
                        cardState = "已挂失";
                        break;

                    case 3:
                        cardState = "已作废";
                        break;

                    case 4:
                        cardState = "已退卡";
                        break;
                    }
                    throw new PosException(string.Format("充值失败,该卡{0}!", cardState));
                }
                if (!checkData.CardType.Contains("1"))
                {
                    throw new PosException(string.Format("非储值卡不允许{0}!", type == 1 ? "充值" : "反结算"));
                }
                if (checkData.MinRecharge > amount && type == 1)
                {
                    throw new PosException("充值失败,该卡最低充值 " + checkData.MinRecharge.ToString("N2") + "元!");
                }
            }
            var     beforeAmount = 0m;
            Members member       = null;
            //更新会员卡金额、积分信息
            var membershipCard = MembershipCardService.CurrentRepository.Entities.Where(o => o.CardSN == cardNo && o.CompanyId == CompanyId).FirstOrDefault();

            if (membershipCard != null)
            {
                member = MembersService.Find(o => o.CompanyId == CompanyId && o.MemberId == membershipCard.MemberId);
                switch (membershipCard.State)
                {
                case 0:
                    cardState = "未激活";
                    break;

                case 2:
                    cardState = "已挂失";
                    break;

                case 3:
                    cardState = "已作废";
                    break;

                case 4:
                    cardState = "已退卡";
                    break;
                }
                beforeAmount = membershipCard.Balance;
                if (amount > 0 && type == 1)
                {
                    membershipCard.ReChargeTotal += amount;
                    membershipCard.Balance       += amount;
                }
                else if (amount > 0 && type == 2)
                {
                    if (membershipCard.Balance < amount)
                    {
                        throw new PosException("反结算失败,卡内余额小于反结算金额!");
                    }
                    membershipCard.ReChargeTotal -= amount;
                    membershipCard.Balance       -= amount;
                }
            }
            else
            {
                throw new PosException("未能找到储值卡信息!");
            }

            var result = new StoredValueCardRechargeResult()
            {
                Amount = amount, StateInfo = cardState, balance = membershipCard.Balance, CardNo = cardNo, Name = member == null ? "" : member.RealName
            };

            if (amount > 0)
            {
                var entity = new MemberRecharge()
                {
                    CompanyId      = CompanyId,
                    CreateDT       = DateTime.Now,
                    CreateUID      = info.CashierUid,
                    RechargeSN     = DateTime.Now.ToString("yyyyMMddHHmmss"),
                    BeforeAmount   = beforeAmount,
                    AfterAmount    = type == 1 ? beforeAmount + amount : beforeAmount - amount,
                    CardId         = cardNo,
                    Type           = (short)type,
                    RechargeAmount = amount,
                    MachineSN      = MachineSN,
                    StoreId        = StoreId,
                    IsTest         = IsSalesclerkTest,
                    Memo           = type == 1 ? "门店POS收银台充值!" : "门店POS收银台卡反结算!",
                    Number         = 1
                };
                MemberRechargeService.Add(entity);
                if (type == 1)
                {
                    RedisManager.Publish("RechargeCompleted", new RechargeCompletedEvent()
                    {
                        CompanyId      = CompanyId,
                        MemberId       = membershipCard.MemberId,
                        ReceiveAmount  = amount,
                        SourceRecordId = entity.Id.ToString(),
                        OperatorUid    = info.CashierUid
                    });
                }
            }
            return(result);
        }