Exemple #1
0
        public void RechargeCash(Model.VO.RechargeVO entity)
        {
            CustClubCardModule.ClubCardMgm clubCardMgm = new CustClubCardModule.ClubCardMgm();
            int clubCardID = clubCardMgm.GetCardStatusByClubCardID(entity.ClubCardID);

            if (clubCardID != Convert.ToInt32(ClubCardStatus.OpenCard))
            {
                throw new Exception("非有效会员卡,请联系后台管理员");
            }

            RechargeLogData rechargeLogData = new RechargeLogData();
            ClubCardData    clubCardData    = new ClubCardData();
            ClubCardPO      clubCardPO      = clubCardData.GetClubCardByID(entity.ClubCardID);

            clubCardPO.Balance += entity.PlatformRechargeAmount;


            SqlConnection conn = new SqlConnection(PubConstant.ConnectionString);

            conn.Open();
            SqlTransaction tx = conn.BeginTransaction();

            try
            {
                //entity.RechargeSerialNo = SerialNoGenerator.GenRechargeSerialNo(entity.RechargeStore);
                rechargeLogData.AddRechargeLog(Mapper.Map <RechargeVO, RechargeLogPO>(entity));
                clubCardData.UpdateClubCard(clubCardPO);
                tx.Commit();
            }
            catch
            {
                tx.Rollback();
                throw new Exception("现金充值失败");
            }
        }
Exemple #2
0
        public Model.VO.ClubCardVO GetClubCardByID(int id)
        {
            ClubCardData clubCardData = new ClubCardData();
            ClubCardVO   clubCardVO   = new ClubCardVO();
            ClubCardPO   clubCardPO   = clubCardData.GetClubCardByID(id);

            clubCardVO = Mapper.Map <ClubCardPO, ClubCardVO>(clubCardPO);

            return(clubCardVO);
        }
Exemple #3
0
        public string ConsumeCash(List <Model.VO.ConsumeVO> list)
        {
            string strBatchNo = "";

            CustClubCardModule.ClubCardMgm clubCardMgm = new CustClubCardModule.ClubCardMgm();
            int clubCardStat = clubCardMgm.GetCardStatusByClubCardID(list[0].ClubCardID);

            if (clubCardStat != Convert.ToInt32(ClubCardStatus.OpenCard))
            {
                throw new Exception("非有效会员卡,请联系后台管理员");
            }

            ConsumeLogData consumeLogData = new ConsumeLogData();
            ClubCardData   clubCardData   = new ClubCardData();
            ClubCardPO     clubCardPO     = clubCardData.GetClubCardByID(list[0].ClubCardID);

            SqlConnection conn = new SqlConnection(PubConstant.ConnectionString);

            conn.Open();
            SqlTransaction tx      = conn.BeginTransaction();
            int            storeId = Convert.ToInt32(list.FirstOrDefault().Reserved1);

            list.ForEach(itm => itm.Reserved1 = null);
            try
            {
                decimal dConsumeAmount = 0.0M;
                strBatchNo = SerialNoGenerator.GenConsumeBatchNo(storeId);
                foreach (var item in list)
                {
                    dConsumeAmount     += item.OriginalPrice;
                    item.ConsumeBatchNo = strBatchNo;
                    consumeLogData.AddConsumeLog(Mapper.Map <ConsumeVO, ConsumeLogPO>(item));
                }
                clubCardPO.Balance = clubCardPO.Balance - dConsumeAmount;
                clubCardData.UpdateClubCard(clubCardPO);
                tx.Commit();
            }
            catch
            {
                tx.Rollback();
                throw new Exception("会员现金消费失败");
            }
            return(strBatchNo);
        }
