Example #1
0
        public static List <int> GetRedSeatings(Cashback Current)
        {
            List <Cashback> Cashbakcs   = Cashback.GetAll(OrderType.CurrOrgId(), 1);// all active cashbk of current outlet
            List <int>      RedSeatings = new List <int>();

            Cashbakcs = Cashbakcs.FindAll(x => x.SeatingIds != "");
            Cashbakcs = Cashbakcs.FindAll(x => x.CashBkId != Current.CashBkId && x.CashBkStatus == 1); // all running cashback not Current cashbk
            if (Current.CampeignType == 3)                                                             // check for only offers
            {
                Cashbakcs = Cashbakcs.FindAll(x => x.CampeignType == 3);
            }
            else if (Current.CampeignType == 1 || Current.CampeignType == 2)
            {
                Cashbakcs = Cashbakcs.FindAll(x => x.CampeignType != 3);
            }
            if (Current.StartDate.Date > DateTime.Now.Date)
            {
                Cashbakcs = Cashbakcs.FindAll(x => Current.StartDate.Date >= x.StartDate.Date && x.ValidTillDate <= Current.ValidTillDate.Date).ToList();
            }
            else
            {
                if (Current.ValidTillDate < DateTime.Now.Date)
                {
                    return(RedSeatings);
                }
                Cashbakcs = Cashbakcs.FindAll(x => Current.StartDate.Date <= x.ValidTillDate.Date).ToList();
            }
            foreach (var cashbak in Cashbakcs)
            {
                RedSeatings.AddRange(cashbak.SeatingIds.Split(',').Select(int.Parse).ToList());
            }

            return(RedSeatings);
        }
Example #2
0
        public static List <Cashback> GetAll(int OrgId, int TerminateSts = 0)
        {
            DBCon           dBCon   = new DBCon();
            SqlCommand      cmd     = null;
            SqlDataReader   SDR     = null;
            List <Cashback> ListTmp = new List <Cashback>();
            string          Query   = "SELECT * FROM  CashBack where OrgID=" + OrgId.ToString();

            if (TerminateSts > 0)
            {
                Query += "and TerminateSts = " + TerminateSts;
            }
            try
            {
                cmd = new SqlCommand(Query, dBCon.Con);
                SDR = cmd.ExecuteReader();
                while (SDR.Read())
                {
                    int      index  = 0;
                    Cashback ObjTmp = new Cashback();
                    ObjTmp.CashBkId      = SDR.GetInt32(index++);
                    ObjTmp.OrgID         = SDR.GetInt32(index++);
                    ObjTmp.StartDate     = SDR.GetDateTime(index++);
                    ObjTmp.ValidTill     = SDR.GetInt32(index++);
                    ObjTmp.ValidTillDate = SDR.GetDateTime(index++);
                    ObjTmp.CashBkType    = SDR.GetInt32(index++);
                    ObjTmp.Percentage    = SDR.GetDouble(index++);
                    ObjTmp.MaxAmt        = SDR.GetDouble(index++);
                    ObjTmp.BilAmt        = SDR.GetDouble(index++);
                    ObjTmp.RaiseDynamic  = SDR.GetBoolean(index++);
                    ObjTmp.CashBkStatus  = SDR.GetInt32(index++);
                    ObjTmp.SeatingIds    = SDR.GetString(index++);
                    ObjTmp.TerminateSts  = SDR.GetInt32(index++);
                    ObjTmp.CBUniqId      = SDR.GetInt64(index++);
                    ObjTmp.CampeignType  = SDR.GetInt32(index++);
                    ObjTmp.MaxCBLimit    = SDR.GetInt32(index++);
                    ObjTmp.OfferType     = SDR.GetInt32(index++);
                    ListTmp.Add(ObjTmp);
                }
            }
            catch (Exception e) { e.ToString(); }
            finally { dBCon.Close(); }

            return(ListTmp);
        }
Example #3
0
        public static Cashback GetAppliedCashBk(int OrgId, Int64 SeatinId, int CampType)
        {
            List <Cashback> Cashbacks = Cashback.GetAll(OrgId, 1);   // only actives

            Cashbacks = Cashbacks.FindAll(x => x.CashBkStatus == 1); // only running
            Cashbacks = Cashbacks.FindAll(x => x.CampeignType == CampType);
            Cashbacks = Cashbacks.FindAll(x => x.SeatingIds != "");
            Cashbacks = Cashbacks.FindAll(x => x.StartDate.Date <= DateTime.Now.Date && x.ValidTillDate.Date >= DateTime.Now.Date).ToList();
            for (int i = 0; i < Cashbacks.Count; i++)
            {
                List <int> seats = Cashbacks[i].SeatingIds.Split(',').Select(int.Parse).ToList();
                int        seat  = seats.Find(x => x == SeatinId);
                if (seat > 0)
                {
                    return(Cashbacks[i]);
                }
            }
            return(null);
        }
