Ejemplo n.º 1
0
        public ActionResult Index()
        {
            List <Preferential> pft = new PreferentialRepository().getAll();


            return(View(pft));
        }
Ejemplo n.º 2
0
 public ActionResult Delete(int?id)
 {
     if (!id.HasValue)
     {
         return(RedirectToAction("Index"));
     }
     else
     {
         //var category = this.newsRepository.Get(id.Value);
         var mall = new PreferentialRepository().Get((int)id);
         return(View(mall));
     }
 }
        public ActionResult Index()
        {
            List <PProductViewModel> pam = new List <PProductViewModel>();

            ViewData["cfgUnit"] = new UnitsRepository().getAll();
            List <Product>      pd  = new MallRepository().getAll().ToList();
            List <Preferential> pft = new PreferentialRepository().getAllvaild();

            foreach (var p in pd)
            {
                PProductViewModel pm = new PProductViewModel();
                pm.id             = p.id;
                pm.image          = p.image;
                pm.inpdate        = p.inpdate;
                pm.Price          = p.Price;
                pm.ProductContent = p.ProductContent;
                pm.transform      = p.transform;
                pm.type           = p.type;
                pm.unitSn         = p.unitSn;
                pm.valid          = p.valid;
                pm.ProductName    = p.ProductName;
                pm.createDate     = p.createDate;



                if (p.type == 1 || p.type == 2)
                {
                    if (pft.Where(x => x.offerModel == 3 && x.productId == null).FirstOrDefault() != null)
                    {
                        pm.offer = pft.Where(x => x.offerModel == 3 && x.productId == null).FirstOrDefault().offer;
                        pm.Pname = pft.Where(x => x.offerModel == 3 && x.productId == null).FirstOrDefault().Pname;
                    }

                    foreach (var pt in pft.Where(x => x.offerModel == 3))
                    {
                        if (pt.productId == p.id)
                        {
                            pm.offer = pt.offer;
                            pm.Pname = pt.Pname;
                        }
                    }
                }

                pam.Add(pm);
            }
            //new MailServiceMailgun().ChangeSend("熊i猜兌獎通知信", "test","*****@*****.**", "");
            ViewData["ProductM"] = new MallRepository().PMenuGetAll();
            return(View(pam));
        }
Ejemplo n.º 4
0
        public ActionResult Login(string returnUrl, string message, int?log)
        {
            if (string.IsNullOrEmpty(User.Identity.GetUserId()))
            {
                ViewBag.ReturnUrl = returnUrl;
                if (message != "")
                {
                    ViewData["Message"] = message;
                }

                if (log == 1)
                {
                    ViewBag.log = log;
                }
                return(View());
            }
            else
            {
                PreferentialRecords pr = new PreferentialRepository().getPRecordsType(User.Identity.GetUserId(), 100);
                if (log == 1)
                {
                    ViewBag.log = log;
                }

                if (pr == null && log == 1)
                {
                    var prm = new PreferentialRecords
                    {
                        UserId         = User.Identity.GetUserId(),
                        Count          = 0,
                        inpdate        = DateTime.Now,
                        PreferentialID = 100
                    };

                    new PreferentialRepository().PRecordsCreate(prm);
                    var ar = new AssetsRecord
                    {
                        UserId  = User.Identity.GetUserId(),
                        unitSn  = 1,
                        assets  = 5000,
                        type    = 2,
                        inpdate = DateTime.Now
                    };
                    new AssetsRepository().AddAssetsByAssets(ar);
                    return(RedirectToAction("Index", "Manage", new { Log = "已贈送5000魚骨幣至您的帳戶" }));
                }
                return(RedirectToAction("Index", "Manage"));
            }
        }
Ejemplo n.º 5
0
 public string FirstAssets(int money)
 {
     try
     {
         //var preferential = new PreferentialRepository().Get((int)id);
         var pft = new PreferentialRepository().Get(1);
         pft.assets = money;
         new PreferentialRepository().Update(pft);
         return("1");
     }
     catch
     {
         return("0");
     }
 }
Ejemplo n.º 6
0
 public ActionResult DeleteConfirmed(int?id)
 {
     try
     {
         // TODO: Add delete logic here
         var mall = new PreferentialRepository().Get((int)id);
         new PreferentialRepository().Delete(mall);
         return(RedirectToAction("Index"));
     }
     catch (DataException)
     {
         return(RedirectToAction("Delete", new { id = id }));
     }
     //return RedirectToAction("Mall");
 }
