Beispiel #1
0
        /// <summary>
        /// 日结月结
        /// </summary>
        /// <param name="from"></param>
        /// <param name="to"></param>
        /// <param name="range"></param>
        /// <returns></returns>
        public DayReportResult DayMonthReport(DateTime from, DateTime to, Range range)
        {
            DayReportResult result = new DayReportResult();

            result.Summary         = new List <DayReportDetailItem>();
            result.SalesmanRecords = new List <SalesmanDayReportResult>();
            var machineParams = range == Range.Local ? MachineSN : "";
            var users         = SaleOrdersService.DayMonthReport(from, to, ref result, StoreId, machineParams, CompanyId, IsSalesclerkTest);

            SaleDetailService.DayMonthReport(from, to, ref result, StoreId, machineParams, CompanyId, IsSalesclerkTest, users);
            PosIncomePayoutService.DayMonthReport(from, to, ref result, StoreId, machineParams, CompanyId, IsSalesclerkTest);
            MemberRechargeService.DayMonthReport(from, to, ref result, StoreId, machineParams, CompanyId, IsSalesclerkTest);

            return(result);
        }
Beispiel #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);
        }