| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- //----------------------------------------------------------------
- //Module Name: $safeprojectname$
- //Purpose:
- //CopyRight: Muchinfo
- //History:
- //----------------------------------------------------------------
- //DateTime 2016/10/25 15:25:09
- //Author
- //Description Create
- //----------------------------------------------------------------
- using GalaSoft.MvvmLight.Command;
- using GalaSoft.MvvmLight.Ioc;
- using Muchinfo.MTPClient.Data;
- using Muchinfo.MTPClient.Data.Enums;
- using Muchinfo.MTPClient.Data.Model.Account;
- using Muchinfo.MTPClient.Infrastructure.MessageBox;
- using Muchinfo.MTPClient.Infrastructure.Helpers;
- using Muchinfo.MTPClient.Infrastructure.Utilities;
- using Muchinfo.MTPClient.IService;
- using Muchinfo.MTPClient.Resources;
- namespace Muchinfo.MTPClient.Account.ViewModels
- {
- public class TaAmountLogViewModel : RegisterMessageBase
- {
- public bool IsQueryHistory
- {
- get;set;
- }
- /// 查询开始时间
- private DateTime _startDateTime;
- /// <summary>
- /// 查询开始时间
- /// </summary>
- public DateTime StartDateTime
- {
- get { return _startDateTime; }
- set
- {
- Set(() => StartDateTime, ref _startDateTime, new DateTime(value.Year, value.Month, value.Day, 0, 0, 0));
- }
- }
- /// 查询结束时间
- private DateTime _endDateTime;
- /// <summary>
- /// 查询结束时间
- /// </summary>
- public DateTime EndDateTime
- {
- get { return _endDateTime; }
- set
- {
- Set(() => EndDateTime, ref _endDateTime, new DateTime(value.Year, value.Month, value.Day, 23, 59, 59));
- }
- }
- private List<AccountAmountLog> _amountLogList;
- public List<AccountAmountLog> AmountLogList
- {
- get { return _amountLogList; }
- set { Set(() => AmountLogList, ref _amountLogList, value); }
- }
-
- public TaAmountLogViewModel()
- {
- _orderService = SimpleIoc.Default.GetInstance<IOrderService>();
- DateTime time = ApplicationParameter.ServerTimeNow;
- //this.StartDateTime = time.AddDays(1 - time.Day);
- this.StartDateTime = time.AddDays(-7);
- this.EndDateTime = time;
- MessengerHelper.DefaultUnregister<ulong>(this, MessengerTokens.ShowTaAmountLogByCapitalAccount);
- MessengerHelper.DefaultRegister<ulong>(this, MessengerTokens.ShowTaAmountLogByCapitalAccount, (e) =>
- {
- //显示对应资金账户的数据信息
- QueryAmountLog(e);
- });
-
- }
- public RelayCommand QueryCommand
- {
- get
- {
- return new RelayCommand(() =>
- {
- if (Vailed())
- {
- QueryAmountLog(UserManager.CurrentTradeAccount.FundsAccountId, IsQueryHistory);
- }
- });
- }
- }
- /// <summary>
- /// Queries the amount log.
- /// </summary>
- /// <param name="accountid">The accountid.</param>
- /// <param name="isHistory">if set to <c>true</c> [is history].</param>
- public void QueryAmountLog(ulong accountid, bool isHistory = false)
- {
- if (IsBusy) return;
- IsBusy = true;
- var queryCommons = new List<QueryCommonParam>();
- queryCommons.Add(new QueryCommonParam()
- {
- ParamKey = "accountId",
- ParamValue = accountid + string.Empty
- });
- if (isHistory)
- {
- queryCommons.Add(new QueryCommonParam()
- {
- ParamKey = "startDate",
- ParamValue = StartDateTime.ToString("yyyy-MM-dd")
- });
- queryCommons.Add(new QueryCommonParam()
- {
- ParamKey = "endDate",
- ParamValue = EndDateTime.ToString("yyyy-MM-dd HH:mm:ss")
- });
- }
- queryCommons.Add(new QueryCommonParam() // 90926 2.资金流水记录中,仅保留出入金记录,其他类型的流水都不显示;
- {
- ParamKey = "operatetype",
- ParamValue = "101,103",
- });
- _orderService.QueryTaAmountLog(isHistory, queryCommons, QueryAmountLogCallBack,
- QueryErrorCallback);
- }
- private void QueryAmountLogCallBack(List<AccountAmountLog> amountQueryList)
- {
- IsBusy = false;
- this.AmountLogList = amountQueryList;
- }
- public override void QueryErrorCallback(ErrorEntity errorEntity)
- {
- IsBusy = false;
- System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- {
- ErrorManager.ShowReturnError(errorEntity, Client_Resource.APP_Tips, false);
- }));
- }
- //注册消息
- public override void RegisterMessage()
- {
- RefreshContent();
- }
- public override void RefreshContent()
- {
- QueryCommand.Execute(null);
- }
- /// <summary>
- /// 数据验证
- /// </summary>
- /// <returns></returns>
- private bool Vailed()
- {
- if (StartDateTime > EndDateTime)
- {
- MessageBoxHelper.ShowInfo(Muchinfo.MTPClient.Resources.Client_Resource.DateTimeVaided_StartEnd, Muchinfo.MTPClient.Resources.Client_Resource.Models_Tips, true);
- return false;
- }
- else if ((EndDateTime - StartDateTime).Days > 30)
- {
- MessageBoxHelper.ShowInfo(Muchinfo.MTPClient.Resources.Client_Resource.DateTimeVaided_Over30days, Muchinfo.MTPClient.Resources.Client_Resource.Models_Tips, true);
- return false;
- }
- return true;
- }
-
- }
- }
|