Example #1
0
 public CommonForm(OrderEntity orderEntity)
     : this()
 {
     this.orderEntity = orderEntity;
     OrderSource = CommonFunction.GetOrderSource(orderEntity.Entity.GetType());
     Order order = ControlGenerator.GetOrder(orderEntity.OrderType);
     InitData(order);
     InitControl(order);
 }
Example #2
0
        public CommonForm(OrderEntity orderEntity)
            : this()
        {
            this.orderEntity = orderEntity;
            OrderSource      = CommonFunction.GetOrderSource(orderEntity.Entity.GetType());
            Order order = ControlGenerator.GetOrder(orderEntity.OrderType);

            InitData(order);
            InitControl(order);
        }
Example #3
0
        /// <summary>
        /// Orders manager
        /// </summary>
        /// <param name="source">Orders source</param>
        /// <param name="orderPrefix">Select prefix if you want to distinguish orders</param>
        /// <param name="targetPair">Select target pair, if you want to filter monitored orders</param>
        public CryptoOrders(IOrderSource source, long?orderPrefix = null, string targetPair = null)
        {
            CryptoValidations.ValidateInput(source, nameof(source));

            _source            = source;
            TargetPair         = CryptoPairsHelper.Clean(targetPair);
            TargetPairOriginal = targetPair;
            _source.SetExistingOrders(_idToOrder);
            _orderPrefix = orderPrefix;

            Subscribe();
        }
Example #4
0
        public CForm(OrderEntity source)
        {
            orderEntity = source;

            Type type = typeof(OrderSource <>).MakeGenericType(new Type[] { source.OrderType });

            OrderSource = Activator.CreateInstance(type) as IOrderSource;

            if (string.IsNullOrEmpty(source.OrderID))
            {
                OperationType = OperationTypes.New;
                this.GridToolBar_Delete.Visibility = Visibility.Collapsed;
            }
            else
            {
                OperationType = OperationTypes.Edit;
            }
            InitializeComponent();


            List <string[]> FInfo = new List <string[]>();

            FInfo.Add(new string[] { "单据编号", "OrderCode", "OrderCode", "0", "0" });
            FInfo.Add(new string[] { "状态", "OrderStates", "OrderStates", "0", "0" });
            FInfo.Add(new string[] { "创建人", "CreateUser", "CreateUser", "0", "0" });
            FInfo.Add(new string[] { "创建时间", "CreateDate", "CreateDate", "0", "0" });
            this.GForm.LeftFForm.Items = GetFieldItems(FInfo);
            this.GForm.LeftFForm.InitForm();

            FInfo.Clear();
            FInfo.Add(new string[] { "单据类型", "OrderType", "OrderType", "0", "0" });
            FInfo.Add(new string[] { "申请人", "Applicant", "Applicant", "3", "1" });
            FInfo.Add(new string[] { "申请部门", "AppliedDepartMent", "AppliedDepartMentData", "2", "1" });
            FInfo.Add(new string[] { "申请公司", "Company", "CompanyData", "2", "1" });
            this.GForm.RightForm.Items = GetFieldItems(FInfo);
            this.GForm.RightForm.InitForm();

            FInfo.Clear();
            FInfo.Add(new string[] { "备注", "Remark", "Remark", "4", "0" });
            this.GFormRemark.Items = GetFieldItems(FInfo);
            this.GFormRemark.InitForm();

            FInfo.Clear();
            FInfo.Add(new string[] { "编号", "SerialNumber", "75", "1" });
            FInfo.Add(new string[] { "预算项目", "ObjectName", "200", "1" });
            FInfo.Add(new string[] { "可用金额", "UsableMoney", "100", "1" });
            FInfo.Add(new string[] { "已用金额", "UsedMoney", "100", "0" });
            FInfo.Add(new string[] { "费用类型", "ChargeType", "100", "1" });
            this.AGrid.Items = GetDataGridItem(FInfo);
            this.AGrid.InitGrid();

            BindingData();
        }