Example #4
0
        public static Cashback Getone(int CashBkId)
        {
            DBCon         dBCon = new DBCon();
            SqlCommand    cmd   = null;
            SqlDataReader SDR   = null;
            Cashback      Tmp   = new Cashback();
            string        Query = "SELECT * FROM  CashBack where CashBkId=" + CashBkId.ToString();

            try
            {
                cmd = new SqlCommand(Query, dBCon.Con);
                SDR = cmd.ExecuteReader();
                while (SDR.Read())
                {
                    int      index  = 0;
                    Cashback ObjTmp = new Cashback();
                    ObjTmp.CashBkId      = SDR.GetInt32(index++);
                    ObjTmp.OrgID         = SDR.GetInt32(index++);
                    ObjTmp.StartDate     = SDR.GetDateTime(index++);
                    ObjTmp.ValidTill     = SDR.GetInt32(index++);
                    ObjTmp.ValidTillDate = SDR.GetDateTime(index++);
                    ObjTmp.CashBkType    = SDR.GetInt32(index++);
                    ObjTmp.Percentage    = SDR.GetDouble(index++);
                    ObjTmp.MaxAmt        = SDR.GetDouble(index++);
                    ObjTmp.BilAmt        = SDR.GetDouble(index++);
                    ObjTmp.RaiseDynamic  = SDR.GetBoolean(index++);
                    ObjTmp.CashBkStatus  = SDR.GetInt32(index++);
                    ObjTmp.SeatingIds    = SDR.GetString(index++);
                    ObjTmp.TerminateSts  = SDR.GetInt32(index++);
                    ObjTmp.CBUniqId      = SDR.GetInt64(index++);
                    ObjTmp.CampeignType  = SDR.GetInt32(index++);
                    ObjTmp.MaxCBLimit    = SDR.GetInt32(index++);
                    ObjTmp.OfferType     = SDR.GetInt32(index++);
                    ObjTmp.StrStartDate  = ObjTmp.StartDate.ToString("dd-MM-yyyy");
                    ObjTmp.ValidTillStr  = ObjTmp.ValidTillDate.ToString("dd-MM-yyyy");
                    Tmp = ObjTmp;
                }
            }
            catch (Exception e) { e.ToString(); }
            finally { dBCon.Close(); }

            return(Tmp);
        }
Example #5
0
        public static void AddToWallet(HG_Orders ObjOrder, int AppType = 0)
        {
            if (ObjOrder.Status != "3")
            {
                return;
            }
            if (AppType == 1)
            {
            }
            else if (ObjOrder.Status == "3")
            {
                vw_HG_UsersDetails ObjUser = new vw_HG_UsersDetails().GetSingleByUserId((int)ObjOrder.CID);
                if (ObjUser.UserType != "CUST")
                {
                    return;
                }
            }
            Cashback cashbk = Cashback.GetAppliedCashBk(ObjOrder.OrgId, ObjOrder.Table_or_SheatId, 1);

            if (cashbk != null)
            {
                double cashBkAmt = 0.00;

                if (cashbk.Percentage > 0 && cashbk.RaiseDynamic)
                {
                    double OrdAmt       = HG_Orders.OrderAmt(ObjOrder.OID, ObjOrder.DeliveryCharge);
                    var    AggStudy     = GetOrder.GetTotalAmt(ObjOrder.OrgId);
                    double DynamicValue = AggStudy + (AggStudy - cashbk.BilAmt) * (cashbk.Percentage * 2 / 100);
                    if (DynamicValue > cashbk.BilAmt && OrdAmt > DynamicValue)
                    {
                        cashBkAmt = OrdAmt * cashbk.Percentage / 100;
                    }
                    else if (OrdAmt > cashbk.BilAmt)
                    {
                        cashBkAmt = OrdAmt * cashbk.Percentage / 100;
                    }
                }
                else if (cashbk.Percentage > 0 && cashbk.RaiseDynamic == false)
                {
                    double OrdAmt = HG_Orders.OrderAmt(ObjOrder.OID, ObjOrder.DeliveryCharge);
                    // cashBkAmt = OrdAmt * cashbk.Percentage / 100;
                    if (OrdAmt > cashbk.BilAmt && cashbk.MaxCBLimit == 0)//unlimited;
                    {
                        cashBkAmt = OrdAmt * cashbk.Percentage / 100;
                    }
                    else if (OrdAmt > cashbk.BilAmt && cashbk.MaxCBLimit == 1)// limited
                    {
                        cashBkAmt = OrdAmt * cashbk.Percentage / 100;
                        if (cashBkAmt > cashbk.MaxAmt)
                        {
                            cashBkAmt = cashbk.MaxAmt;
                        }
                    }
                }


                if (cashBkAmt > 0)
                {
                    Wallet wallet = new Wallet();
                    wallet.AmtActiveOn = DateTime.Now.AddDays(1);
                    wallet.CID         = (int)ObjOrder.CID;
                    wallet.OID         = ObjOrder.OID;
                    wallet.OrgId       = ObjOrder.OrgId;
                    wallet.DeductedAmt = 0;
                    wallet.CashBkAmt   = cashBkAmt;
                    wallet.CashBkId    = cashbk.CashBkId;
                    wallet.Save();
                    string[] topics = { ObjOrder.CID.ToString() };
                    string   Title  = "foodDo";
                    string   Msg    = "You Got " + cashBkAmt.ToString("0.00") + " Rs/- Cashback ";
                    PushNotification.SendNotification(topics, Msg, Title, OID: ObjOrder.OID, UserRating: 400);//user-Rating 400 for cashbk notification
                }
            }
        }