Esempio n. 1
0
        /// <summary>
        ///     购买通知交易
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void btn_PurchaseTrisfer_Click(object sender, EventArgs e)
        {
            //
            try
            {
                this.lblmsg6.Text = "正在消耗........";
                this.btn_PurchaseTrisfer.Enabled = false;
                BrokeredMessage brokeredMessage;
                this.txb_PurchaseTrisferFnums.Text = "0";
                this.txb_PurchaseTrisferSnums.Text = "0";
                do
                {
                    brokeredMessage = this.messageReiceiverPurchase.Receive();
                    if (brokeredMessage != null)
                    {
                        string  batchBookCreditInfos = brokeredMessage.GetBody <string>();
                        JObject jObject = JObject.Parse(batchBookCreditInfos);
                        if (jObject == null)
                        {
                            continue; //MessageData
                        }
                        //转json
                        TifisfalPurchaseRequestModel tifisfalPurchaseRequestModel = jObject["MessageData"].ToString().FromJson <TifisfalPurchaseRequestModel>();
                        //重试5次执行数据
                        for (int i = 0; i < 5; i++)
                        {
                            Tuple <bool, string> result = await YemApiService.PurchaseSendToTrader(this.loadAppSettings.AssetApiUrl, tifisfalPurchaseRequestModel, "PurchaseSendToTraderLogs");

                            if (result.Item1)
                            {
                                this.UpdateTxtInfos(this.txb_PurchaseTrisferSnums);
                                break;
                            }
                            else
                            {
                                if (i == 4)
                                {
                                    this.UpdateTxtInfos(this.txb_PurchaseTrisferFnums);
                                    //记录下来数据
                                    Logger.LoadData(@"PurchaseSendToTraderInfos\ErrorDeadLineInfos.txt", tifisfalPurchaseRequestModel.ToJson());
                                    Logger.LoadData(@"PurchaseSendToTraderInfos\ErrorDeadLineInfos.txt", "\r\n");
                                }
                            }
                        }
                    }
                } while (brokeredMessage != null);
                this.btn_PurchaseTrisfer.Enabled = true;
                MessageBox.Show("本轮次执行完毕");
            }
            catch (Exception exception)
            {
                this.lblmsg6.Text = "发生一个错误" + exception.Message;
                this.btn_PurchaseTrisfer.Enabled = true;
                Logger.LoadData(@"PurchaseSendToTraderInfos\Errors.txt", exception.Message);
            }
        }