Example #5
0
        public CForm(OrderEntity source)
        {
            orderEntity = source;

            Type type = typeof(OrderSource<>).MakeGenericType(new Type[] { source.OrderType });
            OrderSource = Activator.CreateInstance(type) as IOrderSource;

            if (string.IsNullOrEmpty(source.OrderID))
            {
                OperationType = OperationTypes.New;
                this.GridToolBar_Delete.Visibility = Visibility.Collapsed;
            }
            else
            {
                OperationType = OperationTypes.Edit;
            }
            InitializeComponent();

            
            List<string[]> FInfo = new List<string[]>();
            FInfo.Add(new string[]{"单据编号", "OrderCode", "OrderCode", "0", "0"});
            FInfo.Add(new string[] { "状态", "OrderStates", "OrderStates", "0", "0" });
            FInfo.Add(new string[] { "创建人", "CreateUser", "CreateUser", "0", "0" });
            FInfo.Add(new string[] { "创建时间", "CreateDate", "CreateDate", "0", "0" });
            this.GForm.LeftFForm.Items = GetFieldItems(FInfo);
            this.GForm.LeftFForm.InitForm();

            FInfo.Clear();
            FInfo.Add(new string[] { "单据类型", "OrderType", "OrderType", "0", "0" });
            FInfo.Add(new string[] { "申请人", "Applicant", "Applicant", "3", "1" });
            FInfo.Add(new string[] { "申请部门", "AppliedDepartMent", "AppliedDepartMentData", "2", "1" });
            FInfo.Add(new string[] { "申请公司", "Company", "CompanyData", "2", "1" });
            this.GForm.RightForm.Items = GetFieldItems(FInfo);
            this.GForm.RightForm.InitForm();

            FInfo.Clear();
            FInfo.Add(new string[] { "备注", "Remark", "Remark", "4", "0" });
            this.GFormRemark.Items = GetFieldItems(FInfo);
            this.GFormRemark.InitForm();

            FInfo.Clear();
            FInfo.Add(new string[] { "编号", "SerialNumber", "75", "1" });
            FInfo.Add(new string[] { "预算项目", "ObjectName", "200", "1" });
            FInfo.Add(new string[] { "可用金额", "UsableMoney", "100", "1" });
            FInfo.Add(new string[] { "已用金额", "UsedMoney", "100", "0" });
            FInfo.Add(new string[] { "费用类型", "ChargeType", "100", "1" });
            this.AGrid.Items= GetDataGridItem(FInfo);
            this.AGrid.InitGrid();

            BindingData();
        }
Example #6
0
 public OrderRepository(IOrderSource orderSource) => this.orderSource = orderSource;
Example #7
0
 public OrderRepository(IOrderSource source) => this.source = source;
        /// <summary>
        /// 新增提现订单
        /// </summary>
        /// <param name="userId">用户Id</param>
        /// <param name="withdrawAmount">提现金额</param>
        /// <param name="OrderSource">提现来源</param>
        /// <returns>返回true时,表示新增成功;反之,表示新增失败</returns>
        /// <remarks>added by jimmy,2015-7-21</remarks>
        public ResultModel AddZJ_WithdrawOrder(long userId, decimal withdrawAmount, IOrderSource OrderSource)
        {
            var result = new ResultModel();

            //事务开始进行
            using (var bt = this._database.Db.BeginTransaction())
            {
                try
                {
                    //判断用户余额是否存在数据
                    ZJ_UserBalanceModel zJUserBalanceModel = bt.ZJ_UserBalance.FindByUserID(userId);
                    if (zJUserBalanceModel == null)
                    {
                        bt.Rollback();
                        result.IsValid  = false;
                        result.Messages = new List <string>()
                        {
                            "M01"
                        };
                        return(result);
                    }
                    //判断提现余额是否大于用户余额,如果大于,则回滚
                    if (zJUserBalanceModel.ConsumeBalance < withdrawAmount)
                    {
                        bt.Rollback();
                        result.IsValid  = false;
                        result.Messages = new List <string>()
                        {
                            "M02"
                        };
                        return(result);
                    }
                    //获取用户银行账户信息
                    dynamic bank;
                    List <YH_UserBankAccountModel> userbankList = bt.YH_UserBankAccount.FindAll(bt.YH_UserBankAccount.UserID == userId && bt.YH_UserBankAccount.IsUse == 1).
                                                                  LeftJoin(bt.BD_Bank, out bank).On(bt.YH_UserBankAccount.BankID == bank.BankID).
                                                                  Select(
                        bt.YH_UserBankAccount.BankID,
                        bt.YH_UserBankAccount.BankAccount,
                        bt.YH_UserBankAccount.BankSubbranch,
                        bt.YH_UserBankAccount.BankUserName,
                        bank.BankName
                        );
                    if (userbankList == null || userbankList.Count == 0)
                    {
                        bt.Rollback();
                        result.IsValid  = false;
                        result.Messages = new List <string>()
                        {
                            "M03"
                        };                                             //M03表示用户不存在银行账户信息
                        return(result);
                    }


                    //新增提现订单
                    dynamic recordWithdraw = new SimpleRecord();
                    long    OrderNo        = MemCacheFactory.GetCurrentMemCache().Increment("commonId");
                    recordWithdraw.OrderNO            = OrderNo;
                    recordWithdraw.UserID             = userId;
                    recordWithdraw.WithdrawAmount     = withdrawAmount;
                    recordWithdraw.WithdrawCommission = 0;
                    recordWithdraw.WithdrawDT         = DateTime.Now;
                    recordWithdraw.BankAccount        = userbankList[0].BankAccount;
                    recordWithdraw.BankName           = userbankList[0].BankName;
                    recordWithdraw.BankSubbranch      = userbankList[0].BankSubbranch;
                    recordWithdraw.BankUserName       = userbankList[0].BankUserName;
                    recordWithdraw.IsDisplay          = 1;
                    recordWithdraw.WithdrawResult     = (int)IWithdrawResult.ToAudit;
                    recordWithdraw.OrderSource        = (int)OrderSource;

                    bt.ZJ_WithdrawOrder.Insert(recordWithdraw);

                    bt.Commit();
                    result.Data = OrderNo;
                }
                catch (Exception ex)
                {
                    //todo错误日志记录

                    bt.Rollback();
                    result.IsValid = false;
                    result.Messages.Add(ex.Message);
                    throw;
                }
            }
            return(result);
        }