Пример #1
0
        static void Main(string[] args)
        {
            var tradeStream    = Assembly.GetExecutingAssembly().GetManifestResourceStream("No7.Solution.Console.trades.txt");
            var tradeProcessor = new TradeService();

            tradeProcessor.WriteToDb(tradeProcessor.ReadFromStream(tradeStream));
        }
Пример #2
0
 // 绑定Trade的货物信息数据到送货信息Tab
 private void ReceiverGoodsDetail(string customTid)
 {
     try
     {
         Alading.Entity.Trade tradeInRow = TradeService.GetTrade(customTid);
         txtBuyerName.Text       = tradeInRow.receiver_name;
         txtMobile.Text          = tradeInRow.receiver_mobile;
         txtPhone.Text           = tradeInRow.receiver_phone;
         txtReceiverAddress.Text = tradeInRow.receiver_address;
         txtZip.Text             = tradeInRow.receiver_zip;
         memoBuyerMemo.Text      = tradeInRow.buyer_memo;
         memoBuyerMessage.Text   = tradeInRow.buyer_message;
         /* 初始化买家省市区的信息并绑定数据*/
         cmbReceiverState.Properties.Items.Clear();
         cmbReceiverCity.Properties.Items.Clear();
         cmbReceiverDistrict.Properties.Items.Clear();
         cmbReceiverState.Text    = tradeInRow.receiver_state.ToString();
         cmbReceiverCity.Text     = tradeInRow.receiver_city;
         cmbReceiverDistrict.Text = tradeInRow.receiver_district;
         //绑定物流订单数据
         BoundCompanyMessage(tradeInRow.LastShippingType);
         BoundTemplateMessage(tradeInRow.LogisticCompanyCode);
         cmbShippingCompany.EditValue  = tradeInRow.LogisticCompanyCode;
         cmbShippingTemplate.EditValue = tradeInRow.TemplateCode;
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Пример #3
0
        public async Task <CreateTradeResponseModel> SubmitUserTrade(ApiSubmitUserTradeRequest request)
        {
            var tradePair = request.TradePairId.HasValue
                                ? await TradePairReader.GetTradePair(request.TradePairId.Value).ConfigureAwait(false)
                                : await TradePairReader.GetTradePair(request.Market.Replace('/', '_')).ConfigureAwait(false);

            if (tradePair == null)
            {
                var marketName = request.TradePairId.HasValue ? request.TradePairId.ToString() : request.Market;
                return(new CreateTradeResponseModel {
                    Error = $"Market '{marketName}' not found."
                });
            }

            var totalTrade = request.Amount * request.Rate;

            if (totalTrade < tradePair.BaseMinTrade)
            {
                return new CreateTradeResponseModel {
                           Error = $"Invalid trade amount, Minimum total trade is {tradePair.BaseMinTrade} {tradePair.BaseSymbol}"
                }
            }
            ;

            var response = await TradeService.CreateTrade(request.UserId.ToString(), new CreateTradeModel
            {
                Amount      = request.Amount,
                Price       = request.Rate,
                TradePairId = tradePair.TradePairId,
                IsBuy       = request.Type == TradeHistoryType.Buy,
            }, true).ConfigureAwait(false);

            return(response);
        }
Пример #4
0
        private void BindPrice()
        {
            var list_price = new TradeService().FindNewDetails(20);

            this.Repeater_price.DataSource = list_price;
            this.Repeater_price.DataBind();
        }
Пример #5
0
        private TradeService CreateTradeService()
        {
            var userId  = Guid.Parse(User.Identity.GetUserId());
            var service = new TradeService(userId);

            return(service);
        }
        public ActionResult Admin(int employeeid)
        {
            List <TradeViewModel> Tradeviewmodellist = new List <TradeViewModel>();
            List <Trade>          employeetradelist  = TradeService.GetByEmployee(employeeid);

            using var context = new SqlLiteContext();
            List <Trade> tradelist = context.Trades.ToList();

            foreach (Trade t in tradelist)
            {
                TradeViewModel tvm = new TradeViewModel();
                tvm.TradeId    = t.TradeId;
                tvm.EmployeeId = employeeid;
                tvm.Name       = t.Name;
                tvm.Connected  = false;
                foreach (Trade te in employeetradelist)
                {
                    if (t.TradeId == te.TradeId)
                    {
                        tvm.Connected = true;
                    }
                }
                Tradeviewmodellist.Add(tvm);
            }
            var sortedlist = Tradeviewmodellist.OrderBy(foo => foo.Name).ToList();
            var model      = new BindEmployeeTradeViewModel(sortedlist);

            return(View(model));
        }
Пример #7
0
        public void CalculateVolumeWeightedStockPriceTestGivenThreeTradesTwoWithSameSymbol()
        {
            var tradeService = new TradeService();

            tradeService.Trades.Add(TestData.GetBuyTradeQty100Price50WithSymbolTEA());
            tradeService.Trades.Add(TestData.GetBuyTradeQty50Price10WithSymbolTEA());
            tradeService.Trades.Add(TestData.GetBuyTradeQty100Price50WithSymbolTEST());

            const double tradeOnePrice      = 50;
            const double tradeOneQty        = 100;
            const double tradeOneTotalValue = tradeOneQty * tradeOnePrice;

            const double tradeTwoPrice      = 10;
            const double tradeTwoQty        = 50;
            const double tradeTwoTotalValue = tradeTwoQty * tradeTwoPrice;

            const double totalValue = tradeOneTotalValue + tradeTwoTotalValue;
            const double totalQty   = tradeOneQty + tradeTwoQty;

            const double expected = totalValue / totalQty;

            var actual = tradeService.CalculateVolumeWeightedStockPrice("TEA");

            Assert.AreEqual(expected, actual);
        }
Пример #8
0
        public async Task <ApiResult <CancelOrderResponse> > CancelOrder(string userId, TradeCancelType cancelType, int?orderId, string market)
        {
            try
            {
                var result = await TradeService.QueueCancel(new CancelTradeModel
                {
                    UserId     = userId,
                    Market     = market,
                    OrderId    = orderId,
                    CancelType = cancelType,
                    IsApi      = true
                });

                if (result.HasError)
                {
                    return(new ApiResult <CancelOrderResponse>(false, result.Error));
                }

                var response = new CancelOrderResponse
                {
                    CanceledOrders = result.CanceledOrders
                };
                return(new ApiResult <CancelOrderResponse>(true, response));
            }
            catch (Exception ex)
            {
                return(new ApiResult <CancelOrderResponse>(ex));
            }
        }
Пример #9
0
        public void Initialize()
        {
            GameObjectsManager.Initialize();
            ImageManager.Initialize();
            TimeManager.Initialize();

            SaveLoadService = new SaveLoadService();
            SaveLoadService.Initialize();

            ConfigurationService = new ConfigurationService();
            ConfigurationService.Initialize();
            BuyPriceDictionaryService = new BuyPriceDictionaryService();
            BuyPriceDictionaryService.Initialize();
            SellPriceDictionaryService = new SellPriceDictionaryService();
            SellPriceDictionaryService.Initialize();
            // before trade need to know a price
            TradeService = new TradeService();
            TradeService.Initialize();
            MoneyService = new MoneyService();
            MoneyService.Initialize();
            ProducerProductionDictionaryService = new ProducerProductionDictionaryService();
            ProducerProductionDictionaryService.Initialize();
            //
            ProductionDurationDictionaryService = new ProductionDurationDictionaryService();
            ProductionDurationDictionaryService.Initialize();
            SatietyDurationDictionaryService = new SatietyDurationDictionaryService();
            SatietyDurationDictionaryService.Initialize();
            // before visualize money amount need to know a money amount
            InventoryService = new InventoryService();
            InventoryService.Initialize();
            // before visualize inventory items amount need to know a inventory items amount
            UserInterfaceManager.Initialize();
        }
Пример #10
0
        /// 待打印转化为待确认
        private void BtnBack_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            GridView currentView   = gvTradeWaitPrint;     //取得当前展示交易的GridView
            int      totalRowCount = currentView.RowCount; //循环获取需要提交的Trade
            DataRow  currentRow    = null;

            WaitDialogForm waitFrm = new WaitDialogForm(Alading.Taobao.Constants.OPERATE_DB_DATA);

            for (int runner = 0; runner < totalRowCount; runner++)
            {
                currentRow = currentView.GetDataRow(runner);

                if (Convert.ToBoolean(currentRow["IsSelected"].ToString()))
                {
                    string curCustomTid = currentRow["CustomTid"].ToString();

                    int returnValue = TradeService.RebackCommonTrade(curCustomTid, LocalTradeStatus.SummitNotPrint, LocalTradeStatus.HasNotSummit);
                    switch (returnValue)
                    {
                    case SummitReturnType.Success:
                        SystemHelper.CreateFlowMessage(curCustomTid, "取消打印成功", "交易取消打印成功", "订单管理");
                        break;

                    case SummitReturnType.StatusChanged:
                        SystemHelper.CreateFlowMessage(curCustomTid, "取消打印失败", "交易状态已经改变", "订单管理");
                        break;
                    }
                }
            }

            waitFrm.Close();
            InitSelectTab();
        }
Пример #11
0
        //根据选中选项卡绑定数据
        private void InitSelectMainTab()
        {
            List <Alading.Entity.Trade> trades = null;
            GridControl currentGC = GetCurrentGC();
            GridView    currentGV = GetCurrentGV();

            switch (tabsMain.SelectedTabPageIndex)
            {
            //调用存储过程获取数据
            case 0:
                trades = TradeService.GetTradesByStatus(LocalTradeStatus.SummitNotPrint, TradeEnum.WAIT_SELLER_SEND_GOODS);
                break;

            case 1:
                trades = TradeService.GetTradesByStatus(LocalTradeStatus.Printed, TradeEnum.WAIT_SELLER_SEND_GOODS);
                break;

            case 2:
                trades = TradeService.GetTradesByStatus(LocalTradeStatus.WaitAssort, TradeEnum.WAIT_SELLER_SEND_GOODS);
                break;
                //case 3:
                //    trades = TradeService.GetTrade(p => p.LocalStatus == LocalTradeStatus.AllocateNotSent && p.status == TradeStatus.WAIT_SELLER_SEND_GOODS);
                //    break;
            }
            currentGC.DataSource = trades;
            currentGV.BestFitColumns();
            currentGC.ForceInitialize();
        }
Пример #12
0
        public IHttpActionResult FetchTradeViews(FilterCriteria filterCriteria)
        {
            log4net.Config.BasicConfigurator.Configure();
            log4net.ILog log = log4net.LogManager.GetLogger(typeof(Program));

            IEnumerable <Trade> trades;

            try
            {
                if (filterCriteria == null)
                {
                    throw new ArgumentNullException();
                }

                TradeService tradeService = new TradeService();
                var          tradeIds     = filterCriteria.TradeIds.Split(',').ToList();
                var          fields       = filterCriteria.Fields.Split(',').ToList();
                trades = tradeService.LoadTrade(tradeIds, fields, filterCriteria.Source);
            }
            catch (ArgumentException exception)
            {
                //Logging the exception using Log4Net for monitoring purpose.
                log.Error(exception.ToString());
                return(NotFound());
            }
            return(Ok(new TradeLoaderResponse(trades)));
        }
Пример #13
0
        //绑定数据到买家数据
        private void BuyerInforDetail(string customTid)
        {
            string buyerNick = TradeService.GetTrade(customTid).buyer_nick;
            List <Alading.Entity.Consumer> buyerList = ConsumerService.GetConsumer(p => p.nick == buyerNick);

            if (buyerList.Count > 0)
            {
                BuyerNick.Text = buyerNick;
                Birthday.Text  = (buyerList.First().birthday ?? DateTime.Parse(Alading.Taobao.Constants.DEFAULT_TIME)).ToString("yyyy-MM-dd");
                register.Text  = (buyerList.First().created ?? DateTime.Parse(Alading.Taobao.Constants.DEFAULT_TIME)).ToString("yyyy-MM-dd");
                lastLogin.Text = (buyerList.First().last_visit ?? DateTime.Parse(Alading.Taobao.Constants.DEFAULT_TIME)).ToString("yyyy-MM-dd");
                zip.Text       = buyerList.First().buyer_zip;
                if (buyerList.First().sex == "f")
                {
                    sex.SelectedIndex = 0;
                }
                else if (buyerList.First().sex == "m")
                {
                    sex.SelectedIndex = 1;
                }
                level.Text   = "信用等级:" + buyerList.First().level.ToString();
                score.Text   = "信用总分:" + buyerList.First().score.ToString();
                total.Text   = buyerList.First().buyer_total_num.ToString();
                goodNum.Text = buyerList.First().buyer_good_num.ToString();
                ((ILinearGauge)rating.Gauges[0]).Scales[0].Value = (float)buyerList.First().level * 90 / 20;
            }
        }
Пример #14
0
        public TradeServiceTests()
        {
            IShareService _ishareServiceMock = new ShareServiceFake(shareRepository.Object);

            _tradeRepositoryMock.Setup(p => p.Query()).Returns(populateTradeData().AsQueryable());
            _tradeService = new TradeService(_tradeRepositoryMock.Object, _ishareServiceMock);
        }
Пример #15
0
        public void ShouldUpdate()
        {
            using (var context = new AmfMoneyContext(_options))
            {
                context.Add(new Trade()
                {
                    OperationType = 'B'
                });

                context.SaveChanges();
            }

            using (var context = new AmfMoneyContext(_options))
            {
                var service = new TradeService(context);
                var trade   = context.Find <Trade>(1);
                trade.OperationType = 'S';
                service.Update(trade);
            }

            using (var context = new AmfMoneyContext(_options))
            {
                var trade = context.Find <Trade>(1);
                Assert.Equal('S', trade.OperationType);
            }
        }
Пример #16
0
        public async Task <CreateTransferResponseModel> SubmitUserTransfer(ApiSubmitUserTransferRequest request)
        {
            var currency = request.CurrencyId.HasValue
                                ? await CurrencyReader.GetCurrency(request.CurrencyId.Value).ConfigureAwait(false)
                                : await CurrencyReader.GetCurrency(request.Currency).ConfigureAwait(false);

            if (currency == null)
            {
                return new CreateTransferResponseModel {
                           Error = "Currency not found."
                }
            }
            ;

            var receiver = await UserReader.GetUserByName(request.UserName).ConfigureAwait(false);

            if (receiver == null)
            {
                return new CreateTransferResponseModel {
                           Error = "Receiver not found."
                }
            }
            ;

            var response = await TradeService.CreateTransfer(request.UserId.ToString(), new CreateTransferModel
            {
                CurrencyId   = currency.CurrencyId,
                Amount       = request.Amount,
                TransferType = TransferType.User,
                Receiver     = receiver.UserId
            }, true).ConfigureAwait(false);

            return(response);
        }
        public IHttpActionResult PostNewTrade(JObject jtrade)
        {
            log4net.Config.BasicConfigurator.Configure();
            log4net.ILog log         = log4net.LogManager.GetLogger(typeof(Program));
            Trade        tradeToSave = null;

            try
            {
                if (jtrade == null)
                {
                    throw new ArgumentNullException();
                }

                dynamic      trade        = jtrade;
                TradeService tradeService = new TradeService();
                tradeToSave = TradeParserFactory.GetTradeParser(trade.SourceApplication.Value).Parse(jtrade);
                var saved = tradeService.SaveTrade(tradeToSave);
                if (!saved)
                {
                    throw new EntryPointNotFoundException();
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.ToString());
                return(NotFound());
            }
            return(Ok(tradeToSave));
        }
Пример #18
0
        // This is a generic method for testing buy/sell.
        private void Trade_Test(Action <ITradeService, IStock, Decimal, Int32, DateTime> action, TradeIndicator indicator, Decimal expectedPrice, Int32 expectedQuantity)
        {
            Moq.Mock <ITradeRepository> mockTradeRepo = new Moq.Mock <ITradeRepository>();
            Moq.Mock <IStock>           mockStock     = new Moq.Mock <IStock>();
            mockStock.Setup(mock => mock.Symbol).Returns("ABC");

            ITrade   actualTrade       = null;
            IStock   expectedStock     = mockStock.Object;
            DateTime expectedTimestamp = DateTime.UtcNow;

            // Setup our mock dependency to listen for what we expect to happen and capture the trade created
            // so we can verify it.
            mockTradeRepo
            .Setup(mock => mock.Save(Moq.It.IsAny <ITrade>()))
            .Callback <ITrade>(trade =>
            {
                actualTrade = trade;     // Copy to unit test scope.
            })
            .Verifiable();

            // Run the action.
            ITradeService tradeService = new TradeService(mockTradeRepo.Object);

            action(tradeService, expectedStock, expectedPrice, expectedQuantity, expectedTimestamp);

            // Verify
            mockTradeRepo.Verify(x => x.Save(Moq.It.IsAny <ITrade>()), Moq.Times.Once);
            Assert.IsNotNull(actualTrade);
            Assert.AreEqual(expectedPrice, actualTrade.Price);
            Assert.AreEqual(expectedQuantity, actualTrade.Quantity);
            Assert.AreEqual(expectedTimestamp, actualTrade.TimeStamp);
            Assert.AreEqual(indicator, actualTrade.Indicator);
            Assert.ReferenceEquals(expectedStock, actualTrade.StockInformation);
        }
Пример #19
0
        public void CtorGivenAListOfStocksCreateStockManagerWithStocks()
        {
            var trades       = TestData.GetListOfTrades();
            var tradeService = new TradeService(trades);

            Assert.IsNotNull(tradeService.Trades);
        }
Пример #20
0
        public void ValidConstructor_Test()
        {
            Moq.Mock <ITradeRepository> mockTradeRepo = new Moq.Mock <ITradeRepository>();
            ITradeService tradeService = new TradeService(mockTradeRepo.Object);

            Assert.IsNotNull(tradeService);
        }
Пример #21
0
        public async Task <ApiResult <ApiSubmitOrderResponse> > SubmitOrder(string userId, string market, TradeType type, decimal amount, decimal price)
        {
            try
            {
                var result = await TradeService.QueueTrade(new CreateTradeModel
                {
                    UserId    = userId,
                    Amount    = amount,
                    TradeType = type,
                    Rate      = price,
                    Market    = market,
                    IsApi     = true
                });

                if (result.HasError)
                {
                    return(new ApiResult <ApiSubmitOrderResponse>(false, result.Error));
                }

                var apiResult = new ApiSubmitOrderResponse
                {
                    OrderId = result.TradeId,
                    Filled  = result.FilledTrades
                };
                return(new ApiResult <ApiSubmitOrderResponse>(true, apiResult));
            }
            catch (Exception ex)
            {
                return(new ApiResult <ApiSubmitOrderResponse>(ex));
            }
        }
Пример #22
0
        /// <summary>
        /// 支付方式
        /// </summary>
        public ActionResult PayMent()
        {
            var uid   = RequestHelper.GetValue("uid");
            var pid   = RequestHelper.GetValue("pid");
            var pwd   = RequestHelper.GetValue("pwd");
            var pcode = RequestHelper.GetValue("pcode");

            if (string.IsNullOrEmpty(uid) || string.IsNullOrEmpty(pid) || string.IsNullOrEmpty(pwd))
            {
                return(RedirectToAction("List", "Product"));
            }
            //判断服务是否已在运行
            var user      = UserCache.Cache.GetValue(uid);
            var IsRunning = SSService.IsRunning(user.Id);

            if (IsRunning)
            {
                return(View("PayMentResultNotice", new ResponseResult()
                {
                    Result = false, Info = "购买失败!请再服务过期后,再进行购买!"
                }));
            }
            var timestamp  = FormatHelper.ConvertDateTimeInt(DateTime.Now);               //时间戳
            var sign       = TradeService.ParameterSign(uid, pid, pwd, pcode, timestamp); //参数签名
            var alipaycode = TradeService.GetAlipayTransferCode(uid);                     //支付宝唯一支付码

            SessionHelper.SetValue("AlipayCode", alipaycode);
            ViewData["Uid"]       = uid;
            ViewData["Pid"]       = pid;
            ViewData["Pwd"]       = pwd;
            ViewData["Pcode"]     = pcode;
            ViewData["TimeStamp"] = timestamp;
            ViewData["Sign"]      = sign;
            return(View());
        }
Пример #23
0
        public async Task <IWriterResult <bool> > CreatePaidVote(string userId, CreatePaidVoteModel model)
        {
            if (!await VoteService.CheckVoteItems())
            {
                return(WriterResult <bool> .ErrorResult("The current vote round has ended."));
            }

            using (var context = DataContextFactory.CreateContext())
            {
                var settings = await context.VoteSetting.FirstOrDefaultNoLockAsync();

                if (settings == null)
                {
                    return(WriterResult <bool> .ErrorResult("VoteItem not found."));
                }

                if (model.VoteCount <= 0 || (settings.Price * model.VoteCount) <= 0)
                {
                    return(WriterResult <bool> .ErrorResult("Invalid vote amount."));
                }

                var voteItem = await context.VoteItem.FirstOrDefaultNoLockAsync(x => x.Id == model.VoteItemId);

                if (voteItem == null)
                {
                    return(WriterResult <bool> .ErrorResult("VoteItem not found."));
                }

                var transferResult = await TradeService.QueueTransfer(new CreateTransferModel
                {
                    UserId       = userId,
                    ToUser       = Constants.SystemVoteUserId,
                    CurrencyId   = settings.CurrencyId,
                    Amount       = model.VoteCount *settings.Price,
                    TransferType = TransferType.Vote
                });

                if (transferResult.HasError)
                {
                    return(WriterResult <bool> .ErrorResult(transferResult.Error));
                }

                var vote = new Entity.Vote
                {
                    Created    = DateTime.UtcNow,
                    Count      = model.VoteCount,
                    Type       = VoteType.Paid,
                    Status     = VoteStatus.Live,
                    UserId     = userId,
                    VoteItemId = model.VoteItemId
                };

                context.Vote.Add(vote);

                var contextResults = await context.SaveChangesWithLoggingAsync();

                return(WriterResult <bool> .ContextResult(contextResults, "Successfully added {0} vote(s) for {1}", model.VoteCount, voteItem.Name));
            }
        }
Пример #24
0
        public virtual void Audit(string id, JObject data)
        {
            var status  = data["status"].ToString();
            var comment = data["comment"].ToString();
            var result  = new TradeService().Audit(typeof(TMasterModel).Name, id, status, comment);

            TradeHelper.ThrowHttpExceptionWhen(result < 0, "单据审核失败[BillNo={0}],请重试或联系管理员!", id);
        }
Пример #25
0
        // GET: Trade
        public ActionResult Index()
        {
            var userId  = Guid.Parse(User.Identity.GetUserId());
            var service = new TradeService(userId);
            var model   = service.GetTrades();

            return(View(model));
        }
Пример #26
0
 public TradeOperateDaily(string customTid)
 {
     InitializeComponent();
     _customTid           = customTid;
     txtCustomTid.Text    = _customTid;
     txtTradeTitle.Text   = TradeService.GetTrade(_customTid).title;
     txtOperaterName.Text = Alading.Utils.SystemHelper.User.nick;
 }
Пример #27
0
        public virtual void Audit(string id, JObject data)
        {
            var status  = data["status"].ToString();
            var comment = data["comment"].ToString();
            var result  = new TradeService().Audit("trade_trailer", id, status, comment);

            TradeHelper.ThrowHttpExceptionWhen(result < 0, "单据审核失败[Jobno={0}],请重试或联系管理员!", id);
        }
Пример #28
0
 public TradeController(TradeService tradeService, UserManager <IdentityUser> userManager,
                        InstrumentService instrumentService, InstrumentMarketDataService instrumentMarketDataService)
 {
     _tradeService          = tradeService;
     _userManager           = userManager;
     _instrumentService     = instrumentService;
     _instrumentDataService = instrumentMarketDataService;
 }
        public async Task <IWriterResult> DustBalance(string userId, int currencyId)
        {
            try
            {
                var symbol      = "";
                var available   = 0m;
                var currentUser = new Guid(userId);
                using (var context = ExchangeDataContextFactory.CreateContext())
                {
                    var balance = await context.Balance
                                  .Include(x => x.Currency)
                                  .Where(b => b.UserId == currentUser && b.CurrencyId == currencyId)
                                  .FirstOrDefaultNoLockAsync().ConfigureAwait(false);

                    if (balance == null || balance.Total <= 0)
                    {
                        return(new WriterResult(false, "No funds found to dust."));
                    }

                    if (balance.HeldForTrades > 0)
                    {
                        return(new WriterResult(false, "You have funds held for trades, please cancel any open orders before dusting balance."));
                    }

                    if (balance.PendingWithdraw > 0)
                    {
                        return(new WriterResult(false, "You have funds pending withdrawal, please cancel/confirm any pending withdrawals before dusting balance."));
                    }

                    if (balance.Unconfirmed > 0)
                    {
                        return(new WriterResult(false, "You have unconfirmed deposits, please wait for full confirmations on the pending deposits before dusting balance."));
                    }

                    symbol    = balance.Currency.Symbol;
                    available = balance.Available;
                }

                var result = await TradeService.CreateTransfer(userId, new CreateTransferModel
                {
                    Amount       = available,
                    CurrencyId   = currencyId,
                    Receiver     = Constant.SYSTEM_USER_DUSTBIN.ToString(),
                    TransferType = TransferType.DustBin
                }).ConfigureAwait(false);

                if (result.IsError)
                {
                    return(new WriterResult(false, result.Error));
                }

                return(new WriterResult(true, $"Successfully sent {available:F8} {symbol} to the dustbin."));
            }
            catch (Exception)
            {
                return(new WriterResult(false));
            }
        }
Пример #30
0
        /// 订单锁定
        private void Lock_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            DataRow row = null;
            /*用于判断点击锁定按钮前是否选定*/
            int flag = 0;
            List <Alading.Entity.Trade> tradeList = new List <Alading.Entity.Trade>();
            /*存放处理的行号*/
            List <int> rowHandle = new List <int>();

            for (int handle = 0; handle < GetCurrentTradeGV().RowCount; handle++)
            {
                row = gvTradeWaitConfirm.GetDataRow(handle);
                if (Convert.ToBoolean(row["IsSelected"]))
                {
                    if (row["LockedUserName"].ToString() == null || row["LockedUserName"].ToString() == string.Empty || row["LockedUserName"].ToString() == "未锁定")
                    {
                        Alading.Entity.Trade trade = TradeService.GetTrade(row["CustomTid"].ToString());
                        trade.LockedUserName = SystemHelper.User.nick;
                        trade.LockedUserCode = SystemHelper.User.UserCode;
                        trade.LockedTime     = System.DateTime.Now;
                        tradeList.Add(trade);
                        rowHandle.Add(handle);
                    }
                    else
                    {
                        DevExpress.XtraEditors.XtraMessageBox.Show("'" + row["receiver_name"] + "' 等收货人的交易" + SystemHelper.User.nick + "锁定,不能再锁定!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
                else
                {
                    flag++;
                }
            }
            /*判断是否点击锁定前有无交易选中*/
            if (flag >= gvTradeWaitConfirm.RowCount)
            {
                DevExpress.XtraEditors.XtraMessageBox.Show("没有选择需要锁定的交易,请检查!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            /*修改数据成功则修改界面上的值*/

            if (DialogResult.OK == DevExpress.XtraEditors.XtraMessageBox.Show("确定要锁定所选交易?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information))
            {
                if (TradeService.UpdateTrade(tradeList) == ReturnType.Success)
                {
                    foreach (int handle in rowHandle)
                    {
                        row = gvTradeWaitConfirm.GetDataRow(handle);
                        row["IsSelected"]     = false;
                        row["LockedUserName"] = SystemHelper.User.nick;
                    }
                }
                // 添加一条添加赠品流程信息到交易流程
                Alading.Utils.SystemHelper.CreateFlowMessage(row["CustomTid"].ToString(), "交易锁定", "交易锁定:" + row["title"].ToString() + "锁单时间:" + row["LockedTime"].ToString(), "交易锁定");
            }
        }
Пример #31
0
 public virtual void Audit(string id, JObject data)
 {
     var status = data["status"].ToString();
     var comment = data["comment"].ToString();
     var result = new TradeService().Audit("trade_trailer", id, status, comment);
     TradeHelper.ThrowHttpExceptionWhen(result < 0, "单据审核失败[Jobno={0}],请重试或联系管理员!", id);
 }
Пример #32
0
 private void BindPrice()
 {
     var list_price = new TradeService().FindNewDetails(20);
     this.Repeater_price.DataSource = list_price;
     this.Repeater_price.DataBind();
 }