Esempio n. 2
0
        //购买债转通知交易系统
        private async Task <Tuple <bool, string> > PurchaseSendToTrader(TifisfalPurchaseRequestModel request)
        {
            HttpResponseMessage httpResponseMesage = new HttpResponseMessage();

            try
            {
                //DebtForBank/SendAdvanceDebt
                httpResponseMesage = await this.httpClient.PostAsJsonAsync($"{this.loadAppSettings.AssetApiUrl}MessageToTifisfal/PurchaseSendToTrader", request);

                CommonResult <bool> response = await httpResponseMesage.Content.ReadAsAsync <CommonResult <bool> >();

                if (response.Result)
                {
                    return(new Tuple <bool, string>(true, "成功"));
                }
                return(new Tuple <bool, string>(false, response.Message));
            }
            catch (Exception ex)
            {
                //log记录日志
                Logger.LoadData(@"GetJson\Error.txt", ex.Message + "---------" + await httpResponseMesage.Content.ReadAsStringAsync());
                return(new Tuple <bool, string>(false, ex.Message));
            }
        }
        /// <summary>
        ///     批量修改用户购买表
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void btn_batchUpdate_Click_1(object sender, EventArgs e)
        {
            try
            {
                List <string> userIds = this.txb_handleUserIds.Text.Trim().Split(new[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries).Distinct().ToList();
                if (userIds.Count == 0)
                {
                    MessageBox.Show("请输入需要执行的asstids");
                    return;
                }
                this.lbl_showmsg.Text        = "正在准备数据.......";
                this.btn_batchUpdate.Enabled = false;
                //购买订单数据
                foreach (string userId in userIds)
                {
                    this.txb_CurrentUserId.Text = userId;
                    List <YemUserProductInfo> listYemUserProductInfos = this.GetYemUserOrderInfo(userId);
                    //获取所有的数据
                    List <YemUserProductInfo> listYemUserProductInfosOne = listYemUserProductInfos.Where(x => x.RemainingAmount < 0).ToList();

                    foreach (YemUserProductInfo yemUserProductInfo in listYemUserProductInfosOne)
                    {
                        // Logger.LoadData(@"UpdateYemUserProductInfo\Error_" + userId + ".txt", new { yemUserProductInfo.OrderId, yemUserProductInfo.RemainingAmount }.ToJson());
                        long resetPurchaseAmount = Math.Abs(yemUserProductInfo.RemainingAmount);
                        //逐个处理
                        List <YemUserProductInfo> listYemUserProductInfosTwo = listYemUserProductInfos.Where(x => x.RemainingAmount > 0).ToList();
                        long dealAmount = 0;
                        foreach (YemUserProductInfo yemItem in listYemUserProductInfosTwo)
                        {
                            if (yemItem.RemainingAmount > 0)
                            {
                                if (resetPurchaseAmount == 0)
                                {
                                    break;
                                }
                                if (yemItem.RemainingAmount > resetPurchaseAmount)
                                {
                                    yemItem.RemainingAmount -= resetPurchaseAmount;
                                    dealAmount          = resetPurchaseAmount;
                                    resetPurchaseAmount = 0;
                                }
                                else
                                {
                                    dealAmount              = yemItem.RemainingAmount;
                                    resetPurchaseAmount    -= yemItem.RemainingAmount;
                                    yemItem.RemainingAmount = 0;
                                }
                            }
                            TextPurchase txtPurchase = new TextPurchase
                            {
                                OldOrderId = yemUserProductInfo.OrderId,
                                NewOrderId = yemItem.OrderId,
                                Amout      = dealAmount
                            };
                            Logger.LoadData(@"UpdateYemUserProductInfo\" + userId + ".txt", txtPurchase.ToJson());
                            string sqlStr   = yemItem.RemainingAmount == 0 ? ",Status=1" : "";
                            string sql      = "update YEMUserProducts_Copy set RemainingAmount -=" + dealAmount + " ,Allocated+=" + dealAmount + " " + sqlStr + " where OrderId='" + yemItem.OrderId + "';update YEMUserProducts_Copy set RemainingAmount+=" + dealAmount + ",Allocated-=" + dealAmount + "" + sqlStr + " where OrderId='" + yemUserProductInfo.OrderId + "'";
                            int    dbResult = SqlHelper.SqlHelper.ExecuteNoneQuery(sql);
                            if (dbResult > 0)
                            {
                                TifisfalPurchaseRequestModel triTifisfalPurchaseRequestModel = new TifisfalPurchaseRequestModel
                                {
                                    AllotAmount              = dealAmount,
                                    IsReturnToAccount        = false,
                                    ResultTime               = DateTime.UtcNow.ToChinaStandardTime(),
                                    UserIdentifier           = yemItem.UserId,
                                    YemAssetRecordIdentifier = Guid.NewGuid().ToGuidString(),
                                    YemOrderIdentifier       = yemItem.OrderId
                                };
                                var result = await this.PurchaseSendToTrader(triTifisfalPurchaseRequestModel);

                                if (!result.Item1)
                                {
                                    Logger.LoadData(@"UpdateTrisferYemUserProductInfo\Error_" + userId + ".txt", triTifisfalPurchaseRequestModel.ToJson());
                                }
                                this.txb_CurrentAssetIdNums.Text = (Convert.ToInt32(this.txb_CurrentAssetIdNums.Text) + 1).ToString();
                            }
                            else
                            {
                                Logger.LoadData(@"UpdateDbYemUserProductInfo\Error_" + userId + ".txt", new { yemItem.OrderId }.ToJson());
                            }
                        }
                    }
                }
                this.btn_batchUpdate.Enabled = true;
                this.lbl_showmsg.Text        = "执行完毕";
            }
            catch (Exception exception)
            {
                this.btn_batchUpdate.Enabled = true;
                this.lbl_showmsg.Text        = "发生错误:" + exception.Message;
            }
        }
Esempio n. 4
0
        /// <summary>
        ///     通知交易购买
        /// </summary>
        /// <returns></returns>
        public async Task SetRedisNotifyPurchaseAsync(TifisfalPurchaseRequestModel model, string deptId)
        {
            await this.database.HashSetToCacheAsync("TifisfalPurchaseRequestModels", "List", deptId, model, TimeSpan.MaxValue);

            //await this.database.SetDataToCacheAsync("NotifyPurchaseRequest", orderId, status.ToJson(), TimeSpan.MaxValue);
        }
Esempio n. 5
0
        //购买债转通知交易系统
        public static async Task <Tuple <bool, string> > PurchaseSendToTrader(string url, TifisfalPurchaseRequestModel request, string logFolderName)
        {
            HttpResponseMessage httpResponseMesage = new HttpResponseMessage();

            try
            {
                //DebtForBank/SendAdvanceDebt
                httpResponseMesage = await InitialHttpClient().PostAsJsonAsync($"{url}MessageToTifisfal/PurchaseSendToTrader", request);

                CommonResult <bool> response = await httpResponseMesage.Content.ReadAsAsync <CommonResult <bool> >();

                if (response.Result)
                {
                    return(new Tuple <bool, string>(true, "成功"));
                }
                return(new Tuple <bool, string>(false, response.Message));
            }
            catch (Exception ex)
            {
                //log记录日志
                Logger.LoadData(Path.Combine(logFolderName, "Error.txt"), ex.Message + "---------" + await httpResponseMesage.Content.ReadAsStringAsync() + "----" + request.ToJson());
                return(new Tuple <bool, string>(false, ex.Message));
            }
        }