Exemple #4
0
        public int RechargePkg(Model.VO.RechargeVO entity)
        {
            //尚需完善
            CustClubCardModule.ClubCardMgm clubCardMgm = new CustClubCardModule.ClubCardMgm();

            int clubCardState = clubCardMgm.GetCardStatusByClubCardID(entity.ClubCardID);

            if (clubCardState != Convert.ToInt32(ClubCardStatus.OpenCard))
            {
                throw new Exception("非有效会员卡,请联系后台管理员");
            }

            RechargeLogData   rechargeLogData = new RechargeLogData();
            ClubCardPackagePO clubCardPkgPO   = new ClubCardPackagePO();

            List <ClubCardPackageDetailPO> clubCardPkgDetailPOList = new List <ClubCardPackageDetailPO>();

            ClubCardPackageData clubCardPkgData = new ClubCardPackageData();


            MarktingPlanModule.PackageMgm   pkgMgm      = new MarktingPlanModule.PackageMgm();
            MarktingPlanModule.IPkgItemsMgm pkgItemsMgm = new MarktingPlanModule.PkgItemsMgm();

            //PackageData packageData = new PackageData();
            //PkgItemsData pkgItemsData = new PkgItemsData();

            PackageVO        packageVO   = pkgMgm.GetPackageByID(Convert.ToInt32(entity.ClubCardPackageID));//此处ClubCardPackageID即为PackageID
            PackagePO        packagePO   = Mapper.Map <PackageVO, PackagePO>(packageVO);
            List <PkgItemVO> pkgItemList = pkgItemsMgm.GetItemsByPkgID(packagePO.PackageID);


            clubCardPkgPO.PackageID         = packagePO.PackageID;
            clubCardPkgPO.ClubCardID        = entity.ClubCardID;
            clubCardPkgPO.PackageName       = packagePO.PackageName;
            clubCardPkgPO.OriginalAmount    = entity.PlatformRechargeAmount;
            clubCardPkgPO.ActualAmount      = entity.ActualRechargeAmount;
            clubCardPkgPO.DiscountRate      = entity.DiscountRate;
            clubCardPkgPO.DiscountInfo      = entity.DiscountInfo;
            clubCardPkgPO.DiscountRate      = Convert.ToDecimal(CardSPackageStatus.Available);
            clubCardPkgPO.Salesman          = entity.SalesMan;
            clubCardPkgPO.SalesTime         = DateTime.Now;
            clubCardPkgPO.SaleStore         = entity.RechargeStore;//从login信息中获取
            clubCardPkgPO.CreatedDate       = DateTime.Now;
            clubCardPkgPO.CreatorID         = entity.CreatorID;
            clubCardPkgPO.LastModifiedDate  = DateTime.Now;
            clubCardPkgPO.LastModifierID    = entity.LastModifierID;
            clubCardPkgPO.ClubCardPackageID = SerialNoGenerator.GenClubCardPkgID();

            foreach (var item in pkgItemList)
            {
                ClubCardPackageDetailPO clubCardPkgDetailPO = new ClubCardPackageDetailPO();
                clubCardPkgDetailPO.ClubCardPackageID = clubCardPkgPO.ClubCardPackageID;
                clubCardPkgDetailPO.ItemID            = item.ItemID;
                clubCardPkgDetailPO.ItemName          = item.ItemName;
                clubCardPkgDetailPO.OriginalCount     = item.ConsumeCount;//消费项目次数
                clubCardPkgDetailPO.RemainCount       = item.ConsumeCount;
                clubCardPkgDetailPO.CreatedDate       = DateTime.Now;
                clubCardPkgDetailPO.CreatorID         = entity.CreatorID;
                clubCardPkgDetailPO.LastModifiedDate  = DateTime.Now;
                clubCardPkgDetailPO.LastModifierID    = entity.LastModifierID;

                clubCardPkgDetailPOList.Add(clubCardPkgDetailPO);
            }

            ClubCardData clubCardData = new ClubCardData();
            ClubCardPO   clubCardPO   = clubCardData.GetClubCardByID(entity.ClubCardID);

            clubCardPO.Balance          = clubCardPO.Balance + entity.PlatformRechargeAmount;
            clubCardPO.LastModifiedDate = DateTime.Now;
            clubCardPO.LastModifierID   = entity.LastModifierID;


            SqlConnection conn = new SqlConnection(PubConstant.ConnectionString);

            conn.Open();
            SqlTransaction tx = conn.BeginTransaction();

            try
            {
                clubCardPkgData.AddClubCardPkg(clubCardPkgPO);
                clubCardPkgData.AddClubCardPkgDetailList(clubCardPkgDetailPOList);

                // entity.RechargeSerialNo = SerialNoGenerator.GenRechargeSerialNo(entity.RechargeStore);
                rechargeLogData.AddRechargeLog(Mapper.Map <RechargeVO, RechargeLogPO>(entity));
                tx.Commit();
            }
            catch
            {
                tx.Rollback();
                throw new Exception("套餐充值失败");
            }
            return(1);
        }