Ejemplo n.º 7
0
        public ActionResult Edit(int id)
        {
            var preferential = new PreferentialRepository().Get((int)id);

            return(View(preferential));
        }
        public ActionResult bluenewRequest(SpGatewayResponse response)
        {
            //正式
            response.Vi  = "PmNER6HP23jikkcC";
            response.Key = "382go6Z9UrDy3XBuJnCHzNusEYFnBfls";

            //test
            //response.Key = "CON3KthrvPulsAWQQiQ3jsswLIzxxgQK";
            //response.Vi = "ugZbqRhI6x5LGI94";

            //test
            //var success = response.Validate("MS15822085");

            //正式
            var success = response.Validate("MS3276146654");

            if (success)
            {
                var tradInfoModel = response.GetResponseModel <TradeInfoModel>();
                var resuccess     = true;
                //var OrderNoToProuctId = tradInfoModel.Result.MerchantOrderNo.OrderNoToProuctId();
                var wait = new InvoiceRepository().GetWait(tradInfoModel.Result.MerchantOrderNo);
                var inv  = new InvoiceRepository().GetInvoice(wait.id);
                if (inv != null)
                {
                    resuccess = false;
                }

                if (resuccess)
                {
                    User_CashReturn user         = new MallRepository().GetUserPRecord(tradInfoModel.Result.MerchantOrderNo);
                    Product         productModel = new MallRepository().Get((int)user.productId);
                    Order           order        = new Order
                    {
                        UserId            = user.userId,
                        ProductId         = productModel.id,
                        Pay               = tradInfoModel.Result.PaymentType,
                        Order_No          = tradInfoModel.Result.MerchantOrderNo,
                        PayStore          = tradInfoModel.Result.PayStore,
                        Barcode_1         = tradInfoModel.Result.Barcode_1,
                        Barcode_2         = tradInfoModel.Result.Barcode_2,
                        Barcode_3         = tradInfoModel.Result.Barcode_3,
                        PayBankCode       = tradInfoModel.Result.PayBankCode,
                        CodeNo            = tradInfoModel.Result.CodeNo,
                        PayerAccount5Code = tradInfoModel.Result.PayerAccount5Code,
                        inpdate           = tradInfoModel.Result.PayTime
                    };

                    //加入購物記錄
                    var reutrnorder = new MallRepository().OrderCreate(order);



                    ProductRecord assr = new ProductRecord
                    {
                        UserID    = user.userId,
                        unitSn    = 1,
                        assets    = productModel.transform,
                        inpdate   = DateTime.Now,
                        type      = 1,
                        ProductId = productModel.id
                    };
                    new AssetsRepository().AddBearByAssets(assr);

                    var pr = new PreferentialRepository().getPRecordsAll(user.userId).Where(x => x.PreferentialID == 5 && x.productID == productModel.id).FirstOrDefault();
                    //2倍

                    /*
                     * if (pr.Count != 0)
                     * {
                     *  assr = new ProductRecord
                     *  {
                     *      UserID = user.userId,
                     *      unitSn = 1,
                     *      assets = productModel.transform,
                     *      inpdate = DateTime.Now,
                     *      type = 5,
                     *      ProductId = productModel.id
                     *  };
                     *  new AssetsRepository().AddBearByAssets(assr);
                     *  var prds = new PreferentialRecords
                     *  {
                     *      id = pr.id,
                     *      UserId = user.userId,
                     *      Count = 0,
                     *      inpdate = DateTime.Now,
                     *      PreferentialID = pr.PreferentialID,
                     *      productID = pr.productID
                     *  };
                     *  new PreferentialRepository().PRecordsUpdate(prds);
                     * }*/



                    //普通首儲

                    /*if(pr.Count != 0)
                     * {
                     *  assr = new ProductRecord
                     *  {
                     *      UserID = user.userId,
                     *      unitSn = 1,
                     *      assets = new PreferentialRepository().getpreferential(1).assets,
                     *      inpdate = DateTime.Now,
                     *      type = 5,
                     *      ProductId = productModel.id
                     *  };
                     *  new AssetsRepository().AddBearByAssets(assr);
                     *  var prds = new PreferentialRecords {
                     *      id = pr.id,
                     *      UserId = user.userId,
                     *      Count = 0,
                     *      inpdate = DateTime.Now,
                     *      PreferentialID = 1
                     *  };
                     *  new PreferentialRepository().PRecordsUpdate(prds);
                     * }*/
                    //InvoiceModel invoice = new InvoiceModel();
                    //發送發票
                    var smilePayEinvoice = new InvoiceRepository().invoiceSend(tradInfoModel.Result.MerchantOrderNo, productModel);

                    Invoice invoice = new Invoice
                    {
                        invoiceNumber = smilePayEinvoice.InvoiceNumber,
                        RandomNumber  = smilePayEinvoice.RandomNumber,
                        inpdate       = DateTime.Parse(smilePayEinvoice.InvoiceDate + " " + smilePayEinvoice.InvoiceTime),
                        IwaitId       = wait.id,
                        CarrierID     = smilePayEinvoice.CarrierID,
                        orderId       = reutrnorder.id
                    };


                    new InvoiceRepository().InvoiceCreate(invoice);
                }
            }
            return(View());
        }
        public int MallChange(int id, float?money, string name, string phone, string address)
        {
            var userId = User.Identity.GetUserId();
            // var malldata = new MangerRepository().GetTransferRecords(userId);
            Product product = new MallRepository().Get(id);
            // 1 現金換魚骨 -2 兌獎 -3 鮭魚換魚骨

            int offer = 100;

            List <Preferential> pft = new PreferentialRepository().getAllvaild();

            if (pft != null)
            {
                if (pft.Where(x => x.offerModel == 3 && x.productId == null).FirstOrDefault() != null)
                {
                    offer = (int)pft.Where(x => x.offerModel == 3 && x.productId == null).FirstOrDefault().offer;
                }

                foreach (var pt in pft.Where(x => x.offerModel == 3))
                {
                    if (pt.productId == id)
                    {
                        offer = (int)pft.Where(x => x.offerModel == 3 && x.productId == id).FirstOrDefault().offer;
                    }
                }
            }

            ProductRecord assr = new ProductRecord
            {
                UserID    = User.Identity.GetUserId(),
                unitSn    = product.unitSn,
                assets    = (money != null) ? -money : -product.Price * offer / 100,
                inpdate   = DateTime.Now,
                type      = (money != null)?-3:-2,
                ProductId = product.id,
                recipient = name,
                phone     = phone,
                address   = address
            };
            bool aset = new AssetsRepository().AddBearByAssets(assr);

            if (product.unitSn == 2 && product.type == 3)
            {
                assr = new ProductRecord
                {
                    UserID    = User.Identity.GetUserId(),
                    unitSn    = 1,
                    assets    = money * product.Price,
                    inpdate   = DateTime.Now,
                    type      = 3,
                    ProductId = product.id,
                    recipient = name,
                    phone     = phone,
                    address   = address
                };
                aset = new AssetsRepository().AddBearByAssets(assr);
            }
            if (money == null)
            {
                var m = Math.Ceiling((double)product.Price / 1.2 / 30000 * 30);
                var d = 0;
                if (m < 1000)
                {
                    d = 1;
                }
                else if (999 < m && m < 20000)
                {
                    d = 2;
                }
                else if (m > 19999)
                {
                    d = 3;
                }
                var    user         = UserManager.FindById(User.Identity.GetUserId());
                var    content      = ConfirmChange(d, assr, product);
                var    EmailContent = EmailTemplatesService.GetChangeEmailHTML(content);
                var    h            = Server.MapPath("\\Content\\Pdf\\Change\\");
                string url          = (product.pdf_file != null) ?  product.pdf_file : "";
                new MailServiceMailgun().ChangeSend("熊i猜兌獎通知信", EmailContent, user.Email, url);
            }



            return(aset?1:0);
        }
        public async Task <ActionResult> _MallChange(int id)
        {
            aJaxDto ajd = new aJaxDto();

            try {
                if (User.Identity.GetUserId() == null)
                {
                    ajd.ErrorMsg = "登入後才可以購買";
                    ajd.Title    = "未登入!";
                    ajd.isTrue   = true;
                    throw new Exception("error");
                }
                var user = UserManager.FindById(User.Identity.GetUserId());
                if (!user.EmailConfirmed)
                {
                    ajd.ErrorMsg = "請先至會員中心進行驗證,謝謝";
                    ajd.Title    = "Email尚未驗證!";
                    ajd.isTrue   = false;
                    throw new Exception("error");
                }
                if (!user.PhoneNumberConfirmed)
                {
                    ajd.ErrorMsg = "請先至會員中心進行驗證,謝謝";
                    ajd.Title    = "手機尚未驗證!";
                    ajd.isTrue   = false;
                    throw new Exception("error");
                }
                ProductApiModel pm = new ProductApiModel();

                Product product = new MallRepository().Get(id);
                // List<Product> productAll = new MallRepository().getAll();
                cfgUnit unit = new UnitsRepository().getValid(product.unitSn);

                pm.unit    = unit;
                pm.product = product;
                //pm.producList = productAll.Where(x => x.id < 5).ToList();
                int offer = 100;

                List <Preferential> pft = new PreferentialRepository().getAllvaild();
                ViewBag.offer = 100;
                if (pft != null)
                {
                    if (pft.Where(x => x.offerModel == 3 && x.productId == null).FirstOrDefault() != null)
                    {
                        ViewBag.offer = pft.Where(x => x.offerModel == 3 && x.productId == null).FirstOrDefault().offer;
                        offer         = (int)pft.Where(x => x.offerModel == 3 && x.productId == null).FirstOrDefault().offer;
                    }

                    foreach (var pt in pft.Where(x => x.offerModel == 3))
                    {
                        if (pt.productId == id)
                        {
                            ViewBag.offer = pt.offer;
                            offer         = (int)pft.Where(x => x.offerModel == 3 && x.productId == id).FirstOrDefault().offer;
                        }
                    }
                }

                var gold = new AssetsRepository().getAssetsListByUserID(User.Identity.GetUserId()).Where(x => x.unitSn == product.unitSn).FirstOrDefault();
                ViewBag.gold   = (gold != null) ? gold.Asset : 0;
                ViewBag.change = (product.Price * offer / 100 > ViewBag.gold) ? 0 : 1;



                return(View(pm));
            }
            catch
            {
                //ajd.isTrue = false;
                return(Json(ajd, JsonRequestBehavior.AllowGet));
            }
        }
        public ActionResult _FishPay(int id)
        {
            aJaxDto ajd = new aJaxDto();

            try
            {
                if (User.Identity.GetUserId() == null)
                {
                    ajd.ErrorMsg = "登入後才可以購買";
                    ajd.Title    = "未登入!";
                    ajd.isTrue   = true;
                    throw new Exception("error");
                }
                var user = UserManager.FindById(User.Identity.GetUserId());
                if (!user.EmailConfirmed)
                {
                    ajd.ErrorMsg = "請先至會員中心進行驗證,謝謝";
                    ajd.Title    = "Email尚未驗證!";
                    ajd.isTrue   = false;
                    throw new Exception("error");
                }
                if (!user.PhoneNumberConfirmed)
                {
                    ajd.ErrorMsg = "請先至會員中心進行驗證,謝謝";
                    ajd.Title    = "手機尚未驗證!";
                    ajd.isTrue   = false;
                    throw new Exception("error");
                }

                //var pr = new PreferentialRepository().getPRecords(User.Identity.GetUserId());

                //普通首儲

                /*if (pr == null)
                 * {
                 *  var prm = new PreferentialRecords {
                 *      UserId = User.Identity.GetUserId(),
                 *      Count = 1,
                 *      inpdate = DateTime.Now,
                 *      PreferentialID = 1
                 *  };
                 *
                 *  new PreferentialRepository().PRecordsCreate(prm);
                 *  pr = new PreferentialRepository().getPRecords(User.Identity.GetUserId());
                 * }*/
                var pr = new PreferentialRepository().getPRecordsAll(User.Identity.GetUserId()).Where(x => x.PreferentialID == 5);
                //2倍首儲
                if (pr.Count() == 0)
                {
                    var m = new MallRepository().getAll().Where(x => x.unitSn == 3 && x.type == 3).ToList();
                    foreach (var md in m)
                    {
                        var prm = new PreferentialRecords
                        {
                            UserId         = User.Identity.GetUserId(),
                            Count          = 1,
                            inpdate        = DateTime.Now,
                            PreferentialID = 5,
                            productID      = md.id
                        };

                        new PreferentialRepository().PRecordsCreate(prm);
                        //pr = new PreferentialRepository().getPRecords(User.Identity.GetUserId());
                    }
                }
                pr = new PreferentialRepository().getPRecordsAll(User.Identity.GetUserId()).Where(x => x.PreferentialID == 5);



                Product         product    = new MallRepository().Get(id);
                List <Product>  productAll = new MallRepository().getAll();
                cfgUnit         unit       = new UnitsRepository().getValid(product.unitSn);
                ProductApiModel pm         = new ProductApiModel();
                pm.unit       = unit;
                pm.product    = product;
                pm.producList = productAll.Where(x => x.unitSn == 3 && x.type == 3).ToList();

                List <int> fta = new List <int>();
                foreach (var p in pr)
                {
                    if (p.Count != 0)
                    {
                        fta.Add(1);
                    }
                    else
                    {
                        fta.Add(0);
                    }
                }
                pm.firstTypeArray = fta;
                if (pr.Where(x => x.Count != 0).Count() != 0)
                {
                    pm.firstType = 1;
                }
                else
                {
                    pm.firstType = 0;
                }
                //pm.firstType = (pr.Count != 0) ? 1 : 0;
                pm.preferential = new PreferentialRepository().getpreferential(1);
                return(View(pm));
            }
            catch
            {
                return(Json(ajd, JsonRequestBehavior.AllowGet));
            }
        }
