public ActionResult AddTranfer(string key, string moneyTranfer, string agencyId, string customerId)
 {
     // var model = new WalletCustomer();
     try
     {
         var wallet = new ReceiveHistory
         {
             AgencyId   = int.Parse(agencyId),
             CustomerID = int.Parse(customerId),
             DateCreate = DateTime.Now.TotalSeconds(),
             IsDeleted  = false,
             Date       = DateTime.Now.TotalSeconds(),
             Month      = DateTime.Now.Month,
             Year       = DateTime.Now.Year,
             Type       = (int)Reward.Receive1,
             Price      = decimal.Parse(moneyTranfer)
         };
         _da.Add(wallet);
         _da.Save();
         return(Json(1, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         return(Json(0, JsonRequestBehavior.AllowGet));
     }
 }
示例#2
0
        public void InsertReward(int agencyId, int customerid, decimal?price, int orderid, decimal date, decimal prizeMoney)
        {
            var customer  = _customerDa.GetCustomerAwad(customerid);
            var bonusItem = _ordersDa.GetBonusTypeItem();
            var now       = DateTime.Now.TotalSeconds();

            //Tích lũy trực tiếp
            if (bonusItem.Percent > 0)
            {
                var reward = new RewardHistory
                {
                    Price      = price * (bonusItem.Percent / 100),
                    CustomerID = customerid,
                    Date       = now,
                    OrderID    = orderid,
                    Type       = (int)Reward.Cus,
                    Percent    = bonusItem.Percent,
                    IsDeleted  = false
                };
                var json = new JavaScriptSerializer().Serialize(reward);
                _rewardHistoryApi.AddRewardLocal(json);
                //_rewardHistoryDa.Add(reward);
            }
            //Tích lũy giới thiệu
            //if (customer.ParentID != null && customer.ParentID != bonusItem.RootID)
            //{
            //    var reward1 = new RewardHistory
            //    {
            //        Price = price * (bonusItem.PercentParent / 100),
            //        CustomerID = customer.ParentID,
            //        AgencyId = Agencyid(),
            //        Date = now,
            //        OrderID = orderid,
            //        Type = (int)Reward.Parent,
            //        Percent = bonusItem.PercentParent,
            //        IsDeleted = false
            //    };
            //    var json = new JavaScriptSerializer().Serialize(reward1);
            //    _rewardHistoryApi.AddRewardLocal(json);
            //    //_rewardHistoryDa.Add(reward1);
            //}
            //trừ tích lũy
            if (prizeMoney > 0)
            {
                var recive = new ReceiveHistory
                {
                    CustomerID = customerid,
                    AgencyId   = agencyId,
                    Price      = prizeMoney,
                    Date       = now,
                    OrderID    = orderid,
                    Type       = (int)Reward.Receive1,
                    IsDeleted  = false
                };
                //_rewardHistoryDa.Add();
                var json = new JavaScriptSerializer().Serialize(recive);
                _receiveHistoryApi.AddReciveLocal(json);
            }
            //_rewardHistoryDa.Save();
        }
 public ActionResult SearchMoney(string query, int cusId)
 {
     try
     {
         var totalwalet = customerDA.GetItemByID(cusId);
         var config     = _walletCustomerDa.GetConfig();
         if (totalwalet.Wallets > 0 && totalwalet.Wallets >= config.PriceSearch)
         {
             var recive = new ReceiveHistory
             {
                 CustomerID = cusId,
                 Price      = config.PriceSearch,
                 IsActive   = true,
                 Query      = query,
                 DateCreate = DateTime.Now.TotalSeconds(),
                 Type       = 1,
             };
             _rewardHistoryDa.Add(recive);
             _rewardHistoryDa.Save();
         }
         else
         {
             if (totalwalet.TotalWallets > 0 && totalwalet.TotalWallets >= config.PriceSearch)
             {
                 var recive = new CashOutWallet()
                 {
                     CustomerID = cusId,
                     TotalPrice = config.PriceSearch,
                     DateCreate = DateTime.Now.TotalSeconds(),
                     Type       = 3,
                     Query      = query,
                 };
                 _cashOutWalletDa.Add(recive);
                 _cashOutWalletDa.Save();
             }
             else
             {
                 return(Json(new BaseResponse <List <ProductItem> > {
                     Code = 1, Message = "Ví tiền của bạn không đủ.!"
                 }, JsonRequestBehavior.AllowGet));
             }
         }
         return(Json(new BaseResponse <List <ProductItem> > {
             Code = 200, Message = ""
         }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception e)
     {
         return(Json(new BaseResponse <List <ProductItem> > {
             Code = -1, Message = e.ToString()
         }, JsonRequestBehavior.AllowGet));
     }
 }
示例#4
0
        public ActionResult Add(string key, string json)
        {
            var msg   = new JsonMessage(false, "Trả thưởng thành công.");
            var model = new ReceiveHistory();

            try
            {
                if (key != Keyapi)
                {
                    return(Json(0, JsonRequestBehavior.AllowGet));
                }
                UpdateModel(model);
                var month = model.Month ?? int.Parse(DateTime.Now.Month.ToString());
                var year  = model.Year ?? int.Parse(DateTime.Now.Year.ToString());
                var check = _da.CheckReciveHistory(month, year, model.CustomerID ?? 0, Agencyid(), model.Price ?? 0);
                if (check)
                {
                    model.DateCreate = DateTime.Now.TotalSeconds();
                    model.AgencyId   = Agencyid();
                    model.IsDeleted  = false;
                    model.Type       = 1;
                    _da.Add(model);
                    _da.Save();
                }
                else
                {
                    msg.Erros   = true;
                    msg.Message = "Trả thưởng thất bại, vui lòng kiểm tra lại.";
                }
            }
            catch (Exception ex)
            {
                msg.Erros   = true;
                msg.Message = "Trả thưởng thất bại, vui lòng kiểm tra lại.";
                Log2File.LogExceptionToFile(ex);
            }
            return(Json(msg, JsonRequestBehavior.AllowGet));
        }
示例#5
0
 public void Add(ReceiveHistory item)
 {
     FDIDB.ReceiveHistories.Add(item);
 }