Exemplo n.º 1
0
        /// <summary>
        /// 担保交易(金币)支付,生成结算单
        /// </summary>
        public static SettleAccounts CreateSettleAccount(ContextSession contextSession, CommodityOrder commodityOrder)
        {
            // 未加入场馆的不生成结算单
            if (!commodityOrder.EsAppId.HasValue)
            {
                return(null);
            }

            if (!CheckPayType(commodityOrder))
            {
                return(null);
            }

            var parSources = PaySource.GetPaymentByTradeType(0);

            if (commodityOrder.Payment != 0)
            {
                LogHelper.Warn("担保交易(金币)支付,生成结算单失败,该订单:[" + commodityOrder.Id + "]非金币支付。");
                return(null);
            }

            // 查询场馆信息
            var mall = MallApply.ObjectSet().Where(m => m.AppId == commodityOrder.AppId && m.EsAppId == commodityOrder.EsAppId && (m.State.Value == 2 || m.State.Value == 4)).FirstOrDefault();

            if (mall == null)
            {
                LogHelper.Info("生成结算项失败,商城中未找到该APP,订单ID:" + commodityOrder.Id);
                return(null);
            }
            return(CreateSettleAccount(contextSession, commodityOrder, mall));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,Name,FullName,ValidThru,Balance,Group")] PaySource paySource)
        {
            if (id != paySource.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(paySource);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PaySourceExists(paySource.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(paySource));
        }
Exemplo n.º 3
0
        public static void CheckInpaymentSumAndAjustPaySource(FamilyFinancesContext context, Inpayment inpayment)
        {
            var       originalSum = (decimal)context.Entry(inpayment).GetDatabaseValues().GetValue <object>("Sum");
            var       currentSum  = context.Entry(inpayment).Property(x => x.Sum).CurrentValue;
            PaySource paySource   = context.PaySources.Find(inpayment.PaySourceID);

            SetNewBalance(context, paySource, paySource.Balance - originalSum + currentSum);
        }
Exemplo n.º 4
0
        public static void CheckExpenseSumAndAjustPaySource(FamilyFinancesContext context, Expense expense)
        {
            var       originalSum = (decimal)context.Entry(expense).GetDatabaseValues().GetValue <object>("Sum");
            var       currentSum  = context.Entry(expense).Property(x => x.Sum).CurrentValue;
            PaySource paySource   = context.PaySources.Find(expense.PaySourceID);

            SetNewBalance(context, paySource, paySource.Balance + originalSum - currentSum);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 游戏中真实消费(充值)的时候调用此方法
        /// </summary>
        /// <param name="cash">本次消费金额</param>
        /// <param name="source">来源</param>
        /// <param name="coin">本次消费等值的虚拟币</param>
        public static void Pay(double cash, PaySource source, double coin)
        {
#if UNITY_EDITOR
            //Debug.Log("Pay");
#elif UNITY_IPHONE
            _PayCashForCoin(cash, (int)source, coin);
#elif UNITY_ANDROID
            Agent.CallStatic("pay", cash, coin, (int)source);
#endif
        }
Exemplo n.º 6
0
        /// <summary>
        /// 玩家支付货币购买道具
        /// </summary>
        /// <param name="cash">真实货币数量</param>
        /// <param name="source">支付渠道</param>
        /// <param name="item">道具名称</param>
        /// <param name="amount">道具数量</param>
        /// <param name="price">道具单价</param>
        public static void Pay(double cash, PaySource source, string item, int amount, double price)
        {
#if UNITY_EDITOR
            //Debug.Log("Pay");
#elif UNITY_IPHONE
            _PayCashForItem(cash, (int)source, item, amount, price);
#elif UNITY_ANDROID
            Agent.CallStatic("pay", cash, item, amount, price, (int)source);
#endif
        }
Exemplo n.º 7
0
        public async Task <IActionResult> Create([Bind("ID,Name,FullName,ValidThru,Balance,Group")] PaySource paySource)
        {
            if (ModelState.IsValid)
            {
                _context.Add(paySource);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(paySource));
        }
Exemplo n.º 8
0
        public static bool CheckPayType(CommodityOrder commodityOrder)
        {
            var paySources = PaySource.GetPaymentByTradeType(0);

            if (paySources.Contains(commodityOrder.Payment))
            {
                return(true);
            }
            LogHelper.Warn("担保交易(金币)支付,生成结算单失败,该订单:[" + commodityOrder.Id + "]非担保交易。");
            return(false);
        }
Exemplo n.º 9
0
        public ActionResult DeleteConfirmed(int id)
        {
            PaySource entity = _paySourceService.GetById(id);

            if (entity != null)
            {
                _paySourceService.Remove(entity);
            }

            Success($"<strong>{entity.Description}</strong> was successfully deleted.");
            return(RedirectToAction("Index"));
        }
Exemplo n.º 10
0
        // GET: PaySources/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            PaySource entity = _paySourceService.GetById(id.Value);

            if (entity == null)
            {
                return(HttpNotFound());
            }
            return(View(entity));
        }
Exemplo n.º 11
0
        private static void SetNewBalance(FamilyFinancesContext context, PaySource paySource, decimal newBalance)
        {
            int?group = paySource.Group;

            if (group != null)
            {
                foreach (var ps in context.PaySources.Where(p => p.Group == group))
                {
                    ps.Balance = newBalance;
                }
            }
            else
            {
                paySource.Balance = newBalance;
            }
        }
Exemplo n.º 12
0
        // GET: PaySources/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            PaySource entity = _paySourceService.GetById(id.Value);

            if (entity == null)
            {
                return(HttpNotFound());
            }

            var viewmodel = Mapper.Map <PaySource, PaySourceEditViewModel>(entity);

            return(View(viewmodel));
        }
Exemplo n.º 13
0
        public ActionResult Edit(PaySourceEditViewModel viewmodel)
        {
            if (ModelState.IsValid)
            {
                PaySource entity = _paySourceService.GetById(viewmodel.Id);
                if (entity == null)
                {
                    return(HttpNotFound());
                }
                Mapper.Map(viewmodel, entity);

                _paySourceService.UpdatePaySource(entity);

                Success($"<strong>{entity.Description}</strong> was successfully updated.");
                return(RedirectToAction("Index"));
            }
            return(View(viewmodel));
        }
Exemplo n.º 14
0
 /// <summary>
 /// 获取所有支付方式和描述信息。
 /// </summary>
 /// <returns></returns>
 public System.Collections.Generic.List <Jinher.AMP.BTP.Deploy.PaySourceDTO> GetAllPaySourcesExt()
 {
     try
     {
         List <PaySource> psList = PaySource.GetAllPaySources();
         if (psList == null || !psList.Any())
         {
             return(null);
         }
         List <Jinher.AMP.BTP.Deploy.PaySourceDTO> psDtoList = psList.ConvertAll(ps => ps.ToEntityData());
         return(psDtoList);
     }
     catch (Exception ex)
     {
         LogHelper.Error("GetAllPaySourcesExt异常,异常信息:", ex);
     }
     return(null);
 }
Exemplo n.º 15
0
        /// <summary>
        /// 获取所有可用支付方式。
        /// </summary>
        /// <returns></returns>
        public List <int> GetAllPayments()
        {
            List <int> paymentList = new List <int>();

            try
            {
                var pQuery = (from p in PaySource.GetAllPaySources()
                              select p.Payment).ToList();
                if (pQuery != null && pQuery.Any())
                {
                    paymentList.AddRange(pQuery);
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error("GetAllPayments异常,异常信息:", ex);
            }
            return(paymentList);
        }
Exemplo n.º 16
0
        /// <summary>
        /// 按类型获取支付方式
        /// </summary>
        /// <returns></returns>
        private List <int> GetPaymentByTradeType(int tradeType)
        {
            List <int> paymentList = new List <int>();

            try
            {
                var pQuery = (from p in PaySource.GetAllPaySources()
                              where p.TradeType == tradeType
                              select p.Payment).ToList();
                if (pQuery != null && pQuery.Any())
                {
                    paymentList.AddRange(pQuery);
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error("GetPaymentByTradeType异常,异常信息:", ex);
            }
            return(paymentList);
        }
Exemplo n.º 17
0
 /// <summary>
 /// 获取所有支付方式对应的描述信息
 /// </summary>
 /// <param name="payment">支付方式数字编号</param>
 /// <returns></returns>
 public string GetPaymentNameExt(int payment)
 {
     try
     {
         List <PaySource> psList = PaySource.GetAllPaySources();
         if (psList == null || !psList.Any())
         {
             return("");
         }
         PaySource psModel = psList.Where(ps => ps.Payment == payment).FirstOrDefault();
         if (psModel == null)
         {
             return("");
         }
         return(psModel.Name);
     }
     catch (Exception ex)
     {
         LogHelper.Error("GetPaymentNameExt异常,异常信息:", ex);
     }
     return("");
 }
Exemplo n.º 18
0
        /// <summary>
        /// 玩家支付货币购买道具
        /// </summary>
        /// <param name="cash">真实货币数量</param>
        /// <param name="source">支付渠道</param>
        /// <param name="item">道具名称</param>
        /// <param name="amount">道具数量</param>
        /// <param name="price">道具单价</param>
        public static void Pay(double cash, PaySource source, string item, int amount, double price)
        {

#if UNITY_EDITOR
            Debug.Log("Pay");
#elif UNITY_IPHONE
            _PayCashForItem(cash,(int)source,item,amount,price);
#elif UNITY_ANDROID
            Agent.CallStatic("pay",cash, item, amount, price, (int)source);
#endif
        }
Exemplo n.º 19
0
        /// <summary>
        /// 游戏中真实消费(充值)的时候调用此方法
        /// </summary>
        /// <param name="cash">本次消费金额</param>
		/// <param name="source">来源</param>
        /// <param name="coin">本次消费等值的虚拟币</param>
        public static void Pay(double cash, PaySource source, double coin)
        {

#if UNITY_EDITOR
            Debug.Log("Pay");
#elif UNITY_IPHONE
            _PayCashForCoin(cash,(int)source,coin);
#elif UNITY_ANDROID
            Agent.CallStatic("pay",cash , coin, (int)source);
#endif
        }
Exemplo n.º 20
0
        public static void Initialize(FamilyFinancesContext context)
        {
            //context.Database.EnsureCreated();

            // Look for any students.
            if (context.PurchaseCategories.Any())
            {
                return;   // DB has been seeded
            }

            // PurchaseCategory
            var purchaseCategories = new PurchaseCategory[]
            {
                new PurchaseCategory {
                    Name = "Продукты"
                },
                new PurchaseCategory {
                    Name = "Коммунальные"
                },
                new PurchaseCategory {
                    Name = "Здоровье"
                },
                new PurchaseCategory {
                    Name = "Заправки"
                },
                new PurchaseCategory {
                    Name = "Дача"
                }
            };

            foreach (PurchaseCategory pc in purchaseCategories)
            {
                context.PurchaseCategories.Add(pc);
            }
            context.SaveChanges();

            // Pay Source Types
            var paySources = new PaySource[]
            {
                new PaySource {
                    Name = "ДК", FullName = "XXXX XXXX XXXX 0256", ValidThru = "08/22"
                },
                new PaySource {
                    Name = "КК", FullName = "XXXX XXXX XXXX 3348", ValidThru = "11/20"
                },
                new PaySource {
                    Name = "Счет", FullName = "Мастер счет в рублях"
                },
                new PaySource {
                    Name = "Наличные"
                },
            };

            foreach (PaySource ps in paySources)
            {
                context.PaySources.Add(ps);
            }
            context.SaveChanges();


            // Expences
            var expences = new Expense[]
            {
                new Expense {
                    TimeStamp = DateTime.Parse("2020-07-03"), Sum = Decimal.Parse("569.70"),
                    Purchase  = "Дикси", PaySource = paySources.Single(x => x.Name == "ДК"), Category = purchaseCategories.Single(x => x.Name == "Продукты")
                },
                new Expense {
                    TimeStamp = DateTime.Parse("2020-07-03"), Sum = Decimal.Parse("110.00"),
                    Purchase  = "Колобок", PaySource = paySources.Single(x => x.Name == "ДК"), Category = purchaseCategories.Single(x => x.Name == "Продукты")
                },
                new Expense {
                    TimeStamp = DateTime.Parse("2020-07-06"), Sum = Decimal.Parse("100.00"),
                    Purchase  = "На даче", PaySource = paySources.Single(x => x.Name == "Наличные"), Category = purchaseCategories.Single(x => x.Name == "Продукты")
                },
                new Expense {
                    TimeStamp = DateTime.Parse("2020-07-06"), Sum = Decimal.Parse("164.00"),
                    Purchase  = "Колобок", PaySource = paySources.Single(x => x.Name == "КК"), Category = purchaseCategories.Single(x => x.Name == "Продукты")
                }
            };

            foreach (Expense e in expences)
            {
                context.Expenses.Add(e);
            }
            context.SaveChanges();


            /*
             * var instructors = new Instructor[]
             * {
             *  new Instructor { FirstMidName = "Kim",     LastName = "Abercrombie",
             *      HireDate = DateTime.Parse("1995-03-11") },
             *  new Instructor { FirstMidName = "Fadi",    LastName = "Fakhouri",
             *      HireDate = DateTime.Parse("2002-07-06") },
             *  new Instructor { FirstMidName = "Roger",   LastName = "Harui",
             *      HireDate = DateTime.Parse("1998-07-01") },
             *  new Instructor { FirstMidName = "Candace", LastName = "Kapoor",
             *      HireDate = DateTime.Parse("2001-01-15") },
             *  new Instructor { FirstMidName = "Roger",   LastName = "Zheng",
             *      HireDate = DateTime.Parse("2004-02-12") }
             * };
             *
             * foreach (Instructor i in instructors)
             * {
             *  context.Instructors.Add(i);
             * }
             * context.SaveChanges();
             *
             * var departments = new Department[]
             * {
             *  new Department { Name = "English",     Budget = 350000,
             *      StartDate = DateTime.Parse("2007-09-01"),
             *      InstructorID  = instructors.Single( i => i.LastName == "Abercrombie").ID },
             *  new Department { Name = "Mathematics", Budget = 100000,
             *      StartDate = DateTime.Parse("2007-09-01"),
             *      InstructorID  = instructors.Single( i => i.LastName == "Fakhouri").ID },
             *  new Department { Name = "Engineering", Budget = 350000,
             *      StartDate = DateTime.Parse("2007-09-01"),
             *      InstructorID  = instructors.Single( i => i.LastName == "Harui").ID },
             *  new Department { Name = "Economics",   Budget = 100000,
             *      StartDate = DateTime.Parse("2007-09-01"),
             *      InstructorID  = instructors.Single( i => i.LastName == "Kapoor").ID }
             * };
             *
             * foreach (Department d in departments)
             * {
             *  context.Departments.Add(d);
             * }
             * context.SaveChanges();
             *
             * var courses = new Course[]
             * {
             *  new Course {CourseID = 1050, Title = "Chemistry",      Credits = 3,
             *      DepartmentID = departments.Single( s => s.Name == "Engineering").DepartmentID
             *  },
             *  new Course {CourseID = 4022, Title = "Microeconomics", Credits = 3,
             *      DepartmentID = departments.Single( s => s.Name == "Economics").DepartmentID
             *  },
             *  new Course {CourseID = 4041, Title = "Macroeconomics", Credits = 3,
             *      DepartmentID = departments.Single( s => s.Name == "Economics").DepartmentID
             *  },
             *  new Course {CourseID = 1045, Title = "Calculus",       Credits = 4,
             *      DepartmentID = departments.Single( s => s.Name == "Mathematics").DepartmentID
             *  },
             *  new Course {CourseID = 3141, Title = "Trigonometry",   Credits = 4,
             *      DepartmentID = departments.Single( s => s.Name == "Mathematics").DepartmentID
             *  },
             *  new Course {CourseID = 2021, Title = "Composition",    Credits = 3,
             *      DepartmentID = departments.Single( s => s.Name == "English").DepartmentID
             *  },
             *  new Course {CourseID = 2042, Title = "Literature",     Credits = 4,
             *      DepartmentID = departments.Single( s => s.Name == "English").DepartmentID
             *  },
             * };
             *
             * foreach (Course c in courses)
             * {
             *  context.Courses.Add(c);
             * }
             * context.SaveChanges();
             *
             * var officeAssignments = new OfficeAssignment[]
             * {
             *  new OfficeAssignment {
             *      InstructorID = instructors.Single( i => i.LastName == "Fakhouri").ID,
             *      Location = "Smith 17" },
             *  new OfficeAssignment {
             *      InstructorID = instructors.Single( i => i.LastName == "Harui").ID,
             *      Location = "Gowan 27" },
             *  new OfficeAssignment {
             *      InstructorID = instructors.Single( i => i.LastName == "Kapoor").ID,
             *      Location = "Thompson 304" },
             * };
             *
             * foreach (OfficeAssignment o in officeAssignments)
             * {
             *  context.OfficeAssignments.Add(o);
             * }
             * context.SaveChanges();
             *
             * var courseInstructors = new CourseAssignment[]
             * {
             *  new CourseAssignment {
             *      CourseID = courses.Single(c => c.Title == "Chemistry" ).CourseID,
             *      InstructorID = instructors.Single(i => i.LastName == "Kapoor").ID
             *      },
             *  new CourseAssignment {
             *      CourseID = courses.Single(c => c.Title == "Chemistry" ).CourseID,
             *      InstructorID = instructors.Single(i => i.LastName == "Harui").ID
             *      },
             *  new CourseAssignment {
             *      CourseID = courses.Single(c => c.Title == "Microeconomics" ).CourseID,
             *      InstructorID = instructors.Single(i => i.LastName == "Zheng").ID
             *      },
             *  new CourseAssignment {
             *      CourseID = courses.Single(c => c.Title == "Macroeconomics" ).CourseID,
             *      InstructorID = instructors.Single(i => i.LastName == "Zheng").ID
             *      },
             *  new CourseAssignment {
             *      CourseID = courses.Single(c => c.Title == "Calculus" ).CourseID,
             *      InstructorID = instructors.Single(i => i.LastName == "Fakhouri").ID
             *      },
             *  new CourseAssignment {
             *      CourseID = courses.Single(c => c.Title == "Trigonometry" ).CourseID,
             *      InstructorID = instructors.Single(i => i.LastName == "Harui").ID
             *      },
             *  new CourseAssignment {
             *      CourseID = courses.Single(c => c.Title == "Composition" ).CourseID,
             *      InstructorID = instructors.Single(i => i.LastName == "Abercrombie").ID
             *      },
             *  new CourseAssignment {
             *      CourseID = courses.Single(c => c.Title == "Literature" ).CourseID,
             *      InstructorID = instructors.Single(i => i.LastName == "Abercrombie").ID
             *      },
             * };
             *
             * foreach (CourseAssignment ci in courseInstructors)
             * {
             *  context.CourseAssignments.Add(ci);
             * }
             * context.SaveChanges();
             *
             * var enrollments = new Enrollment[]
             * {
             *  new Enrollment {
             *      StudentID = students.Single(s => s.LastName == "Alexander").ID,
             *      CourseID = courses.Single(c => c.Title == "Chemistry" ).CourseID,
             *      Grade = Grade.A
             *  },
             *      new Enrollment {
             *      StudentID = students.Single(s => s.LastName == "Alexander").ID,
             *      CourseID = courses.Single(c => c.Title == "Microeconomics" ).CourseID,
             *      Grade = Grade.C
             *      },
             *      new Enrollment {
             *      StudentID = students.Single(s => s.LastName == "Alexander").ID,
             *      CourseID = courses.Single(c => c.Title == "Macroeconomics" ).CourseID,
             *      Grade = Grade.B
             *      },
             *      new Enrollment {
             *          StudentID = students.Single(s => s.LastName == "Alonso").ID,
             *      CourseID = courses.Single(c => c.Title == "Calculus" ).CourseID,
             *      Grade = Grade.B
             *      },
             *      new Enrollment {
             *          StudentID = students.Single(s => s.LastName == "Alonso").ID,
             *      CourseID = courses.Single(c => c.Title == "Trigonometry" ).CourseID,
             *      Grade = Grade.B
             *      },
             *      new Enrollment {
             *      StudentID = students.Single(s => s.LastName == "Alonso").ID,
             *      CourseID = courses.Single(c => c.Title == "Composition" ).CourseID,
             *      Grade = Grade.B
             *      },
             *      new Enrollment {
             *      StudentID = students.Single(s => s.LastName == "Anand").ID,
             *      CourseID = courses.Single(c => c.Title == "Chemistry" ).CourseID
             *      },
             *      new Enrollment {
             *      StudentID = students.Single(s => s.LastName == "Anand").ID,
             *      CourseID = courses.Single(c => c.Title == "Microeconomics").CourseID,
             *      Grade = Grade.B
             *      },
             *  new Enrollment {
             *      StudentID = students.Single(s => s.LastName == "Barzdukas").ID,
             *      CourseID = courses.Single(c => c.Title == "Chemistry").CourseID,
             *      Grade = Grade.B
             *      },
             *      new Enrollment {
             *      StudentID = students.Single(s => s.LastName == "Li").ID,
             *      CourseID = courses.Single(c => c.Title == "Composition").CourseID,
             *      Grade = Grade.B
             *      },
             *      new Enrollment {
             *      StudentID = students.Single(s => s.LastName == "Justice").ID,
             *      CourseID = courses.Single(c => c.Title == "Literature").CourseID,
             *      Grade = Grade.B
             *      }
             * };
             *
             * foreach (Enrollment e in enrollments)
             * {
             *  var enrollmentInDataBase = context.Enrollments.Where(
             *      s =>
             *              s.Student.ID == e.StudentID &&
             *              s.Course.CourseID == e.CourseID).SingleOrDefault();
             *  if (enrollmentInDataBase == null)
             *  {
             *      context.Enrollments.Add(e);
             *  }
             * }
             * context.SaveChanges();
             */
        }
Exemplo n.º 21
0
 public void AddPaySource(PaySource paySource)
 {
     _paySourceRepoitory.Add(paySource);
     _unitOfWork.Commit();
 }
Exemplo n.º 22
0
 public static void Pay(double cash, PaySource source, string item, int amount, double price)
 {
     object[] args = new object[] { cash, item, amount, price, (int)source };
     Analytics.Agent.CallStatic("pay", args);
 }
Exemplo n.º 23
0
 public static void Pay(double cash, PaySource source, double coin)
 {
     object[] args = new object[] { cash, coin, (int)source };
     Analytics.Agent.CallStatic("pay", args);
 }
Exemplo n.º 24
0
 public void Remove(PaySource paySource)
 {
     _paySourceRepoitory.Delete(paySource);
     _unitOfWork.Commit();
 }
Exemplo n.º 25
0
 public void UpdatePaySource(PaySource paySource)
 {
     _paySourceRepoitory.Update(paySource);
     _unitOfWork.Commit();
 }