Ejemplo n.º 12
0
        public async Task <ActionResult> Login(LoginViewModel model, string returnUrl, int?log)
        {
            if (!ModelState.IsValid || !new reCAPTCHAHelper().Validate(Request["g-recaptcha-response"]))
            {
                ViewData["Message"] = "驗證有誤,請重新登入";
                return(View(model));
            }

            // 這不會計算為帳戶鎖定的登入失敗
            // 若要啟用密碼失敗來觸發帳戶鎖定,請變更為 shouldLockout: true
            var result = await SignInManager.PasswordSignInAsync(model.Name, model.Password, model.RememberMe, shouldLockout : false);

            switch (result)
            {
            case SignInStatus.Success:
                var live = new UserRepository().getlive();
                var user = UserManager.FindByName(model.Name);

                foreach (var l in live)
                {
                    if (l.username == user.Id)
                    {
                        if (l.valid != 0)
                        {
                            ViewData["Message"] = "此為直播主帳號,無法登入。";
                            return(View(model));
                        }
                        else
                        {
                            ViewData["Message"] = "此帳號還在申請審核中。";
                            return(View(model));
                        }
                    }
                }
                string vClientIP = GetIPAddress();

                new UserRepository().CreateIP(user.Id, vClientIP);

                PreferentialRecords pr = new PreferentialRepository().getPRecordsType(user.Id, 100);



                Session["Assets"] = new AssetsRepository().getAssetsListByUserID(User.Identity.GetUserId());
                //Session["levelExp"] = new AssetsRepository().getExpByUserID(User.Identity.GetUserId());
                if (returnUrl != null)
                {
                    Response.Redirect(returnUrl);
                }

                if (pr == null && log == 1)
                {
                    var prm = new PreferentialRecords
                    {
                        UserId         = user.Id,
                        Count          = 0,
                        inpdate        = DateTime.Now,
                        PreferentialID = 100
                    };

                    new PreferentialRepository().PRecordsCreate(prm);
                    var ar = new AssetsRecord
                    {
                        UserId  = user.Id,
                        unitSn  = 1,
                        assets  = 5000,
                        type    = 2,
                        inpdate = DateTime.Now
                    };
                    new AssetsRepository().AddAssetsByAssets(ar);
                    return(RedirectToAction("Index", "Manage", new { Log = "已贈送5000魚骨幣至您的帳戶" }));
                }

                return(RedirectToAction("Index", "Home"));


            //return RedirectToLocal(returnUrl);
            case SignInStatus.LockedOut:
                return(View("Lockout"));

            case SignInStatus.RequiresVerification:
                return(RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe }));

            case SignInStatus.Failure:
            default:
                //ModelState.AddModelError("", "登入嘗試失試。");
                ViewData["Message"] = "登入嘗試失試。";
                return(View(model));
            }
        }