Exemplo n.º 1
0
        private void OnInterceptExecuted(InterceptInfo input, Exception ex)
        {

        }
Exemplo n.º 2
0
        private async Task InterceptTrade(InterceptInfo info)
        {
            SuplierInfo supplier = info.supplier;
            string spu = info.spuId;
            TopTrade trade = info.trade;
            Statistic statistic = info.statistic;
            AppendText("将拦截订单{0},买家:{1}", trade.Tid, trade.BuyerNick);
            trade.Intercept = true;
            AppDatabase.db.TopTrades.Update(trade);
            var product = AppDatabase.db.ProductItems.FindById(trade.NumIid);

            try
            {
                if (!await this.SetProductProfit(product, (x) => 0, forceModify: true))
                {
                    statistic.InterceptFailed++;
                    AppDatabase.db.Statistics.Upsert(statistic, statistic.Id);
                    OnStatisticUpdate(statistic);
                }
                else
                {
                    AppendText("商品{0}改价已提交", trade.NumIid);

                    //1分钟后关单
                    await Task.Delay(1000 * 60 - 500);

                    AppendText("{0}关闭交易...", trade.Tid);
                    await CloseTradeIfPossible(trade.Tid);
                }
            }
            catch (Exception ex)
            {
                AppendException(ex);
            }
        }