コード例 #1
0
ファイル: Member_VIPService.cs プロジェクト: navy235/WebSite
        public ServiceResult Create(Member_VIP model)
        {
            ServiceResult result = new ServiceResult();
            try
            {
                DB_Service.Add<Member_VIP>(model);
                DB_Service.Commit();
            }
            catch (System.Data.Entity.Validation.DbEntityValidationException ex)
            {

                result.AddServiceError(Utilities.GetInnerMostException(ex));
            }
            return result;
        }
コード例 #2
0
ファイル: Member_VIPService.cs プロジェクト: navy235/WebSite
        public ServiceResult Update(Member_VIP model)
        {
            ServiceResult result = new ServiceResult();

            try
            {
                var target = DB_Service.Set<Member_VIP>().Single(x => x.MemberID == model.MemberID);
                DB_Service.Attach<Member_VIP>(target);
                target.EndTime = model.EndTime;
                target.VipLevel = model.VipLevel;
                target.PayTime = target.PayTime + 1;
                DB_Service.Commit();
            }
            catch (System.Data.Entity.Validation.DbEntityValidationException ex)
            {

                result.AddServiceError(Utilities.GetInnerMostException(ex));
            }
            return result;
        }
コード例 #3
0
ファイル: Member_VIPService.cs プロジェクト: navy235/WebSite
        public ServiceResult PayVIP(int MemberID, ServerItem Server, PayList PayOrder)
        {
            ServiceResult result = new ServiceResult();
            try
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    Member_VIP model = new Member_VIP();
                    var vip = GetMemberVIP(MemberID, true);

                    PayStatusViewModel PayStatus = new PayStatusViewModel();
                    PayStatus.Pay_No = PayOrder.Pay_No.ToString();
                    PayStatus.Buy_Email = CookieHelper.Email;
                    PayStatus.Buy_ID = CookieHelper.UID;

                    PayStatus.Trade_No = "29038423784523849573247856";
                    PayStatus.Status = Pay_State.ApplyOk.ToString();
                    PayListService.UpdateOrder(PayStatus);

                    var Upgrade = false;
                    var MoneyType = "0201";
                    if (vip != null)
                    {
                        Server.Money = Server.Month * 10;
                        MoneyType = "0206";

                        if (vip.EndTime.CompareTo(DateTime.Now) > 0 && Server.ServerType > vip.VipLevel)
                        {
                            Upgrade = true;
                            var day = UIHelper.DateDiff(DateDiffType.Day, DateTime.Now, vip.EndTime);
                            var UpgradeMoney = day * 2;
                            Member_MoneyService.AddMoney(MemberID, Server.Money, "0202");
                        }
                    }
                    else
                    {
                        MoneyType = "0205";
                        Server.Money = Server.Month * 5;
                    }

                    Member_MoneyService.AddMoney(MemberID, Server.Money, MoneyType);

                    if (vip == null)
                    {
                        model.AddTime = DateTime.Now;
                        model.VipLevel = Server.ServerType;
                        model.StartTime = DateTime.Now;
                        model.MemberID = MemberID;
                        model.EndTime = DateTime.Now.AddMonths(Server.Month + Server.GiftMonth);
                        model.Description = PayOrder.ProductType;
                        model.PayTime = 1;
                        Create(model);
                    }
                    else
                    {
                        model.ID = vip.ID;
                        model.MemberID = MemberID;
                        model.VipLevel = Server.ServerType;
                        if (vip.EndTime.CompareTo(DateTime.Now) > 0)
                        {
                            if (Upgrade)
                            {
                                model.EndTime = DateTime.Now.AddMonths(Server.Month + Server.GiftMonth);
                            }
                            else
                            {
                                model.EndTime = vip.EndTime.AddMonths(Server.Month + Server.GiftMonth);
                            }
                        }
                        else
                        {
                            model.EndTime = DateTime.Now.AddMonths(Server.Month + Server.GiftMonth);
                        }

                        Update(model);

                    }
                    Member_MoneyService.AddMoney(MemberID, Server.GiftMoney, "0201");

                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                result.AddServiceError(Utilities.GetInnerMostException(ex));
            }
            return result;
        }