コード例 #1
0
ファイル: MemberMsController.cs プロジェクト: WeyproHDZ/HEO
        public ActionResult AddViprecord(Viprecord viprecord, Guid Vipdetailid)
        {
            Vipdetail vipdetail  = vipdetailService.GetByID(Vipdetailid);
            Viprecord old_record = viprecordService.Get().Where(a => a.Status == 2).OrderByDescending(o => o.Enddate).FirstOrDefault(a => a.Memberid == viprecord.Memberid);
            DateTime  now        = DateTime.Now;

            if (TryUpdateModel(viprecord, new string[] { "Payway", "Status" }) && ModelState.IsValid)
            {
                viprecord.Viprecordid   = Guid.NewGuid();
                viprecord.Createdate    = DateTime.Now;
                viprecord.Updatedate    = DateTime.Now;
                viprecord.Enddate       = DateTime.Now;
                viprecord.Day           = vipdetail.Day;
                viprecord.Money         = vipdetail.Money;
                viprecord.Depositnumber = DateTime.Now.ToString("yyyyMMddHHmmssfff");
                double day = Convert.ToDouble(viprecord.Day);

                /*** 如果有完成付款,就將開始日期填入今天,填寫付款方式,並且將該會員之層級提升至VIP ***/
                if (viprecord.Status == 2)
                {
                    /** 假設沒有舊資料,就直接新增進去 **/
                    if (old_record != null)
                    {
                        if (old_record.Enddate > now)
                        {
                            viprecord.Enddate   = old_record.Enddate.AddDays(day);
                            viprecord.Startdate = old_record.Enddate;
                        }
                        else
                        {
                            viprecord.Enddate   = DateTime.Now.AddDays(day);
                            viprecord.Startdate = DateTime.Now;
                        }
                    }
                    else
                    {
                        viprecord.Enddate   = DateTime.Now.AddDays(day);
                        viprecord.Startdate = DateTime.Now;
                    }

                    Members     Member      = membersService.GetByID(viprecord.Memberid);
                    Memberlevel Memberlevel = memberlevelService.Get().Where(a => a.Levelname == "VIP").FirstOrDefault();
                    Member.Levelid = Memberlevel.Levelid;
                    membersService.SpecificUpdate(Member, new string[] { "Levelid" });
                    membersService.SaveChanges();
                }
                viprecordService.Create(viprecord);
                viprecordService.SaveChanges();
            }

            return(RedirectToAction("Viprecord"));
        }
コード例 #2
0
ファイル: DepositMsController.cs プロジェクト: WeyproHDZ/HEO
        public ActionResult Deposit(Viprecord viprecord)
        {
            Vipdetail data     = vipdetailService.Get().Where(a => a.Money == viprecord.Money).FirstOrDefault();
            Guid      Memberid = Guid.Parse((Session["Memberid"]).ToString());

            if (TryUpdateModel(viprecord, new string[] { "Money", "Payway" }) && ModelState.IsValid)
            {
                viprecord.Viprecordid   = Guid.NewGuid();
                viprecord.Memberid      = Memberid;
                viprecord.Depositnumber = DateTime.Now.ToString("yyyyMMddHHmmssfff");
                viprecord.Day           = data.Day;
                viprecord.Enddate       = DateTime.Now;                 // VIP截止日期,因客戶還沒進行繳費,所以將日期寫現在
                viprecord.Buydate       = DateTime.Now;                 // 購買日期
                viprecord.Createdate    = DateTime.Now;                 // 建立時間
                viprecord.Updatedate    = DateTime.Now;                 // 更新時間
                viprecordService.Create(viprecord);
                viprecordService.SaveChanges();
            }

            string CustomerURL = "http://heohelp.com/DepositMs/DepositSuccess";
            string NotifyURL   = "http://heohelp.com/DepositMs/DepositReceive";

            int TimeStamp = (int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;       // 總秒數

            Newebpay.set_paramer(viprecord, CustomerURL, NotifyURL, TimeStamp);
            return(RedirectToAction("DepositForm"));
        }