| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222 |
- using GalaSoft.MvvmLight.Command;
- using GalaSoft.MvvmLight.Ioc;
- //----------------------------------------------------------------
- //Module Name: $safeprojectname$
- //Purpose:
- //CopyRight: Muchinfo
- //History:
- //----------------------------------------------------------------
- //DateTime 2016/6/21 13:38:33
- //Author
- //Description Create
- //----------------------------------------------------------------
- using GalaSoft.MvvmLight.Messaging;
- using Muchinfo.MTPClient.Data;
- using Muchinfo.MTPClient.Data.Enums;
- using Muchinfo.MTPClient.Data.Model.Account;
- using Muchinfo.MTPClient.Data.Model.Sale;
- using Muchinfo.MTPClient.Infrastructure.Helpers;
- using Muchinfo.MTPClient.Infrastructure.Utilities;
- using Muchinfo.MTPClient.Infrastructure.Windows;
- using Muchinfo.MTPClient.IService;
- using System.Collections.Generic;
- using System.Linq;
- using System.Windows;
- namespace Muchinfo.MTPClient.Sale.ViewModels
- {
- /// <summary>
- /// 配号中签
- /// </summary>
- public class DistributeBallotViewModel : QueryPanelModelBase
- {
- #region "=========私有成员/Private Data Members"
- protected ISaleService _saleService;
- #endregion "Private Data Members"
- #region "=========构造函数/Constructor/Initialization"
- public DistributeBallotViewModel()
- {
- this._saleService = SimpleIoc.Default.GetInstance<ISaleService>();
- }
- #endregion "Constructor/Initialization"
- #region "=========接口重写/Interface implementation Or override"
- public override void RegisterMessage()
- {
- RefreshCommand.Execute(null);
- MessengerHelper.DefaultUnregister<TradeAccount>(this, MessengerTokens.OrderNotify);
- MessengerHelper.DefaultRegister<TradeAccount>(this, MessengerTokens.OrderNotify, (e) =>
- {
- RefreshCommand.Execute(null);
- });
- }
- public override void UnRegisterMessage()
- {
- MessengerHelper.DefaultUnregister<TradeAccount>(this, MessengerTokens.OrderNotify);
- }
- public override void RefreshContent()
- {
- IsBusy = true;
- var queryCommonParams = new List<QueryCommonParam>();
- var accountid = UserManager.CurrentTradeAccount.AccountId;
- //if (UserManager.CurrentTradeAccount.FundsAccounts != null && UserManager.CurrentTradeAccount.FundsAccounts.Any())
- //{
- // accountid = UserManager.CurrentTradeAccount.FundsAccounts[0].AccountId;
- //}
- queryCommonParams.Add(new QueryCommonParam() { ParamKey = "accountId", ParamValue = accountid + string.Empty });
- queryCommonParams.Add(new QueryCommonParam() { ParamKey = "Status", ParamValue = (int)eCommonResult.COMMONRESULT_OK + string.Empty });
- _saleService.QueryAccountDistributeBallot(queryCommonParams, MarketOrderSuccess, QueryErrorCallback);
- }
- #endregion "Interface implementation Or override"
- #region "=========公共属性/Public Properties To Get/Set "
- #region 数据源
- private List<DistributeBallot> _itemSource;
- public List<DistributeBallot> ItemSource
- {
- get { return _itemSource; }
- set { Set(() => ItemSource, ref _itemSource, value); }
- }
- #endregion
- #region 当前选择配号中签
- private DistributeBallot _currentDistributeBallotItem;
- /// <summary>
- /// 当前选择配号中签
- /// </summary>
- public DistributeBallot CurrentDistributeBallotItem
- {
- get
- {
- return _currentDistributeBallotItem;
- }
- set
- {
- Set(() => CurrentDistributeBallotItem, ref _currentDistributeBallotItem, value);
- }
- }
- #endregion
- #region 是否显示查看详细
- private Visibility _isVisibility_CheckSeeMoreDetail = Visibility.Collapsed;
- /// <summary>
- /// 是否显示查看详细
- /// </summary>
- public Visibility IsVisibility_CheckSeeMoreDetail
- {
- get
- {
- return _isVisibility_CheckSeeMoreDetail;
- }
- set
- {
- Set(() => IsVisibility_CheckSeeMoreDetail, ref _isVisibility_CheckSeeMoreDetail, value);
- }
- }
- #endregion
- #endregion "Public Properties To Get/Set "
- #region "=========公共命令/Public Commands"
- #region 查看详情
- private RelayCommand<DistributeBallot> _seeMoreDetailCommand;
- /// <summary>
- /// 查看详情
- /// </summary>
- public RelayCommand<DistributeBallot> SeeMoreDetailCommand
- {
- get
- {
- return _seeMoreDetailCommand
- ?? (_seeMoreDetailCommand = new RelayCommand<DistributeBallot>(
- p =>
- {
- MessengerHelper.DefaultSend(CurrentDistributeBallotItem, MessengerTokens.DistributeBallotDetail);
- }, CheckSeeMoreDetail));
- }
- }
- #endregion
- #endregion "Public Commands"
- #region "=========私有方法/Private Methods"
- protected void MarketOrderSuccess(List<DistributeBallot> orders)
- {
- #region 重构数据源
- //多个中签尾号,相同委托单号,只显示一个,中签尾号以逗号隔开
- Dictionary<string, DistributeBallot> dicList = new Dictionary<string, DistributeBallot>();
- List<DistributeBallot> FilterDistributeBallotList = new List<DistributeBallot>();
- if (orders != null && orders.Any())
- {
- string orderid = string.Empty;
- string winTailNo = string.Empty;
- foreach (var item in orders.OrderBy(x => x.OrderId))
- {
- if (orderid == string.Empty)
- {
- orderid = item.OrderId.ToString();
- winTailNo = item.WINTAILNO;
- dicList.Add(item.OrderId.ToString(), item);
- }
- else if (orderid == item.OrderId.ToString())
- {
- item.WINTAILNO = winTailNo = item.WINTAILNO + "," + winTailNo;
- dicList.Remove(item.OrderId.ToString());
- dicList.Add(item.OrderId.ToString(), item);
- }
- else if (orderid != item.OrderId.ToString())
- {
- orderid = item.OrderId.ToString();
- winTailNo = item.WINTAILNO;
- dicList.Add(item.OrderId.ToString(), item);
- }
- }
- }
- if (dicList != null && dicList.Any())
- {
- foreach (var item in dicList)
- {
- FilterDistributeBallotList.Add(item.Value);
- }
- }
- #endregion
- ItemSource = FilterDistributeBallotList.OrderByDescending((item) => item.OrderTime).ToList();
- IsBusy = false;
- }
- #endregion "Private Methods"
- #region "=========其它方法/Other Methods"
- /// <summary>
- /// 检查是否可查看详细
- /// </summary>
- /// <returns></returns>
- private bool CheckSeeMoreDetail(DistributeBallot order)
- {
- bool result = false;
- IsVisibility_CheckSeeMoreDetail = Visibility.Collapsed;
- if (this.CurrentDistributeBallotItem != null)
- {
- IsVisibility_CheckSeeMoreDetail = Visibility.Visible;
- result = true;
- }
- return result;
- }
- #endregion "Other Methods"
-
- }
- }
|